| | |
| | | |
| | | 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.utils.ValidateUtil; |
| | | |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.apache.commons.collections4.ListUtils; |
| | | |
| | |
| | | private IDocInfoService docInfoService; |
| | | @Autowired |
| | | private INcLogInfoService iNcLogInfoService; |
| | | @Autowired |
| | | private IDocRelativeService iDocRelativeService; |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean addPartsInfo(PartsInfo partsInfo) { |
| | |
| | | if(processStreams != null && !processStreams.isEmpty()) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PROCESS_EXIST); |
| | | boolean b = partsPermissionService.deleteByPartsId(partsInfo.getPartsId()); |
| | | //验证是否存在文档 |
| | | List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type","3").eq("attribution_id",partsId)); |
| | | if (!docRelativeList.isEmpty()){ |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DOC_EXIST); |
| | | } |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = partsDepartmentService.deleteByPartsId(partsInfo.getPartsId()); |
| | |
| | | b = permissionStreamService.deleteDepartPermsByPartsId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId()); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = docInfoService.deleteByPartsId(partsInfo.getPartsId()); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("产品结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(4); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("零件名称:"+partsInfo.getPartsName()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | return super.removeById(partsInfo.getPartsId()); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignAddDepart(PartsInfo partsInfo, Collection<Department> departmentList) { |
| | | public boolean assignAddDepart(PartsInfo partsInfo, Collection<MdcProduction> departmentList) { |
| | | if(partsInfo == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsDepartment> partsDepartments = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getDepartId()); |
| | | PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId()); |
| | | if(en == null) { |
| | | en = new PartsDepartment(); |
| | | en.setDepartId(item.getDepartId()); |
| | | en.setDepartId(item.getId()); |
| | | en.setPartsId(partsInfo.getPartsId()); |
| | | partsDepartments.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId(), item.getDepartId()); |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), |
| | | partsInfo.getPartsId(), item.getId()); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream.setDepartId(item.getDepartId()); |
| | | stream.setDepartId(item.getId()); |
| | | stream.setProductId(partsInfo.getProductId()); |
| | | stream.setComponentId(partsInfo.getComponentId()); |
| | | stream.setPartsId(partsInfo.getPartsId()); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignRemoveDepart(PartsInfo partsInfo, Collection<Department> departmentList) { |
| | | public boolean assignRemoveDepart(PartsInfo partsInfo, Collection<MdcProduction> departmentList) { |
| | | if(partsInfo == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsDepartment> partsDepartments = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getDepartId()); |
| | | PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId()); |
| | | if(en != null) { |
| | | partsDepartments.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId(), item.getDepartId()); |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), |
| | | partsInfo.getPartsId(), item.getId()); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |