调试mk
This commit is contained in:
+3
@@ -27,4 +27,7 @@ public class CustomerProcessNodeSyncDTO implements Serializable {
|
||||
|
||||
@Schema(description = "审批状态")
|
||||
private String approvalStatus;
|
||||
|
||||
@Schema(description = "MK 流程实例详情,传入后按 currentHandlers.fdName 和 handlerInfos.nodeName 回写")
|
||||
private Object processInfo;
|
||||
}
|
||||
|
||||
+9
-26
@@ -168,9 +168,9 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
|
||||
businessProcess.setProcessInstanceId(processInstanceId);
|
||||
businessProcess.setApproveStatus(ApproveStatusEnum.APPROVING.getValue());
|
||||
this.saveOrUpdate(businessProcess);
|
||||
List<?> currentNodes = this.getCurrentNodes(processInstanceId, loginName);
|
||||
this.syncCustomerArchiveCurrentNode(param.getFormInstanceId(), currentNodes);
|
||||
this.getProcessInfo(processInstanceId, loginName);
|
||||
this.getCurrentNodes(processInstanceId, loginName);
|
||||
Object processInfo = this.getProcessInfo(processInstanceId, loginName);
|
||||
this.syncCustomerArchiveFromProcessInfo(param.getFormInstanceId(), processInfo);
|
||||
return processInstanceId;
|
||||
}
|
||||
|
||||
@@ -226,9 +226,9 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
|
||||
}
|
||||
}
|
||||
|
||||
private void syncCustomerArchiveCurrentNode(String formInstanceId, List<?> currentNodes) {
|
||||
if (StringUtils.isBlank(formInstanceId) || CollectionUtil.isEmpty(currentNodes)) {
|
||||
log.warn("同步客商当前节点跳过,formInstanceId或节点详情为空 formInstanceId={}", formInstanceId);
|
||||
private void syncCustomerArchiveFromProcessInfo(String formInstanceId, Object processInfo) {
|
||||
if (StringUtils.isBlank(formInstanceId) || processInfo == null) {
|
||||
log.warn("同步客商当前节点跳过,formInstanceId或流程实例详情为空 formInstanceId={}", formInstanceId);
|
||||
return;
|
||||
}
|
||||
Long customerId;
|
||||
@@ -238,32 +238,15 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
|
||||
log.warn("同步客商当前节点失败,表单实例id不是数字:{}", formInstanceId);
|
||||
return;
|
||||
}
|
||||
String currentNode = currentNodes.stream()
|
||||
.map(this::readMkNodeName)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.distinct()
|
||||
.collect(Collectors.joining(","));
|
||||
String currentProcessor = currentNodes.stream()
|
||||
.flatMap(this::readMkHandlerNames)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.distinct()
|
||||
.collect(Collectors.joining(","));
|
||||
if (StringUtils.isBlank(currentNode) && StringUtils.isBlank(currentProcessor)) {
|
||||
log.warn("同步客商当前节点跳过,未解析到节点名称或处理人 customerId={}", customerId);
|
||||
return;
|
||||
}
|
||||
CustomerProcessNodeSyncDTO param = new CustomerProcessNodeSyncDTO();
|
||||
param.setId(customerId);
|
||||
param.setCurrentNode(currentNode);
|
||||
param.setCurrentProcessor(currentProcessor);
|
||||
param.setProcessInfo(processInfo);
|
||||
param.setApprovalStatus("reviewing");
|
||||
try {
|
||||
FR<Boolean> result = customerArchiveClient.syncProcessNode(param);
|
||||
log.info("同步客商当前节点完成 customerId={} currentNode={} currentProcessor={} result={}",
|
||||
customerId, currentNode, currentProcessor, JSON.toJSONString(result));
|
||||
log.info("同步客商当前节点完成 customerId={} result={}", customerId, JSON.toJSONString(result));
|
||||
} catch (Exception e) {
|
||||
log.error("同步客商当前节点异常 customerId={} currentNode={} currentProcessor={}",
|
||||
customerId, currentNode, currentProcessor, e);
|
||||
log.error("同步客商当前节点异常 customerId={}", customerId, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
-10
@@ -49,6 +49,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -115,15 +116,6 @@ public class CustomerArchivePublicController {
|
||||
Object nodeData = result == null ? null : result.getData();
|
||||
log.info("客商公开页流程消息当前节点详情 processId={} loginName={} result={}",
|
||||
processId, loginName, JSON.toJSONString(nodeData));
|
||||
if (StringUtil.isBlank(customerIdText)) {
|
||||
log.warn("客商公开页流程消息未找到客商id,跳过同步当前节点");
|
||||
} else {
|
||||
try {
|
||||
customerArchiveService.syncProcessNodeFromMk(Long.valueOf(customerIdText), nodeData);
|
||||
} catch (NumberFormatException e) {
|
||||
log.warn("客商公开页流程消息客商id格式不正确:{}", customerIdText);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("客商公开页查询当前节点失败 processId={} loginName={}", processId, loginName, e);
|
||||
}
|
||||
@@ -136,6 +128,12 @@ public class CustomerArchivePublicController {
|
||||
applyProcessResult(customerIdText, processId, formValues, true);
|
||||
} else if (isProcessRejected(processInfo)) {
|
||||
applyProcessResult(customerIdText, processId, formValues, false);
|
||||
} else if (StringUtil.isNotBlank(customerIdText)) {
|
||||
try {
|
||||
customerArchiveService.syncProcessNodeFromProcessInfo(Long.valueOf(customerIdText), processInfo);
|
||||
} catch (NumberFormatException e) {
|
||||
log.warn("客商公开页流程消息客商id格式不正确:{}", customerIdText);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("客商公开页查询流程实例详情失败 processId={} loginName={}", processId, loginName, e);
|
||||
@@ -148,7 +146,18 @@ public class CustomerArchivePublicController {
|
||||
}
|
||||
|
||||
private static boolean isProcessRejected(Object processInfo) {
|
||||
return "20".equals(firstText(asMap(processInfo), "fdProcessStatus"));
|
||||
Map<String, Object> info = asMap(processInfo);
|
||||
if (!"20".equals(firstText(info, "fdProcessStatus"))) {
|
||||
return false;
|
||||
}
|
||||
if (hasItems(info.get("currentHandlers"))) {
|
||||
return false;
|
||||
}
|
||||
return !hasItems(asMap(info.get("fdTaskInfo")).get("handlerInfos"));
|
||||
}
|
||||
|
||||
private static boolean hasItems(Object value) {
|
||||
return value instanceof Collection<?> collection && !collection.isEmpty();
|
||||
}
|
||||
|
||||
private void applyProcessResult(String customerIdText, String processId, Map<String, Object> formValues,
|
||||
|
||||
+3
@@ -30,6 +30,9 @@ public class CustomerArchiveClient implements ICustomerArchiveClient {
|
||||
if (param == null) {
|
||||
return FR.data(false);
|
||||
}
|
||||
if (param.getProcessInfo() != null) {
|
||||
return FR.data(customerArchiveService.syncProcessNodeFromProcessInfo(param.getId(), param.getProcessInfo()));
|
||||
}
|
||||
return FR.data(customerArchiveService.syncProcessNode(
|
||||
param.getId(), param.getCurrentNode(), param.getCurrentProcessor(), param.getApprovalStatus()));
|
||||
}
|
||||
|
||||
+9
@@ -120,6 +120,15 @@ public interface ICustomerArchiveService extends BaseService<CustomerArchive> {
|
||||
*/
|
||||
boolean syncProcessNodeFromMk(Long id, Object currentNodes);
|
||||
|
||||
/**
|
||||
* 按 MK 流程实例详情回写当前节点、当前处理人
|
||||
*
|
||||
* @param id 客商ID
|
||||
* @param processInfo MK getProcessInfo 返回数据
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean syncProcessNodeFromProcessInfo(Long id, Object processInfo);
|
||||
|
||||
/**
|
||||
* MK 流程结束(fdProcessStatus=30)时将客商置为审核通过
|
||||
*
|
||||
|
||||
+45
-1
@@ -284,6 +284,28 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
return syncProcessNode(id, joinDistinct(nodeNames), joinDistinct(handlerNames), APPROVAL_REVIEWING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@TenantIgnore
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean syncProcessNodeFromProcessInfo(Long id, Object processInfo) {
|
||||
if (Func.isEmpty(id) || processInfo == null) {
|
||||
return false;
|
||||
}
|
||||
Map<String, Object> info = asStringObjectMap(processInfo);
|
||||
if (info.isEmpty()) {
|
||||
log.warn("同步客商当前节点跳过,流程实例详情为空 id={}", id);
|
||||
return false;
|
||||
}
|
||||
String currentProcessor = joinDistinct(extractTexts(info.get("currentHandlers"), "fdName", "name"), "、");
|
||||
Map<String, Object> taskInfo = asStringObjectMap(info.get("fdTaskInfo"));
|
||||
String currentNode = joinDistinct(extractTexts(taskInfo.get("handlerInfos"), "nodeName"), "、");
|
||||
if (Func.isEmpty(currentNode) && Func.isEmpty(currentProcessor)) {
|
||||
log.warn("同步客商当前节点跳过,未解析到节点名称或处理人 id={}", id);
|
||||
return false;
|
||||
}
|
||||
return syncProcessNode(id, currentNode, currentProcessor, APPROVAL_REVIEWING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@TenantIgnore
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -1194,7 +1216,29 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
}
|
||||
|
||||
private String joinDistinct(List<String> values) {
|
||||
return values.stream().filter(Func::isNotEmpty).distinct().collect(Collectors.joining(","));
|
||||
return joinDistinct(values, ",");
|
||||
}
|
||||
|
||||
private String joinDistinct(List<String> values, String delimiter) {
|
||||
return values.stream().filter(Func::isNotEmpty).distinct().collect(Collectors.joining(delimiter));
|
||||
}
|
||||
|
||||
private List<String> extractTexts(Object listObj, String... keys) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if (!(listObj instanceof Collection<?> collection) || keys == null) {
|
||||
return result;
|
||||
}
|
||||
for (Object item : collection) {
|
||||
Map<String, Object> map = asStringObjectMap(item);
|
||||
for (String key : keys) {
|
||||
String text = Func.toStr(map.get(key), "").trim();
|
||||
if (Func.isNotEmpty(text)) {
|
||||
result.add(text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addChangeRecord(Long customerId, String content, CustomerArchive before, CustomerArchive after) {
|
||||
|
||||
Reference in New Issue
Block a user