Browse Source

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Min 1 year ago
parent
commit
0f9c3d1d4b

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

@@ -2068,8 +2068,8 @@ public class ReportController {
     }
 
     @GetMapping("/fixIssue")
-    public HttpRespMsg fixIssue(Integer companyId){
-        return reportService.fixIssue(companyId);
+    public HttpRespMsg fixIssue(Integer companyId, String startDate, String endDate){
+        return reportService.fixIssue(companyId, startDate, endDate);
     }
 
     /**

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -203,4 +203,7 @@ public interface ReportMapper extends BaseMapper<Report> {
 
     List<Map<String, Object>> selectReallyTimeWithMap(Integer companyId,Integer projectId);
     List<Map<String, Object>> getCustomDataWithDate(String startDate, String endDate, Integer companyId);
+
+    @Select("SELECT report.id,report.creator_id,  report.`create_date`, report.`create_time`, group_id, task_group.`name`,report.project_id, task_group.`project_id` AS error_pid FROM report LEFT JOIN task_group ON task_group.id = report.`group_id` WHERE report.`company_id`=#{companyId} AND report.project_id <> task_group.`project_id`  AND create_date BETWEEN #{startDate} AND #{endDate} ORDER BY report.id DESC")
+    List<Map<String, Object>> selectErrorGroupData(Integer companyId, String startDate, String endDate);
 }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -94,7 +94,7 @@ public interface ReportService extends IService<Report> {
 
     HttpRespMsg getReportListByToken(String json);
 
-    HttpRespMsg fixIssue(Integer companyId);
+    HttpRespMsg fixIssue(Integer companyId, String startDate, String endDate);
 
     HttpRespMsg getWeeklyCardTime(String dateStr, HttpServletRequest request);
 

+ 115 - 17
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -6374,24 +6374,122 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     }
 
     @Override
-    public HttpRespMsg fixIssue(Integer companyId) {
+    public HttpRespMsg fixIssue(Integer companyId, String startDate, String endDate) {
         HttpRespMsg msg = new HttpRespMsg();
-        List<ReportBatch> reportBatchList = reportBatchMapper.selectList(new QueryWrapper<ReportBatch>().eq("company_id", companyId));
-        List<Integer> batchIds = reportBatchList.stream().map(ReportBatch::getId).collect(Collectors.toList());
-        List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("company_id", companyId).notIn("batch_id", batchIds));
-        List<Report> updateList = new ArrayList<>();
-        for(Report r : reportList) {
-            Report targetReport = reportMapper.selectOne(new QueryWrapper<Report>().select("id, batch_id").eq("company_id", companyId).eq("creator_id", r.getCreatorId()).eq("create_date", r.getCreateDate()).orderByDesc("batch_id").last("limit 1"));
-            Report upItem = new Report();
-            upItem.setId(r.getId());
-            upItem.setBatchId(targetReport.getBatchId());
-            updateList.add(upItem);
-        }
-        if (updateList.size() > 0) {
-            updateBatchById(updateList);
-        }
-        msg.setData("共更新"+updateList.size()+"条数据");
-        return msg;
+        List<Map<String, Object>> reportList = reportMapper.selectErrorGroupData(companyId, startDate, endDate);
+        System.out.println("==异常数据有=="+reportList.size()+"条==");
+        if (reportList.size() > 0) {
+            List<Report> updateList = new ArrayList<>();
+            List<Integer> allPids = new ArrayList<>();
+            for(Map<String, Object> r : reportList) {
+                Integer projectId = (Integer)r.get("project_id");
+                allPids.add(projectId);
+            }
+            //获取项目下的全部任务分组
+            List<TaskGroup> taskGroupList = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", allPids));
+            List<Map<String, Object>> noDataList = new ArrayList<>();
+            List<Map<String, Object>> similaryMatchList = new ArrayList<>();
+            List<Map<String, Object>> completeMatchList = new ArrayList<>();
+            List<Map<String, Object>> directOneList = new ArrayList<>();
+
+            for(Map<String, Object> r : reportList) {
+                String oldGroupName = (String)r.get("name");
+                Integer groupId = (Integer)r.get("group_id");
+                String creatorId = (String)r.get("creator_id");
+                groupParticipatorMapper.selectList(new QueryWrapper<GroupParticipator>().eq("group_id", groupId).eq("user_id", creatorId));
+                Integer projectId = (Integer)r.get("project_id");
+                List<TaskGroup> correctGroupList = taskGroupList.stream().filter(tg -> tg.getProjectId().equals(projectId)).collect(Collectors.toList());
+                //第一个任务分组
+                TaskGroup firstGroup = correctGroupList.get(0);
+                //过滤当前填报人参与的任务分组
+                List<Integer> groupIds = correctGroupList.stream().map(TaskGroup::getId).collect(Collectors.toList());
+                List<GroupParticipator> groupParticipatorList = groupParticipatorMapper.selectList(new QueryWrapper<GroupParticipator>().in("group_id", groupIds).eq("user_id", creatorId));
+                correctGroupList = correctGroupList.stream().filter(tg -> groupParticipatorList.stream().anyMatch(gp -> gp.getGroupId().equals(tg.getId()))).collect(Collectors.toList());
+                r.put("correctGroupList", correctGroupList);
+                if (correctGroupList.size() == 0) {
+                    noDataList.add(r);
+                    //没有参与的分组,就取项目下的第一个任务分组
+                    Report report = new Report();
+                    report.setId((Integer)r.get("id"));
+                    report.setGroupId(firstGroup.getId());
+                    updateList.add(report);
+                } else if (correctGroupList.size() == 1) {
+                    //就参与了一个任务分组,直接换成那个
+                    Report report = new Report();
+                    report.setId((Integer)r.get("id"));
+                    report.setGroupId(correctGroupList.get(0).getId());
+                    updateList.add(report);
+                    directOneList.add(r);
+                } else {
+                    //按oldGroupName进行匹配,如果不能完全匹配上,按相似度匹配
+                    Optional<TaskGroup> first = correctGroupList.stream().filter(tg -> tg.getName().equals(oldGroupName)).findFirst();
+                    if (!first.isPresent()) {
+                        //模糊匹配,按照oldGroupName的文字在correctGroupList中的匹配字数,获取匹配字数最多的一条
+                        int maxMatch = 0;
+                        TaskGroup maxMatchGroup = null;
+                        for (TaskGroup tg : correctGroupList) {
+                            int curMatchWordCount = 0;
+                            for (int i = 0; i < oldGroupName.length(); i++) {
+                                char c = oldGroupName.charAt(i);
+                                if (tg.getName().indexOf(c) != -1) {
+                                    curMatchWordCount++;
+                                }
+                            }
+                            if (curMatchWordCount > maxMatch) {
+                                maxMatch = curMatchWordCount;
+                                maxMatchGroup = tg;
+                            }
+                        }
+                        if (maxMatchGroup != null) {
+                            Report report = new Report();
+                            report.setId((Integer)r.get("id"));
+                            report.setGroupId(maxMatchGroup.getId());
+                            System.out.println(r.get("id")+" =@@@@日报中分组="+oldGroupName+", 更新为="+maxMatchGroup.getName());
+                            updateList.add(report);
+                            similaryMatchList.add(r);
+                        } else {
+                            System.out.println(r.get("id")+" 找不到任何匹配的任务分组==日报中分组="+oldGroupName+", projectId="+projectId+"下的分组列表为==");
+                            for (TaskGroup tg : correctGroupList) {
+                                System.out.println(tg.getName());
+                            }
+                            noDataList.add(r);
+                            //没有匹配的分组,就取项目下的第一个任务分组
+                            Report report = new Report();
+                            report.setId((Integer)r.get("id"));
+                            report.setGroupId(firstGroup.getId());
+                            updateList.add(report);
+                            System.out.println("======END========");
+                        }
+                    } else {
+                        Report report = new Report();
+                        report.setId((Integer)r.get("id"));
+                        report.setGroupId(first.get().getId());
+                        updateList.add(report);
+                        completeMatchList.add(r);
+                    }
+                }
+
+            }
+            if (updateList.size() > 0) {
+                updateBatchById(updateList);
+            }
+            String str = "";
+            for (Map<String, Object> r : noDataList) {
+                str += r.get("id")+", ";
+            }
+            if (str.length() > 0) {
+                str = str.substring(0, str.length()-2);
+            }
+            System.out.println("无法匹配的数据=id=="+str);
+            msg.setData("共"+reportList.size()+"条异常数据,可更新"+updateList.size()+"条数据"+"(相似匹配的数据=="+similaryMatchList.size()+"条"+", 完全匹配的数据=="+completeMatchList.size()+"条"
+            +", 直接仅一个分组替换的数据=="+directOneList.size()+"条"+"), 无法匹配的数据=="+noDataList.size()+"条:"+str);
+
+            return msg;
+        } else {
+            msg.setData("无异常数据");
+            return msg;
+        }
+
 
 //        //处理被误操作为自动审核的数据,
 //        List<AuditWorkflowTimeSetting> settings = auditWorkflowTimeSettingMapper.selectList(new QueryWrapper<AuditWorkflowTimeSetting>().select("distinct company_id"));

+ 2 - 0
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/index.vue

@@ -1898,6 +1898,7 @@ export default {
             }
 
             this.form.domains[this.clickIndex].showPickerStage = false;
+            this.getTaskList(this.form.domains[this.clickIndex]);
             this.$forceUpdate();
 
         },
@@ -1971,6 +1972,7 @@ export default {
                 this.$axios.post("/task/getRecentTask", param)
                     .then(res => {
                         if (res.code == "ok") {
+                            this.form.domains[this.clickIndex].allTaskList = res.data;
                             this.form.domains[this.clickIndex].taskList = res.data;
                             this.form = this.form;
                         } else {