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
86
87
88
89
90
91
92
package cn.iocoder.yudao.module.mes.controller.admin.qc.vo;
 
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
 
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
 
/**
 * MES 质检检验单导出 Excel VO(IQC/IPQC/OQC/RQC 共用)
 *
 * <p>导出列:检验单名称 / 物料名称 / 批号 / 检测日期 / 检验指标 / 判定依据 / 检验结果 / 检验人 / 审核人 / 备注。
 * 检验指标、判定依据取自检验单行明细;审核人暂无数据来源,导出为空列。
 *
 * @author 超级管理员
 */
@Data
public class MesQcQualityExportVO {
 
    @ExcelProperty("检验单名称")
    private String docName;
 
    @ExcelProperty("物料名称")
    private String itemName;
 
    @ExcelProperty("批号")
    private String batchNo;
 
    @ExcelProperty("检测日期")
    private String inspectDate;
 
    @ExcelProperty("检验指标")
    private String indicatorNames;
 
    @ExcelProperty("判定依据")
    private String judgementBasis;
 
    @ExcelProperty("检验结果")
    private String checkResultText;
 
    @ExcelProperty("检验人")
    private String inspectorName;
 
    @ExcelProperty("审核人")
    private String auditorName;
 
    @ExcelProperty("备注")
    private String remark;
 
    /**
     * 格式化检测日期(仅日期),null 返回空串
     */
    public static String formatDateTime(LocalDateTime dateTime) {
        if (dateTime == null) {
            return "";
        }
        return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }
 
    /**
     * 去掉数值尾部无意义的 0,如 35.000000 -> 35、2.500000 -> 2.5
     */
    public static String formatDecimal(BigDecimal value) {
        if (value == null) {
            return "";
        }
        return value.stripTrailingZeros().toPlainString();
    }
 
    /**
     * 组装单个检测项的判定依据文本:
     * 上下限均有 -> "下限~上限";仅有上限 -> "≤上限";仅有下限 -> "≥下限";
     * 均无但给了标准值 -> "标准值 标准值";否则返回空串。
     */
    public static String buildRangeText(BigDecimal standardValue, BigDecimal minThreshold, BigDecimal maxThreshold) {
        if (maxThreshold != null && minThreshold != null) {
            return formatDecimal(minThreshold) + "~" + formatDecimal(maxThreshold);
        }
        if (maxThreshold != null) {
            return "≤" + formatDecimal(maxThreshold);
        }
        if (minThreshold != null) {
            return "≥" + formatDecimal(minThreshold);
        }
        if (standardValue != null) {
            return "标准值 " + formatDecimal(standardValue);
        }
        return "";
    }
 
}