|
@@ -9,6 +9,7 @@ import cn.cslg.pas.common.model.vo.UploadParamsVO;
|
|
import cn.cslg.pas.common.model.vo.UploadSettingVO;
|
|
import cn.cslg.pas.common.model.vo.UploadSettingVO;
|
|
import cn.cslg.pas.common.utils.*;
|
|
import cn.cslg.pas.common.utils.*;
|
|
import cn.cslg.pas.domain.*;
|
|
import cn.cslg.pas.domain.*;
|
|
|
|
+import cn.cslg.pas.mapper.ImportErrorLogMapper;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.apache.poi.ss.usermodel.PictureData;
|
|
import org.apache.poi.ss.usermodel.PictureData;
|
|
@@ -18,10 +19,8 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
-import java.util.Collections;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -46,9 +45,10 @@ public class UploadPatentBatchService {
|
|
private final PatentLabelService patentLabelService;
|
|
private final PatentLabelService patentLabelService;
|
|
private final PatentClassNumberLinkService patentClassNumberLinkService;
|
|
private final PatentClassNumberLinkService patentClassNumberLinkService;
|
|
private final PatentAffairService patentAffairService;
|
|
private final PatentAffairService patentAffairService;
|
|
|
|
+ private final ImportErrorLogMapper importErrorLogMapper;
|
|
|
|
+ private static int FLAG = 0;
|
|
|
|
|
|
@Async("singleThreadAsyncTaskExecutor")
|
|
@Async("singleThreadAsyncTaskExecutor")
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
public void uploadPatentBatch(TaskParams params, ProjectImportPatentVO projectImportPatentVO) {
|
|
public void uploadPatentBatch(TaskParams params, ProjectImportPatentVO projectImportPatentVO) {
|
|
Integer total = params.getRowList().size();
|
|
Integer total = params.getRowList().size();
|
|
try {
|
|
try {
|
|
@@ -87,6 +87,7 @@ public class UploadPatentBatchService {
|
|
//将装配对象中的数据保存到数据库
|
|
//将装配对象中的数据保存到数据库
|
|
dataToDB(params, uploadParamsVO, projectImportPatentVO);
|
|
dataToDB(params, uploadParamsVO, projectImportPatentVO);
|
|
|
|
|
|
|
|
+ //通过WebSocket 在每一次循环结束后 向前端发送完成进度
|
|
WebSocketServer.sendInfo(Response.websocket(new TaskWebSocketDTO()
|
|
WebSocketServer.sendInfo(Response.websocket(new TaskWebSocketDTO()
|
|
.setTaskId(params.getTaskId())
|
|
.setTaskId(params.getTaskId())
|
|
.setProjectId(projectImportPatentVO.getProjectId())
|
|
.setProjectId(projectImportPatentVO.getProjectId())
|
|
@@ -99,6 +100,7 @@ public class UploadPatentBatchService {
|
|
.setUrl("")
|
|
.setUrl("")
|
|
.setTotal(total), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), params.getUserId());
|
|
.setTotal(total), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), params.getUserId());
|
|
}
|
|
}
|
|
|
|
+
|
|
SpringUtil.getBean(ProjectService.class).setImportPatentTaskStatus(2, params.getTaskId());
|
|
SpringUtil.getBean(ProjectService.class).setImportPatentTaskStatus(2, params.getTaskId());
|
|
WebSocketServer.sendInfo(Response.websocket(new TaskWebSocketDTO()
|
|
WebSocketServer.sendInfo(Response.websocket(new TaskWebSocketDTO()
|
|
.setTaskId(params.getTaskId())
|
|
.setTaskId(params.getTaskId())
|
|
@@ -113,9 +115,12 @@ public class UploadPatentBatchService {
|
|
.setTotal(total), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), params.getUserId());
|
|
.setTotal(total), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), params.getUserId());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
SpringUtil.getBean(ProjectService.class).setImportPatentTaskStatus(3, params.getTaskId());
|
|
SpringUtil.getBean(ProjectService.class).setImportPatentTaskStatus(3, params.getTaskId());
|
|
- WebSocketServer.sendInfo(Response.error(ResponseEnum.PATENT_IMPORT_TASK_ERROR), params.getUserId());
|
|
|
|
|
|
+ if (FLAG > 0) {
|
|
|
|
+ int successCount = total - FLAG;
|
|
|
|
+ WebSocketServer.sendInfo(Response.error("部分数据上传成功" + "\n" + "成功条数:" + successCount + "失败条数:" + FLAG), params.getUserId());
|
|
|
|
+ }
|
|
|
|
+ FLAG = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -125,67 +130,84 @@ public class UploadPatentBatchService {
|
|
* @name 数据库交互
|
|
* @name 数据库交互
|
|
* @description 将装配完毕的VO类向数据库中不同的表进行添加或修改操作
|
|
* @description 将装配完毕的VO类向数据库中不同的表进行添加或修改操作
|
|
*/
|
|
*/
|
|
- private void dataToDB(TaskParams params, UploadParamsVO uploadParamsVO, ProjectImportPatentVO projectImportPatentVO) {
|
|
|
|
- //专利信息 OS_PATENT
|
|
|
|
- if (uploadParamsVO.getPatent() != null) {
|
|
|
|
- List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Collections.singletonList(Constants.PATENT_SIMPLE_STATUS));
|
|
|
|
- Integer simpleStatus = Integer.parseInt(systemDictList.stream()
|
|
|
|
- .filter(systemDict -> systemDict.getType().equals(Constants.PATENT_SIMPLE_STATUS) && systemDict.getLabel().equals(uploadParamsVO.getPatentSimpleStatus()))
|
|
|
|
- .findFirst()
|
|
|
|
- .orElse(new SystemDict()).getValue());
|
|
|
|
- uploadParamsVO.getPatent().setSimpleStatus(simpleStatus);
|
|
|
|
- uploadParamsVO.getPatent().updateById();
|
|
|
|
- }
|
|
|
|
- //权利要求 OS_PATENT_RIGHT
|
|
|
|
- patentRightBusiness(uploadParamsVO);
|
|
|
|
- //说明书(文本) OS_PATENT_INSTRUCTION_TEXT
|
|
|
|
- if (uploadParamsVO.getPatentInstructionText() != null) {
|
|
|
|
- patentInstructionTextBusiness(uploadParamsVO);
|
|
|
|
- }
|
|
|
|
- //代理人 OS_PATENT_AGENT
|
|
|
|
- if (uploadParamsVO.getPatentAgentList() != null) {
|
|
|
|
- patentAgentBusiness(uploadParamsVO);
|
|
|
|
- }
|
|
|
|
- //质押质权人 OS_PATENT_PLEDGE
|
|
|
|
- if (uploadParamsVO.getPatentPledgeList() != null) {
|
|
|
|
- patentPledgeBusiness(uploadParamsVO);
|
|
|
|
- }
|
|
|
|
- //许可人 OS_PATENT_LICENSOR
|
|
|
|
- if (uploadParamsVO.getPatentLicensorList() != null) {
|
|
|
|
- patentLicensorBusiness(uploadParamsVO);
|
|
|
|
- }
|
|
|
|
- //简单同族 OS_PATENT_SIMPLEFAMILY
|
|
|
|
- patentSimplyFamilyBusiness(uploadParamsVO);
|
|
|
|
- //发明人 OS_PATENT_INVENTOR
|
|
|
|
- patentInventorBusiness(uploadParamsVO);
|
|
|
|
- //申请人/权利人 OS_APPLICATION_ATTR
|
|
|
|
- //权利人
|
|
|
|
- //patentCurrentApplicationBusiness(uploadParamsVO);
|
|
|
|
- //申请人
|
|
|
|
- //patentOriginalApplicationBusiness(uploadParamsVO);
|
|
|
|
- //专题库关联专利信息 OS_THEMATIC_PID
|
|
|
|
- if (uploadParamsVO.getPatent() != null) {
|
|
|
|
- patentThematicPidBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
|
- }
|
|
|
|
- //标引内容关联专利信息 OS_PATENT_FIELD_PATENT_LINK
|
|
|
|
- if (uploadParamsVO.getPatent() != null) {
|
|
|
|
- patentProjectFieldPatentLinkBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
|
- }
|
|
|
|
- //文件夹管理 OS_PORTFOLIO_LINK
|
|
|
|
- if (uploadParamsVO.getPatent() != null) {
|
|
|
|
- patentProjectFolderPatentLinkBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
|
- }
|
|
|
|
- //标签 OS_PATENT_LABEL
|
|
|
|
- if (uploadParamsVO.getPatentLabelList() != null) {
|
|
|
|
- patentLabelBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
|
- }
|
|
|
|
- //分类号关联 OS_PATENT_TYPENO
|
|
|
|
- patentTypeNoBusiness(uploadParamsVO);
|
|
|
|
- //事务信息 OS_PATENT_AFFAIR
|
|
|
|
- patentAffairBusiness(uploadParamsVO);
|
|
|
|
- //自定义字段
|
|
|
|
- if (uploadParamsVO.getKey() != null && uploadParamsVO.getFieldList() != null) {
|
|
|
|
- patentFieldBusiness(params, uploadParamsVO, projectImportPatentVO);
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void dataToDB(TaskParams params, UploadParamsVO uploadParamsVO, ProjectImportPatentVO projectImportPatentVO) {
|
|
|
|
+ try {
|
|
|
|
+ //专利信息 OS_PATENT
|
|
|
|
+ if (uploadParamsVO.getPatent() != null) {
|
|
|
|
+ List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Collections.singletonList(Constants.PATENT_SIMPLE_STATUS));
|
|
|
|
+ Integer simpleStatus = Integer.parseInt(systemDictList.stream()
|
|
|
|
+ .filter(systemDict -> systemDict.getType().equals(Constants.PATENT_SIMPLE_STATUS) && systemDict.getLabel().equals(uploadParamsVO.getPatentSimpleStatus()))
|
|
|
|
+ .findFirst()
|
|
|
|
+ .orElse(new SystemDict()).getValue());
|
|
|
|
+ uploadParamsVO.getPatent().setSimpleStatus(simpleStatus);
|
|
|
|
+ uploadParamsVO.getPatent().updateById();
|
|
|
|
+ }
|
|
|
|
+ //权利要求 OS_PATENT_RIGHT
|
|
|
|
+ patentRightBusiness(uploadParamsVO);
|
|
|
|
+ //说明书(文本) OS_PATENT_INSTRUCTION_TEXT
|
|
|
|
+ if (uploadParamsVO.getPatentInstructionText() != null) {
|
|
|
|
+ patentInstructionTextBusiness(uploadParamsVO);
|
|
|
|
+ }
|
|
|
|
+ //代理人 OS_PATENT_AGENT
|
|
|
|
+ if (uploadParamsVO.getPatentAgentList() != null) {
|
|
|
|
+ patentAgentBusiness(uploadParamsVO);
|
|
|
|
+ }
|
|
|
|
+ //质押质权人 OS_PATENT_PLEDGE
|
|
|
|
+ if (uploadParamsVO.getPatentPledgeList() != null) {
|
|
|
|
+ patentPledgeBusiness(uploadParamsVO);
|
|
|
|
+ }
|
|
|
|
+ //许可人 OS_PATENT_LICENSOR
|
|
|
|
+ if (uploadParamsVO.getPatentLicensorList() != null) {
|
|
|
|
+ patentLicensorBusiness(uploadParamsVO);
|
|
|
|
+ }
|
|
|
|
+ //简单同族 OS_PATENT_SIMPLEFAMILY
|
|
|
|
+ patentSimplyFamilyBusiness(uploadParamsVO);
|
|
|
|
+ //发明人 OS_PATENT_INVENTOR
|
|
|
|
+ patentInventorBusiness(uploadParamsVO);
|
|
|
|
+ //申请人/权利人 OS_APPLICATION_ATTR
|
|
|
|
+ //权利人
|
|
|
|
+ //patentCurrentApplicationBusiness(uploadParamsVO);
|
|
|
|
+ //申请人
|
|
|
|
+ //patentOriginalApplicationBusiness(uploadParamsVO);
|
|
|
|
+ //专题库关联专利信息 OS_THEMATIC_PID
|
|
|
|
+ if (uploadParamsVO.getPatent() != null) {
|
|
|
|
+ patentThematicPidBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
|
+ }
|
|
|
|
+ //标引内容关联专利信息 OS_PATENT_FIELD_PATENT_LINK
|
|
|
|
+ if (uploadParamsVO.getPatent() != null) {
|
|
|
|
+ patentProjectFieldPatentLinkBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
|
+ }
|
|
|
|
+ //文件夹管理 OS_PORTFOLIO_LINK
|
|
|
|
+ if (uploadParamsVO.getPatent() != null) {
|
|
|
|
+ patentProjectFolderPatentLinkBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
|
+ }
|
|
|
|
+ //标签 OS_PATENT_LABEL
|
|
|
|
+ if (uploadParamsVO.getPatentLabelList() != null) {
|
|
|
|
+ patentLabelBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
|
+ }
|
|
|
|
+ //分类号关联 OS_PATENT_TYPENO
|
|
|
|
+ patentTypeNoBusiness(uploadParamsVO);
|
|
|
|
+ //事务信息 OS_PATENT_AFFAIR
|
|
|
|
+ patentAffairBusiness(uploadParamsVO);
|
|
|
|
+ //自定义字段
|
|
|
|
+ if (uploadParamsVO.getKey() != null && uploadParamsVO.getFieldList() != null) {
|
|
|
|
+ patentFieldBusiness(params, uploadParamsVO, projectImportPatentVO);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ if (uploadParamsVO.getPatent() != null) {
|
|
|
|
+ ImportErrorLog importErrorLog = new ImportErrorLog();
|
|
|
|
+ importErrorLog.setPatentId(uploadParamsVO.getPatent().getId())
|
|
|
|
+ .setPatentNo(uploadParamsVO.getPatent().getPatentNo())
|
|
|
|
+ .setCreateTime(new SimpleDateFormat("yyyy-MM-dd 24HI:mm:ss").format(new Date()))
|
|
|
|
+ .setCreateUserId(Integer.parseInt(params.getUserId()))
|
|
|
|
+ .setMistakeMessage(e.getMessage())
|
|
|
|
+ .setProjectId(params.getProjectId());
|
|
|
|
+ importErrorLogMapper.insert(importErrorLog);
|
|
|
|
+ FLAG += 1;
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -388,4 +410,3 @@ public class UploadPatentBatchService {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|