diff --git a/platform-metadata/src/main/java/com/eip4/platform/metadata/flow/FlowInputCoercer.java b/platform-metadata/src/main/java/com/eip4/platform/metadata/flow/FlowInputCoercer.java
index 6b4b546..b9622c1 100644
--- a/platform-metadata/src/main/java/com/eip4/platform/metadata/flow/FlowInputCoercer.java
+++ b/platform-metadata/src/main/java/com/eip4/platform/metadata/flow/FlowInputCoercer.java
@@ -106,6 +106,57 @@ public class FlowInputCoercer {
applyCoerce(map, colTypes);
}
+ /**
+ * 读流(SEARCH)日期 coerce:仅把 DATE/TIME 列的 String 值转 {@code DateTime}/{@code DateTime[]}。
+ *
+ *
amis {@code input-date(time)-range} 把时间段提交为 "起,止" 逗号串,但引擎 GeneralPO 的搜索 where
+ * 构建只对 {@code DateTime[]} 值生成区间条件 {@code (col>=起 AND col<=止)}——收到 String 则识别不了,
+ * 整条时间段过滤被忽略(操作日志等"时间段查不动"根因)。本方法把日期列值转成引擎期望形态。
+ *
+ *
只碰 DATE/TIME 列,其它过滤参(文本/枚举/picker)一概不动 → 对已工作的搜索零回归。fail-safe:
+ * 无表名/查元数据失败/parse 失败 → 原值保留。供 {@code FlowController} 命名读流(NAMED_READ)路径调用。
+ */
+ public void coerceSearchDatesByFlowId(String flowId, Map map) {
+ if (flowId == null || flowId.isBlank() || map == null || map.isEmpty()) {
+ return;
+ }
+ coerceDatesOnly(map, flowTableCache.get(flowId, this::resolveTableNameByFlowId));
+ }
+
+ /**
+ * 同 {@link #coerceSearchDatesByFlowId},但表名直接给定——合成 {@code _SEARCH} 流无 contentxml,
+ * 表名由 key 剥后缀推得({@code FlowController} SYNTHESIZED 路径用)。
+ */
+ public void coerceSearchDatesByTable(String tableName, Map map) {
+ if (map == null || map.isEmpty()) {
+ return;
+ }
+ coerceDatesOnly(map, tableName);
+ }
+
+ /** 就地:只对 {@code tableName} 里 DATE/TIME 列的 String 值做日期/区间 coerce,其余键不动。 */
+ private void coerceDatesOnly(Map map, String tableName) {
+ if (tableName == null || tableName.isEmpty()) {
+ return;
+ }
+ Map colTypes = columnTypeCache.get(tableName, this::queryColumnTypes);
+ if (colTypes.isEmpty()) {
+ return;
+ }
+ for (Map.Entry entry : map.entrySet()) {
+ if (!(entry.getValue() instanceof String s) || s.isEmpty()) {
+ continue;
+ }
+ String refId = colTypes.get(entry.getKey().toUpperCase());
+ if ("DATE".equals(refId) || "TIME".equals(refId)) {
+ Object coerced = coerceValue(s, refId, entry.getKey());
+ if (coerced != entry.getValue()) {
+ entry.setValue(coerced);
+ }
+ }
+ }
+ }
+
/**
* 就地 coerce 写流入参 map:按流 contentxml 里的 tableName 查元数据,把 String 值
* 强制转成引擎期望的 Java 类型(Integer/Boolean/BigDecimal),其余类型不动。
@@ -426,7 +477,9 @@ public class FlowInputCoercer {
// DATE/TIME 列:引擎 GeneralPO 期望 joda DateTime,amis input-date/datetime 提交字符串
// (ISO/时间戳/yyyy-MM-dd[ HH:mm:ss])。原默认不转 → 引擎直接 cast String→DateTime 抛
// ClassCastException,致一切含日期列的表单写流崩。此处 String→joda DateTime(parse 失败保留原值)。
- return coerceDate(val.trim(), colName);
+ // amis input-date(time)-range 提交 "起,止"(逗号串) → joda DateTime[],引擎 GeneralPO 据此
+ // 构建区间查询 (col>=起millis AND col<=止millis);单值 → DateTime。
+ return coerceDateMaybeRange(val.trim(), colName);
}
default -> {
// NVARCHAR/CHAR/LIST/BLOB/CODE/UUID-ref 等 → 不动
@@ -435,12 +488,44 @@ public class FlowInputCoercer {
}
}
- /** DATE/TIME 字符串 → joda {@link DateTime}:依次试 毫秒时间戳 → ISO → {@code yyyy-MM-dd HH:mm:ss} → {@code yyyy-MM-dd};都失败保留原值。 */
+ /**
+ * DATE/TIME 值 coerce,识别 amis 区间:"起,止"(逗号串) → {@code DateTime[]}(引擎 GeneralPO 构建
+ * {@code (col>=起 AND col<=止)} 区间查询);单值 → {@code DateTime}。空段 → null(引擎该侧不加约束);
+ * 两段都解析失败 → 原 String 保留(fail-safe)。
+ */
+ private Object coerceDateMaybeRange(String v, String colName) {
+ if (v.isEmpty()) {
+ return v;
+ }
+ int comma = v.indexOf(',');
+ if (comma < 0) {
+ return coerceDate(v, colName); // 单值
+ }
+ String startStr = v.substring(0, comma).trim();
+ String endStr = v.substring(comma + 1).trim();
+ Object start = startStr.isEmpty() ? null : coerceDate(startStr, colName);
+ Object end = endStr.isEmpty() ? null : coerceDate(endStr, colName);
+ boolean startOk = start == null || start instanceof DateTime;
+ boolean endOk = end == null || end instanceof DateTime;
+ if (startOk && endOk && (start != null || end != null)) {
+ return new DateTime[] { (DateTime) start, (DateTime) end };
+ }
+ return v; // 解析失败 → 保留原值
+ }
+
+ /** DATE/TIME 字符串 → joda {@link DateTime}:依次试 秒/毫秒时间戳 → ISO → {@code yyyy-MM-dd HH:mm:ss} → {@code yyyy-MM-dd};都失败保留原值。 */
private Object coerceDate(String v, String colName) {
if (v.isEmpty()) {
return v;
}
- if (v.matches("-?\\d{12,}")) { // 13 位左右毫秒时间戳
+ if (v.matches("-?\\d{10,11}")) { // 10-11 位 → unix 秒(amis input-date(time)-range 默认 format=X)
+ try {
+ return new DateTime(Long.parseLong(v) * 1000L);
+ } catch (RuntimeException ignore) {
+ // 继续试
+ }
+ }
+ if (v.matches("-?\\d{12,}")) { // 12+ 位 → 毫秒时间戳
try {
return new DateTime(Long.parseLong(v));
} catch (RuntimeException ignore) {
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 a2226e6..010b8bd 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
@@ -291,6 +291,11 @@ public class FlowController {
// 命名读流:GET/POST 皆可。WS-D D.3:命名读流(如查看新闻查询 OA_NEWSMANAGE_SEARCH_LOOK)按其
// sys_serviceflow.entityid → sys_entity.tablename 解析数据源实体表,使引用列 id→姓名解析生效
// (发布人 USERSEND_ID 等显「-」根因);解析不到 → null,跳过解析(现状行为不变)。
+ // 时间段过滤:amis input-date(time)-range 提交 "起,止" 逗号串,引擎需 DateTime[] 才构建区间
+ // 查询。仅转 DATE/TIME 列(其它过滤参不动,零回归),修「操作日志等时间段查不动」。
+ if (inputCoercer != null) {
+ inputCoercer.coerceSearchDatesByFlowId(id, map);
+ }
Properties ctx = UserSession.getAdmin();
Object output = flowExcuteService.excute(map, ctx, id);
yield ok(output, flowNameResolver.entityTableForNamedFlow(id));
@@ -343,6 +348,10 @@ public class FlowController {
// 直接用原始 flowId(已大写 = TABLE_SEARCH)调引擎。读流,GET/POST 皆可。
Properties ctx = UserSession.getAdmin();
String flowKey = resolved.definition().getKey();
+ // 时间段过滤同 NAMED_READ:合成流无 contentxml,表名由 key 剥 _SEARCH 后缀得(仅转 DATE/TIME 列)。
+ if (inputCoercer != null) {
+ inputCoercer.coerceSearchDatesByTable(tableFromSearchKey(flowKey), map);
+ }
Object output = flowExcuteService.excute(map, ctx, flowKey);
// 合成搜索流的 key = _SEARCH,剥后缀即数据源实体表名,用于用户引用列 id→姓名解析
yield ok(output, tableFromSearchKey(flowKey));
diff --git a/platform-metadata/src/test/java/com/eip4/platform/metadata/flow/FlowInputCoercerTest.java b/platform-metadata/src/test/java/com/eip4/platform/metadata/flow/FlowInputCoercerTest.java
index 74d487d..e55e270 100644
--- a/platform-metadata/src/test/java/com/eip4/platform/metadata/flow/FlowInputCoercerTest.java
+++ b/platform-metadata/src/test/java/com/eip4/platform/metadata/flow/FlowInputCoercerTest.java
@@ -187,6 +187,60 @@ class FlowInputCoercerTest {
assertEquals("maybe", result);
}
+ // ── coerceValue DATE/TIME(单值 + amis 区间 input-date(time)-range)──────────
+
+ @Test
+ @DisplayName("coerceValue: TIME 'yyyy-MM-dd HH:mm:ss' → joda DateTime")
+ void coerceTimeFormatted() {
+ Object r = coercer.coerceValue("2026-06-15 17:41:00", "TIME", "UPDATETIME");
+ org.junit.jupiter.api.Assertions.assertInstanceOf(org.joda.time.DateTime.class, r);
+ }
+
+ @Test
+ @DisplayName("coerceValue: TIME unix 秒(10位) → DateTime(×1000,amis range 默认 format=X)")
+ void coerceTimeUnixSeconds() {
+ Object r = coercer.coerceValue("1749978060", "TIME", "UPDATETIME");
+ org.junit.jupiter.api.Assertions.assertInstanceOf(org.joda.time.DateTime.class, r);
+ assertEquals(1749978060_000L, ((org.joda.time.DateTime) r).getMillis(), "秒应 ×1000 转毫秒");
+ }
+
+ @Test
+ @DisplayName("coerceValue: TIME 区间 '起秒,止秒' → DateTime[](引擎据此构建区间查询)")
+ void coerceTimeRangeSeconds() {
+ Object r = coercer.coerceValue("1749978060,1750237260", "TIME", "UPDATETIME");
+ org.junit.jupiter.api.Assertions.assertInstanceOf(org.joda.time.DateTime[].class, r);
+ org.joda.time.DateTime[] arr = (org.joda.time.DateTime[]) r;
+ assertEquals(2, arr.length);
+ assertEquals(1749978060_000L, arr[0].getMillis());
+ assertEquals(1750237260_000L, arr[1].getMillis());
+ }
+
+ @Test
+ @DisplayName("coerceValue: TIME 区间格式化字符串 '起,止' → DateTime[]")
+ void coerceTimeRangeFormatted() {
+ Object r = coercer.coerceValue("2026-06-15 00:00:00,2026-06-18 23:59:59", "TIME", "UPDATETIME");
+ org.junit.jupiter.api.Assertions.assertInstanceOf(org.joda.time.DateTime[].class, r);
+ org.joda.time.DateTime[] arr = (org.joda.time.DateTime[]) r;
+ org.junit.jupiter.api.Assertions.assertTrue(arr[0].isBefore(arr[1]));
+ }
+
+ @Test
+ @DisplayName("coerceValue: TIME 区间一侧空 '起,' → DateTime[]{起, null}(引擎只加下界)")
+ void coerceTimeRangeOpenEnd() {
+ Object r = coercer.coerceValue("1749978060,", "TIME", "UPDATETIME");
+ org.junit.jupiter.api.Assertions.assertInstanceOf(org.joda.time.DateTime[].class, r);
+ org.joda.time.DateTime[] arr = (org.joda.time.DateTime[]) r;
+ assertEquals(1749978060_000L, arr[0].getMillis());
+ assertNull(arr[1], "止侧空 → null(不加上界约束)");
+ }
+
+ @Test
+ @DisplayName("coerceValue: TIME 区间无法解析 → 原 String 保留(fail-safe)")
+ void coerceTimeRangeUnparseable() {
+ Object r = coercer.coerceValue("foo,bar", "TIME", "UPDATETIME");
+ assertEquals("foo,bar", r);
+ }
+
// ── coerce(contentXml, map) ───────────────────────────────────────────────
@Test