Kaynağa Gözat

查询专利号带筛选 2022/3/16

lwhhszx 2 yıl önce
ebeveyn
işleme
ebf244c0ab
27 değiştirilmiş dosya ile 844 ekleme ve 35 silme
  1. 1 2
      PAS/src/main/java/cn/cslg/pas/common/model/QueryPatentVO.java
  2. 47 0
      PAS/src/main/java/cn/cslg/pas/common/model/dto/ProductPatentDTO.java
  3. 1 1
      PAS/src/main/java/cn/cslg/pas/common/model/vo/ProductCategoryTrendVO.java
  4. 1 1
      PAS/src/main/java/cn/cslg/pas/common/model/vo/TaskParams.java
  5. 1 0
      PAS/src/main/java/cn/cslg/pas/common/model/vo/TaskVO.java
  6. 6 0
      PAS/src/main/java/cn/cslg/pas/common/utils/Response.java
  7. 10 0
      PAS/src/main/java/cn/cslg/pas/controller/PatentController.java
  8. 2 2
      PAS/src/main/java/cn/cslg/pas/controller/ProductCategoryController.java
  9. 72 0
      PAS/src/main/java/cn/cslg/pas/controller/ProductPatentController.java
  10. 1 0
      PAS/src/main/java/cn/cslg/pas/controller/ProjectFieldOptionController.java
  11. 0 1
      PAS/src/main/java/cn/cslg/pas/controller/ProjectImportController.java
  12. 3 3
      PAS/src/main/java/cn/cslg/pas/controller/TaskController.java
  13. 2 0
      PAS/src/main/java/cn/cslg/pas/domain/Task.java
  14. 3 0
      PAS/src/main/java/cn/cslg/pas/domain/asso/AssoPatentStructure.java
  15. 9 1
      PAS/src/main/java/cn/cslg/pas/mapper/AssoStructurePatentMapper.java
  16. 28 0
      PAS/src/main/java/cn/cslg/pas/mapper/asso/AssoProductPatentMapper.java
  17. 1 1
      PAS/src/main/java/cn/cslg/pas/service/IProductCategoryService.java
  18. 101 0
      PAS/src/main/java/cn/cslg/pas/service/PatentService.java
  19. 2 0
      PAS/src/main/java/cn/cslg/pas/service/ProjectImportService.java
  20. 5 2
      PAS/src/main/java/cn/cslg/pas/service/ProjectService.java
  21. 14 5
      PAS/src/main/java/cn/cslg/pas/service/TaskService.java
  22. 80 1
      PAS/src/main/java/cn/cslg/pas/service/UploadPatentBatchService.java
  23. 175 0
      PAS/src/main/java/cn/cslg/pas/service/asso/AssoProductPatentService.java
  24. 41 0
      PAS/src/main/java/cn/cslg/pas/service/asso/AssoStructurePatentService.java
  25. 57 15
      PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java
  26. 178 0
      PAS/src/main/resources/mapper/AssoProductPatentMapper.xml
  27. 3 0
      PAS/src/main/resources/mapper/TaskMapper.xml

+ 1 - 2
PAS/src/main/java/cn/cslg/pas/common/model/QueryPatentVO.java

