From f14c50cb0036d3ddd655ce4e34732ba396a836c4 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 30 五月 2023 12:42:03 +0800
Subject: [PATCH] optimize 统计

---
 java110-db/src/main/resources/mapper/store/AllocationUserStorehouseServiceDaoImplMapper.xml |   51 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/store/AllocationUserStorehouseServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/store/AllocationUserStorehouseServiceDaoImplMapper.xml
index 8d3c705..aa72afa 100644
--- a/java110-db/src/main/resources/mapper/store/AllocationUserStorehouseServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/store/AllocationUserStorehouseServiceDaoImplMapper.xml
@@ -118,14 +118,22 @@
         acceptUserName,t.status_cd,t.status_cd statusCd,t.remark,t.store_id,t.store_id storeId,t.res_id,t.res_id
         resId,t.res_name,t.res_name resName,t.start_user_id,t.start_user_id startUserId,t.start_user_name,
         t.start_user_name startUserName,t.aus_id,t.aus_id ausId,t.b_id,t.b_id
-        bId,t.stock,t.give_quantity,t.give_quantity giveQuantity
+        bId,t.stock,t.give_quantity,t.give_quantity giveQuantity,t.create_time createTime,rst.name rstName,rss.spec_name
+        specName,td1.name unitCodeName,td2.name miniUnitCodeName,rst1.name parentRstName,rs.is_fixed isFixed,rs.res_code resCode,td3.name isFixedName
         from allocation_user_storehouse t
+        left join resource_store rs on t.res_id = rs.res_id and rs.status_cd = '0'
+        left join resource_store_type rst on rs.rst_id = rst.rst_id and rst.status_cd = '0'
+        left join resource_store_type rst1 on rs.parent_rst_id = rst1.rst_id and rst1.status_cd = '0'
+        left join resource_store_specification rss on rs.rss_id=rss.rss_id and rss.status_cd = '0'
+        left join t_dict td1 on rs.unit_code = td1.status_cd and td1.table_name = 'resource_store' and td1.table_columns = 'unit_code'
+        left join t_dict td2 on rs.mini_unit_code = td2.status_cd and td2.table_name = 'resource_store' and td2.table_columns = 'unit_code'
+        left join t_dict td3 on rs.is_fixed = td3.status_cd and td3.table_name = 'resource_store' and td3.table_columns = 'is_fixed'
         where 1 = 1
         <if test="acceptUserId !=null and acceptUserId != ''">
             and t.accept_user_id= #{acceptUserId}
         </if>
         <if test="acceptUserName !=null and acceptUserName != ''">
-            and t.accept_user_name= #{acceptUserName}
+            and t.accept_user_name like '%${acceptUserName}%'
         </if>
         <if test="statusCd !=null and statusCd != ''">
             and t.status_cd= #{statusCd}
@@ -140,13 +148,13 @@
             and t.res_id= #{resId}
         </if>
         <if test="resName !=null and resName != ''">
-            and t.res_name= #{resName}
+            and t.res_name like '%${resName}%'
         </if>
         <if test="startUserId !=null and startUserId != ''">
             and t.start_user_id= #{startUserId}
         </if>
         <if test="startUserName !=null and startUserName != ''">
-            and t.start_user_name= #{startUserName}
+            and t.start_user_name like '%${startUserName}%'
         </if>
         <if test="ausId !=null and ausId != ''">
             and t.aus_id= #{ausId}
@@ -159,6 +167,18 @@
         </if>
         <if test="giveQuantity !=null and giveQuantity != ''">
             and t.give_quantity= #{giveQuantity}
+        </if>
+        <if test="rstId !=null and rstId != ''">
+            and rs.rst_id= #{rstId}
+        </if>
+        <if test="parentRstId !=null and parentRstId != ''">
+            and rs.parent_rst_id= #{parentRstId}
+        </if>
+        <if test="rssId !=null and rssId != ''">
+            and rs.rss_id= #{rssId}
+        </if>
+        <if test="isFixed !=null and isFixed != ''">
+            and rs.is_fixed= #{isFixed}
         </if>
         order by t.create_time desc
         <if test="page != -1 and page != null ">
@@ -216,12 +236,17 @@
     <select id="queryAllocationUserStorehousesCount" parameterType="Map" resultType="Map">
         select count(1) count
         from allocation_user_storehouse t
+        left join resource_store rs on t.res_id = rs.res_id and rs.status_cd = '0'
+        left join resource_store_type rst on rs.rst_id = rst.rst_id and rst.status_cd = '0'
+        left join resource_store_specification rss on rs.rss_id=rss.rss_id and rss.status_cd = '0'
+        left join t_dict td1 on rs.unit_code = td1.status_cd and td1.table_name = 'resource_store' and td1.table_columns = 'unit_code'
+        left join t_dict td2 on rs.mini_unit_code = td2.status_cd and td2.table_name = 'resource_store' and td2.table_columns = 'unit_code'
         where 1 =1
         <if test="acceptUserId !=null and acceptUserId != ''">
             and t.accept_user_id= #{acceptUserId}
         </if>
         <if test="acceptUserName !=null and acceptUserName != ''">
-            and t.accept_user_name= #{acceptUserName}
+            and t.accept_user_name like '%${acceptUserName}%'
         </if>
         <if test="statusCd !=null and statusCd != ''">
             and t.status_cd= #{statusCd}
@@ -236,13 +261,13 @@
             and t.res_id= #{resId}
         </if>
         <if test="resName !=null and resName != ''">
-            and t.res_name= #{resName}
+            and t.res_name like '%${resName}%'
         </if>
         <if test="startUserId !=null and startUserId != ''">
             and t.start_user_id= #{startUserId}
         </if>
         <if test="startUserName !=null and startUserName != ''">
-            and t.start_user_name= #{startUserName}
+            and t.start_user_name like '%${startUserName}%'
         </if>
         <if test="ausId !=null and ausId != ''">
             and t.aus_id= #{ausId}
@@ -256,5 +281,17 @@
         <if test="giveQuantity !=null and giveQuantity != ''">
             and t.give_quantity= #{giveQuantity}
         </if>
+        <if test="rstId !=null and rstId != ''">
+            and rs.rst_id= #{rstId}
+        </if>
+        <if test="isFixed !=null and isFixed != ''">
+            and rs.is_fixed= #{isFixed}
+        </if>
+        <if test="parentRstId !=null and parentRstId != ''">
+            and rs.parent_rst_id= #{parentRstId}
+        </if>
+        <if test="rssId !=null and rssId != ''">
+            and rs.rss_id= #{rssId}
+        </if>
     </select>
 </mapper>

--
Gitblit v1.8.0