From a7ad8c17aa069e723aa0a813cf198d07e67b5fb5 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期五, 14 三月 2025 14:19:08 +0800
Subject: [PATCH] 新增刀具、设备类信息管理,新增结构树优化,优化权限分配,新增双控设备结构书 修改flow模块 删除部分废弃yml配置

---
 lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java |   95 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 84 insertions(+), 11 deletions(-)

diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java
index e39af4e..938efca 100644
--- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java
+++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java
@@ -1,22 +1,25 @@
 package org.jeecg.modules.system.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.FillRuleConstant;
-import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.FillRuleUtil;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.system.entity.*;
-import org.jeecg.modules.system.mapper.*;
+import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper;
+import org.jeecg.modules.system.mapper.MdcProductionMapper;
+import org.jeecg.modules.system.mapper.MdcUserProductionMapper;
+import org.jeecg.modules.system.mapper.SysUserMapper;
 import org.jeecg.modules.system.model.MdcProductionTreeModel;
 import org.jeecg.modules.system.model.ProductionIdModel;
 import org.jeecg.modules.system.service.IMdcProductionService;
+import org.jeecg.modules.system.service.ISysParamsService;
 import org.jeecg.modules.system.util.FindsProductionsChildrenUtil;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
@@ -45,7 +48,7 @@
     private MdcProductionEquipmentMapper productionEquipmentMapper;
 
     @Resource
-    private DncDeviceGroupPermissionMapper dncDeviceGroupPermissionMapper;
+    private ISysParamsService sysParamsService;
     /**
      * queryTreeList 瀵瑰簲 queryTreeList 鏌ヨ鎵�鏈夌殑浜х嚎鏁版嵁,浠ユ爲缁撴瀯褰㈠紡鍝嶅簲缁欏墠绔�
      */
@@ -60,6 +63,45 @@
         this.setUserIdsByProList(list);
         //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁
         return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list);
+    }
+
+    /**
+     * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず(娣诲姞绯荤粺閰嶇疆)
+     */
+    @Override
+    public List<MdcProductionTreeModel> queryTreeListByConfig(){
+        SysParams sysParams = sysParamsService.getSysPramBySettingKey("dnc_production");
+        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>();
+        if (sysParams == null) {
+            return null;
+        }else {
+            if (("0").equals(sysParams.getSettingValue())){
+                query.eq(MdcProduction::getOrgType,"2");
+                query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
+                query.orderByAsc(MdcProduction::getProductionOrder);
+                List<MdcProduction> list = this.list(query);
+                //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず
+                this.setUserIdsByProList(list);
+                //灏佽涓�绾ф爲
+                List<MdcProductionTreeModel> listResult = new ArrayList<>();
+                for (MdcProduction production : list) {
+                    if (production.getDescription().isEmpty()){
+                        production.setDescription("");
+                    }
+                    listResult.add(new MdcProductionTreeModel(production));
+                }
+                //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁
+                return listResult;
+            }else {
+                query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
+                query.orderByAsc(MdcProduction::getProductionOrder);
+                List<MdcProduction> list = this.list(query);
+                //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず
+                this.setUserIdsByProList(list);
+                //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁
+                return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list);
+            }
+        }
     }
 
     /**
@@ -138,13 +180,6 @@
             mdcProduction.setOrgType(String.valueOf(orgType));
             mdcProduction.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
             this.save(mdcProduction);
-            //鏂板DNC杞﹂棿鏉冮檺
-            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-            String userId = user.getId();
-            DncDeviceGroupPermission dncDeviceGroupPermission=new DncDeviceGroupPermission();
-            dncDeviceGroupPermission.setGroupPermId(mdcProduction.getId());
-            dncDeviceGroupPermission.setUserId(userId);
-            dncDeviceGroupPermissionMapper.insert(dncDeviceGroupPermission);
         }
     }
 
@@ -202,6 +237,15 @@
     @Override
     public List<MdcProduction> queryProdByPid(String pid) {
         return this.baseMapper.queryProdByPid(pid);
+    }
+
+    /**
+     * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣
+     */
+    @Override
+    public List<MdcProduction> recursionChildrenByPid(String pid){
+        List<String> ids=this.recursionChildren(pid);
+        return super.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).in(MdcProduction::getId, ids));
     }
 
     /**
@@ -368,4 +412,33 @@
         }
         return stringList;
     }
+
+    /**
+     * 鑾峰彇鐢ㄦ埛宸插垎閰嶇殑閮ㄩ棬鍒楄〃
+     * @param userId
+     * @return
+     */
+     @Override
+     public Map<String, MdcProduction> getUserAssignedDepart(String userId){
+         if(StrUtil.isEmpty(userId))
+             return null;
+         List<MdcProduction> userPermDepart = this.baseMapper.findAllProductionId(userId);
+         if(userPermDepart == null || userPermDepart.isEmpty())
+             return null;
+         Map<String, MdcProduction> map = new HashMap<>();
+         userPermDepart.forEach(item -> {
+             map.put(item.getId(), item);
+         });
+         return map;
+    }
+
+    /**
+     * 閫氳繃涓�缁刬d鑾峰彇閮ㄩ棬
+     * @param ids
+     * @return
+     */
+    @Override
+    public List<String> findAllProductionIds(List<String> ids){
+        return this.baseMapper.recursionChildrenByList(ids);
+    }
 }

--
Gitblit v1.9.3