shudonghui пре 1 година
родитељ
комит
6717447c4c

+ 19 - 3
sop-business/src/main/java/com/qmth/sop/business/service/impl/SopScheduleServiceImpl.java

@@ -24,8 +24,11 @@ import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
+import static com.qmth.sop.common.util.DateDisposeUtils.parseDate;
+
 @Service
 public class SopScheduleServiceImpl extends ServiceImpl<SopScheduleMapper, TBSopInfo> implements SopScheduleService {
     @Resource
@@ -121,10 +124,23 @@ public class SopScheduleServiceImpl extends ServiceImpl<SopScheduleMapper, TBSop
             map.put("count", v.stream().filter(map1 -> map1.get("count") != null).mapToInt(m -> Integer.parseInt(m.get("count").toString())).sum());
             plan.add(map);
         });
+        List<Map<String, Object>> temp2List = new ArrayList<>();
+        List<Map<String, Object>> actualed = this.baseMapper.actualProgress(serviceId);
+        temp2List.addAll(plan);
+        temp2List.addAll(actualed);
+        Object max = temp2List.stream().max(Comparator.comparing(o -> o.get("datetime").toString())).get().get("datetime");
+        Object min =temp2List.stream().min(Comparator.comparing(o -> o.get("datetime").toString())).get().get("datetime");
+        List<String> daysBetween = DateDisposeUtils.getDaysBetween(parseDate(min).getTime(), parseDate(max).getTime(), SystemConstant.DEFAULT_DATE_YMD_PATTERN);
+        daysBetween.forEach(e->{
+            Map<String, Object> map = new HashMap<>();
+            map.put("datetime", e);
+            map.put("count", 0);
+            if(plan.stream().noneMatch(e1->e1.containsKey(e)))plan.add(map);
+            if(actualed.stream().noneMatch(e1->e1.containsKey(e)))actualed.add(map);
+        });
 
-
-        result.put("plan", plan);
-        result.put("actual", this.baseMapper.actualProgress(serviceId));
+        result.put("plan", plan.stream().sorted(Comparator.comparing(o -> o.get("datetime").toString())).collect(Collectors.toList()));
+        result.put("actual", actualed.stream().sorted(Comparator.comparing(o -> o.get("datetime").toString())).collect(Collectors.toList()));
         return result;
     }