From ddaad70562d53c68ad80f221755d0ab985da3dee Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期一, 22 十二月 2025 20:20:11 +0800
Subject: [PATCH] yys  修改项目利率

---
 src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java    |    4 +-
 src/main/java/com/ruoyi/procurementrecord/pojo/CustomStorage.java                        |    3 +
 src/main/resources/mapper/procurementrecord/CustomStorageMapper.xml                      |   25 ++++++++++++
 src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml                  |   16 +++++++-
 src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDto.java                    |    5 ++
 src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java |   30 +++++++-------
 src/main/java/com/ruoyi/procurementrecord/mapper/CustomStorageMapper.java                |    2 +
 src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml                             |    6 +-
 8 files changed, 69 insertions(+), 22 deletions(-)

diff --git a/src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDto.java b/src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDto.java
index 2ac434b..27ac770 100644
--- a/src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDto.java
+++ b/src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDto.java
@@ -23,6 +23,11 @@
     private Long createUser;
 
     /**
+     * true:鍘绘帀鍓╀綑搴撳瓨涓�0
+     */
+    private Boolean flag;
+
+    /**
      * 鍏ュ簱绫诲瀷 1-閲囪喘 2-鐢熶骇
      */
     private Integer type;
diff --git a/src/main/java/com/ruoyi/procurementrecord/mapper/CustomStorageMapper.java b/src/main/java/com/ruoyi/procurementrecord/mapper/CustomStorageMapper.java
index 1b4b703..e72555d 100644
--- a/src/main/java/com/ruoyi/procurementrecord/mapper/CustomStorageMapper.java
+++ b/src/main/java/com/ruoyi/procurementrecord/mapper/CustomStorageMapper.java
@@ -13,4 +13,6 @@
  */
 public interface CustomStorageMapper extends BaseMapper<CustomStorage> {
     IPage<CustomStorage> listPageCopyByCustom(Page page,@Param("req") CustomStorage customStorageLambdaQueryWrapper);
+
+    IPage<CustomStorage> listPageByCustom(Page page,@Param("req") CustomStorage customStorage);
 }
diff --git a/src/main/java/com/ruoyi/procurementrecord/pojo/CustomStorage.java b/src/main/java/com/ruoyi/procurementrecord/pojo/CustomStorage.java
index 5107c06..5599500 100644
--- a/src/main/java/com/ruoyi/procurementrecord/pojo/CustomStorage.java
+++ b/src/main/java/com/ruoyi/procurementrecord/pojo/CustomStorage.java
@@ -18,6 +18,9 @@
 @Data
 public class CustomStorage {
 
+    @TableField(exist = false)
+    private Boolean flag;
+
 
     private static final long serialVersionUID = 1L;
 
diff --git a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
index fdd9c7c..d1cb3b3 100644
--- a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -476,21 +476,21 @@
 
     @Override
     public IPage<CustomStorage> listPageByCustom(Page page, CustomStorage customStorage) {
-        LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        if(customStorage != null){
-            if(!StringUtils.isEmpty(customStorage.getSupplierName())){
-                customStorageLambdaQueryWrapper.like(CustomStorage::getSupplierName, customStorage.getSupplierName());
-            }
-            // 绛涢�夊叆搴撴椂闂�
-            if(customStorage.getTimeStr() != null){
-                customStorageLambdaQueryWrapper.eq(CustomStorage::getInboundDate, customStorage.getTimeStr());
-            }
-            if(!StringUtils.isEmpty(customStorage.getProductCategory())){
-                customStorageLambdaQueryWrapper.like(CustomStorage::getProductCategory, customStorage.getProductCategory());
-            }
-        }
-        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getInboundDate);
-        IPage<CustomStorage> procurementPageDtoIPage = customStorageMapper.selectPage(page, customStorageLambdaQueryWrapper);
+//        LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
+//        if(customStorage != null){
+//            if(!StringUtils.isEmpty(customStorage.getSupplierName())){
+//                customStorageLambdaQueryWrapper.like(CustomStorage::getSupplierName, customStorage.getSupplierName());
+//            }
+//            // 绛涢�夊叆搴撴椂闂�
+//            if(customStorage.getTimeStr() != null){
+//                customStorageLambdaQueryWrapper.eq(CustomStorage::getInboundDate, customStorage.getTimeStr());
+//            }
+//            if(!StringUtils.isEmpty(customStorage.getProductCategory())){
+//                customStorageLambdaQueryWrapper.like(CustomStorage::getProductCategory, customStorage.getProductCategory());
+//            }
+//        }
+//        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getInboundDate);
+        IPage<CustomStorage> procurementPageDtoIPage = customStorageMapper.listPageByCustom(page, customStorage);
         procurementPageDtoIPage.getRecords().forEach(item -> item.setInboundNum0(item.getInboundNum()));
         List<CustomStorage> procurementPageDtos = procurementPageDtoIPage.getRecords();
         // 璁$畻寰呭叆搴撴暟閲�
diff --git a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
index 81fd76f..6ea4520 100644
--- a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
@@ -84,9 +84,9 @@
             }
 
             // 鐘舵�� = 鏁伴噺鍜屽畬宸ユ暟閲忔瘮杈�
