ソースを参照

2022-10-17 补充已修改但未上传的代码

沈永艺 3 年 前
コミット
9ceb629b20

+ 6 - 3
PAS/src/main/java/cn/cslg/pas/common/utils/StringUtils.java

@@ -13,7 +13,9 @@ public class StringUtils {
     private final static int NUM_32 = 32;
     //集群号
     private static int machineId = 1;
-    /** 下划线 */
+    /**
+     * 下划线
+     */
     private static final char SEPARATOR = '_';
 
     /**
@@ -241,8 +243,8 @@ public class StringUtils {
         String[] split = split(str, code);
         List<String> lnums = new ArrayList<>();
         for (String s : split) {
-            //long lnum = getLong(s, 0l);
-            lnums.add(s);
+            String trim = s.trim();
+            lnums.add(trim);
         }
         return lnums;
     }
@@ -495,6 +497,7 @@ public class StringUtils {
     public static <T> String join(List<T> list, String separator) {
         return org.apache.commons.lang3.StringUtils.join(list, separator);
     }
+
     public static <T> String join(String[] list, String separator) {
         return org.apache.commons.lang3.StringUtils.join(list, separator);
     }

+ 7 - 5
PAS/src/main/java/cn/cslg/pas/common/utils/UploadPatentBatchUtil.java

@@ -66,11 +66,13 @@ public class UploadPatentBatchUtil {
                 String key = object.toString();
                 Object value = row.get(key);
                 if (key.contains(":")) {
-                    UploadParamsVO.Field field = new UploadParamsVO.Field();
-                    StringSpecialHandler stringSpecialHandler = new StringSpecialHandler();
-                    field.setKey(key);
-                    field.setFieldList((List<String>) stringSpecialHandler.processData(value.toString(), "\\\n"));
-                    list.add(field);
+                    if (value != null && !value.equals("")) {
+                        UploadParamsVO.Field field = new UploadParamsVO.Field();
+                        StringSpecialHandler stringSpecialHandler = new StringSpecialHandler();
+                        field.setKey(key);
+                        field.setFieldList((List<String>) stringSpecialHandler.processData(value.toString(), "\\\n"));
+                        list.add(field);
+                    }
                 }
                 if (StringUtils.isNotNull(value) && !value.equals("") && !value.equals("-") && !value.equals("\\")) {
                     //将配置项与Excel栏位进行比对

+ 32 - 2
PAS/src/main/java/cn/cslg/pas/service/CustomAnalysisItemSourceService.java

@@ -139,20 +139,32 @@ public class CustomAnalysisItemSourceService extends ServiceImpl<CustomAnalysisI
         return resultList.stream().sorted(Comparator.comparing(AnalysisItemResultDTO::getCount).reversed()).limit(end).collect(Collectors.toList());
     }
 
+    /**
+     * @description 图标分析模块 数据获取方法(一维数据,二位数据的下拉选项)
+     */
     public String getSourceData2(SearchSourceDataVO searchSourceDataVO) {
+        //从Redis中获取选中ID的缓存
         String id = cacheUtils.getSelectPatentIds(searchSourceDataVO.getPatentKey());
+        //为空报错
         if (StringUtils.isEmpty(id)) {
             return Response.error(ResponseEnum.QUERY_CACHE_ERROR);
         }
+        //获取前端选择的条数范围(10,20,30,40,50,全部)
         long end = searchSourceDataVO.getNum();
         List<CustomAnalysisItemSource> list = new ArrayList<>();
+        //拆分出选中的IDList
         List<Integer> patentIds = StringUtils.changeStringToInteger(id, ",");
+        //如果选中的数据类型是 树(6) 执行分支
         if (searchSourceDataVO.getType().equals(6)) {
+            // TODO: 2022/9/26 树型数据 未解析逻辑 沈永艺
             this.setTreeNodeCountDataForRedis(patentIds, searchSourceDataVO);
             return Response.success(projectFieldTreeService.getProjectFieldTreeNodeByFieldId(searchSourceDataVO.getFieldId()));
         }
+        //非树型
         switch (searchSourceDataVO.getPtype()) {
+            //(部,大类,小类,大组,小组) (当前,标准,合并后) (国家,省,市)
             case 1:
+                // TODO: 2022/9/26 处理条件 未解析逻辑 沈永艺
                 List<AnalysisItemResultDTO> resultList = this.setCommonDataCountDataForRedis(patentIds, searchSourceDataVO);
                 for (AnalysisItemResultDTO item : resultList) {
                     CustomAnalysisItemSource customAnalysisItemSource = new CustomAnalysisItemSource();
@@ -163,27 +175,45 @@ public class CustomAnalysisItemSourceService extends ServiceImpl<CustomAnalysisI
                     list.add(customAnalysisItemSource);
                 }
                 break;
+            //年份(月,季度,半年,1年,2年,3年,5年)
             case 2:
+                //获取PType为2的数据
                 List<ProjectFieldExpand> expandList = projectFieldService.getProjectFieldExpand().stream().filter(item -> item.getPtype().equals(searchSourceDataVO.getPtype())).collect(Collectors.toList());
+                //获取属性的名称
                 String dateType = expandList.stream().filter(item -> item.getId().equals(searchSourceDataVO.getExpandId())).findFirst().orElse(new ProjectFieldExpand()).getName();
+                //用名称获取偏移的数字 (注:这里的偏移均是指减去多少个月 例:2022-01-01 偏移-12 为 2021-01-01)
                 Integer offset = Constants.DATE_OFFSET.get(dateType);
+                //根据FieldId的不同获取选中IDList中的对应日期 fieldId说明: 25申请日 26公开日 27公开授权日
+                //1.获取最小的日期
                 Date endDate = patentService.getDateTime(id, searchSourceDataVO.getFieldId(), "min");
+                //2.获取最大的日期
                 Date startTime = patentService.getDateTime(id, searchSourceDataVO.getFieldId(), "max");
+                //创建偏移数据
                 Date endTime = DateUtil.offsetMonth(startTime, offset);
-                Integer index = 0;
+                int index = 0;
+                /*
+                    do while的判断规则: 1.当最大日期比最小日期小 &&  2.循环次数超出所传入范围
+                 */
                 do {
+                    //装填数据
                     CustomAnalysisItemSource customAnalysisItemSource = new CustomAnalysisItemSource();
+                    //依据偏移月数的不同 获取不同的对应数据
                     customAnalysisItemSource.setName(DateUtils.getDateSourceName(startTime, endTime, offset, index++));
                     customAnalysisItemSource.setStatus(null);
                     customAnalysisItemSource.setCreateTime(null);
                     customAnalysisItemSource.setUpdateTime(null);
+                    //重设最大日期
                     startTime = DateUtil.offsetMonth(startTime, offset);
+                    //重设偏移数据
                     endTime = DateUtil.offsetMonth(endTime, offset);
+                    //向List中加入所需数据 用于返回前台展示
                     list.add(customAnalysisItemSource);
-                } while (DateUtil.compare(startTime, endDate) > 0 && index < end);
+                } while (DateUtil.compare(DateUtil.offsetMonth(startTime, offset * -1), endDate) > 0 && index < end);
                 break;
+            //自定义
             case 3:
             case 4:
+                // TODO: 2022/9/26 自定义字段 未解析逻辑 沈永艺
                 list = this.getItemSourceList(searchSourceDataVO.getUid(), searchSourceDataVO.getDimension(), searchSourceDataVO.getFieldId(), searchSourceDataVO.getExpandId());
                 break;
         }

+ 17 - 8
PAS/src/main/java/cn/cslg/pas/service/PatentApplicantService.java

@@ -256,17 +256,26 @@ public class PatentApplicantService extends ServiceImpl<PatentApplicantMapper, P
         } else {
             for (String s : shortName) {
                 LambdaQueryWrapper<PatentApplicant> queryWrapper = new LambdaQueryWrapper<>();
-                queryWrapper.eq(PatentApplicant::getName, "");
                 queryWrapper.eq(PatentApplicant::getShortName, s);
                 queryWrapper.eq(PatentApplicant::getMerge, 0);
-                PatentApplicant temp = this.getOne(queryWrapper);
-                if (temp == null) {
-                    temp = this.add("", s);
-                } else if (s != null && !s.equals(temp.getShortName())) {
-                    temp.setShortName(s);
-                    temp.updateById();
+                List<PatentApplicant> temp = this.list(queryWrapper);
+
+                PatentApplicant patentApplicant = new PatentApplicant();
+                if (temp.size() == 0) {
+                    patentApplicant = this.add(s, s);
+                } else {
+                    if (temp.size() == 1) {
+                        patentApplicant = temp.get(0);
+                    } else {
+                        for (PatentApplicant pa : temp) {
+                            if (pa.getShortName().equals(pa.getName())) {
+                                patentApplicant = pa;
+                                break;
+                            }
+                        }
+                    }
                 }
-                ids.add(temp.getId());
+                ids.add(patentApplicant.getId());
             }
         }