From e6198034545e7152bc02229e4851a3a39e0bd101 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=88=98=5F=E9=9C=87?= <haiweizixuan@163.com>
Date: Tue, 16 Jul 2024 14:48:26 +0800
Subject: [PATCH] =?UTF-8?q?code=E8=BD=AC=E4=B8=80=E4=BA=8C=E7=BA=A7?=
 =?UTF-8?q?=E5=88=86=E7=B1=BB=EF=BC=88=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?=
 =?UTF-8?q?=EF=BC=89-=E6=B7=BB=E5=8A=A0=E8=B4=B9=E7=94=A8=E6=9D=A5?=
 =?UTF-8?q?=E6=BA=90=EF=BC=88=E5=A4=84=E7=90=86=E7=89=B9=E6=AE=8A=E7=9F=BF?=
 =?UTF-8?q?=E7=9A=84=E6=9D=90=E6=96=99=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../impl/AsiccSuppliesServiceImpl.java        | 218 +++++++++++-------
 1 file changed, 133 insertions(+), 85 deletions(-)

diff --git a/ruoyi-wages/src/main/java/com/ruoyi/system/service/impl/AsiccSuppliesServiceImpl.java b/ruoyi-wages/src/main/java/com/ruoyi/system/service/impl/AsiccSuppliesServiceImpl.java
index 4bc6511..284745e 100644
--- a/ruoyi-wages/src/main/java/com/ruoyi/system/service/impl/AsiccSuppliesServiceImpl.java
+++ b/ruoyi-wages/src/main/java/com/ruoyi/system/service/impl/AsiccSuppliesServiceImpl.java
@@ -13,6 +13,7 @@ import org.apache.commons.lang3.Range;
 import org.springframework.stereotype.Service;
 
 import javax.accessibility.AccessibleValue;
