| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.other.mapper.TempFileMapper; |
| | | import com.ruoyi.other.pojo.TempFile; |
| | | import com.ruoyi.production.dto.ProductOrderDto; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.service.ProductionProductMainService; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | |
| | | import com.ruoyi.sales.mapper.*; |
| | | import com.ruoyi.sales.pojo.*; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import com.ruoyi.sales.service.SalesLedgerProductionRefService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.FilenameUtils; |
| | |
| | | private SysUserMapper sysUserMapper; |
| | | @Autowired |
| | | private CustomerPrivatePoolMapper customerPrivatePoolMapper; |
| | | @Autowired |
| | | private SalesLedgerProductionRefService salesLedgerProductionRefService; |
| | | @Autowired |
| | | private SalesLedgerProductionRefMapper salesLedgerProductionRefMapper; |
| | | |
| | | @Override |
| | | public List<SalesLedger> selectSalesLedgerList(SalesLedgerDto salesLedgerDto) { |
| | |
| | | if (salesLedger == null) { |
| | | throw new BaseException("台账不存在"); |
| | | } |
| | | |
| | | List<ProductOrderDto> productionOrdersBySalesLedgerId = getProductionOrdersBySalesLedgerId(salesLedger.getId()); |
| | | salesLedger.setProductionOrders(productionOrdersBySalesLedgerId); |
| | | // 2. 查询子表 |
| | | LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>(); |
| | | productWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedger.getId()); |
| | |
| | | return resultDto; |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductOrderDto> getProductionOrdersBySalesLedgerId(Long salesLedgerId) { |
| | | List<Long> productOrderIds = salesLedgerProductionRefMapper.getProductionOrderIdsBySalesLedgerId(salesLedgerId); |
| | | if (productOrderIds == null || productOrderIds.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return productOrderMapper.listByProductOrderId(productOrderIds); |
| | | } |
| | | |
| | | @Override |
| | | public void getProductionOrders(List<SalesLedger> records) { |
| | | List<Long> ledgerIdList = records.stream() |
| | | .map(SalesLedger::getId) |
| | | .collect(Collectors.toList()); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 下划线命名转驼峰命名 |
| | | */ |
| | |
| | | ); |
| | | } |
| | | |
| | | // 5. 迁移临时文件到正式目录 |
| | | //5. 绑定销售订单和生产订单 |
| | | bindSalesOrderAndProductionOrder(salesLedgerDto.getProductionOrderIds(), salesLedger.getId()); |
| | | |
| | | // 6. 迁移临时文件到正式目录 |
| | | if (salesLedgerDto.getTempFileIds() != null && !salesLedgerDto.getTempFileIds().isEmpty()) { |
| | | migrateTempFilesToFormal(salesLedger.getId(), salesLedgerDto.getTempFileIds()); |
| | | } |
| | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | private void bindSalesOrderAndProductionOrder(List<Long> productionOrderIds, Long salesLedgerId) { |
| | | // 先删除该销售台账所有旧关联 |
| | | LambdaQueryWrapper<SalesLedgerProductionRef> deleteWrapper = Wrappers.lambdaQuery(); |
| | | deleteWrapper.eq(SalesLedgerProductionRef::getSalesLedgerId, salesLedgerId); |
| | | salesLedgerProductionRefMapper.delete(deleteWrapper); |
| | | |
| | | if (productionOrderIds == null || productionOrderIds.isEmpty()) { |
| | | return; |
| | | } |
| | | List<SalesLedgerProductionRef> refList = productionOrderIds.stream() |
| | | .map(productOrderId -> { |
| | | SalesLedgerProductionRef ref = new SalesLedgerProductionRef(); |
| | | ref.setSalesLedgerId(salesLedgerId); |
| | | ref.setProductOrderId(productOrderId); |
| | | return ref; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | salesLedgerProductionRefService.saveBatch(refList); |
| | | } |
| | | |
| | | public void addApproveByPurchase(LoginUser loginUser, SalesLedger salesLedger) throws Exception { |
| | |
| | | salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice()); |
| | | salesLedgerProductMapper.insert(salesLedgerProduct); |
| | | // 添加生产数据 |
| | | salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); |
| | | //salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); |
| | | } |
| | | } |
| | | } |