| | |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.service.impl.ProductOrderServiceImpl; |
| | | 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 ProductOrderServiceImpl productOrderServiceImpl; |
| | | |
| | | @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.setNpsNo("SC" + String.format("%08d", salesLedgerProduct.getId())); |
| | | productOrder.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | productOrder.setSaleLedgerProductId(salesLedgerProduct.getId()); |
| | | String string = productOrderServiceImpl.generateNextOrderNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); |
| | | productOrder.setNpsNo(string); |
| | | productOrder.setQuantity(salesLedgerProduct.getQuantity());//需求数量 |
| | | productOrder.setCompleteQuantity(BigDecimal.ZERO);//完成数量 |
| | | productOrderMapper.insert(productOrder); |
| | |
| | | //新增生产订单工艺路线子表 |
| | | List<ProcessRouteItem> processRouteItems = processRouteItemMapper.selectList(new QueryWrapper<ProcessRouteItem>().lambda().eq(ProcessRouteItem::getRouteId, processRoute.getId())); |
| | | // 生成当前日期的前缀:年月日 |
| | | String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | String datePrefix = "GD" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | for (ProcessRouteItem processRouteItem : processRouteItems) { |
| | | ProductProcessRouteItem productProcessRouteItem = new ProductProcessRouteItem(); |
| | | productProcessRouteItem.setProductModelId(processRouteItem.getProductModelId()); |
| | |
| | | int insert = productProcessRouteItemMapper.insert(productProcessRouteItem); |
| | | if (insert > 0) { |
| | | // 查询今日已存在的最大工单号 |
| | | QueryWrapper<ProductWorkOrder> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.likeRight("work_order_no", datePrefix) |
| | | .orderByDesc("work_order_no") |
| | | .last("LIMIT 1"); |
| | | |
| | | ProductWorkOrder lastWorkOrder = productWorkOrderMapper.selectOne(queryWrapper); |
| | | |
| | | ProductWorkOrder lastWorkOrder = productWorkOrderMapper.selectMax(datePrefix); |
| | | int sequenceNumber = 1; // 默认序号 |
| | | if (lastWorkOrder != null && lastWorkOrder.getWorkOrderNo() != null) { |
| | | String lastNo = lastWorkOrder.getWorkOrderNo().toString(); |
| | |
| | | //批量查询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)); |
| | | } |
| | | } |
| | | |
| | |
| | | IPage<SalesLedgerProductDto> salesLedgerProductDtoIPage = salesLedgerProductMapper.listPagePurchaseLedger(page, salesLedgerProduct); |
| | | salesLedgerProductDtoIPage.getRecords().forEach(item -> { |
| | | // 判断状态 |
| | | if(item.getTaxInclusiveTotalPrice().compareTo(item.getInvoiceTotal()) == 0){ |
| | | if(item.getTaxInclusiveTotalPrice().compareTo(item.getTicketsTotal()) == 0){ |
| | | item.setStatusName("已完成付款"); |
| | | }else{ |
| | | item.setStatusName("未完成付款"); |