| | |
| | | salesLedger.setIsFh(isFh); |
| | | |
| | | salesLedger.setIsEdit(!isFh); |
| | | |
| | | |
| | | // 根据 reviewStatus 控制反审相关字段的显示 |
| | | if (salesLedger.getReviewStatus() != null && salesLedger.getReviewStatus() != 2) { |
| | | // 当 reviewStatus 不为 2 时,隐藏反审时间、反审人和反审人ID |
| | |
| | | salesLedgerProcessRouteService.saveBatch(salesLedgerProcessRouteList); |
| | | |
| | | List<SalesLedgerProcessRoute> savedRoutes = salesLedgerProcessRouteService.list(new LambdaQueryWrapper<SalesLedgerProcessRoute>() |
| | | .eq(SalesLedgerProcessRoute::getSalesLedgerId, salesLedger.getId()) |
| | | .eq(SalesLedgerProcessRoute::getProcessRouteId, processRoute.getId())); |
| | | .eq(SalesLedgerProcessRoute::getSalesLedgerId, salesLedger.getId()) |
| | | .eq(SalesLedgerProcessRoute::getProcessRouteId, processRoute.getId())); |
| | | Map<Long, SalesLedgerProcessRoute> routeMap = savedRoutes.stream() |
| | | .filter(item -> item.getProcessRouteItemId() != null) |
| | | .collect(Collectors.toMap(SalesLedgerProcessRoute::getProcessRouteItemId, item -> item, (a, b) -> a)); |
| | | .filter(item -> item.getProcessRouteItemId() != null) |
| | | .collect(Collectors.toMap(SalesLedgerProcessRoute::getProcessRouteItemId, item -> item, (a, b) -> a)); |
| | | |
| | | Map<Long, SalesLedgerProcessRouteRecord> inputRecordMap = new HashMap<>(); |
| | | if (CollectionUtils.isNotEmpty(salesLedgerProcessRouteDto.getRecordList())) { |
| | |
| | | SalesLedgerProcessRouteDto dto = new SalesLedgerProcessRouteDto(); |
| | | List<SalesLedgerProcessRoute> list = baseMapper.selectSalesProcess(salesLedgerId); |
| | | List<SalesLedgerProcessRouteRecord> recordList = salesLedgerProcessRouteRecordService.list( |
| | | new LambdaQueryWrapper<SalesLedgerProcessRouteRecord>() |
| | | .eq(SalesLedgerProcessRouteRecord::getSalesLedgerId, salesLedgerId) |
| | | .orderByAsc(SalesLedgerProcessRouteRecord::getId) |
| | | new LambdaQueryWrapper<SalesLedgerProcessRouteRecord>() |
| | | .eq(SalesLedgerProcessRouteRecord::getSalesLedgerId, salesLedgerId) |
| | | .orderByAsc(SalesLedgerProcessRouteRecord::getId) |
| | | ); |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | Long processRouteId = list.get(0).getProcessRouteId(); |
| | |
| | | dto.setList(list); |
| | | if (CollectionUtils.isNotEmpty(list) && CollectionUtils.isNotEmpty(recordList)) { |
| | | Map<Long, Long> routeItemIdMap = list.stream() |
| | | .filter(item -> item.getId() != null && item.getProcessRouteItemId() != null) |
| | | .collect(Collectors.toMap(SalesLedgerProcessRoute::getId, SalesLedgerProcessRoute::getProcessRouteItemId, (a, b) -> a)); |
| | | .filter(item -> item.getId() != null && item.getProcessRouteItemId() != null) |
| | | .collect(Collectors.toMap(SalesLedgerProcessRoute::getId, SalesLedgerProcessRoute::getProcessRouteItemId, (a, b) -> a)); |
| | | recordList.forEach(record -> { |
| | | if (record != null && record.getSalesLedgerProcessRouteId() != null) { |
| | | record.setProcessRouteItemId(routeItemIdMap.get(record.getSalesLedgerProcessRouteId())); |
| | |
| | | } |
| | | SalesLedger ledger = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>().eq(SalesLedger::getSalesContractNo, orderNo).last("LIMIT 1")); |
| | | if (ledger == null) { |
| | | throw new ServiceException("导入失败,订单编号[" + orderNo + "]不存在,无法补录已发货数据"); |
| | | // throw new ServiceException("导入失败,订单编号[" + orderNo + "]不存在,无法补录已发货数据"); |
| | | continue; |
| | | } |
| | | List<SalesLedgerProduct> dbProducts = salesLedgerProductMapper.selectList(new LambdaQueryWrapper<SalesLedgerProduct>().eq(SalesLedgerProduct::getSalesLedgerId, ledger.getId()).eq(SalesLedgerProduct::getType, SaleEnum.SALE.getCode())); |
| | | if (CollectionUtils.isEmpty(dbProducts)) { |
| | |
| | | shippingInfo.setType("货车"); |
| | | shippingInfo.setShippingCarNumber("无"); |
| | | shippingInfo.setShippingDate(row.getReportDate()); |
| | | long existedShippingCount = shippingInfoMapper.selectCount(new LambdaQueryWrapper<ShippingInfo>().eq(ShippingInfo::getSalesLedgerId, ledger.getId()).eq(ShippingInfo::getSalesLedgerProductId, dbProduct.getId()).eq(StringUtils.hasText(row.getShippingNo()), ShippingInfo::getShippingNo, row.getShippingNo()).eq(row.getReportDate() != null, ShippingInfo::getShippingDate, row.getReportDate())); |
| | | long existedShippingCount = shippingInfoMapper.selectCount(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getSalesLedgerId, ledger.getId()) |
| | | .eq(ShippingInfo::getSalesLedgerProductId, dbProduct.getId()) |
| | | .eq(StringUtils.hasText(row.getShippingNo()), ShippingInfo::getShippingNo, row.getShippingNo()) |
| | | .eq(row.getReportDate() != null, ShippingInfo::getShippingDate, row.getReportDate())); |
| | | if (existedShippingCount > 0) { |
| | | // continue; |
| | | List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getSalesLedgerId, ledger.getId()) |
| | | .eq(ShippingInfo::getSalesLedgerProductId, dbProduct.getId()) |
| | | .eq(StringUtils.hasText(row.getShippingNo()), ShippingInfo::getShippingNo, row.getShippingNo()) |
| | | .eq(row.getReportDate() != null, ShippingInfo::getShippingDate, row.getReportDate())); |
| | | throw new ServiceException("导入失败,订单编号[" + orderNo + "]存在重复发货记录,请勿重复导入"); |
| | | } |
| | | shippingInfoMapper.insert(shippingInfo); |
| | |
| | | } |
| | | ledger.setStockStatus(allInbound ? 2 : (anyInbound ? 1 : 0)); |
| | | ledger.setDeliveryStatus(allShipped ? 5 : 1); |
| | | // ledger.setReviewStatus(1); |
| | | salesLedgerMapper.updateById(ledger); |
| | | } |
| | | } |
| | |
| | | } |
| | | Map<String, ProductModel> productModelKeyMap = productModelMapper.selectList(null).stream().filter(Objects::nonNull).filter(m -> m.getProductId() != null && StringUtils.hasText(m.getModel())).collect(Collectors.toMap(m -> buildProductModelKey(m.getProductId(), m.getModel()), Function.identity(), (a, b) -> a)); |
| | | |
| | | List<String> extraProcessNames = Arrays.asList("打孔", "挖缺", "安全角", "磨边"); |
| | | List<String> extraProcessNames = Arrays.asList("打孔", "挖缺", "安全角", "磨边", "精磨边", "运费", "加急费"); |
| | | Map<String, SalesLedgerProductProcess> processMap = salesLedgerProductProcessService.list(new LambdaQueryWrapper<SalesLedgerProductProcess>().in(SalesLedgerProductProcess::getProcessName, extraProcessNames)).stream().filter(Objects::nonNull).filter(p -> StringUtils.hasText(p.getProcessName())).collect(Collectors.toMap(SalesLedgerProductProcess::getProcessName, Function.identity(), (a, b) -> a)); |
| | | List<ProcessRoute> processRoutes = processRouteMapper.selectList(new LambdaQueryWrapper<ProcessRoute>().eq(ProcessRoute::getProductModelId, 0L)); |
| | | Map<String, ProcessRoute> routeNameMap = processRoutes.stream().filter(Objects::nonNull).filter(r -> StringUtils.hasText(r.getProcessRouteName())).collect(Collectors.toMap(r -> normalizeRouteFlowKey(r.getProcessRouteName()), Function.identity(), this::chooseBetterRoute)); |
| | |
| | | ledger.setDeliveryDate(first.getDeliveryDeadline() == null ? (first.getReportDate() == null ? LocalDate.now().plusDays(7) : DateUtils.toLocalDate(first.getReportDate()).plusDays(7)) : DateUtils.toLocalDate(first.getDeliveryDeadline())); |
| | | ledger.setDeliveryStatus(1); |
| | | ledger.setStockStatus(0); |
| | | ledger.setReviewStatus(0); |
| | | |
| | | ledger.setCustomerId(customer.getId()); |
| | | ledger.setCustomerContractNo(StringUtils.hasText(ledger.getCustomerContractNo()) ? ledger.getCustomerContractNo() : customer.getTaxpayerIdentificationNumber()); |
| | |
| | | ledger.setContractAmount(BigDecimal.ZERO); |
| | | salesLedgerMapper.insert(ledger); |
| | | bindImportProcessRoute(ledger.getId(), rowList, routeNameMap, routeItemMap); |
| | | int reviewCount = 0; |
| | | |
| | | BigDecimal contractAmount = BigDecimal.ZERO; |
| | | for (SalesNotShippingImportDto row : rowList) { |
| | |
| | | product.setPendingInvoiceTotal(lineAmount); |
| | | product.fillRemainingQuantity(); |
| | | salesLedgerProductMapper.insert(product); |
| | | if (StringUtils.isNotEmpty(row.getAuditor())) { |
| | | reviewCount++; |
| | | } |
| | | |
| | | List<SalesLedgerProductProcess> bindProcessList = buildImportProcessBinds(row, processMap); |
| | | if (CollectionUtils.isNotEmpty(bindProcessList)) { |
| | |
| | | } |
| | | |
| | | ledger.setContractAmount(contractAmount); |
| | | if (reviewCount == rowList.size()) { |
| | | ledger.setReviewStatus(1); |
| | | } |
| | | |
| | | salesLedgerMapper.updateById(ledger); |
| | | } |
| | | } |
| | |
| | | mergeProcessQuantity(processQuantityMap, "挖缺", toProcessQuantity(row.getNotching())); |
| | | mergeProcessQuantity(processQuantityMap, "安全角", toProcessQuantity(row.getSafetyCorner())); |
| | | mergeProcessQuantity(processQuantityMap, "磨边", toProcessQuantity(row.getGrindingIrregular())); |
| | | mergeProcessQuantity(processQuantityMap, "精磨边", toProcessQuantity(row.getFineGrinding())); |
| | | mergeProcessQuantity(processQuantityMap, "运费", toProcessQuantity(row.getFreightFee())); |
| | | mergeProcessQuantity(processQuantityMap, "加急费", toProcessQuantity(row.getUrgentFee())); |
| | | |
| | | List<SalesLedgerProductProcess> result = new ArrayList<>(); |
| | | for (Map.Entry<String, Integer> entry : processQuantityMap.entrySet()) { |
| | |
| | | created.setProductId(product.getId()); |
| | | created.setModel(modelName.trim()); |
| | | created.setThickness(thickness); |
| | | created.setUnit("mm"); |
| | | productModelMapper.insert(created); |
| | | productModelKeyMap.put(key, created); |
| | | return created; |
| | |
| | | String shippingNo = StringUtils.hasText(row.getShippingNo()) ? row.getShippingNo().trim() : ""; |
| | | String dateStr = row.getReportDate() == null ? "" : String.valueOf(row.getReportDate().getTime()); |
| | | String subCategory = StringUtils.hasText(row.getProductSubCategory()) ? row.getProductSubCategory().trim() : ""; |
| | | return ledgerId + "|" + subCategory + "|" + shippingNo + "|" + dateStr + "|" + defaultDecimal(row.getQuantity()); |
| | | Long sequence = row.getSequence(); |
| | | if (sequence == null) { |
| | | throw new ServiceException("新增失败,导入出库单编号为空"); |
| | | } |
| | | return ledgerId + "|" + subCategory + "|" + shippingNo + "|" + dateStr + "|" + defaultDecimal(row.getQuantity()) + "|" + sequence; |
| | | } |
| | | |
| | | private void createShippingQualityInspect(SalesLedger ledger, SalesLedgerProduct dbProduct, SalesShippingImportDto row, BigDecimal inspectQty) { |
| | |
| | | baseMapper.updateById(salesLedger); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理销售台账反审逻辑 |
| | | * 1. 设置反审相关信息(时间、人员) |
| | |
| | | |
| | | // 复制产品到新台账 |
| | | List<SalesLedgerProduct> originalProducts = salesLedgerProductMapper.selectList( |
| | | Wrappers.<SalesLedgerProduct>lambdaQuery() |
| | | .eq(SalesLedgerProduct::getSalesLedgerId, id) |
| | | Wrappers.<SalesLedgerProduct>lambdaQuery() |
| | | .eq(SalesLedgerProduct::getSalesLedgerId, id) |
| | | ); |
| | | for (SalesLedgerProduct originalProduct : originalProducts) { |
| | | SalesLedgerProduct newProduct = new SalesLedgerProduct(); |
| | |
| | | salesLedger.setCounterReviewPerson(loginUser.getUser().getNickName()); |
| | | salesLedger.setCounterReviewPersonId(loginUser.getUserId()); |
| | | salesLedger.setReviewStatus(2); |
| | | |
| | | |
| | | Long originalSalesLedgerId = salesLedger.getId(); |
| | | |
| | | |
| | | // 2. 查询原销售台账数据 |
| | | SalesLedger originalLedger = salesLedgerMapper.selectById(originalSalesLedgerId); |
| | | if (originalLedger == null) { |
| | | throw new ServiceException("原订单不存在,无法反审"); |
| | | } |
| | | |
| | | |
| | | // 3. 创建新的销售台账,复制原台账数据 |
| | | SalesLedger newLedger = new SalesLedger(); |
| | | BeanUtils.copyProperties(originalLedger, newLedger); |
| | |
| | | newLedger.setCounterReviewTime(null); // 清空反审时间 |
| | | newLedger.setCounterReviewPerson(null); // 清空反审人 |
| | | newLedger.setCounterReviewPersonId(null); // 清空反审人ID |
| | | |
| | | |
| | | // 4. 插入新的销售台账 |
| | | salesLedgerMapper.insert(newLedger); |
| | | |
| | | |
| | | // 5. 查询并复制原台账的所有产品数据 |
| | | List<SalesLedgerProduct> originalProducts = salesLedgerProductMapper.selectList( |
| | | Wrappers.<SalesLedgerProduct>lambdaQuery() |
| | | .eq(SalesLedgerProduct::getSalesLedgerId, originalSalesLedgerId) |
| | | Wrappers.<SalesLedgerProduct>lambdaQuery() |
| | | .eq(SalesLedgerProduct::getSalesLedgerId, originalSalesLedgerId) |
| | | ); |
| | | |
| | | |
| | | for (SalesLedgerProduct originalProduct : originalProducts) { |
| | | // 5.1 创建新产品记录,复制原产品数据 |
| | | SalesLedgerProduct newProduct = new SalesLedgerProduct(); |
| | |
| | | newProduct.setAvailableQuality(newProduct.getQuantity().subtract(newProduct.getReturnQuality())); // 重新计算可用数量 |
| | | newProduct.setProductStockStatus(0); // 产品库存状态重置为0 |
| | | newProduct.fillRemainingQuantity(); // 重新计算剩余数量 |
| | | |
| | | |
| | | // 5.2 插入新产品记录 |
| | | salesLedgerProductMapper.insert(newProduct); |
| | | } |
| | | |
| | | |
| | | // 6. 处理原订单的库存数据(生成反审出入库记录) |
| | | processOriginalOrderStock(originalSalesLedgerId); |
| | | |
| | | |
| | | // 7. 清除原订单的质检记录 |
| | | clearQualityInspectRecords(originalSalesLedgerId); |
| | | |
| | | |
| | | // 8. 清除原订单的发货信息和发货审批记录 |
| | | clearShippingAndApprovalRecords(originalSalesLedgerId); |
| | | |
| | | |
| | | // 9. 取消原订单相关的审批流程 |
| | | cancelApproveProcesses(originalSalesLedgerId, originalLedger.getSalesContractNo()); |
| | | } |
| | |
| | | private void clearQualityInspectRecords(Long originalSalesLedgerId) { |
| | | // 删除与原订单关联的质检记录 |
| | | qualityInspectMapper.delete( |
| | | Wrappers.<QualityInspect>lambdaQuery() |
| | | .eq(QualityInspect::getPurchaseLedgerId, originalSalesLedgerId) |
| | | Wrappers.<QualityInspect>lambdaQuery() |
| | | .eq(QualityInspect::getPurchaseLedgerId, originalSalesLedgerId) |
| | | ); |
| | | } |
| | | |
| | |
| | | private void clearShippingAndApprovalRecords(Long originalSalesLedgerId) { |
| | | // 1. 查询原订单的所有发货信息 |
| | | List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList( |
| | | Wrappers.<ShippingInfo>lambdaQuery() |
| | | .eq(ShippingInfo::getSalesLedgerId, originalSalesLedgerId) |
| | | Wrappers.<ShippingInfo>lambdaQuery() |
| | | .eq(ShippingInfo::getSalesLedgerId, originalSalesLedgerId) |
| | | ); |
| | | |
| | | |
| | | // 2. 删除发货审批记录 |
| | | if (!CollectionUtils.isEmpty(shippingInfos)) { |
| | | List<Long> shippingInfoIds = shippingInfos.stream() |
| | | .map(ShippingInfo::getId) |
| | | .collect(Collectors.toList()); |
| | | |
| | | .map(ShippingInfo::getId) |
| | | .collect(Collectors.toList()); |
| | | |
| | | shipmentApprovalMapper.delete( |
| | | Wrappers.<ShipmentApproval>lambdaQuery() |
| | | .eq(ShipmentApproval::getSalesLedgerId, originalSalesLedgerId) |
| | | .or() |
| | | .in(ShipmentApproval::getShippingInfoId, shippingInfoIds) |
| | | Wrappers.<ShipmentApproval>lambdaQuery() |
| | | .eq(ShipmentApproval::getSalesLedgerId, originalSalesLedgerId) |
| | | .or() |
| | | .in(ShipmentApproval::getShippingInfoId, shippingInfoIds) |
| | | ); |
| | | |
| | | |
| | | // 3. 删除发货信息记录 |
| | | shippingInfoMapper.delete( |
| | | Wrappers.<ShippingInfo>lambdaQuery() |
| | | .eq(ShippingInfo::getSalesLedgerId, originalSalesLedgerId) |
| | | Wrappers.<ShippingInfo>lambdaQuery() |
| | | .eq(ShippingInfo::getSalesLedgerId, originalSalesLedgerId) |
| | | ); |
| | | } |
| | | } |
| | |
| | | private void cancelApproveProcesses(Long originalSalesLedgerId, String originalSalesContractNo) { |
| | | // 取消入库审批流程 |
| | | List<ApproveProcess> stockInApproveProcesses = approveProcessService.list( |
| | | new LambdaQueryWrapper<ApproveProcess>() |
| | | .eq(ApproveProcess::getApproveType, ApproveTypeEnum.STOCK_IN.getCode()) |
| | | .like(ApproveProcess::getApproveRemark, "salesStock:" + originalSalesLedgerId + ":") |
| | | .eq(ApproveProcess::getApproveDelete, 0) |
| | | new LambdaQueryWrapper<ApproveProcess>() |
| | | .eq(ApproveProcess::getApproveType, ApproveTypeEnum.STOCK_IN.getCode()) |
| | | .like(ApproveProcess::getApproveRemark, "salesStock:" + originalSalesLedgerId + ":") |
| | | .eq(ApproveProcess::getApproveDelete, 0) |
| | | ); |
| | | |
| | | |
| | | for (ApproveProcess process : stockInApproveProcesses) { |
| | | process.setApproveStatus(3); // 设置为审批失败状态 |
| | | process.setApproveDelete(1); // 标记为已删除 |
| | | approveProcessService.updateById(process); |
| | | } |
| | | |
| | | |
| | | // 取消发货审批流程 |
| | | List<ApproveProcess> deliveryApproveProcesses = approveProcessService.list( |
| | | new LambdaQueryWrapper<ApproveProcess>() |
| | | .eq(ApproveProcess::getApproveType, 7) // 发货审批类型 |
| | | .like(ApproveProcess::getApproveReason, "发货审批:" + originalSalesContractNo) |
| | | .eq(ApproveProcess::getApproveDelete, 0) |
| | | new LambdaQueryWrapper<ApproveProcess>() |
| | | .eq(ApproveProcess::getApproveType, 7) // 发货审批类型 |
| | | .like(ApproveProcess::getApproveReason, "发货审批:" + originalSalesContractNo) |
| | | .eq(ApproveProcess::getApproveDelete, 0) |
| | | ); |
| | | |
| | | |
| | | for (ApproveProcess process : deliveryApproveProcesses) { |
| | | process.setApproveStatus(3); // 设置为审批失败状态 |
| | | process.setApproveDelete(1); // 标记为已删除 |
| | |
| | | private void processOriginalOrderStock(Long originalSalesLedgerId) { |
| | | // 1. 查询原订单的所有入库记录 |
| | | List<StockInRecord> stockInRecords = stockInRecordMapper.selectList( |
| | | Wrappers.<StockInRecord>lambdaQuery() |
| | | .eq(StockInRecord::getSalesLedgerId, originalSalesLedgerId) |
| | | Wrappers.<StockInRecord>lambdaQuery() |
| | | .eq(StockInRecord::getSalesLedgerId, originalSalesLedgerId) |
| | | ); |
| | | |
| | | |
| | | // 2. 删除入库记录并扣减库存 |
| | | for (StockInRecord stockInRecord : stockInRecords) { |
| | | // 从库存表中扣减相应数量 |
| | |
| | | stockInventoryDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockInventoryMapper.updateSubtractStockInventory(stockInventoryDto); |
| | | } |
| | | |
| | | |
| | | // 3. 删除所有入库记录 |
| | | stockInRecordMapper.delete( |
| | | Wrappers.<StockInRecord>lambdaQuery() |
| | | .eq(StockInRecord::getSalesLedgerId, originalSalesLedgerId) |
| | | Wrappers.<StockInRecord>lambdaQuery() |
| | | .eq(StockInRecord::getSalesLedgerId, originalSalesLedgerId) |
| | | ); |
| | | |
| | | |
| | | // 4. 查询原订单的所有出库记录 |
| | | List<StockOutRecord> stockOutRecords = stockOutRecordMapper.selectList( |
| | | Wrappers.<StockOutRecord>lambdaQuery() |
| | | .eq(StockOutRecord::getSalesLedgerId, originalSalesLedgerId) |
| | | Wrappers.<StockOutRecord>lambdaQuery() |
| | | .eq(StockOutRecord::getSalesLedgerId, originalSalesLedgerId) |
| | | ); |
| | | |
| | | |
| | | // 5. 删除出库记录并增加库存 |
| | | for (StockOutRecord stockOutRecord : stockOutRecords) { |
| | | // 向库存表中增加相应数量 |
| | |
| | | stockInventoryDto.setQualitity(stockOutRecord.getStockOutNum()); |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | | } |
| | | |
| | | |
| | | // 6. 删除所有出库记录 |
| | | stockOutRecordMapper.delete( |
| | | Wrappers.<StockOutRecord>lambdaQuery() |
| | | .eq(StockOutRecord::getSalesLedgerId, originalSalesLedgerId) |
| | | Wrappers.<StockOutRecord>lambdaQuery() |
| | | .eq(StockOutRecord::getSalesLedgerId, originalSalesLedgerId) |
| | | ); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | salesLedgerMapper.update(null, |
| | | Wrappers.<SalesLedger>lambdaUpdate() |
| | | .in(SalesLedger::getId, ids) |
| | | .set(SalesLedger::getOrderStatus, 1) |
| | | Wrappers.<SalesLedger>lambdaUpdate() |
| | | .in(SalesLedger::getId, ids) |
| | | .set(SalesLedger::getOrderStatus, 1) |
| | | ); |
| | | } |
| | | |
| | |
| | | if ("label".equals(printType)) { |
| | | int currentCount = ledger.getLabelPrintCount() == null ? 0 : ledger.getLabelPrintCount(); |
| | | salesLedgerMapper.update(null, |
| | | Wrappers.<SalesLedger>lambdaUpdate() |
| | | .eq(SalesLedger::getId, id) |
| | | .set(SalesLedger::getLabelPrintCount, currentCount + 1) |
| | | Wrappers.<SalesLedger>lambdaUpdate() |
| | | .eq(SalesLedger::getId, id) |
| | | .set(SalesLedger::getLabelPrintCount, currentCount + 1) |
| | | ); |
| | | } else { |
| | | int currentCount = ledger.getDocumentPrintCount() == null ? 0 : ledger.getDocumentPrintCount(); |
| | | salesLedgerMapper.update(null, |
| | | Wrappers.<SalesLedger>lambdaUpdate() |
| | | .eq(SalesLedger::getId, id) |
| | | .set(SalesLedger::getDocumentPrintCount, currentCount + 1) |
| | | Wrappers.<SalesLedger>lambdaUpdate() |
| | | .eq(SalesLedger::getId, id) |
| | | .set(SalesLedger::getDocumentPrintCount, currentCount + 1) |
| | | ); |
| | | } |
| | | } |
| | |
| | | Page<SalesLedger> page = new Page<>(-1, -1); |
| | | // 使用 Wrappers 构建升序查询 |
| | | LambdaQueryWrapper<SalesLedger> queryWrapper = Wrappers.<SalesLedger>lambdaQuery() |
| | | .orderByAsc(SalesLedger::getEntryDate) |
| | | .orderByAsc(SalesLedger::getId); |
| | | .orderByAsc(SalesLedger::getEntryDate) |
| | | .orderByAsc(SalesLedger::getId); |
| | | |
| | | // 添加查询条件 |
| | | if (salesLedgerDto.getCustomerName() != null && !salesLedgerDto.getCustomerName().isEmpty()) { |
| | |
| | | } |
| | | if (salesLedgerDto.getReviewStatusList() != null && !salesLedgerDto.getReviewStatusList().isEmpty()) { |
| | | queryWrapper.and(w -> w.in(SalesLedger::getReviewStatus, salesLedgerDto.getReviewStatusList()) |
| | | .or().isNull(SalesLedger::getReviewStatus)); |
| | | .or().isNull(SalesLedger::getReviewStatus)); |
| | | } |
| | | |
| | | IPage<SalesLedger> ledgerPage = salesLedgerMapper.selectPage(page, queryWrapper); |
| | |
| | | ledgerDto.setEntryPersonName(ledger.getEntryPersonName()); |
| | | ledgerDto.setEntryDate(ledger.getEntryDate()); |
| | | ledgerDto.setExecutionDate(ledger.getExecutionDate() != null ? |
| | | java.sql.Date.valueOf(ledger.getExecutionDate()) : null); |
| | | java.sql.Date.valueOf(ledger.getExecutionDate()) : null); |
| | | ledgerDto.setDeliveryDate(ledger.getDeliveryDate() != null ? |
| | | java.sql.Date.valueOf(ledger.getDeliveryDate()) : null); |
| | | java.sql.Date.valueOf(ledger.getDeliveryDate()) : null); |
| | | ledgerDto.setContractAmount(ledger.getContractAmount()); |
| | | ledgerDto.setRemarks(ledger.getRemarks()); |
| | | ledgerDto.setCustomerRemarks(ledger.getCustomerRemarks()); |
| | |
| | | |
| | | // 查询该台账的产品列表 |
| | | List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList( |
| | | Wrappers.<SalesLedgerProduct>lambdaQuery() |
| | | .eq(SalesLedgerProduct::getSalesLedgerId, ledger.getId()) |
| | | .eq(SalesLedgerProduct::getType, 1) |
| | | Wrappers.<SalesLedgerProduct>lambdaQuery() |
| | | .eq(SalesLedgerProduct::getSalesLedgerId, ledger.getId()) |
| | | .eq(SalesLedgerProduct::getType, 1) |
| | | ); |
| | | |
| | | for (SalesLedgerProduct product : products) { |
| | |
| | | } |
| | | |
| | | LambdaQueryWrapper<SalesLedgerProcessRouteRecord> queryWrapper = Wrappers.<SalesLedgerProcessRouteRecord>lambdaQuery() |
| | | .eq(SalesLedgerProcessRouteRecord::getIsCompleted, 1) |
| | | .ge(SalesLedgerProcessRouteRecord::getCompletedTime, startTime) |
| | | .le(SalesLedgerProcessRouteRecord::getCompletedTime, endTime) |
| | | .orderByAsc(SalesLedgerProcessRouteRecord::getCompletedTime) |
| | | .orderByAsc(SalesLedgerProcessRouteRecord::getId); |
| | | .eq(SalesLedgerProcessRouteRecord::getIsCompleted, 1) |
| | | .ge(SalesLedgerProcessRouteRecord::getCompletedTime, startTime) |
| | | .le(SalesLedgerProcessRouteRecord::getCompletedTime, endTime) |
| | | .orderByAsc(SalesLedgerProcessRouteRecord::getCompletedTime) |
| | | .orderByAsc(SalesLedgerProcessRouteRecord::getId); |
| | | |
| | | if (CollectionUtils.isNotEmpty(salesLedgerIds)) { |
| | | queryWrapper.in(SalesLedgerProcessRouteRecord::getSalesLedgerId, salesLedgerIds); |
| | |
| | | |
| | | if (CollectionUtils.isNotEmpty(completedRoutes)) { |
| | | List<Long> routeSalesLedgerIds = completedRoutes.stream() |
| | | .map(SalesLedgerProcessRouteRecord::getSalesLedgerId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | .map(SalesLedgerProcessRouteRecord::getSalesLedgerId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | List<Long> salesLedgerProcessRouteIds = completedRoutes.stream() |
| | | .map(SalesLedgerProcessRouteRecord::getSalesLedgerProcessRouteId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | .map(SalesLedgerProcessRouteRecord::getSalesLedgerProcessRouteId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | if (CollectionUtils.isNotEmpty(routeSalesLedgerIds)) { |
| | | salesLedgerMap = salesLedgerMapper.selectBatchIds(routeSalesLedgerIds).stream() |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toMap(SalesLedger::getId, item -> item, (a, b) -> a)); |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toMap(SalesLedger::getId, item -> item, (a, b) -> a)); |
| | | List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(new LambdaQueryWrapper<SalesLedgerProduct>() |
| | | .in(SalesLedgerProduct::getSalesLedgerId, routeSalesLedgerIds) |
| | | .eq(SalesLedgerProduct::getType, 1) |
| | | .orderByAsc(SalesLedgerProduct::getSalesLedgerId) |
| | | .orderByAsc(SalesLedgerProduct::getId)); |
| | | .in(SalesLedgerProduct::getSalesLedgerId, routeSalesLedgerIds) |
| | | .eq(SalesLedgerProduct::getType, 1) |
| | | .orderByAsc(SalesLedgerProduct::getSalesLedgerId) |
| | | .orderByAsc(SalesLedgerProduct::getId)); |
| | | productMap = products.stream().collect(Collectors.groupingBy( |
| | | SalesLedgerProduct::getSalesLedgerId, |
| | | LinkedHashMap::new, |
| | | Collectors.toList() |
| | | SalesLedgerProduct::getSalesLedgerId, |
| | | LinkedHashMap::new, |
| | | Collectors.toList() |
| | | )); |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(salesLedgerProcessRouteIds)) { |
| | | routeMap = salesLedgerProcessRouteService.listByIds(salesLedgerProcessRouteIds).stream() |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toMap(SalesLedgerProcessRoute::getId, item -> item, (a, b) -> a)); |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toMap(SalesLedgerProcessRoute::getId, item -> item, (a, b) -> a)); |
| | | List<Long> processRouteItemIds = routeMap.values().stream() |
| | | .map(SalesLedgerProcessRoute::getProcessRouteItemId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | .map(SalesLedgerProcessRoute::getProcessRouteItemId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(processRouteItemIds)) { |
| | | processRouteItemMap = processRouteItemMapper.selectBatchIds(processRouteItemIds).stream() |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toMap(ProcessRouteItem::getId, item -> item, (a, b) -> a)); |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toMap(ProcessRouteItem::getId, item -> item, (a, b) -> a)); |
| | | } |
| | | } |
| | | } |
| | |
| | | final Map<Long, ProcessRouteItem> finalProcessRouteItemMap = processRouteItemMap; |
| | | LinkedHashMap<String, List<List<Object>>> sheetMap = new LinkedHashMap<>(); |
| | | List<Long> orderedProcessRouteItemIds = routeGroupMap.keySet().stream() |
| | | .sorted((left, right) -> compareProcessRouteItem(left, right, finalProcessRouteItemMap)) |
| | | .collect(Collectors.toList()); |
| | | .sorted((left, right) -> compareProcessRouteItem(left, right, finalProcessRouteItemMap)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | for (Long processRouteItemId : orderedProcessRouteItemIds) { |
| | | ProcessRouteItem processRouteItem = finalProcessRouteItemMap.get(processRouteItemId); |
| | |
| | | } |
| | | if (product.getWidth() != null && product.getHeight() != null) { |
| | | BigDecimal area = product.getWidth().multiply(product.getHeight()) |
| | | .divide(new BigDecimal("1000000"), 2, RoundingMode.HALF_UP); |
| | | .divide(new BigDecimal("1000000"), 2, RoundingMode.HALF_UP); |
| | | return area.multiply(qty).setScale(2, RoundingMode.HALF_UP); |
| | | } |
| | | return BigDecimal.ZERO; |
| | |
| | | |
| | | private String buildUniqueSheetName(Map<String, List<List<Object>>> sheetMap, ProcessRouteItem processRouteItem, Long processRouteItemId) { |
| | | String baseName = processRouteItem != null && StringUtils.hasText(processRouteItem.getProcessName()) |
| | | ? processRouteItem.getProcessName() |
| | | : "工序" + processRouteItemId; |
| | | ? processRouteItem.getProcessName() |
| | | : "工序" + processRouteItemId; |
| | | baseName = sanitizeSheetName(baseName); |
| | | String sheetName = baseName; |
| | | int suffix = 2; |
| | |
| | | private String getDeliveryStatusText(Integer status) { |
| | | if (status == null) return "未知"; |
| | | switch (status) { |
| | | case 1: return "未发货"; |
| | | case 2: return "审批中"; |
| | | case 3: return "审批不通过"; |
| | | case 4: return "审批通过"; |
| | | case 5: return "已发货"; |
| | | case 6: return "部分发货"; |
| | | default: return "未知"; |
| | | case 1: |
| | | return "未发货"; |
| | | case 2: |
| | | return "审批中"; |
| | | case 3: |
| | | return "审批不通过"; |
| | | case 4: |
| | | return "审批通过"; |
| | | case 5: |
| | | return "已发货"; |
| | | case 6: |
| | | return "部分发货"; |
| | | default: |
| | | return "未知"; |
| | | } |
| | | } |
| | | |
| | | private String getStockStatusText(Integer status) { |
| | | if (status == null) return "未知"; |
| | | switch (status) { |
| | | case 0: return "未入库"; |
| | | case 1: return "部分入库"; |
| | | case 2: return "已入库"; |
| | | case 3: return "审批中"; |
| | | default: return "未知"; |
| | | case 0: |
| | | return "未入库"; |
| | | case 1: |
| | | return "部分入库"; |
| | | case 2: |
| | | return "已入库"; |
| | | case 3: |
| | | return "审批中"; |
| | | default: |
| | | return "未知"; |
| | | } |
| | | } |
| | | |
| | | private String getReviewStatusText(Integer status) { |
| | | if (status == null) return "待审核"; |
| | | switch (status) { |
| | | case 0: return "待审核"; |
| | | case 1: return "已审核"; |
| | | case 2: return "已反审"; |
| | | default: return "待审核"; |
| | | case 0: |
| | | return "待审核"; |
| | | case 1: |
| | | return "已审核"; |
| | | case 2: |
| | | return "已反审"; |
| | | default: |
| | | return "待审核"; |
| | | } |
| | | } |
| | | |
| | | private String getOrderStatusText(Integer status) { |
| | | if (status == null || status == 0) return "进行中"; |
| | | switch (status) { |
| | | case 0: return "进行中"; |
| | | case 1: return "已完成"; |
| | | default: return "进行中"; |
| | | case 0: |
| | | return "进行中"; |
| | | case 1: |
| | | return "已完成"; |
| | | default: |
| | | return "进行中"; |
| | | } |
| | | } |
| | | } |