-            if(i.getSchedulingNum().compareTo(new BigDecimal(0)) == 0){
+            if(i.getSuccessNum().compareTo(new BigDecimal(0)) == 0){
                 i.setStatus("鏈紑濮�");
-            } else if(i.getQuantity().compareTo(i.getSchedulingNum()) <= 0){
+            } else if(i.getQuantity().compareTo(i.getSuccessNum()) <= 0){
                 i.setStatus("宸插畬鎴�");
             }else{
                 i.setStatus("鐢熶骇涓�");
diff --git a/src/main/resources/mapper/procurementrecord/CustomStorageMapper.xml b/src/main/resources/mapper/procurementrecord/CustomStorageMapper.xml
index ba0e289..3236b93 100644
--- a/src/main/resources/mapper/procurementrecord/CustomStorageMapper.xml
+++ b/src/main/resources/mapper/procurementrecord/CustomStorageMapper.xml
@@ -25,4 +25,29 @@
         HAVING availableStock > 0
         order by t1.inbound_date desc
     </select>
+    <select id="listPageByCustom" resultType="com.ruoyi.procurementrecord.pojo.CustomStorage">
+        select t1.*,
+        sum(t1.inbound_num) as inboundNum,
+        sum(t1.inbound_num) as inboundNum0,
+        sum(t1.tax_inclusive_total_price) as taxInclusiveTotalPrice,
+        SUM(t1.inbound_num) - COALESCE(SUM(t2.inbound_num), 0) AS availableStock
+        from custom_storage t1
+        left join procurement_record_out t2 on t1.id = t2.procurement_record_storage_id and t2.type = 3
+        <where>
+            <if test="req.productCategory != null and req.productCategory != ''">
+                and t1.product_category like  concat('%',#{req.productCategory},'%')
+            </if>
+            <if test="req.supplierName !=null and req.supplierName != ''">
+                and t1.supplier_name like concat('%',#{req.supplierName},'%')
+            </if>
+            <if test="req.timeStr != null and req.timeStr != ''">
+                and t1.inbound_date like concat('%',#{req.timeStr},'%')
+            </if>
+        </where>
+        group by t1.id
+        <if test="req.flag != null and req.flag">
+            having availableStock > 0
+        </if>
+        order by t1.inbound_date desc
+    </select>
 </mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml b/src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml
index 0d28ecd..177e1c3 100644
--- a/src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml
+++ b/src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml
@@ -50,10 +50,12 @@
         t1.create_time,
         t1.update_time,
         t1.create_by,
-        t2.warn_num
+        t2.warn_num,
+        SUM(t1.inbound_num) - COALESCE(SUM(t4.inbound_num), 0) AS availableStock
         from  procurement_record_storage t1
                   left join sales_ledger_product t2 on t2.id = t1.sales_ledger_product_id and t2.type = 2
                   left join purchase_ledger t3 on t3.id = t2.sales_ledger_id
+        left join procurement_record_out t4 on t1.id = t4.procurement_record_storage_id and t4.type = 1
         <where>
             t1.type = 1
             <if test="req.supplierName != null and req.supplierName != ''">
@@ -66,6 +68,10 @@
                 and t1.create_time like  concat('%',#{req.timeStr},'%')
             </if>
         </where>
+        group by t1.id
+        <if test="req.flag != null and req.flag">
+            having availableStock > 0
+        </if>
         order by t1.create_time desc
     </select>
     <select id="list" resultType="com.ruoyi.procurementrecord.dto.ProcurementPageDto">
@@ -257,10 +263,12 @@
         t1.create_time,
         t1.update_time,
         t1.create_by,
-        t2.warn_num
+        t2.warn_num,
+        SUM(t1.inbound_num) - COALESCE(SUM(t4.inbound_num), 0) AS availableStock
         from  procurement_record_storage t1
         left join sales_ledger_product t2 on t2.id = t1.sales_ledger_product_id and t2.type = 1
         left join sales_ledger t3 on t3.id = t2.sales_ledger_id
+        left join procurement_record_out t4 on t4.procurement_record_storage_id = t1.id and t1.type = 2
         <where>
             t1.type = 2
             <if test="req.customerName != null and req.customerName != ''">
@@ -273,6 +281,10 @@
                 and t1.create_time like  concat('%',#{req.timeStr},'%')
             </if>
         </where>
+        group by t1.id
+        <if test="req.flag != null and req.flag">
+            having availableStock > 0
+        </if>
         order by t1.create_time desc
     </select>
     <select id="listPageCopyByProduction" resultType="com.ruoyi.procurementrecord.dto.ProcurementPageDtoCopy">
diff --git a/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml b/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml
index af6e508..79310e8 100644
--- a/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml
+++ b/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml
@@ -11,7 +11,7 @@
         FORMAT(A.sales_tax_amount - A.purchase_tax_amount, 2) AS balance_amount
         FROM (
         SELECT
-        sl.customer_contract_no,
+        sl.sales_contract_no as customerContractNo,
         sl.id,
         pl.id AS pl_id,
         sl.customer_name,
@@ -41,9 +41,9 @@
         LEFT JOIN
         sales_ledger_product slp1 ON slp1.sales_ledger_id = pl.id AND slp1.type = 2
         GROUP BY
-        sl.customer_contract_no, sl.customer_name, sl.project_name, sl.id, pl.id
+        pl.id
         HAVING
-        sl.customer_contract_no IS NOT NULL
+        customerContractNo IS NOT NULL
         ) A
         <where>
             <if test="c.customerName != null and c.customerName != ''">

--
Gitblit v1.9.3