From 18fa07479d3c7f5a9b683ab0f698528d9bd2a9ec Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 21 四月 2026 11:23:53 +0800
Subject: [PATCH] feat: 入库管理、出库台账增加合同号字段;支持合同模糊查询

---
 src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java |  161 +++++++++++++++++++++--------------------------------
 1 files changed, 65 insertions(+), 96 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
index c149b52..807aeaf 100644
--- a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
+++ b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -1,9 +1,8 @@
 package com.ruoyi.sales.controller;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.pojo.Customer;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
@@ -13,8 +12,6 @@
 import com.ruoyi.framework.web.page.TableDataInfo;
 import com.ruoyi.sales.dto.*;
 import com.ruoyi.sales.mapper.InvoiceLedgerMapper;
-import com.ruoyi.sales.mapper.ReceiptPaymentMapper;
-import com.ruoyi.sales.pojo.ReceiptPayment;
 import com.ruoyi.sales.pojo.SalesLedger;
 import com.ruoyi.sales.pojo.SalesLedgerProcessRoute;
 import com.ruoyi.sales.service.ICommonFileService;
@@ -59,9 +56,6 @@
     @Autowired
     private InvoiceLedgerMapper invoiceLedgerMapper;
 
-    @Autowired
-    private ReceiptPaymentMapper receiptPaymentMapper;
-
     /**
      * 瀵煎叆閿�鍞彴璐�
      */
@@ -71,7 +65,8 @@
     public AjaxResult importData(@RequestParam("file")
                                  @ApiParam(value = "Excel鏂囦欢", required = true)
                                  MultipartFile file) {
-        return salesLedgerService.importData(file);
+        salesLedgerService.importData(file);
+        return AjaxResult.success();
     }
 
     @ApiOperation("瀵煎嚭閿�鍞彴璐︽ā鏉�")
@@ -116,7 +111,7 @@
      * 鏌ヨ閿�鍞彴璐﹀垪琛�
      */
     @GetMapping("/list")
