chendayu пре 2 година
родитељ
комит
b501cc7749

+ 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/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() {
 
     }

+ 7 - 5
PAS/src/main/java/cn/cslg/pas/controller/ProductPatentController.java

@@ -38,27 +38,29 @@ 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){
+        List<String> patentNos = assoProductPatentService.deletePatents(patentDTO);
+        if (patentNos.size() == 0) {
             return Response.success("删除成功");
         }
-    return  Response.successBut(patentNos);
+        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);
+        TaskParams taskParams = projectService.getImportPatentTaskParamsBro(file, productId);
+        uploadPatentBatchService.uploadPatentForProduct(taskParams, productId);
         return Response.success();
     }
 

+ 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)

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

@@ -1,22 +0,0 @@
-package cn.cslg.pas.mapper;
-
-import cn.cslg.pas.domain.asso.AssoProductPatent;
-import org.springframework.stereotype.Repository;
-
-/**
- * 产品专利关联表的Mapper层接口
- *
- * @Author chenyu
- * @Date 2023/3/16
- */
-@Repository
-public interface AssoProductPatentMapper {
-    /**
-     * 插入数据
-     *
-     * @param assoProductPatent 数据对象
-     * @return 返回受影响的行数
-     */
-    int insert(AssoProductPatent assoProductPatent);
-
-}

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

@@ -3,6 +3,7 @@ package cn.cslg.pas.mapper;
 import cn.cslg.pas.common.model.dto.AssoStructurePatentQueryDTO;
 import cn.cslg.pas.common.model.vo.AssoStructurePatentVO;
 import cn.cslg.pas.domain.asso.AssoStructurePatent;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -14,7 +15,7 @@ import java.util.List;
  * @Date 2023/3/13
  */
 @Repository
-public interface AssoStructurePatentMapper {
+public interface AssoStructurePatentMapper extends BaseMapper<AssoStructurePatent> {
     /**
      * 插入标引数据
      *

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

@@ -0,0 +1,35 @@
+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.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 管理员表 Mapper 接口
+ * </p>
+ *
+ * @author 王岩
+ * @since 2022-03-25
+ */
+@Mapper
+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);
+
+
+
+}

+ 15 - 44
PAS/src/main/java/cn/cslg/pas/service/ProjectService.java

@@ -5,14 +5,15 @@ import cn.cslg.pas.common.core.exception.CustomException;
 import cn.cslg.pas.common.model.PersonnelVO;
 import cn.cslg.pas.common.model.dto.ClientDTO;
 import cn.cslg.pas.common.model.dto.UploadFileDTO;
-import cn.cslg.pas.common.model.vo.*;
+import cn.cslg.pas.common.model.vo.ProjectExportVO;
+import cn.cslg.pas.common.model.vo.ProjectImportVO;
+import cn.cslg.pas.common.model.vo.ProjectVO;
+import cn.cslg.pas.common.model.vo.TaskParams;
 import cn.cslg.pas.common.utils.*;
 import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
 import cn.cslg.pas.common.utils.SecurityUtils.SecurityUtils;
 import cn.cslg.pas.common.utils.auth.checkAuth;
 import cn.cslg.pas.domain.*;
-import cn.cslg.pas.mapper.AssoStructurePatentMapper;
-import cn.cslg.pas.mapper.ProductMapper;
 import cn.cslg.pas.mapper.ProjectMapper;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.IterUtil;
@@ -35,7 +36,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.scheduling.annotation.Async;
@@ -59,7 +59,6 @@ import java.util.stream.Collectors;
  * @author 王岩
  * @since 2022-01-24
  */
-@Slf4j
 @Service
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
@@ -102,14 +101,12 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
     private final UserService userService;
     private final LoginUtils loginUtils;
     private final RequestService requestService;
-    private final AssoStructurePatentMapper assoStructurePatentMapper;
-    private final ProductMapper productMapper;
 
     public Project getProjectByName(String name) {
         LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
-        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        PersonnelVO personnelVO =cacheUtils.getLoginUser(loginUtils.getId());
         queryWrapper.eq(Project::getName, name);
-        queryWrapper.eq(Project::getTenantId, personnelVO.getTenantId());
+        queryWrapper.eq(Project::getTenantId,personnelVO.getTenantId());
         queryWrapper.last("limit 1");
         return this.getOne(queryWrapper);
     }
@@ -131,7 +128,6 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
                 params.setTenantId(personnelVO.getTenantId());
             }
         }
-        //分页查询专题库列表
         IPage<Project> pageList = baseMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
 
         List<Project> dataList = pageList.getRecords();
