|
|
|
@ -1306,8 +1306,11 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
// 通过函数获取流程标题 2024-12-25 |
|
|
|
String requestName = changeManagementMapper.getRequestNameByFunction(paramData.getSite(), paramData.getClassificationNo(), paramData.getWorkflowId(), paramData.getWorkflowName(), paramData.getNodeId(), paramData.getNodeName(), paramData.getDocNo(), "", paramData.getUserName(), DateUtils.getStringNow(), "", paramData.getMenuName(), "下达"); |
|
|
|
|
|
|
|
List<String> createdTodoOaUsers = new ArrayList<>(); |
|
|
|
try { |
|
|
|
// 统一待办接口 |
|
|
|
for (String key : dcas.keySet()) { |
|
|
|
String oaUserId = dcas.get(key).split("#")[1]; |
|
|
|
// 创建单点登录地址 |
|
|
|
String url = loginTokenUrl + "?dca=" + key + "&token=" + dcas.get(key).split("#")[0] + "&site=" + paramData.getSite() + "&path=" + paramData.getPath() + "&docNo=" + paramData.getDocNo(); |
|
|
|
ReceiveRequestInfoParam receiveRequestInfoParam = new ReceiveRequestInfoParam( |
|
|
|
@ -1322,20 +1325,22 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
"0", |
|
|
|
paramData.getUserId(), |
|
|
|
DateUtils.getStringNow(), |
|
|
|
dcas.get(key).split("#")[1], |
|
|
|
oaUserId, |
|
|
|
DateUtils.getStringNow(), |
|
|
|
String.valueOf(new Date().getTime())); |
|
|
|
String receiveRequestInfoURL = apiUrlOa + "/oa/interface/receiveRequestInfoByJson"; |
|
|
|
ResponseData receiveRequestInfoResponse = HttpClientUtil.doPostByRawWithOA(receiveRequestInfoURL, receiveRequestInfoParam); |
|
|
|
if (!"0".equals(receiveRequestInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("统一待办异常信息:" + receiveRequestInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
invokeReceiveRequestInfo(receiveRequestInfoParam); |
|
|
|
createdTodoOaUsers.add(oaUserId); |
|
|
|
} |
|
|
|
|
|
|
|
// 将第一个节点记录修改为同意 |
|
|
|
paramData.setStepId(10); |
|
|
|
paramData.setBu(paramData.getBu() == null ? "" : paramData.getBu()); |
|
|
|
changeManagementMapper.updateProcessFormToAgree(paramData); |
|
|
|
} catch (Exception e) { |
|
|
|
cleanupReceiveRequestInfoOnException(paramData, type, paramData.getWorkflowId(), paramData.getRequestId(), |
|
|
|
createdTodoOaUsers, "issueFunction", "after-receive-exception"); |
|
|
|
throw e; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -1728,6 +1733,8 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
} |
|
|
|
} |
|
|
|
} else { // 未结束 |
|
|
|
List<String> createdTodoOaUsers = new ArrayList<>(); |
|
|
|
try { |
|
|
|
// 调用获取最新节点ID的接口 |
|
|
|
String getWorkflowRequestURL = apiUrlOa + "/oa/interface/getWorkflowRequest"; |
|
|
|
ResponseData getWorkflowRequestResponses = HttpClientUtil.doPostByRawWithOA(getWorkflowRequestURL, requestOperatorInfoParam); |
|
|
|
@ -1775,11 +1782,8 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
paramData.getUserId(), |
|
|
|
DateUtils.getStringNow(), |
|
|
|
String.valueOf(new Date().getTime())); |
|
|
|
String receiveRequestInfoURL = apiUrlOa + "/oa/interface/receiveRequestInfoByJson"; |
|
|
|
ResponseData receiveRequestInfoResponse = HttpClientUtil.doPostByRawWithOA(receiveRequestInfoURL, receiveRequestInfoParam); |
|
|
|
if (!"0".equals(receiveRequestInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("统一待办异常信息:" + receiveRequestInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
invokeReceiveRequestInfo(receiveRequestInfoParam); |
|
|
|
createdTodoOaUsers.add(paramData.getUserId()); |
|
|
|
// 如果没有isRemark = 0的则return |
|
|
|
if (isRemarks.isEmpty()) { |
|
|
|
return; |
|
|
|
@ -1947,6 +1951,7 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
|
|
|
|
// 9、统一待办接口 |
|
|
|
for (String key : dcas.keySet()) { |
|
|
|
String oaUserId = dcas.get(key).split("#")[1]; |
|
|
|
// 创建单点登录地址 |
|
|
|
String url = loginTokenUrl + "?dca=" + key + "&token=" + dcas.get(key).split("#")[0] + "&site=" + paramData.getSite() + "&path=" + paramData.getPath() + "&docNo=" + paramData.getDocNo(); |
|
|
|
ReceiveRequestInfoParam receiveRequestInfoParam = new ReceiveRequestInfoParam( |
|
|
|
@ -1961,14 +1966,16 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
"0", |
|
|
|
paramData.getUserId(), |
|
|
|
DateUtils.getStringNow(), |
|
|
|
dcas.get(key).split("#")[1], |
|
|
|
oaUserId, |
|
|
|
DateUtils.getStringNow(), |
|
|
|
String.valueOf(new Date().getTime())); |
|
|
|
String receiveRequestInfoURL = apiUrlOa + "/oa/interface/receiveRequestInfoByJson"; |
|
|
|
ResponseData receiveRequestInfoResponse = HttpClientUtil.doPostByRawWithOA(receiveRequestInfoURL, receiveRequestInfoParam); |
|
|
|
if (!"0".equals(receiveRequestInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("统一待办异常信息:" + receiveRequestInfoResponse.getMsg()); |
|
|
|
invokeReceiveRequestInfo(receiveRequestInfoParam); |
|
|
|
createdTodoOaUsers.add(oaUserId); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
cleanupReceiveRequestInfoOnException(paramData, type, paramData.getWorkflowId(), paramData.getRequestId(), |
|
|
|
createdTodoOaUsers, "agreeFunction", "after-receive-exception"); |
|
|
|
throw asRuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -2033,6 +2040,8 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
changeManagementMapper.updateProcessForm3(paramData); |
|
|
|
} |
|
|
|
|
|
|
|
List<String> createdTodoOaUsers = new ArrayList<>(); |
|
|
|
try { |
|
|
|
if (isRemarks.isEmpty()) { // 已结束 |
|
|
|
// 反刷单据状态为 "已完成" |
|
|
|
paramData.setStatus("已完成"); |
|
|
|
@ -2119,6 +2128,7 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
|
|
|
|
// 9、统一待办接口 |
|
|
|
for (String key : dcas.keySet()) { |
|
|
|
String oaUserId = dcas.get(key).split("#")[1]; |
|
|
|
// 创建单点登录地址 |
|
|
|
String url = loginTokenUrl + "?dca=" + key + "&token=" + dcas.get(key).split("#")[0] + "&site=" + paramData.getSite() + "&path=" + paramData.getPath() + "&docNo=" + paramData.getDocNo(); |
|
|
|
ReceiveRequestInfoParam receiveRequestInfoParam = new ReceiveRequestInfoParam( |
|
|
|
@ -2133,14 +2143,11 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
"0", |
|
|
|
paramData.getUserId(), |
|
|
|
DateUtils.getStringNow(), |
|
|
|
dcas.get(key).split("#")[1], |
|
|
|
oaUserId, |
|
|
|
DateUtils.getStringNow(), |
|
|
|
String.valueOf(new Date().getTime())); |
|
|
|
String receiveRequestInfoURL = apiUrlOa + "/oa/interface/receiveRequestInfoByJson"; |
|
|
|
ResponseData receiveRequestInfoResponse = HttpClientUtil.doPostByRawWithOA(receiveRequestInfoURL, receiveRequestInfoParam); |
|
|
|
if (!"0".equals(receiveRequestInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("统一待办异常信息:" + receiveRequestInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
invokeReceiveRequestInfo(receiveRequestInfoParam); |
|
|
|
createdTodoOaUsers.add(oaUserId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -2149,6 +2156,11 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
changeManagementMapper.updateChangeItemForReject(paramData.getSite(), paramData.getDocNo()); |
|
|
|
changeManagementMapper.updateChangeCountersignatureItemForReject(paramData.getSite(), paramData.getDocNo()); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
cleanupReceiveRequestInfoOnException(paramData, type, paramData.getWorkflowId(), paramData.getRequestId(), |
|
|
|
createdTodoOaUsers, "rejectFunction", "after-receive-exception"); |
|
|
|
throw asRuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2648,6 +2660,55 @@ public class ChangeManagementServiceImpl extends ServiceImpl<ChangeManagementMap |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void invokeReceiveRequestInfo(ReceiveRequestInfoParam receiveRequestInfoParam) { |
|
|
|
String receiveRequestInfoURL = apiUrlOa + "/oa/interface/receiveRequestInfoByJson"; |
|
|
|
ResponseData receiveRequestInfoResponse = HttpClientUtil.doPostByRawWithOA(receiveRequestInfoURL, receiveRequestInfoParam); |
|
|
|
if (!"0".equals(receiveRequestInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("统一待办异常信息:" + receiveRequestInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* receiveRequestInfoByJson 调用成功后,如果后续逻辑异常,补偿删除统一待办,避免脏数据。 |
|
|
|
*/ |
|
|
|
private void cleanupReceiveRequestInfoOnException(ParamData paramData, String documentType, String workflowId, String requestId, |
|
|
|
Collection<String> createdTodoOaUsers, String callMethod, String callScene) { |
|
|
|
if (createdTodoOaUsers == null || createdTodoOaUsers.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Set<String> userIds = createdTodoOaUsers.stream() |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
.collect(Collectors.toCollection(LinkedHashSet::new)); |
|
|
|
if (userIds.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
logger.warn("{}流程异常,触发统一待办补偿删除, site={}, documentNo={}, flowId={}, userCount={}", |
|
|
|
callMethod, paramData.getSite(), paramData.getDocNo(), |
|
|
|
StringUtils.defaultString(workflowId) + StringUtils.defaultString(requestId), userIds.size()); |
|
|
|
for (String oaUserId : userIds) { |
|
|
|
deleteUserRequestInfoWithLog( |
|
|
|
paramData.getSite(), |
|
|
|
paramData.getDocNo(), |
|
|
|
documentType, |
|
|
|
workflowId, |
|
|
|
requestId, |
|
|
|
oaUserId, |
|
|
|
callMethod, |
|
|
|
callScene, |
|
|
|
paramData.getUserName() |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private RuntimeException asRuntimeException(Exception e) { |
|
|
|
if (e instanceof RuntimeException) { |
|
|
|
return (RuntimeException) e; |
|
|
|
} |
|
|
|
return new RuntimeException(e); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除OA待办并记录接口调用日志(无论成功失败都不影响主流程) |
|
|
|
*/ |
|
|
|
|