diff --git a/src/main/java/com/yunhai/notice/controller/api/NoticeFlowController.java b/src/main/java/com/yunhai/notice/controller/api/NoticeFlowController.java index 5d60b2e..ff7827b 100644 --- a/src/main/java/com/yunhai/notice/controller/api/NoticeFlowController.java +++ b/src/main/java/com/yunhai/notice/controller/api/NoticeFlowController.java @@ -23,6 +23,7 @@ import java.util.Map; *
  • POST Flow/TrySubmit:提交/重提审核(幂等,bizId=notice.id;apply 失败保持待提交可重推);
  • *
  • GET Flow/Trace:审批进度(后端 getInstanceByBiz 组装,前端不直调 oapi——放行判定必须收在后端)。
  • *
  • GET Flow/Embed:办件进度嵌入页地址(Drawer iframe 直嵌,可见性与 Trace 同口径)。
  • + *
  • GET Flow/DiagramDef:流程定义示意图(绑定页/发通知页 Drawer,登录即可读——与 Binding 同口径)。
  • * */ @RestController @@ -32,6 +33,7 @@ public class NoticeFlowController { private final NoticeFlowService noticeFlowService; private final com.yunhai.notice.service.flow.NoticeFlowEmbedService noticeFlowEmbedService; + private final com.yunhai.notice.service.flow.FlowClient flowClient; /** 审核流程下拉选项(流程中心未启用时返回空列表,前端隐藏选择器) */ @GetMapping("Options") @@ -83,6 +85,21 @@ public class NoticeFlowController { return noticeFlowService.diagramImage(serid, user); } + /** + * 流程定义示意图(PNG 流,绑定页/发通知页 Drawer 同源直嵌 img)。def 口径无办件, + * 不适用 NoticeFlowGuard 办件守卫——与绑定读取(Binding,登录即可读)同口径:CAS 登录即可, + * schId 从登录用户推导,本校限定由 flow-center 按 schId+flowGuid 收敛; + * 绑定已解除/无已发布版时对端报业务错(JSON 信封),前端 img onerror 转提示,不留 500。 + */ + @GetMapping(value = "DiagramDef", produces = org.springframework.http.MediaType.IMAGE_PNG_VALUE) + public byte[] diagramDef(@RequestParam("flowGuid") String flowGuid, BoaUser user) { + if (flowGuid == null || flowGuid.trim().isEmpty()) { + throw new com.yunhai.platform.apistd.BizException( + com.yunhai.platform.utils.exception.ErrorCode.PARAM_ERROR, "缺少流程标识"); + } + return flowClient.diagramImageByFlowGuid(currentSchId(user), flowGuid.trim()); + } + /** * 办件进度嵌入页地址(详情页 Drawer 内 iframe 直嵌 flow-center 统一进度页)。 * 可见性与 Trace/Diagram 同口径;pageUrl 含短时 token,现取现发不落前端缓存。 diff --git a/src/main/java/com/yunhai/notice/service/flow/FlowCenterClient.java b/src/main/java/com/yunhai/notice/service/flow/FlowCenterClient.java index 566ba80..66e6b1f 100644 --- a/src/main/java/com/yunhai/notice/service/flow/FlowCenterClient.java +++ b/src/main/java/com/yunhai/notice/service/flow/FlowCenterClient.java @@ -197,6 +197,37 @@ public class FlowCenterClient implements FlowClient { return token.isEmpty() ? null : token; } + @Override + public byte[] diagramImageByFlowGuid(Integer schId, String flowGuid) { + requireEnabled(); + String imgUrl; + if (directoryResolved) { + FlowModels.DiagramUrlVo dto = com.yunhai.platform.openapi.flow.YschFlowOpenApi.diagramUrl( + null, flowGuid, null, schId, FlowModels.DiagramUrlVo.class); + imgUrl = dto == null ? null : dto.getImgUrl(); + } else { + Map query = new HashMap<>(); + query.put("flowGuid", flowGuid); + query.put("schId", String.valueOf(schId)); + FlowModels.DiagramUrlVo dto = + openCall.get(target(), "/oapi/flow/diagram/url", query, FlowModels.DiagramUrlVo.class); + imgUrl = dto == null ? null : dto.getImgUrl(); + } + String token = tokenOf(imgUrl); + if (token == null) { + throw new BizException(ErrorCode.PARAM_ERROR, "流程中心未返回有效的示意图地址"); + } + Map imgQuery = new HashMap<>(); + imgQuery.put("token", token); + byte[] bytes = directoryResolved + ? com.yunhai.platform.openapi.flow.YschFlowOpenApi.raw().download(DIAGRAM_IMG_PATH, imgQuery) + : openCall.download(target(), DIAGRAM_IMG_PATH, imgQuery); + if (bytes == null || bytes.length == 0) { + throw new BizException(ErrorCode.PARAM_ERROR, "流程示意图为空(流程可能未发布节点)"); + } + return bytes; + } + private TargetSpec target() { // base-path 空:本地/容器裸地址直连(两级模型 §2.2 对齐不变式的现行约定) return TargetSpec.of(properties.getBaseUrl(), ""); diff --git a/src/main/java/com/yunhai/notice/service/flow/FlowClient.java b/src/main/java/com/yunhai/notice/service/flow/FlowClient.java index a75f7c2..bf6fc7f 100644 --- a/src/main/java/com/yunhai/notice/service/flow/FlowClient.java +++ b/src/main/java/com/yunhai/notice/service/flow/FlowClient.java @@ -33,4 +33,11 @@ public interface FlowClient { /** 流程示意图字节(token 换图两步都在本方法内,浏览器只拿同源 PNG,token 不落前端) */ byte[] diagramImage(Integer schId, Long instanceId); + + /** + * 流程定义示意图字节(def 口径,绑定页/发通知页 Drawer):按 flowGuid 取最高已发布版出图。 + * 与办件图同一免签 token 通道;本校限定由 flow-center 按 schId+flowGuid 收敛(绑定已解除/ + * 无已发布版 → 业务异常文案,不留 500)。 + */ + byte[] diagramImageByFlowGuid(Integer schId, String flowGuid); }