From 94288b8314a4cdc9feedfba28292af41104aeaaf Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期六, 29 三月 2025 10:06:03 +0800 Subject: [PATCH] 检验任务数据预警 --- inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 118 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 91 insertions(+), 27 deletions(-) diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java index b57a72f..f8d709c 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java @@ -158,6 +158,11 @@ private ISysDictTypeService iSysDictTypeService; @Resource private InsOrderRatesService insOrderRatesService; + @Resource + private InsProductDeviationWarningService insProductDeviationWarningService; + @Resource + private InsProductDeviationWarningDetailService insProductDeviationWarningDetailService; + @Override public IPage<InsOrderPlanVO> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) { @@ -942,33 +947,10 @@ // 16 鍒ゆ柇褰撳墠鏍峰搧鏄惁涓哄師鏉愭枡, 鍘熸潗鏂欓渶瑕佽繘琛屾暟鎹垎鏋�, 鍒ゆ柇涔嬪墠10鏉℃暟鎹悓涓�涓緵搴斿晢, 鍚屼竴涓楠岄」鐨勫亸宸槸鍚﹁秴杩�10% // 鏌ヨifs淇℃伅鑾峰彇鑾峰彇鍓�10涓緵搴斿晢涓�鏍风殑, 妫�楠岄」涓�鏍蜂俊鎭� -// threadPoolTaskExecutor.execute(() -> { -// -// for (InsProduct insProduct : productList) { -// // todo: 鏆傛椂鍒ゆ柇鏄惁鏄�佸寲 -// if (insProduct.getInspectionItem().contains("鑰佸寲")) { -// List<InsProductAnalysisDto> insProductAnalysisDtoList = insProductMapper.selectAnalysis(insProduct, ifsInventoryQuantity.getSupplierName()); -// -// if (insProductAnalysisDtoList.size() < 10) { -// continue; -// } -// -// // 鍒ゆ柇褰撳墠妫�娴嬮」鏄惁鍋忓樊瓒呰繃10% -// List<String> laseValueList = insProductAnalysisDtoList.stream().map(InsProductAnalysisDto::getLastValue) -// .collect(Collectors.toList()); -// -// double deviation = isDeviationOverTenPercent(laseValueList, insProduct.getLastValue()); -// // 鍒ゆ柇鍋忓樊鏄惁澶т簬10 -// if (deviation > 10) { -// // 鍙戦�侀�氱煡, 骞朵笖娣诲姞鏁版嵁 -// -// -// -// -// } -// } -// } -// }); + threadPoolTaskExecutor.execute(() -> { + // 娣诲姞鍒嗘瀽鏁版嵁 + addAnalysis(productList, ifsInventoryQuantity, order); + }); } else { @@ -990,6 +972,88 @@ } /** + * *****娣诲姞鍒嗘瀽鏁版嵁****** + * @param productList + * @param ifsInventoryQuantity + * @param order + */ + private void addAnalysis(List<InsProduct> productList, IfsInventoryQuantity ifsInventoryQuantity, InsOrder order) { + for (InsProduct insProduct : productList) { + // todo: 鏆傛椂鍒ゆ柇鏄惁鏄�佸寲 + if (insProduct.getInspectionItem().contains("鑰佸寲")) { + List<InsProductDeviationWarningDetail> insProductAnalysisDtoList = insProductMapper.selectAnalysis(insProduct, ifsInventoryQuantity.getSupplierName()); + + if (insProductAnalysisDtoList.size() < 10) { + continue; + } + + // 鍒ゆ柇褰撳墠妫�娴嬮」鏄惁鍋忓樊瓒呰繃10% + List<String> laseValueList = insProductAnalysisDtoList.stream().map(InsProductDeviationWarningDetail::getTestValue) + .collect(Collectors.toList()); + + double deviation = isDeviationOverTenPercent(laseValueList, insProduct.getLastValue()); + // 鍒ゆ柇鍋忓樊鏄惁澶т簬10 + if (deviation > 10) { + // 鍒ゆ柇涔嬪墠鏄惁娣诲姞杩�, 娣诲姞杩囦笉闇�瑕佹坊鍔� + long count = insProductDeviationWarningService.count(Wrappers.<InsProductDeviationWarning>lambdaQuery() + .eq(InsProductDeviationWarning::getInsProductId, insProduct.getId())); + if (count == 0L) { + // 鍙戦�侀�氱煡, 骞朵笖娣诲姞鏁版嵁 + // 娣诲姞涓昏〃淇℃伅 + InsProductDeviationWarning deviationWarning = new InsProductDeviationWarning(); + deviationWarning.setInsOrderId(order.getId()); + deviationWarning.setInsSampleId(insProduct.getInsSampleId()); + deviationWarning.setInsProductId(insProduct.getId()); + deviationWarning.setEntrustCode(order.getEntrustCode()); + deviationWarning.setSampleCode(insProduct.getSampleCode()); + deviationWarning.setSupplierName(ifsInventoryQuantity.getSupplierName()); + deviationWarning.setDeviationValue(Double.toString(deviation)); + deviationWarning.setDetectionTime(insProduct.getUpdateTime()); + insProductDeviationWarningService.save(deviationWarning); + + // 娣诲姞璇︽儏鏁版嵁 + InsProductDeviationWarningDetail deviationWarningDetail = new InsProductDeviationWarningDetail(); + deviationWarningDetail.setInsOrderId(order.getId()); + deviationWarningDetail.setInsSampleId(insProduct.getInsSampleId()); + deviationWarningDetail.setInsProductId(insProduct.getId()); + deviationWarningDetail.setEntrustCode(order.getEntrustCode()); + deviationWarningDetail.setSampleCode(insProduct.getSampleCode()); + deviationWarningDetail.setSupplierName(ifsInventoryQuantity.getSupplierName()); + deviationWarningDetail.setTestValue(insProduct.getLastValue()); + deviationWarningDetail.setIsIssue(1); + + insProductAnalysisDtoList.add(deviationWarningDetail); + + // 娣诲姞id + for (InsProductDeviationWarningDetail warningDetail : insProductAnalysisDtoList) { + warningDetail.setDeviationWarningId(deviationWarning.getDeviationWarningId()); + } + + insProductDeviationWarningDetailService.saveBatch(insProductAnalysisDtoList); + + +// String message = ""; +// message += "妫�楠屼换鍔″鏍搁�氱煡"; +// message += "\n鎻愪氦浜�: " + userName; +// message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); +// message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); +// message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); +// if (ifsInventoryQuantity != null) { +// message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); +// } +// //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 +// try { +// WxCpUtils.inform(sendUserAccount, message, null); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } + } + } + } + } + } + + /** * *****璁$畻鍋忓樊**** * @param data * @param targetStr -- Gitblit v1.9.3