| | |
| | | |
| | | 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; |
| | |
| | | private IDocInfoService docInfoService; |
| | | @Autowired |
| | | private INcLogInfoService iNcLogInfoService; |
| | | @Autowired |
| | | private IDocRelativeService iDocRelativeService; |
| | | @Autowired |
| | | private IProductPermissionService productPermissionService; |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean addPartsInfo(PartsInfo partsInfo) { |
| | |
| | | if(componentInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); |
| | | partsInfo.setPartsStatus(1); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("产品结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(2); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("零件名称:"+partsInfo.getPartsName()+",零件代号:"+partsInfo.getPartsCode()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | boolean b = super.save(partsInfo); |
| | | List<PermissionStream> oldDepartPermList = permissionStreamService.getByComponentId(componentInfo.getProductId(), componentInfo.getComponentId()); |
| | | if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) { |
| | |
| | | } |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | PartsPermission permission = new PartsPermission(); |
| | | permission.setPartsId(partsInfo.getPartsId()); |
| | | permission.setUserId(userId); |
| | | b = partsPermissionService.save(permission); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | // if(!b) |
| | | // ExceptionCast.cast(CommonCode.FAIL); |
| | | b = productPermissionService.add(partsInfo.getPartsId(), userId,"3"); |
| | | if (!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); |
| | | } |
| | | //添加用户权限 |
| | | PermissionStream stream = new PermissionStream(); |
| | | stream.setProductId(partsInfo.getProductId()); |
| | | stream.setComponentId(partsInfo.getComponentId()); |
| | | stream.setPartsId(partsInfo.getPartsId()); |
| | | stream.setUserId(userId); |
| | | // //添加日志 |
| | | // NcLogInfo ncLogInfogx = new NcLogInfo(); |
| | | // //模块 |
| | | // ncLogInfogx.setModuleInfo("产品结构树"); |
| | | // //类型 |
| | | // ncLogInfogx.setOperateType(2); |
| | | // //日志内容 |
| | | // ncLogInfogx.setLogContent("零件名称:"+partsInfo.getPartsName()+"生成默认工序,工序号:"+processStream.getProcessCode()); |
| | | // iNcLogInfoService.saveLogNcInfos(ncLogInfogx); |
| | | return permissionStreamService.save(stream); |
| | | } |
| | | |
| | |
| | | partsInfo.setPartsStatus(null); |
| | | partsInfo.setProductId(null); |
| | | partsInfo.setComponentId(null); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("产品结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(3); |
| | | //修改保存备注 |
| | | ncLogInfo.setRemark(JSONObject.toJSONString(en)); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("修改部件名称:"+productInfoMapper.selectById(en.getProductId()).getProductName()+"子集零件"); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | boolean b = super.updateById(partsInfo); |
| | | if(!b) |
| | | return false; |
| | |
| | | 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()); |
| | | } |
| | | |