Ver Fonte

数据拉取定时任务、逻辑补充

zhouyy há 1 mês atrás
pai
commit
16baa51ebd

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/QRCodeController.java

@@ -66,7 +66,7 @@ public class QRCodeController {
                 msg.setError("二维码生成失败,请联系管理员");
                 return msg;
             }
-            filesToZip[index] = "/upload/"+fileName;
+            filesToZip[index] = uploadPath+fileName;
             index++;
         }
         String zipFileName = System.currentTimeMillis()+".zip";

+ 20 - 18
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/DataCollectTask.java

@@ -104,7 +104,7 @@ public class DataCollectTask {
 
 
 
-    @Scheduled(cron = "0 52 10 * * ?")
+    @Scheduled(cron = "0 0 1 * * ?")
     @Async
     public void sqlServerTask() {
         RestTemplate restTemplate = new RestTemplate();
@@ -223,27 +223,29 @@ public class DataCollectTask {
                                 User tmp = userMap.get(userFvTime.getUserId());
                                 userFvTime.setUserId(null==tmp?null:tmp.getId());
                             }
-                            List<String> collect = dataList.stream().map(UserFvTime::getProcinstId).distinct().collect(Collectors.toList());
-                            List<String> existIds = userFvTimeMapper.getExistIds(collect,specialCompanyId);
-                            if(!CollectionUtils.isEmpty(existIds)){
-                                toUpdateList.addAll(dataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
-                                toAddList.addAll(dataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
-                            }else{
-                                toAddList.addAll(dataList);
-                            }
-                            if(!CollectionUtils.isEmpty(toAddList)){
-                                userFvTimeMapper.batchInsertCollect(toAddList);
-                            }
-                            if(!CollectionUtils.isEmpty(toUpdateList)){
-                                for (UserFvTime tmp : toUpdateList) {
-                                    userFvTimeMapper.updateById(tmp);
+                            List<UserFvTime> realDataList = dataList.stream().filter(t -> null != t.getUserId()).collect(Collectors.toList());
+                            if(!CollectionUtils.isEmpty(realDataList)){
+                                List<String> collect = dataList.stream().map(UserFvTime::getProcinstId).distinct().collect(Collectors.toList());
+                                List<String> existIds = userFvTimeMapper.getExistIds(collect,specialCompanyId);
+                                if(!CollectionUtils.isEmpty(existIds)){
+                                    toUpdateList.addAll(dataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
+                                    toAddList.addAll(dataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
+                                }else{
+                                    toAddList.addAll(dataList);
+                                }
+                                if(!CollectionUtils.isEmpty(toAddList)){
+                                    userFvTimeMapper.batchInsertCollect(toAddList);
+                                }
+                                if(!CollectionUtils.isEmpty(toUpdateList)){
+                                    for (UserFvTime tmp : toUpdateList) {
+                                        userFvTimeMapper.updateById(tmp);
+                                    }
                                 }
                             }
-                            toUpdateList.clear();
-                            toAddList.clear();
                         }
-
                     }
+                    toUpdateList.clear();
+                    toAddList.clear();
                     offset += pageSize;
                 }
             }