|
@@ -0,0 +1,671 @@
|
|
|
+package cn.cslg.pas.service.exportProject;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.core.base.FamilyType;
|
|
|
+import cn.cslg.pas.common.dto.business.CustomFieldDTO;
|
|
|
+import cn.cslg.pas.common.dto.business.CustomOptionDTO;
|
|
|
+import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
|
|
|
+import cn.cslg.pas.common.dto.business.TreeNodeDTO;
|
|
|
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
|
|
|
+import cn.cslg.pas.common.model.importTaskModel.PatentInventor;
|
|
|
+import cn.cslg.pas.common.utils.DateUtils;
|
|
|
+import cn.cslg.pas.common.utils.FileUtils;
|
|
|
+import cn.cslg.pas.common.utils.FormatUtil;
|
|
|
+import cn.cslg.pas.common.utils.esDataForm.AddressSplitter;
|
|
|
+import cn.cslg.pas.common.utils.esDataForm.PatentClassifySplitter;
|
|
|
+import cn.cslg.pas.domain.business.TreeNode;
|
|
|
+import cn.cslg.pas.domain.es.*;
|
|
|
+import cn.cslg.pas.service.business.CommonService;
|
|
|
+import cn.cslg.pas.service.business.CustomFieldService;
|
|
|
+import cn.cslg.pas.service.business.CustomOptionService;
|
|
|
+import cn.cslg.pas.service.business.TreeNodeService;
|
|
|
+import cn.cslg.pas.service.business.es.EsService;
|
|
|
+import cn.cslg.pas.service.common.FileManagerService;
|
|
|
+import cn.cslg.pas.service.exportProject.oldPasEntity.*;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.context.annotation.Scope;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.time.Period;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Scope("prototype")
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class ImportFromFileToEsService {
|
|
|
+ private final CustomFieldService customFieldService;
|
|
|
+ private final TreeNodeService treeNodeService;
|
|
|
+ private final CustomOptionService customOptionService;
|
|
|
+ private final EsService esService;
|
|
|
+ private final FileManagerService fileManagerService;
|
|
|
+
|
|
|
+ public void ImportFromFile(File file, Integer projectId) {
|
|
|
+//获取自定义栏位列表
|
|
|
+ List<OldProjectField> oldProjectFields = new ArrayList<>();
|
|
|
+ List<OldProjectFieldOption> oldProjectFieldOptions = new ArrayList<>();
|
|
|
+ List<OldProjectFieldText> oldProjectFieldTexts = new ArrayList<>();
|
|
|
+ List<OldProjectFieldTree> oldProjectFieldTrees = new ArrayList<>();
|
|
|
+ List<OldProjectFolder> oldProjectFolders = new ArrayList<>();
|
|
|
+ List<File> files = new ArrayList<>();
|
|
|
+ this.saveCustomField(oldProjectFields, oldProjectFieldOptions, oldProjectFieldTexts, oldProjectFieldTrees, projectId);
|
|
|
+ this.saveFolder(oldProjectFolders, projectId);
|
|
|
+
|
|
|
+ for (File pFile : files) {
|
|
|
+ OldPatentDTO oldPatentDTO = new OldPatentDTO();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void saveCustomField(List<OldProjectField> oldProjectFields, List<OldProjectFieldOption> oldProjectFieldOptions, List<OldProjectFieldText> oldProjectFieldTexts, List<OldProjectFieldTree> oldProjectFieldTrees, Integer projectId) {
|
|
|
+ for (OldProjectField oldProjectField : oldProjectFields) {
|
|
|
+ //保存自定义栏位内容
|
|
|
+ CustomFieldDTO customFieldDTO = new CustomFieldDTO();
|
|
|
+ customFieldDTO.setName(oldProjectField.getName());
|
|
|
+ customFieldDTO.setDescription(oldProjectField.getRemark());
|
|
|
+ if (oldProjectField.getStatus() != null && oldProjectField.getStatus().equals(1)) {
|
|
|
+ customFieldDTO.setStatus(true);
|
|
|
+ } else {
|
|
|
+ customFieldDTO.setStatus(false);
|
|
|
+ }
|
|
|
+ customFieldDTO.setProjectId(projectId);
|
|
|
+ customFieldDTO.setPersonId(oldProjectField.getCreateBy().toString());
|
|
|
+ Integer type = oldProjectField.getType();
|
|
|
+ customFieldDTO.setType(type);
|
|
|
+ Integer oldCustomFieldId = oldProjectField.getId();
|
|
|
+ Integer customFieldId = customFieldService.addCustomField(customFieldDTO);
|
|
|
+ oldProjectField.setNewId(customFieldId);
|
|
|
+ switch (type) {
|
|
|
+ case 0:
|
|
|
+ case 1:
|
|
|
+
|
|
|
+ case 2:
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ case 5:
|
|
|
+ List<OldProjectFieldOption> newOldFieldOptions = oldProjectFieldOptions.stream().filter(item -> item.getFieldId().equals(oldCustomFieldId)).collect(Collectors.toList());
|
|
|
+ for (OldProjectFieldOption oldProjectFieldOption : newOldFieldOptions) {
|
|
|
+ CustomOptionDTO customOptionDTO = new CustomOptionDTO();
|
|
|
+ customOptionDTO.setCustomFieldId(customFieldId);
|
|
|
+ customOptionDTO.setName(oldProjectFieldOption.getName());
|
|
|
+ Integer id = customOptionService.simpleAddCustomOption(customOptionDTO);
|
|
|
+ oldProjectFieldOption.setNewId(id);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ List<OldProjectFieldTree> newOldFieldTrees = oldProjectFieldTrees.stream().filter(item -> item.getFieldId().equals(oldCustomFieldId)).collect(Collectors.toList());
|
|
|
+ List<OldProjectFieldTree> rootTrees = newOldFieldTrees.stream().filter(item -> item.getParentId().equals(0)).collect(Collectors.toList());
|
|
|
+ rootTrees.forEach(item -> item.setParentId(0));
|
|
|
+ while (rootTrees.size() > 0) {
|
|
|
+ OldProjectFieldTree oldProjectFieldTree = rootTrees.remove(0);
|
|
|
+ TreeNodeDTO treeNodeDTO = new TreeNodeDTO();
|
|
|
+ treeNodeDTO.setName(oldProjectFieldTree.getName());
|
|
|
+ treeNodeDTO.setParentId(oldProjectFieldTree.getParentId());
|
|
|
+ treeNodeDTO.setType(4);
|
|
|
+ treeNodeDTO.setTypeId(customFieldId);
|
|
|
+ TreeNode treeNode = treeNodeService.addTreeNode(treeNodeDTO);
|
|
|
+ oldProjectFieldTree.setNewParentId(treeNode.getParentId());
|
|
|
+ oldProjectFieldTree.setNewId(treeNode.getId());
|
|
|
+ //查询子节点
|
|
|
+ List<OldProjectFieldTree> childTreeNodes = newOldFieldTrees.stream().filter(item -> item.getParentId().equals(oldProjectFieldTree.getId())).collect(Collectors.toList());
|
|
|
+ childTreeNodes.forEach(item -> item.setParentId(treeNode.getId()));
|
|
|
+ rootTrees.addAll(childTreeNodes);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void saveFolder(List<OldProjectFolder> oldProjectFolders, Integer projectId) {
|
|
|
+ CustomFieldDTO customFieldDTO = new CustomFieldDTO();
|
|
|
+ customFieldDTO.setName("文件夹");
|
|
|
+ customFieldDTO.setDescription("老系统文件夹迁移");
|
|
|
+ customFieldDTO.setStatus(true);
|
|
|
+ customFieldDTO.setProjectId(projectId);
|
|
|
+ customFieldDTO.setPersonId("");
|
|
|
+ customFieldDTO.setType(6);
|
|
|
+ Integer customFieldId = customFieldService.addCustomField(customFieldDTO);
|
|
|
+ oldProjectFolders = oldProjectFolders.stream().sorted(Comparator.comparing(OldProjectFolder::getOrder)).collect(Collectors.toList());
|
|
|
+ List<OldProjectFolder> rootOlderProjectFolders = oldProjectFolders.stream().filter(item -> item.getParentId().equals(0)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ while (rootOlderProjectFolders.size() > 0) {
|
|
|
+ OldProjectFolder olderProjectFolder = rootOlderProjectFolders.remove(0);
|
|
|
+ TreeNodeDTO treeNodeDTO = new TreeNodeDTO();
|
|
|
+ treeNodeDTO.setName(olderProjectFolder.getName());
|
|
|
+ treeNodeDTO.setParentId(olderProjectFolder.getParentId());
|
|
|
+ treeNodeDTO.setType(4);
|
|
|
+ treeNodeDTO.setTypeId(customFieldId);
|
|
|
+ TreeNode treeNode = treeNodeService.addTreeNode(treeNodeDTO);
|
|
|
+ olderProjectFolder.setNewParentId(treeNode.getParentId());
|
|
|
+ olderProjectFolder.setNewId(treeNode.getId());
|
|
|
+ olderProjectFolder.setFieldId(customFieldId);
|
|
|
+ olderProjectFolder.setCustomFieldId(customFieldId);
|
|
|
+ //查询子节点
|
|
|
+ List<OldProjectFolder> childTreeNodes = oldProjectFolders.stream().filter(item -> item.getParentId().equals(olderProjectFolder.getId())).collect(Collectors.toList());
|
|
|
+ childTreeNodes.forEach(item -> item.setParentId(treeNode.getId()));
|
|
|
+ rootOlderProjectFolders.addAll(childTreeNodes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Patent loadPatent(OldPatentDTO oldPatentDTO) throws Exception {
|
|
|
+ Patent patent = new Patent();
|
|
|
+
|
|
|
+ //号码
|
|
|
+ patent.setAppNo(oldPatentDTO.getApplicationNo());
|
|
|
+ patent.setPublicNo(oldPatentDTO.getPublicNo());
|
|
|
+ if (oldPatentDTO.getPublicDate() != null) {
|
|
|
+ Date publicDate = DateUtils.strToDate(oldPatentDTO.getPublicDate());
|
|
|
+ patent.setPublicDate(publicDate);
|
|
|
+ }
|
|
|
+ if (oldPatentDTO.getApplicationDate() != null) {
|
|
|
+ Date appDate = DateUtils.strToDate(oldPatentDTO.getApplicationDate());
|
|
|
+ patent.setAppDate(appDate);
|
|
|
+ }
|
|
|
+ patent.setGrantNo(oldPatentDTO.getPublicAccreditNo());
|
|
|
+ if (oldPatentDTO.getPublicAccreditDate() != null && !oldPatentDTO.getPublicAccreditDate().trim().equals("")) {
|
|
|
+ Date grantDate = DateUtils.strToDate(oldPatentDTO.getPublicAccreditDate());
|
|
|
+ patent.setGrantDate(grantDate);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String patentNo = patent.getPatentNo();
|
|
|
+ String appNo = patent.getAppNo();
|
|
|
+ String publicNo = patent.getPublicNo();
|
|
|
+ String grantNo = patent.getGrantNo();
|
|
|
+
|
|
|
+ String usedNo = null;
|
|
|
+ if (appNo != null) {
|
|
|
+ usedNo = appNo;
|
|
|
+ } else if (publicNo != null) {
|
|
|
+ usedNo = publicNo;
|
|
|
+ } else if (grantNo != null) {
|
|
|
+ usedNo = grantNo;
|
|
|
+ }
|
|
|
+
|
|
|
+ String contry = usedNo.substring(0, 2);
|
|
|
+ if (contry.equals("CN")) {
|
|
|
+ patent.setPatentNo(appNo);
|
|
|
+ } else {
|
|
|
+ if (publicNo != null) {
|
|
|
+ patent.setPatentNo(publicNo);
|
|
|
+ } else if (grantNo != null) {
|
|
|
+ patent.setPatentNo(grantNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //装载标题
|
|
|
+ List<Text> texts = new ArrayList<>();
|
|
|
+ if (oldPatentDTO.getName() != null) {
|
|
|
+ Text text = new Text();
|
|
|
+ text.setTextContent(oldPatentDTO.getName());
|
|
|
+ text.setIfOrigin(true);
|
|
|
+ text.setLanguage(contry);
|
|
|
+ texts.add(text);
|
|
|
+ }
|
|
|
+ if (oldPatentDTO.getNameOut() != null) {
|
|
|
+ Text text = new Text();
|
|
|
+ text.setTextContent(oldPatentDTO.getNameOut());
|
|
|
+ text.setIfOrigin(false);
|
|
|
+ text.setLanguage("CN");
|
|
|
+ texts.add(text);
|
|
|
+ }
|
|
|
+ if (texts.size() != 0) {
|
|
|
+ patent.setTitle(texts);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //装载说明书
|
|
|
+ List<Text> textInstructions = new ArrayList<>();
|
|
|
+ if(oldPatentDTO.getInstruction()!=null) {
|
|
|
+ if (oldPatentDTO.getInstruction().getManual() != null) {
|
|
|
+ Text text = new Text();
|
|
|
+ text.setTextContent(oldPatentDTO.getInstruction().getManual());
|
|
|
+ text.setIfOrigin(true);
|
|
|
+ text.setLanguage(contry);
|
|
|
+ textInstructions.add(text);
|
|
|
+ }
|
|
|
+ if (oldPatentDTO.getInstruction().getManualOut() != null) {
|
|
|
+ Text text = new Text();
|
|
|
+ text.setTextContent(oldPatentDTO.getInstruction().getManualOut());
|
|
|
+ text.setIfOrigin(false);
|
|
|
+ text.setLanguage("CN");
|
|
|
+ textInstructions.add(text);
|
|
|
+ }
|
|
|
+ if (textInstructions.size() != 0) {
|
|
|
+ patent.setPublicFullText(textInstructions);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //装载摘要
|
|
|
+ List<Text> textsAbstractStr = new ArrayList<>();
|
|
|
+ if (oldPatentDTO.getAbstractStr() != null) {
|
|
|
+ Text text = new Text();
|
|
|
+ text.setTextContent(oldPatentDTO.getAbstractStr());
|
|
|
+ text.setIfOrigin(true);
|
|
|
+ text.setLanguage(contry);
|
|
|
+
|
|
|
+ textsAbstractStr.add(text);
|
|
|
+ }
|
|
|
+ if (oldPatentDTO.getAbstractOut() != null) {
|
|
|
+ Text text = new Text();
|
|
|
+ text.setTextContent(oldPatentDTO.getAbstractOut());
|
|
|
+ text.setIfOrigin(false);
|
|
|
+ text.setLanguage("CN");
|
|
|
+ texts.add(text);
|
|
|
+ textsAbstractStr.add(text);
|
|
|
+ }
|
|
|
+ if (textsAbstractStr.size() != 0) {
|
|
|
+ patent.setAbstractStr(textsAbstractStr);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //装载申请人,权利人地址 以及申请人权利人
|
|
|
+ if (oldPatentDTO.getApplicant() != null && oldPatentDTO.getApplicant().size() != 0) {
|
|
|
+ List<PatentPerson> patentPeopleApp = new ArrayList<>();
|
|
|
+ List<PatentPerson> patentPeopleRightHolder = new ArrayList<>();
|
|
|
+ String addressApp = null;
|
|
|
+ String addressRightHolder = null;
|
|
|
+ for (OldPatentApplicant patentApplicant : oldPatentDTO.getApplicant()) {
|
|
|
+ if (patentApplicant.getDataType().equals(2)) {
|
|
|
+ if (patentApplicant.getAddressStr() != null) {
|
|
|
+ addressApp = patentApplicant.getAddressStr();
|
|
|
+ }
|
|
|
+ PatentPerson patentPerson = new PatentPerson();
|
|
|
+ patentPerson.setOrder(patentPeopleApp.size() + 1);
|
|
|
+ patentPerson.setType("1");
|
|
|
+ patentPerson.setName(patentApplicant.getName());
|
|
|
+ patentPeopleApp.add(patentPerson);
|
|
|
+ }
|
|
|
+ if (patentApplicant.getDataType().equals(1)) {
|
|
|
+ if (patentApplicant.getAddressStr() != null) {
|
|
|
+ addressRightHolder = patentApplicant.getAddressStr();
|
|
|
+ }
|
|
|
+ PatentPerson patentPerson = new PatentPerson();
|
|
|
+ patentPerson.setOrder(patentPeopleRightHolder.size() + 1);
|
|
|
+ patentPerson.setType("1");
|
|
|
+ patentPerson.setName(patentApplicant.getName());
|
|
|
+ patentPeopleApp.add(patentPerson);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ if (patentPeopleApp.size() != 0) {
|
|
|
+ patent.setApplicant(patentPeopleApp);
|
|
|
+ }
|
|
|
+ if (patentPeopleRightHolder.size() != 0) {
|
|
|
+ patent.setRightHolder(patentPeopleRightHolder);
|
|
|
+ }
|
|
|
+ if (addressApp != null) {
|
|
|
+ PersonAddress personAddress = new PersonAddress();
|
|
|
+ personAddress.setAddress(addressApp);
|
|
|
+ patent.setApplicantAddr(personAddress);
|
|
|
+ }
|
|
|
+ if (addressRightHolder != null) {
|
|
|
+ PersonAddress personAddress = new PersonAddress();
|
|
|
+ personAddress.setAddress(addressRightHolder);
|
|
|
+ patent.setRightHolderAddr(personAddress);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //发明人
|
|
|
+ List<OldPatentInventor> patentInventorList = oldPatentDTO.getInventor();
|
|
|
+ if (patentInventorList != null && patentInventorList.size() > 0) {
|
|
|
+ List<PatentPerson> patentPeople = new ArrayList<>();
|
|
|
+ for (int i = 0; i < patentInventorList.size(); i++) {
|
|
|
+ PatentPerson patentPerson = new PatentPerson();
|
|
|
+ patentPerson.setOrder(i + 1);
|
|
|
+ patentPerson.setType("1");
|
|
|
+ patentPerson.setName(patentInventorList.get(i).getName());
|
|
|
+ patentPeople.add(patentPerson);
|
|
|
+ }
|
|
|
+ patent.setInventor(patentPeople);
|
|
|
+ }
|
|
|
+ //装载审查员
|
|
|
+ patent.setExaminer(oldPatentDTO.getExaminer());
|
|
|
+
|
|
|
+ //助理审查员
|
|
|
+ patent.setAidExaminer(oldPatentDTO.getAidExaminer());
|
|
|
+
|
|
|
+ //优先权
|
|
|
+ if (oldPatentDTO.getPriorityNo() != null) {
|
|
|
+
|
|
|
+ List<Priorities> priorities = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ Priorities prioritie = new Priorities();
|
|
|
+ prioritie.setPriorityNo(oldPatentDTO.getPriorityNo());
|
|
|
+ String pCountry = oldPatentDTO.getPriorityNo().substring(0, 2);
|
|
|
+ prioritie.setPriorityCountry(pCountry);
|
|
|
+ if (oldPatentDTO.getPriorityDate() != null) {
|
|
|
+ prioritie.setPriorityDate(oldPatentDTO.getPriorityDate());
|
|
|
+ }
|
|
|
+ priorities.add(prioritie);
|
|
|
+
|
|
|
+ patent.setPriorities(priorities);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //分类号
|
|
|
+ //装载IPC分类号
|
|
|
+ List<String> ipcList = oldPatentDTO.getIpcList();
|
|
|
+ String mainIpc = oldPatentDTO.getIpc();
|
|
|
+ if (ipcList == null && mainIpc != null) {
|
|
|
+ ipcList = new ArrayList<>();
|
|
|
+ ipcList.add(mainIpc);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ipcList != null && ipcList.size() > 0) {
|
|
|
+ List<PatentClassify> patentClassifies = new ArrayList<>();
|
|
|
+ for (int i = 0; i < ipcList.size(); i++) {
|
|
|
+ PatentClassify patentClassify = PatentClassifySplitter.split(ipcList.get(i));
|
|
|
+ if (patentClassify != null) {
|
|
|
+ patentClassifies.add(patentClassify);
|
|
|
+ if (i == 0) {
|
|
|
+ patent.setMipc(patentClassify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ patent.setIpc(patentClassifies);
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载CPC分类号
|
|
|
+ List<String> cpcList = oldPatentDTO.getCpcList();
|
|
|
+ String mainCpc = oldPatentDTO.getCpc();
|
|
|
+ if (cpcList == null && mainCpc != null) {
|
|
|
+ cpcList = new ArrayList<>();
|
|
|
+ cpcList.add(mainCpc);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cpcList != null && cpcList.size() > 0) {
|
|
|
+ List<PatentClassify> patentClassifies = new ArrayList<>();
|
|
|
+ for (int i = 0; i < cpcList.size(); i++) {
|
|
|
+ PatentClassify patentClassify = PatentClassifySplitter.split(cpcList.get(i));
|
|
|
+ if (patentClassify != null) {
|
|
|
+ patentClassifies.add(patentClassify);
|
|
|
+ if (i == 0) {
|
|
|
+ patent.setMcpc(patentClassify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ patent.setCpc(patentClassifies);
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载UPC分类号
|
|
|
+ List<String> upcList = oldPatentDTO.getCpcList();
|
|
|
+ String mainUpc = oldPatentDTO.getUpc();
|
|
|
+ if (upcList == null && mainUpc != null) {
|
|
|
+ upcList = new ArrayList<>();
|
|
|
+ upcList.add(mainUpc);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (upcList != null && upcList.size() > 0) {
|
|
|
+ List<PatentClassify> patentClassifies = new ArrayList<>();
|
|
|
+ for (int i = 0; i < upcList.size(); i++) {
|
|
|
+ PatentClassify patentClassify = PatentClassifySplitter.split(upcList.get(i));
|
|
|
+ if (patentClassify != null) {
|
|
|
+ patentClassifies.add(patentClassify);
|
|
|
+ if (i == 0) {
|
|
|
+ patent.setMupc(patentClassify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ patent.setUpc(patentClassifies);
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载Loc分类号
|
|
|
+ List<String> locList = oldPatentDTO.getLocList();
|
|
|
+ String mainLoc = oldPatentDTO.getLoc();
|
|
|
+ if (locList == null && mainLoc != null) {
|
|
|
+ locList = new ArrayList<>();
|
|
|
+ locList.add(mainLoc);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (locList != null && locList.size() > 0) {
|
|
|
+ List<PatentClassify> patentClassifies = new ArrayList<>();
|
|
|
+ for (int i = 0; i < locList.size(); i++) {
|
|
|
+ PatentClassify patentClassify = PatentClassifySplitter.split(locList.get(i));
|
|
|
+ if (patentClassify != null) {
|
|
|
+ patentClassifies.add(patentClassify);
|
|
|
+ if (i == 0) {
|
|
|
+ patent.setMloc(patentClassify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ patent.setLoc(patentClassifies);
|
|
|
+ }
|
|
|
+
|
|
|
+ //简单法律状态
|
|
|
+ if(oldPatentDTO.getSimpleStatus()!=null) {
|
|
|
+ switch (oldPatentDTO.getSimpleStatus()) {
|
|
|
+ case "有效":
|
|
|
+ patent.setSimpleStatus("1");
|
|
|
+ break;
|
|
|
+ case "审中":
|
|
|
+ patent.setSimpleStatus("3");
|
|
|
+ break;
|
|
|
+ case "失效":
|
|
|
+ patent.setSimpleStatus("2");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ patent.setSimpleStatus("1");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(oldPatentDTO.getType()!=null){
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ //专利类型
|
|
|
+ String type = oldPatentDTO.getType();
|
|
|
+ if (type != null) {
|
|
|
+ type = type.trim();
|
|
|
+ switch (type) {
|
|
|
+ case "授权发明":
|
|
|
+ case "发明申请":
|
|
|
+ type = "1";
|
|
|
+ break;
|
|
|
+ case "实用新型":
|
|
|
+ type = "2";
|
|
|
+ break;
|
|
|
+ case "外观设计":
|
|
|
+ type = "3";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ type = null;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ patent.setPatentType(type);
|
|
|
+ }
|
|
|
+ //装载权利要求
|
|
|
+ if (oldPatentDTO.getRights() != null && oldPatentDTO.getRights().size() > 0) {
|
|
|
+ List<Text> rightTexts = new ArrayList<>();
|
|
|
+ List<OldPatentRight> oldPatentRights = oldPatentDTO.getRights().stream().sorted(Comparator.comparing(OldPatentRight::getSort)).collect(Collectors.toList());
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ for (OldPatentRight oldPatentRight : oldPatentRights) {
|
|
|
+ stringBuilder.append(oldPatentRight.getContent());
|
|
|
+ }
|
|
|
+ Text text = new Text();
|
|
|
+ text.setTextContent(stringBuilder.toString());
|
|
|
+ text.setIfOrigin(true);
|
|
|
+ text.setLanguage(contry);
|
|
|
+ rightTexts.add(text);
|
|
|
+ if (rightTexts.size() != 0) {
|
|
|
+ patent.setClaim(rightTexts);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //wo指定国
|
|
|
+ if (oldPatentDTO.getWo() != null) {
|
|
|
+ patent.setWo(oldPatentDTO.getWo());
|
|
|
+ }
|
|
|
+
|
|
|
+ //同族
|
|
|
+ if (oldPatentDTO.getFamily() != null) {
|
|
|
+ OldPatentDTO.PatentFamily family = oldPatentDTO.getFamily();
|
|
|
+ if (family.getSimple() != null && family.getSimple().size() > 0) {
|
|
|
+ EsPatentFamilyDTO esPatentFamilyDTO = esService.addEsPatentFamily(patent, family.getSimple(), FamilyType.SIMPLE);
|
|
|
+ if (esPatentFamilyDTO != null) {
|
|
|
+ patent.setSimpleFamilyId(esPatentFamilyDTO.getPatentFamilyId());
|
|
|
+ patent.setSimpleFamilyNum(esPatentFamilyDTO.getFamilyNum());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (family.getInpadoc() != null && family.getInpadoc().size() > 0) {
|
|
|
+ EsPatentFamilyDTO esPatentFamilyDTO = esService.addEsPatentFamily(patent, family.getInpadoc(), FamilyType.INPADOC);
|
|
|
+ if (esPatentFamilyDTO != null) {
|
|
|
+ patent.setInpadocFamilyId(esPatentFamilyDTO.getPatentFamilyId());
|
|
|
+ patent.setInpadocFamilyNum(esPatentFamilyDTO.getFamilyNum());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //引用专利
|
|
|
+
|
|
|
+ String nos = oldPatentDTO.getQuote();
|
|
|
+ System.out.println(nos);
|
|
|
+// if (nos != null) {
|
|
|
+// List<String> quotedNos = this.reQuotedNos(nos);
|
|
|
+// esService.addEsQuotePatent(, quotedNos);
|
|
|
+// }
|
|
|
+ return patent;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public List<EsCustomFieldDTO> getEsCustomField(List<OldProjectFolderPatentLink> oldProjectFolderPatentLinks, List<OldPatentLabel> oldPatentLabels, Integer projectId, List<OldProjectFolder> oldProjectFolders) {
|
|
|
+ List<EsCustomFieldDTO> esCustomFieldDTOList = new ArrayList<>();
|
|
|
+ if (oldPatentLabels != null && oldPatentLabels.size() > 0) {
|
|
|
+ List<String> names = oldPatentLabels.stream().map(OldPatentLabel::getName).collect(Collectors.toList());
|
|
|
+ EsCustomFieldDTO esCustomFieldDTO = new EsCustomFieldDTO();
|
|
|
+ esCustomFieldDTO.setFieldType(10);
|
|
|
+ esCustomFieldDTO.setProjectId(projectId);
|
|
|
+ esCustomFieldDTO.setFieldId("0");
|
|
|
+ esCustomFieldDTO.setFieldValue(names);
|
|
|
+
|
|
|
+ esCustomFieldDTOList.add(esCustomFieldDTO);
|
|
|
+ }
|
|
|
+ if (oldProjectFolders != null && oldProjectFolders.size() > 0 && oldProjectFolderPatentLinks.size() > 0) {
|
|
|
+ EsCustomFieldDTO esCustomFieldDTO = new EsCustomFieldDTO();
|
|
|
+ esCustomFieldDTO.setFieldType(6);
|
|
|
+ esCustomFieldDTO.setProjectId(projectId);
|
|
|
+ esCustomFieldDTO.setFieldId(oldProjectFolders.get(0).getCustomFieldId().toString());
|
|
|
+ List<Integer> oldLinkIds = oldProjectFolderPatentLinks.stream().map(OldProjectFolderPatentLink::getFolderId).collect(Collectors.toList());
|
|
|
+ List<Integer> newLinkIds = oldProjectFolders.stream().filter(item -> oldLinkIds.contains(item.getId())).map(OldProjectFolder::getNewId).collect(Collectors.toList());
|
|
|
+ List<String> names = FormatUtil.IntegerTOStringList(newLinkIds);
|
|
|
+ esCustomFieldDTO.setFieldValue(names);
|
|
|
+ esCustomFieldDTOList.add(esCustomFieldDTO);
|
|
|
+ }
|
|
|
+ return esCustomFieldDTOList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<EsCustomFieldDTO> getEsCustomField(File file, Integer projectId, List<OldProjectFieldOption> oldProjectFieldOptions, List<OldProjectField> oldProjectFields, List<OldProjectFieldTree> oldProjectFieldTrees, List<OldProjectFieldText> oldProjectFieldTexts) {
|
|
|
+ List<EsCustomFieldDTO> esCustomFieldDTOList = new ArrayList<>();
|
|
|
+ List<OldProjectFieldPatentLink> oldProjectFieldPatentLinks = new ArrayList<>();
|
|
|
+ String patentFieldLinkJsons = CommonService.readJsonFile(file);
|
|
|
+ oldProjectFieldPatentLinks = JSONArray.parseArray(patentFieldLinkJsons, OldProjectFieldPatentLink.class);
|
|
|
+
|
|
|
+ if (oldProjectFieldPatentLinks.size() > 0 && oldProjectFields.size() > 0) {
|
|
|
+ for (OldProjectField oldProjectField : oldProjectFields) {
|
|
|
+ List<OldProjectFieldPatentLink> partLinks = oldProjectFieldPatentLinks.stream().filter(item -> item.getFieldId().equals(oldProjectField.getId())).collect(Collectors.toList());
|
|
|
+ if (partLinks.size() > 0) {
|
|
|
+ Integer type = oldProjectField.getType();
|
|
|
+ EsCustomFieldDTO esCustomFieldDTO = new EsCustomFieldDTO();
|
|
|
+ esCustomFieldDTO.setFieldType(type);
|
|
|
+ esCustomFieldDTO.setProjectId(projectId);
|
|
|
+ esCustomFieldDTO.setFieldId(oldProjectField.getNewId().toString());
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
+ List<Integer> linkIds = partLinks.stream().map(OldProjectFieldPatentLink::getOptionId).collect(Collectors.toList());
|
|
|
+ switch (type) {
|
|
|
+ case 0:
|
|
|
+ case 1:
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ names = oldProjectFieldTexts.stream().filter(item -> linkIds.contains(item.getId())).map(OldProjectFieldText::getText).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ case 5:
|
|
|
+ List<Integer> optionIds = oldProjectFieldOptions.stream().filter(item -> linkIds.contains(item.getId())).map(OldProjectFieldOption::getNewId).collect(Collectors.toList());
|
|
|
+ names = FormatUtil.IntegerTOStringList(optionIds);
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ List<Integer> treeIds = oldProjectFieldTrees.stream().filter(item -> linkIds.contains(item.getId())).map(OldProjectFieldTree::getNewId).collect(Collectors.toList());
|
|
|
+ names = FormatUtil.IntegerTOStringList(treeIds);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ esCustomFieldDTO.setFieldValue(names);
|
|
|
+ esCustomFieldDTOList.add(esCustomFieldDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return esCustomFieldDTOList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void WriteCustomFieldToFile(List<OldProjectField> oldProjectFields, List<OldProjectFieldOption> oldProjectFieldOptions, List<OldProjectFieldTree> oldProjectFieldTrees, File file) {
|
|
|
+
|
|
|
+// FileUtils.writeFile(oldProjectFields,);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<String> reQuotedNos(String quoteNos) {
|
|
|
+ List<String> nos = new ArrayList<>();
|
|
|
+ if (quoteNos == null) {
|
|
|
+ return nos;
|
|
|
+ }
|
|
|
+ String[] quoteNoStrs = quoteNos.split("\\|");
|
|
|
+ for (int i = 0; i < quoteNoStrs.length; i++) {
|
|
|
+ nos.add(quoteNoStrs[i].trim());
|
|
|
+ }
|
|
|
+ return nos;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void savePatentPicture(File file, Patent patent) throws Exception {
|
|
|
+ File imageDiretory = FileUtils.getFileByName(file, Constants.PATENT_IMAGE);
|
|
|
+ if(imageDiretory==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ File[] imageFiles = imageDiretory.listFiles();
|
|
|
+ if(imageFiles.length>0){
|
|
|
+ File ImageFile =imageFiles[0];
|
|
|
+ String guid = FormatUtil.getPictureFormat(patent.getAppNo());
|
|
|
+ fileManagerService.uploadFileWithGuid(ImageFile, guid);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+ public void savePatentPDF(File file, Patent patent) throws Exception {
|
|
|
+ File pdfDiretory = FileUtils.getFileByName(file, Constants.PATENT_PDF);
|
|
|
+ if(pdfDiretory==null||!pdfDiretory.exists()){
|
|
|
+
|
|
|
+ System.out.println(patent.getPatentNo());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ File[] pdfFiles = pdfDiretory.listFiles();
|
|
|
+ for (int i = 0; i < pdfFiles.length; i++) {
|
|
|
+ File pdfFile = pdfFiles[i];
|
|
|
+ String name = pdfFile.getName();
|
|
|
+ String[] names = name.split("_");
|
|
|
+ Integer type = 0;
|
|
|
+ if (names[1].contains("2")) {
|
|
|
+ type = 1;
|
|
|
+ }
|
|
|
+ String guid1 = FormatUtil.getPDFFormat(patent.getPatentNo(), type);
|
|
|
+ fileManagerService.uploadFileWithGuid(pdfFile,guid1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|