From 81f7d381c300f6b0a22c00f98517b2619d0094f4 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期三, 23 七月 2025 16:00:27 +0800
Subject: [PATCH] yys  释放javaWork资源路径

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java |   47 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index 837245e..b6c43ed 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -2,15 +2,24 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.basic.mapper.CustomerMapper;
 import com.ruoyi.basic.pojo.Customer;
+import com.ruoyi.common.enums.FileNameType;
 import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.other.mapper.TempFileMapper;
 import com.ruoyi.other.pojo.TempFile;
+import com.ruoyi.production.mapper.SalesLedgerSchedulingMapper;
+import com.ruoyi.production.pojo.SalesLedgerScheduling;
+import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.sales.dto.MonthlyAmountDto;
 import com.ruoyi.sales.dto.SalesLedgerDto;
 import com.ruoyi.sales.mapper.*;
@@ -68,8 +77,10 @@
 
     private final InvoiceLedgerMapper invoiceLedgerMapper;
 
+    private final SalesLedgerSchedulingMapper salesLedgerSchedulingMapper;
+
     @Autowired
-    private InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
+    private SysDeptMapper sysDeptMapper;
 
     @Value("${file.upload-dir}")
     private String uploadDir;
@@ -85,6 +96,7 @@
         return salesLedgerMapper.selectSalesLedgerList(salesLedgerDto);
     }
 
+    @Override
     public SalesLedgerDto getSalesLedgerWithProducts(SalesLedgerDto salesLedgerDto) {
         // 1. 鏌ヨ涓昏〃
         SalesLedger salesLedger = salesLedgerMapper.selectById(salesLedgerDto.getId());
@@ -95,12 +107,15 @@
         // 2. 鏌ヨ瀛愯〃
         LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>();
         productWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedger.getId());
+        productWrapper.eq(SalesLedgerProduct::getType, 1);
         List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(productWrapper);
         for (SalesLedgerProduct product : products) {
             product.setOriginalNoInvoiceNum(product.getNoInvoiceNum());
             // 鎻愪緵涓存椂鏈紑绁ㄦ暟锛屾湭寮�绁ㄩ噾棰濅緵鍓嶆璁$畻
             product.setTempnoInvoiceAmount(product.getNoInvoiceAmount());
             product.setTempNoInvoiceNum(product.getNoInvoiceNum());
+            product.setRegister(SecurityUtils.getLoginUser().getUser().getNickName());
+            product.setRegisterDate(LocalDateTime.now());
         }
 
         // 3.鏌ヨ涓婁紶鏂囦欢
@@ -238,6 +253,11 @@
         return monthlyAmounts;
     }
 
+    @Override
+    public IPage<SalesLedger> selectSalesLedgerListPage(Page page, SalesLedgerDto salesLedgerDto) {
+        return salesLedgerMapper.selectSalesLedgerListPage(page, salesLedgerDto);
+    }
+
     // 鍐呴儴绫荤敤浜庡瓨鍌ㄨ仛鍚堢粨鏋�
     private static class GroupedCustomer {
         private final Long customerId;
@@ -296,15 +316,23 @@
         List<Long> idList = Arrays.stream(ids)
                 .filter(Objects::nonNull)
                 .collect(Collectors.toList());
-
         if (CollectionUtils.isEmpty(idList)) {
             return 0;
+        }
+        // 鐢熶骇璁㈠崟鏈夊緟鎺掍骇鏁版嵁锛屽彴璐︿笉鍙垹闄�
+        LambdaQueryWrapper<SalesLedgerScheduling> salesLedgerSchedulingLambdaQueryWrapper = new LambdaQueryWrapper<SalesLedgerScheduling>()
+                .in(SalesLedgerScheduling::getSalesLedgerId, idList);
+        if (salesLedgerSchedulingMapper.selectCount(salesLedgerSchedulingLambdaQueryWrapper) > 0) {
+            throw new BaseException("鏈夋帓浜ф暟鎹紝涓嶅彲鍒犻櫎");
         }
         // 1. 鍏堝垹闄ゅ瓙琛ㄦ暟鎹�
         LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>();
         productWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList);
         salesLedgerProductMapper.delete(productWrapper);
-
+        // 鍒犻櫎鐢熶骇璁㈠崟鏁版嵁
+        LambdaQueryWrapper<SalesLedgerScheduling> in = new LambdaQueryWrapper<SalesLedgerScheduling>()
+                .in(SalesLedgerScheduling::getSalesLedgerId, idList);
+        salesLedgerSchedulingMapper.delete(in);
         // 2. 鍐嶅垹闄や富琛ㄦ暟鎹�
         return salesLedgerMapper.deleteBatchIds(idList);
     }
@@ -414,7 +442,8 @@
                 fileRecord.setName(originalFilename);
                 fileRecord.setUrl(formalFilePath.toString());
                 fileRecord.setCreateTime(LocalDateTime.now());
-                fileRecord.setType("1");
+                //閿�鍞�
+                fileRecord.setType(FileNameType.SALE.getValue());
                 commonFileMapper.insert(fileRecord);
 
                 // 鍒犻櫎涓存椂鏂囦欢璁板綍
@@ -492,7 +521,15 @@
                 throw new RuntimeException("鑾峰彇鍚堝悓缂栧彿鐢熸垚閿佸け璐ワ細瓒呮椂");
             }
 
-            // 2. 鏌ヨ褰撳ぉ宸插瓨鍦ㄧ殑搴忓垪鍙凤紙涓庡師閫昏緫涓�鑷达級
+            // 2. 鏌ヨ褰撳ぉ/鍏徃宸插瓨鍦ㄧ殑搴忓垪鍙凤紙涓庡師閫昏緫涓�鑷达級
+            Long tenantId = SecurityUtils.getLoginUser().getTenantId();
+            if (null != tenantId) {
+                //鑾峰彇鍏徃缂栧彿
+                SysDept sysDept = sysDeptMapper.selectDeptById(tenantId.longValue());
+                if (!ObjectUtils.isEmpty(sysDept)) {
+                    datePart = (StringUtils.isEmpty(sysDept.getDeptNick()) ? "" : sysDept.getDeptNick()) + datePart;
+                }
+            }
             List<Integer> existingSequences = salesLedgerMapper.selectSequencesByDate(datePart);
             int nextSequence = findFirstMissingSequence(existingSequences);
 

--
Gitblit v1.9.3