Kaynağa Gözat

考勤同步修改

QuYueTing 1 hafta önce
ebeveyn
işleme
1445a4f021

+ 10 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/DataCollectTask.java

@@ -288,7 +288,7 @@ public class DataCollectTask {
     }
 
     @Scheduled(cron = "0 30 1 * * ?")
-//@Scheduled(cron = "0 33 16 * * ?")
+//@Scheduled(cron = "0 42 16 * * ?")
     public void workDayTask(){
         if(isDev){return;}
         RestTemplate restTemplate = new RestTemplate();
@@ -345,12 +345,15 @@ public class DataCollectTask {
                             List<UserFvTime> realDataList = dataList.stream().filter(t -> StringUtils.isNotBlank(t.getUserId())).collect(Collectors.toList());
                             if(!CollectionUtils.isEmpty(realDataList)){
                                 List<String> collect = realDataList.stream().map(UserFvTime::getProcinstId).distinct().collect(Collectors.toList());
-                                List<String> existIds = userFvTimeMapper.getExistIds(collect,specialCompanyId);
-                                if(!CollectionUtils.isEmpty(existIds)){
-                                    toUpdateList.addAll(realDataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
-                                    toAddList.addAll(realDataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
-                                }else{
-                                    toAddList.addAll(realDataList);
+                                List<UserFvTime> existList = userFvTimeMapper.selectList(new LambdaQueryWrapper<UserFvTime>().in(UserFvTime::getProcinstId, collect).eq(UserFvTime::getCompanyId, specialCompanyId));
+                                for (UserFvTime tmp : realDataList) {
+                                    Optional<UserFvTime> first = existList.stream().filter(t -> t.getProcinstId().equals(tmp.getProcinstId())).findFirst();
+                                    if(first.isPresent()){
+                                        tmp.setId(first.get().getId());
+                                        toUpdateList.add(tmp);
+                                    } else {
+                                        toAddList.add(tmp);
+                                    }
                                 }
                                 if(!CollectionUtils.isEmpty(toAddList)){
                                     userFvTimeMapper.batchInsertCollect(toAddList);