|
@@ -16,14 +16,17 @@ import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class UploadPatentBatchService {
|
|
|
private final FileUtils fileUtils;
|
|
|
+ private final SystemDictService systemDictService;
|
|
|
private final PatentImageService patentImageService;
|
|
|
private final PatentService patentService;
|
|
|
private final PatentAgencyService patentAgencyService;
|
|
@@ -40,6 +43,7 @@ public class UploadPatentBatchService {
|
|
|
private final PatentApplicantLinkService patentApplicantLinkService;
|
|
|
private final PatentLabelService patentLabelService;
|
|
|
private final PatentClassNumberLinkService patentClassNumberLinkService;
|
|
|
+ private final PatentAffairService patentAffairService;
|
|
|
|
|
|
@Async("singleThreadAsyncTaskExecutor")
|
|
|
public void uploadPatentBatch(TaskParams params, ProjectImportPatentVO projectImportPatentVO) {
|
|
@@ -65,15 +69,21 @@ public class UploadPatentBatchService {
|
|
|
//专利信息需要特殊处理部分
|
|
|
//专利信息(摘要附图)数据装配
|
|
|
PictureData pictureData = pictureDataMap.get(String.valueOf(i + 1));
|
|
|
- uploadParamsVO.getPatent().setAbstractPath(patentImageService.updatePatentImage(uploadParamsVO.getPatent().getId(), pictureData));
|
|
|
- //专利信息(代理机构)数据装配
|
|
|
- if (uploadParamsVO.getPatent().getAgencyId() != null) {
|
|
|
- uploadParamsVO.getPatent().setAgencyId(patentAgencyService.getAgencyStringIdByName(uploadParamsVO.getPatent().getAgencyId()));
|
|
|
+ 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()));
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ }
|
|
|
//将装配对象中的数据保存到数据库
|
|
|
- dataToDB(uploadParamsVO, projectImportPatentVO);
|
|
|
+ dataToDB(params, uploadParamsVO, projectImportPatentVO);
|
|
|
+
|
|
|
WebSocketServer.sendInfo(Response.websocket(new TaskWebSocketDTO()
|
|
|
.setTaskId(params.getTaskId())
|
|
|
.setProjectId(projectImportPatentVO.getProjectId())
|
|
@@ -109,54 +119,74 @@ public class UploadPatentBatchService {
|
|
|
* @name 数据库交互
|
|
|
* @description 将装配完毕的VO类向数据库中不同的表进行添加或修改操作
|
|
|
*/
|
|
|
- private void dataToDB(UploadParamsVO uploadParamsVO, ProjectImportPatentVO projectImportPatentVO) {
|
|
|
- // TODO: 2022/7/12 发明人地址 申请人地址 自定义字段 事务信息
|
|
|
- //专利信息
|
|
|
- //表:OS_PATENT
|
|
|
- uploadParamsVO.getPatent().updateById();
|
|
|
- //权利要求
|
|
|
- //表:OS_PATENT_RIGHT
|
|
|
- patentRightBusiness(uploadParamsVO);
|
|
|
- //说明书(文本)
|
|
|
- //表:OS_PATENT_INSTRUCTION_TEXT
|
|
|
- patentInstructionTextBusiness(uploadParamsVO);
|
|
|
- //代理人
|
|
|
- //表:OS_PATENT_AGENT
|
|
|
- patentAgentBusiness(uploadParamsVO);
|
|
|
- //质押质权人
|
|
|
- //表:OS_PATENT_PLEDGE
|
|
|
- patentPledgeBusiness(uploadParamsVO);
|
|
|
- //许可人
|
|
|
- //表:OS_PATENT_LICENSOR
|
|
|
- patentLicensorBusiness(uploadParamsVO);
|
|
|
- //简单同族
|
|
|
- //表:OS_PATENT_SIMPLEFAMILY
|
|
|
- patentSimplyFamilyBusiness(uploadParamsVO);
|
|
|
- //发明人
|
|
|
- //表:OS_PATENT_INVENTOR
|
|
|
- patentInventorBusiness(uploadParamsVO);
|
|
|
- patentInventorAddressBusiness(uploadParamsVO);
|
|
|
- //申请人/权利人
|
|
|
- //表:OS_APPLICATION_ATTR
|
|
|
- //权利人
|
|
|
- patentCurrentApplicationBusiness(uploadParamsVO);
|
|
|
- //申请人
|
|
|
- patentOriginalApplicationBusiness(uploadParamsVO);
|
|
|
- //专题库关联专利信息
|
|
|
- //表:OS_THEMATIC_PID
|
|
|
- patentThematicPidBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
- //标引内容关联专利信息
|
|
|
- //表:OS_PATENT_FIELD_PATENT_LINK
|
|
|
- patentProjectFieldPatentLinkBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
- //文件夹管理
|
|
|
- //表:OS_PORTFOLIO_LINK
|
|
|
- patentProjectFolderPatentLinkBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
- //标签
|
|
|
- //表:OS_PATENT_LABEL
|
|
|
- //patentLabelBusiness(uploadParamsVO, projectImportPatentVO);
|
|
|
- //分类号关联
|
|
|
- //表:OS_PATENT_TYPENO
|
|
|
- patentTypeNoBusiness(uploadParamsVO);
|
|
|
+ private void dataToDB(TaskParams params, UploadParamsVO uploadParamsVO, ProjectImportPatentVO projectImportPatentVO) {
|
|
|
+ //专利信息 OS_PATENT
|
|
|
+ if (uploadParamsVO.getPatent() != null) {
|
|
|
+ uploadParamsVO.getPatent().updateById();
|
|
|
+ }
|
|
|
+ //权利要求 OS_PATENT_RIGHT
|
|
|
+ if (uploadParamsVO.getPatentRight() != null && uploadParamsVO.getSelfContent() != null) {
|
|
|
+ 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
|
|
|
+ if (uploadParamsVO.getSimpleFamily() != null && uploadParamsVO.getPatSnapFamily() != null && uploadParamsVO.getInpadocFamily() != null) {
|
|
|
+ patentSimplyFamilyBusiness(uploadParamsVO);
|
|
|
+ }
|
|
|
+ //发明人 OS_PATENT_INVENTOR
|
|
|
+ if (uploadParamsVO.getPatentInventorList() != null && uploadParamsVO.getFirstName() != null && uploadParamsVO.getFirstAddress() != null) {
|
|
|
+ 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
|
|
|
+ if (uploadParamsVO.getMainIpc() != null && uploadParamsVO.getMainUpc() != null && uploadParamsVO.getCpcList() != null && uploadParamsVO.getLocList() != null && uploadParamsVO.getUpcList() != null && uploadParamsVO.getIpcList() != null) {
|
|
|
+ patentTypeNoBusiness(uploadParamsVO);
|
|
|
+ }
|
|
|
+ //事务信息 OS_PATENT_AFFAIR
|
|
|
+ if (uploadParamsVO.getPatentAffair() != null && uploadParamsVO.getSimpleStatus() != null) {
|
|
|
+ patentAffairBusiness(uploadParamsVO);
|
|
|
+ }
|
|
|
+ //自定义字段
|
|
|
+ if (uploadParamsVO.getKey() != null && uploadParamsVO.getFieldList() != null) {
|
|
|
+ patentFieldBusiness(params, uploadParamsVO, projectImportPatentVO);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -166,13 +196,15 @@ public class UploadPatentBatchService {
|
|
|
* @description 查询数据是否存在 如果存在 返回该条数据 如果不存在 新增一条数据
|
|
|
*/
|
|
|
private void getOneOrInsertOne(UploadParamsVO uploadParamsVO) {
|
|
|
- //用专利号查询该条数据是否存在
|
|
|
- Patent patent = patentService.getByPatentNo(uploadParamsVO.getPatent().getPatentNo());
|
|
|
- //如果不存在就新增一条
|
|
|
- if (patent == null) {
|
|
|
- uploadParamsVO.getPatent().insert();
|
|
|
- } else {
|
|
|
- uploadParamsVO.getPatent().setId(patent.getId());
|
|
|
+ if (uploadParamsVO.getPatent() != null) {
|
|
|
+ //用专利号查询该条数据是否存在
|
|
|
+ Patent patent = patentService.getByPatentNo(uploadParamsVO.getPatent().getPatentNo());
|
|
|
+ //如果不存在就新增一条
|
|
|
+ if (patent == null) {
|
|
|
+ uploadParamsVO.getPatent().insert();
|
|
|
+ } else {
|
|
|
+ uploadParamsVO.getPatent().setId(patent.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -246,20 +278,15 @@ public class UploadPatentBatchService {
|
|
|
PatentInventorParams patentInventorParams = new PatentInventorParams();
|
|
|
patentInventorParams.setPatentId(uploadParamsVO.getPatent().getId());
|
|
|
patentInventorParams.setFirstName(uploadParamsVO.getFirstName());
|
|
|
+ patentInventorParams.setFirstAddress(uploadParamsVO.getFirstAddress());
|
|
|
+ List<String> addressList = uploadParamsVO.getPatentInventorList().stream().map(PatentInventor::getAddress).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ patentInventorParams.setAddressList(addressList);
|
|
|
List<String> nameList = uploadParamsVO.getPatentInventorList().stream().map(PatentInventor::getName).collect(Collectors.toList());
|
|
|
patentInventorParams.setNameList(nameList);
|
|
|
|
|
|
patentInventorService.updatePatentInventor(patentInventorParams);
|
|
|
- }
|
|
|
-
|
|
|
- private void patentInventorAddressBusiness(UploadParamsVO uploadParamsVO) {
|
|
|
- PatentInventorAddressParams patentInventorAddressParams = new PatentInventorAddressParams();
|
|
|
- List<String> addressList = uploadParamsVO.getPatentInventorList().stream().map(PatentInventor::getAddress).collect(Collectors.toList());
|
|
|
- patentInventorAddressParams.setAddress(addressList);
|
|
|
- patentInventorAddressParams.setFirstAddress(uploadParamsVO.getFirstAddress());
|
|
|
- patentInventorAddressParams.setPatentId(uploadParamsVO.getPatent().getId());
|
|
|
|
|
|
- patentInventorService.updatePatentInventorAddress(patentInventorAddressParams);
|
|
|
+ //patentInventorService.updatePatentInventorAddress(patentInventorAddressParams);
|
|
|
}
|
|
|
|
|
|
private void patentCurrentApplicationBusiness(UploadParamsVO uploadParamsVO) {
|
|
@@ -286,12 +313,8 @@ public class UploadPatentBatchService {
|
|
|
PatentLabelParams patentLabelParams = new PatentLabelParams();
|
|
|
patentLabelParams.setPatentId(uploadParamsVO.getPatent().getId());
|
|
|
patentLabelParams.setProjectId(projectImportPatentVO.getProjectId());
|
|
|
- if (uploadParamsVO.getPatentLabelList().get(0).getName() != null) {
|
|
|
- List<String> labelList = uploadParamsVO.getPatentLabelList().stream().map(PatentLabel::getName).collect(Collectors.toList());
|
|
|
- patentLabelParams.setLabel(labelList);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ List<String> labelList = uploadParamsVO.getPatentLabelList().stream().map(PatentLabel::getName).collect(Collectors.toList());
|
|
|
+ patentLabelParams.setLabel(labelList);
|
|
|
|
|
|
patentLabelService.updatePatentLabel(patentLabelParams);
|
|
|
}
|
|
@@ -309,5 +332,31 @@ public class UploadPatentBatchService {
|
|
|
patentClassNumberLinkService.updatePatentClassNumberLink(patentClassNumberParams);
|
|
|
}
|
|
|
|
|
|
+ private void patentAffairBusiness(UploadParamsVO uploadParamsVO) {
|
|
|
+ PatentAffairParams patentAffairParams = new PatentAffairParams();
|
|
|
+ patentAffairParams.setPatentId(uploadParamsVO.getPatent().getId());
|
|
|
+ patentAffairParams.setContent(uploadParamsVO.getPatentAffair().getContent());
|
|
|
+ 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.getSimpleStatus()))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(new SystemDict()).getValue());
|
|
|
+ patentAffairParams.setSimpleStatus(simpleStatus);
|
|
|
+ patentAffairParams.setStatusList(uploadParamsVO.getPatentAffair().getStatus());
|
|
|
+ patentAffairParams.setDateTime(uploadParamsVO.getPatentAffair().getDateTime());
|
|
|
+
|
|
|
+ patentAffairService.updatePatientAffair(patentAffairParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void patentFieldBusiness(TaskParams params, UploadParamsVO uploadParamsVO, ProjectImportPatentVO projectImportPatentVO) {
|
|
|
+ PatentCustomFieldParams patentCustomFieldParams = new PatentCustomFieldParams();
|
|
|
+ patentCustomFieldParams.setPatentId(uploadParamsVO.getPatent().getId());
|
|
|
+ patentCustomFieldParams.setProjectId(projectImportPatentVO.getProjectId());
|
|
|
+ patentCustomFieldParams.setUserId(Integer.parseInt(params.getUserId()));
|
|
|
+ patentCustomFieldParams.put(uploadParamsVO.getKey(), uploadParamsVO.getFieldList());
|
|
|
+
|
|
|
+ patentService.updatePatentCustomField(patentCustomFieldParams);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|