feat(apply): 办件详情出参补发 formSchemaJson——申请内容按表单 schema 显示中文 label 与分组
build / build-push (push) Successful in 48s

- ApplyVo 新增响应期字段 formSchemaJson(仅 detail 填,不入库)
- ServiceFormService.schemaAt:按办件提交时 formVersion 精确命中,缺失回落最新已发布
- 无表单/事项清理/未发布 → null,前端回落按 key 展示
- 单测 ServiceApplyDetailSchemaTest 三态冻结(详情中文化分组 2026-09-17,详见验收清单)
This commit is contained in:
chenxing
2026-09-17 14:50:46 +08:00
parent f0279ae12d
commit 8504ca970c
4 changed files with 154 additions and 1 deletions
@@ -444,6 +444,12 @@ public final class SvcModels {
* enabled=false → 真的不会翻转,直接告知未接入;enabled=true 且 flowStatus=0 → 排队中,等待轮询。
*/
private Boolean flowEnabled;
/**
* 办理表单 schema(<b>响应期补发,不入库</b>;仅 detail 出参填):
* 前端「申请内容」以此为 key→中文 label/分组的唯一事实源(2026-09-17),版本口径=
* 办件 formVersion 精确命中、缺失回落最新已发布版本。无表单事项为 null。
*/
private String formSchemaJson;
public static ApplyVo of(com.yunhai.svchall.entity.ServiceApply a) {
ApplyVo vo = new ApplyVo();
@@ -286,7 +286,25 @@ public class ServiceApplyService {
.orElseThrow(() -> new BizException(ErrorCode.PARAM_ERROR, "办件不存在"));
applyViewGuard.requireVisible(apply, user);
}
return ApplyVo.of(apply);
ApplyVo vo = ApplyVo.of(apply);
vo.setFormSchemaJson(formSchemaJson(apply));
return vo;
}
/**
* 申请内容展示 schema(key→中文 label/分组的唯一事实源):办件 → 事项 formCode →
* 按提交时 formVersion 定版(缺失回落最新已发布)取 schemaJson。任何一环缺失(无表单
* 事项/事项已清理/表单未发布过)返回 null,前端回落按 key 展示,不报错。
*/
private String formSchemaJson(ServiceApply apply) {
if (apply.getFormVersion() == null || apply.getItemId() == null) {
return null;
}
ServiceItem item = itemRepository.findById(apply.getItemId()).orElse(null);
if (item == null || item.getFormCode() == null || item.getFormCode().isEmpty()) {
return null;
}
return formService.schemaAt(apply.getSchId(), item.getFormCode(), apply.getFormVersion());
}
// ===== 管理面 =====
@@ -157,4 +157,18 @@ public class ServiceFormService {
public Optional<ServiceForm> latestPublished(Long schId, String code) {
return formRepository.findFirstBySchIdAndCodeAndStatusOrderByVersionDesc(schId, code, 1);
}
/**
* 详情展示取 schema:办件提交时的 formVersion 精确命中(快照纪律的展示侧对齐——
* 表单后续改版不改历史办件的字段含义);该版本已不可考(如被整 code 清理)回落最新已发布版本,
* 再不行给 null(前端回落按 key 展示)。
*/
public String schemaAt(Long schId, String code, Integer version) {
Optional<ServiceForm> form = version == null ? Optional.empty()
: formRepository.findBySchIdAndCodeAndVersion(schId, code, version);
if (!form.isPresent()) {
form = latestPublished(schId, code);
}
return form.map(ServiceForm::getSchemaJson).orElse(null);
}
}