From a120fea377cef686d37d7adfe34b553a48250812 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期三, 03 九月 2025 17:36:56 +0800
Subject: [PATCH] 检验项中英文去除多余的空格

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java |   39 +++++++++++++++++++++++++++++----------
 1 files changed, 29 insertions(+), 10 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 f91b9bd..351fae1 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
@@ -502,18 +502,16 @@
 
                 // 娣诲姞宸ユ椂
                 // 鍒ゆ柇鏄惁鍙槸鍙備笌璁$畻鍊�, 鍙備笌璁$畻鍊煎疄闄呮病鏈夊~鍐�
+                InsProduct finalInsProduct = insProductMapper.selectById(product.getId());
+                InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
                 if (StringUtils.isNotBlank(newResult.getInsValue()) && !newResult.getInsValue().equals("[]")) {
                     threadPoolTaskExecutor.execute(() -> {
-                        InsProduct finalInsProduct = insProductMapper.selectById(product.getId());
-                        InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
                         this.addAuxiliary(userId, finalInsProduct, insOrder);
                     });
                 } else {
                     // 鍒ゆ柇鏄惁鏄病鏈夋楠屽�肩殑鍐呭
                     if (saveInsContextDto.getIsNoTestValue() != null && saveInsContextDto.getIsNoTestValue() == 1) {
                         threadPoolTaskExecutor.execute(() -> {
-                            InsProduct finalInsProduct = insProductMapper.selectById(product.getId());
-                            InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
                             this.addAuxiliary(userId, finalInsProduct, insOrder);
                         });
                     }
@@ -968,7 +966,7 @@
             if (insProduct.getInspectionValueType().equals("1") && insProduct.getInsResult().equals(1)) {
                 List<InsProductDeviationWarningDetail> insProductAnalysisDtoList = insProductMapper.selectAnalysis(insProduct, ifsInventoryQuantity.getSupplierName());
 
-                if (insProductAnalysisDtoList.size() < 10) {
+                if (CollectionUtils.isEmpty(insProductAnalysisDtoList)) {
                     continue;
                 }
 
@@ -977,8 +975,10 @@
                         .collect(Collectors.toList());
 
                 double deviation = isDeviationOverTenPercent(laseValueList, insProduct.getLastValue());
+                // 鍒ゆ柇瑕佹眰鍊兼槸鍚﹀亸宸秴杩�10%
+                double asked = isDeviationOverTenPercentByAsked(insProduct.getAsk(), insProduct.getLastValue());
                 // 鍒ゆ柇鍋忓樊鏄惁澶т簬10
-                if (deviation > 10) {
+                if (deviation > 10 || asked > 10) {
                     // 鍒ゆ柇涔嬪墠鏄惁娣诲姞杩�, 娣诲姞杩囦笉闇�瑕佹坊鍔�
                     long count = insProductDeviationWarningService.count(Wrappers.<InsProductDeviationWarning>lambdaQuery()
                             .eq(InsProductDeviationWarning::getInsProductId, insProduct.getId()));
@@ -1006,7 +1006,8 @@
                         deviationWarningDetail.setSupplierName(ifsInventoryQuantity.getSupplierName());
                         deviationWarningDetail.setTestValue(insProduct.getLastValue());
                         deviationWarningDetail.setDetectionTime(insProduct.getCreateTime());
-                        deviationWarningDetail.setIsIssue(1);
+                        deviationWarningDetail.setIsIssue(deviation > 10 ? 1 : 0);
+                        deviationWarningDetail.setIsIssueAsked(asked > 10 ? 1 : 0);
 
                         insProductAnalysisDtoList.add(deviationWarningDetail);
 
@@ -1059,6 +1060,24 @@
         double sum = doubleData.stream().mapToDouble(Double::doubleValue).sum();
         double average = sum / doubleData.size();
 
+        double target = Double.parseDouble(targetStr);
+        double deviationPercent = Math.abs(target - average) / average * 100;
+
+        // 淇濈暀涓や綅灏忔暟
+        DecimalFormat df = new DecimalFormat("#.00");
+        String formatted = df.format(deviationPercent);
+        return Double.parseDouble(formatted);
+    }
+
+    /**
+     * *****璁$畻鍋忓樊锛堣姹傚�硷級****
+     * @param asked
+     * @param targetStr
+     * @return
+     */
+    public static double isDeviationOverTenPercentByAsked(String asked, String targetStr) {
+        if(!isNumeric(asked)) return 0;
+        double average = Double.parseDouble(asked);
         double target = Double.parseDouble(targetStr);
         double deviationPercent = Math.abs(target - average) / average * 100;
 
@@ -3723,9 +3742,9 @@
                                        String itemCh,
                                        String itemEn) {
         // 鍒ゆ柇鏄惁鏈夋楠岄」鍒嗙被map
-        String classTiemName = itemCh + (StringUtils.isBlank(sample.getInspectionItemClass()) ? "" : sample.getInspectionItemClass());
-        String classTiemNameEn = itemEn + (StringUtils.isBlank(sample.getInspectionItemClassEN()) ? "" : sample.getInspectionItemClassEN());
-        String classTiemNameItemEN = StringUtils.isBlank(sample.getInspectionItemEn()) ? "" : sample.getInspectionItemEn();
+        String classTiemName = itemCh + (StringUtils.isBlank(sample.getInspectionItemClass()) ? "" : sample.getInspectionItemClass()).trim();
+        String classTiemNameEn = itemEn + (StringUtils.isBlank(sample.getInspectionItemClassEN()) ? "" : sample.getInspectionItemClassEN()).trim();
+        String classTiemNameItemEN = StringUtils.isBlank(sample.getInspectionItemEn()) ? "" : sample.getInspectionItemEn().trim();
 
         if (errorClassItemMapCn.containsKey(classTiemName)) {
             // 鍒ゆ柇鏄惁鏈夋楠岄」map

--
Gitblit v1.9.3