| | |
| | | |
| | | @Override |
| | | public Boolean addProductOrder(ProductOrder productOrder) { |
| | | // 检查相同产品型号和批号是否已存在 |
| | | if (productOrder.getProductModelId() != null && productOrder.getBatchNo() != null) { |
| | | LambdaQueryWrapper<ProductOrder> queryWrapper = Wrappers.<ProductOrder>lambdaQuery() |
| | | .eq(ProductOrder::getProductModelId, productOrder.getProductModelId()) |
| | | .eq(ProductOrder::getBatchNo, productOrder.getBatchNo()); |
| | | if (this.count(queryWrapper) > 0) { |
| | | throw new RuntimeException("相同产品型号和批号的生产订单已存在"); |
| | | } |
| | | } |
| | | String string = generateNextOrderNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); |
| | | productOrder.setNpsNo(string); |
| | | productOrder.setCompleteQuantity(BigDecimal.ZERO); |
| | |
| | | } |
| | | // 如果有数据先加库存 |
| | | ProductOrder productOrder = productOrderMapper.selectById(productOrderDto.getId()); |
| | | if (productOrder != null) { |
| | | if (productOrder.getDrawMaterials() != null) { |
| | | List<DrawMaterialDto> materialDtoList = JSON.parseArray(productOrder.getDrawMaterials(), DrawMaterialDto.class); |
| | | for (DrawMaterialDto drawMaterialDto : materialDtoList) { |
| | | stockUtils.addStock(drawMaterialDto.getProductModelId(), drawMaterialDto.getRequisitionQty(), null, productOrderDto.getId(), |
| | | drawMaterialDto.getBatchNo(), drawMaterialDto.getCustomer() |
| | | drawMaterialDto.getBatchNo(), drawMaterialDto.getCustomer(),drawMaterialDto.getProductionDate() |
| | | ); |
| | | } |
| | | } |
| | |
| | | if (drawMaterialDto.getProductModelId() == null) { |
| | | throw new RuntimeException("产品型号ID不能为空"); |
| | | } |
| | | if (drawMaterialDto.getQualitity() == null || drawMaterialDto.getQualitity().compareTo(BigDecimal.ZERO) == 0) { |
| | | throw new RuntimeException("产品" + drawMaterialDto.getProductName() + "型号" + drawMaterialDto.getModel() |
| | | + "批号" + drawMaterialDto.getBatchNo() + "库存不足!"); |
| | | } |
| | | stockUtils.substractStock(drawMaterialDto.getProductModelId(), drawMaterialDto.getRequisitionQty(), |
| | | StockOutQualifiedRecordTypeEnum.DRAW_MATERIALS_STOCK_OUT.getCode(), productOrderDto.getId(), |
| | | drawMaterialDto.getBatchNo(),drawMaterialDto.getCustomer()); |