| | |
| | | import com.ruoyi.basic.service.IProductModelService; |
| | | import com.ruoyi.basic.service.IProductService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.production.dto.ProductProcessDto; |
| | | import com.ruoyi.production.dto.ProductProcessImportDto; |
| | | import com.ruoyi.production.enums.ProductProcessEnum; |
| | | import com.ruoyi.production.mapper.ProcessRouteItemMapper; |
| | | import com.ruoyi.production.mapper.ProductProcessMapper; |
| | | import com.ruoyi.production.mapper.ProductProcessRouteItemMapper; |
| | |
| | | throw new ServiceException("新增失败,计划工时不能为空"); |
| | | } |
| | | // 判断产品是否存在 |
| | | if (ObjectUtils.isEmpty(productProcessDto.getProductModelId())) { |
| | | throw new ServiceException("新增失败,部件不能为空"); |
| | | } |
| | | ProductModel productModel = productModelService.getById(productProcessDto.getProductModelId()); |
| | | if (productModel == null) { |
| | | throw new ServiceException("新增失败,该部件不存在"); |
| | | } |
| | | validateDuplicateTypeForSameProduct(productModel.getId(), productProcessDto.getType(), null); |
| | | // if (ObjectUtils.isEmpty(productProcessDto.getProductModelId())) { |
| | | // throw new ServiceException("新增失败,部件不能为空"); |
| | | // } |
| | | // ProductModel productModel = productModelService.getById(productProcessDto.getProductModelId()); |
| | | // if (productModel == null) { |
| | | // throw new ServiceException("新增失败,该部件不存在"); |
| | | // } |
| | | // validateDuplicateTypeForSameProduct(productModel.getId(), productProcessDto.getType(), null); |
| | | |
| | | ProductProcess productProcess = new ProductProcess(); |
| | | BeanUtils.copyProperties(productProcessDto, productProcess); |
| | | productProcess.setProductModelId(productModel.getId()); |
| | | // productProcess.setProductModelId(productModel.getId()); |
| | | |
| | | validatePlanner(productProcessDto.getPlannerId(), productProcessDto.getPlannerName(), null); |
| | | |
| | |
| | | if (oldProductProcess == null) { |
| | | throw new ServiceException("修改失败,工序不存在"); |
| | | } |
| | | Long finalProductModelId = ObjectUtils.isNotEmpty(productProcessDto.getProductModelId()) |
| | | ? productProcessDto.getProductModelId() : oldProductProcess.getProductModelId(); |
| | | Integer finalType = ObjectUtils.isNotEmpty(productProcessDto.getType()) |
| | | ? productProcessDto.getType() : oldProductProcess.getType(); |
| | | |
| | | // Long finalProductModelId = ObjectUtils.isNotEmpty(productProcessDto.getProductModelId()) |
| | | // ? productProcessDto.getProductModelId() : oldProductProcess.getProductModelId(); |
| | | // Integer finalType = ObjectUtils.isNotEmpty(productProcessDto.getType()) |
| | | // ? productProcessDto.getType() : oldProductProcess.getType(); |
| | | // |
| | | // 判断关联产品是否存在 |
| | | ProductModel productModel = productModelService.getById(finalProductModelId); |
| | | if (productModel == null) { |
| | | throw new ServiceException("修改失败,关联部件不存在"); |
| | | } |
| | | validateDuplicateTypeForSameProduct(productModel.getId(), finalType, productProcessDto.getId()); |
| | | // ProductModel productModel = productModelService.getById(finalProductModelId); |
| | | // if (productModel == null) { |
| | | // throw new ServiceException("修改失败,关联部件不存在"); |
| | | // } |
| | | // validateDuplicateTypeForSameProduct(productModel.getId(), finalType, productProcessDto.getId()); |
| | | |
| | | // 校验计划人员 |
| | | validatePlanner(productProcessDto.getPlannerId(), productProcessDto.getPlannerName(), null); |
| | |
| | | if (ObjectUtils.isEmpty(importDto.getProductProcessType())) { |
| | | throw new ServiceException("第" + rowNum + "行:部件【" + importDto.getName() + "】的类型不能为空"); |
| | | } |
| | | ProductProcessEnum enumByInfo = ProductProcessEnum.getEnumByInfo(importDto.getProductProcessType()); |
| | | if (ObjectUtils.isEmpty(enumByInfo)) { |
| | | String dictValue = DictUtils.getDictValue("product_process_type", importDto.getProductProcessType()); |
| | | if (StringUtils.isEmpty(dictValue)) { |
| | | throw new ServiceException("第" + rowNum + "行:部件【" + importDto.getName() + "】的类型【" |
| | | + importDto.getProductProcessType() + "】不存在,请填写正确的类型:加工、刮板冷芯制作、管路组对、罐体连接及调试、测试打压、其他"); |
| | | + importDto.getProductProcessType() + "】不存在,请填写正确的类型:" + DictUtils.getDictLabels("product_process_type")); |
| | | } |
| | | // 检验计划工时 |
| | | if (importDto.getSalaryQuota() == null || importDto.getSalaryQuota().compareTo(BigDecimal.ZERO) < 0) { |
| | |
| | | ProductProcess productProcess = new ProductProcess(); |
| | | BeanUtils.copyProperties(importDto, productProcess); |
| | | productProcess.setProductModelId(productModel.getId()); |
| | | productProcess.setType(enumByInfo.getCode()); |
| | | productProcess.setType(Integer.valueOf(dictValue)); |
| | | if (sysUser != null) { |
| | | productProcess.setPlannerId(sysUser.getUserId()); |
| | | productProcess.setPlannerName(sysUser.getNickName()); |