package cn.iocoder.yudao.module.qcreport.enums;
|
|
import lombok.AllArgsConstructor;
|
import lombok.Getter;
|
|
import java.util.Objects;
|
|
/**
|
* 报告来源单据类型(MES 的四类质检单)。
|
* <p>
|
* 这里同时钉死三件互相绑定的事,避免散落成三处字符串字面量:
|
* 质检单的类型值(传给 MES 接口用)、模板 {@code report_type} 的取值(与前端下拉同源,是数字字符串)、
|
* 以及报告实例落库时的 {@code business_type}。
|
* <p>
|
* {@code businessType} 用的 {@code mes_qc_*} 是事实上的契约 ——
|
* 「按单据反查报告」靠它过滤,改一个字符就查不到历史报告。
|
*/
|
@Getter
|
@AllArgsConstructor
|
public enum QcReportSourceTypeEnum {
|
|
IQC(1, "来料检验", "mes_qc_iqc"),
|
IPQC(2, "过程检验", "mes_qc_ipqc"),
|
OQC(3, "出货检验", "mes_qc_oqc"),
|
RQC(4, "退货检验", "mes_qc_rqc");
|
|
/** 质检类型值,见 MES 的 MesQcTypeEnum */
|
private final Integer type;
|
/** 类型名,与 MES 列表上的叫法一致 */
|
private final String name;
|
/** 报告实例的 business_type */
|
private final String businessType;
|
|
/** 识别不出返回 null,由调用方决定怎么报错 */
|
public static QcReportSourceTypeEnum of(Integer type) {
|
for (QcReportSourceTypeEnum value : values()) {
|
if (Objects.equals(value.type, type)) {
|
return value;
|
}
|
}
|
return null;
|
}
|
|
/**
|
* 模板上的报告类型是否指向本类型。
|
* <p>
|
* 模板的 {@code report_type} 存的是数字字符串(前端下拉取 mes_qc_type 字典的 string 值),
|
* 所以比的是 {@code "1"} 而不是 {@code "IQC"}。
|
*/
|
public boolean matchesTemplateReportType(String reportType) {
|
return reportType != null && reportType.trim().equals(String.valueOf(type));
|
}
|
|
}
|