Pārlūkot izejas kodu

做预估工时检查时,去掉前端传过来的已经审核通过的日报。

seyason 1 gadu atpakaļ
vecāks
revīzija
57f655f867

+ 18 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -1193,7 +1193,6 @@ public class ReportController {
                             decimalFormat.format(report.getWorkingTime())));
                     return httpRespMsg;
                 }
-
             }
         }
         //如果开启了加班时长校验
@@ -1219,8 +1218,17 @@ public class ReportController {
         String warningGroupLack = "";
         EstimateTimeSetting estimateTimeSetting = null;
         if(comTimeType.getProjectManDay()==1){
-            Collection<Integer> projectIds = reportList.stream().map(Report::getProjectId).distinct().collect(Collectors.toList());
-            List<Report> needCheckReportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id", projectIds).and(wrapper->wrapper.eq("state",0).or().eq("state",1).or().eq("state",3)));
+            //剔除其中已通过的日报
+            List<Integer> filledReportIds = reportList.stream().filter(r->r.getId() != -1).map(Report::getId).collect(Collectors.toList());
+            List<Report> targetCheckList = reportList;
+            if (filledReportIds.size() > 0) {
+                List<Report> passedReportList = reportMapper.selectList(new QueryWrapper<Report>().select("id").in("id", filledReportIds).eq("state", 1));
+                if (passedReportList.size() > 0) {
+                    targetCheckList = reportList.stream().filter(r->!passedReportList.stream().map(Report::getId).collect(Collectors.toList()).contains(r.getId())).collect(Collectors.toList());
+                }
+            }
+            Collection<Integer> projectIds = targetCheckList.stream().map(Report::getProjectId).distinct().collect(Collectors.toList());
+            List<Report> oldRelatedReportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id", projectIds).and(wrapper->wrapper.eq("state",0).or().eq("state",1).or().eq("state",3)));
             List<Project> targetProjectList = projectList.stream().filter(pl -> projectIds.contains(pl.getId())).collect(Collectors.toList());
             estimateTimeSetting = estimateTimeSettingMapper.selectById(company.getId());
             //如果没有设置过项目人天,就初始化一下
@@ -1230,18 +1238,18 @@ public class ReportController {
                 estimateTimeSettingMapper.insert(estimateTimeSetting);
                 estimateTimeSetting = estimateTimeSettingMapper.selectById(company.getId());
             }
-            for (Report report : reportList) {
+            for (Report report : targetCheckList) {
                 HttpRespMsg httpRespMsg = new HttpRespMsg();
                 Optional<Project> first = targetProjectList.stream().filter(tl -> tl.getId().equals(report.getProjectId())).findFirst();
                 if(first.isPresent()){
-                    double nowReport = reportList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId())).mapToDouble(Report::getWorkingTime).sum();
+                    double nowReport = targetCheckList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId())).mapToDouble(Report::getWorkingTime).sum();
                     if(first.get().getManDay()!=null){
                         //已填报的工时情况
                         double sum;
                         if(first.get().getManDayStartDate()!=null){
-                            sum = needCheckReportList.stream().filter(npl -> npl.getProjectId().equals(first.get().getId()) &&(npl.getCreateDate().isAfter(first.get().getManDayStartDate())||npl.getCreateDate().isEqual(first.get().getManDayStartDate()))&& (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
+                            sum = oldRelatedReportList.stream().filter(npl -> npl.getProjectId().equals(first.get().getId()) &&(npl.getCreateDate().isAfter(first.get().getManDayStartDate())||npl.getCreateDate().isEqual(first.get().getManDayStartDate()))&& (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
                         }else {
-                            sum = needCheckReportList.stream().filter(npl -> npl.getProjectId().equals(first.get().getId()) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
+                            sum = oldRelatedReportList.stream().filter(npl -> npl.getProjectId().equals(first.get().getId()) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
                         }
                         BigDecimal hasReport = new BigDecimal(sum).add(new BigDecimal(nowReport));
                         BigDecimal multiply = new BigDecimal(first.get().getManDay()).multiply(new BigDecimal(comTimeType.getAllday()));
@@ -1263,11 +1271,11 @@ public class ReportController {
                             if (targetGpId != null) {
                                 double groupSum = 0;
                                 if(first.get().getManDayStartDate()!=null){
-                                    groupSum = needCheckReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) &&(npl.getCreateDate().isAfter(first.get().getManDayStartDate())||npl.getCreateDate().isEqual(first.get().getManDayStartDate()))&& (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
+                                    groupSum = oldRelatedReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) &&(npl.getCreateDate().isAfter(first.get().getManDayStartDate())||npl.getCreateDate().isEqual(first.get().getManDayStartDate()))&& (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
                                 }else {
-                                    groupSum = needCheckReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
+                                    groupSum = oldRelatedReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
                                 }
-                                nowReport = reportList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId()) && targetGpId.equals(rl.getGroupId())).mapToDouble(Report::getWorkingTime).sum();
+                                nowReport = targetCheckList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId()) && targetGpId.equals(rl.getGroupId())).mapToDouble(Report::getWorkingTime).sum();
                                 hasReport = new BigDecimal(groupSum).add(new BigDecimal(nowReport));
                                 TaskGroup tgp = taskGroupService.getById(targetGpId);
                                 //设置的数值大于0时检查是否超额