F2-1b:视图脚本执行路径补全默认导入(GetServicesFunction/DateTime 可用)

dataDic.binding.ScriptingEnginesManager 换用 SecureGroovyScriptEngineFactory,
与服务流路径对齐,注入 8 条 DEFAULTIMPORTSLIST + org.joda.time 星号导入。
修复 execute-template 端点「No such property: GetServicesFunction」和
「unable to resolve class DateTime」。迁移手册 §10.4 新增坑位登记。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 22:23:41 +08:00
parent 9a055ef3b6
commit bc23909feb
2 changed files with 30 additions and 4 deletions

View File

@@ -809,4 +809,24 @@ com.dsasp.* com.eip4.*
---
---
### 10.4 视图脚本执行路径默认导入缺失,GetServicesFunction/DateTime 不可用 [NEW 2026-06-11]
**现象**:POST /api/script/execute-template 执行含 `GetServicesFunction.loadPOJO(...)` 静态类名引用的脚本报「No such property: GetServicesFunction」;`new DateTime[2]` 报 unable to resolve class DateTime。
**根因**:视图脚本执行路径(`ScriptExecuteController` → `com.dsasp.server.dataDic.binding.ScriptingEnginesManager.evaluateGroovy`)使用裸 `GroovyScriptEngineFactory`,不含 `DEFAULTIMPORTSLIST`(8 条服务端导入)和 `DEFAULTSTARIMPORTSLIST`(org.joda.time)。服务流路径(`com.dsasp.server.core.service.script.ScriptingEnginesManager`)已正确使用 `SecureGroovyScriptEngineFactory`,两路径存在不一致。
**对策(F2-1b)**:`com.dsasp.server.dataDic.binding.ScriptingEnginesManager` 换用 `SecureGroovyScriptEngineFactory`(与服务流路径对齐),自动注入 8 条默认导入(`GeneralPOJO/CustomSearchConditional/POJOCRUDService/StringUtil/GetServicesFunction/GetDefaultValueFunction/GetValueFunction/Console`)+ `org.joda.time` 星号导入。属「替换类登记」最小适配,ArchUnit「保真层禁止依赖现代层」不受影响。
**验证**:
- `GetServicesFunction.class.simpleName` → `"GetServicesFunction"` (passed: True)
- `GetValueFunction.class.simpleName` → `"GetValueFunction"` (passed: True)
- `new DateTime[2]; arr.length` → `2` (passed: True)
- 087739c4-3dee-4bac-b031-772497addc6b seq1(含 `new DateTime[2]`)→ passed: True
**影响范围**:所有经 execute-template 端点执行的改写后脚本(FULL_AUTO/NO_S3 均走此路径)。
---
**手册维护说明**:本手册随工程化进展持续更新;新坑位发现即追加,以 `[NEW yyyy-mm-dd]` 标记;章节完成后移除「待补」标记。任何对引擎行为契约的更改必须同步更新第五章并过 code review。