Prechádzať zdrojové kódy

修复补填上个月时,按周填报模块出现的bug

seyason 1 rok pred
rodič
commit
19e0ad06a0

+ 66 - 15
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -692,7 +692,6 @@ public class ReportController {
                 LocalDate curMonthDeadline = LocalDate.now().withDayOfMonth(compTimeType.getFillMonthOnDay());
                 if (createDate.length > 0) {
                     String createDateOne = createDate[0];
-                    //日期都是一样的,取第一个就行了
                     if (fillMonths == 2) {
                         //补填到上个月的情况,要检查当前日期,是否在设置的日期之前
                         LocalDate lastMonth = LocalDate.now().minusMonths(1);
@@ -712,15 +711,20 @@ public class ReportController {
                                 }
                             }
                         } else {
-                            //单日填报,检查日期是否早于限制时间
-                            if (LocalDate.parse(createDateOne, dateTimeFormatter).isBefore(targetDate)) {
-                                isForbidden = true;
-                            } else {
-                                if (LocalDate.parse(createDateOne, dateTimeFormatter).getMonth().getValue() == lastMonth.getMonth().getValue()) {
-                                    //补填到上个月的情况,要检查当前日期,是否在设置的日期之前
-                                    if (LocalDate.now().isAfter(curMonthDeadline)) {
-                                        isForbidden = true;
-                                        isLastMonthFail = true;
+                            //单日或者按周填报
+                            String checkDate = getCheckDate(createDate, id);
+                            //可能返回的是Null,表示都是待审核或者已通过的
+                            if (checkDate != null) {
+                                //检查目标是否早于限制时间
+                                if (LocalDate.parse(checkDate, dateTimeFormatter).isBefore(targetDate)) {
+                                    isForbidden = true;
+                                } else {
+                                    if (LocalDate.parse(checkDate, dateTimeFormatter).getMonth().getValue() == lastMonth.getMonth().getValue()) {
+                                        //补填到上个月的情况,要检查当前日期,是否在设置的日期之前
+                                        if (LocalDate.now().isAfter(curMonthDeadline)) {
+                                            isForbidden = true;
+                                            isLastMonthFail = true;
+                                        }
                                     }
                                 }
                             }
@@ -734,10 +738,14 @@ public class ReportController {
                                 isForbidden = true;
                             }
                         } else {
-                            //单日填报,检查日期是否早于限制时间
-                            if (LocalDate.parse(createDateOne, dateTimeFormatter).isBefore(targetDate)) {
-                                isForbidden = true;
+                            //单日填报,检查日期是否早于限制时间; //可能返回的是Null,表示都是待审核或者已通过的
+                            String checkDate = getCheckDate(createDate, id);
+                            if (checkDate != null) {
+                                if (LocalDate.parse(checkDate, dateTimeFormatter).isBefore(targetDate)) {
+                                    isForbidden = true;
+                                }
                             }
+
                         }
                     }
                 }
@@ -1238,14 +1246,12 @@ public class ReportController {
                                 }else {
                                     groupSum = needCheckReportList.stream().filter(npl -> npl.getGroupId().equals(targetGpId) && (npl.getState() == 0 || npl.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
                                 }
-                                System.out.println("groupSum:"+groupSum);
                                 nowReport = reportList.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时检查是否超额
                                 if (tgp != null && tgp.getManDay() != null && tgp.getManDay() > 0) {
                                     multiply = new BigDecimal(tgp.getManDay()).multiply(new BigDecimal(comTimeType.getAllday()));
-                                    System.out.println("hasReport:"+hasReport+" multiply:"+multiply);
                                     if (hasReport.doubleValue() > multiply.doubleValue()) {
                                         if (estimateTimeSetting.getGroupFronzeOnLack() == 1) {
                                             httpRespMsg.setError("超过当前项目["+first.get().getProjectName()+"]分组["+tgp.getName()+"]预算工时,无法继续提交工时");
@@ -2338,5 +2344,50 @@ public class ReportController {
         return reportService.getUserTimeCostByThird(json);
     }
 
+
+    private String getCheckDate(String[] createDate, Integer[] id) {
+        String checkDate = null;
+        String createDateOne = createDate[0];
+        if (createDate.length == 1) {
+            checkDate = createDateOne;
+        } else {
+            List<Integer> idParams = ListUtil.fromIntegers(id);
+            //只取填报过的日报id,新增加的不用检查
+            idParams = idParams.stream().filter(i->i!=-1).collect(Collectors.toList());
+            if (idParams.size() >0) {
+                //已通过或待审核的日报
+                System.out.println("=============查询已通过或者待审核的日报==================");
+                List<Report> passOrPendingReportList = reportMapper.selectList(new QueryWrapper<Report>().select("id").in("id", idParams).and(reportQueryWrapper -> reportQueryWrapper.eq("state", 1).or().eq("state", 0)));
+                if (passOrPendingReportList.size() > 0) {
+                    List<Integer> collect = passOrPendingReportList.stream().map(Report::getId).collect(Collectors.toList());
+                    for (int i=0;i<id.length; i++) {
+                        if (!collect.contains(id[i])) {
+                            if (checkDate == null) {
+                                checkDate = createDate[i];
+                            } else {
+                                //取最早的日期
+                                if (createDate[i].compareTo(checkDate) < 0) {
+                                    checkDate = createDate[i];
+                                }
+                            }
+                        }
+                    }
+                }
+            } else {
+                //全是新增的情况,取最早的一个日期
+                for (int i=0;i<createDate.length; i++) {
+                    if (checkDate == null) {
+                        checkDate = createDate[i];
+                    } else {
+                        //取最早的日期
+                        if (createDate[i].compareTo(checkDate) < 0) {
+                            checkDate = createDate[i];
+                        }
+                    }
+                }
+            }
+        }
+        return checkDate;
+    }
 }
 

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Report.java

@@ -403,6 +403,8 @@ public class Report extends Model<Report> {
     @TableField("sap_service_id")
     private Integer sapServiceId;
 
+    @TableField(exist = false)
+    private List<SapProjectService> serviceList;
 
     @Override
     protected Serializable pkVal() {

+ 8 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -1845,37 +1845,37 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             }
                             if (withPercent == 1) {
                                 //工时占比
-                                membRowData.add(String.valueOf(new BigDecimal((Double)resultList.get(0).get("cost")/curUserTotalTime*100).setScale(1, BigDecimal.ROUND_HALF_UP))+"%");
+                                membRowData.add(String.valueOf(new BigDecimal((Double)resultList.get(0).get("cost")/curUserTotalTime*100).setScale(2, BigDecimal.ROUND_HALF_UP))+"%");
                             }
                             costTime += (Double)resultList.get(0).get("cost");
                             moneyCost = moneyCost.add((BigDecimal)resultList.get(0).get("costMoney"));
                         }else{
                             if ("hours".equals(exportContent) && functionTimeList.size()>0){
-                                membRowData.add("");
+                                membRowData.add("0");
                             }else if ("cost".equals(exportContent) && functionCostList.size()>0){
-                                membRowData.add("");
+                                membRowData.add("0");
                             }else {
                                 if(functionTimeList.size()>0){
-                                    membRowData.add("");
+                                    membRowData.add("0");
                                 }
                                 if(functionCostList.size()>0){
-                                    membRowData.add("");
+                                    membRowData.add("0");
                                 }
                             }
                             if (withPercent == 1) {
                                 //工时占比
-                                membRowData.add("");
+                                membRowData.add("0");
                             }
                         }
                     }
 
                     if ("hours".equals(exportContent) && functionTimeList.size()>0){
-                        membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
+                        membRowData.add(""+new BigDecimal(costTime).setScale(2, BigDecimal.ROUND_HALF_UP));
                     }else if ("cost".equals(exportContent) && functionCostList.size()>0){
                         membRowData.add(moneyCost.toString());
                     }else {
                         if(functionTimeList.size()>0){
-                            membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
+                            membRowData.add(""+new BigDecimal(costTime).setScale(2, BigDecimal.ROUND_HALF_UP));
                         }
                         if(functionCostList.size()>0){
                             membRowData.add(moneyCost.toString());

+ 29 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -204,6 +204,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     @Resource
     private ReportAuditLogService reportAuditLogService;
     @Resource
+    private TaskExecutorMapper taskExecutorMapper;
+    @Resource
     private TimeTypeService timeTypeService;
     @Resource
     private HttpServletRequest request;
@@ -792,6 +794,20 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     List<ProFunWorkContext> workContentList = ((List<ProFunWorkContext>)funWorkContextList.data);
                     r.setWorkContentList(workContentList);
                 }
+                //依斯贝要返回服务
+                if (companyId == 3092) {
+                    Integer taskId = r.getTaskId();
+                    if (taskId != null) {
+                        List<TaskExecutor> executorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().eq("task_id", taskId).eq("executor_id", r.getCreatorId()));
+                        List<String> sapServiceIds = executorList.stream().map(TaskExecutor::getServiceId).collect(Collectors.toList());
+                        if (sapServiceIds.size() > 0) {
+                            List<SapProjectService> sapSList = sapProjectServiceMapper.selectList(new QueryWrapper<SapProjectService>().in("id", sapServiceIds));
+                            r.setServiceList(sapSList);
+                        } else {
+                            r.setServiceList(new ArrayList<>());
+                        }
+                    }
+                }
             });
             resultMap.put("report", reports);
             TimeType timeType = timeTypeMapper.selectById(companyId);
@@ -1590,6 +1606,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 targetUids = ListUtil.convertLongIdsArrayToList(userId);
             }
             List<Map<String, Object>> auditReportList = reportMapper.getAuditReportList(date, companyId, departmentId, projectId, leaderId, isEngeering, startDate, endDate, targetUids);
+            //针对依斯贝增加服务名称显示
+            if (companyId == 3092) {
+                List<SapProjectService> serviceList = sapProjectServiceMapper.selectList(new QueryWrapper<SapProjectService>().eq("company_id", companyId));
+                for (Map<String, Object> mapItem : auditReportList) {
+                    Integer sapServiceId = (Integer)mapItem.get("sapServiceId");
+                    if (sapServiceId != null) {
+                        Optional<SapProjectService> first = serviceList.stream().filter(s -> s.getId().equals(sapServiceId)).findFirst();
+                        if (first.isPresent()) {
+                            mapItem.put("sapServiceName", first.get().getServiceName());
+                        }
+                    }
+                }
+            }
             //抽取姓名,进行分组
             List<Map<String, Object>> nameList = new ArrayList<Map<String, Object>>();
             Map<String, Object> lastName = null;

+ 7 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ListUtil.java

@@ -154,4 +154,11 @@ public class ListUtil {
 		}
 		return ids;
 	}
+	public static List<Integer> fromIntegers(Integer[] data) {
+		List<Integer> ids = new ArrayList<>();
+		for (int i : data) {
+			ids.add(i);
+		}
+		return ids;
+	}
 }

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TaskMapper.xml

@@ -234,10 +234,10 @@
             and executor_id like '%${userId}%'
         </if>
         <if test="stage != null">
-            and stages.stagesName = #{stage}
+            and stages.stages_name = #{stage}
         </if>
         <if test="groupId != null">
-            and task.gruop_id = #{groupId}
+            and task.group_id = #{groupId}
         </if>
         and task_status = 0 order by task.id desc limit 50
     </select>

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -5407,7 +5407,7 @@
                                     extraField3: list.report[i].extraField3,
                                     workContentList: list.report[i].workContentList,
                                     filteredRespList: filteredRespList,
-                                    serviceList: report[i].serviceList
+                                    serviceList: list.report[i].serviceList
                                 })
                                 if (list.report[i].state >= 2) {
                                     this.canEdit = true;