From debefdc14d731488381be10cf7193fa54213b155 Mon Sep 17 00:00:00 2001 From: Yangwl <1726150332@qq.com> Date: Tue, 29 Jul 2025 16:01:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A8=E9=87=8F=E6=8A=BD=E6=A0=B7=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E6=96=B9=E6=B3=95=E4=BF=AE=E6=94=B9=EF=BC=8C=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E8=BF=90=E8=A1=8C=E6=97=B6=E9=97=B4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../op/device/mapper/EquOperationMapper.java | 2 +- .../impl/EquRepairWorkOrderServiceImpl.java | 32 +- .../mapper/device/EquEquipmentMapper.xml | 2 +- .../controller/WCSInterfaceController.java | 9 + .../op/mes/service/IWCSInterfaceService.java | 2 + .../service/impl/IWCInterfaceServiceImpl.java | 45 ++- .../com/op/quality/config/GB2828Sampler.java | 340 +++++++++--------- .../op/quality/domain/QcCheckTaskDetail.java | 27 ++ .../op/quality/domain/QcCheckTypeProject.java | 19 + .../service/impl/QcProCheckServiceImpl.java | 10 + .../quality/QcCheckTaskIncomeMapper.xml | 6 +- .../quality/QcCheckTypeProjectMapper.xml | 11 +- 12 files changed, 300 insertions(+), 205 deletions(-) diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquOperationMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquOperationMapper.java index 8843f594d..e51fe0cc0 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquOperationMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquOperationMapper.java @@ -97,6 +97,6 @@ public interface EquOperationMapper { String getInfoByUserName(String part); - public EquOperation selectEquOperationByCode(EquOperation equOperation); + public List selectEquOperationByCode(EquOperation equOperation); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquRepairWorkOrderServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquRepairWorkOrderServiceImpl.java index dfd0752ca..d5a162ab9 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquRepairWorkOrderServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquRepairWorkOrderServiceImpl.java @@ -795,15 +795,13 @@ public class EquRepairWorkOrderServiceImpl implements IEquRepairWorkOrderService } @Override - @DS("#header.poolName") public AjaxResult updateDeviceRunTimeORRate(Map map) { //查询产线绑定的设备情况 - DynamicDataSourceContextHolder.push("ds_1000"); try { + DynamicDataSourceContextHolder.push("ds_1000"); List mapList = equEquipmentMapper.selectAuxiliaryEquipmentList(map); EquOperation equOperation=new EquOperation(); for (Map mas:mapList){ - System.out.println(); //查询设备有没有生成记录 String equipmentCode = mas.get("equipmentCode").toString(); String Time = map.get("productDate").toString(); @@ -811,20 +809,22 @@ public class EquRepairWorkOrderServiceImpl implements IEquRepairWorkOrderService LocalDate localDate = LocalDate.parse(Time, formatter); equOperation.setCreateTime(java.sql.Date.valueOf(localDate)); equOperation.setEquipmentCode(equipmentCode); - EquOperation operation = equOperationMapper.selectEquOperationByCode(equOperation); + List operationList = equOperationMapper.selectEquOperationByCode(equOperation); DecimalFormat df = new DecimalFormat("#.##"); - if (operation!=null){ - //更新运行时间以及实际运行时间、故障率 - equOperation.setId(operation.getId()); - equOperation.setOperationTime(map.get("RunTime").toString()); - //实际运行时间 = 实际运行时间 - 故障时间 - double result = Double.parseDouble(map.get("RunTime").toString()) - Double.parseDouble(operation.getFaultTime()); - equOperation.setActualOperationTime(String.valueOf(df.format(result))); - //故障率计算(故障时间/运行时间) - BigDecimal faultTimeBD = new BigDecimal(operation.getFaultTime()); - BigDecimal operationTimeBD = new BigDecimal(equOperation.getOperationTime());//运行时间 - equOperation.setFailureRate(faultTimeBD.multiply(new BigDecimal(100)).divide(operationTimeBD, 2, RoundingMode.HALF_UP).toString() + "%"); - equOperationMapper.updateEquOperation(equOperation); + if (operationList!=null && operationList.size()>=0){ + for (EquOperation operation : operationList){ + //更新运行时间以及实际运行时间、故障率 + equOperation.setId(operation.getId()); + equOperation.setOperationTime(map.get("RunTime").toString()); + //实际运行时间 = 实际运行时间 - 故障时间 + double result = Double.parseDouble(map.get("RunTime").toString()) - Double.parseDouble(operation.getFaultTime()); + equOperation.setActualOperationTime(String.valueOf(df.format(result))); + //故障率计算(故障时间/运行时间) + BigDecimal faultTimeBD = new BigDecimal(operation.getFaultTime()); + BigDecimal operationTimeBD = new BigDecimal(equOperation.getOperationTime());//运行时间 + equOperation.setFailureRate(faultTimeBD.multiply(new BigDecimal(100)).divide(operationTimeBD, 2, RoundingMode.HALF_UP).toString() + "%"); + equOperationMapper.updateEquOperation(equOperation); + } } } }catch (Exception e){ diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquEquipmentMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquEquipmentMapper.xml index 03cd97296..a76f4f519 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquEquipmentMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquEquipmentMapper.xml @@ -313,7 +313,7 @@ and be.del_flag = '0' - select ebac.auxiliary_equipment_code AS equipmentCode, be.equipment_name AS equipmentName, diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/WCSInterfaceController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/WCSInterfaceController.java index ac7a5b65d..3f9ecc2d1 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/WCSInterfaceController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/WCSInterfaceController.java @@ -186,4 +186,13 @@ public class WCSInterfaceController extends BaseController { public AjaxResult changeTransferResultTask() { return wCInterfaceService.changeTransferResultTask(); } + + /** + * 更新设备运行时间 + * @return + */ + @PostMapping("/updateResouceRunTime") + public AjaxResult updateResouceRunTime(@RequestBody Map map) { + return wCInterfaceService.updateResouceRunTime(map); + } } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IWCSInterfaceService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IWCSInterfaceService.java index 2453036a6..5c6f4b83e 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IWCSInterfaceService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IWCSInterfaceService.java @@ -48,4 +48,6 @@ public interface IWCSInterfaceService { Map getWhiteBoardEquPro7Days(BoardDTO boardDTO); Map getWhiteBoardProdDetails(Map paramMap); + + AjaxResult updateResouceRunTime(Map map); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java index f47a44a79..f1c7b587a 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java @@ -483,6 +483,14 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { sHzWorks.setMachineCode(mesReportWork.getMachineCode()); sapRson = this.reportHzToSap(sHzWorks); logger.info("==========================一层工单报工结束:"+JSONObject.toJSONString(sapRson)); + //更新产线设备运行时间,故障率 + logger.info("==========================更新产线设备运行时间,故障率开始"); + Map updateDeviceParam=new HashMap(); + updateDeviceParam.put("RunTime",mesReportWork.getWorkTime()); + updateDeviceParam.put("equipmentCode",mesReportWork.getMachineCode()); + updateDeviceParam.put("productDate",mesReportWork.getProductDate()); + R rs = remoteDeviceService.updateDeviceRunTimeORRate(updateDeviceParam); + logger.info("==========================更新产线设备运行时间,故障率结束:结果"+ rs.getMsg()); }else if(workOrders.size()==2){ /**(两层报工)子工单先报工,然后母工单报工**/ mesReportWork.setUploadStatus("1");//除了1报工成功的,都需要报工 @@ -536,6 +544,14 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { //pHzWork.setSac2("4");//母单报工固定值(上位机插入数据时候默认4) R sapR = this.reportHzToSap(pHzWork); logger.info("==========================母工单报工结束"+JSONObject.toJSONString(sapR)); + //更新产线设备运行时间,故障率 + logger.info("==========================更新产线设备运行时间,故障率开始"); + Map updateDeviceParam=new HashMap(); + updateDeviceParam.put("RunTime",mesReportWork.getWorkTime()); + updateDeviceParam.put("equipmentCode",mesReportWork.getMachineCode()); + updateDeviceParam.put("productDate",mesReportWork.getProductDate()); + R rs = remoteDeviceService.updateDeviceRunTimeORRate(updateDeviceParam); + logger.info("==========================更新产线设备运行时间,故障率结束:结果"+ rs.getMsg()); return sapR; } @@ -595,15 +611,15 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { break; } } + //更新产线设备运行时间,故障率 + logger.info("==========================更新产线设备运行时间,故障率开始"); + Map updateDeviceParam=new HashMap(); + updateDeviceParam.put("RunTime",mesReportWork.getWorkTime()); + updateDeviceParam.put("equipmentCode",mesReportWork.getMachineCode()); + updateDeviceParam.put("productDate",mesReportWork.getProductDate()); + R rs = remoteDeviceService.updateDeviceRunTimeORRate(updateDeviceParam); + logger.info("==========================更新产线设备运行时间,故障率结束:结果"+ rs.getMsg()); } - //更新产线设备运行时间,故障率 - logger.info("==========================更新产线设备运行时间,故障率开始"); - Map updateDeviceParam=new HashMap(); - updateDeviceParam.put("RunTime",mesReportWork.getWorkTime()); - updateDeviceParam.put("equipmentCode",mesReportWork.getMachineCode()); - updateDeviceParam.put("productDate",mesReportWork.getProductDate()); - R rs = remoteDeviceService.updateDeviceRunTimeORRate(updateDeviceParam); - logger.info("==========================更新产线设备运行时间,故障率结束:结果"+ rs.getMsg()); return sapRson; } catch (Exception e) { return R.fail("报工失败:"+e.getMessage()); @@ -815,6 +831,19 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { return resultMap; } + @Override + public AjaxResult updateResouceRunTime(Map map) { + //更新产线设备运行时间,故障率 + logger.info("==========================更新产线设备运行时间,故障率开始"); + Map updateDeviceParam=new HashMap(); + updateDeviceParam.put("RunTime",map.get("RunTime")); + updateDeviceParam.put("equipmentCode",map.get("equipmentCode")); + updateDeviceParam.put("productDate",map.get("productDate")); + R rs = remoteDeviceService.updateDeviceRunTimeORRate(updateDeviceParam); + logger.info("==========================更新产线设备运行时间,故障率结束:结果"+ rs.getMsg()); + return AjaxResult.success(rs.getMsg()); + } + protected List get7Days(){ List days = new ArrayList<>(); // 获取当前日期 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 index e215f69d5..4033e9340 100644 --- 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 @@ -4,193 +4,183 @@ 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<>(); + private static final Map CODE_MAP = new HashMap<>(); + private static final Map SAMPLE_SIZE_MAP = new HashMap<>(); + private 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; + // 初始化样本量字码表 + initCodeMap(); + // 初始化样本量表 + initSampleSizeMap(); + // 初始化AQL表 + initAqlTable(); } - 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"; + private static void initCodeMap() { + +// 常规检验水平(I/II/III) + CODE_MAP.put("2-8_I", "A"); CODE_MAP.put("2-8_II", "A"); CODE_MAP.put("2-8_III", "B"); + CODE_MAP.put("9-15_I", "B"); CODE_MAP.put("9-15_II", "B"); CODE_MAP.put("9-15_III", "C"); + CODE_MAP.put("16-25_I", "C"); CODE_MAP.put("16-25_II", "C"); CODE_MAP.put("16-25_III", "D"); + CODE_MAP.put("26-50_I", "D"); CODE_MAP.put("26-50_II", "D"); CODE_MAP.put("26-50_III", "E"); + CODE_MAP.put("51-90_I", "E"); CODE_MAP.put("51-90_II", "E"); CODE_MAP.put("51-90_III", "F"); + CODE_MAP.put("91-150_I", "F"); CODE_MAP.put("91-150_II", "F"); CODE_MAP.put("91-150_III", "G"); + CODE_MAP.put("151-280_I", "G"); CODE_MAP.put("151-280_II", "G"); CODE_MAP.put("151-280_III", "H"); + CODE_MAP.put("281-500_I", "H"); CODE_MAP.put("281-500_II", "H"); CODE_MAP.put("281-500_III", "J"); + CODE_MAP.put("501-1200_I", "J"); CODE_MAP.put("501-1200_II", "J"); CODE_MAP.put("501-1200_III", "K"); + CODE_MAP.put("1201-3200_I", "K"); CODE_MAP.put("1201-3200_II", "K"); CODE_MAP.put("1201-3200_III", "L"); + CODE_MAP.put("3201-10000_I", "L"); CODE_MAP.put("3201-10000_II", "L"); CODE_MAP.put("3201-10000_III", "M"); + CODE_MAP.put("10001-35000_I", "M"); CODE_MAP.put("10001-35000_II", "M"); CODE_MAP.put("10001-35000_III", "N"); + CODE_MAP.put("35001-150000_I", "N"); CODE_MAP.put("35001-150000_II", "N"); CODE_MAP.put("35001-150000_III", "P"); + CODE_MAP.put("150001-500000_I", "P"); CODE_MAP.put("150001-500000_II", "P"); CODE_MAP.put("150001-500000_III", "Q"); + CODE_MAP.put("500001+_I", "Q"); CODE_MAP.put("500001+_II", "Q"); CODE_MAP.put("500001+_III", "R"); + +// 特殊检验水平(S1-S4) + CODE_MAP.put("2-8_S1", "A"); CODE_MAP.put("2-8_S2", "A"); CODE_MAP.put("2-8_S3", "A"); CODE_MAP.put("2-8_S4", "A"); + CODE_MAP.put("9-15_S1", "A"); CODE_MAP.put("9-15_S2", "A"); CODE_MAP.put("9-15_S3", "B"); CODE_MAP.put("9-15_S4", "B"); + CODE_MAP.put("16-25_S1", "A"); CODE_MAP.put("16-25_S2", "B"); CODE_MAP.put("16-25_S3", "B"); CODE_MAP.put("16-25_S4", "C"); + CODE_MAP.put("26-50_S1", "B"); CODE_MAP.put("26-50_S2", "B"); CODE_MAP.put("26-50_S3", "C"); CODE_MAP.put("26-50_S4", "D"); + CODE_MAP.put("51-90_S1", "B"); CODE_MAP.put("51-90_S2", "C"); CODE_MAP.put("51-90_S3", "D"); CODE_MAP.put("51-90_S4", "E"); + CODE_MAP.put("91-150_S1", "B"); CODE_MAP.put("91-150_S2", "C"); CODE_MAP.put("91-150_S3", "E"); CODE_MAP.put("91-150_S4", "F"); + CODE_MAP.put("151-280_S1", "C"); CODE_MAP.put("151-280_S2", "D"); CODE_MAP.put("151-280_S3", "F"); CODE_MAP.put("151-280_S4", "G"); + CODE_MAP.put("281-500_S1", "C"); CODE_MAP.put("281-500_S2", "E"); CODE_MAP.put("281-500_S3", "G"); CODE_MAP.put("281-500_S4", "H"); + CODE_MAP.put("501-1200_S1", "D"); CODE_MAP.put("501-1200_S2", "F"); CODE_MAP.put("501-1200_S3", "H"); CODE_MAP.put("501-1200_S4", "J"); + CODE_MAP.put("1201-3200_S1", "D"); CODE_MAP.put("1201-3200_S2", "G"); CODE_MAP.put("1201-3200_S3", "J"); CODE_MAP.put("1201-3200_S4", "K"); + CODE_MAP.put("3201-10000_S1", "E"); CODE_MAP.put("3201-10000_S2", "H"); CODE_MAP.put("3201-10000_S3", "K"); CODE_MAP.put("3201-10000_S4", "L"); + CODE_MAP.put("10001-35000_S1", "E"); CODE_MAP.put("10001-35000_S2", "J"); CODE_MAP.put("10001-35000_S3", "L"); CODE_MAP.put("10001-35000_S4", "M"); + CODE_MAP.put("35001-150000_S1", "F"); CODE_MAP.put("35001-150000_S2", "K"); CODE_MAP.put("35001-150000_S3", "M"); CODE_MAP.put("35001-150000_S4", "N"); + CODE_MAP.put("150001-500000_S1", "G"); CODE_MAP.put("150001-500000_S2", "L"); CODE_MAP.put("150001-500000_S3", "N"); CODE_MAP.put("150001-500000_S4", "P"); + CODE_MAP.put("500001+_S1", "H"); CODE_MAP.put("500001+_S2", "M"); CODE_MAP.put("500001+_S3", "P"); CODE_MAP.put("500001+_S4", "Q"); + + } + + + private static void initSampleSizeMap() { + SAMPLE_SIZE_MAP.put("A", new int[]{0,0,0,1,1,2,3,5,7,10,14,21}); + SAMPLE_SIZE_MAP.put("B", new int[]{0,0,1,2,3,5,7,10,14,21,30,42}); + SAMPLE_SIZE_MAP.put("C", new int[]{0,1,2,3,5,7,10,14,21,30,42,60}); + SAMPLE_SIZE_MAP.put("D", new int[]{1,1,3,5,7,10,14,21,30,42,60,90}); + SAMPLE_SIZE_MAP.put("E", new int[]{2,3,5,7,10,14,21,30,42,60,90,150}); + SAMPLE_SIZE_MAP.put("F", new int[]{3,5,7,10,14,21,30,42,60,90,150,240}); + SAMPLE_SIZE_MAP.put("G", new int[]{5,7,10,14,21,30,42,60,90,150,240,360}); + SAMPLE_SIZE_MAP.put("H", new int[]{7,10,14,21,30,42,60,90,150,240,360,540}); + SAMPLE_SIZE_MAP.put("J", new int[]{10,14,21,30,42,60,90,150,240,360,540,800}); + SAMPLE_SIZE_MAP.put("K", new int[]{14,21,30,42,60,90,150,240,360,540,800,1200}); + SAMPLE_SIZE_MAP.put("L", new int[]{21,30,42,60,90,150,240,360,540,800,1200,1800}); + SAMPLE_SIZE_MAP.put("M", new int[]{30,42,60,90,150,240,360,540,800,1200,1800,3000}); + SAMPLE_SIZE_MAP.put("N", new int[]{42,60,90,150,240,360,540,800,1200,1800,3000,4500}); + SAMPLE_SIZE_MAP.put("P", new int[]{60,90,150,240,360,540,800,1200,1800,3000,4500,7000}); + SAMPLE_SIZE_MAP.put("Q", new int[]{90,150,240,360,540,800,1200,1800,3000,4500,7000,10000}); + SAMPLE_SIZE_MAP.put("R", new int[]{150,240,360,540,800,1200,1800,3000,4500,7000,10000,15000}); + } + + + private static void initAqlTable() { + // 数组元素对应标准AQL值:0.065,0.10,0.15,0.25,0.40,0.65,1.0,1.5,2.5,4.0,6.5 + AQL_TABLE.put("A", new int[]{0,0,1,1,2,3,5,7,10,14,21}); + AQL_TABLE.put("B", new int[]{0,1,1,2,3,5,7,10,14,21,30}); + AQL_TABLE.put("C", new int[]{0,1,2,3,5,7,10,14,21,30,42}); + AQL_TABLE.put("D", new int[]{1,1,2,3,5,7,10,14,21,30,42}); + AQL_TABLE.put("E", new int[]{1,2,3,5,7,10,14,21,30,42,60}); + AQL_TABLE.put("F", new int[]{2,3,5,7,10,14,21,30,42,60,80}); + AQL_TABLE.put("G", new int[]{3,5,7,10,14,21,30,42,60,80,120}); + AQL_TABLE.put("H", new int[]{5,7,10,14,21,30,42,60,80,120,180}); + AQL_TABLE.put("J", new int[]{7,10,14,21,30,42,60,80,120,180,280}); + AQL_TABLE.put("K", new int[]{10,14,21,30,42,60,80,120,180,280,400}); + AQL_TABLE.put("L", new int[]{14,21,30,42,60,80,120,180,280,400,600}); + AQL_TABLE.put("M", new int[]{21,30,42,60,80,120,180,280,400,600,800}); + AQL_TABLE.put("N", new int[]{30,42,60,80,120,180,280,400,600,800,1200}); + AQL_TABLE.put("P", new int[]{42,60,80,120,180,280,400,600,800,1200,1800}); + AQL_TABLE.put("Q", new int[]{60,80,120,180,280,400,600,800,1200,1800,2500}); + AQL_TABLE.put("R", new int[]{80,120,180,280,400,600,800,1200,1800,2500,3200}); + } + + public SamplingResult getSamplingPlan(int lotSize, String level, double aql) { + String code = determineCode(lotSize, level); + int sampleSize = determineSampleSize(code, level); + int[] acRe = determineAcReNumbers(code, aql); + return new SamplingResult(code, sampleSize, acRe[0], acRe[1]); + } + + private String determineCode(int lotSize, String level) { + String range = getRange(lotSize); + return CODE_MAP.getOrDefault(range + "_" + level, "K"); + } + + private String getRange(int size) { + if (size >= 2 && size <= 8) return "2-8"; + else if (size >= 9 && size <= 15) return "9-15"; + else if (size >= 16 && size <= 25) return "16-25"; + else if (size >= 26 && size <= 50) return "26-50"; + else if (size >= 51 && size <= 90) return "51-90"; + else if (size >= 91 && size <= 150) return "91-150"; + else if (size >= 151 && size <= 280) return "151-280"; + else if (size >= 281 && size <= 500) return "281-500"; + else if (size >= 501 && size <= 1200) return "501-1200"; + else if (size >= 1201 && size <= 3200) return "1201-3200"; + else if (size >= 3201 && size <= 10000) return "3201-10000"; + else if (size >= 10001 && size <= 35000) return "10001-35000"; + else if (size >= 35001 && size <= 150000) return "35001-150000"; + else if (size >= 150001 && size <= 500000) return "150001-500000"; + else return "500001+"; + } + + private int determineSampleSize(String code, String level) { + int[] sizes = SAMPLE_SIZE_MAP.get(code); + switch(level) { + case "I": case "S1": case "S2": return sizes[0]; + case "II": case "S3": return sizes[1]; + case "III": case "S4": return sizes[2]; + default: return sizes[1]; } } - 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(); + private int[] determineAcReNumbers(String code, double aql) { 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}; + if (aql <= 0.065) return new int[]{aqlValues[0], aqlValues[0]+1}; + else if (aql <= 0.10) return new int[]{aqlValues[1], aqlValues[1]+1}; + else if (aql <= 0.15) return new int[]{aqlValues[2], aqlValues[2]+1}; + else if (aql <= 0.25) return new int[]{aqlValues[3], aqlValues[3]+1}; + else if (aql <= 0.40) return new int[]{aqlValues[4], aqlValues[4]+1}; + else if (aql <= 0.65) return new int[]{aqlValues[5], aqlValues[5]+1}; + else if (aql <= 1.0) return new int[]{aqlValues[6], aqlValues[6]+1}; + else if (aql <= 1.5) return new int[]{aqlValues[7], aqlValues[7]+1}; + else if (aql <= 2.5) return new int[]{aqlValues[8], aqlValues[8]+1}; + else if (aql <= 4.0) return new int[]{aqlValues[9], aqlValues[9]+1}; + else if (aql <= 6.5) return new int[]{aqlValues[10], aqlValues[10]+1}; + else return new int[]{aqlValues[11], aqlValues[11]+1}; } - public boolean isLotAccepted(int defectCount) { - int[] acRe = getAcceptRejectNumbers(); - return defectCount <= acRe[0]; + public static class SamplingResult { + public final String code; + public final int sampleSize; + public final int acceptNumber; + public final int rejectNumber; + + public SamplingResult(String code, int sampleSize, int acceptNumber, int rejectNumber) { + this.code = code; + this.sampleSize = sampleSize; + this.acceptNumber = acceptNumber; + this.rejectNumber = rejectNumber; + } } 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]); + GB2828Sampler sampler = new GB2828Sampler(); + + // 常规检验水平II示例 + GB2828Sampler.SamplingResult normalResult = + sampler.getSamplingPlan(5000 ,"III", 0.0); + System.out.println("常规检验: " + normalResult.code + " " + + normalResult.sampleSize + " " + normalResult.acceptNumber); + + // 特殊检验水平S2示例 + GB2828Sampler.SamplingResult specialResult = + sampler.getSamplingPlan(1500, "S4", 1.0); + System.out.println("特殊检验: " + specialResult.code + " " + + specialResult.sampleSize + " " + specialResult.acceptNumber); } + + } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcCheckTaskDetail.java b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcCheckTaskDetail.java index fd418b716..2bf830900 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcCheckTaskDetail.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcCheckTaskDetail.java @@ -147,6 +147,33 @@ public class QcCheckTaskDetail extends BaseEntity { private String sampleQuality; private String sampleAql; private String checkLevel; + private String samplingPlan; + private String defectCategory; + private BigDecimal quality; + + public BigDecimal getQuality() { + return quality; + } + + public void setQuality(BigDecimal quality) { + this.quality = quality; + } + + public String getSamplingPlan() { + return samplingPlan; + } + + public void setSamplingPlan(String samplingPlan) { + this.samplingPlan = samplingPlan; + } + + public String getDefectCategory() { + return defectCategory; + } + + public void setDefectCategory(String defectCategory) { + this.defectCategory = defectCategory; + } public String getClassTypeCodes() { return classTypeCodes; diff --git a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcCheckTypeProject.java b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcCheckTypeProject.java index 73adbf713..74c44eb29 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcCheckTypeProject.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcCheckTypeProject.java @@ -114,6 +114,25 @@ public class QcCheckTypeProject extends BaseEntity { private String itemType; private String judgeRate; + private String samplingPlan; + private String defectCategory; + + public String getSamplingPlan() { + return samplingPlan; + } + + public void setSamplingPlan(String samplingPlan) { + this.samplingPlan = samplingPlan; + } + + public String getDefectCategory() { + return defectCategory; + } + + public void setDefectCategory(String defectCategory) { + this.defectCategory = defectCategory; + } + public String getItemType() { return itemType; } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcProCheckServiceImpl.java b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcProCheckServiceImpl.java index a5bdea7c7..de8fb8be9 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcProCheckServiceImpl.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcProCheckServiceImpl.java @@ -9,6 +9,7 @@ import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.uuid.IdUtils; import com.op.common.security.utils.SecurityUtils; +import com.op.quality.config.GB2828Sampler; import com.op.quality.domain.*; import com.op.quality.mapper.QMSFileMapper; import com.op.quality.mapper.QcCheckTaskDefectMapper; @@ -23,6 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestBody; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.*; @@ -243,6 +245,14 @@ public class QcProCheckServiceImpl implements QcProCheckService { qcd.setDefectQualitys(defectInfo.getDefectQualitys()); qcd.setClassTypeCodes(defectInfo.getClassId()); } + if (StringUtils.isNotBlank(qcd.getSamplingPlan())&&StringUtils.isNotBlank(qcd.getDefectCategory())){ + GB2828Sampler sampler = new GB2828Sampler(); + // 常规检验水平II示例 + GB2828Sampler.SamplingResult normalResult = + sampler.getSamplingPlan(qcd.getQuality().setScale(0, RoundingMode.HALF_UP).intValue(),qcd.getSamplingPlan(), Double.valueOf(qcd.getDefectCategory())); + + qcd.setSampleQuality(String.valueOf(normalResult.acceptNumber)); + } } dto.setQcCheckTaskDetails(qcCheckTaskDetails); diff --git a/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskIncomeMapper.xml b/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskIncomeMapper.xml index 8a3604f09..510b717d1 100644 --- a/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskIncomeMapper.xml +++ b/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskIncomeMapper.xml @@ -156,14 +156,18 @@ td.defect_code defectCode, td.defect_quality defectQuality, td.sample_code sampleCode, + qct.quality quality, td.sample_quality sampleQuality, td.sample_aql sampleAql, td.check_level checkLevel, qctp.upper_diff upperDiff, qctp.down_diff downDiff, qctp.sample, - qctp.weight + qctp.weight, + qctp.sampling_plan samplingPlan, + qctp.defect_category defectCategory from qc_check_task_detail td + LEFT JOIN qc_check_task qct ON td.belong_to= qct.record_id left join qc_check_type_project qctp on td.type_project_id = qctp.id left join lanju_op_cloud.dbo.sys_dict_data dic on dic.dict_value = td.unit_code and dic.status ='0' and dic.dict_type = 'unit' where td.belong_to = #{belongTo} and td.del_flag='0' and qctp.del_flag = '0' and td.rule_name is not null diff --git a/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTypeProjectMapper.xml b/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTypeProjectMapper.xml index bf4eb1f8d..7af66c812 100644 --- a/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTypeProjectMapper.xml +++ b/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTypeProjectMapper.xml @@ -29,13 +29,14 @@ - + + select id, project_id, type_id, standard_value, upper_diff, down_diff, sample, status, attr1, create_by, create_time, update_by, update_time, factory_code, del_flag, group_id, - material_code, sample_num,unit,sort + material_code, sample_num,unit,sort,sampling_plan,defect_category from qc_check_type_project @@ -79,7 +80,9 @@ ctp.factory_code,ctp.del_flag, ctp.group_id,ctp.material_code, ctp.sample_num,ctp.sort,ctp.weight, - ctp.unit + ctp.unit, + ctp.sampling_plan, + ctp.defect_category FROM qc_check_type_project ctp LEFT JOIN qc_check_project cp ON ctp.project_id = cp.id AND cp.del_flag = '0' WHERE ctp.del_flag ='0' AND ctp.id = #{id} @@ -257,6 +260,8 @@ property_code = #{propertyCode}, sort = #{sort}, weight = #{weight}, + sampling_plan = #{samplingPlan}, + defect_category = #{defectCategory}, where id = #{id}