@@ -14,6 +14,7 @@ import java.util.List;
  */
 @Data
 public class QueryPatentVO extends BaseVO {
+    private Integer productId;
     //专题库ID
     private Integer projectId;
     //RMS导入ID
@@ -22,8 +23,6 @@ public class QueryPatentVO extends BaseVO {
     private List<String> patentNos;
     // 去除的专利号
     private List<String> notInPatentNos;
-    //条件专利号
-    private List<String> conPatentNos;
     //申请人名字
     private String applicationName;
     //权利人名字

+ 47 - 0
PAS/src/main/java/cn/cslg/pas/common/model/dto/ProductPatentDTO.java

@@ -0,0 +1,47 @@
+package cn.cslg.pas.common.model.dto;
+
+import cn.cslg.pas.common.model.vo.BaseVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ProductPatentDTO extends BaseVO {
+
+    private Integer productId;
+    //专利号
+    private List<String> patentNos;
+    // 去除的专利号
+    private List<String> notInPatentNos;
+    //申请人名字
+    private String applicationName;
+    //权利人名字
+    private String obligeeName;
+
+    private Integer startNumber;
+
+    private Integer endNumber;
+
+    private String orderType;
+
+    private String orderItem;
+
+    @Schema(description = "专利号")
+    private String patentNo;
+
+    @Schema(description = "申请号")
+    private String applicationNo;
+
+    @Schema(description = "IPC分类号")
+    private String numberIpc;
+    @Schema(description = "CPC分类号")
+    private String numberCpc;
+    @Schema(description = "UPC分类号")
+    private String numberUpc;
+    @Schema(description = "摘要")
+    private String abstractStr;
+    @Schema(description = "标题")
+    private String patentName;
+    private Integer isIn;
+}

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/common/model/vo/ProductCategoryTrendVO.java

@@ -27,7 +27,7 @@ public class ProductCategoryTrendVO implements Serializable {
         /**
          * 时间(季度或者月份)
          */
-        private String marketData;
+        private String marketDate;
 
         /**
          * 销售额

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/common/model/vo/TaskParams.java

@@ -23,7 +23,7 @@ public class TaskParams implements Serializable {
     private String oldName;
     private Integer total;
     private Integer index;
-
+    private Integer productId;
     public TaskParams() {
 
     }

+ 1 - 0
PAS/src/main/java/cn/cslg/pas/common/model/vo/TaskVO.java

@@ -9,4 +9,5 @@ public class TaskVO extends BaseVO {
     private Integer type;
     private String createName;
     private String projectName;
+    private Integer productId;
 }

+ 6 - 0
PAS/src/main/java/cn/cslg/pas/common/utils/Response.java

@@ -19,6 +19,12 @@ public class Response {
         return JsonUtils.objectToJson(response);
     }
 
+    public static String successBut(Object data) {
+        Response response = new Response();
+        response.setCode(201);
+        response.setData(data);
+        return JsonUtils.objectToJson(response);
+    }
     /**
      * 陈宇 ↓ 直接返回对象(前台默认显示为jsonResult格式对象)
      */

+ 10 - 0
PAS/src/main/java/cn/cslg/pas/controller/PatentController.java

@@ -28,6 +28,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
 import java.io.*;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -203,5 +204,14 @@ public class PatentController {
         return fileDTO;
     }
 
+    @GetMapping("getPatentsDTOById")
+    @Operation(summary = "根据专利号获得专利")
+    public String getPatentsDTOById(String patentNos){
+        String[] strs =patentNos.split("\\|");
+        List<String> list2 = new ArrayList<>();
+        Collections.addAll(list2, strs);
+        return Response.success(patentService.getPatentsDTOById(list2));
+    }
+
 
 }

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/controller/ProductCategoryController.java

@@ -92,8 +92,8 @@ public class ProductCategoryController {
     }
     @Operation(summary = "获得架构的地区集合")
     @GetMapping("/getAreaList")
-    public String getAreaList(Integer id) {
-        return Response.success( productCategoryService.getAreaList(id));
+    public String getAreaList(Integer id,Integer productId) {
+        return Response.success( productCategoryService.getAreaList(id,productId));
     }
     @Operation(summary = "获得架构的公司集合")
     @GetMapping("/getCompanyList")

+ 72 - 0
PAS/src/main/java/cn/cslg/pas/controller/ProductPatentController.java

@@ -0,0 +1,72 @@
+package cn.cslg.pas.controller;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.model.QueryPatentVO;
+import cn.cslg.pas.common.model.dto.ProductPatentDTO;
+import cn.cslg.pas.common.model.vo.TaskParams;
+import cn.cslg.pas.common.model.vo.TaskVO;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.common.utils.StringUtils;
+import cn.cslg.pas.common.utils.auth.checkAuth;
+import cn.cslg.pas.domain.Task;
+import cn.cslg.pas.service.ProjectService;
+import cn.cslg.pas.service.TaskService;
+import cn.cslg.pas.service.UploadPatentBatchService;
+import cn.cslg.pas.service.asso.AssoProductPatentService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 任务 前端控制器
+ * </p>
+ *
+ * @author 王岩
+ * @since 2022-02-17
+ */
+@Tag(name = "产品相关专利管理")
+@RestController
+@RequestMapping(Constants.API_VERSION_V2 + "/proPatent")
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class ProductPatentController {
+    private final AssoProductPatentService assoProductPatentService;
+    private final UploadPatentBatchService uploadPatentBatchService;
+    private final ProjectService projectService;
+    @PostMapping("/add")
+    @Operation(summary = "添加产品相关专利")
+    public String addPatents(@RequestBody ProductPatentDTO patentDTO) {
+        assoProductPatentService.addPatents(patentDTO);
+        return Response.success(true);
+    }
+
+    @PostMapping("/delete")
+    @Operation(summary = "删除产品相关专利")
+    public String deletePatents(@RequestBody ProductPatentDTO patentDTO) {
+      List<String> patentNos =  assoProductPatentService.deletePatents(patentDTO);
+        if(patentNos.size()==0){
+            return Response.success("删除成功");
+        }
+    return  Response.successBut(patentNos);
+    }
+
+    @PostMapping("/importPatents")
+    @Operation(summary = "导入专利")
+    public String importSysPatent(MultipartFile file, Integer productId) {
+        TaskParams taskParams = projectService.getImportPatentTaskParamsBro(file,productId);
+        uploadPatentBatchService.uploadPatentForProduct(taskParams,productId);
+        return Response.success();
+    }
+
+    @PostMapping("/queryPatents")
+    @Operation(summary = "查询产品相关专利")
+    public String queryPatents(@RequestBody QueryPatentVO params) {
+        return Response.success(assoProductPatentService.getPageList(params));
+    }
+}
+

+ 1 - 0
PAS/src/main/java/cn/cslg/pas/controller/ProjectFieldOptionController.java

@@ -90,6 +90,7 @@ public class ProjectFieldOptionController {
     @Operation(summary = "删除选项")
     public String delete(Integer type, Integer id) {
         if (type == 6) {
+
             projectFieldTreeService.delete(id);
         } else {
             projectFieldOptionService.delete(id);

+ 0 - 1
PAS/src/main/java/cn/cslg/pas/controller/ProjectImportController.java

@@ -63,7 +63,6 @@ public class ProjectImportController {
     public String importSysPatent(@RequestBody TaskParams taskParams) {
         return uploadPatentBatchService.uploadPatentBatchBro(taskParams);
     }
-
     @GetMapping("list")
     @Operation(summary = "导入任务列表")
     public String getPageList(ProjectImportVO params) {

+ 3 - 3
PAS/src/main/java/cn/cslg/pas/controller/TaskController.java

@@ -30,7 +30,7 @@ public class TaskController {
     @GetMapping("list")
     @Operation(summary = "任务列表")
     public String getPageList(TaskVO params) {
-        return Response.success(taskService.getPageList(params));
+      return Response.success(taskService.getPageList(params));
     }
 
     @PostMapping("delete")
@@ -41,8 +41,8 @@ public class TaskController {
 
     @GetMapping("queue")
     @Operation(summary = "获取进行中的任务")
-    public String getQueueList(Integer type, Integer projectId) {
-        return Response.success(taskService.getQueueList(type, projectId));
+    public String getQueueList(Integer type, Integer projectId,Integer productId) {
+        return Response.success(taskService.getQueueList(type, projectId,productId));
     }
 
     @PostMapping("update")

+ 2 - 0
PAS/src/main/java/cn/cslg/pas/domain/Task.java

@@ -84,6 +84,8 @@ public class Task extends BaseEntity<Task> {
     @TableField("downexcel")
     private String url;
 
+    @TableField("product_id")
+    private Integer productId;
     private String oldName;
 
     @TableField(exist = false)

+ 3 - 0
PAS/src/main/java/cn/cslg/pas/domain/asso/AssoPatentStructure.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.domain.asso;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.experimental.Accessors;
@@ -25,5 +26,7 @@ public class AssoPatentStructure implements Serializable {
      * 专利号
      */
     private String patentNo;
+    @TableField(value = "product_Id")
+    private Integer projectId;
 
 }

+ 9 - 1
PAS/src/main/java/cn/cslg/pas/mapper/AssoStructurePatentMapper.java

@@ -1,5 +1,12 @@
 package cn.cslg.pas.mapper;
 
+import cn.cslg.pas.common.model.QueryPatentVO;
+import cn.cslg.pas.domain.Patent;
+import cn.cslg.pas.domain.asso.AssoPatentStructure;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -11,7 +18,7 @@ import java.util.List;
  * @Date 2023/3/13
  */
 @Repository
-public interface AssoStructurePatentMapper {
+public interface AssoStructurePatentMapper extends BaseMapper<AssoPatentStructure> {
     /**
      * 根据架构id批量删除数据
      *
@@ -20,4 +27,5 @@ public interface AssoStructurePatentMapper {
      */
     int deleteByStructureIds(List<Integer> structureIds);
 
+
 }

+ 28 - 0
PAS/src/main/java/cn/cslg/pas/mapper/asso/AssoProductPatentMapper.java

@@ -0,0 +1,28 @@
+package cn.cslg.pas.mapper.asso;
+
+import cn.cslg.pas.common.model.QueryPatentVO;
+import cn.cslg.pas.common.model.dto.ProductPatentDTO;
+import cn.cslg.pas.domain.AdminUser;
+import cn.cslg.pas.domain.Patent;
+import cn.cslg.pas.domain.asso.AssoProductPatent;
+import cn.cslg.pas.domain.asso.AssoProductPicture;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 管理员表 Mapper 接口
+ * </p>
+ *
+ * @author 王岩
+ * @since 2022-03-25
+ */
+public interface AssoProductPatentMapper extends BaseMapper<AssoProductPatent> {
+    int insertBatch(List<String> patentNos, Integer productId);
+    IPage<Patent> getPageList(Page<Patent> page, @Param("params") QueryPatentVO params);
+    List<String> getPatentNos( @Param("params") ProductPatentDTO params);
+}

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/service/IProductCategoryService.java

@@ -59,7 +59,7 @@ public interface IProductCategoryService {
     @Transactional
     List<ProductCategoryTrendVO> showTrend(ProductCategoryDTO dto);
 
-    List<String>  getAreaList(Integer id);
+    List<String>  getAreaList(Integer id,Integer productId);
 
     List<String> getCompanyList(Integer id);
 }

+ 101 - 0
PAS/src/main/java/cn/cslg/pas/service/PatentService.java

@@ -1521,7 +1521,108 @@ public String getConPantentNos(QueryPatentVO params){
     }
 
 
+    public List<PatentDTO> getPatentsDTOById(List<String> patentNos) {
+        LambdaQueryWrapper<Patent> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(Patent::getPatentNo, patentNos);
+        List<Patent> patents =this.list(wrapper);
+        List<PatentDTO> patentDTOs =new ArrayList<>();
+        for(Patent patent: patents) {
+            PatentDTO patentDTO = new PatentDTO();
+            BeanUtils.copyProperties(patent, patentDTO);
+            List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Arrays.asList(Constants.PATENT_TYPE, Constants.PATENT_SIMPLE_STATUS, Constants.COUNTRIES));
+            List<PatentClassNumberLink> patentClassNumberLinkList = patentClassNumberLinkService.getPatentClassNumberLinkByPatentIds(Collections.singletonList(patent.getId()));
+
+            if (patent.getPriorityNo() != null) {
+                patentDTO.setPriorityNo(patent.getPriorityNo());
+            } else {
+                patentDTO.setPriorityNo("");
+            }
 
+            if (patent.getPriorityCountry() != null) {
+                if (patent.getPriorityCountry().contains("\\|")) {
+                    List<String> countryList = StringUtils.changeStringToString(patent.getPriorityCountry().replaceAll(" ", ""), "\\|");
+                    patentDTO.setPriorityCountry(countryList);
+                } else if (patent.getPriorityCountry().contains(",")) {
+                    List<String> countryList = StringUtils.changeStringToString(patent.getPriorityCountry().replaceAll(" ", ""), ",");
+                    patentDTO.setPriorityCountry(countryList);
+                } else if (patent.getPriorityCountry().contains(";")) {
+                    List<String> countryList = StringUtils.changeStringToString(patent.getPriorityCountry().replaceAll(" ", ""), ";");
+                    patentDTO.setPriorityCountry(countryList);
+                }
+            } else {
+                patentDTO.setPriorityCountry(Collections.singletonList(""));
+            }
+
+            patentDTO.setQuote("");
+            if (patent.getQuote() != null) {
+                patentDTO.setQuote(patent.getQuote());
+            }
+            patentDTO.setQuoted("");
+            if (patent.getQuoted() != null) {
+                patentDTO.setQuoted(patent.getQuoted());
+            }
+            //根据同族号,获得所有同族专利(三种同族)
+            List<Integer> familyIds = new ArrayList<>();
+            if (patent.getSimpleFamily() != null) {
+                familyIds.add(patent.getSimpleFamily());
+            }
+            if (patent.getInpadocFamily() != null) {
+
+                familyIds.add(patent.getInpadocFamily());
+            }
+            if (patent.getPatSnapFamily() != null) {
+                familyIds.add(patent.getPatSnapFamily());
+            }
+            if (familyIds.size() != 0) {
+                LambdaQueryWrapper<PatentSimpleFamilyLink> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.in(PatentSimpleFamilyLink::getFamilyId, familyIds);
+                List<PatentSimpleFamilyLink> patentSimpleFamilyLinks = patentSimpleFamilyLinkService.list(queryWrapper);
+                List<String> familyPatentNos = patentSimpleFamilyLinks.stream().map(PatentSimpleFamilyLink::getPatentNo).collect(Collectors.toList());
+                PatentDTO.PatentFamily patentFamily = new PatentDTO.PatentFamily();
+                patentFamily.setSimple(familyPatentNos);
+                patentDTO.setFamily(patentFamily);
+            }
+            patentDTO.setApplicationDate(DateUtils.formatDate(patent.getApplicationDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setPriorityDate(DateUtils.formatDate(patent.getPriorityDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setPublicDate(DateUtils.formatDate(patent.getPublicDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setPublicAccreditDate(DateUtils.formatDate(patent.getPublicAccreditDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setFirstPublicDate(DateUtils.formatDate(patent.getFirstPublicDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setSimpleStatus(systemDictList.stream().filter(systemDict -> systemDict.getType().equals(Constants.PATENT_SIMPLE_STATUS) && systemDict.getValue().equals(String.valueOf(patent.getSimpleStatus()))).findFirst().orElse(new SystemDict()).getLabel());
+            patentDTO.setSimpleStatusInt(patent.getSimpleStatus());
+            patentDTO.setType(systemDictList.stream().filter(systemDict -> systemDict.getType().equals(Constants.PATENT_TYPE) && systemDict.getValue().equals(String.valueOf(patent.getType()))).findFirst().orElse(new SystemDict()).getLabel());
+            patentDTO.setApplicant(patentApplicantService.getPatentApplicantByPatentId(patent.getId()));
+            patentDTO.setInventor(patentInventorService.getPatentInventorByPatentId(patent.getId()));
+            if (StringUtils.isNotEmpty(patent.getAgencyId())) {
+                patentDTO.setAgency(patentAgencyService.getPatentAgencyById(Integer.parseInt(patent.getAgencyId())));
+            } else {
+                PatentAgency patentAgency = new PatentAgency();
+                patentAgency.setName("");
+                patentDTO.setAgency(patentAgency);
+            }
+            patentDTO.setAgent(patentAgentService.getPatentAgentByPatentId(patent.getId()));
+            patentDTO.setAffair(patentAffairService.getPatentAffairByPatentId(patent.getId()));
+            if (StringUtils.isNotEmpty(patent.getPriorityCountry())) {
+                List<String> priorityList = PatentUtils.formatValue(patent.getPriorityCountry());
+                List<String> priorityCountryList = new ArrayList<>();
+                for (String priorityCountry : priorityList) {
+                    priorityCountryList.add(systemDictList.stream().filter(systemDict -> systemDict.getType().equals(Constants.COUNTRIES) && systemDict.getValue().equals(priorityCountry)).findFirst().orElse(new SystemDict()).getLabel());
+                }
+                patentDTO.setPriorityCountry(priorityCountryList);
+            }
+            patentDTO.setInstruction(patentInstructionTextService.getPatentInstructionTextByPatentId(patent.getId()));
+            patentDTO.setRights(patentRightService.getPatentRightByPatentId(patent.getId()));
+            patentDTO.setImage(patentImageService.getPatentImageByPatentId(patent.getId()));
+            patentDTO.setPdf(patentInstructionService.getPatentInstructionByPatentNo(patent.getPatentNo()));
+            patentDTO.setIpc(patentClassNumberLinkList.stream().filter(patentClassNumberLink -> patentClassNumberLink.getType().equals(Constants.PATENT_CLASS_NUMBER_IPC) && patentClassNumberLink.getMain().equals(1)).findFirst().orElse(new PatentClassNumberLink()).getCode());
+            patentDTO.setUpc(patentClassNumberLinkList.stream().filter(patentClassNumberLink -> patentClassNumberLink.getType().equals(Constants.PATENT_CLASS_NUMBER_UPC) && patentClassNumberLink.getMain().equals(1)).findFirst().orElse(new PatentClassNumberLink()).getCode());
+            patentDTO.setIpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_IPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+            patentDTO.setCpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_CPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+            patentDTO.setUpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_UPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+            patentDTO.setLocList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_LOC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+            patentDTOs.add(patentDTO);
+        }
+        return patentDTOs;
+    }
 
 
 }

+ 2 - 0
PAS/src/main/java/cn/cslg/pas/service/ProjectImportService.java

@@ -60,4 +60,6 @@ public class ProjectImportService extends ServiceImpl<ProjectImportMapper, Proje
         projectImport.insert();
         return projectImport.getId();
     }
+
+
 }

+ 5 - 2
PAS/src/main/java/cn/cslg/pas/service/ProjectService.java

@@ -575,7 +575,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         for (int i = 1; i < rowList.size(); i++) {
             mapList.add(IterUtil.toMap(rowList.get(0), rowList.get(i)));
         }
-        Integer taskId = taskService.add(fileDTO, projectId, rowList.size() - 1, 1, 0, file.getOriginalFilename());
+        Integer taskId = taskService.add(fileDTO, projectId, null,rowList.size() - 1, 1, 0, file.getOriginalFilename());
         TaskParams taskParams = new TaskParams();
         taskParams.setTaskId(taskId);
         taskParams.setPath(path);
@@ -587,7 +587,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
     }
 
     //获得
-    public TaskParams getImportPatentTaskParamsBro(MultipartFile file) {
+    public TaskParams getImportPatentTaskParamsBro(MultipartFile file,Integer productId) {
         //上传文档
         UploadFileDTO fileDTO = fileUtils.uploadFile(file);
         //获得文档保存的路径
@@ -599,12 +599,15 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         for (int i = 1; i < rowList.size(); i++) {
             mapList.add(IterUtil.toMap(rowList.get(0), rowList.get(i)));
         }
+        Integer taskId = taskService.add(fileDTO, null,productId, rowList.size() - 1, 1, 0, file.getOriginalFilename());
         TaskParams taskParams = new TaskParams();
         taskParams.setPath(path);
+        taskParams.setTaskId(taskId);
         taskParams.setTaskType(1);
         taskParams.setRowList(mapList);
         taskParams.setUserId(String.valueOf(loginUtils.getId()));
         taskParams.setOldName(file.getOriginalFilename());
+        taskParams.setProductId(productId);
         return taskParams;
     }
 

+ 14 - 5
PAS/src/main/java/cn/cslg/pas/service/TaskService.java

@@ -42,11 +42,16 @@ public class TaskService extends ServiceImpl<TaskMapper, Task> {
         return fileUtils.getSystemPath() + task.getUrl();
     }
 
-    public Integer add(UploadFileDTO fileDTO, Integer projectId, Integer total, Integer type, Integer fieldNum, String oldName) {
+    public Integer add(UploadFileDTO fileDTO, Integer projectId,Integer productId, Integer total, Integer type, Integer fieldNum, String oldName) {
         Task task = new Task();
         task.setStartTime(DateUtils.getDateTime());
         task.setStatus(0);
-        task.setProjectId(projectId);
+        if(projectId!=null) {
+            task.setProjectId(projectId);
+        }
+        if(productId!=null){
+            task.setProductId(productId);
+        }
         task.setFileName(fileDTO.getFileName());
         task.setUrl(fileDTO.getPath());
         task.setTotal(total);
@@ -81,12 +86,16 @@ public class TaskService extends ServiceImpl<TaskMapper, Task> {
         return pageList;
     }
 
-    public List<Task> getQueueList(Integer type, Integer projectId) {
+    public List<Task> getQueueList(Integer type, Integer projectId,Integer productId) {
         LambdaQueryWrapper<Task> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(Task::getCreateBy, loginUtils.getId());
         queryWrapper.eq(Task::getType, type);
-        queryWrapper.in(Task::getStatus, new ArrayList<Integer>() {{ add(0); add(1); }});
-        queryWrapper.eq(Task::getProjectId, projectId);
+        queryWrapper.in(Task::getStatus, new ArrayList<Integer>() {{ add(0); add(1);}});
+        if(projectId!=null){
+        queryWrapper.eq(Task::getProjectId, projectId);}
+        if(productId!=null){
+            queryWrapper.eq(Task::getProductId,productId);
+        }
         queryWrapper.orderByAsc(Task::getStartTime);
         return this.list(queryWrapper);
     }

+ 80 - 1
PAS/src/main/java/cn/cslg/pas/service/UploadPatentBatchService.java

@@ -10,6 +10,7 @@ import cn.cslg.pas.common.model.vo.UploadSettingVO;
 import cn.cslg.pas.common.utils.*;
 import cn.cslg.pas.domain.*;
 import cn.cslg.pas.mapper.ImportErrorLogMapper;
+import cn.cslg.pas.service.asso.AssoProductPatentService;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
@@ -48,6 +49,7 @@ public class UploadPatentBatchService {
     private final PatentClassNumberLinkService patentClassNumberLinkService;
     private final PatentAffairService patentAffairService;
     private final ImportErrorLogMapper importErrorLogMapper;
+    private final AssoProductPatentService assoProductPatentService;
     private static int FLAG = 0;
 
     @Async("singleThreadAsyncTaskExecutor")
@@ -323,7 +325,6 @@ public class UploadPatentBatchService {
                 patentApplicationBusiness(uploadParamsVO);
             //申请人地址 OS_PATENT_APPLICATION
             patentApplicationAddressBusiness(uploadParamsVO);
-
             //分类号关联 OS_PATENT_TYPENO
             patentTypeNoBusiness(uploadParamsVO);
             //事务信息 OS_PATENT_AFFAIR
@@ -580,4 +581,82 @@ public class UploadPatentBatchService {
         patentService.updatePatentCustomField(patentCustomFieldParams);
     }
 
+
+
+    @Async("singleThreadAsyncTaskExecutor")
+    public void uploadPatentForProduct(TaskParams params,Integer productId) {
+        Integer total = params.getRowList().size();
+        try {
+            //先解析Json文件 获得配置文件的Json串
+            String getSettingJson = fileUtils.analysisJsonFile();
+            //查找需求数据源的对应配置
+            List<UploadSettingVO.Column> jsonData = UploadPatentBatchUtil.parsingConfigurationFilesBro(getSettingJson);
+
+            Map<String, PictureData> pictureDataMap = ExcelUtils.getDataFromExcel(params.getPath());
+
+            //将数据进行装配并进行数据库操作
+            for (int i = 0; i < params.getRowList().size(); i++) {
+                //获取每一行的数据
+                Map<Object, Object> row = params.getRowList().get(i);
+                //基础数据装配
+                UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(row, jsonData);
+
+                //查询数据是否存在 如果存在 返回该条数据 如果不存在 新增一条数据
+                getOneOrInsertOne(uploadParamsVO);
+
+                //专利信息需要特殊处理部分
+                //专利信息(摘要附图)数据装配
+                PictureData pictureData = pictureDataMap.get(String.valueOf(i + 1));
+                if (uploadParamsVO.getPatent() != null) {
+                    if (uploadParamsVO.getPatent().getId() != null && pictureData != null) {
+                        uploadParamsVO.getPatent().setAbstractPath(patentImageService.updatePatentImage(uploadParamsVO.getPatent().getId(), pictureData));
+                    }
+                }
+                //专利信息(代理机构)数据装配
+                if (uploadParamsVO.getPatent() != null) {
+                    if (uploadParamsVO.getPatent().getAgencyId() != null) {
+                        uploadParamsVO.getPatent().setAgencyId(patentAgencyService.getAgencyStringIdByName(uploadParamsVO.getPatent().getAgencyId()));
+                    }
+
+                }
+                //将装配对象中的数据保存到数据库
+                dataToDBBro(params, uploadParamsVO);
+                //添加关联关系
+                List<String> list = new ArrayList<>();
+                Collections.addAll(list, uploadParamsVO.getPatent().getPatentNo());
+                assoProductPatentService.addPatents(list,productId);
+                //通过WebSocket 在每一次循环结束后 向前端发送完成进度
+                WebSocketServer.sendInfo(Response.websocket(new TaskWebSocketDTO()
+                        .setTaskId(params.getTaskId())
+                        .setComplete(false)
+                        .setIndex(i)
+                        .setTaskType(Constants.TASK_IMPORT_PATENT)
+                        .setPercentage(total == 0 ? 0 : Math.round((total.equals(i) ? (i * 1D) : (i + 1D)) / total * 100D))
+                        .setFileName("")
+                        .setOldName(params.getOldName())
+                        .setUrl("")
+                        .setTotal(total), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), params.getUserId());
+            }
+
+            SpringUtil.getBean(ProjectService.class).setImportPatentTaskStatus(2, params.getTaskId());
+            WebSocketServer.sendInfo(Response.websocket(new TaskWebSocketDTO()
+                    .setTaskId(params.getTaskId())
+                    .setComplete(true)
+                    .setIndex(total)
+                    .setTaskType(Constants.TASK_IMPORT_PATENT)
+                    .setPercentage(100L)
+                    .setFileName("")
+                    .setOldName(params.getOldName())
+                    .setUrl("")
+                    .setTotal(total), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), params.getUserId());
+        } catch (Exception e) {
+            e.printStackTrace();
+            SpringUtil.getBean(ProjectService.class).setImportPatentTaskStatus(3, params.getTaskId());
+            if (FLAG > 0) {
+                int successCount = total - FLAG;
+                WebSocketServer.sendInfo(Response.error("部分数据上传成功" + "\n" + "成功条数:" + successCount + "失败条数:" + FLAG), params.getUserId());
+            }
+            FLAG = 0;
+        }
+    }
 }

+ 175 - 0
PAS/src/main/java/cn/cslg/pas/service/asso/AssoProductPatentService.java

@@ -0,0 +1,175 @@
+package cn.cslg.pas.service.asso;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.model.QueryPatentVO;
+import cn.cslg.pas.common.model.dto.PatentDTO;
+import cn.cslg.pas.common.model.dto.ProductPatentDTO;
+import cn.cslg.pas.common.utils.*;
+import cn.cslg.pas.domain.*;
+import cn.cslg.pas.domain.asso.AssoPatentStructure;
+import cn.cslg.pas.domain.asso.AssoProductPatent;
+import cn.cslg.pas.mapper.DepartmentMapper;
+import cn.cslg.pas.mapper.PatentMapper;
+import cn.cslg.pas.mapper.asso.AssoProductPatentMapper;
+import cn.cslg.pas.service.*;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.lang.tree.Tree;
+import cn.hutool.core.lang.tree.TreeNode;
+import cn.hutool.core.lang.tree.TreeNodeConfig;
+import cn.hutool.core.lang.tree.TreeUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.graphbuilder.math.func.Function;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 后台部门表 服务类
+ * </p>
+ *
+ * @author 王岩
+ * @since 2022-03-25
+ */
+@Service
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class AssoProductPatentService extends ServiceImpl<AssoProductPatentMapper, AssoProductPatent> {
+    private final PatentApplicantService patentApplicantService;
+    private final PatentAffairService patentAffairService;
+    private final PatentLabelService patentLabelService;
+    private final ProjectFieldService projectFieldService;
+    private final PatentInventorService patentInventorService;
+    private final PatentAgencyService patentAgencyService;
+    private final PatentAgentService patentAgentService;
+    private final PatentClassNumberLinkService patentClassNumberLinkService;
+    private final SystemDictService systemDictService;
+    private final PatentSimpleFamilyLinkService patentSimpleFamilyLinkService;
+    private final AssoStructurePatentService assoStructurePatentService;
+
+    /**
+     * 给产品添加相关专利
+     */
+    public int addPatents(ProductPatentDTO patentDTO) {
+        patentDTO.setIsIn(0);
+        List<String> patentNos = this.baseMapper.getPatentNos(patentDTO);
+        if (patentNos.size() == 0) {
+            return -1;
+        }
+        return this.baseMapper.insertBatch(patentNos, patentDTO.getProductId());
+    }
+
+
+    public int addPatents(List<String> patentNos, Integer productId) {
+        LambdaQueryWrapper<AssoProductPatent> wrapper = new LambdaQueryWrapper<>();
+        wrapper.select(AssoProductPatent::getPatentNo);
+        wrapper.eq(AssoProductPatent::getProductId, productId);
+        wrapper.in(AssoProductPatent::getPatentNo, patentNos);
+        List<String> patentNo = this.listObjs(wrapper, Object::toString);
+        patentNos.removeAll(patentNo);
+        if (patentNos.size() == 0) {
+            return -1;
+        }
+        return this.baseMapper.insertBatch(patentNos, productId);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public List<String> deletePatents(ProductPatentDTO patentDTO) {
+        patentDTO.setIsIn(1);
+        List<String> patentNos= new ArrayList<>();
+        if (patentDTO.getStartNumber() != null && patentDTO.getEndNumber() != null&&patentDTO.getEndNumber() >patentDTO.getStartNumber()) {
+            patentDTO.setEndNumber(patentDTO.getEndNumber() - patentDTO.getStartNumber()+1);
+            patentNos = this.baseMapper.getPatentNos(patentDTO);
+        }
+        if(patentDTO.getPatentNos()!=null&&patentDTO.getPatentNos().size()>0){
+          for(String item:patentDTO.getPatentNos()){
+                if(!patentNos.contains(item)){
+                    patentNos.add(item);
+                }
+            }
+        }
+        if(patentDTO.getNotInPatentNos()!=null) {
+            patentNos.removeAll(patentDTO.getNotInPatentNos());
+        }
+
+
+        List<String> assoPatents = new ArrayList<>();
+        if (patentNos.size() != 0) {
+            LambdaQueryWrapper<AssoPatentStructure> assoWrapper = new LambdaQueryWrapper<>();
+            assoWrapper.select(AssoPatentStructure::getPatentNo);
+            assoWrapper.eq(AssoPatentStructure::getProjectId, patentDTO.getProductId())
+                    .in(AssoPatentStructure::getPatentNo, patentNos);
+            assoPatents = assoStructurePatentService.listObjs(assoWrapper, Object::toString);
+            LambdaQueryWrapper<AssoProductPatent> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(AssoProductPatent::getProductId, patentDTO.getProductId());
+            wrapper.in(AssoProductPatent::getPatentNo, patentNos);
+            this.remove(wrapper);
+            return assoPatents;
+        }
+        return assoPatents;
+    }
+
+    public IPage<PatentDTO> getPageList(QueryPatentVO params) {
+        IPage<Patent> dataPage = baseMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
+        IPage<PatentDTO> pageList = new Page<>();
+        List<PatentDTO> records = new ArrayList<>();
+        List<Integer> patentIds = dataPage.getRecords().stream().map(Patent::getId).collect(Collectors.toList());
+        List<PatentApplicant> patentApplicantList = patentApplicantService.getPatentApplicantByPatentIds(patentIds);
+        List<PatentInventor> patentInventorList = patentInventorService.getPatentInventorByPatentIds(patentIds);
+        List<PatentLabel> patentLabelList = patentLabelService.getPatentLabelByPatentIdsAndProjectId(patentIds, params.getProjectId());
+        List<PatentClassNumberLink> patentClassNumberLinkList = patentClassNumberLinkService.getPatentClassNumberLinkByPatentIds(patentIds);
+        List<PatentAgent> patentAgentList = patentAgentService.getPatentAgentByPatentIds(patentIds);
+        List<PatentAgency> patentAgencyList = patentAgencyService.getPatentAgencyByIds(dataPage.getRecords().stream().filter(item -> StringUtils.isNotEmpty(item.getAgencyId())).map(item -> Integer.parseInt(item.getAgencyId())).distinct().collect(Collectors.toList()));
+        List<PatentSimpleFamilyLink> patentSimpleFamilyLinkList = patentSimpleFamilyLinkService.getPatentSimpleFamilyLinkByFamilyIds(dataPage.getRecords().stream().map(Patent::getSimpleFamily).collect(Collectors.toList()));
+        List<PatentSimpleFamilyLink> patentInpadocFamilyLinkList = patentSimpleFamilyLinkService.getPatentSimpleFamilyLinkByFamilyIds(dataPage.getRecords().stream().map(Patent::getInpadocFamily).collect(Collectors.toList()));
+        List<PatentSimpleFamilyLink> patentPatSnapFamilyLinkList = patentSimpleFamilyLinkService.getPatentSimpleFamilyLinkByFamilyIds(dataPage.getRecords().stream().map(Patent::getPatSnapFamily).collect(Collectors.toList()));
+        List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Arrays.asList(Constants.PATENT_TYPE, Constants.PATENT_SIMPLE_STATUS));
+        dataPage.getRecords().forEach(item -> {
+            PatentDTO patentDTO = new PatentDTO();
+            BeanUtils.copyProperties(item, patentDTO);
+            patentDTO.setApplicationDate(DateUtils.formatDate(item.getApplicationDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setPriorityDate(DateUtils.formatDate(item.getPriorityDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setPublicDate(DateUtils.formatDate(item.getPublicDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setPublicAccreditDate(DateUtils.formatDate(item.getPublicAccreditDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setFirstPublicDate(DateUtils.formatDate(item.getFirstPublicDate(), DateUtils.YYYY_MM_DD));
+            patentDTO.setSimpleStatus(systemDictList.stream().filter(systemDict -> systemDict.getType().equals(Constants.PATENT_SIMPLE_STATUS) && systemDict.getValue().equals(String.valueOf(item.getSimpleStatus()))).findFirst().orElse(new SystemDict()).getLabel());
+            patentDTO.setType(systemDictList.stream().filter(systemDict -> systemDict.getType().equals(Constants.PATENT_TYPE) && systemDict.getValue().equals(String.valueOf(item.getType()))).findFirst().orElse(new SystemDict()).getLabel());
+            patentDTO.setApplicant(patentApplicantList.stream().filter(patentApplicant -> patentApplicant.getPatentId().equals(item.getId())).collect(Collectors.toList()));
+            patentDTO.setInventor(patentInventorList.stream().filter(patentInventor -> patentInventor.getPatentId().equals(item.getId())).collect(Collectors.toList()));
+            patentDTO.setLabel(patentLabelList.stream().filter(patentLabel -> patentLabel.getPatentId().equals(item.getId())).collect(Collectors.toList()));
+            patentDTO.setIpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getPatentId().equals(item.getId()) && patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_IPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+            patentDTO.setCpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getPatentId().equals(item.getId()) && patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_CPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+            patentDTO.setUpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getPatentId().equals(item.getId()) && patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_UPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+            patentDTO.setLocList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getPatentId().equals(item.getId()) && patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_LOC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+            patentDTO.setAffair(patentAffairService.getPatentAffairByPatentId(item.getId()));
+            if (StringUtils.isNotEmpty(item.getAgencyId())) {
+                patentDTO.setAgency(patentAgencyList.stream().filter(patentAgency -> patentAgency.getId().equals(Integer.parseInt(item.getAgencyId()))).findFirst().orElse(null));
+            }
+            PatentDTO.PatentFamily patentFamily = new PatentDTO.PatentFamily();
+            patentFamily.setSimple(patentSimpleFamilyLinkList.stream().filter(patentSimpleFamilyLink -> patentSimpleFamilyLink.getFamilyId().equals(item.getSimpleFamily())).map(PatentSimpleFamilyLink::getPatentNo).collect(Collectors.toList()));
+            patentFamily.setInpadoc(patentInpadocFamilyLinkList.stream().filter(patentSimpleFamilyLink -> patentSimpleFamilyLink.getFamilyId().equals(item.getInpadocFamily())).map(PatentSimpleFamilyLink::getPatentNo).collect(Collectors.toList()));
+            patentFamily.setPatSnap(patentPatSnapFamilyLinkList.stream().filter(patentSimpleFamilyLink -> patentSimpleFamilyLink.getFamilyId().equals(item.getPatSnapFamily())).map(PatentSimpleFamilyLink::getPatentNo).collect(Collectors.toList()));
+            patentDTO.setFamily(patentFamily);
+            patentDTO.setAgent(patentAgentList.stream().filter(patentAgent -> patentAgent.getPatentId().equals(item.getId())).collect(Collectors.toList()));
+            // TODO 性能优化
+            patentDTO.setField(projectFieldService.getPatentFieldByPatentIdAndProjectId(params.getProjectId(), item.getId()));
+            records.add(patentDTO);
+        });
+        pageList.setTotal(dataPage.getTotal());
+        pageList.setRecords(records);
+        pageList.setPages(dataPage.getPages());
+        pageList.setSize(dataPage.getSize());
+        pageList.setCurrent(dataPage.getCurrent());
+        Map<String, Object> map = new HashMap<>();
+        return pageList;
+    }
+
+
+}

+ 41 - 0
PAS/src/main/java/cn/cslg/pas/service/asso/AssoStructurePatentService.java

@@ -0,0 +1,41 @@
+package cn.cslg.pas.service.asso;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.model.QueryPatentVO;
+import cn.cslg.pas.common.model.dto.PatentDTO;
+import cn.cslg.pas.common.model.dto.ProductPatentDTO;
+import cn.cslg.pas.common.utils.DateUtils;
+import cn.cslg.pas.common.utils.StringUtils;
+import cn.cslg.pas.domain.*;
+import cn.cslg.pas.domain.asso.AssoPatentStructure;
+import cn.cslg.pas.domain.asso.AssoProductPatent;
+import cn.cslg.pas.mapper.AssoStructurePatentMapper;
+import cn.cslg.pas.mapper.asso.AssoProductPatentMapper;
+import cn.cslg.pas.service.*;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 后台部门表 服务类
+ * </p>
+ *
+ * @author 王岩
+ * @since 2022-03-25
+ */
+@Service
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class AssoStructurePatentService extends ServiceImpl<AssoStructurePatentMapper, AssoPatentStructure> {
+
+
+}

+ 57 - 15
PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java

@@ -260,9 +260,16 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
         List<ProductCategoryTrendVO> trendVOS = new ArrayList<>();
         //存储所有产品的营销数据
         List<ProductMarketData> marketData = new ArrayList<>();
+        //存储所有
+        ProductCategoryTrendVO trendAllVO = new ProductCategoryTrendVO();
+        trendAllVO.setProductId(0);
+        trendAllVO.setProductName("总产品");
+        Map<String, Object> allMarketDataMap = new HashMap<>();
         //根据产品类别ID获得产品id和产品名称
         LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();
         productWrapper.eq(Product::getProductCategoryId, dto.getCategoryId());
+        if(dto.getCompanyName()!=null&&dto.getCompanyName()!=""){
+        productWrapper.eq(Product::getCompanyName,dto.getCompanyName());}
         List<Product> products = productService.list(productWrapper);
         if (products.size() != 0) {
             List<Integer> productIds = products.stream().map(Product::getId).collect(Collectors.toList());
@@ -290,58 +297,94 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
             temMarketData.forEach(item -> {
                         //获得营销数据的时间
                         String date = item.getSaleTime();
-                        double saleCount = item.getSaleCount() * item.getSaleMoney();
+                        double saleCount = item.getSaleMoney();
                         if (dto.getTimeUnit() == 1) {
                             try {
                                 Date dateForm = new SimpleDateFormat("yyyy-MM").parse(date);
-                                int month = dateForm.getMonth();
-                                int year = dateForm.getYear();
-                                int season = (month - 1) / 3;
+                                Calendar ca = Calendar.getInstance();
+                                ca.setTime(dateForm);
+                                int month = ca.get(Calendar.MONTH);//第几个月
+                                int year = ca.get(Calendar.YEAR);//年份数值
+                                int season = (month - 1) / 3+1;
                                 date = year + "-" + season;
                             } catch (ParseException e) {
                                 e.printStackTrace();
                             }
                         }
+                        else if(dto.getTimeUnit() == 2){
+                            try {
+                                Date dateForm = new SimpleDateFormat("yyyy-MM").parse(date);
+                                Calendar ca = Calendar.getInstance();
+                                ca.setTime(dateForm);
+                                int year = ca.get(Calendar.YEAR);//年份数值
+                                date = year+"";
+                            } catch (ParseException e) {
+                                e.printStackTrace();
+                            }
+                        }
                         //计算销售额
                         if (marketDataMap.get(date) != null) {
                             saleCount += Double.parseDouble(marketDataMap.get(date).toString());
                         }
                         marketDataMap.put(date, saleCount);
+
+                        //产品总体部分
+                if (allMarketDataMap.get(date) != null) {
+                    saleCount += Double.parseDouble(allMarketDataMap.get(date).toString());
+                }
+                allMarketDataMap.put(date, saleCount);
                     }
             );
             Set keyset = marketDataMap.keySet();
             List<ProductCategoryTrendVO.saleVO> saleVOS = new ArrayList<>();
             for (Object key : keyset) {
                 ProductCategoryTrendVO.saleVO saleVO = new ProductCategoryTrendVO.saleVO();
-                saleVO.setMarketData(key.toString());
+                saleVO.setMarketDate(key.toString());
                 saleVO.setSaleTotalMoney(Double.parseDouble(marketDataMap.get(key).toString()));
                 saleVOS.add(saleVO);
             }
             trendVO.setSaleVOS(saleVOS);
             trendVOS.add(trendVO);
         }
-
+        Set keyset = allMarketDataMap.keySet();
+        List<ProductCategoryTrendVO.saleVO> saleVOS = new ArrayList<>();
+        for (Object key : keyset) {
+            ProductCategoryTrendVO.saleVO saleVO = new ProductCategoryTrendVO.saleVO();
+            saleVO.setMarketDate(key.toString());
+            saleVO.setSaleTotalMoney(Double.parseDouble(allMarketDataMap.get(key).toString()));
+            saleVOS.add(saleVO);
+        }
+        trendAllVO.setSaleVOS(saleVOS);
+        trendVOS.add(trendAllVO);
         return trendVOS;
     }
 
     @Override
-    public List<String> getAreaList(Integer id) {
+    public List<String> getAreaList(Integer id,Integer productId) {
         //存储所有产品的营销数据
         List<ProductMarketData> marketData = new ArrayList<>();
         List<String> areaList = new ArrayList<>();
-        //根据架构id获得产品
-        LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();
-        productWrapper.eq(Product::getProductCategoryId, id);
-        List<Product> products = productService.list(productWrapper);
-        if (products.size() != 0) {
-            List<Integer> productIds = products.stream().map(Product::getId).collect(Collectors.toList());
+        List<Integer> productIds = new ArrayList<>();
+        if(productId==null) {
+            //根据架构id获得产品
+            LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();
+            productWrapper.eq(Product::getProductCategoryId, id);
+            List<Product> products = productService.list(productWrapper);
+
+            if (products.size() != 0) {
+                productIds = products.stream().map(Product::getId).collect(Collectors.toList());
+            }
+        }
+        else {
+            productIds=Arrays.asList(productId);
+        }
             if (productIds.size() > 0) {
                 //根据产品Id获得产品营销数据
                 LambdaQueryWrapper<ProductMarketData> market = new LambdaQueryWrapper<>();
                 market.in(ProductMarketData::getProductId, productIds);
                 marketData = productMarketDataIService.list(market);
             }
-        }
+
         marketData.forEach(
                 item -> {
                     if (!areaList.contains(item.getSaleArea())) {
@@ -354,7 +397,6 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
 
 
     public List<String> getCompanyList(Integer id) {
-
         List<String> areaList = new ArrayList<>();
         //根据架构id获得产品
         LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();

+ 178 - 0
PAS/src/main/resources/mapper/AssoProductPatentMapper.xml

@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="cn.cslg.pas.mapper.asso.AssoProductPatentMapper">
+    <!--批量插入数据-->
+    <!--int insertBatch(List<AssoProductPicture> assoProductPictures);-->
+    <insert id="insertBatch">
+        insert into asso_product_patent (product_id,patent_no)
+        values
+        <foreach collection="patentNos" item="item" separator=",">
+            (#{productId},#{item})
+        </foreach>
+    </insert>
+
+
+    <select id="getPageList" parameterType="cn.cslg.pas.common.model.vo.PatentVO"
+            resultType="cn.cslg.pas.domain.Patent">
+        select DISTINCT a.id, a.`name` as name, a.nameout as name_out, a.patentno as patent_no, a.abstract_path,
+        a.abstract as
+        abstract_str, a.abstractout as abstract_out,
+        a.publicno as public_no, a.publicdate as public_date, a.simple_family, a.inpadoc_family, a.applicationno as
+        application_no, a.appdate as application_date,
+        a.`status` as simple_status, a.type, a.publictodate as public_accredit_date, a.fpublicdate as first_public_date,
+        a.prioritydate as priority_date,
+        a.agencyid as agency_id, a.num2 as right_num, a.quoteno as quote_num, a.quotedno as quoted_num,
+        a.patsnap_family as patSnapFamily, a.patsnapfamilynum as patSnapFamilyNum
+        from os_patent a
+        left join asso_product_patent i on i.patent_no=a.patentno
+            left join asso_structure_patent t on t.patent_no =a.patentno
+        <if test="params.applicationName !=null ">
+            left join os_applicant_attr b on a.id=b.pid and b.type =1
+            left join os_patent_applicant c on c.id=b.applicantid
+        </if>
+        <if test=" params.obligeeName !=null">
+            left join os_applicant_attr d on a.id=d.pid and d.type =2
+            left join os_patent_applicant e on e.id=d.applicantid
+        </if>
+        <if test="params.numberIpc!=null ">
+            left join os_patent_typeno f on f.pid =a.id and f.type =1
+        </if>
+        <if test=" params.numberCpc!=null ">
+            left join os_patent_typeno g on g.pid =a.id and g.type =2
+        </if>
+        <if test=" params.numberUpc!=null">
+            left join os_patent_typeno h on h.pid =a.id and h.type =3
+        </if>
+        <where>
+          ( i.product_id =#{params.productId}
+            or t.product_id =#{params.productId} )
+                    <if test="params.applicationName !=null and params.applicationName !=''  ">
+                        and c.name  REGEXP #{params.applicationName}
+                    </if>
+                    <if test="params.obligeeName !=null and params.obligeeName!=''">
+                        and e.name  REGEXP #{params.obligeeName}
+                    </if>
+                    <if test="params.numberIpc !=null and params.numberIpc!=''">
+                        and f.code like concat("%", #{params.numberIpc}, "%")
+                    </if>
+                    <if test="params.numberCpc !=null and params.numberCpc!=''">
+                        and g.code like concat("%", #{params.numberCpc}, "%")
+                    </if>
+                    <if test="params.numberUpc !=null and params.numberUpc!=''">
+                        and h.code like concat("%", #{params.numberUpc}, "%")
+                    </if>
+                    <if test="params.patentNo !=null and params.patentNo !=''">
+                        and a.patentNo REGEXP  #{params.patentNo}
+                    </if>
+                    <if test="params.applicationNo !=null and params.applicationNo !=''">
+                        and a.applicationNo like concat("%", #{params.applicationNo}, "%")
+                    </if>
+                    <if test="params.abstractStr !=null and params.abstractStr !=''">
+                        and a.abstract like concat("%", #{params.abstractStr}, "%")
+                    </if>
+                    <if test="params.patentName !=null and params.patentName !=''">
+                        and a.`name` like concat("%", #{params.patentName}, "%")
+                    </if>
+                    <if test="params.orderItem!=null and params.orderItem!='SysOrder'">
+                        order by #{params.orderItem}
+                        <if test="params.orderType!=null">
+                            #{params.orderType}
+                        </if>
+                    </if>
+                    <if test="params.orderItem==null">
+                        order by a.patentno
+                    </if>
+                    <if test="params.orderItem=='SysOrder' and params.patentNos != null and params.patentNos.size()!=0">
+                        order by field (a.patentno,
+                        <foreach item="item" collection="params.patentNos" index="index" open="" separator=","
+                                 close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+
+        </where>
+    </select>
+
+    <select id="getPatentNos" resultType="java.lang.String">
+        select DISTINCT a.patentno as patent_no
+        from os_patent a
+        left join asso_product_patent i on i.patent_no=a.patentno
+        left join asso_structure_patent t on t.patent_no =a.patentno
+        <if test="params.applicationName !=null ">
+            left join os_applicant_attr b on a.id=b.pid and b.type =1
+            left join os_patent_applicant c on c.id=b.applicantid
+        </if>
+        <if test=" params.obligeeName !=null">
+            left join os_applicant_attr d on a.id=d.pid and d.type =2
+            left join os_patent_applicant e on e.id=d.applicantid
+        </if>
+        <if test="params.numberIpc!=null ">
+            left join os_patent_typeno f on f.pid =a.id and f.type =1
+        </if>
+        <if test=" params.numberCpc!=null ">
+            left join os_patent_typeno g on g.pid =a.id and g.type =2
+        </if>
+        <if test=" params.numberUpc!=null">
+            left join os_patent_typeno h on h.pid =a.id and h.type =3
+        </if>
+        <where>
+
+            <if test="params.applicationName !=null and params.applicationName !=''  ">
+                and c.name  REGEXP #{params.applicationName}
+            </if>
+            <if test="params.obligeeName !=null and params.obligeeName!=''">
+                and e.name  REGEXP #{params.obligeeName}
+            </if>
+            <if test="params.numberIpc !=null and params.numberIpc!=''">
+                and f.code like concat("%", #{params.numberIpc}, "%")
+            </if>
+            <if test="params.numberCpc !=null and params.numberCpc!=''">
+                and g.code like concat("%", #{params.numberCpc}, "%")
+            </if>
+            <if test="params.numberUpc !=null and params.numberUpc!=''">
+                and h.code like concat("%", #{params.numberUpc}, "%")
+            </if>
+            <if test="params.patentNo !=null and params.patentNo !=''">
+                and a.patentNo REGEXP  #{params.patentNo}
+            </if>
+            <if test="params.applicationNo !=null and params.applicationNo !=''">
+                and a.applicationNo like concat("%", #{params.applicationNo}, "%")
+            </if>
+            <if test="params.abstractStr !=null and params.abstractStr !=''">
+                and a.abstract like concat("%", #{params.abstractStr}, "%")
+            </if>
+            <if test="params.patentName !=null and params.patentName !=''">
+                and a.`name` like concat("%", #{params.patentName}, "%")
+            </if>
+            <if test="params.isIn ==0">
+             and   (i.product_id !=#{params.productId} or i.product_id is null)
+                and (t.product_id !=#{params.productId} or t.product_id is null)
+            </if>
+            <if test="params.isIn !=0">
+             and (i.product_id =#{params.productId} or t.product_id =#{params.productId})
+            </if>
+            <if test="params.orderItem!=null and params.orderItem!='SysOrder'">
+                order by #{params.orderItem}
+                <if test="params.orderType!=null">
+                    #{params.orderType}
+                </if>
+            </if>
+            <if test="params.orderItem==null">
+                order by a.patentno
+            </if>
+            <if test="params.orderItem=='SysOrder' and params.patentNos != null and params.patentNos.size()!=0">
+                order by field (a.patentno,
+                <foreach item="item" collection="params.patentNos" index="index" open="" separator=","
+                         close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test=" params.endNumber &gt; 0">
+                limit #{params.startNumber},#{params.endNumber}
+            </if>
+        </where>
+
+    </select>
+
+</mapper>

+ 3 - 0
PAS/src/main/resources/mapper/TaskMapper.xml

@@ -21,6 +21,9 @@
             <if test="params.projectId != null">
                 and a.tid = #{params.projectId}
             </if>
+            <if test="params.productId != null">
+                and a.product_id = #{params.productId}
+            </if>
             <if test="params.projectName != '' and params.projectName != null">
                 and c.name like concat('%', #{params.projectName}, '%')
             </if>