|
@@ -21,6 +21,7 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.hamcrest.core.Is;
|
|
import org.hamcrest.core.Is;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -34,10 +35,7 @@ import java.io.*;
|
|
import java.lang.reflect.Array;
|
|
import java.lang.reflect.Array;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -76,6 +74,10 @@ public class ReportLogController {
|
|
private ReportLogDetailService reportLogDetailService;
|
|
private ReportLogDetailService reportLogDetailService;
|
|
@Resource
|
|
@Resource
|
|
private WxCorpInfoService wxCorpInfoService;
|
|
private WxCorpInfoService wxCorpInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ReportLogMapper reportLogMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ReportLogDetailMapper reportLogDetailMapper;
|
|
|
|
|
|
@RequestMapping("/get")
|
|
@RequestMapping("/get")
|
|
public HttpRespMsg get(String creatorId, String createDate) {
|
|
public HttpRespMsg get(String creatorId, String createDate) {
|
|
@@ -86,16 +88,29 @@ public class ReportLogController {
|
|
CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
|
|
CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
|
|
List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id",user.getCompanyId()));
|
|
List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id",user.getCompanyId()));
|
|
for (ReportLog reportLog : list) {
|
|
for (ReportLog reportLog : list) {
|
|
- String operatorId = reportLog.getOperatorId();
|
|
|
|
- for (User item : users) {
|
|
|
|
- if (item.getId().equals(operatorId)){
|
|
|
|
- String name = item.getName();
|
|
|
|
- if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
|
|
- reportLog.setMsg(reportLog.getMsg().replace(name,"$userName=" + item.getCorpwxUserid() + "$"));
|
|
|
|
- }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
|
|
|
|
- reportLog.setMsg(reportLog.getMsg().replace(name,"$userName=" + item.getDingdingUserid() + "$"));
|
|
|
|
|
|
+ if (reportLog.getMsg().endsWith("提交了日报")) {
|
|
|
|
+ String reportCreatorId = reportLog.getCreatorId();
|
|
|
|
+ for (User item : users) {
|
|
|
|
+ if (item.getId().equals(reportCreatorId)){
|
|
|
|
+ String name = item.getName();
|
|
|
|
+ if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
|
|
+ reportLog.setMsg(reportLog.getMsg().replace(name,"$userName=" + item.getCorpwxUserid() + "$"));
|
|
|
|
+ }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
|
|
|
|
+ reportLog.setMsg(reportLog.getMsg().replace(name,"$userName=" + item.getDingdingUserid() + "$"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String operatorId = reportLog.getOperatorId();
|
|
|
|
+ for (User item : users) {
|
|
|
|
+ if (item.getId().equals(operatorId)){
|
|
|
|
+ String name = item.getName();
|
|
|
|
+ if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
|
|
+ reportLog.setMsg(reportLog.getMsg().replace(name,"$userName=" + item.getCorpwxUserid() + "$"));
|
|
|
|
+ }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
|
|
|
|
+ reportLog.setMsg(reportLog.getMsg().replace(name,"$userName=" + item.getDingdingUserid() + "$"));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -247,7 +262,7 @@ public class ReportLogController {
|
|
List<Integer> reportSubIds = Arrays.asList(split).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
List<Integer> reportSubIds = Arrays.asList(split).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
reportIdList.addAll(reportSubIds);
|
|
reportIdList.addAll(reportSubIds);
|
|
});
|
|
});
|
|
- List<Report> reportList = reportMapper.selectList(new LambdaQueryWrapper<Report>().in(Report::getId, reportIdList));
|
|
|
|
|
|
+ List<Report> reportList = reportMapper.selectList(new LambdaQueryWrapper<Report>().select(Report::getId, Report::getCreateTime, Report::getProjectAuditTime).in(Report::getId, reportIdList));
|
|
List<ReportLogDetail> allReportLogDetails = reportLogDetailService.list(new LambdaQueryWrapper<ReportLogDetail>().select(ReportLogDetail::getMsg,ReportLogDetail::getId).in(ReportLogDetail::getReportId, reportIdList));
|
|
List<ReportLogDetail> allReportLogDetails = reportLogDetailService.list(new LambdaQueryWrapper<ReportLogDetail>().select(ReportLogDetail::getMsg,ReportLogDetail::getId).in(ReportLogDetail::getReportId, reportIdList));
|
|
StringBuilder sb=new StringBuilder();
|
|
StringBuilder sb=new StringBuilder();
|
|
List<Report> needUpdateReportList=new ArrayList<>();
|
|
List<Report> needUpdateReportList=new ArrayList<>();
|
|
@@ -402,5 +417,136 @@ public class ReportLogController {
|
|
}
|
|
}
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @RequestMapping("/changeReportLogAuditor")
|
|
|
|
+ public HttpRespMsg changeReportLogAuditor(HttpServletRequest request){
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+// try {
|
|
|
|
+// String auditorId = "8523550798754947072";
|
|
|
|
+// List<ReportLog> reportLogs = reportLogMapper.selectList(new QueryWrapper<ReportLog>().eq("company_id", 7544).eq("operator_id", auditorId).like("msg", "审核通过了"));
|
|
|
|
+//
|
|
|
|
+// List<ReportLog> updateReportLogs = new ArrayList<>();
|
|
|
|
+// List<Integer> reportIdList = new ArrayList<>();
|
|
|
|
+// for (ReportLog reportLog : reportLogs) {
|
|
|
|
+// String reportIds = reportLog.getReportIds();
|
|
|
|
+// List<Integer> ids = Arrays.asList(reportIds.split(",")).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
|
|
+// //只去第一个项目
|
|
|
|
+// Integer rid = ids.get(0);
|
|
|
|
+// reportIdList.add(rid);
|
|
|
|
+// }
|
|
|
|
+// if (reportIdList.size() == 0) {
|
|
|
|
+// msg.data = "没有数据";
|
|
|
|
+// return msg;
|
|
|
|
+// }
|
|
|
|
+// List<Report> reports = reportMapper.selectList(new QueryWrapper<Report>().select("id, project_id").in("id", reportIdList));
|
|
|
|
+// List<Integer> collect = reports.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
|
+// List<Project> projects = projectMapper.selectList(new QueryWrapper<Project>().select("id, incharger_id").in("id", collect));
|
|
|
|
+// List<User> allUsers = userMapper.selectList(new QueryWrapper<User>().select("id, name").eq("company_id", 7544));
|
|
|
|
+// for (ReportLog reportLog : reportLogs) {
|
|
|
|
+// String reportIds = reportLog.getReportIds();
|
|
|
|
+// List<Integer> ids = Arrays.asList(reportIds.split(",")).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
|
|
+// //只去第一个项目
|
|
|
|
+// Integer rid = ids.get(0);
|
|
|
|
+// Report report = reports.stream().filter(r -> r.getId().equals(rid)).findFirst().get();
|
|
|
|
+// //查找project的inchargerId
|
|
|
|
+// Project project = projects.stream().filter(p -> p.getId().equals(report.getProjectId())).findFirst().get();
|
|
|
|
+// String inChargerId = project.getInchargerId();
|
|
|
|
+// reportLog.setOperatorId(inChargerId);
|
|
|
|
+// ReportLog item = new ReportLog();
|
|
|
|
+// item.setId(reportLog.getId());
|
|
|
|
+// item.setOperatorId(inChargerId);
|
|
|
|
+// //woy9TkCAAAapCHjv-2GgW0l7xw4pKDtQ审核通过了日报
|
|
|
|
+// allUsers.stream().filter(u -> u.getId().equals(inChargerId)).findFirst().ifPresent(u -> item.setMsg(u.getName()+"审核通过了日报"));
|
|
|
|
+// System.out.println("更新》》" + reportLog.getId()+", inchargerId="+inChargerId+", msg="+item.getMsg());
|
|
|
|
+// updateReportLogs.add(item);
|
|
|
|
+// }
|
|
|
|
+// if (updateReportLogs.size() > 0) {
|
|
|
|
+// //更新
|
|
|
|
+// System.out.println("更新了" + updateReportLogs.size() + "条数据");
|
|
|
|
+// reportLogService.updateBatchById(updateReportLogs);
|
|
|
|
+// }
|
|
|
|
+// msg.setMsg("更新完成");
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// msg.setError(MessageUtils.message("other.error"));
|
|
|
|
+// return msg;
|
|
|
|
+// }
|
|
|
|
+ try {
|
|
|
|
+ String auditorId = "8523550798754947072";
|
|
|
|
+ List<ReportLogDetail> reportLogs = reportLogDetailMapper.selectList(new QueryWrapper<ReportLogDetail>().eq("company_id", 7544).eq("operator_id", auditorId).like("msg", "审核通过了"));
|
|
|
|
+
|
|
|
|
+ List<ReportLogDetail> updateReportLogs = new ArrayList<>();
|
|
|
|
+ List<Integer> reportIdList = new ArrayList<>();
|
|
|
|
+ for (ReportLogDetail reportLog : reportLogs) {
|
|
|
|
+ reportIdList.add(reportLog.getReportId());
|
|
|
|
+ }
|
|
|
|
+ if (reportIdList.size() == 0) {
|
|
|
|
+ msg.data = "没有数据";
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ List<Report> reports = reportMapper.selectList(new QueryWrapper<Report>().select("id, project_id").in("id", reportIdList));
|
|
|
|
+ List<Integer> collect = reports.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
|
+ List<Project> projects = projectMapper.selectList(new QueryWrapper<Project>().select("id, incharger_id").in("id", collect));
|
|
|
|
+ List<User> allUsers = userMapper.selectList(new QueryWrapper<User>().select("id, name").eq("company_id", 7544));
|
|
|
|
+ for (ReportLogDetail reportLog : reportLogs) {
|
|
|
|
+ Integer rid = reportLog.getReportId();
|
|
|
|
+ Report report = reports.stream().filter(r -> r.getId().equals(rid)).findFirst().get();
|
|
|
|
+ //查找project的inchargerId
|
|
|
|
+ Project project = projects.stream().filter(p -> p.getId().equals(report.getProjectId())).findFirst().get();
|
|
|
|
+ String inChargerId = project.getInchargerId();
|
|
|
|
+ reportLog.setOperatorId(inChargerId);
|
|
|
|
+ ReportLogDetail item = new ReportLogDetail();
|
|
|
|
+ item.setId(reportLog.getId());
|
|
|
|
+ item.setOperatorId(inChargerId);
|
|
|
|
+ //woy9TkCAAAapCHjv-2GgW0l7xw4pKDtQ审核通过了日报
|
|
|
|
+ allUsers.stream().filter(u -> u.getId().equals(inChargerId)).findFirst().ifPresent(u -> item.setMsg(u.getName()+"审核通过了日报"));
|
|
|
|
+ System.out.println("更新》》" + reportLog.getId()+", inchargerId="+inChargerId+", msg="+item.getMsg());
|
|
|
|
+ updateReportLogs.add(item);
|
|
|
|
+ }
|
|
|
|
+ if (updateReportLogs.size() > 0) {
|
|
|
|
+ //更新
|
|
|
|
+ System.out.println("更新了" + updateReportLogs.size() + "条数据");
|
|
|
|
+ reportLogDetailService.updateBatchById(updateReportLogs);
|
|
|
|
+ }
|
|
|
|
+ msg.setMsg("更新完成");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ msg.setError(MessageUtils.message("other.error"));
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @RequestMapping("/changeReportLogDetail")
|
|
|
|
+ public HttpRespMsg changeReportLogDetail(HttpServletRequest request){
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ String auditorId = "8523550798754947072";
|
|
|
|
+ Integer companyId = 7544;
|
|
|
|
+ List<ReportLogDetail> reportLogDetails = reportLogDetailMapper.getErrorData();
|
|
|
|
+ if (reportLogDetails.size() == 0) {
|
|
|
|
+ msg.data = "无数据需要更新";
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ System.out.println("问题数据:" + reportLogDetails.size());
|
|
|
|
+ List<Integer> collect = reportLogDetails.stream().map(ReportLogDetail::getReportId).collect(Collectors.toList());
|
|
|
|
+ List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().select("id, creator_id").in("id", collect));
|
|
|
|
+ List<ReportLogDetail> updateList = new ArrayList<>();
|
|
|
|
+ for (ReportLogDetail item : reportLogDetails) {
|
|
|
|
+ ReportLogDetail updateItem = new ReportLogDetail();
|
|
|
|
+ updateItem.setId(item.getId());
|
|
|
|
+ Optional<Report> first = reportList.stream().filter(r -> r.getId().equals(item.getReportId())).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ updateItem.setOperatorId(first.get().getCreatorId());
|
|
|
|
+ updateList.add(updateItem);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ System.out.println("需更新:"+updateList.size());
|
|
|
|
+ if (updateList.size() > 0) {
|
|
|
|
+ reportLogDetailService.updateBatchById(updateList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|