diff --git a/blade-service-api/blade-process-api/src/main/java/org/springblade/process/feign/IBusinessProcessClient.java b/blade-service-api/blade-process-api/src/main/java/org/springblade/process/feign/IBusinessProcessClient.java index 16cc18e..d6e5fa3 100644 --- a/blade-service-api/blade-process-api/src/main/java/org/springblade/process/feign/IBusinessProcessClient.java +++ b/blade-service-api/blade-process-api/src/main/java/org/springblade/process/feign/IBusinessProcessClient.java @@ -38,6 +38,7 @@ public interface IBusinessProcessClient { String QUERY_TODO_LIST = API_PREFIX + "/queryTodoList"; String QUERY_BUSINESS_PROCESS_SNAPSHOT = API_PREFIX + "/queryBusinessProcessSnapshot"; String QUERY_APPROVED_RECORD_LIST = API_PREFIX + "/queryApprovedRecordsNoAttachments"; + String GET_CURRENT_NODES = API_PREFIX + "/getCurrentNodes"; /** * 提交业务流程 @@ -102,4 +103,15 @@ public interface IBusinessProcessClient { */ @GetMapping(QUERY_APPROVED_RECORD_LIST) FR> queryApprovedRecordsNoAttachments(@RequestParam(name = "bizId", required = false) String bizId, @RequestParam(name = "processInstanceId", required = false) String processInstanceId); + + /** + * 获取流程当前节点详情 + * + * @param processInstanceId 流程实例id + * @param loginName MK登录名(手机号) + * @return 当前节点详情 + */ + @GetMapping(GET_CURRENT_NODES) + FR getCurrentNodes(@RequestParam("processInstanceId") String processInstanceId, + @RequestParam(value = "loginName", required = false) String loginName); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/process/feign/BusinessProcessClient.java b/blade-service/blade-system/src/main/java/org/springblade/process/feign/BusinessProcessClient.java index eb789f4..b0f8b8e 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/process/feign/BusinessProcessClient.java +++ b/blade-service/blade-system/src/main/java/org/springblade/process/feign/BusinessProcessClient.java @@ -3,6 +3,8 @@ package org.springblade.process.feign; import io.swagger.v3.oas.annotations.Hidden; import jakarta.validation.Valid; import lombok.AllArgsConstructor; +import org.springblade.core.secure.annotation.PreAuth; +import org.springblade.core.secure.constant.AuthConstant; import org.springblade.core.tool.api.FR; import org.springblade.process.pojo.dto.BusinessProcessCurrentHandlerRefreshDTO; import org.springblade.process.pojo.dto.BusinessProcessDeleteDTO; @@ -13,8 +15,10 @@ import org.springblade.process.pojo.vo.ProcessApprovedRecordVO; import org.springblade.process.pojo.vo.ProcessTodoVO; import org.springblade.process.service.IBusinessProcessService; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -74,4 +78,12 @@ public class BusinessProcessClient implements IBusinessProcessClient { public FR> queryApprovedRecordsNoAttachments(String bizId, String processInstanceId) { return FR.data(businessProcessService.queryApprovedRecordsNoAttachments(bizId, processInstanceId)); } + + @PreAuth(AuthConstant.PERMIT_ALL) + @GetMapping(GET_CURRENT_NODES) + @Override + public FR getCurrentNodes(@RequestParam("processInstanceId") String processInstanceId, + @RequestParam(value = "loginName", required = false) String loginName) { + return FR.data(businessProcessService.getCurrentNodes(processInstanceId, loginName)); + } } diff --git a/blade-service/blade-system/src/main/java/org/springblade/process/service/IBusinessProcessService.java b/blade-service/blade-system/src/main/java/org/springblade/process/service/IBusinessProcessService.java index a577c09..ebdc83b 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/process/service/IBusinessProcessService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/process/service/IBusinessProcessService.java @@ -34,6 +34,15 @@ public interface IBusinessProcessService extends IService { */ String processSubmit(MKProcessCreateDTO param); + /** + * 获取流程当前节点详情 + * + * @param processInstanceId 流程实例id + * @param loginName MK登录名(手机号),可为空,为空时按流程发起人解析 + * @return 当前节点列表 + */ + List getCurrentNodes(String processInstanceId, String loginName); + /** * 修改业务流程状态 * @param param diff --git a/blade-service/blade-system/src/main/java/org/springblade/process/service/impl/BusinessProcessServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/process/service/impl/BusinessProcessServiceImpl.java index 1317fdf..4ad3724 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/process/service/impl/BusinessProcessServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/process/service/impl/BusinessProcessServiceImpl.java @@ -163,9 +163,36 @@ public class BusinessProcessServiceImpl extends ServiceImpl getCurrentNodes(String processInstanceId, String loginName) { + if (StringUtils.isBlank(processInstanceId)) { + log.warn("查询当前节点失败,processInstanceId为空"); + return Collections.emptyList(); + } + String resolvedLoginName = loginName; + if (StringUtils.isBlank(resolvedLoginName)) { + BusinessProcess businessProcess = this.getBusinessProcessByProcessInstanceId(processInstanceId); + resolvedLoginName = resolvePromoterLoginName(businessProcess, null); + } + if (StringUtils.isBlank(resolvedLoginName)) { + log.warn("查询当前节点失败,loginName为空 processInstanceId={}", processInstanceId); + return Collections.emptyList(); + } + try { + List currentNodes = mkService.getCurrentNodes(processInstanceId, resolvedLoginName); + log.info("获取流程当前节点详情 processInstanceId={} loginName={} result={}", + processInstanceId, resolvedLoginName, JSON.toJSONString(currentNodes)); + return currentNodes == null ? Collections.emptyList() : currentNodes; + } catch (Exception e) { + log.error("查询当前节点异常 processInstanceId={} loginName={}", processInstanceId, resolvedLoginName, e); + return Collections.emptyList(); + } + } + /** * 从当前登录用户实体读取真实手机号(绕过接口返回脱敏) */ diff --git a/blade-service/blade-transport/pom.xml b/blade-service/blade-transport/pom.xml index b012436..f2490ca 100644 --- a/blade-service/blade-transport/pom.xml +++ b/blade-service/blade-transport/pom.xml @@ -43,6 +43,10 @@ org.springblade blade-system-api + + org.springblade + blade-process-api + org.springframework.boot spring-boot-starter-amqp diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchivePublicController.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchivePublicController.java index 8db8987..3bbb385 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchivePublicController.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchivePublicController.java @@ -35,7 +35,10 @@ import org.springblade.core.mp.support.Query; 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.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.process.feign.IBusinessProcessClient; import org.springblade.transport.pojo.vo.CustomerArchiveVO; import org.springblade.transport.pojo.vo.CustomerChangeRecordVO; import org.springblade.transport.service.ICustomerArchiveService; @@ -46,6 +49,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; /** @@ -63,6 +68,7 @@ import java.util.Map; public class CustomerArchivePublicController { private final ICustomerArchiveService customerArchiveService; + private final IBusinessProcessClient businessProcessClient; /** * 公开详情 @@ -90,10 +96,57 @@ public class CustomerArchivePublicController { */ @PostMapping("/process-message") @ApiOperationSupport(order = 3) - @Operation(summary = "公开接收流程消息", description = "无需登录,当前仅打印接收数据") + @Operation(summary = "公开接收流程消息", description = "无需登录,接收后查询当前节点并打印") public R processMessage(@RequestBody Map body) { log.info("客商公开页收到流程消息:{}", JSON.toJSONString(body)); + Map formValues = asMap(body == null ? null : body.get("formValues")); + String processId = firstText(formValues, "processId"); + if (StringUtil.isBlank(processId) && body != null) { + processId = firstText(body, "processId"); + } + String loginName = firstText(formValues, "mkLoginName", "loginName"); + if (StringUtil.isBlank(processId)) { + log.warn("客商公开页流程消息未找到 processId,跳过查询当前节点"); + return R.success("ok"); + } + try { + FR result = businessProcessClient.getCurrentNodes(processId, loginName); + log.info("客商公开页流程消息当前节点详情 processId={} loginName={} result={}", + processId, loginName, JSON.toJSONString(result == null ? null : result.getData())); + } catch (Exception e) { + log.error("客商公开页查询当前节点失败 processId={} loginName={}", processId, loginName, e); + } return R.success("ok"); } + private static Map asMap(Object value) { + if (!(value instanceof Map map)) { + return Collections.emptyMap(); + } + Map result = new HashMap<>(); + map.forEach((key, nested) -> { + if (key != null) { + result.put(String.valueOf(key), nested); + } + }); + return result; + } + + private static String firstText(Map source, String... keys) { + if (source == null || keys == null) { + return null; + } + for (String key : keys) { + Object value = source.get(key); + if (value == null) { + continue; + } + String text = String.valueOf(value).trim(); + if (StringUtil.isNotBlank(text) && !"null".equalsIgnoreCase(text)) { + return text; + } + } + return null; + } + } diff --git a/doc/nacos/blade.yaml b/doc/nacos/blade.yaml index 6c40037..052f97e 100644 --- a/doc/nacos/blade.yaml +++ b/doc/nacos/blade.yaml @@ -220,6 +220,7 @@ blade: - /customer-archive/public/** - /blade-openapi/openApi/mk/process/commonCallback - /openApi/mk/process/commonCallback + - /feign/client/businessProcess/getCurrentNodes #授权认证配置 auth: - method: ALL