Ver Fonte

发明人修改

沈永艺 há 3 anos atrás
pai
commit
0b543e514b

+ 5 - 21
PAS/src/main/java/cn/cslg/pas/service/PatentInventorService.java

@@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -203,30 +204,13 @@ public class PatentInventorService extends ServiceImpl<PatentInventorMapper, Pat
                         patentInventor.setCountry(params.getAddressList().get(i).substring(params.getAddressList().get(i).lastIndexOf(",") + 1).replaceAll(" ", ""));
                     }
                 } else {
-                    patentInventor.setAddress("");
+                    if (patentInventor.getAddress() == null || patentInventor.getAddress().equals("")) {
+                        patentInventor.setAddress("");
+                        patentInventor.setCountry("");
+                    }
                 }
-
-                //patentInventor.setType(PatentUtils.getIntKeyByOrganType(name));
                 dataList.add(patentInventor);
             }
-//            if (StringUtils.isNotEmpty(params.getFirstAddress())) {
-//                PatentInventor patentInventor = patentInventorList.stream().filter(PatentInventor::getFirst).findFirst().orElse(null);
-//                if (patentInventor != null) {
-//                    patentInventor.setAddress(params.getFirstAddress().replaceAll(" ", ""));
-//                    patentInventor.setCountry(params.getFirstAddress().substring(params.getFirstAddress().lastIndexOf(",") + 1).replaceAll(" ", ""));
-//                    patentInventor.updateById();
-//                }
-//            }
-//            List<PatentInventor> dataList = params.getNameList().stream().map(name -> {
-//                PatentInventor patentInventor = this.getPatentInventorByName(name);
-//                if (patentInventor == null) {
-//                    patentInventor = new PatentInventor();
-//                }
-//                patentInventor.setName(name);
-//                patentInventor.setMerge(false);
-//                patentInventor.setType(PatentUtils.getIntKeyByOrganType(name));
-//                return patentInventor;
-//            }).collect(Collectors.toList());
             this.saveOrUpdateBatch(dataList);
             PatentInventor first = dataList.stream().filter(item -> item.getName().equals(params.getFirstName())).findFirst().orElse(null);
             patentInventorLinkService.updatePatentInventLink(dataList.stream().map(PatentInventor::getId).collect(Collectors.toList()), params.getPatentId(), first == null ? 0 : first.getId());

+ 8 - 2
PAS/src/main/java/cn/cslg/pas/service/PatentSimpleFamilyService.java

@@ -84,14 +84,16 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
     }
 
     public void updateData(List<String> familyNo, String patentNo, Integer patentId, Integer type) {
+        //两个表 1.同族表 2.同组关联专利表
         //用专利号 获取同族关联专利表的信息
         List<PatentSimpleFamilyLink> patentSimpleFamilyLinkList = patentSimpleFamilyLinkService.getPatentSimpleFamilyLinkByPatentNo(patentNo);
         PatentSimpleFamily family;
-        //没有就新建一条
+
         if (patentSimpleFamilyLinkList == null || patentSimpleFamilyLinkList.size() == 0) {
+            //如果 同组关联专利表 内没有数据 就新建一条 同族表 的数据
             family = this.add(type);
         } else {
-            //如果用PatentNo查出来数据了
+            //如果 同组关联专利表 内有数据 那么用查询出来的List中的 同族表 的ID来获取 同族表 内的其他对应信息
             PatentSimpleFamily patentSimpleFamily = this.getPatentSimpleFamilyByIdsAndType(patentSimpleFamilyLinkList.stream().map(PatentSimpleFamilyLink::getFamilyId).collect(Collectors.toList()), type);
             if (patentSimpleFamily == null) {
                 family = this.add(type);
@@ -110,6 +112,8 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
                 temp.setFamilyId(family.getId());
                 temp.updateById();
             }
+
+
             Patent patent1 = patentService.getPublicDateAndPatentNoByPatentNo(patent);
             Patent patent2 = patentService.getPublicDateAndPatentNoByPatentNo(family.getPatentNo());
             if (patent1 != null) {
@@ -142,6 +146,8 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
                 family.setPatentNo(patent2.getPatentNo());
                 patent2.updateById();
             }
+
+
             if (StringUtils.isEmpty(family.getPatentNo())) {
                 family.setPatentNo(patent);
             } else {

+ 8 - 6
PAS/src/main/java/cn/cslg/pas/service/UploadPatentBatchService.java

@@ -15,11 +15,11 @@ import org.apache.poi.ss.usermodel.PictureData;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+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;
 
 @Service
@@ -46,6 +46,7 @@ public class UploadPatentBatchService {
     private final PatentAffairService patentAffairService;
 
     @Async("singleThreadAsyncTaskExecutor")
+    @Transactional(rollbackFor = Exception.class)
     public void uploadPatentBatch(TaskParams params, ProjectImportPatentVO projectImportPatentVO) {
         Integer total = params.getRowList().size();
         try {
@@ -110,6 +111,9 @@ public class UploadPatentBatchService {
                     .setTotal(total), ResponseEnum.PATENT_IMPORT_TASK_SUCCESS), params.getUserId());
         } catch (Exception e) {
             e.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            SpringUtil.getBean(ProjectService.class).setImportPatentTaskStatus(3, params.getTaskId());
+            WebSocketServer.sendInfo(Response.error(ResponseEnum.PATENT_IMPORT_TASK_ERROR), params.getUserId());
         }
     }
 
@@ -285,8 +289,6 @@ public class UploadPatentBatchService {
         patentInventorParams.setNameList(nameList);
 
         patentInventorService.updatePatentInventor(patentInventorParams);
-
-        //patentInventorService.updatePatentInventorAddress(patentInventorAddressParams);
     }
 
     private void patentCurrentApplicationBusiness(UploadParamsVO uploadParamsVO) {