| | |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.service.impl.SalesLedgerProductionAccountingServiceImpl; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | |
| | | private ProductStructureMapper productStructureMapper; |
| | | @Autowired |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | @Autowired |
| | | private SalesLedgerProductionAccountingServiceImpl salesLedgerProductionAccountingServiceImpl; |
| | | |
| | | @Override |
| | | public SalesLedgerProduct selectSalesLedgerProductById(Long id) { |
| | |
| | | int result; |
| | | Long salesLedgerId = salesLedgerProduct.getSalesLedgerId(); |
| | | if (salesLedgerProduct.getId() == null) { |
| | | salesLedgerProduct.setRegisterDate(LocalDateTime.now()); |
| | | result = salesLedgerProductMapper.insert(salesLedgerProduct); |
| | | addProductionData(salesLedgerProduct); |
| | | } else { |
| | |
| | | /*删除对应的生产数据并重新新增*/ |
| | | deleteProductionData(Arrays.asList(salesLedgerProduct.getId())); |
| | | // 删除生产核算数据 |
| | | LambdaQueryWrapper<SalesLedgerProductionAccounting> reportWrapper = new LambdaQueryWrapper<>(); |
| | | reportWrapper.in(SalesLedgerProductionAccounting::getSalesLedgerId, salesLedgerId); |
| | | salesLedgerProductionAccountingMapper.delete(reportWrapper); |
| | | |
| | | addProductionData(salesLedgerProduct); |
| | | } |
| | | |
| | |
| | | public void addProductionData(SalesLedgerProduct salesLedgerProduct) { |
| | | ProductOrder productOrder = new ProductOrder(); |
| | | productOrder.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId()); |
| | | productOrder.setProductModelId(salesLedgerProduct.getId()); |
| | | productOrder.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | productOrder.setSaleLedgerProductId(salesLedgerProduct.getId()); |
| | | productOrder.setNpsNo("SC" + String.format("%08d", salesLedgerProduct.getId())); |
| | | productOrder.setQuantity(salesLedgerProduct.getQuantity());//需求数量 |
| | | productOrder.setCompleteQuantity(BigDecimal.ZERO);//完成数量 |
| | |
| | | } |
| | | } |
| | | // 生成完整的工单号 |
| | | String workOrderNoStr = String.format("%s%03d", datePrefix, sequenceNumber); |
| | | String workOrderNoStr ="GD"+ String.format("%s%03d", datePrefix, sequenceNumber); |
| | | ProductWorkOrder productWorkOrder = new ProductWorkOrder(); |
| | | productWorkOrder.setProductProcessRouteItemId(productProcessRouteItem.getId()); |
| | | productWorkOrder.setProductOrderId(productOrder.getId()); |
| | |
| | | //批量查询productOrder |
| | | List<ProductOrder> productOrders = productOrderMapper.selectList( |
| | | new LambdaQueryWrapper<ProductOrder>() |
| | | .in(ProductOrder::getProductModelId, productIds) |
| | | .in(ProductOrder::getSaleLedgerProductId, productIds) |
| | | ); |
| | | if (!org.springframework.util.CollectionUtils.isEmpty(productOrders)) { |
| | | List<Long> orderIds = productOrders.stream() |
| | |
| | | } |
| | | }); |
| | | qualityInspectMapper.deleteByProductMainIds(productMainIds); |
| | | salesLedgerProductionAccountingMapper.delete(new LambdaQueryWrapper<SalesLedgerProductionAccounting>() |
| | | .in(SalesLedgerProductionAccounting::getProductMainId, productMainIds)); |
| | | } |
| | | |
| | | // 删除生产主表数据 |
| | |
| | | |
| | | // 批量删除productOrder |
| | | productOrderMapper.delete(new LambdaQueryWrapper<ProductOrder>() |
| | | .in(ProductOrder::getProductModelId, productIds)); |
| | | .in(ProductOrder::getSaleLedgerProductId, productIds)); |
| | | } |
| | | } |
| | | |