gongchunyi
2 天以前 278bc72697e323e1a162f72c8572163033bd12ca
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -27,6 +27,7 @@
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.excel.ExcelUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.other.mapper.TempFileMapper;
@@ -822,7 +823,11 @@
            record.setSalesLedgerProcessRouteId(route.getId());
            Integer isCompleted = inputRecord != null && inputRecord.getIsCompleted() != null ? inputRecord.getIsCompleted() : 0;
            record.setIsCompleted(isCompleted);
            record.setCompletedTime(Objects.equals(isCompleted, 1) ? LocalDateTime.now() : null);
            if (Objects.equals(isCompleted, 1)) {
                record.setCompletedTime(inputRecord != null && inputRecord.getCompletedTime() != null ? inputRecord.getCompletedTime() : LocalDateTime.now());
            } else {
                record.setCompletedTime(null);
            }
            routeRecordList.add(record);
        }
        salesLedgerProcessRouteRecordService.saveBatch(routeRecordList);
@@ -1905,7 +1910,11 @@
            BigDecimal stockedQty = item.getStockedQuantity() == null ? BigDecimal.ZERO : item.getStockedQuantity();
            return orderQty.compareTo(BigDecimal.ZERO) <= 0 || stockedQty.compareTo(orderQty) >= 0;
        });
        ledger.setStockStatus(allStocked ? 2 : (hasStocked ? 1 : 0));
        int newStockStatus = allStocked ? 2 : (hasStocked ? 1 : 0);
        if (newStockStatus > 0 && ledger.getDeliveryDate() == null) {
            ledger.setDeliveryDate(LocalDate.now().plusDays(7));
        }
        ledger.setStockStatus(newStockStatus);
        baseMapper.updateById(ledger);
    }
@@ -2070,7 +2079,11 @@
            return sq != null && sq.compareTo(BigDecimal.ZERO) > 0;
        });
        boolean allLinesFull = ledgerAllProducts.stream().allMatch(p -> Objects.equals(p.getProductStockStatus(), 2));
        salesLedger.setStockStatus(allLinesFull ? 2 : (anyInbound ? 1 : 0));
        int newStockStatus = allLinesFull ? 2 : (anyInbound ? 1 : 0);
        if (newStockStatus > 0 && salesLedger.getDeliveryDate() == null) {
            salesLedger.setDeliveryDate(LocalDate.now().plusDays(7));
        }
        salesLedger.setStockStatus(newStockStatus);
        baseMapper.updateById(salesLedger);
    }
@@ -4441,7 +4454,7 @@
                sheetMap.put("工艺路线", sheetData);
            }
            com.ruoyi.common.utils.excel.ExcelUtils.exportManySheet(response, "销售台账工艺路线导出", sheetMap);
            ExcelUtils.exportManySheet(response, "销售台账工艺路线导出", sheetMap);
        } catch (Exception e) {
            log.error("导出售后台账工艺路线失败", e);
            throw new ServiceException("导出售后台账工艺路线失败:" + e.getMessage());
@@ -4487,7 +4500,7 @@
    private List<Object> buildProcessRouteRow(SalesLedger salesLedger, SalesLedgerProduct product, SalesLedgerProcessRouteRecord route) {
        List<Object> row = new ArrayList<>();
        row.add(salesLedger.getEntryDate() == null ? "" : DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, salesLedger.getEntryDate()));
        row.add(route.getCompletedTime() == null ? "" : route.getCompletedTime().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")));
        row.add(salesLedger.getSalesContractNo());
        row.add(salesLedger.getCustomerName());
        row.add(product == null ? "" : product.getSpecificationModel());