Files
hose-use/scripts/mvel_date_format_node.mvel
gitea 86a02b82b7 feat(workflow): 支持节点只读透视与样本固化,规范企业切换上下文持久化
- skill: 补充终止节点物理断点与样本固化 (Stop Barrier & Sample Pinning) 最佳实践
- config: 修复 switchCorp / enter --switch 持久化写入 defaultCorpId 与激活 stateful 模式
- workflow node: 新增 inspect (探针透视配置/样本/执行) 与 sample-save (一键固化出参至 sampleData 并刷新选择树)
- workflow test: 新增 --save-sample 选项,调测通过后自动将产生出参的节点固化为 sampleData
- parser/metadata: 注册 save-sample 选项词汇表,补充单测 workflow-node-sample-inspect.test.ts
2026-11-24 11:45:46 +08:00

124 lines
5.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ==============================================================================
// 合思代码节点 (MVEL): 单据日期/日期范围字段转化为具体时间字符串与时间戳
// ==============================================================================
// ── 1. 配置区(按需修改)───────────────────────────────────────────────────────
// (1) 前置工作流节点 ID(例如:第2步单据详情节点 action_pfsq28)
upstreamNode = action_pfsq28;
// (2) 需要转化的单据层面字段 ID(例如标准起止日期 "feeDatePeriod",或自定义字段 "u_出差起止日期")
dateFieldKey = "feeDatePeriod";
// ── 2. 字段取值与防御提取 ──────────────────────────────────────────────────────
fieldVal = null;
if (upstreamNode != null) {
fieldVal = upstreamNode.get(dateFieldKey);
if (fieldVal == null && upstreamNode.get("form") != null) {
fieldVal = upstreamNode.get("form").get(dateFieldKey);
}
}
rawStart = null;
rawEnd = null;
if (fieldVal != null) {
if (fieldVal instanceof java.util.Map) {
rawStart = fieldVal.get("start");
rawEnd = fieldVal.get("end");
} else {
rawStart = fieldVal;
}
}
// ── 3. 初始化日期格式化器(强制北京时间 GMT+8) ────────────────────────────────
tz = java.util.TimeZone.getTimeZone("GMT+8");
sdfSecond = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdfSecond.setTimeZone(tz);
sdfMinute = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm");
sdfMinute.setTimeZone(tz);
sdfDay = new java.text.SimpleDateFormat("yyyy-MM-dd");
sdfDay.setTimeZone(tz);
// ── 4. 转换开始时间 (start) ───────────────────────────────────────────────────
startStr = "";
startMinute = "";
startDay = "";
startMs = 0L;
startSec = 0L;
dStart = null;
if (rawStart != null && String.valueOf(rawStart).trim() != "") {
startMs = java.lang.Long.parseLong(String.valueOf(rawStart).trim());
if (startMs < 10000000000L) {
startMs = startMs * 1000L;
}
startSec = startMs / 1000L;
dStart = new java.util.Date(startMs);
startStr = sdfSecond.format(dStart);
startMinute = sdfMinute.format(dStart);
startDay = sdfDay.format(dStart);
}
// ── 5. 转换结束时间 (end) ─────────────────────────────────────────────────────
endStr = "";
endMinute = "";
endDay = "";
endMs = 0L;
endSec = 0L;
dEnd = null;
if (rawEnd != null && String.valueOf(rawEnd).trim() != "") {
endMs = java.lang.Long.parseLong(String.valueOf(rawEnd).trim());
if (endMs < 10000000000L) {
endMs = endMs * 1000L;
}
endSec = endMs / 1000L;
dEnd = new java.util.Date(endMs);
endStr = sdfSecond.format(dEnd);
endMinute = sdfMinute.format(dEnd);
endDay = sdfDay.format(dEnd);
}
// ── 6. 组合区间显示文本 ───────────────────────────────────────────────────────
rangeMinuteStr = "";
rangeSecondStr = "";
if (startMinute != "" && endMinute != "") {
rangeMinuteStr = startMinute + " ~ " + endMinute;
rangeSecondStr = startStr + " ~ " + endStr;
} else if (startMinute != "") {
rangeMinuteStr = startMinute;
rangeSecondStr = startStr;
}
// ── 7. 组装返回结果 ───────────────────────────────────────────────────────────
result = new java.util.HashMap();
// 开始时间 / 单个时间
result.put("startTimeStr", startStr); // 如: "2026-11-19 20:59:00"
result.put("startTimeMinute", startMinute); // 如: "2026-11-19 20:59"
result.put("startDate", startDay); // 如: "2026-11-19"
result.put("startTimestampMs", startMs); // 毫秒时间戳 (Long)
result.put("startTimestampSec", startSec); // 秒时间戳 (Long)
// 结束时间
result.put("endTimeStr", endStr); // 如: "2026-11-20 16:55:00"
result.put("endTimeMinute", endMinute); // 如: "2026-11-20 16:55"
result.put("endDate", endDay); // 如: "2026-11-20"
result.put("endTimestampMs", endMs); // 毫秒时间戳 (Long)
result.put("endTimestampSec", endSec); // 秒时间戳 (Long)
// 区间文本(方便下游直接放入 comment 或通知)
result.put("rangeMinuteStr", rangeMinuteStr); // 如: "2026-11-19 20:59 ~ 2026-11-20 16:55"
result.put("rangeSecondStr", rangeSecondStr); // 如: "2026-11-19 20:59:00 ~ 2026-11-20 16:55:00"
// 兼容单日期直接取用别名
result.put("formattedTime", startStr);
result.put("formattedMinute", startMinute);
result.put("timestampMs", startMs);
result.put("timestampSec", startSec);
return result;