动火作业延时监火列表sql优化

liujun0703-新项目开发
limingyu 2024-05-23 16:11:22 +08:00
parent 2a08fe0b7b
commit 633119aaf9
1 changed files with 21 additions and 16 deletions

View File

@ -231,7 +231,16 @@
and f.HOTWORKAPPLICATION_ID in (select hu.FOREIGN_KEY from bus_hotworkapplicationuser hu LEFT JOIN vi_user_all bhuuser ON bhuuser.USER_ID = hu.USER_ID where bhuuser.DEPARTMENT_ID in (${pd.supDeparIds}) or u.DEPARTMENT_ID in (${pd.supDeparIds}) )
</when>
<when test='pd.roleLevel == "2"'>
and f.HOTWORKAPPLICATION_ID in (select hu.FOREIGN_KEY from bus_hotworkapplicationuser hu where hu.USER_ID = #{pd.loginUserId}
<if test="pd.STATE != null and pd.STATE != ''">
<choose>
<when test='pd.STATE == "10"'>
and f.HOTWORKAPPLICATION_ID in (select hu.FOREIGN_KEY from bus_hotworkapplicationuser hu where hu.USER_ID = uu.DEPARTMENT_ID
</when>
<otherwise>
and f.HOTWORKAPPLICATION_ID in (select hu.FOREIGN_KEY from bus_hotworkapplicationuser hu where hu.USER_ID = #{pd.loginUserId}
</otherwise>
</choose>
</if>
<if test="pd.STATE != null and pd.STATE != ''">
<choose>
@ -253,7 +262,16 @@
</choose>
</if>
<if test="pd.myApprove != null and pd.myApprove != ''"><!-- 应该由我审批的数据 -->
and f.HOTWORKAPPLICATION_ID in (select hu.FOREIGN_KEY from bus_hotworkapplicationuser hu where hu.USER_ID = #{pd.myApprove}
<if test="pd.STATE != null and pd.STATE != ''">
<choose>
<when test='pd.STATE == "10"'>
and f.HOTWORKAPPLICATION_ID in (select hu.FOREIGN_KEY from bus_hotworkapplicationuser hu where hu.USER_ID = uu.DEPARTMENT_ID
</when>
<otherwise>
and f.HOTWORKAPPLICATION_ID in (select hu.FOREIGN_KEY from bus_hotworkapplicationuser hu where hu.USER_ID = #{pd.loginUserId}
</otherwise>
</choose>
</if>
<if test="pd.STATE != null and pd.STATE != ''">
<choose>
@ -279,18 +297,6 @@
and (u.NAME LIKE CONCAT(CONCAT('%', #{pd.applicantName}),'%'))
</if>
<if test="pd.keyState != null and pd.keyState != ''">
<!-- <if test='pd.keyState == "1"'>-->
<!-- and f.STATE = '11'-->
<!-- </if>-->
<!-- <if test='pd.keyState == "2"'>-->
<!-- and f.STATE = '12'-->
<!-- </if>-->
<!-- <if test='pd.keyState == "3"'>-->
<!-- and f.STATE = '2'-->
<!-- </if>-->
<!-- <if test='pd.keyState == "4"'>-->
<!-- and f.STATE = '-2'-->
<!-- </if>-->
and f.STATE = #{pd.keyState}
</if>
<if test="pd.keyApplyUserName != null and pd.keyApplyUserName != ''"><!-- 申请人 -->
@ -326,7 +332,7 @@
</when>
<when test='pd.STATE == "10"'>
and (f.STATE != '11')
) or (uu.USER_ID is not null and f.ISDELETE = '0')
) and (uu.USER_ID is not null and f.ISDELETE = '0')
</when>
<otherwise>
and (f.STATE = #{pd.STATE})
@ -335,7 +341,6 @@
</if>
group by f.HOTWORKAPPLICATION_ID
ORDER BY f.CREATTIME desc
<!-- ORDER BY f.OPERATTIME desc -->
</select>
<!-- 列表 -->