diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java index a54112c..8c41ef6 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java @@ -24,8 +24,8 @@ public class MailController { @NotPower @GetMapping("{id}") - public AjaxResult get(@PathVariable String id, @RequestParam Integer workId) { - return AjaxResult.success(mailService.getMailFlowDetail(id, workId)); + public AjaxResult get(@PathVariable String id) { + return AjaxResult.success(mailService.getMailFlowDetailByWork(id)); } @SaCheckPermission("mail:add") diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java index 53d0c1a..022b50a 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java @@ -8,6 +8,7 @@ import com.biutag.lan.domain.Mail; import com.biutag.lan.domain.Work; import com.biutag.lan.domain.bo.MailQuery; import com.biutag.lan.domain.vo.MailExcel; +import com.biutag.lan.domain.vo.MailFlowDetail; import com.biutag.lan.domain.vo.QueryMailVo; import com.biutag.lan.domain.vo.WorkVo; import com.biutag.lan.service.MailService; @@ -64,4 +65,11 @@ public class WorkController { public AjaxResult> dissatisfied(Page page, MailQuery todoQuery) { return AjaxResult.success(workService.dissatisfied(page, todoQuery)); } + + @NotPower + @GetMapping("mail/detail") + public AjaxResult get(@RequestParam String mailId, @RequestParam Integer workId) { + return AjaxResult.success(mailService.getMailFlowDetailByWork(mailId, workId)); + } + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/MailSource.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/MailSource.java index d2feafa..caf1526 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/MailSource.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/MailSource.java @@ -81,7 +81,8 @@ public class MailSource { Mail mail = new Mail(); BeanUtils.copyProperties(this, mail); mail.setCreateTime(LocalDateTime.now()) - .setUpdateTime(mail.getCreateTime()); + .setUpdateTime(mail.getCreateTime()) + .setFlowLimitedLastHandlerTime(createTime); return mail; } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java index fab7829..19d2524 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java @@ -71,29 +71,19 @@ public class MailService extends ServiceImpl { @Autowired private FlowConfig flowConfig; - public MailFlowDetail getMailFlowDetail(String mailId, Integer workId) { + public MailFlowDetail getMailFlowDetailByWork(String mailId) { MailSource mailSource = mailSourceService.getById(mailId); - Flow flow = null; + Flow flow; Mail mail; MailFlowDetail flowDetail = new MailFlowDetail(); - Work work = workService.getById(workId); if (!mailSource.getSignFlag()) { flow = SpringUtil.getBean(FirstSignFlow.class); mail = mailSource.toMail(); - // 将流程开始时间设置为 - mail.setFlowLimitedLastHandlerTime(mailSource.getCreateTime()); } else { mail = getById(mailId); - if (!FlowNodeEnum.COMPLETION.getKey().equals(mail.getFlowKey())) { - flow = flowNodes.stream() - .filter(item -> mail.getFlowKey().equals(item.getFlowNode().getKey())) - .findFirst().orElseThrow(() -> new BusinessException("没有该流程节点")); - } - if (!work.getMainDeptFlag()) { - flow = flowNodes.stream() - .filter(item -> work.getFlowKey().equals(item.getFlowNode().getKey())) - .findFirst().orElseThrow(() -> new BusinessException("没有该流程节点")); - } + flow = flowNodes.stream() + .filter(item -> mail.getFlowKey().equals(item.getFlowNode().getKey())) + .findFirst().orElse(null); } MailVo mailVo = MailVo.of(mail); @@ -136,7 +126,7 @@ public class MailService extends ServiceImpl { flowDetail.setApprovals(approvalVos); } } - if (!FlowNodeEnum.COMPLETION.getKey().equals(mail.getFlowKey())) { + if (Objects.nonNull(flow)) { FlowNode flowNode = flow.getFlowNode(); int limitedTime = flowNode.getLimitedTime().intValue(); if (Objects.nonNull(mail.getExtensionFlag()) && mail.getExtensionFlag()) { @@ -151,8 +141,7 @@ public class MailService extends ServiceImpl { .setFlowRemainingTime(flowRemainingTime) .setFlowLimitedTime(limitedTime); flowDetail.setFlowNode(flowNode).setActions(flow.getActions()); - // 如果是会签中 - } else { + } else { // 如果是会签中 flowDetail.setFlowNode(flowNodeService.getById(mail.getFlowKey())); } List flowNodes = Arrays.asList(FlowNodeEnum.SECOND_APPROVAL.getKey()); @@ -169,10 +158,20 @@ public class MailService extends ServiceImpl { long mainDeptSignTime = flows.stream().filter(item -> item.getFlowKey().contains("_sign") || item.getFlowKey().contains("_distribute")).mapToLong(MailFlow::getConsumingTime).sum(); mailVo.setMainDeptSignTime(mainDeptSignTime); } + return flowDetail; + } + + public MailFlowDetail getMailFlowDetailByWork(String mailId, Integer workId) { + MailFlowDetail mailDetail = getMailFlowDetailByWork(mailId); + Work work = workService.getById(workId); if (!work.getMainDeptFlag()) { - mailVo.setSecondaryResponsibleFlag(true); + Flow flow = flowNodes.stream() + .filter(item -> work.getFlowKey().equals(item.getFlowNode().getKey())) + .findFirst().orElseThrow(() -> new BusinessException("没有该流程节点")); + mailDetail.setFlowNode(flow.getFlowNode()); + mailDetail.getMail().setSecondaryResponsibleFlag(true); } - return flowDetail; + return mailDetail; } @Transactional(rollbackFor = Exception.class)