@@ -143,12 +139,6 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
             JSONArray jsonArray1 = JSON.parseArray(jsonObject);
             List<ProjectVO.Department> departmentList = jsonArray1.toJavaList(ProjectVO.Department.class);
             for (Project project : dataList) {
-                Integer productId = project.getProductId();
-                if (productId != null) {
-                    ProductVO queryResult = productMapper.getStandardById(productId);
-                    String productName = queryResult.getProductName();
-                    project.setProductName(productName);
-                }
                 for (ProjectVO.Department department : departmentList) {
                     if (project.getDepartmentId() != null) {
                         if (project.getDepartmentId().equals(department.getId())) {
@@ -200,19 +190,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         }
         LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(Project::getId, ids);
-        //根据ids查询专题库列表
         List<Project> dataList = this.list(queryWrapper);
-        //↓根据专题库id查询专题库时,查询到的就是一条,就将当前专题库的产品名字赋值(他妈的两个控制层方法调当前业务层,坑爹)
-        if (dataList.size() == 1) {
-            for (Project project : dataList) {
-                Integer productId = project.getProductId();
-                if (productId != null) {
-                    ProductVO queryResult = productMapper.getStandardById(productId);
-                    String productName = queryResult.getProductName();
-                    project.setProductName(productName);
-                }
-            }
-        }
         try {
             //获取所属部门对应信息
             String jsonObject = requestService.getDepartmentFromPCS(dataList);
@@ -282,7 +260,8 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
                 item.setTypeList(StringUtils.changeStringToInteger(item.getType(), ","));
                 item.setTypeName(systemDictList.stream().filter(systemDict -> systemDict.getType().equals(Constants.INVESTIGATION_TYPE) && item.getTypeList().contains(Integer.parseInt(systemDict.getValue()))).map(SystemDict::getLabel).collect(Collectors.toList()));
                 item.setType(null);
-            } else {
+            }
+            else{
                 item.setTypeList(new ArrayList<Integer>());
             }
         });
@@ -431,12 +410,11 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
     @Transactional
     public String add(Project project) throws IOException {
         PersonnelVO user = cacheUtils.getLoginUserPersonnel(loginUtils.getId());
-        //检查专题库名称是否被占用
         Project temp = this.getProjectByName(project.getName());
         if (temp != null) {
             return Response.error("专题库名称已存在");
         }
-        if (project.getClientId() == null || project.getClientId() == -1) {
+        if (project.getClientId()==null||project.getClientId() == -1) {
             ClientDTO clientDTO = new ClientDTO();
             clientDTO.setName(project.getClientName());
             clientDTO.setTenantId(user.getTenantId());
@@ -450,8 +428,6 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         project.setCreateBy(loginUtils.getId());
         project.setCreateTime(DateUtils.getDateTime());
         project.setTenantId(user.getTenantId());
-        //专题库表新增数据
-        log.info("专题库表新增数据");
         project.insert();
         this.addProjectUser(project.getId());
         return Response.success(project.getId());
@@ -459,13 +435,11 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
 
     @Transactional
     public String edit(Project project) throws IOException {
-        System.out.println(project);
         Project temp = this.getProjectByName(project.getName());
-        //检查尝试修改的新专题库名称是否被占用
         if (temp != null && !temp.getId().equals(project.getId())) {
             return Response.error("专题库名称已存在");
         }
-        if (project.getClientId() == null || project.getClientId() == -1) {
+        if (project.getClientId()==null||project.getClientId() == -1) {
             ClientDTO clientDTO = new ClientDTO();
             clientDTO.setName(project.getClientName());
             clientDTO.setTenantId(project.getTenantId());
@@ -476,16 +450,12 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         }
         project.setScenario(StringUtils.join(project.getScenarioList(), ","));
         project.setType(StringUtils.join(project.getTypeList(), ","));
-        //专题库表修改数据
-        log.info("专题库表修改数据");
         project.updateById();
         return Response.success();
     }
 
     @Transactional
     public String delete(Integer id) {
-        //专题库表删除数据
-        log.info("专题库表删除数据");
         this.removeById(id);
         this.deleteProjectUser(id, loginUtils.getId());
         projectPatentLinkService.deleteByProjectId(id);
@@ -494,8 +464,6 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         projectUserService.deleteByProjectId(id);
         projectFileService.deleteByProjectId(id);
         patentApplicantMergeLinkService.deleteByProjectId(id);
-        //陈宇 ↓ 删除专题库id关联产品id关联架构id(asso_structure_patent表)数据
-        assoStructurePatentMapper.deleteByProjectId(id);
         return Response.success();
     }
 
@@ -607,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);
@@ -619,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);
         //获得文档保存的路径
@@ -631,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);
     }

+ 78 - 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,80 @@ 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);
+                //添加关联关系
+                assoProductPatentService.addPatents(Arrays.asList(uploadParamsVO.getPatent().getPatentNo()),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;
+        }
+    }
 }

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

@@ -0,0 +1,169 @@
+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.AssoStructurePatent;
+import cn.cslg.pas.domain.asso.AssoProductPatent;
+import cn.cslg.pas.mapper.asso.AssoProductPatentMapper;
+import cn.cslg.pas.service.*;
+import cn.cslg.pas.service.impl.StructurePatentServiceImpl;
+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 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 StructurePatentServiceImpl 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<AssoStructurePatent> assoWrapper = new LambdaQueryWrapper<>();
+            assoWrapper.select(AssoStructurePatent::getPatentNo);
+            assoWrapper.eq(AssoStructurePatent::getProjectId, patentDTO.getProductId())
+                    .in(AssoStructurePatent::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;
+    }
+
+
+}

+ 2 - 1
PAS/src/main/java/cn/cslg/pas/service/impl/StructurePatentServiceImpl.java

@@ -7,6 +7,7 @@ import cn.cslg.pas.domain.asso.AssoStructurePatent;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.AssoStructurePatentMapper;
 import cn.cslg.pas.service.IStructurePatentService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -23,7 +24,7 @@ import java.util.List;
 @RequiredArgsConstructor
 @Slf4j
 @Service
-public class StructurePatentServiceImpl implements IStructurePatentService {
+public class StructurePatentServiceImpl extends ServiceImpl<AssoStructurePatentMapper, AssoStructurePatent> implements IStructurePatentService {
     private final AssoStructurePatentMapper assoStructurePatentMapper;
 
     /**

+ 172 - 6
PAS/src/main/resources/mapper/AssoProductPatentMapper.xml

@@ -1,12 +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.AssoProductPatentMapper">
-    <!--插入数据-->
-    <!--int insert(AssoProductPatent assoProductPatent);-->
-    <insert id="insert" useGeneratedKeys="true" keyProperty="id">
-        insert into asso_product_patent (patent_no, product_id)
-        values (#{patentNo}, #{productId});
+<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>