:refactor: 提取审批状态中文名映射为公共方法

- 审批状态中文名映射收敛至 HcsSyncConstant.approvalStatusName(金蝶回调变更记录共用)
- 删除项目/合同特批/合同同步三个支撑组件中的重复私有实现
This commit is contained in:
刘泉佳
2026-10-20 16:54:26 +08:00
parent 7a48057019
commit f579a7eb20
4 changed files with 24 additions and 62 deletions
@@ -301,6 +301,27 @@ public final class HcsSyncConstant {
return message.length() > SYNC_MSG_MAX_LENGTH ? message.substring(0, SYNC_MSG_MAX_LENGTH) : message;
}
/**
* 审批状态中文名(变更记录展示用,金蝶同步结果回调等系统链路共用;未匹配回退原值)
*/
public static String approvalStatusName(String approvalStatus) {
if (approvalStatus == null || approvalStatus.isEmpty()) {
return null;
}
return switch (approvalStatus) {
case "draft" -> "草稿";
case "reviewing" -> "审批中";
case "withdrawn" -> "已撤回";
case "approved" -> "审批通过";
case "rejected" -> "已驳回";
case "change_reviewing" -> "变更审批中";
case "change_rejected" -> "变更驳回";
case "change_approved" -> "变更审批通过";
case "voided" -> "已作废";
default -> approvalStatus;
};
}
private HcsSyncConstant() {
}
}
@@ -229,30 +229,11 @@ public class HcsContractSpecSyncSupport {
record.put("changeType", "金蝶同步结果");
record.put("changeContent", changeContent);
record.put("status", contractManage.getApprovalStatus());
record.put("statusName", approvalStatusName(contractManage.getApprovalStatus()));
record.put("statusName", HcsSyncConstant.approvalStatusName(contractManage.getApprovalStatus()));
records.add(record);
contractManage.setChangeRecordJson(JSONUtil.toJsonStr(records));
}
/**
* 审批状态中文名(变更记录展示用,未匹配回退原值)
*/
private String approvalStatusName(String approvalStatus) {
if (StringUtil.isBlank(approvalStatus)) {
return null;
}
return switch (approvalStatus) {
case "draft" -> "草稿";
case "reviewing" -> "审批中";
case "withdrawn" -> "已撤回";
case "approved" -> "审批通过";
case "rejected" -> "已驳回";
case "change_reviewing" -> "变更审批中";
case "change_approved" -> "变更审批通过";
default -> approvalStatus;
};
}
/**
* 按 ERP 合同编号定位合同(合规推送 contractCode,合同编号唯一)
*/
@@ -208,30 +208,11 @@ public class HcsContractSyncSupport {
record.put("changeType", "金蝶同步结果");
record.put("changeContent", changeContent);
record.put("status", contractManage.getApprovalStatus());
record.put("statusName", approvalStatusName(contractManage.getApprovalStatus()));
record.put("statusName", HcsSyncConstant.approvalStatusName(contractManage.getApprovalStatus()));
records.add(record);
contractManage.setChangeRecordJson(JSONUtil.toJsonStr(records));
}
/**
* 审批状态中文名(变更记录展示用,未匹配回退原值)
*/
private String approvalStatusName(String approvalStatus) {
if (StringUtil.isBlank(approvalStatus)) {
return null;
}
return switch (approvalStatus) {
case "draft" -> "草稿";
case "reviewing" -> "审批中";
case "withdrawn" -> "已撤回";
case "approved" -> "审批通过";
case "rejected" -> "已驳回";
case "change_reviewing" -> "变更审批中";
case "change_approved" -> "变更审批通过";
default -> approvalStatus;
};
}
/**
* 推送合同到 HCS:特批挂起门禁 → 风险校验(仅留痕,高风险不再阻断)→ 附件转传 → 判重 → 起草/更新 → 回填合规 fdId 置 synced
* → 履约计划行级同步(C103-9,先于特批挂起)→ 高风险/黑名单客商合同挂起"特批审核"等待合规特批结果(报文随 fdSepcailContract=true,外部客商管控)
@@ -331,32 +331,11 @@ public class HcsProjectSyncSupport {
record.put("changeType", "金蝶同步结果");
record.put("changeContent", changeContent);
record.put("status", projectApply.getApprovalStatus());
record.put("statusName", approvalStatusName(projectApply.getApprovalStatus()));
record.put("statusName", HcsSyncConstant.approvalStatusName(projectApply.getApprovalStatus()));
records.add(record);
projectApply.setChangeRecordJson(JSONUtil.toJsonStr(records));
}
/**
* 审批状态中文名(变更记录展示用,未匹配回退原值)
*/
private String approvalStatusName(String approvalStatus) {
if (StringUtil.isBlank(approvalStatus)) {
return null;
}
return switch (approvalStatus) {
case "draft" -> "草稿";
case "reviewing" -> "审批中";
case "withdrawn" -> "已撤回";
case "approved" -> "审批通过";
case "rejected" -> "已驳回";
case "change_reviewing" -> "变更审批中";
case "change_rejected" -> "变更驳回";
case "change_approved" -> "变更审批通过";
case "voided" -> "已作废";
default -> approvalStatus;
};
}
/**
* 按 ERP 项目编号定位项目(合规推送 projectCode,对应 C102 fd_num)
*/