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 | 112 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 91 insertions(+), 21 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 d69da06..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,23 +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());
-//
-// // 鍒ゆ柇褰撳墠妫�娴嬮」鏄惁鍋忓樊瓒呰繃10%
-// List<String> laseValueList = insProductAnalysisDtoList.stream().map(InsProductAnalysisDto::getLastValue)
-// .collect(Collectors.toList());
-//
-//
-//
-//
-// }
-// }
-// });
+ threadPoolTaskExecutor.execute(() -> {
+ // 娣诲姞鍒嗘瀽鏁版嵁
+ addAnalysis(productList, ifsInventoryQuantity, order);
+ });
} else {
@@ -977,6 +969,88 @@
}
return 1;
+ }
+
+ /**
+ * *****娣诲姞鍒嗘瀽鏁版嵁******
+ * @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);
+// }
+ }
+ }
+ }
+ }
}
/**
@@ -1953,10 +2027,6 @@
ConfigureBuilder builder = Configure.builder();
builder.useSpringEL(true);
- // 鑾峰彇褰撳墠鏃堕棿
- LocalDate currentDate = LocalDate.now();
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- String formattedDate = currentDate.format(formatter);
InputStream inputStream = this.getClass().getResourceAsStream("/static/small-report-template.docx");
XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render(
--
Gitblit v1.9.3