调试mk
This commit is contained in:
+20
-2
@@ -96,7 +96,7 @@ public class CustomerArchivePublicController {
|
||||
*/
|
||||
@PostMapping("/process-message")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "公开接收流程消息", description = "无需登录,接收后查询当前节点并打印")
|
||||
@Operation(summary = "公开接收流程消息", description = "无需登录,接收后查询当前节点、流程实例详情并同步客商当前节点")
|
||||
public R processMessage(@RequestBody Map<String, Object> body) {
|
||||
log.info("客商公开页收到流程消息:{}", JSON.toJSONString(body));
|
||||
Map<String, Object> formValues = asMap(body == null ? null : body.get("formValues"));
|
||||
@@ -111,11 +111,29 @@ public class CustomerArchivePublicController {
|
||||
}
|
||||
try {
|
||||
FR<Object> result = businessProcessClient.getCurrentNodes(processId, loginName);
|
||||
Object nodeData = result == null ? null : result.getData();
|
||||
log.info("客商公开页流程消息当前节点详情 processId={} loginName={} result={}",
|
||||
processId, loginName, JSON.toJSONString(result == null ? null : result.getData()));
|
||||
processId, loginName, JSON.toJSONString(nodeData));
|
||||
String customerIdText = firstText(asMap(body == null ? null : body.get("formData")), "id");
|
||||
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);
|
||||
}
|
||||
try {
|
||||
FR<Object> processInfoResult = businessProcessClient.getProcessInfo(processId, loginName);
|
||||
log.info("客商公开页流程消息流程实例详情 processId={} loginName={} result={}",
|
||||
processId, loginName, JSON.toJSONString(processInfoResult == null ? null : processInfoResult.getData()));
|
||||
} catch (Exception e) {
|
||||
log.error("客商公开页查询流程实例详情失败 processId={} loginName={}", processId, loginName, e);
|
||||
}
|
||||
return R.success("ok");
|
||||
}
|
||||
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package org.springblade.transport.feign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.secure.constant.AuthConstant;
|
||||
import org.springblade.core.tenant.annotation.TenantIgnore;
|
||||
import org.springblade.core.tool.api.FR;
|
||||
import org.springblade.transport.pojo.dto.CustomerProcessNodeSyncDTO;
|
||||
import org.springblade.transport.service.ICustomerArchiveService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 客商档案 Feign实现
|
||||
*/
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class CustomerArchiveClient implements ICustomerArchiveClient {
|
||||
|
||||
private final ICustomerArchiveService customerArchiveService;
|
||||
|
||||
@TenantIgnore
|
||||
@PreAuth(AuthConstant.PERMIT_ALL)
|
||||
@PostMapping(SYNC_PROCESS_NODE)
|
||||
@Override
|
||||
public FR<Boolean> syncProcessNode(@RequestBody CustomerProcessNodeSyncDTO param) {
|
||||
if (param == null) {
|
||||
return FR.data(false);
|
||||
}
|
||||
return FR.data(customerArchiveService.syncProcessNode(
|
||||
param.getId(), param.getCurrentNode(), param.getCurrentProcessor(), param.getApprovalStatus()));
|
||||
}
|
||||
}
|
||||
+20
@@ -100,6 +100,26 @@ public interface ICustomerArchiveService extends BaseService<CustomerArchive> {
|
||||
*/
|
||||
boolean submitApproval(Long id);
|
||||
|
||||
/**
|
||||
* 按 MK 当前节点同步客商当前节点、当前处理人和审批状态
|
||||
*
|
||||
* @param id 客商ID
|
||||
* @param currentNode 当前节点
|
||||
* @param currentProcessor 当前处理人
|
||||
* @param approvalStatus 审批状态,可为空,为空时保持为审核中
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean syncProcessNode(Long id, String currentNode, String currentProcessor, String approvalStatus);
|
||||
|
||||
/**
|
||||
* 按 MK getCurrentNodes 返回结果同步客商当前节点
|
||||
*
|
||||
* @param id 客商ID
|
||||
* @param currentNodes MK 当前节点详情
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean syncProcessNodeFromMk(Long id, Object currentNodes);
|
||||
|
||||
/**
|
||||
* 撤回审批并恢复草稿状态
|
||||
*
|
||||
|
||||
+111
-2
@@ -29,6 +29,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
@@ -85,6 +86,7 @@ import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -101,6 +103,7 @@ import java.util.stream.Collectors;
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveMapper, CustomerArchive> implements ICustomerArchiveService {
|
||||
@@ -214,12 +217,73 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
CustomerArchive before = Objects.requireNonNull(BeanUtil.copyProperties(detail, CustomerArchive.class));
|
||||
CustomerArchive after = copyCustomer(before);
|
||||
after.setApprovalStatus(APPROVAL_REVIEWING);
|
||||
after.setCurrentNode("客商准入审批");
|
||||
after.setCurrentProcessor("待处理");
|
||||
if (Func.isEmpty(after.getCurrentNode()) || Objects.equals(after.getCurrentNode(), "草稿")) {
|
||||
after.setCurrentNode("客商准入审批");
|
||||
after.setCurrentProcessor("待处理");
|
||||
}
|
||||
addChangeRecord(id, "提交客商准入审批", before, after);
|
||||
return updateById(after);
|
||||
}
|
||||
|
||||
@Override
|
||||
@TenantIgnore
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean syncProcessNode(Long id, String currentNode, String currentProcessor, String approvalStatus) {
|
||||
if (Func.isEmpty(id)) {
|
||||
log.warn("同步客商当前节点失败,客商ID为空");
|
||||
return false;
|
||||
}
|
||||
CustomerArchive customer = getById(id);
|
||||
if (customer == null || Objects.equals(customer.getIsDeleted(), 1)) {
|
||||
log.warn("同步客商当前节点失败,客商不存在 id={}", id);
|
||||
return false;
|
||||
}
|
||||
String nextStatus = Func.isEmpty(approvalStatus) ? APPROVAL_REVIEWING : approvalStatus;
|
||||
boolean updated = this.lambdaUpdate()
|
||||
.eq(CustomerArchive::getId, id)
|
||||
.set(Func.isNotEmpty(currentNode), CustomerArchive::getCurrentNode, currentNode)
|
||||
.set(Func.isNotEmpty(currentProcessor), CustomerArchive::getCurrentProcessor, currentProcessor)
|
||||
.set(Func.isNotEmpty(nextStatus), CustomerArchive::getApprovalStatus, nextStatus)
|
||||
.update();
|
||||
log.info("同步客商当前节点 id={} currentNode={} currentProcessor={} approvalStatus={} result={}",
|
||||
id, currentNode, currentProcessor, nextStatus, updated);
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
@TenantIgnore
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean syncProcessNodeFromMk(Long id, Object currentNodes) {
|
||||
if (Func.isEmpty(id) || currentNodes == null) {
|
||||
return false;
|
||||
}
|
||||
List<Map<String, Object>> nodes = normalizeMkNodeList(currentNodes);
|
||||
if (nodes.isEmpty()) {
|
||||
log.warn("同步客商当前节点跳过,节点详情为空 id={}", id);
|
||||
return false;
|
||||
}
|
||||
List<String> nodeNames = new ArrayList<>();
|
||||
List<String> handlerNames = new ArrayList<>();
|
||||
for (Map<String, Object> node : nodes) {
|
||||
String nodeName = Func.toStr(node.get("nodeName"), "").trim();
|
||||
if (Func.isNotEmpty(nodeName)) {
|
||||
nodeNames.add(nodeName);
|
||||
}
|
||||
Object handlers = node.get("nodeHandlers");
|
||||
if (!(handlers instanceof Collection<?> handlerList)) {
|
||||
continue;
|
||||
}
|
||||
for (Object handler : handlerList) {
|
||||
Map<String, Object> handlerMap = asStringObjectMap(handler);
|
||||
String handlerName = Func.toStr(handlerMap.get("handlerName"), "").trim();
|
||||
if (Func.isNotEmpty(handlerName)) {
|
||||
handlerNames.add(handlerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return syncProcessNode(id, joinDistinct(nodeNames), joinDistinct(handlerNames), APPROVAL_REVIEWING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean withdrawApproval(Long id) {
|
||||
@@ -1032,6 +1096,51 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
return Objects.requireNonNull(BeanUtil.copyProperties(customer, CustomerArchive.class));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Map<String, Object>> normalizeMkNodeList(Object currentNodes) {
|
||||
Object source = currentNodes;
|
||||
if (source instanceof String text && Func.isNotEmpty(text.trim())) {
|
||||
source = JsonUtil.parse(text, List.class);
|
||||
}
|
||||
if (source instanceof Collection<?> collection) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (Object item : collection) {
|
||||
Map<String, Object> map = asStringObjectMap(item);
|
||||
if (!map.isEmpty()) {
|
||||
result.add(map);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Map<String, Object> single = asStringObjectMap(source);
|
||||
return single.isEmpty() ? List.of() : List.of(single);
|
||||
}
|
||||
|
||||
private Map<String, Object> asStringObjectMap(Object value) {
|
||||
if (value instanceof Map<?, ?> map) {
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
map.forEach((key, nested) -> {
|
||||
if (key != null) {
|
||||
result.put(String.valueOf(key), nested);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
if (value == null) {
|
||||
return Map.of();
|
||||
}
|
||||
try {
|
||||
Map<String, Object> parsed = JsonUtil.toMap(JsonUtil.toJson(value));
|
||||
return parsed == null ? Map.of() : parsed;
|
||||
} catch (Exception ignored) {
|
||||
return Map.of();
|
||||
}
|
||||
}
|
||||
|
||||
private String joinDistinct(List<String> values) {
|
||||
return values.stream().filter(Func::isNotEmpty).distinct().collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
private void addChangeRecord(Long customerId, String content, CustomerArchive before, CustomerArchive after) {
|
||||
Map<String, Object> beforeSnapshot = customerSnapshot(before);
|
||||
Map<String, Object> afterSnapshot = customerSnapshot(after);
|
||||
|
||||
Reference in New Issue
Block a user