yxh
昨天 fce96ef468291fb9a0e6a4d34ab371315e9485d4
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/enums/AppointmentTypeEnum.java
@@ -4,11 +4,29 @@
import lombok.Getter;
/**
 * Action类型枚举
 * 检查状态编码枚举。
 *
 * <h3>修正说明</h3>
 * 原实现存在两处问题,已修正:
 * <ol>
 *   <li><b>字面值含空白污染</b>:原定义为 {@code SQDKL("   1", ...)}、
 *       {@code JCDJ("  3\t", ...)},type 值前有空格、部分含制表符,
 *       导致 {@link #getByType(String)} 对正常传入的 {@code "1"}、{@code "3"}
 *       匹配失败(返回 null)。现已去除全部空白。</li>
 *   <li><b>包含病理专用状态</b>:原表含 21 标本送检、22 取消标本送检、23 已缴费,
 *       这些属病理科业务,心电系统不涉及,已移除。</li>
 * </ol>
 *
 * <p>编码值与《检查状态编码表》一致。状态的**归一化**(去前导零、校验合法性)
 * 请使用 {@link HisCheckStatusEnum#normalize(String)},本枚举只负责
 * 类型值到名称的展示映射。
 *
 * @author 心电排队装机系统
 */
@Getter
@AllArgsConstructor
public enum AppointmentTypeEnum {
    SQDKL("   1", "   申请单开立"),
    SQDCX("  2", "申请单撤销"),
    JCDJ("  3   ", "检查登记"),
@@ -21,24 +39,31 @@
    BGSH("  10", "   报告审核");
    /**
     * 类型
     * 状态编码(标准值,无空白、无前导零)
     */
    private final String type;
    /**
     * 描述
     * 状态名称
     */
    private final String description;
    /**
     * 根据类型获取枚举
     * 根据状态编码获取名称。
     * <p>
     * 入参会先做归一化处理(去空白、去前导零),因此传入
     * {@code "3"}、{@code "03"}、{@code " 3 "} 均可正确匹配。
     *
     * @param type 类型
     * @return 枚举
     * @param type 状态编码
     * @return 状态名称;无法识别时返回 null
     */
    public static String getByType(String type) {
        String normalized = HisCheckStatusEnum.normalize(type);
        if (normalized == null) {
            return null;
        }
        for (AppointmentTypeEnum value : values()) {
            if (value.getType().equals(type)) {
                return value.getDescription();
            if (value.type.equals(normalized)) {
                return value.description;
            }
        }
        return null;