| | |
| | | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @Autowired |
| | | private IDocInfoService docInfoService; |
| | | @Autowired |
| | | private INcLogInfoService iNcLogInfoService; |
| | | private IDocRelativeService iDocRelativeService; |
| | | @Autowired |
| | | private IProductPermissionService productPermissionService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | |
| | | } |
| | | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | 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); |
| | |
| | | |
| | | @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); |
| | |
| | | |
| | | @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); |
| | | } |