|
@@ -6374,24 +6374,122 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg fixIssue(Integer companyId) {
|
|
|
|
|
|
+ public HttpRespMsg fixIssue(Integer companyId, String startDate, String endDate) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
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"));
|
|
// List<AuditWorkflowTimeSetting> settings = auditWorkflowTimeSettingMapper.selectList(new QueryWrapper<AuditWorkflowTimeSetting>().select("distinct company_id"));
|