+import java.lang.reflect.Array;
 import java.util.*;
 
 /**
@@ -62,62 +63,76 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
             ActSupplies actSupplies = asiccSuppliesMapper.selectByNum();
             //存放处理之后的code (asiccDAO中的Code)
             for (String code : asiccDAO.getCodes()) {
-                Map<String,Object> map = new HashMap<>();
+                Map<String, Object> map = new HashMap<>();
                 //存放基本生产原煤的一级、二级分类
-                Map<String,Object> codeList1 = new HashMap<>();
+                Map<String, Object> codeList1 = new HashMap<>();
                 //存放基本生产洗煤的一级、二级分类
-                Map<String,Object> codeList2 = new HashMap<>();
+                Map<String, Object> codeList2 = new HashMap<>();
                 //存放其他费用来源的一级、二级分类
-                Map<String,Object> codeList3 = new HashMap<>();
+                Map<String, Object> codeList3 = new HashMap<>();
 
-                String kmCode = StringUtils.substring(code, 0, 6);
-                if (codeMap.containsKey(kmCode)) {
-                    get(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, kmCode);
+                Range<String> range = Range.between("30", "36");
+                String kmCode1 = StringUtils.substring(code, 0, 2);
+                String kmCode2 = StringUtils.substring(code, 0, 4);
+                if (mineId.equals("011704") && range.contains(kmCode1)) {
+                    codeList1.put("一级分类", "配件");
+                    codeList1.put("二级分类", "配件");
+                    codeList2.put("一级分类", "配件");
+                    codeList2.put("二级分类", "配件");
+                    codeList3.put("一级分类", "其他材料");
+                    codeList3.put("二级分类", "其他");
+                    map.put("基本生产原煤", codeList1);
+                    map.put("基本生产洗煤", codeList2);
+                    map.put("其他费用来源", codeList3);
+                    voMap.put(code, map);
+                } else if (mineId.equals("011704") && kmCode2.equals("6199")) {
+                    codeList1.put("一级分类", "其他材料");
+                    codeList1.put("二级分类", "其他");
+                    codeList2.put("一级分类", "其他材料");
+                    codeList2.put("二级分类", "其他");
+                    codeList3.put("一级分类", "其他材料");
+                    codeList3.put("二级分类", "其他");
+                    map.put("基本生产原煤", codeList1);
+                    map.put("基本生产洗煤", codeList2);
+                    map.put("其他费用来源", codeList3);
+                    voMap.put(code, map);
                 } else {
-                    kmCode = StringUtils.substring(kmCode, 0, 4);
+                    String kmCode = StringUtils.substring(code, 0, 6);
                     if (codeMap.containsKey(kmCode)) {
-                        if (mineId.equals("011704") && kmCode.equals("6199")) {
-                            codeList1.put("一级分类","其他材料");
-                            codeList1.put("二级分类","其他");
-                            codeList2.put("一级分类","其他材料");
-                            codeList2.put("二级分类","其他");
-                        } else {
-                            getId(suppliesMap, codeMap, codeList1, codeList2, kmCode);
-                        }
-                        codeList3.put("一级分类","其他材料");
-                        codeList3.put("二级分类","其他");
-                        map.put("基本生产原煤", codeList1);
-                        map.put("基本生产洗煤", codeList2);
-                        map.put("其他费用来源", codeList3);
-                        voMap.put(code,map);
+                        get(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, kmCode);
                     } else {
-                        kmCode = StringUtils.substring(kmCode, 0, 2);
-                        Range<String> range = Range.between("30", "36");
-                        if (mineId.equals("011704") && range.contains(kmCode)) {
-                            codeList1.put("一级分类","配件");
-                            codeList1.put("二级分类","配件");
-                            codeList2.put("一级分类","配件");
-                            codeList2.put("二级分类","配件");
-                        } else if (codeMap.containsKey(kmCode)) {
-                            get(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, kmCode);
-                        } else {
-                            //kmCode一律为10
-                            String oneLevel = actSupplies.getSuppliesName();
-                            codeList1.put("一级分类",oneLevel);
-                            codeList1.put("二级分类",null);
-                            if (oneLevel.equals("油脂")||oneLevel.equals("配件")) {
-                                codeList2.put("一级分类",oneLevel);
-                                codeList2.put("二级分类",null);
-                            }else{
-                                codeList2.put("一级分类","其他材料");
-                                codeList2.put("二级分类","其他");
-                            }
-                            codeList3.put("一级分类","其他材料");
-                            codeList3.put("二级分类","其他");
+                        kmCode = StringUtils.substring(kmCode, 0, 4);
+                        if (codeMap.containsKey(kmCode)) {
+                            getId(suppliesMap, codeMap, codeList1, codeList2, kmCode);
+                            codeList3.put("一级分类", "其他材料");
+                            codeList3.put("二级分类", "其他");
                             map.put("基本生产原煤", codeList1);
                             map.put("基本生产洗煤", codeList2);
                             map.put("其他费用来源", codeList3);
-                            voMap.put(code,map);
+                            voMap.put(code, map);
+                        } else {
+                            kmCode = StringUtils.substring(kmCode, 0, 2);
+                            if (codeMap.containsKey(kmCode)) {
+                                get(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, kmCode);
+                            } else {
+                                //kmCode一律为10
+                                String oneLevel = actSupplies.getSuppliesName();
+                                codeList1.put("一级分类", oneLevel);
+                                codeList1.put("二级分类", null);
+                                if (oneLevel.equals("油脂") || oneLevel.equals("配件")) {
+                                    codeList2.put("一级分类", oneLevel);
+                                    codeList2.put("二级分类", null);
+                                } else {
+                                    codeList2.put("一级分类", "其他材料");
+                                    codeList2.put("二级分类", "其他");
+                                }
+                                codeList3.put("一级分类", "其他材料");
+                                codeList3.put("二级分类", "其他");
+                                map.put("基本生产原煤", codeList1);
+                                map.put("基本生产洗煤", codeList2);
+                                map.put("其他费用来源", codeList3);
+                                voMap.put(code, map);
+                            }
                         }
                     }
                 }
@@ -131,13 +146,13 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
             });
             for (String code : asiccDAO.getCodes()) {
                 boolean matched = false;
-                Map<String,Object> map = new HashMap<>();
+                Map<String, Object> map = new HashMap<>();
                 //存放基本生产原煤的一级、二级分类
-                Map<String,Object> codeList1 = new HashMap<>();
+                Map<String, Object> codeList1 = new HashMap<>();
                 //存放基本生产洗煤的一级、二级分类
-                Map<String,Object> codeList2 = new HashMap<>();
+                Map<String, Object> codeList2 = new HashMap<>();
                 //存放其他费用来源的一级、二级分类
-                Map<String,Object> codeList3 = new HashMap<>();
+                Map<String, Object> codeList3 = new HashMap<>();
                 for (ActSuppliesMaterialCode materialCode : materialCodeList) {
                     String kmCode = code;
                     String codeMin = materialCode.getCodeMin();
@@ -155,14 +170,47 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
                             break; // 跳出内部循环
                         } else {
                             kmCode = StringUtils.substring(kmCode, 0, 4);
+                            String[] number = {"6101", "6102"};
                             if (range.contains(kmCode)) {
-                                getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
+                                // 跳出内部循环
+                                if (mineId.equals("011702") && Arrays.asList(number).contains(kmCode)) {
+                                    String twoLevel = materialCode.getMaterialName();
+                                    String codeType = materialCode.getMaterialCodeType();
+                                    String oneLevel = suppliesMap.get(codeType);
+                                    codeList1.put("一级分类", oneLevel);
+                                    codeList1.put("二级分类", twoLevel);
+                                    codeList2.put("一级分类", "油脂及乳化液");
+                                    codeList2.put("二级分类", "油脂");
+                                    codeList3.put("一级分类", "其他材料");
+                                    codeList3.put("二级分类", "其他");
+                                    map.put("基本生产原煤", codeList1);
+                                    map.put("基本生产洗煤", codeList2);
+                                    map.put("其他费用来源", codeList3);
+                                } else {
+                                    getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
+                                }
                                 matched = true;
                                 break; // 跳出内部循环
                             } else {
                                 kmCode = StringUtils.substring(kmCode, 0, 2);
                                 if (range.contains(kmCode)) {
-                                    getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
+                                    String[] numbers = {"30", "31", "32", "34", "35"};
+                                    if (mineId.equals("011702") && Arrays.asList(numbers).contains(kmCode)) {
+                                        String twoLevel = materialCode.getMaterialName();
+                                        String codeType = materialCode.getMaterialCodeType();
+                                        String oneLevel = suppliesMap.get(codeType);
+                                        codeList1.put("一级分类", oneLevel);
+                                        codeList1.put("二级分类", twoLevel);
+                                        codeList2.put("一级分类", "配件");
+                                        codeList2.put("二级分类", "配件");
+                                        codeList3.put("一级分类", "其他材料");
+                                        codeList3.put("二级分类", "其他");
+                                        map.put("基本生产原煤", codeList1);
+                                        map.put("基本生产洗煤", codeList2);
+                                        map.put("其他费用来源", codeList3);
+                                    } else {
+                                        getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
+                                    }
                                     matched = true;
                                     break; // 跳出内部循环
                                 }
@@ -171,12 +219,12 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
                     }
                 }
                 if (!matched) {
-                    codeList1.put("一级分类","其他材料");
-                    codeList1.put("二级分类","其他");
-                    codeList2.put("一级分类","其他材料");
-                    codeList2.put("二级分类","其他");
-                    codeList3.put("一级分类","其他材料");
-                    codeList3.put("二级分类","其他");
+                    codeList1.put("一级分类", "其他材料");
+                    codeList1.put("二级分类", "其他");
+                    codeList2.put("一级分类", "其他材料");
+                    codeList2.put("二级分类", "其他");
+                    codeList3.put("一级分类", "其他材料");
+                    codeList3.put("二级分类", "其他");
                     map.put("基本生产原煤", codeList1);
                     map.put("基本生产洗煤", codeList2);
                     map.put("其他费用来源", codeList3);
@@ -192,26 +240,26 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
      */
     private void getLevelInfo(Map<String, Object> voMap, Map<Object, String> suppliesMap,
                               String code, Map<String, Object> map,
-                              Map<String,Object> codeList1, Map<String,Object> codeList2,
-                              Map<String,Object> codeList3, ActSuppliesMaterialCode materialCode) {
+                              Map<String, Object> codeList1, Map<String, Object> codeList2,
+                              Map<String, Object> codeList3, ActSuppliesMaterialCode materialCode) {
         String twoLevel = materialCode.getMaterialName();
         String codeType = materialCode.getMaterialCodeType();
         String oneLevel = suppliesMap.get(codeType);
-        codeList1.put("一级分类",oneLevel);
-        codeList1.put("二级分类",twoLevel);
-        if (oneLevel.equals("油脂及乳化液")||oneLevel.equals("配件")) {
-            codeList2.put("一级分类",oneLevel);
-            codeList2.put("二级分类",twoLevel);
-        }else{
-            codeList2.put("一级分类","其他材料");
-            codeList2.put("二级分类","其他");
+        codeList1.put("一级分类", oneLevel);
+        codeList1.put("二级分类", twoLevel);
+        if (oneLevel.equals("油脂及乳化液") || oneLevel.equals("配件")) {
+            codeList2.put("一级分类", oneLevel);
+            codeList2.put("二级分类", twoLevel);
+        } else {
+            codeList2.put("一级分类", "其他材料");
+            codeList2.put("二级分类", "其他");
         }
-        codeList3.put("一级分类","其他材料");
-        codeList3.put("二级分类","其他");
+        codeList3.put("一级分类", "其他材料");
+        codeList3.put("二级分类", "其他");
         map.put("基本生产原煤", codeList1);
         map.put("基本生产洗煤", codeList2);
         map.put("其他费用来源", codeList3);
-        voMap.put(code,map);
+        voMap.put(code, map);
     }
 
     /**
@@ -219,35 +267,35 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
      */
     private void get(Map<String, Object> voMap, Map<Object, String> suppliesMap,
                      Map<String, Object> codeMap, String code, Map<String, Object> map,
-                     Map<String,Object> codeList1, Map<String,Object> codeList2,
-                     Map<String,Object> codeList3, String kmCode) {
+                     Map<String, Object> codeList1, Map<String, Object> codeList2,
+                     Map<String, Object> codeList3, String kmCode) {
         getId(suppliesMap, codeMap, codeList1, codeList2, kmCode);
-        codeList3.put("一级分类","其他材料");
-        codeList3.put("二级分类","其他");
+        codeList3.put("一级分类", "其他材料");
+        codeList3.put("二级分类", "其他");
         map.put("基本生产原煤", codeList1);
         map.put("基本生产洗煤", codeList2);
         map.put("其他费用来源", codeList3);
-        voMap.put(code,map);
+        voMap.put(code, map);
     }
 
     /**
      * 处理原煤和洗煤的一级和二级分类(处理矿id不存在)
      */
     private void getId(Map<Object, String> suppliesMap, Map<String, Object> codeMap,
-                       Map<String,Object> codeList1, Map<String,Object> codeList2, String kmCode) {
+                       Map<String, Object> codeList1, Map<String, Object> codeList2, String kmCode) {
         Object sid = codeMap.get(kmCode);
         String finalLevel = suppliesMap.get(sid);
         String[] part = finalLevel.split("_");
         String oneLevel = part[0];
         String twoLevel = part[1];
-        codeList1.put("一级分类",oneLevel);
-        codeList1.put("二级分类",twoLevel);
-        if (oneLevel.equals("油脂及乳化液")||oneLevel.equals("配件")) {
-            codeList2.put("一级分类",oneLevel);
-            codeList2.put("二级分类",twoLevel);
-        }else{
-            codeList2.put("一级分类","其他材料");
-            codeList2.put("二级分类","其他");
+        codeList1.put("一级分类", oneLevel);
+        codeList1.put("二级分类", twoLevel);
+        if (oneLevel.equals("油脂及乳化液") || oneLevel.equals("配件")) {
+            codeList2.put("一级分类", oneLevel);
+            codeList2.put("二级分类", twoLevel);
+        } else {
+            codeList2.put("一级分类", "其他材料");
+            codeList2.put("二级分类", "其他");
         }
     }
 }
-- 
2.26.2