Files
eip4-platform/docs/P1/F2-1函数库回迁报告.md
zhengwr 8c856e7a93 F2-1: WS3 平台函数库回迁(GetServicesFunction/GetDefaultValueFunction/GetValueFunction)
- GetServicesFunction.java:原 45 行桩扩展为完整 18 方法实现,覆盖全部
  top 调用(loadPOJO/listSelectResult/listSelectResultBySql/getEnumerateItemValue/
  getEnumerateItemDes/executeQueryForMap/findCount/excuteFlow/getCurrentUser* 等)
- GetDefaultValueFunction.java:从 Groovy 移植为 Java,12 个方法(getConfigValue/
  currentDate/currentYear/currentMonth/getCurrentUserId/getCurrentUserOrgId/
  getCurrentProjectId/guid 等),DateMidnight 语义完全对拍
- GetValueFunction.java:从 Groovy 移植为 Java,780 行→完整 Java 实现,
  40+ 纯函数(日期/字符串/数学/金额转换),null 行为/格式/返回类型逐方法对拍
- 新增接口:ChangeStatus、WorkCalendarService(P2 占位)
- 删除已被替换的 Groovy 源文件(GetDefaultValueFunction.groovy/GetValueFunction.groovy)
- 单测 80 个全绿,全套 platform-legacy-core 132 个测试 BUILD SUCCESS

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 20:42:33 +08:00

6.7 KiB
Raw Blame History

F2-1 WS3 平台函数库回迁报告

方法实现清单

GetServicesFunction(原版 136 行,15 个方法,全部实现)

方法 原版调用频度 实现状态 委托目标
loadPOJO(entityId, tableName, isHierarchical) 156 ✅ 完整实现 pojoCRUDService.loadPOJO
listSelectResult(map, tableName) 100 ✅ 完整实现 pojoCRUDService.listSelect → LIST_RESULT
getEnumerateItemValue(enumerateType, Des) 67 ✅ 完整实现 Enumerate.getEnumerateItemValue
listSelectResultBySql(map, tableName, sql, columns) 61 ✅ 完整实现 pojoCRUDService.listSelectBySql → LIST_RESULT
getEnumerateItemDes(enumerateType, value) 13 ✅ 完整实现 Enumerate.getEnumerateItemDes
executeQueryForMap(sql) 16 ✅ 完整实现 pojoService.executeQueryForMap
findCount(countSql) 11 ✅ 完整实现(原有桩扩展) dataDicService.findCount
excuteFlow(map, flowId) 11 ✅ 完整实现 flowExcuteService.excute
listSelect(map, tableName, ctx) 7 ✅ 完整实现(原有桩扩展) pojoCRUDService.listSelect
listSelectResult(map, tableName, columns) — ✅ 完整实现 pojoCRUDService.listSelectSpecialCol → LIST_RESULT
getEnumerateItem(enumerateType, value) — ✅ 完整实现 Enumerate.getEnumerateItem
isWorkDay(day) — ✅ 完整实现 workCalendarService.isWorkDay
convertIdsToUserIds(ids) — ✅ 完整实现 userFindService.findUsersByUserOrg
findUserContainer(userId) — ✅ 完整实现 organizationService.findUserContainer
deleteCascadeValidate(tableName, recordId) — ✅ 完整实现 pojoService.deleteCascadeValidate
getWFVariable(businessKey, variableName) — ✅ 完整实现 processCoreService.getWFVariable
setWFVariable(businessKey, variableName, obj) — ✅ 完整实现 processCoreService.setWFVariable
setWFStatus(businessKey, tableName, status) — ✅ 完整实现 changeStatus.UpdateStatus

GetDefaultValueFunction(原版 88 行,12 个方法,全部实现)

方法 原版调用频度 实现状态 说明
getConfigValue(key) 176 ✅ 完整实现 委托 SysConfig.getConfigValue(带缓存)
currentYear() 58 ✅ 完整实现 currentDateTime().getYear()
currentDate() 55 ✅ 完整实现 DateMidnight.toDateTime()(00:00:00)
currentMonth() 27 ✅ 完整实现 currentDateTime().getMonthOfYear()
getCurrentUserOrgId() 17 ✅ 完整实现 UserSession.get().CURRENTORG
getCurrentUserId() 16 ✅ 完整实现 UserSession.get().CURRENTUSER
getCurrentProjectId() 11 ✅ 完整实现 UserSession.get().CURRENTPROJECT
currentDateTime() 4 ✅ 完整实现 new DateTime(DateTimeZone.getDefault())
guid() — ✅ 完整实现 UUID.randomUUID().toString()
getCurrentUserDepartId() — ✅ 完整实现 UserSession.get().CURRENTDEPART
currentDay() / currentHour() / currentMinute() / secondOf() — ✅ 完整实现 currentDateTime() 派生

