瀏覽代碼

异步处理导入接口

Administrator 2 年之前
父節點
當前提交
7bbfe118ee
共有 1 個文件被更改,包括 27 次插入21 次删除
  1. 27 21
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserInfoServiceImpl.java

+ 27 - 21
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserInfoServiceImpl.java

@@ -136,7 +136,7 @@ public class UserInfoServiceImpl implements IUserInfoService {
     @Transactional(rollbackFor = Exception.class)
     @Async
     public String importUser(List<UserInfo> userList, String jobStyle, String focusCrowdStyle, String detectionNumber,
-                             String detectionScope, String startTime, String endTime,SysUser user) throws Exception {
+                             String detectionScope, String startTime, String endTime, SysUser user) throws Exception {
 
         if (userList == null) {
             return "表格格式错误,请按照表格模板格式上传人员名单";
@@ -172,8 +172,11 @@ public class UserInfoServiceImpl implements IUserInfoService {
         //从第三方数据库查询人员核酸计录
         List<OdsQssHsjcxx> OdsQssHsjcxxList = qdsQssHsjcxxService.thirdNucleicAcid(startTime, endTime, idCardList);
 
+        Map<String, List<OdsQssHsjcxx>> OdsQssHsjcxxMapSorted = new HashMap<>();
+        if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
+            OdsQssHsjcxxMapSorted = OdsQssHsjcxxList.stream().sorted(Comparator.comparing(OdsQssHsjcxx::getCjsj).reversed()).collect(Collectors.groupingBy(OdsQssHsjcxx::getSfzhm));
+        }
         //把采集时间降序
-        List<OdsQssHsjcxx> OdsQssHsjcxxListSorted = OdsQssHsjcxxList.stream().sorted(Comparator.comparing(OdsQssHsjcxx::getCjsj).reversed()).collect(Collectors.toList());
         List<UserNucleicTime> UserNucleicTimeList = new ArrayList<>();
 
         int index = 0;
@@ -201,26 +204,29 @@ public class UserInfoServiceImpl implements IUserInfoService {
             Boolean bl = true;
 
             index = 0;
-            for (OdsQssHsjcxx odsQssHsjcxx : OdsQssHsjcxxListSorted) {
-                //判断 核酸采集时间是不是在 startTime和date之间
-                if (userInfo.getIdCard().equals(odsQssHsjcxx.getSfzhm())) {
-
-                    if (StringUtils.isNotEmpty(collectPlace.toString())) {
-                        collectPlace.append("<br>");
-                    }
-                    collectPlace.append(odsQssHsjcxx.getJcdd());
-
-                    if (StringUtils.isNotEmpty(nucleicCollectTime.toString())) {
-                        nucleicCollectTime.append("<br>");
-                    }
-                    nucleicCollectTime.append(odsQssHsjcxx.getCjsj());
-
-                    if (StringUtils.isNotEmpty(nucleicResultsTime.toString())) {
-                        nucleicResultsTime.append("<br>");
+            if (OdsQssHsjcxxMapSorted.size() > 0) {
+                //身份证号码
+                String idCard = userInfo.getIdCard();
+                List<OdsQssHsjcxx> odsQssHsjcxxes = OdsQssHsjcxxMapSorted.get(idCard);
+                if (odsQssHsjcxxes != null && odsQssHsjcxxes.size() > 0) {
+                    for (OdsQssHsjcxx odsQssHsjcxx : odsQssHsjcxxes) {
+
+                        if (StringUtils.isNotEmpty(collectPlace.toString())) {
+                            collectPlace.append("<br>");
+                        }
+                        collectPlace.append(odsQssHsjcxx.getJcdd());
+
+                        if (StringUtils.isNotEmpty(nucleicCollectTime.toString())) {
+                            nucleicCollectTime.append("<br>");
+                        }
+                        nucleicCollectTime.append(odsQssHsjcxx.getCjsj());
+
+                        if (StringUtils.isNotEmpty(nucleicResultsTime.toString())) {
+                            nucleicResultsTime.append("<br>");
+                        }
+                        nucleicResultsTime.append(odsQssHsjcxx.getJgcjss());
                     }
-                    nucleicResultsTime.append(odsQssHsjcxx.getJgcjss());
-
-                    index++;
+                    index = odsQssHsjcxxes.size();
                 }
             }
             if (index < Integer.parseInt(detectionNumber)) {