| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean addProductMain(ProductionProductMainDto dto) { |
| | | SysUser user = userMapper.selectUserById(dto.getUserId()); |
| | | ProductionProductMain productionProductMain = new ProductionProductMain(); |
| | |
| | | Long modelId = drawMaterial.getProductModelId(); |
| | | BigDecimal reportQty = drawMaterial.getReportQty(); |
| | | |
| | | if (reportQty != null && reportQty.compareTo(new BigDecimal(0)) == 0) { |
| | | throw new RuntimeException("产品" + drawMaterial.getProductName() + "- 型号" + drawMaterial.getModel() + |
| | | "- 批次号=" + drawMaterial.getBatchNo() + "的料已用完,请重新领料"); |
| | | |
| | | } |
| | | |
| | | String key = drawMaterial.getProductModelId() + "_" + |
| | | (drawMaterial.getBatchNo() == null ? "" : drawMaterial.getBatchNo()) + "_" + |
| | | (drawMaterial.getCustomer() == null ? "" : drawMaterial.getCustomer()); |
| | |
| | | order.setDrawMaterials(JSON.toJSONString(existingMaterialList)); |
| | | productOrderMapper.updateById(order); |
| | | } |
| | | } else { |
| | | throw new RuntimeException("请领取投入材料"); |
| | | } |
| | | /*新增报工产出表*/ |
| | | ProductionProductOutput productionProductOutput = new ProductionProductOutput(); |
| | |
| | | //合格数量=报工数量 |
| | | BigDecimal productQty = productionProductOutput.getQuantity(); |
| | | //只有合格数量>0才能增加相应数据 |
| | | ProductWorkOrder pwo = productWorkOrderMapper.selectById(productionProductMain.getWorkOrderId()); |
| | | String customer = "长治市轴承制造有限公司"; |
| | | if (productQty.compareTo(BigDecimal.ZERO) > 0) { |
| | | /*新增质检*/ |
| | | List<ProductProcessRouteItem> productProcessRouteItems = productProcessRouteItemMapper.selectList(Wrappers.<ProductProcessRouteItem>lambdaQuery().eq(ProductProcessRouteItem::getProductRouteId, productProcessRouteItem.getProductRouteId())); |
| | |
| | | inspectType = 2; |
| | | process = null; |
| | | } |
| | | ProductWorkOrder productWorkOrder = productWorkOrderMapper.selectById(productionProductMain.getWorkOrderId()); |
| | | ProductOrder productOrder = productOrderMapper.selectById(productWorkOrder.getProductOrderId()); |
| | | ProductOrder productOrder = productOrderMapper.selectById(pwo.getProductOrderId()); |
| | | if (productOrder == null) { |
| | | throw new RuntimeException("生产订单不存在"); |
| | | } |
| | |
| | | qualityInspect.setProductModelId(productModel.getId()); |
| | | qualityInspect.setBatchNo(productOrder.getBatchNo()); |
| | | qualityInspect.setManufacturingTeam(productOrder.getManufacturingTeam()); |
| | | qualityInspect.setProductionDate(pwo.getActualStartTime() != null ? pwo.getActualStartTime() : LocalDate.now()); |
| | | qualityInspectMapper.insert(qualityInspect); |
| | | List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(product.getId(), inspectType, process); |
| | | if (qualityTestStandard.size() > 0) { |
| | |
| | | } |
| | | } else { |
| | | //直接入库 |
| | | String customer = "长治市轴承制造有限公司"; |
| | | stockUtils.addStock(productProcessRouteItem.getProductModelId(), productionProductOutput.getQuantity().subtract(productionProductOutput.getScrapQty()), |
| | | StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode(), productionProductMain.getId(),order.getBatchNo(),customer,null |
| | | StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode(), productionProductMain.getId(), order.getBatchNo(), customer, pwo.getActualStartTime() != null ? pwo.getActualStartTime() : LocalDate.now() |
| | | ); |
| | | } |
| | | /*更新工单和生产订单*/ |
| | |
| | | } |
| | | } |
| | | productOrderMapper.updateById(productOrder); |
| | | /*添加生产核算 区分工序是计件还是计时*/ |
| | | BigDecimal workHours = (productProcess.getType() == 1) |
| | | ? productProcess.getSalaryQuota().multiply(productQty) |
| | | : productProcess.getSalaryQuota(); |
| | | /*添加生产核算*/ |
| | | BigDecimal workHours = productProcess.getSalaryQuota(); |
| | | |
| | | SalesLedgerProductionAccounting salesLedgerProductionAccounting = SalesLedgerProductionAccounting.builder() |
| | | .productMainId(productionProductMain.getId()) |
| | |
| | | //如果报废数量>0,需要进入报废的库存 |
| | | if (ObjectUtils.isNotEmpty(dto.getScrapQty())) { |
| | | if (dto.getScrapQty().compareTo(BigDecimal.ZERO) > 0) { |
| | | stockUtils.addUnStock(productModel.getId(), dto.getScrapQty(), StockInUnQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode(), productionProductMain.getId()); |
| | | stockUtils.addUnStock(productModel.getId(), dto.getScrapQty(), StockInUnQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode(), productionProductMain.getId(), |
| | | order.getBatchNo(), customer, pwo.getActualStartTime() != null ? pwo.getActualStartTime() : LocalDate.now()); |
| | | } |
| | | } |
| | | return true; |
| | |
| | | public Boolean removeProductMain(Long id) { |
| | | //判断该条报工是否不合格处理,如果不合格处理了,则不允许删除 |
| | | List<QualityInspect> qualityInspects = qualityInspectMapper.selectList(Wrappers.<QualityInspect>lambdaQuery().eq(QualityInspect::getProductMainId, id)); |
| | | if (qualityInspects.size() > 0) { |
| | | if (!qualityInspects.isEmpty()) { |
| | | List<QualityUnqualified> qualityUnqualifieds = qualityUnqualifiedMapper.selectList(Wrappers.<QualityUnqualified>lambdaQuery() |
| | | .in(QualityUnqualified::getInspectId, qualityInspects.stream().map(QualityInspect::getId).collect(Collectors.toList()))); |
| | | if (qualityUnqualifieds.size() > 0 && qualityUnqualifieds.get(0).getInspectState() == 1) { |