From e13cac448fcaa3f470aec6e7e7065760c4e6517e Mon Sep 17 00:00:00 2001
From: cyf009 <591388323@qq.com>
Date: Fri, 28 Feb 2025 09:12:12 +0800
Subject: [PATCH] 111111

---
 .../mapper/xml/EntryBillMapper.xml            | 61 +++++++------------
 1 file changed, 21 insertions(+), 40 deletions(-)

diff --git a/ServiceSite/src/main/java/com/seasky/ledgerincome/infrastructure/mapper/xml/EntryBillMapper.xml b/ServiceSite/src/main/java/com/seasky/ledgerincome/infrastructure/mapper/xml/EntryBillMapper.xml
index 78b90ff5..dbc304e2 100644
--- a/ServiceSite/src/main/java/com/seasky/ledgerincome/infrastructure/mapper/xml/EntryBillMapper.xml
+++ b/ServiceSite/src/main/java/com/seasky/ledgerincome/infrastructure/mapper/xml/EntryBillMapper.xml
@@ -375,41 +375,30 @@
         a.income_postscript,
         a.income_speed,
         a.pre_income_type,
-        b.id entry_bill_id,
-        c.id entry_bill_flow_id,
-        d.voucher_state
-        ,c.voucher_id,
+        h.voucher_state
+        ,h.id voucher_id,
         a.id income_id,
-        d.batch_id batchId,
-        d.voucher_code ,
-        d.voucher_date
+        h.batch_id batchId,
+        h.voucher_code ,
+        h.voucher_date
         from t_income a
         left JOIN t_income_type ty ON ty.id = a.income_type_id
-
-
-        left join t_entry_bill b on a.id=b.income_id
-        left join t_entry_bill_flow c on c.entry_id=b.id
-        and c.entry_type='鍒版杞殏瀛�' and c.income_id=b.income_id
-        left join t_voucher d ON d.income_id = c.income_id
-
-        and d.id=c.voucher_id
-<!--        <if test="qry.voucherState !=null and qry.voucherState.contains('寰呭鐞�')">-->
-<!--            and d.voucher_state!='椹冲洖'-->
-<!--        </if>-->
-        AND c.batch_id = (
-        SELECT MAX(tt.batch_id)
-        FROM t_voucher tt left join t_entry_bill_flow ff on tt.id = ff.voucher_id
-        WHERE tt.income_id = a.id and  ff.entry_type = '鍒版杞殏瀛�'
-        AND tt.available = 'Yes'
-        )
-
-        and   d.available='Yes'
         left join t_bank_account_number e on e.bank_number=a.income_account and e.available='Yes'
         left join (select a.income_id from t_entry_bill_flow a join t_voucher
         b on a.income_id=b.income_id
         and  a.voucher_id=b.id
         where a.entry_type in('鍒版杞敹鍏�','鏆傚瓨杞敹鍏�')
         and b.available!='NO') g on a.id=g.income_id
+
+        left join (
+        select tt2.* from (SELECT MAX(tt.batch_id)batch_id,tt.income_id
+        FROM t_voucher tt left join t_entry_bill_flow ff on tt.id = ff.voucher_id
+        WHERE   ff.entry_type = '鍒版杞殏瀛�'
+        AND tt.available = 'Yes'
+        group by income_id
+        )tt1 left join t_voucher tt2 on tt1.batch_id=tt2.batch_id
+        and tt1.income_id=tt2.income_id
+        ) h on h.income_id=a.id
         <where>
             a.available='Yes' and a.is_offline=0
              and g.income_id is null
@@ -417,18 +406,10 @@
 
 
 
-            <if test="qry.voucherStateSelect !=null and qry.voucherStateSelect.equals('宸插叆璐�'.toString()) ">
-                and a.income_speed='鍏ヨ处'  and d.voucher_state='宸插叆璐�'
-            </if>
-            <if test="qry.voucherStateSelect !=null and qry.voucherStateSelect.equals('鐢宠涓�'.toString()) ">
-                and (( a.income_speed = '涓氬姟琛ュ厖' or a.income_speed = '鍙戝竷' or a.need_in_quire=1 )
-                and  d.voucher_state='鐢宠涓�')
+            <if test="qry.voucherStateSelect !=null and qry.voucherStateSelect!='' ">
+                and h.voucher_state=#{qry.voucherStateSelect}
             </if>
 
-            <if test="qry.voucherStateSelect !=null and qry.voucherStateSelect.equals('椹冲洖'.toString()) ">
-                and (( a.income_speed = '涓氬姟琛ュ厖' or a.income_speed = '鍙戝竷' or a.income_speed = '鍏ヨ处' or a.need_in_quire=1 )
-                and  d.voucher_state='椹冲洖')
-            </if>
             <if test="qry.billNo != null and qry.billNo!=''">
                 and bill_no like concat('%',#{qry.billNo},'%')
             </if>
@@ -436,15 +417,15 @@
                 and a.income_account=#{qry.incomeAccount}
             </if>
             <if test="qry.voucherState !=null and qry.voucherState.contains('鍏ㄩ儴') ">
-                and c.entry_type='鍒版杞殏瀛�' and ((a.income_speed='鍏ヨ处'  and d.voucher_state='宸插叆璐�')
+                and ((a.income_speed='鍏ヨ处'  and h.voucher_state='宸插叆璐�')
                 or (( a.income_speed = '涓氬姟琛ュ厖' or a.income_speed = '鍙戝竷' or a.income_speed = '鍏ヨ处' or a.need_in_quire=1 )
-                and (d.voucher_state='鐢宠涓�' or d.voucher_state='椹冲洖'))
+                and (h.voucher_state='鐢宠涓�' or h.voucher_state='椹冲洖' or h.voucher_state is null or h.voucher_state=''  ))
                 )
             </if>
             <if test="qry.voucherState !=null and qry.voucherState.contains('寰呭鐞�')">
 
-                and d.id is null and ( ( a.need_in_quire=1 and (d.voucher_state ='' or d.voucher_state is null ))
-                or a.income_speed='鍙戝竷' or ( a.income_speed = '涓氬姟琛ュ厖' and a.supplement_state='寰呰ˉ鍏�')
+                and ( (( a.income_speed = '涓氬姟琛ュ厖' or a.income_speed = '鍙戝竷' or a.income_speed = '鍏ヨ处' or a.need_in_quire=1 )
+                and (h.voucher_state='' or h.voucher_state='椹冲洖' or h.voucher_state is null ))
                 )
             </if>
             <!-- <if test="qry.voucherState !=null and qry.voucherState.contains('鐢宠涓�') ">
-- 
GitLab