Parcourir la source

教培计划查询sql更新

jingyuanchao il y a 2 ans
Parent
commit
970fecdffb

+ 18 - 5
soc-modules/soc-modules-core/src/main/resources/mapper/edu/CoreEduTrainingPlanMapper.xml

@@ -440,14 +440,27 @@
         p.issue,
         p.standard,
         P.belong_org_id,
-        P.belong_org_name from core_edu_training_plan p left join sys_user u on p.update_by=u.id where p.deleted = 0 and p.parent_id is null
+        P.belong_org_name from core_edu_training_plan p left join sys_user u on p.update_by=u.id
+        <if test="request.planRoleId!=null">
+            left join (select id from core_edu_training_plan p1 inner join core_edu_training_plan_to_role r1 on p1.id =
+            r1.plan_id where r1.role_id = #{request.planRoleId} and p1.deleted=0) t on p.id = t.id and p.deleted=0
+        </if>
+        where p.deleted = 0 and p.parent_id is null
         and p.standard=1 and p.issue=1
-        and p.id in ( select sp.parent_id from core_edu_training_plan sp where sp.deleted = 0 and sp.parent_id is not null  <include refid="pageIncludeSP"/>)
+        and p.id in ( select sp.parent_id from core_edu_training_plan sp where sp.deleted = 0 and sp.parent_id is not
+        null<include refid="pageIncludeSP"/>)
         <!-- 不是标准计划但是也没下发: 行社自建的计划 -->
-        or ( p.standard=0 and p.issue=0 and p.deleted=0 and p.parent_id is null  <include refid="pageIncludeP"/>)
+        or ( p.standard=0 and p.issue=0 and p.deleted=0 and p.parent_id is null
+        <if test="request.planRoleId!=null">
+            and p.id in ( select distinct r.plan_id from core_edu_training_plan_to_role r where r.role_id =  #{request.planRoleId})
+        </if>
+        <include refid="pageIncludeP"/>)
         <!-- 是标准计划但是未下发 -->
-        or ( p.standard=1 and p.issue=0 and p.deleted=0 and p.parent_id is null  <include refid="pageIncludeP"/>)
-
+        or ( p.standard=1 and p.issue=0 and p.deleted=0 and p.parent_id is null
+        <if test="request.planRoleId!=null">
+            and p.id in ( select distinct r.plan_id from core_edu_training_plan_to_role r where r.role_id =  #{request.planRoleId})
+        </if>
+        <include refid="pageIncludeP"/>)
     </select>
     <select id="selectPageData1" resultType="com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanPageVo">
         select p.id as id,