|
@@ -9922,15 +9922,93 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg batchDenyHisReport(Integer reportAuditLogId, String reason, HttpServletRequest request) {
|
|
|
- List<ReportAlogMembdate> list = reportAlogMembdateMapper.selectList(new QueryWrapper<ReportAlogMembdate>().eq("rlog_id", reportAuditLogId));
|
|
|
- for (ReportAlogMembdate logMembItem : list) {
|
|
|
- HttpRespMsg msg = denyHisReport(logMembItem.getId(), reason, request);
|
|
|
- if (msg.code.equals("error")) {
|
|
|
- //异常需要跳出
|
|
|
- return msg;
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpRespMsg batchDenyHisReport(Integer reportAuditLogId, String reason, HttpServletRequest request) throws Exception {
|
|
|
+ List<ReportAlogMembdate> dataList = reportAlogMembdateMapper.selectList(new QueryWrapper<ReportAlogMembdate>().eq("rlog_id", reportAuditLogId));
|
|
|
+ for (ReportAlogMembdate item : dataList) {
|
|
|
+ int hisId = item.getId();
|
|
|
+ ReportAlogMembdate log = reportAlogMembdateMapper.selectById(hisId);
|
|
|
+ String userId = log.getUserId();
|
|
|
+ String createDate = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(log.getCreateDate());
|
|
|
+ if (log.getState() != 1) {
|
|
|
+ //已通过的直接跳过
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Company company = companyMapper.selectById(user.getCompanyId());
|
|
|
+ if (reason == null) {
|
|
|
+ reason = "-";
|
|
|
+ }
|
|
|
+ QueryWrapper<Report> eq = new QueryWrapper<Report>().eq("create_date", createDate).eq("creator_id", userId);
|
|
|
+ List<Report> list = reportMapper.selectList(eq);
|
|
|
+ Report oneReport = null;
|
|
|
+ if (list.size() == 0) {
|
|
|
+ //httpRespMsg.setError("日报已不存在");
|
|
|
+ throw new Exception(MessageUtils.message("profession.alreadyNull"));
|
|
|
+ } else {
|
|
|
+ if (list.get(0).getState() == 3) {
|
|
|
+ //只有已通过的历史记录才能撤销
|
|
|
+ continue;
|
|
|
+ } else if (list.get(0).getState() == 2) {
|
|
|
+ //只有已通过的历史记录才能撤销
|
|
|
+ //httpRespMsg.setError("该日报已被撤销,无法重复操作");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ oneReport = list.get(0);
|
|
|
+ //直接进行项目经理审核驳回
|
|
|
+ reportMapper.update(new Report().setState(2)
|
|
|
+ .setRejectReason(reason).setRejectUserid(user.getId()).setRejectUsername(user.getName()),eq);
|
|
|
+
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(company.getId());
|
|
|
+ if (timeType.getReportAuditType() == 2 || timeType.getReportAuditType() == 9) {
|
|
|
+ List<Report> rList = list;
|
|
|
+ //退回任务分组审核状态
|
|
|
+ List<Report> newList = new ArrayList<>();
|
|
|
+ for (Report r : rList) {
|
|
|
+ Report upR = new Report();
|
|
|
+ upR.setId(r.getId());
|
|
|
+ upR.setGroupAuditState(0);
|
|
|
+ String inchargerId = taskGroupMapper.selectById(r.getGroupId()).getInchargerId();
|
|
|
+ upR.setProjectAuditorId(inchargerId);
|
|
|
+ upR.setProjectAuditorName(userMapper.selectById(inchargerId).getName());
|
|
|
+ newList.add(upR);
|
|
|
+ }
|
|
|
+ updateBatchById(newList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改审核记录的状态
|
|
|
+ log.setState(3);
|
|
|
+ reportAlogMembdateMapper.updateById(log);
|
|
|
+
|
|
|
+ saveDenyReportLog(list, user.getId(), user.getName(), reason);
|
|
|
+
|
|
|
+ List<Integer> collect = list.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect));
|
|
|
+ String pNames = projectList.stream().map(Project::getProjectName).collect(Collectors.joining(", ", "[", "]"));
|
|
|
+ //String str = "您"+createDate+"填写的日报中"+pNames+"项目被["+user.getName()+"]驳回。原因:" + reason;;
|
|
|
+ String str = MessageUtils.message("report.dailyReject",createDate,pNames,user.getName(),reason);
|
|
|
+ String fillUserId = oneReport.getCreatorId();
|
|
|
+
|
|
|
+ informationMapper.insert(new Information().setType(0).setContent(createDate).setUserId(fillUserId).setMsg(str));
|
|
|
+
|
|
|
+ //发送企业微信通知消息
|
|
|
+ User reporter = userMapper.selectById(fillUserId);
|
|
|
+ String corpwxUserid = reporter.getCorpwxUserid();
|
|
|
+ //先判断钉钉
|
|
|
+ if (reporter.getDingdingUserid() != null) {
|
|
|
+ projectMapper.selectById(oneReport.getProjectId()).getProjectName();
|
|
|
+ companyDingdingService.sendRejectReportMsg(reporter.getCompanyId(), createDate, pNames, reason, user.getName(), reporter.getDingdingUserid());
|
|
|
+ }
|
|
|
+ if (corpwxUserid != null) {
|
|
|
+ WxCorpInfo info = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", company.getId()));
|
|
|
+ wxCorpInfoService.sendWXCorpMsg(info, corpwxUserid, str, null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_REPORT_DENY);
|
|
|
+ } else if (reporter.getWxOpenid() != null){
|
|
|
+ //发送个人微信通知
|
|
|
+ pushReject(str, reporter, user.getName(), reason);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return new HttpRespMsg();
|
|
|
}
|
|
|
}
|