]*>", Pattern.CASE_INSENSITIVE);
+
+ /**
+ * amis bulkActions 契约适配(F2-17 删除/提交审批/文件归档断链根因):批量按钮只送
+ * {@code ids}=选中行主键逗号串,而老服务流 {@code } 声明的是单条主键入参
+ * (如 {@code OA_NOTICEMANAGE_ID}, required)——直接透传 ids 会因必填缺失 500。
+ *
+ * 返回该流声明的、调用方 map 里没给的必填 {@code *_ID} 字符串入参名;
+ * 无此入参 / 有多个(歧义不猜)/ map 已显式提供 → null。
+ */
+ public String missingRequiredIdInput(String flowId, Map map) {
+ if (flowId == null || flowId.isBlank()) {
+ return null;
+ }
+ String field = requiredIdInputCache.get(flowId, this::resolveRequiredIdInput);
+ if (field.isEmpty() || (map != null && map.containsKey(field))) {
+ return null;
+ }
+ return field;
+ }
+
+ private String resolveRequiredIdInput(String flowId) {
+ try {
+ String xml = jdbcTemplate.queryForObject(
+ "SELECT contentxml::text FROM eip3.sys_serviceflow WHERE sys_serviceflow_id = ?",
+ String.class, flowId);
+ String field = extractRequiredIdInput(xml);
+ return field != null ? field : "";
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ return ""; // 流不存在
+ } catch (RuntimeException e) {
+ log.warn("[FLOW-IDS] 查 contentxml 失败 flowId={}: {}", sanitize(flowId), e.getMessage());
+ return "";
+ }
+ }
+
+ /**
+ * 从 contentxml 的 {@code } 块提取必填 {@code *_ID} 字符串入参名。
+ * 条件:{@code required="true"}、无 {@code initValue}(有初值的不缺)、name 以 _ID 结尾
+ * (大小写不敏感)。命中 0 个或 ≥2 个(歧义)→ null。
+ */
+ static String extractRequiredIdInput(String contentXml) {
+ if (contentXml == null || contentXml.isBlank()) {
+ return null;
+ }
+ Matcher block = INPUT_BLOCK_PATTERN.matcher(contentXml);
+ if (!block.find()) {
+ return null;
+ }
+ String hit = null;
+ Matcher fields = INPUT_FIELD_PATTERN.matcher(block.group(1));
+ while (fields.find()) {
+ String tag = fields.group();
+ String name = attr(tag, "name");
+ if (name == null || !name.toUpperCase().endsWith("_ID")) {
+ continue;
+ }
+ if (!"true".equalsIgnoreCase(attr(tag, "required")) || attr(tag, "initValue") != null) {
+ continue;
+ }
+ if (hit != null) {
+ return null; // 多个必填 *_ID,歧义不猜
+ }
+ hit = name;
+ }
+ return hit;
+ }
+
+ /** 从单个标签文本里取属性值;无该属性 → null。 */
+ private static String attr(String tag, String attrName) {
+ Matcher m = Pattern.compile("\\b" + attrName + "\\s*=\\s*\"([^\"]*)\"", Pattern.CASE_INSENSITIVE)
+ .matcher(tag);
+ return m.find() ? m.group(1).trim() : null;
+ }
+
/**
* 按 flowId 从 sys_serviceflow 查 contentxml,提取 tableName。
* 找不到 → 返回 {@code ""}(空字符串,会被缓存以避免重查)。
diff --git a/platform-metadata/src/main/java/com/eip4/platform/metadata/web/FlowController.java b/platform-metadata/src/main/java/com/eip4/platform/metadata/web/FlowController.java
index 7861621..abe5338 100644
--- a/platform-metadata/src/main/java/com/eip4/platform/metadata/web/FlowController.java
+++ b/platform-metadata/src/main/java/com/eip4/platform/metadata/web/FlowController.java
@@ -195,6 +195,31 @@ public class FlowController {
if (!isPost) {
yield forbiddenWriteViaGet(id);
}
+ // amis bulkActions 契约适配(F2-17 删除/提交审批/文件归档断链根因):
+ // 批量按钮只送 ids=选中行主键逗号串,而老服务流 声明的是单条必填主键
+ // (如 OA_NOTICEMANAGE_ID, required)——透传 ids 会因必填缺失 500。
+ // 这里拆 ids 逐 id 执行(对齐老系统逐行跑流的语义),其余 body 键原样带上。
+ // 注意:每次 excute 各自一个引擎事务,部分失败时已执行的 id 不回滚(与老系统逐行点击一致)。
+ String pkInput = (inputCoercer != null && map.get("ids") instanceof String s && !s.isBlank())
+ ? inputCoercer.missingRequiredIdInput(id, map) : null;
+ if (pkInput != null) {
+ Properties fanoutCtx = currentCtx();
+ List