| | |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityInspectParamMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardParamMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import com.ruoyi.quality.pojo.QualityInspectParam; |
| | | import com.ruoyi.quality.pojo.QualityTestStandard; |
| | | import com.ruoyi.quality.pojo.QualityTestStandardParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private ProductMapper productMapper; |
| | | |
| | | private QualityTestStandardMapper qualityTestStandardMapper; |
| | | private QualityTestStandardParamMapper qualityTestStandardParamMapper; |
| | | |
| | | private QualityInspectParamMapper qualityInspectParamMapper; |
| | | |
| | |
| | | |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | |
| | | if (dto.isReportWork()) { |
| | | // 更新逻辑 - 只更新数量 |
| | | QueryWrapper<ProductionProductOutput> outputWrapper = new QueryWrapper<>(); |
| | | outputWrapper.eq("product_main_id", dto.getProductMainId()); |
| | | |
| | | ProductionProductOutput output = productionProductOutputMapper.selectOne(outputWrapper); |
| | | if (output == null) { |
| | | throw new RuntimeException("产出记录不存在"); |
| | | } |
| | | |
| | | // 查询生产核算记录 |
| | | QueryWrapper<SalesLedgerProductionAccounting> accountingWrapper = new QueryWrapper<>(); |
| | | accountingWrapper.eq("sales_ledger_work_id", dto.getProductMainId()); |
| | | SalesLedgerProductionAccounting accounting = salesLedgerProductionAccountingMapper.selectOne(accountingWrapper); |
| | | if (accounting == null) { |
| | | throw new RuntimeException("生产核算记录不存在"); |
| | | } |
| | | |
| | | // 只更新数量 |
| | | if (dto.getQuantity() != null) { |
| | | output.setQuantity(dto.getQuantity()); |
| | | productionProductOutputMapper.updateById(output); |
| | | // 更新生产核算记录 |
| | | accounting.setFinishedNum(dto.getQuantity()); |
| | | salesLedgerProductionAccountingMapper.updateById(accounting); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | // 新增逻辑 |
| | | ProductionProductMain productionProductMain = new ProductionProductMain(); |
| | |
| | | qualityInspect.setProductMainId(productionProductMain.getId()); |
| | | qualityInspectMapper.insert(qualityInspect); |
| | | |
| | | qualityTestStandardMapper.selectList( |
| | | new LambdaQueryWrapper<QualityTestStandard>() |
| | | .eq(QualityTestStandard::getProductId, product.getId()) |
| | | ).forEach(standard -> { |
| | | QualityInspectParam param = new QualityInspectParam(); |
| | | BeanUtils.copyProperties(standard, param); |
| | | param.setId(null); |
| | | param.setInspectId(qualityInspect.getId()); |
| | | qualityInspectParamMapper.insert(param); |
| | | }); |
| | | List<QualityTestStandardParam> qualityTestStandardParams = qualityTestStandardParamMapper.selectListByProductId(product.getId()); |
| | | if (qualityTestStandardParams.size()>0) { |
| | | qualityTestStandardParams.forEach(standard -> { |
| | | QualityInspectParam param = new QualityInspectParam(); |
| | | BeanUtils.copyProperties(standard, param); |
| | | param.setId(null); |
| | | param.setInspectId(qualityInspect.getId()); |
| | | qualityInspectParamMapper.insert(param); |
| | | }); |
| | | } |
| | | } |
| | | // 添加投入 |
| | | if (productModel != null) { |
| | |
| | | for (ProductStructureDto productStructureDto : productStructureDtos) { |
| | | ProductionProductInput productionProductInput = new ProductionProductInput(); |
| | | productionProductInput.setProductModelId(productStructureDto.getProductModelId()); |
| | | productionProductInput.setQuantity(productStructureDto.getUnitQuantity()); |
| | | productionProductInput.setQuantity(productStructureDto.getUnitQuantity().multiply(dto.getQuantity())); |
| | | productionProductInput.setProductMainId(productionProductMain.getId()); |
| | | productionProductInputMapper.insert(productionProductInput); |
| | | } |