9 小时以前 9bad721754fe8bbe2e5f459d0706e0fefac569f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package cn.iocoder.yudao.module.qcreport.engine.context;
 
import cn.iocoder.yudao.module.qcreport.engine.QualityResult;
import lombok.Data;
import lombok.experimental.Accessors;
 
/**
 * 报告级字段。
 * <p>
 * 模板里的 {@code {{report.xxx}}} 全部相对它取值,字段名与前端
 * {@code engine/context.ts} 的 ReportContextReport 保持一致。
 * <p>
 * 其中的 result / resultText / conclusion / passRate / total / passCount / failCount
 * 由判定器算出后写回,调用方不必自己填。
 * <p>
 * 文本字段默认空串而不是 null:模板里 {@code {{report.xxx}}} 取到空串是「这个字段没有值」,
 * 取到 null 是「路径不存在」,后者会被渲染引擎当成数据缺口报出来。
 * 没填的字段应该走前者,否则每张报告都会刷一堆并不存在的缺口。
 */
@Data
@Accessors(chain = true)
public class ReportFields {
 
    private String reportNo = "";
    private String reportName = "";
    private String sampleNo = "";
    private String productCode = "";
    private String productName = "";
    private String spec = "";
    private String batchNo = "";
    private String workOrderNo = "";
    private String inspectType = "";
    private String inspector = "";
    private String inspectDate = "";
    private String department = "";
    private String customerName = "";
    private String supplierName = "";
 
    /** PASS / FAIL */
    private String result = "";
    /** 合格 / 不合格 / 待判定 */
    private String resultText = "";
    /** 报告结论,与 {@link #resultText} 同源;无结论时为「待判定」 */
    private String conclusion = "";
    /** 合格率,形如 96.67% */
    private String passRate = "";
 
    /**
     * 业务单据自身的检验判定(MES 的四值:合格 / 特采 / 不合格退货 / 不合格报废),非判定引擎产出。
     * <p>
     * 与上面的 result / resultText / conclusion 是两回事,刻意分开:
     * 引擎只有「合格 / 不合格 / 待判定」三态,装不下「特采」「不合格退货」这类处置口径;
     * 而质检单上的判定是人工拍的板,报告要如实照登。两者都可能出现在同一张报告上。
     */
    private String qcResult = "";
    private String qcResultText = "";
 
    private int total;
    private int passCount;
    private int failCount;
 
    /** 复制一份,判定器不修改调用方传进来的上下文 */
    public ReportFields copy() {
        return new ReportFields()
                .setReportNo(reportNo).setReportName(reportName).setSampleNo(sampleNo)
                .setProductCode(productCode).setProductName(productName).setSpec(spec)
                .setBatchNo(batchNo).setWorkOrderNo(workOrderNo).setInspectType(inspectType)
                .setInspector(inspector).setInspectDate(inspectDate).setDepartment(department)
                .setCustomerName(customerName).setSupplierName(supplierName)
                .setResult(result).setResultText(resultText).setConclusion(conclusion)
                .setPassRate(passRate)
                .setQcResult(qcResult).setQcResultText(qcResultText)
                .setTotal(total).setPassCount(passCount).setFailCount(failCount);
    }
 
    /** 按判定结果写回 result / resultText / conclusion,result 为 null 时置为待判定 */
    public ReportFields applyResult(QualityResult verdict) {
        this.result = verdict == null ? "" : verdict.name();
        String text = verdict == null ? QualityResult.PENDING_TEXT : verdict.text();
        this.resultText = text;
        this.conclusion = text;
        return this;
    }
 
}