From 1dc5b63700132703d2303f57387b8919c6d1d5bb Mon Sep 17 00:00:00 2001 From: Yangwl <1726150332@qq.com> Date: Fri, 25 Jul 2025 15:14:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E6=BA=90=E5=8D=95=E8=80=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BF=AE=E6=94=B9=E5=88=86=E9=A1=B5=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DataAnalysisServiceImpl.java | 4 +- .../mapper/report/ReportPointDnbMapper.xml | 2 + .../com/op/quality/config/GB2828Sampler.java | 196 ++++++++++++++++++ 3 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/config/GB2828Sampler.java diff --git a/op-modules/op-energy/src/main/java/com/op/energy/report/service/impl/DataAnalysisServiceImpl.java b/op-modules/op-energy/src/main/java/com/op/energy/report/service/impl/DataAnalysisServiceImpl.java index cd0f3cb20..d2fc2fa37 100644 --- a/op-modules/op-energy/src/main/java/com/op/energy/report/service/impl/DataAnalysisServiceImpl.java +++ b/op-modules/op-energy/src/main/java/com/op/energy/report/service/impl/DataAnalysisServiceImpl.java @@ -1044,7 +1044,7 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService { } } } - return reportOrderEnergyDTOList.stream().sorted(Comparator.comparing(ReportOrderEnergyDTO::getProductDate) - .thenComparing(ReportOrderEnergyDTO::getWorkorderName)).collect(Collectors.toList()); + + return reportOrderEnergyDTOList; } } diff --git a/op-modules/op-energy/src/main/resources/mapper/report/ReportPointDnbMapper.xml b/op-modules/op-energy/src/main/resources/mapper/report/ReportPointDnbMapper.xml index 21d1a9f99..b61a9116f 100644 --- a/op-modules/op-energy/src/main/resources/mapper/report/ReportPointDnbMapper.xml +++ b/op-modules/op-energy/src/main/resources/mapper/report/ReportPointDnbMapper.xml @@ -295,6 +295,8 @@ AND pow.status = 'w3' AND pow.parent_order = '0' + ORDER BY + pow.product_date DESC diff --git a/op-modules/op-quality/src/main/java/com/op/quality/config/GB2828Sampler.java b/op-modules/op-quality/src/main/java/com/op/quality/config/GB2828Sampler.java new file mode 100644 index 000000000..e215f69d5 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/config/GB2828Sampler.java @@ -0,0 +1,196 @@ +package com.op.quality.config; + +import java.util.HashMap; +import java.util.Map; + +public class GB2828Sampler { + public static final Map SAMPLE_SIZE_CODE_MAP = new HashMap<>(); + public static final Map AQL_TABLE = new HashMap<>(); + + static { + // 检验水平I + SAMPLE_SIZE_CODE_MAP.put("2-8_I", 2); + SAMPLE_SIZE_CODE_MAP.put("9-15_I", 2); + SAMPLE_SIZE_CODE_MAP.put("16-25_I", 3); + SAMPLE_SIZE_CODE_MAP.put("26-50_I", 3); + SAMPLE_SIZE_CODE_MAP.put("51-90_I", 5); + SAMPLE_SIZE_CODE_MAP.put("91-150_I", 5); + SAMPLE_SIZE_CODE_MAP.put("151-280_I", 8); + SAMPLE_SIZE_CODE_MAP.put("281-500_I", 13); + SAMPLE_SIZE_CODE_MAP.put("501-1200_I", 20); + SAMPLE_SIZE_CODE_MAP.put("1201-3200_I", 32); + SAMPLE_SIZE_CODE_MAP.put("3201-10000_I", 50); + SAMPLE_SIZE_CODE_MAP.put("10001-35000_I", 80); + SAMPLE_SIZE_CODE_MAP.put("35001-150000_I", 125); + SAMPLE_SIZE_CODE_MAP.put("150001-500000_I", 200); + SAMPLE_SIZE_CODE_MAP.put("500001-_I", 315); + + // 检验水平II (默认水平) + SAMPLE_SIZE_CODE_MAP.put("2-8_II", 2); + SAMPLE_SIZE_CODE_MAP.put("9-15_II", 3); + SAMPLE_SIZE_CODE_MAP.put("16-25_II", 5); + SAMPLE_SIZE_CODE_MAP.put("26-50_II", 8); + SAMPLE_SIZE_CODE_MAP.put("51-90_II", 13); + SAMPLE_SIZE_CODE_MAP.put("91-150_II", 20); + SAMPLE_SIZE_CODE_MAP.put("151-280_II", 32); + SAMPLE_SIZE_CODE_MAP.put("281-500_II", 50); + SAMPLE_SIZE_CODE_MAP.put("501-1200_II", 80); + SAMPLE_SIZE_CODE_MAP.put("1201-3200_II", 125); + SAMPLE_SIZE_CODE_MAP.put("3201-10000_II", 200); + SAMPLE_SIZE_CODE_MAP.put("10001-35000_II", 315); + SAMPLE_SIZE_CODE_MAP.put("35001-150000_II", 500); + SAMPLE_SIZE_CODE_MAP.put("150001-500000_II", 800); + SAMPLE_SIZE_CODE_MAP.put("500001-_II", 1250); + + // 检验水平III + SAMPLE_SIZE_CODE_MAP.put("2-8_III", 3); + SAMPLE_SIZE_CODE_MAP.put("9-15_III", 5); + SAMPLE_SIZE_CODE_MAP.put("16-25_III", 8); + SAMPLE_SIZE_CODE_MAP.put("26-50_III", 13); + SAMPLE_SIZE_CODE_MAP.put("51-90_III", 20); + SAMPLE_SIZE_CODE_MAP.put("91-150_III", 32); + SAMPLE_SIZE_CODE_MAP.put("151-280_III", 50); + SAMPLE_SIZE_CODE_MAP.put("281-500_III", 80); + SAMPLE_SIZE_CODE_MAP.put("501-1200_III", 125); + SAMPLE_SIZE_CODE_MAP.put("1201-3200_III", 200); + SAMPLE_SIZE_CODE_MAP.put("3201-10000_III", 315); + SAMPLE_SIZE_CODE_MAP.put("10001-35000_III", 500); + SAMPLE_SIZE_CODE_MAP.put("35001-150000_III", 800); + SAMPLE_SIZE_CODE_MAP.put("150001-500000_III", 1250); + SAMPLE_SIZE_CODE_MAP.put("500001-_III", 2000); + } + static { + // 样本量字码A-R对应的AQL接收数 + AQL_TABLE.put("A", new int[]{0,0,0,0,0}); // 样本量2-3 + AQL_TABLE.put("B", new int[]{0,0,0,0,0}); // 样本量5 + AQL_TABLE.put("C", new int[]{0,0,0,0,0}); // 样本量8 + AQL_TABLE.put("D", new int[]{0,0,0,0,1}); // 样本量13 + AQL_TABLE.put("E", new int[]{0,0,0,1,1}); // 样本量20 + AQL_TABLE.put("F", new int[]{0,0,1,1,2}); // 样本量32 + AQL_TABLE.put("G", new int[]{0,1,1,2,3}); // 样本量50 + AQL_TABLE.put("H", new int[]{1,1,2,3,5}); // 样本量80 + AQL_TABLE.put("J", new int[]{1,2,3,5,7}); // 样本量125 + AQL_TABLE.put("K", new int[]{2,3,5,7,10}); // 样本量200 + AQL_TABLE.put("L", new int[]{3,5,7,10,14}); // 样本量315 + AQL_TABLE.put("M", new int[]{5,7,10,14,21}); // 样本量500 + AQL_TABLE.put("N", new int[]{7,10,14,21,21}); // 样本量800 + AQL_TABLE.put("P", new int[]{10,14,21,21,21}); // 样本量1250 + AQL_TABLE.put("Q", new int[]{14,21,21,21,21}); // 样本量2000 + } + private int lotSize; + private String inspectionLevel; + private double aqlValue; + private boolean strictInspection; + + public GB2828Sampler(int lotSize, String inspectionLevel, double aqlValue, boolean strictInspection) { + this.lotSize = lotSize; + this.inspectionLevel = inspectionLevel; + this.aqlValue = aqlValue; + this.strictInspection = strictInspection; + } + + public String getSampleSizeCode() { + // 根据批量范围和检验水平确定样本量字码 + if (inspectionLevel.equals("I")) { + if (lotSize >= 2 && lotSize <= 8) return "A"; + else if (lotSize >= 9 && lotSize <= 15) return "A"; + else if (lotSize >= 16 && lotSize <= 25) return "B"; + else if (lotSize >= 26 && lotSize <= 50) return "B"; + else if (lotSize >= 51 && lotSize <= 90) return "C"; + else if (lotSize >= 91 && lotSize <= 150) return "C"; + else if (lotSize >= 151 && lotSize <= 280) return "D"; + else if (lotSize >= 281 && lotSize <= 500) return "D"; + else if (lotSize >= 501 && lotSize <= 1200) return "E"; + else if (lotSize >= 1201 && lotSize <= 3200) return "E"; + else if (lotSize >= 3201 && lotSize <= 10000) return "F"; + else if (lotSize >= 10001 && lotSize <= 35000) return "F"; + else if (lotSize >= 35001 && lotSize <= 150000) return "G"; + else return "H"; + } + else if (inspectionLevel.equals("II")) { + if (lotSize >= 2 && lotSize <= 8) return "A"; + else if (lotSize >= 9 && lotSize <= 15) return "B"; + else if (lotSize >= 16 && lotSize <= 25) return "C"; + else if (lotSize >= 26 && lotSize <= 50) return "D"; + else if (lotSize >= 51 && lotSize <= 90) return "E"; + else if (lotSize >= 91 && lotSize <= 150) return "F"; + else if (lotSize >= 151 && lotSize <= 280) return "G"; + else if (lotSize >= 281 && lotSize <= 500) return "H"; + else if (lotSize >= 501 && lotSize <= 1200) return "J"; + else if (lotSize >= 1201 && lotSize <= 3200) return "K"; + else if (lotSize >= 3201 && lotSize <= 10000) return "L"; + else if (lotSize >= 10001 && lotSize <= 35000) return "M"; + else if (lotSize >= 35001 && lotSize <= 150000) return "N"; + else if (lotSize >= 150001 && lotSize <= 500000) return "P"; + else return "Q"; + } + else { // 检验水平III + if (lotSize >= 2 && lotSize <= 8) return "B"; + else if (lotSize >= 9 && lotSize <= 15) return "C"; + else if (lotSize >= 16 && lotSize <= 25) return "D"; + else if (lotSize >= 26 && lotSize <= 50) return "E"; + else if (lotSize >= 51 && lotSize <= 90) return "F"; + else if (lotSize >= 91 && lotSize <= 150) return "G"; + else if (lotSize >= 151 && lotSize <= 280) return "H"; + else if (lotSize >= 281 && lotSize <= 500) return "J"; + else if (lotSize >= 501 && lotSize <= 1200) return "K"; + else if (lotSize >= 1201 && lotSize <= 3200) return "L"; + else if (lotSize >= 3201 && lotSize <= 10000) return "M"; + else if (lotSize >= 10001 && lotSize <= 35000) return "N"; + else if (lotSize >= 35001 && lotSize <= 150000) return "P"; + else if (lotSize >= 150001 && lotSize <= 500000) return "Q"; + else return "R"; + } + } + + public int getSampleSize() { + String code = getSampleSizeCode(); + // 根据字码获取具体样本量 + switch(code) { + case "A": return 2; + case "B": return 3; + case "C": return 5; + case "D": return 8; + case "E": return 13; + case "F": return 20; + case "G": return 32; + case "H": return 50; + case "J": return 80; + case "K": return 125; + case "L": return 200; + case "M": return 315; + case "N": return 500; + case "P": return 800; + case "Q": return 1250; + case "R": return 2000; + default: return 125; // 默认返回检验水平II的中间值 + } + } + + public int[] getAcceptRejectNumbers() { + String code = getSampleSizeCode(); + int[] aqlValues = AQL_TABLE.get(code); + // 根据AQL值查找对应的接收/拒收数(GB/T 2828.1标准) + if (aqlValue <= 0.65) return new int[]{aqlValues[0], aqlValues[0]+1}; + else if (aqlValue <= 1.0) return new int[]{aqlValues[1], aqlValues[1]+1}; + else if (aqlValue <= 1.5) return new int[]{aqlValues[2], aqlValues[2]+1}; + else if (aqlValue <= 2.5) return new int[]{aqlValues[3], aqlValues[3]+1}; + else if (aqlValue <= 4.0) return new int[]{aqlValues[4], aqlValues[4]+1}; + else if (aqlValue <= 6.5) return new int[]{aqlValues[5], aqlValues[5]+1}; + else if (aqlValue <= 10.0) return new int[]{aqlValues[6], aqlValues[6]+1}; + else return new int[]{aqlValues[aqlValues.length-1], aqlValues[aqlValues.length-1]+1}; + } + + public boolean isLotAccepted(int defectCount) { + int[] acRe = getAcceptRejectNumbers(); + return defectCount <= acRe[0]; + } + + public static void main(String[] args) { + GB2828Sampler sampler = new GB2828Sampler(1000, "II", 1.0, false); + System.out.println("样本量字码: " + sampler.getSampleSizeCode()); + System.out.println("样本量: " + sampler.getSampleSize()); + int[] acRe = sampler.getAcceptRejectNumbers(); + System.out.println("接收数/拒收数: " + acRe[0] + "/" + acRe[1]); + } +}