lyh
2025-02-20 757bfa4a2865b3066e82a7e80bea1efd8bdcd72c
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;
@@ -51,7 +52,9 @@
    @Autowired
    private IDocInfoService docInfoService;
    @Autowired
    private INcLogInfoService iNcLogInfoService;
    private IDocRelativeService iDocRelativeService;
    @Autowired
    private IProductPermissionService productPermissionService;
    @Override
    @Transactional(rollbackFor = {Exception.class})
@@ -90,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);
@@ -128,30 +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);
        b = productPermissionService.add(componentInfo.getComponentId(), userId,"2");
        if (!b) {
            ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
        }
        //去除默认新增工序,转为手动添加
        /*/添加默认工序
        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);*/
        //添加权限
        PermissionStream stream = new PermissionStream();
        stream.setUserId(userId);
@@ -179,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;
@@ -297,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);