| | |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.controller.ProductWorkOrderController; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.dto.ProductionProductMainDto; |
| | | import com.ruoyi.production.mapper.*; |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class ProductionProductMainServiceImpl extends ServiceImpl<ProductionProductMainMapper, ProductionProductMain> implements ProductionProductMainService { |
| | | |
| | | private final ProcurementRecordOutMapper procurementRecordOutMapper; |
| | | private ProductionProductMainMapper productionProductMainMapper; |
| | | |
| | | private ProductWorkOrderController productWorkOrderController; |
| | | |
| | | private ProductWorkOrderMapper productWorkOrderMapper; |
| | | |
| | |
| | | |
| | | private ProductionProductOutputMapper productionProductOutputMapper; |
| | | |
| | | private ProcessRouteItemMapper processRouteItemMapper; |
| | | |
| | | private ProductModelMapper productModelMapper; |
| | | |
| | |
| | | |
| | | |
| | | private QualityTestStandardParamMapper qualityTestStandardParamMapper; |
| | | private QualityTestStandardBindingMapper qualityTestStandardBindingMapper; |
| | | private QualityTestStandardMapper qualityTestStandardMapper; |
| | | |
| | | private QualityInspectParamMapper qualityInspectParamMapper; |
| | |
| | | productionProductInput.setQuantity(productStructureDto.getUnitQuantity().multiply(dto.getQuantity())); |
| | | productionProductInput.setProductMainId(productionProductMain.getId()); |
| | | productionProductInputMapper.insert(productionProductInput); |
| | | //对应的库存出库 |
| | | DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | LocalDate now = LocalDate.now(); |
| | | ProcurementRecordOut procurementRecordOut1 = procurementRecordOutMapper.selectCode(dateFormat.format(now)); |
| | | Long aLong = procurementRecordOut1 == null ? 1L : Long.valueOf(procurementRecordOut1.getCode().split("LS" + dateFormat.format(now))[1]); |
| | | ProcurementRecordOut.ProcurementRecordOutBuilder procurementRecordOut = ProcurementRecordOut.builder() |
| | | .procurementRecordStorageId(0) |
| | | .code("LS" + dateFormat.format(now) + String.format("%03d", aLong + 1)) |
| | | .salesLedgerProductId(productionProductMain.getId())//关联报工产出 |
| | | .inboundBatches(aLong.equals(0L) ? "第1批次" : "第" + (aLong + 1) + "批次") |
| | | .inboundNum(productionProductInput.getQuantity()) |
| | | .type(4) |
| | | .createBy(user.getNickName()) |
| | | .productModelId(productModel1.getId()); |
| | | procurementRecordOutMapper.insert(procurementRecordOut.build()); |
| | | stockUtils.substractStock(productStructureDto.getProductModelId(), productionProductInput.getQuantity(), StockQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(), productionProductMain.getId()); |
| | | |
| | | } |
| | | /*新增报工产出表*/ |
| | | ProductionProductOutput productionProductOutput = new ProductionProductOutput(); |
| | |
| | | // 删除产出记录 |
| | | productionProductOutputMapper.delete(new LambdaQueryWrapper<ProductionProductOutput>() |
| | | .eq(ProductionProductOutput::getProductMainId, productionProductMain.getId())); |
| | | /*删除投入*/ |
| | | procurementRecordOutMapper.delete(new LambdaQueryWrapper<ProcurementRecordOut>() |
| | | .eq(ProcurementRecordOut::getSalesLedgerProductId, productionProductMain.getId())); |
| | | //删除入库 |
| | | productionProductInputMapper.delete(new LambdaQueryWrapper<ProductionProductInput>() |
| | | .eq(ProductionProductInput::getProductMainId, productionProductMain.getId())); |
| | | //删除报废的入库记录 |
| | | stockUtils.deleteStockRecord(productionProductMain.getId(), StockUnQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode()); |
| | | //删除投入对应的出库记录 |
| | | stockUtils.deleteStockRecord(productionProductMain.getId(), StockQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode()); |
| | | // 删除主表 |
| | | productionProductMainMapper.deleteById(productionProductMain.getId()); |
| | | return true; |