diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java index d0c01e1..b9b4a94 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java @@ -1,29 +1,27 @@ package com.biutag.lan.flow.node; +import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.biutag.constants.AppConstants; import com.biutag.enums.RoleEnum; import com.biutag.exception.BusinessException; import com.biutag.lan.config.AdminThreadLocal; -import com.biutag.lan.domain.Mail; -import com.biutag.lan.domain.MailMark; -import com.biutag.lan.domain.MailReturn; -import com.biutag.lan.domain.Work; +import com.biutag.lan.domain.*; +import com.biutag.lan.enums.MailCategory; import com.biutag.lan.enums.MailState; import com.biutag.lan.flow.ActionEnum; import com.biutag.lan.flow.Flow; import com.biutag.lan.flow.FlowNameEnum; import com.biutag.lan.flow.FlowNodeEnum; -import com.biutag.lan.service.MailMarkService; -import com.biutag.lan.service.MailReturnService; -import com.biutag.lan.service.MailService; -import com.biutag.lan.service.WorkService; +import com.biutag.lan.service.*; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.util.Assert; import java.time.LocalDateTime; +import java.util.Objects; import java.util.Optional; +import java.util.stream.Collectors; @RequiredArgsConstructor @Component @@ -72,11 +70,14 @@ public class FirstApprovalFlow extends Flow { .setProblemSolvingStatus(problemSolvingStatus) .setSatisfactionStatus(satisfactionStatus) .setCompletionComment(data.getString("completionComment")) - .setMailLabels(Optional.ofNullable(data.getJSONArray("mailLabels")).map(item -> item.toJSONString()).orElse(null)) .setFlowKey(FlowNodeEnum.COMPLETION.getKey()) .setFlowBeforeName(FlowNodeEnum.COMPLETION.getFullName()) // 信件状态改为已办结 .setMailState(MailState.completion.getValue()); + JSONArray mailLabels = data.getJSONArray("mailLabels"); + if (Objects.nonNull(mailLabels) && !mailLabels.isEmpty()) { + mail.setMailLabels(mailLabels.stream().map(Object::toString).collect(Collectors.joining(","))); + } mailService.updateById(mail); // 认定办结 MailMark mailMark = new MailMark().setMailId(mailId) diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstSignFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstSignFlow.java index 653b9c7..6823481 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstSignFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstSignFlow.java @@ -90,16 +90,20 @@ public class FirstSignFlow extends Flow { } public Flow thankMailFlow(String mailId, JSONObject data) { + String mailFirstCategory = data.getString("mailFirstCategory"); Integer secondDeptId = data.getInteger("secondDeptId"); Integer threeDeptId = data.getInteger("threeDeptId"); Assert.notNull(secondDeptId, "二级办理单位不能为空"); Assert.notNull(threeDeptId, "三级办理单位不能为空"); LocalDateTime now = LocalDateTime.now(); MailSource mailSource = mailSourceService.getById(mailId); - Mail mail = mailSource.toMail().setSecondDeptId(secondDeptId) + Mail mail = mailSource.toMail() + .setMailFirstCategory(mailFirstCategory) + .setMailCategory(mailFirstCategory) + .setSecondDeptId(secondDeptId) .setThreeDeptId(threeDeptId) .setFlowKey(FlowNodeEnum.COMPLETION.getKey()) - .setFlowBeforeName(FlowNodeEnum.COMPLETION.getFullName()) + .setFlowBeforeName("办结处理") .setUpdateTime(now); mailService.save(mail); // 更新为已办 @@ -108,13 +112,16 @@ public class FirstSignFlow extends Flow { } public Flow invalidMailFlow(String mailId, JSONObject data) { + String mailFirstCategory = data.getString("mailFirstCategory"); String invalidationReason = data.getString("invalidationReason"); Assert.hasText(invalidationReason, "判定理由不能为空"); LocalDateTime now = LocalDateTime.now(); MailSource mailSource = mailSourceService.getById(mailId); Mail mail = mailSource.toMail() + .setMailFirstCategory(mailFirstCategory) + .setMailCategory(mailFirstCategory) .setFlowKey(FlowNodeEnum.COMPLETION.getKey()) - .setFlowBeforeName(FlowNodeEnum.COMPLETION.getFullName()) + .setFlowBeforeName("办结处理") .setUpdateTime(now); mailService.save(mail); // 更新为已办 diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondApprovalFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondApprovalFlow.java index 165bb75..1761af7 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondApprovalFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondApprovalFlow.java @@ -73,7 +73,7 @@ public class SecondApprovalFlow extends Flow { // 更新已办 workService.updateDone(mailId, AdminThreadLocal.getEmpNo(), FlowNameEnum.MAIL_RETURN.getDoneName()); // 更新三级机构专班的待办 - workService.updateTodo(mailId, RoleEnum.THREE_DEPT_CLASSES.getRoleId(), mail.getSecondDeptId(), FlowNameEnum.RETURN_RECTIFICATION.getName()); + workService.updateTodo(mailId, RoleEnum.THREE_DEPT_CLASSES.getRoleId(), mail.getThreeDeptId(), FlowNameEnum.RETURN_RECTIFICATION.getName()); // 更新信件 mail.setUpdateTime(now) .setFlowKey(FlowNodeEnum.VERIFY.getKey()) @@ -111,7 +111,7 @@ public class SecondApprovalFlow extends Flow { // 将二级专班角色的信件改为已办 workService.updateDone(mail.getId(), RoleEnum.SECOND_DEPT_CLASSES.getRoleId(), AdminThreadLocal.getDeptId(), FlowNameEnum.PENDING_APPROVAL.getDoneName()); // 将二级副职领导新增信件 - workService.save(mail, leaderEmpNo, now, FlowNameEnum.PENDING_APPROVAL.getName()); + workService.saveOrUpdate(mail, leaderEmpNo, now, FlowNameEnum.PENDING_APPROVAL.getName()); Flow nextNode = next.get(nextActionKey); // 更新信件 mail.setUpdateTime(now) diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondDeputyApprovalFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondDeputyApprovalFlow.java index 8278de9..06c5260 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondDeputyApprovalFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondDeputyApprovalFlow.java @@ -53,7 +53,7 @@ public class SecondDeputyApprovalFlow extends Flow { // 将我的信件改为已办 workService.updateDone(mailId, AdminThreadLocal.getEmpNo(), FlowNameEnum.PENDING_APPROVAL.getDoneName()); // 给二级机构正职领导新增待办 - workService.save(mail, leaderEmpNo, now, FlowNameEnum.PENDING_APPROVAL.getName()); + workService.saveOrUpdate(mail, leaderEmpNo, now, FlowNameEnum.PENDING_APPROVAL.getName()); Flow nextNode = next.get(nextActionKey); // 更新信件 mail.setUpdateTime(now) diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java index b5cf32d..d9d9450 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java @@ -89,17 +89,6 @@ public class WorkService extends ServiceImpl { return saveBatch(list); } - public boolean save(Mail mail, String empNo, LocalDateTime time, String flowName) { - Work work = new Work(); - BeanUtils.copyProperties(mail, work); - work.setMailId(mail.getId()) - .setPoliceEmpNo(empNo) - .setCreateTime(time) - .setUpdateTime(time) - .setFlowName(flowName); - return save(work); - } - public boolean saveOrUpdate(Mail mail, Integer roleId, Integer deptId, LocalDateTime time, Boolean mainDeptFlag, String flowName) { return saveOrUpdate(mail, roleId, deptId, time, mainDeptFlag, flowName, null); } @@ -138,20 +127,23 @@ public class WorkService extends ServiceImpl { Integer roleId = AdminThreadLocal.getRoleId(); Integer signRoleId = RoleEnum.MUNICIPAL_DEPT_CLASSES.getRoleId().equals(roleId) ? RoleEnum.SECOND_DEPT_CLASSES.getRoleId() : RoleEnum.THREE_DEPT_CLASSES.getRoleId(); - List collect = countersignDeptIds.stream().map(id -> { - Work work = new Work(); - BeanUtils.copyProperties(mail, work); - work.setMailId(mail.getId()) - .setSignRoleId(signRoleId) - .setSignDeptId(id) - .setCreateTime(time) - .setUpdateTime(time) + countersignDeptIds.forEach(id -> { + Work work = getOne(mail.getId(), signRoleId, id); + if (Objects.isNull(work)) { + work = new Work(); + BeanUtils.copyProperties(mail, work); + work.setMailId(mail.getId()) + .setSignRoleId(signRoleId) + .setSignDeptId(id) + .setCreateTime(time); + } + work.setUpdateTime(time) // 部门会签 .setWorkType(WorkType.dept_countersign.name()) .setFlowName(FlowNameEnum.PENDING_COUNTERSIGN.getName()); - return work; - }).collect(Collectors.toList()); - return saveBatch(collect); + saveOrUpdate(work); + }); + return true; } public boolean updateDone(String mailId, Integer roleId, Integer deptId, String flowName) { @@ -232,7 +224,11 @@ public class WorkService extends ServiceImpl { workVoPage.getRecords().forEach(item -> { // 会签中 if (FlowNameEnum.COUNTERSIGNING.getName().equals(item.getFlowName())) { - item.setFlowName(String.format("%s(%s/%s)", item.getFlowName(), item.getCountersignCompleted(), item.getCountersignTotal())); + if (item.getCountersignCompleted().equals(item.getCountersignTotal())) { + item.setFlowName(FlowNameEnum.COUNTERSIGNING.getDoneName()); + } else { + item.setFlowName(String.format("%s(%s/%s)", item.getFlowName(), item.getCountersignCompleted(), item.getCountersignTotal())); + } } }); return workVoPage;