Commit 783707bb by 王志超

fix bug: 催办

parent ae196541
Pipeline #88125 passed with stages
in 1 minute 38 seconds
......@@ -2310,39 +2310,36 @@ public class ChangeFlowBiz {
public void urge(Long flowId) {
log.info("[urge] 开始催办,flowId:{}", flowId);
// 1. 通过列表接口查询工单,复用已有的超期判断逻辑
ChangeFlowListQueryReq queryReq = new ChangeFlowListQueryReq();
queryReq.setFlowId(flowId);
ChangeFlowListVO listResult = query(1, 1, queryReq);
// 通过详情接口查询工单
ChangeFlowVO changeFlowVO = detail(flowId);
if (listResult == null || CollectionUtils.isEmpty(listResult.getChangeFlowList())) {
throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, "工单不存在");
}
// 查询主工单信息(用于buildChangeEndTime和后续邮件参数)
ChangeRecord changeRecord = changeFlowService.getByFlowId(flowId);
// 查询该主单下的所有行动工单
List<ChangeSubFlowRecord> allSubFlows = changeSubFlowRecordService.getByChangeRecordIds(
Collections.singletonList(changeFlowVO.getId()));
ChangeFlowVO changeFlowVO = listResult.getChangeFlowList().get(0);
// 构建 subFlowRecordsMap 并计算 isOverdue
Map<Long, List<ChangeSubFlowRecord>> subFlowRecordsMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(allSubFlows)) {
subFlowRecordsMap = allSubFlows.stream()
.collect(Collectors.groupingBy(ChangeSubFlowRecord::getChangeRecordId));
}
buildChangeEndTime(changeRecord, changeFlowVO, subFlowRecordsMap);
// 2. 判断是否超期
// 判断是否超期
if (changeFlowVO.getIsOverdue() == null || !changeFlowVO.getIsOverdue()) {
log.info("[urge] 工单未超期,无需催办,flowId:{}", flowId);
return;
}
// 3. 查询主工单信息
ChangeRecord changeRecord = changeFlowService.getByFlowId(flowId);
if (changeRecord == null) {
throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, "工单不存在");
}
// 4. 查询该主单下的所有行动工单
List<ChangeSubFlowRecord> allSubFlows = changeSubFlowRecordService.getByChangeRecordIds(
Collections.singletonList(changeRecord.getId()));
if (CollectionUtils.isEmpty(allSubFlows)) {
log.info("[urge] 该主单下没有行动工单,flowId:{}", flowId);
return;
}
// 5. 批量查询所有行动工单对应的行动项
// 批量查询所有行动工单对应的行动项
Set<Long> allSubFlowRecordIds = allSubFlows.stream()
.map(ChangeSubFlowRecord::getId)
.collect(Collectors.toSet());
......@@ -2354,7 +2351,7 @@ public class ChangeFlowBiz {
.filter(exec -> exec.getSubFlowRecordId() != null)
.collect(Collectors.groupingBy(ChangeExecRecord::getSubFlowRecordId));
// 6. 过滤出未完结、未取消且超期的行动工单
// 过滤出未完结、未取消且超期的行动工单
Long currentTime = DateUtils.getCurrentTime();
List<ChangeSubFlowRecord> overdueSubFlows = allSubFlows.stream()
.filter(subFlow -> {
......@@ -2392,7 +2389,7 @@ public class ChangeFlowBiz {
return;
}
// 7. 对每个超期的行动工单单独发送催办邮件
// 对每个超期的行动工单单独发送催办邮件
int sentCount = 0;
for (ChangeSubFlowRecord overdueSubFlow : overdueSubFlows) {
String execUserEmail = overdueSubFlow.getChangeExecUserEmail();
......@@ -2410,10 +2407,10 @@ public class ChangeFlowBiz {
// 行动工单ID
param.put("changeId", overdueSubFlow.getSubFlowId());
// 主工单ID(用于跳转)
param.put("mainFlowId", changeRecord.getFlowId());
param.put("changeSubject", ChangeSubjectEnum.getChangeSubjectEnum(changeRecord.getChangeSubject()).getDesc());
param.put("changeContent", changeRecord.getChangeContent());
param.put("changeReason", changeRecord.getChangeReason());
param.put("mainFlowId", changeFlowVO.getFlowId());
param.put("changeSubject", ChangeSubjectEnum.getChangeSubjectEnum(changeFlowVO.getChangeSubject()).getDesc());
param.put("changeContent", changeFlowVO.getChangeContent());
param.put("changeReason", changeFlowVO.getChangeReason());
// 行动工单执行人信息
IusUserInfoRsp execUser = iusService.queryUserInfo(execUserEmail);
......@@ -2422,9 +2419,9 @@ public class ChangeFlowBiz {
param.put("changeExecDepartment", overdueSubFlow.getChangeExecDepartment());
// 获取变更负责人信息
IusUserInfoRsp commanderUser = iusService.queryUserInfo(changeRecord.getChangeCommander());
param.put("changeCommander", commanderUser == null ? changeRecord.getChangeCommander() : commanderUser.getName());
param.put("changeCommanderEmail", changeRecord.getChangeCommander());
IusUserInfoRsp commanderUser = iusService.queryUserInfo(changeFlowVO.getChangeCommander());
param.put("changeCommander", commanderUser == null ? changeFlowVO.getChangeCommander() : commanderUser.getName());
param.put("changeCommanderEmail", changeFlowVO.getChangeCommander());
// 行动项列表
List<Map<String, Object>> execProjectList = new ArrayList<>();
......@@ -2442,7 +2439,7 @@ public class ChangeFlowBiz {
param.put("flowUrl", overdueSubFlow.getSubFlowId());
// 邮件标题:使用行动工单ID
String subjectParam = ChangeSubjectEnum.getChangeSubjectEnum(changeRecord.getChangeSubject()).getDesc()
String subjectParam = ChangeSubjectEnum.getChangeSubjectEnum(changeFlowVO.getChangeSubject()).getDesc()
+ overdueSubFlow.getSubFlowId();
// 收件人:该行动工单的执行人(只发送给行动人,不抄送)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment