From 94c0a729da1b88ab4a0067f1e14a00264e0447cf Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期一, 15 十二月 2025 17:04:05 +0800
Subject: [PATCH] bom管理中空胶计算调整

---
 north-glass-erp/src/main/java/com/example/erp/service/sd/BasicGlassTypeService.java |  164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 164 insertions(+), 0 deletions(-)

diff --git a/north-glass-erp/src/main/java/com/example/erp/service/sd/BasicGlassTypeService.java b/north-glass-erp/src/main/java/com/example/erp/service/sd/BasicGlassTypeService.java
new file mode 100644
index 0000000..08189cb
--- /dev/null
+++ b/north-glass-erp/src/main/java/com/example/erp/service/sd/BasicGlassTypeService.java
@@ -0,0 +1,164 @@
+package com.example.erp.service.sd;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.example.erp.entity.sd.BasicGlassType;
+import com.example.erp.entity.sd.ProcessAttributeConfig;
+import com.example.erp.mapper.sd.BasicGlassTypeMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+@DS("sd")
+public class BasicGlassTypeService {
+    @Autowired
+    BasicGlassTypeMapper basicGlassTypeMapper;
+    public List<BasicGlassType> getOneLevel() {
+        return basicGlassTypeMapper.getOneLevel();
+    }
+
+    public List<BasicGlassType>  getTwoLevel() {
+        return basicGlassTypeMapper.getTwoLevel();
+    }
+
+    public List<Map<String,String>> getAll() {
+        List<BasicGlassType> oneGlassType = basicGlassTypeMapper.getOneLevel();
+        List<BasicGlassType> twoGlassType = basicGlassTypeMapper.getTwoLevel();
+        List<Map<String,String>> list = new ArrayList<>();
+        for (BasicGlassType glassType : oneGlassType) {
+            Map<String, String> map = new HashMap<>();
+            map.put("value", glassType.getTypeId());
+            map.put("label", glassType.getTypeName());
+            map.put("children", "");
+            List<String> equalList = new ArrayList<>();
+            for (BasicGlassType basicGlassType : twoGlassType) {
+                if (Objects.equals(basicGlassType.getBelong(), glassType.getTypeId())) {
+                    Map<String,String> getMap = JSON.parseObject(JSON.toJSONString(basicGlassType), Map.class);
+                    getMap.put("value",getMap.get("typeId"));
+                    getMap.put("label",getMap.get("typeName"));
+                    equalList.add(JSON.toJSONString(getMap)   );
+                }
+            }
+            map.replace("children",equalList.toString());
+            list.add(map);
+        }
+        return list;
+    }
+
+    public List<BasicGlassType> findAll() {
+        return basicGlassTypeMapper.selectList(null);
+    }
+
+    public Boolean deleteById(Integer id) {
+        return basicGlassTypeMapper.deleteById(id) > 0;
+    }
+
+    public List<Map<String,Object>> getOneLevelListMap() {
+        List<BasicGlassType> oneGlassType = basicGlassTypeMapper.getOneLevel();
+        List<Map<String,Object>> list = new ArrayList<>();
+        for (BasicGlassType glassType : oneGlassType) {
+            Map<String,Object> map = new HashMap<>();
+            map.put("value", glassType.getTypeId());
+            map.put("label", glassType.getTypeName());
+            list.add(map);
+        }
+        return list;
+    }
+
+    public Boolean add(Map<String, Object> map) {
+        List<Object> list = (List<Object>) map.get("glassLevel");
+        if(list.get(0)==null
+                || map.get("value") == null
+                || map.get("value").equals("")){
+            return false;
+        }
+        BasicGlassType basicGlassTypeS = new BasicGlassType();
+        if(map.get("type").equals("add")){
+            if(list.size()==1){
+                BasicGlassType basicGlassType =  basicGlassTypeMapper.selectMaxType((Integer) list.get(0));
+                int maxId = Integer.parseInt(basicGlassType.getTypeId());
+                String newTypeId = String.format("%02d", maxId+1);
+                basicGlassTypeS.setLevel((Integer) list.get(0));
+                basicGlassTypeS.setTypeId(newTypeId);
+                basicGlassTypeS.setTypeName((String) map.get("value"));
+            }else if(list.size()==2) {
+                BasicGlassType basicGlassType =  basicGlassTypeMapper.selectMaxTowLevelType((String) list.get(1));
+                Integer maxId = null;
+                if(basicGlassType==null){
+                    maxId = 0;
+                }else {
+                    maxId = Integer.parseInt(basicGlassType.getTypeId().substring(2));
+                }
+
+                String newTypeId =list.get(1) + String.format("%02d", maxId+1);
+                basicGlassTypeS.setLevel((Integer) list.get(0));
+                basicGlassTypeS.setTypeId(newTypeId);
+                basicGlassTypeS.setTypeName((String) map.get("value"));
+                basicGlassTypeS.setBelong((String) list.get(1));
+            }
+            return basicGlassTypeMapper.insert(basicGlassTypeS)>0;
+        }else{
+            basicGlassTypeS.setId((Integer) map.get("id"));
+            basicGlassTypeS.setTypeName((String) map.get("value"));
+           return basicGlassTypeMapper.updateGlassTypeName(basicGlassTypeS);
+        }
+
+    }
+
+    public List<ProcessAttributeConfig> findAllConfig() {
+        return basicGlassTypeMapper.getFindAllConfig();
+    }
+
+    public List<Map<String,Object>> getOneLevelListMapConfig() {
+        List<ProcessAttributeConfig> processAttributeConfigList = basicGlassTypeMapper.getOneLevelListMapConfig();
+        List<Map<String,Object>> list = new ArrayList<>();
+        for (ProcessAttributeConfig processAttributeConfig : processAttributeConfigList) {
+            Map<String,Object> map = new HashMap<>();
+            map.put("value", processAttributeConfig.getInputType());
+            map.put("label", processAttributeConfig.getProcessName());
+            list.add(map);
+        }
+        return list;
+    }
+
+    public Boolean addConfig(Map<String, Object> map) {
+        List<Object> list = (List<Object>) map.get("glassLevel");
+        if(list.get(0)==null
+                || map.get("processType") == null
+                || map.get("processType").equals("")){
+            return false;
+        }
+        ProcessAttributeConfig processAttributeConfigS = new ProcessAttributeConfig();
+        if(map.get("type").equals("add")){
+            if(list.size()==1){
+                ProcessAttributeConfig processAttributeConfig =  basicGlassTypeMapper.selectMaxTypeConfig((Integer) list.get(0));
+                int maxId = Integer.parseInt(processAttributeConfig.getInputType());
+                String newTypeId = String.format("%02d", maxId+1);
+                processAttributeConfigS.setLevel((Integer) list.get(0));
+                processAttributeConfigS.setInputType(newTypeId);
+                processAttributeConfigS.setProcessType((String) map.get("processType"));
+                processAttributeConfigS.setProcessName((String) map.get("processName"));
+            }else if(list.size()==2) {
+                processAttributeConfigS.setLevel((Integer) list.get(0));
+                processAttributeConfigS.setInputType((String) map.get("inputType"));
+                processAttributeConfigS.setProcessType((String) map.get("processType"));
+                processAttributeConfigS.setProcessName((String) map.get("processName"));
+                processAttributeConfigS.setBelong((String) list.get(1));
+            }
+            return basicGlassTypeMapper.insertProcessAttributeConfig(processAttributeConfigS);
+        }else{
+            processAttributeConfigS.setId((Integer) map.get("id"));
+            processAttributeConfigS.setInputType((String) map.get("inputType"));
+            processAttributeConfigS.setProcessType((String) map.get("processType"));
+            processAttributeConfigS.setProcessName((String) map.get("processName"));
+            return basicGlassTypeMapper.updateProcessAttributeConfig(processAttributeConfigS);
+        }
+
+    }
+
+    public Boolean deleteProcessAttributeConfig(Integer id) {
+        return basicGlassTypeMapper.deleteProcessAttributeConfig(id);
+    }
+}

--
Gitblit v1.8.0