From 23a84db2fb05817e23b60839345f6ed96ed57857 Mon Sep 17 00:00:00 2001
From: liuke <123456>
Date: Tue, 03 Nov 2020 18:22:38 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.2.240:7070/r/kidgrow-microservices-platform

---
 kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/resources/mapper/ProductOrderRecordMapper.xml |  132 +++++++++++++++++++++++++++++++++----------
 1 files changed, 101 insertions(+), 31 deletions(-)

diff --git a/kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/resources/mapper/ProductOrderRecordMapper.xml b/kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/resources/mapper/ProductOrderRecordMapper.xml
index 8099d25..9c562d2 100644
--- a/kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/resources/mapper/ProductOrderRecordMapper.xml
+++ b/kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/resources/mapper/ProductOrderRecordMapper.xml
@@ -84,44 +84,114 @@
         <include refid="where"/>
         order by id desc
     </select>
+    <sql id="where_condition">
+        <if test="p.id != null and p.id !=''">
+            and id = #{p.id}
+        </if>
+        <if test="p.proType != null and p.proType !=''">
+            and DE.pro_type = #{p.proType}
+        </if>
+        <if test="p.enabled != null and p.enabled !=''">
+            and DE.enabled = #{p.enabled}
+        </if>
+        <if test="p.hospitalName != null and p.hospitalName !=''">
+            and PRO.hospital_name like concat ('%',#{p.hospitalName},'%')
+        </if>
+        <if test="p.hospitalId != null and p.hospitalId !=''">
+            and PRO.hospital_id  = #{p.hospitalId}
+        </if>
+        <if test="p.departmentId != null and p.departmentId !=''">
+            and PRO.department_id  = #{p.departmentId}
+        </if>
+        <if test="p.proName != null and p.proName !=''">
+            and DE.pro_name like concat ('%',#{p.proName},'%')
+        </if>
+        <if test="p.createTime != null and p.createTime !='' and p.updateTime != null and p.updateTime !=''">
+            and (DE.create_time between #{p.createTime} and #{p.updateTime})
+        </if>
+        <if test="p.startTime!= null and p.startTime !=''">
+            and DE.create_time &gt;= #{p.startTime}
+        </if>
+        <if test="p.endTime!= null and p.endTime !=''">
+            and DE.create_time &lt;= #{p.endTime}
+        </if>
+    </sql>
     <!--sql查询片段-->
     <sql id="wherelimit">
         <where>
             <!--查询条件自行添加-->
             DE.is_del=0
-            <if test="p.id != null and p.id !=''">
-                and id = #{p.id}
-            </if>
-            <if test="p.proType != null and p.proType !=''">
-                and DE.pro_type = #{p.proType}
-            </if>
-            <if test="p.enabled != null and p.enabled !=''">
-                and DE.enabled = #{p.enabled}
-            </if>
-            <if test="p.hospitalName != null and p.hospitalName !=''">
-                and PRO.hospital_name like concat ('%',#{p.hospitalName},'%')
-            </if>
-            <if test="p.hospitalId != null and p.hospitalId !=''">
-                and PRO.hospital_id  = #{p.hospitalId}
-            </if>
-            <if test="p.departmentId != null and p.departmentId !=''">
-                and PRO.department_id  = #{p.departmentId}
-            </if>
-            <if test="p.proName != null and p.proName !=''">
-                and DE.pro_name like concat ('%',#{p.proName},'%')
-            </if>
-            <if test="p.createTime != null and p.createTime !='' and p.updateTime != null and p.updateTime !=''">
-                and (DE.create_time between #{p.createTime} and #{p.updateTime})
-            </if>
-            <if test="p.startTime!= null and p.startTime !=''">
-                and DE.create_time &gt;= #{p.startTime}
-            </if>
-            <if test="p.endTime!= null and p.endTime !=''">
-                and DE.create_time &lt;= #{p.endTime}
-            </if>
-            <include refid="com.kidgrow.oprationcenter.mapper.SysProductMapper.Role_Organization"></include>
+            <include refid="where_condition"></include>
+            <include refid="Role_Organization"></include>
         </where>
     </sql>
+    <!--定义数据权限的查询-->
+    <sql id="Role_Organization">
+        <if test="p.roleOrg != null and p.roleOrg.size>0">
+            <foreach item="item" collection="p.roleOrg" index="">
+                <foreach item="itemto" collection="item" index="inx">
+                    <choose>
+                        <when test="inx == 1">
+                            <if test="itemto.flag">
+
+                            </if>
+                            <if test="!itemto.flag">
+                                or ( is_del = 0 and enabled=1) <include refid="where_condition"></include>
+                            </if>
+                        </when>
+                        <when test="inx==2">
+                            <if test="itemto.flag">
+                                AND
+                                <foreach item="itemtoto" collection="itemto.object" separator="or" open="(" close=")"
+                                         index="">
+                                    create_user_org_code = #{itemtoto.orgCode}
+                                </foreach>
+                            </if>
+                            <if test="!itemto.flag">
+                                or (
+                                <foreach item="itemtoto" collection="itemto.object" separator="or" open="(" close=")"
+                                         index="">
+                                    create_user_org_code = #{itemtoto.orgCode}
+                                </foreach>
+                                and is_del = 0 and enabled=1  <include refid="where_condition"></include>
+                                )
+                            </if>
+                        </when>
+                        <when test="inx == 3">
+                            <if test="itemto.flag">
+                                AND
+                                create_user_org_code = #{itemto.object}
+                            </if>
+                            <if test="!itemto.flag">
+                                or (create_user_org_code = #{itemto.object} and is_del = 0 and enabled=1) <include refid="where_condition"></include>
+                            </if>
+                        </when>
+                        <when test="inx == 4">
+                            <if test="itemto.flag">
+                                AND
+                                create_user_org_code like '${itemto.object}%'
+                            </if>
+                            <if test="!itemto.flag">
+                                or (create_user_org_code like '${itemto.object}%' and is_del = 0 and enabled=1) <include refid="where_condition"></include>
+                            </if>
+                        </when>
+                        <when test="inx == 5">
+                            <if test="itemto.flag">
+                                AND
+                                create_user_id = #{itemto.object}
+                            </if>
+                            <if test="!itemto.flag">
+                                or (create_user_id = #{itemto.object} and is_del = 0 and enabled=1) <include refid="where_condition"></include>
+                            </if>
+                        </when>
+                        <otherwise>
+                            AND id is null
+                        </otherwise>
+                    </choose>
+                </foreach>
+            </foreach>
+        </if>
+    </sql>
     <!--查询产品的消费记录-->
     <select id="findAllList" resultType="com.kidgrow.oprationcenter.vo.ProductOrderJoinDetail">
         SELECT

--
Gitblit v1.8.0