lyh
2025-02-14 f2f8241dd52ef12ec109f6f4f0f13042055338ac
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;
@@ -51,6 +53,8 @@
    private IDocInfoService docInfoService;
    @Autowired
    private INcLogInfoService iNcLogInfoService;
    @Autowired
    private IDocRelativeService iDocRelativeService;
    @Override
    @Transactional(rollbackFor = {Exception.class})
@@ -133,7 +137,8 @@
        b = componentPermissionService.save(permission);
        if(!b)
            ExceptionCast.cast(CommonCode.FAIL);
        //添加默认工序
        //去除默认新增工序,转为手动添加
        /*/添加默认工序
        ProcessStream processStream = new ProcessStream();
        processStream.setProductId(componentInfo.getProductId());
        processStream.setComponentId(componentInfo.getComponentId());
@@ -149,7 +154,7 @@
        iNcLogInfoService.saveLogNcInfos(ncLogInfogx);
        b = processStreamService.save(processStream);
        if(!b)
            ExceptionCast.cast(CommonCode.FAIL);
            ExceptionCast.cast(CommonCode.FAIL);*/
        //添加权限
        PermissionStream stream = new PermissionStream();
        stream.setUserId(userId);
@@ -295,18 +300,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 +410,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 +449,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);
            }