| | |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | if (salesLedgerProduct.getId() == null) { |
| | | salesLedgerProduct.setRegisterDate(LocalDateTime.now()); |
| | | result = salesLedgerProductMapper.insert(salesLedgerProduct); |
| | | addProductionData(salesLedgerProduct); |
| | | } else { |
| | | //查询原本的产品型号id |
| | | result = salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | |
| | | * 新增生产数据 |
| | | */ |
| | | public void addProductionData(SalesLedgerProduct salesLedgerProduct) { |
| | | addProductionDataInternal(salesLedgerProduct, null); |
| | | } |
| | | |
| | | /** |
| | | * 审批通过后创建生产主计划(带审批状态) |
| | | */ |
| | | public void addProductionDataForApproved(SalesLedgerProduct salesLedgerProduct, int approvalStatus) { |
| | | addProductionDataInternal(salesLedgerProduct, approvalStatus); |
| | | } |
| | | |
| | | private void addProductionDataInternal(SalesLedgerProduct salesLedgerProduct, Integer approvalStatus) { |
| | | //先判断该产品是否需要生产 |
| | | if (!salesLedgerProduct.getIsProduction()) { |
| | | return; |
| | |
| | | ProductionPlan productionPlan = new ProductionPlan(); |
| | | productionPlan.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId()); |
| | | productionPlan.setSalesLedgerProductId(salesLedgerProduct.getId()); |
| | | productionPlan.setMpsNo(generateNextPlanNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")))); |
| | | productionPlan.setMpsNo(generateNextPlanNo(salesLedger.getEntryDate().toInstant() |
| | | .atZone(ZoneId.systemDefault()) |
| | | .toLocalDate().format(DateTimeFormatter.ofPattern("yyyyMMdd")))); |
| | | productionPlan.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | productionPlan.setQtyRequired(salesLedgerProduct.getQuantity()); |
| | | productionPlan.setSource("销售"); |
| | | productionPlan.setStatus(0); |
| | | productionPlan.setRequiredDate(salesLedger.getDeliveryDate());//需求日期=交货日期 |
| | | productionPlan.setPromisedDeliveryDate(salesLedger.getDeliveryDate());//承诺日期=交货日期 |
| | | productionPlan.setRequiredDate(salesLedger.getDeliveryDate()); |
| | | productionPlan.setPromisedDeliveryDate(salesLedger.getDeliveryDate()); |
| | | if (approvalStatus != null) { |
| | | productionPlan.setApprovalStatus(approvalStatus); |
| | | } |
| | | productionPlanMapper.insert(productionPlan); |
| | | |
| | | } |
| | | |
| | | /** |