-    public TableDataInfo list(Page page, SalesLedgerDto salesLedgerDto) {
+    public TableDataInfo list(Page<?> page, SalesLedgerDto salesLedgerDto) {
         startPage();
         List<SalesLedger> list = salesLedgerService.selectSalesLedgerList(salesLedgerDto);
         // 璁$畻宸插紑绁ㄩ噾棰�/鏈紑绁ㄩ噾棰�(宸插~鍐欏彂绁ㄩ噾棰濅负鍑�)
@@ -154,7 +149,7 @@
     @Log(title = "閿�鍞彴璐�", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, SalesLedgerDto salesLedgerDto) {
-        Page page = new Page(-1, -1);
+        Page<?> page = new Page<>(-1, -1);
         IPage<SalesLedger> salesLedgerIPage = listPage(page, salesLedgerDto);
         ExcelUtil<SalesLedger> util = new ExcelUtil<SalesLedger>(SalesLedger.class);
         if (salesLedgerIPage == null) {
@@ -171,7 +166,7 @@
     @Log(title = "瀵煎嚭寮�绁ㄧ櫥璁板垪琛�", businessType = BusinessType.EXPORT)
     @PostMapping("/exportOne")
     public void exportOne(HttpServletResponse response, SalesLedgerDto salesLedgerDto) {
-        Page page = new Page();
+        Page<?> page = new Page<>();
         page.setCurrent(-1);
         page.setSize(-1);
         IPage<SalesLedger> salesLedgerIPage = listPage(page, salesLedgerDto);
@@ -267,91 +262,8 @@
      * 鏌ヨ閿�鍞彴璐﹀垪琛�
      */
     @GetMapping("/listPage")
-    public IPage<SalesLedger> listPage(Page page, SalesLedgerDto salesLedgerDto) {
-        IPage<SalesLedger> iPage = salesLedgerService.selectSalesLedgerListPage(page, salesLedgerDto);
-
-        //  鏌ヨ缁撴灉涓虹┖,鐩存帴杩斿洖
-        if (CollectionUtils.isEmpty(iPage.getRecords())) {
-            return iPage;
-        }
-
-        //  鑾峰彇褰撳墠椤垫墍鏈夊彴璐﹁褰曠殑 ID 闆嗗悎
-        List<Long> salesLedgerIds = iPage.getRecords().stream().map(SalesLedger::getId).collect(Collectors.toList());
-
-        //  鏌ヨ鍙戠エ淇℃伅鐨勫凡寮�绁ㄩ噾棰�
-        List<InvoiceLedgerDto> invoiceLedgerDtoList = invoiceLedgerMapper.invoicedTotal(salesLedgerIds);
-        if (CollectionUtils.isEmpty(invoiceLedgerDtoList)) {
-            invoiceLedgerDtoList = Collections.emptyList();
-        }
-
-        //  杞崲鍙戠エ鏁版嵁, key 涓哄彴璐D, value 涓鸿鍙拌处鐨勬�诲紑绁ㄩ噾棰�
-        Map<Long, BigDecimal> invoiceTotals = invoiceLedgerDtoList.stream()
-                .filter(dto -> dto.getSalesLedgerId() != null && dto.getInvoiceTotal() != null)
-                .collect(Collectors.toMap(
-                        dto -> dto.getSalesLedgerId().longValue(),
-                        InvoiceLedgerDto::getInvoiceTotal,
-                        BigDecimal::add // 瀛樺湪閲嶅ID鎵ц绱姞
-                ));
-
-        //  鏌ヨ鍥炴/浠樻璁板綍
-        List<ReceiptPayment> receiptPayments = Collections.emptyList();
-        if (!CollectionUtils.isEmpty(salesLedgerIds)) {
-            receiptPayments = receiptPaymentMapper.selectList(new LambdaQueryWrapper<ReceiptPayment>()
-                    .in(ReceiptPayment::getSalesLedgerId, salesLedgerIds));
-        }
-
-        //  杞崲鍥炴鏁版嵁, key 涓哄彴璐D, value 涓鸿鍙拌处鐨勬�诲洖娆鹃噾棰�
-        Map<Long, BigDecimal> receiptTotals = new HashMap<>();
-        if (!CollectionUtils.isEmpty(receiptPayments)) {
-            for (ReceiptPayment receiptPayment : receiptPayments) {
-                if (receiptPayment.getSalesLedgerId() != null && receiptPayment.getReceiptPaymentAmount() != null) {
-                    //  濡傛灉 key 瀛樺湪鍒欑浉鍔�,涓嶅瓨鍦ㄥ垯鏀惧叆
-                    receiptTotals.merge(receiptPayment.getSalesLedgerId(), receiptPayment.getReceiptPaymentAmount(), BigDecimal::add);
-                }
-            }
-        }
-
-        for (SalesLedger salesLedger : iPage.getRecords()) {
-            Long ledgerId = salesLedger.getId();
-            // 鍚堝悓鎬婚噾棰�
-            BigDecimal contractAmount = salesLedger.getContractAmount() == null ? BigDecimal.ZERO : salesLedger.getContractAmount();
-            // 寮�绁ㄦ�婚鍜屽洖娆炬�婚
-            BigDecimal invoiceTotal = invoiceTotals.getOrDefault(ledgerId, BigDecimal.ZERO);
-            BigDecimal receiptPaymentAmountTotal = receiptTotals.getOrDefault(ledgerId, BigDecimal.ZERO);
-
-            //  鏈紑绁ㄩ噾棰� = 鍚堝悓閲戦 - 宸插紑绁ㄩ噾棰�
-            BigDecimal noInvoiceAmountTotal = contractAmount.subtract(invoiceTotal);
-            if (noInvoiceAmountTotal.compareTo(BigDecimal.ZERO) < 0) {
-                noInvoiceAmountTotal = BigDecimal.ZERO;
-            }
-
-            //  寰呭洖娆鹃噾棰� = 宸插紑绁ㄩ噾棰� - 宸插洖娆鹃噾棰�
-            BigDecimal noReceiptPaymentAmountTotal = invoiceTotal.subtract(receiptPaymentAmountTotal);
-            if (noReceiptPaymentAmountTotal.compareTo(BigDecimal.ZERO) < 0) {
-                noReceiptPaymentAmountTotal = BigDecimal.ZERO;
-            }
-
-            salesLedger.setNoInvoiceAmountTotal(noInvoiceAmountTotal);
-            salesLedger.setInvoiceTotal(invoiceTotal);
-            salesLedger.setReceiptPaymentAmountTotal(receiptPaymentAmountTotal);
-            salesLedger.setNoReceiptAmount(noReceiptPaymentAmountTotal);
-
-            //  濡傛灉宸茬粡鏈夎繃寮�绁ㄦ垨鍥炴鎿嶄綔,鍒欎笉鍏佽缂栬緫
-            boolean hasInvoiceOperation = invoiceTotal.compareTo(BigDecimal.ZERO) > 0;
-            boolean hasReceiptOperation = receiptPaymentAmountTotal.compareTo(BigDecimal.ZERO) > 0;
-            salesLedger.setIsEdit(!(hasInvoiceOperation || hasReceiptOperation));
-        }
-
-        if (ObjectUtils.isNotEmpty(salesLedgerDto.getStatus())) {
-            if (salesLedgerDto.getStatus()) {
-                // 娓呴櫎鎵�鏈夆�滄湭寮�绁ㄩ噾棰濃�濅负 0 鐨勮褰�
-                iPage.getRecords().removeIf(salesLedger ->
-                        Objects.equals(salesLedger.getNoInvoiceAmountTotal(), new BigDecimal("0.00")));
-                iPage.setTotal(iPage.getRecords().size());
-            }
-        }
-
-        return iPage;
+    public IPage<SalesLedger> listPage(Page<?> page, SalesLedgerDto salesLedgerDto) {
+        return salesLedgerService.selectSalesLedgerListPage(page, salesLedgerDto);
     }
 
     @ApiOperation("鏌ヨ閿�鍞彴璐︽秷鑰楃墿鏂欎俊鎭�")
@@ -380,4 +292,61 @@
         SalesOrdersDto salesOrdersDto = salesLedgerService.salesOrders(salesLedgerId);
         return AjaxResult.success(salesOrdersDto);
     }
+
+    @PostMapping("/salesInvoices")
+    @ApiOperation("鎵撳嵃閿�鍞彂璐у崟")
+    public AjaxResult salesInvoices(@RequestBody List<Long> salesLedgerIds) {
+        SalesInvoicesDto dto = salesLedgerService.salesInvoices(salesLedgerIds);
+        return AjaxResult.success(dto);
+    }
+
+    @GetMapping("/salesLabel/{salesLedgerId}")
+    @ApiOperation("鎵撳嵃璁㈠崟鏍囩")
+    public AjaxResult salesLabel(@PathVariable Long salesLedgerId) {
+        List<SalesLabelDto> list = salesLedgerService.salesLabel(salesLedgerId);
+        return AjaxResult.success(list);
+    }
+
+    @PostMapping("/salesStock")
+    @ApiOperation("閿�鍞彴璐︿骇鍝佸叆搴�")
+    public AjaxResult salesStock(@RequestBody SalesProductStockDto dto) {
+        salesLedgerService.salesStock(dto);
+        return AjaxResult.success();
+    }
+
+    @GetMapping("/shippedCustomers")
+    @ApiOperation("宸插彂璐у鎴峰悕鍗�")
+    public AjaxResult shippedCustomers() {
+        List<Customer> list = salesLedgerService.shippedCustomers();
+        return AjaxResult.success(list);
+    }
+
+    @PostMapping("/scanInbound")
+    @ApiOperation("閿�鍞鍗曟壂鐮�-鍚堟牸鍏ュ簱")
+    public AjaxResult scanInbound(@RequestBody SalesScanInboundDto dto) {
+        salesLedgerService.scanInbound(dto);
+        return AjaxResult.success();
+    }
+
+    @PostMapping("/scanInboundUnqualified")
+    @ApiOperation("閿�鍞鍗曟壂鐮�-涓嶅悎鏍煎叆搴�")
+    public AjaxResult scanInboundUnqualified(@RequestBody SalesScanInboundDto dto) {
+        salesLedgerService.scanInboundUnqualified(dto);
+        return AjaxResult.success();
+    }
+
+    @PostMapping("/scanOutbound")
+    @ApiOperation("閿�鍞鍗曟壂鐮�-鍚堟牸鍑哄簱")
+    public AjaxResult scanOutbound(@RequestBody SalesScanInboundDto dto) {
+        salesLedgerService.scanOutbound(dto);
+        return AjaxResult.success();
+    }
+
+    @PostMapping("/scanOutboundUnqualified")
+    @ApiOperation("閿�鍞鍗曟壂鐮�-涓嶅悎鏍煎嚭搴�")
+    public AjaxResult scanOutboundUnqualified(@RequestBody SalesScanInboundDto dto) {
+        salesLedgerService.scanOutboundUnqualified(dto);
+        return AjaxResult.success();
+    }
+
 }

--
Gitblit v1.9.3