From 757bfa4a2865b3066e82a7e80bea1efd8bdcd72c Mon Sep 17 00:00:00 2001
From: lyh <liuyuanheng@xalxzn.com>
Date: 星期四, 20 二月 2025 15:03:27 +0800
Subject: [PATCH] 去除原有日志  默认新增管理员权限

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java |   88 ++++++++++++--------------------------------
 1 files changed, 24 insertions(+), 64 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
index 3856ff5..58c024a 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
@@ -2,6 +2,7 @@
 
 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.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.shiro.SecurityUtils;
@@ -20,6 +21,7 @@
 import org.jeecg.modules.dnc.ucenter.Department;
 import org.jeecg.modules.dnc.utils.ValidateUtil;
 import org.jeecg.modules.dnc.entity.*;
+import org.jeecg.modules.system.entity.MdcProduction;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.dnc.entity.ComponentInfo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -50,7 +52,9 @@
     @Autowired
     private IDocInfoService docInfoService;
     @Autowired
-    private INcLogInfoService iNcLogInfoService;
+    private IDocRelativeService iDocRelativeService;
+    @Autowired
+    private IProductPermissionService productPermissionService;
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
@@ -89,15 +93,6 @@
         }
 
         componentInfo.setComponentStatus(1);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(2);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("閮ㄤ欢鍚嶇О锛�"+componentInfo.getComponentName()+"锛岄儴浠朵唬鍙凤細"+componentInfo.getComponentCode());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         boolean b = super.save(componentInfo);
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
@@ -127,29 +122,11 @@
             if(!b)
                 ExceptionCast.cast(CommonCode.FAIL);
         }
-        ComponentPermission permission = new ComponentPermission();
-        permission.setComponentId(componentInfo.getComponentId());
-        permission.setUserId(userId);
-        b = componentPermissionService.save(permission);
-        if(!b)
-            ExceptionCast.cast(CommonCode.FAIL);
-        //娣诲姞榛樿宸ュ簭
-        ProcessStream processStream = new ProcessStream();
-        processStream.setProductId(componentInfo.getProductId());
-        processStream.setComponentId(componentInfo.getComponentId());
-        processStream.setProcessCode("1");
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfogx = new NcLogInfo();
-        //妯″潡
-        ncLogInfogx.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfogx.setOperateType(2);
-        //鏃ュ織鍐呭
-        ncLogInfogx.setLogContent("閮ㄤ欢鍚嶇О锛�"+componentInfo.getComponentName()+"鐢熸垚榛樿宸ュ簭锛屽伐搴忓彿锛�"+processStream.getProcessCode());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfogx);
-        b = processStreamService.save(processStream);
-        if(!b)
-            ExceptionCast.cast(CommonCode.FAIL);
+        b = productPermissionService.add(componentInfo.getComponentId(), userId,"2");
+        if (!b) {
+            ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
+        }
+        //鍘婚櫎榛樿鏂板宸ュ簭锛岃浆涓烘墜鍔ㄦ坊鍔�
         //娣诲姞鏉冮檺
         PermissionStream stream = new PermissionStream();
         stream.setUserId(userId);
@@ -177,17 +154,6 @@
         componentInfo.setComponentStatus(null);
         componentInfo.setRankLevel(null);
         componentInfo.setProductId(null);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(3);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("淇敼閮ㄤ欢鍚嶇О锛�"+productInfoMapper.selectById(en.getProductId()).getProductName()+"瀛愰泦閮ㄤ欢");
-        //淇敼淇濆瓨澶囨敞
-        ncLogInfo.setRemark(JSONObject.toJSONString(en));
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         boolean b = super.updateById(componentInfo);
         if(!b)
             return false;
@@ -295,18 +261,12 @@
         if(processStreamList != null && !processStreamList.isEmpty()) {
             ExceptionCast.cast(ComponentInfoCode.COMPONENT_PROCESS_EXIST);
         }
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(4);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("閮ㄤ欢鍚嶇О锛�"+componentInfo.getComponentName());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
-        boolean b = docInfoService.deleteByComponentId(id);
-        if(!b)
-            ExceptionCast.cast(CommonCode.FAIL);
+        boolean b;
+        //楠岃瘉鏄惁瀛樺湪鏂囨。
+        List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type","2").eq("attribution_id",id));
+        if (!docRelativeList.isEmpty()){
+            ExceptionCast.cast(ComponentInfoCode.COMPONENT_DOC_EXIST);
+        }
         b = componentPermissionService.deleteByComponentId(id);
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
@@ -411,23 +371,23 @@
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
-    public boolean assignAddDepart(ComponentInfo componentInfo, Collection<Department> departmentList) {
+    public boolean assignAddDepart(ComponentInfo componentInfo, Collection<MdcProduction> departmentList) {
         if(componentInfo == null || departmentList == null || departmentList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         List<ComponentDepartment> componentDepartments = new ArrayList<>();
         List<PermissionStream> permissionStreamList = new ArrayList<>();
         departmentList.forEach(item -> {
-            ComponentDepartment en = componentDepartmentService.getByComponentIdAndDepartId(componentInfo.getComponentId(), item.getDepartId());
+            ComponentDepartment en = componentDepartmentService.getByComponentIdAndDepartId(componentInfo.getComponentId(), item.getId());
             if(en == null) {
                 en = new ComponentDepartment();
-                en.setDepartId(item.getDepartId());
+                en.setDepartId(item.getId());
                 en.setComponentId(componentInfo.getComponentId());
                 componentDepartments.add(en);
             }
-            PermissionStream stream = permissionStreamService.getByComponentIdAndDepartId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getDepartId());
+            PermissionStream stream = permissionStreamService.getByComponentIdAndDepartId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId());
             if(stream == null) {
                 stream = new PermissionStream();
-                stream.setDepartId(item.getDepartId());
+                stream.setDepartId(item.getId());
                 stream.setProductId(componentInfo.getProductId());
                 stream.setComponentId(componentInfo.getComponentId());
                 permissionStreamList.add(stream);
@@ -450,17 +410,17 @@
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
-    public boolean assignRemoveDepart(ComponentInfo componentInfo, Collection<Department> departmentList) {
+    public boolean assignRemoveDepart(ComponentInfo componentInfo, Collection<MdcProduction> departmentList) {
         if(componentInfo == null || departmentList == null || departmentList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         List<ComponentDepartment> componentDepartments = new ArrayList<>();
         List<PermissionStream> permissionStreamList = new ArrayList<>();
         departmentList.forEach(item -> {
-            ComponentDepartment en = componentDepartmentService.getByComponentIdAndDepartId(componentInfo.getComponentId(), item.getDepartId());
+            ComponentDepartment en = componentDepartmentService.getByComponentIdAndDepartId(componentInfo.getComponentId(), item.getId());
             if(en != null) {
                 componentDepartments.add(en);
             }
-            PermissionStream stream = permissionStreamService.getByComponentIdAndDepartId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getDepartId());
+            PermissionStream stream = permissionStreamService.getByComponentIdAndDepartId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId());
             if(stream != null) {
                 permissionStreamList.add(stream);
             }

--
Gitblit v1.9.3