From 886d9f15b0b6c187739ef4d8fa14698eda4120f7 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Sun, 22 Aug 2021 16:26:16 +0800
Subject: [PATCH] 1.单位

---
 src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
index 37e92e4..b92312d 100644
--- a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
+++ b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -3,7 +3,7 @@
 <mapper namespace="org.springblade.modules.information.mapper.InformationMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="informationResultMap" type="org.springblade.modules.information.entity.Information">
+    <resultMap id="informationResultMap" type="org.springblade.modules.information.vo.InformationVO">
         <id column="id" property="id"/>
         <result column="creditCode" property="creditcode"/>
         <result column="enterpriseName" property="enterprisename"/>
@@ -29,6 +29,9 @@
         <result column="contactscell" property="contactscell"/>
         <result column="businessLicense" property="businessLicense"/>
         <result column="licence" property="licence"/>
+        <result column="znum" property="znum"/>
+        <result column="cnum" property="cnum"/>
+        <result column="pnum" property="pnum"/>
     </resultMap>
 
 
@@ -47,21 +50,31 @@
 
 
     <select id="selectInformationPage" resultMap="informationResultMap">
-        select * from sys_information where 1=1
+        SELECT
+        i.*,
+        IFNULL(A.znum ,0) as znum,
+        IFNULL(B.cnum ,0) as cnum,
+        IFNULL(C.pnum ,0) as pnum
+        FROM
+        sys_information i
+        LEFT JOIN ( SELECT COUNT( * ) AS znum, dept_id FROM blade_user WHERE role_id = '1412226235153731586' AND is_deleted = 0 GROUP BY dept_id ) A ON A.dept_id = i.departmentid
+        LEFT JOIN ( SELECT COUNT( * ) AS cnum, dept_id FROM blade_user WHERE role_id = '1412226235153731586' AND is_deleted = 0 AND hold=1 GROUP BY dept_id ) B ON B.dept_id = i.departmentid
+        LEFT JOIN ( SELECT COUNT( * ) AS pnum, dept_id FROM blade_user WHERE role_id = '1412226235153731586' AND is_deleted = 0 AND dispatch=0 GROUP BY dept_id ) C ON C.dept_id = i.departmentid
+        where  1=1
         <if test="information.enterprisename!=null and information.enterprisename!=''">
-            and enterpriseName like concat(concat('%', #{information.enterprisename}),'%')
+            and i.enterpriseName like concat(concat('%', #{information.enterprisename}),'%')
         </if>
         <if test="information.representative!=null and information.representative!=''">
-            and representative like concat(concat('%', #{information.representative}),'%')
+            and i.representative like concat(concat('%', #{information.representative}),'%')
         </if>
         <if test="information.stats!=null and information.stats!=''">
-            and stats=#{information.stats}
+            and i.stats=#{information.stats}
         </if>
         <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1123598813738675201'">
-            and jurisdiction=#{information.jurisdiction}
+            and i.jurisdiction=#{information.jurisdiction}
         </if>
         <if test="information.departmentid!=null and information.departmentid!=''">
-            and departmentid=#{information.departmentid}
+            and i.departmentid=#{information.departmentid}
         </if>
     </select>
 

--
Gitblit v1.9.3