GetValueFunction(原版 780 行,40+ 个方法,全部实现)

方法组 原版调用频度 实现状态
toString(obj) 42 ✅ null→null(Groovy ?.toString() 行为)
firstDateOfMonth(dateTime) 29 ✅ 返回当月1日 00:00:00
addMonths(dateTime, months) 14 ✅ null 安全
lastDateOfMonth(dateTime) 13 ✅ 委托 firstDateOfMonth+addMonths+addDays
concat(str1, str2) 6 ✅ null 安全
replaceFirst(str, regex, replacement) 6 ✅ null 安全
firstDateOfYear(dateTime) 6 ✅ 返回1月1日 00:00:00
addDays(dateTime, days) 6 ✅ null 安全
currentDateTime (via GetDefault) 4 在 GetDefaultValueFunction
toChineseMoney(num) 4 ✅ 完整移植 changeNumberRMB 辅助逻辑
toDecimal(num) 3 ✅ null/BigDecimal/Number 分支
toDate(date, pattern) 3 ✅ toDatePattern 委托
monthOF(dateTime) 2 ✅ null 返回 0
toInteger(num) 1 ✅ null/Integer/Number 分支
yearOf(dateTime) 1 ✅ null 返回 0
其余纯函数(数学/字符串/日期) — ✅ 全部实现

新增接口文件:

  • com.dsasp.server.common.workcalendar.service.WorkCalendarService(P2 实现占位)
  • com.dsasp.server.common.dataDic.service.ChangeStatus(P2 实现占位)

Groovy→Java 替换:

  • 删除 src/main/groovy/.../GetDefaultValueFunction.groovy(88 行)
  • 删除 src/main/groovy/.../GetValueFunction.groovy(780 行)
  • GetServicesFunction 原为 45 行 Java 桩,扩展为 186 行完整实现

对拍说明(与原版的有意偏差)

位置 偏差描述 原因
GetValueFunction.decimalFormat 改用 decimalFormat.format(obj) 而非原版 format.format(obj) 原版 Groovy 存在 bug(String 无 .format(Object) 方法),按预期语义修复;脚本中几乎不调用此方法,影响可控,javadoc 已标注
GetValueFunction.toDecimal new BigDecimal(num.toString()) 而非 new BigDecimal(num) 避免 double→BigDecimal 精度损失,与 Groovy GDK 行为等价
GetDefaultValueFunction.guid() 显式 .toString() Groovy 隐式 toString,Java 需显式;行为完全一致

其余零偏差:null 行为、日期格式、返回类型、Integer.MIN_VALUE(枚举未找到)均与原版完全对拍。

单测证据

Tests run: 80, Failures: 0, Errors: 0, Skipped: 0
  - GetValueFunctionTest:        55 个(覆盖 top 方法 + 怪癖用例)
  - GetDefaultValueFunctionTest: 16 个(纯函数 + UserSession ThreadLocal)
  - GetServicesFunctionTest:      9 个(mock ApplicationContext,覆盖委托路径)
全套 platform-legacy-core 测试:132 个,BUILD SUCCESS

集成实测

集成测试(端口 8095,POST /api/script/execute 真实脚本)待 dev 环境启动后执行。 前置条件:getConfigValue/loadPOJO/listSelectResult/getEnumerateItemValue/listSelectResultBySql 均已正确委托到已移植的 pojoCRUDService / dataDicService / pojoService(单测 mock 验证委托路径正确)。

遗留

  1. WorkCalendarService / ChangeStatus 接口已就绪,impl 随 P2/P3 阶段补全
  2. isWorkDay / convertIdsToUserIds / findUserContainer / getWFVariable / setWFVariable / setWFStatus 的真实服务 impl 在 P2/P3 移植后自动生效(SpringBeanOsgiServices 按 bean 名查找)
  3. decimalFormat 原版 bug 已修复并标注,如需严格保真可还原(影响极小)
  4. 集成实测需 dev 库环境,待 8095 端口验证