From 82f614e4646aeb179927dd82ccf0097a671dce48 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期五, 03 七月 2026 14:19:38 +0800
Subject: [PATCH] 外购下单:出厂检验报告检验值小数位数生成错误问题修复

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java |   44 ++++++++++++++------------------------------
 1 files changed, 14 insertions(+), 30 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 b77a7fd..5257381 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
@@ -811,7 +811,7 @@
                 )
                 .ne(InsProduct::getIsBinding, 1));
         insProducts.addAll(insProductMapper.selectFiberInsProduct(InsSampleIds, laboratory));
-        if (insProducts.size() > 0) {
+        if (!insProducts.isEmpty()) {
             String str = "";
             int count = 0;
             for (InsProduct product : insProducts) {
@@ -1716,8 +1716,8 @@
             for (int i = startIndex; i < endIndex; i++) {
                 String cableTag = cableTags.get(i);
                 for (SampleProductExportDto sDto : collect.get(s)) {
-                    tellSet.add(sDto.getTell());
                     if (sDto.getCableTag().equals(cableTag)) {
+                        tellSet.add(sDto.getTell());
                         lastValueList.add(sDto.getLastValue());
                     }
                 }
@@ -1745,22 +1745,6 @@
     }
 
     /**
-     * 浣跨敤姝e垯琛ㄨ揪寮忓幓闄ゅ瓧绗︿覆鏈�鍚庝竴涓�"-"鍙婂叾鍚庨潰鐨勬墍鏈夊唴瀹�
-     * @param str 寰呭鐞嗙殑瀛楃涓诧紙鍏佽涓簄ull锛�
-     * @return 澶勭悊鍚庣殑瀛楃涓诧紝null杩斿洖null锛屾棤"-"杩斿洖鍘熷瓧绗︿覆
-     */
-    public static String removeLastHyphenAndContent(String str) {
-        // 绌哄�兼牎楠岋細閬垮厤NullPointerException
-        if (str == null || str.isEmpty()) {
-            return str;
-        }
-        // 姝e垯琛ㄨ揪寮忥細鍖归厤鏈�鍚庝竴涓�"-"鍙婂叾鍚庨潰鐨勬墍鏈夊唴瀹�
-        String regex = "-[^-]*$";
-        // 鏇挎崲鍖归厤鐨勫唴瀹逛负绌哄瓧绗︿覆
-        return str.replaceAll(regex, "");
-    }
-
-    /**
      * 灏忔姤鍛婄敓鎴�
      *
      * @param orderId
@@ -1781,7 +1765,7 @@
         IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId());
         //鏌ヨ闆朵欢灞炴��
         IfsPartPropsRecord ifsPartPropsRecord = ifsPartPropsRecordMapper.selectOne(Wrappers.<IfsPartPropsRecord>lambdaQuery()
-                .eq(IfsPartPropsRecord::getIfsInventoryId, ifsInventoryQuantity.getId()));
+                .eq(IfsPartPropsRecord::getIfsInventoryId, ifsInventoryQuantity.getId()).last("limit 1"));
         if (Objects.nonNull(ifsPartPropsRecord)) {
             enterFactoryReport.setOuterColor(StringUtils.equals(ifsPartPropsRecord.getOuterColor(),"/")?ifsPartPropsRecord.getInsulationColor():ifsPartPropsRecord.getOuterColor());
         }
@@ -1828,7 +1812,7 @@
             //鏌ヨ妫�楠屽崟娑堟伅
             InsSampleUserVO insSampleUser = insSampleUserMapper.selectUserNameByOrderId(orderId);
             if (Objects.nonNull(insSampleUser)) {
-                enterFactoryReport.setPartDesc(removeLastHyphenAndContent(insSampleUser.getModel()));
+                enterFactoryReport.setPartDesc(insSampleUser.getModel());
                 enterFactoryReport.setInspector(insSampleUser.getInspector());
                 enterFactoryReport.setInspectDate(insSampleUser.getInspectDate());
             }
@@ -4376,17 +4360,17 @@
     }
 
 
-    private static int getDecimalPlaces(String str) {
-        // 鏌ユ壘灏忔暟鐐逛綅缃�
-        int decimalPointIndex = str.lastIndexOf('.');
-
-        if (decimalPointIndex == -1) {
-            // 濡傛灉娌℃湁灏忔暟鐐癸紝杩斿洖0浣嶅皬鏁�
-            return 0;
+   private static int getDecimalPlaces(String str) {
+        // 浣跨敤姝e垯鍖归厤鎵�鏈夊甫灏忔暟鐐圭殑鏁板瓧锛屽彇鏈�澶у皬鏁颁綅鏁�
+        java.util.regex.Matcher matcher = Pattern.compile("\\d+\\.(\\d+)").matcher(str);
+        int maxDecimalPlaces = 0;
+        while (matcher.find()) {
+            int places = matcher.group(1).length();
+            if (places > maxDecimalPlaces) {
+                maxDecimalPlaces = places;
+            }
         }
-
-        // 璁$畻灏忔暟鐐瑰悗鐨勪綅鏁�
-        return str.length() - decimalPointIndex - 1;
+        return maxDecimalPlaces;
     }
 
     /**

--
Gitblit v1.9.3