|
|
|
@ -122,84 +122,101 @@
|
|
|
|
|
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
|
<select id="datalistPage" parameterType="page" resultType="pd">
|
|
|
|
|
select
|
|
|
|
|
iou.NAME INSPECTION_ORIGINATOR_NAME,
|
|
|
|
|
iod.NAME INSPECTION_DEPARTMENT_NAME,
|
|
|
|
|
isd.NAME INSPECTED_DEPARTMENT_NAME,
|
|
|
|
|
isu.NAME INSPECTED_SITEUSER_NAME,
|
|
|
|
|
IFNULL(GROUP_CONCAT(REPLACE(siu.NAME,'/',',')),'') AS INSPECTION_USER_NAME,
|
|
|
|
|
CASE WHEN IFNULL(se.INSPECTION_TYPE_OTHER, '') = '' THEN d.NAME ELSE se.INSPECTION_TYPE_OTHER END INSPECTION_TYPE_NAME,
|
|
|
|
|
se.INSPECTION_TIME_START,
|
|
|
|
|
se.INSPECTION_TIME_END,
|
|
|
|
|
se.INSPECTION_STATUS,
|
|
|
|
|
se.INSPECTION_SUBJECT,
|
|
|
|
|
se.INSPECTED_DEPARTMENT_ID,
|
|
|
|
|
<include refid="Field"></include>
|
|
|
|
|
from
|
|
|
|
|
<include refid="tableName"></include> f
|
|
|
|
|
INNER JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL se ON se.INSPECTION_ID = f.INSPECTION_ID
|
|
|
|
|
LEFT JOIN VI_USER_ALL iou ON iou.USER_ID = se.INSPECTION_ORIGINATOR_ID
|
|
|
|
|
LEFT JOIN VI_DEPARTMENT_ALL iod ON iod.DEPARTMENT_ID = iou.DEPARTMENT_ID
|
|
|
|
|
LEFT JOIN OA_DEPARTMENT isd ON isd.DEPARTMENT_ID = se.INSPECTED_DEPARTMENT_ID
|
|
|
|
|
LEFT JOIN SYS_USER isu ON isu.USER_ID = se.INSPECTED_SITEUSER_ID
|
|
|
|
|
LEFT JOIN bus_inspection_safetyenvironmental_inspector si ON si.INSPECTION_ID = se.INSPECTION_ID
|
|
|
|
|
AND si.ISDELETE = '0'
|
|
|
|
|
LEFT JOIN vi_user_all siu ON siu.USER_ID = si.INSPECTION_USER_ID
|
|
|
|
|
LEFT JOIN sys_dictionaries d ON d.BIANMA = se.INSPECTION_TYPE
|
|
|
|
|
where f.ISDELETE = '0' and se.ISDELETE = '0'
|
|
|
|
|
<if test="pd.supDeparIds != null and pd.supDeparIds != ''"><!-- 权限显示 -->
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="pd.roleLevel == '0'">
|
|
|
|
|
</when>
|
|
|
|
|
<when test="pd.roleLevel == '1'">
|
|
|
|
|
and siu.DEPARTMENT_ID in (${pd.supDeparIds})
|
|
|
|
|
</when>
|
|
|
|
|
<when test="pd.roleLevel == '3'">
|
|
|
|
|
-- siu.USER_ID in ( #{pd.loginUserId} )
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_USER_ID != null and pd.INSPECTION_USER_ID != ''"><!-- 检查人 -->
|
|
|
|
|
and f.INSPECTION_USER_ID = #{pd.INSPECTION_USER_ID}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_SUBJECT != null and pd.INSPECTION_SUBJECT != ''"><!-- 检查题目 -->
|
|
|
|
|
and se.INSPECTION_SUBJECT = #{pd.INSPECTION_SUBJECT,jdbcType=VARCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTED_DEPARTMENT_NAME != null and pd.INSPECTED_DEPARTMENT_NAME != ''"><!-- 被检查单位 -->
|
|
|
|
|
and isd.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTED_DEPARTMENT_NAME}),'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_DEPARTMENT_NAME != null and pd.INSPECTION_DEPARTMENT_NAME != ''"><!-- 检查部门 -->
|
|
|
|
|
and iod.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTION_DEPARTMENT_NAME}),'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_ORIGINATOR_NAME != null and pd.INSPECTION_ORIGINATOR_NAME != ''"><!-- 检查发起人 -->
|
|
|
|
|
and iou.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTION_ORIGINATOR_NAME}),'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_TYPE != null and pd.INSPECTION_TYPE != ''"><!-- 检查类型 -->
|
|
|
|
|
and se.INSPECTION_TYPE = #{pd.INSPECTION_TYPE}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_TIME_START != null and pd.INSPECTION_TIME_START != ''"><!-- 检查时间 -->
|
|
|
|
|
and se.INSPECTION_TIME_START >= CONCAT(#{pd.INSPECTION_TIME_START}, ' 00:00')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_TIME_END != null and pd.INSPECTION_TIME_END != ''"><!-- 检查时间 -->
|
|
|
|
|
and se.INSPECTION_TIME_END <= CONCAT(#{pd.INSPECTION_TIME_END}, ' 23:59')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_STATUS != null and pd.INSPECTION_STATUS != ''"><!-- 检查状态 -->
|
|
|
|
|
and se.INSPECTION_STATUS = #{pd.INSPECTION_STATUS}
|
|
|
|
|
</if>
|
|
|
|
|
select iou.NAME INSPECTION_ORIGINATOR_NAME,
|
|
|
|
|
iod.NAME INSPECTION_DEPARTMENT_NAME,
|
|
|
|
|
isd.NAME INSPECTED_DEPARTMENT_NAME,
|
|
|
|
|
isu.NAME INSPECTED_SITEUSER_NAME,
|
|
|
|
|
IFNULL(GROUP_CONCAT(REPLACE(siu.NAME, '/', ',')), '') AS INSPECTION_USER_NAME,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN IFNULL(se.INSPECTION_TYPE_OTHER, '') = '' THEN d.NAME
|
|
|
|
|
ELSE se.INSPECTION_TYPE_OTHER END INSPECTION_TYPE_NAME,
|
|
|
|
|
se.INSPECTION_TIME_START,
|
|
|
|
|
se.INSPECTION_TIME_END,
|
|
|
|
|
se.INSPECTION_STATUS,
|
|
|
|
|
se.INSPECTION_SUBJECT,
|
|
|
|
|
se.INSPECTED_DEPARTMENT_ID,
|
|
|
|
|
<include refid="Field">
|
|
|
|
|
</include>
|
|
|
|
|
from
|
|
|
|
|
<include refid="tableName">
|
|
|
|
|
</include>
|
|
|
|
|
f
|
|
|
|
|
INNER JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL se ON se.INSPECTION_ID = f.INSPECTION_ID
|
|
|
|
|
LEFT JOIN VI_USER_ALL iou ON iou.USER_ID = se.INSPECTION_ORIGINATOR_ID
|
|
|
|
|
LEFT JOIN VI_DEPARTMENT_ALL iod ON iod.DEPARTMENT_ID = iou.DEPARTMENT_ID
|
|
|
|
|
LEFT JOIN OA_DEPARTMENT isd ON isd.DEPARTMENT_ID = se.INSPECTED_DEPARTMENT_ID
|
|
|
|
|
LEFT JOIN SYS_USER isu ON isu.USER_ID = se.INSPECTED_SITEUSER_ID
|
|
|
|
|
LEFT JOIN bus_inspection_safetyenvironmental_inspector si ON si.INSPECTION_ID = se.INSPECTION_ID
|
|
|
|
|
AND si.ISDELETE = '0'
|
|
|
|
|
LEFT JOIN vi_user_all siu ON siu.USER_ID = si.INSPECTION_USER_ID
|
|
|
|
|
LEFT JOIN sys_dictionaries d ON d.BIANMA = se.INSPECTION_TYPE
|
|
|
|
|
where f.ISDELETE = '0'
|
|
|
|
|
and se.ISDELETE = '0'
|
|
|
|
|
<if test="pd.supDeparIds != null and pd.supDeparIds != ''">
|
|
|
|
|
<!-- 权限显示 -->
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="pd.roleLevel == '0'">
|
|
|
|
|
</when>
|
|
|
|
|
<when test="pd.roleLevel == '1'">
|
|
|
|
|
and siu.DEPARTMENT_ID in (${pd.supDeparIds})
|
|
|
|
|
</when>
|
|
|
|
|
<when test="pd.roleLevel == '3'">
|
|
|
|
|
-- siu.USER_ID in ( #{pd.loginUserId} )
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_USER_ID != null and pd.INSPECTION_USER_ID != ''">
|
|
|
|
|
<!-- 检查人 -->
|
|
|
|
|
and f.INSPECTION_USER_ID = #{pd.INSPECTION_USER_ID}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_SUBJECT != null and pd.INSPECTION_SUBJECT != ''">
|
|
|
|
|
<!-- 检查题目 -->
|
|
|
|
|
and se.INSPECTION_SUBJECT = #{pd.INSPECTION_SUBJECT,jdbcType=VARCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTED_DEPARTMENT_NAME != null and pd.INSPECTED_DEPARTMENT_NAME != ''">
|
|
|
|
|
<!-- 被检查单位 -->
|
|
|
|
|
and isd.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTED_DEPARTMENT_NAME}), '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_DEPARTMENT_NAME != null and pd.INSPECTION_DEPARTMENT_NAME != ''">
|
|
|
|
|
<!-- 检查部门 -->
|
|
|
|
|
and iod.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTION_DEPARTMENT_NAME}), '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_ORIGINATOR_NAME != null and pd.INSPECTION_ORIGINATOR_NAME != ''">
|
|
|
|
|
<!-- 检查发起人 -->
|
|
|
|
|
and iou.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTION_ORIGINATOR_NAME}), '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_TYPE != null and pd.INSPECTION_TYPE != ''">
|
|
|
|
|
<!-- 检查类型 -->
|
|
|
|
|
and se.INSPECTION_TYPE = #{pd.INSPECTION_TYPE}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_TIME_START != null and pd.INSPECTION_TIME_START != ''">
|
|
|
|
|
<!-- 检查时间 -->
|
|
|
|
|
and se.INSPECTION_TIME_START >= CONCAT(#{pd.INSPECTION_TIME_START}, ' 00:00')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_TIME_END != null and pd.INSPECTION_TIME_END != ''">
|
|
|
|
|
<!-- 检查时间 -->
|
|
|
|
|
and se.INSPECTION_TIME_END <= CONCAT(#{pd.INSPECTION_TIME_END}, ' 23:59')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pd.INSPECTION_STATUS != null and pd.INSPECTION_STATUS != ''">
|
|
|
|
|
<!-- 检查状态 -->
|
|
|
|
|
and se.INSPECTION_STATUS = #{pd.INSPECTION_STATUS}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 被检查单位 -->
|
|
|
|
|
and (
|
|
|
|
|
isd.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
|
|
|
|
|
OR iod.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY f.INSPECTION_ID
|
|
|
|
|
ORDER BY
|
|
|
|
|
FIELD(if(f.INSPECTION_USER_SIGN_TIME is not null,'2','1'), '1','2'),
|
|
|
|
|
FIELD(if(se.INSPECTED_SITEUSER_ID = #{pd.loginUserId},#{pd.loginUserId},'1'), #{pd.loginUserId}, '1'),
|
|
|
|
|
FIELD (se.INSPECTION_STATUS , '0','1','2','3','4','5','6','7','8','-1','-2') ,
|
|
|
|
|
se.INSPECTION_TIME_START DESC , se.INSPECTION_TIME_END DESC
|
|
|
|
|
</select>
|
|
|
|
|
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''">
|
|
|
|
|
<!-- 被检查单位 -->
|
|
|
|
|
and (
|
|
|
|
|
isd.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}), '%')
|
|
|
|
|
OR iod.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}), '%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY f.INSPECTION_ID
|
|
|
|
|
ORDER BY FIELD(if(f.INSPECTION_USER_SIGN_TIME is not null, '2', '1'), '1', '2'),
|
|
|
|
|
<if test="pd.loginUserId != null and pd.loginUserId != ''">
|
|
|
|
|
FIELD(if(se.INSPECTED_SITEUSER_ID = #{pd.loginUserId}, #{pd.loginUserId}, '1'), #{pd.loginUserId}, '1'),
|
|
|
|
|
</if>
|
|
|
|
|
FIELD(se.INSPECTION_STATUS, '0', '1', '2', '3', '4', '5', '6', '7', '8', '-1', '-2'),
|
|
|
|
|
se.INSPECTION_TIME_START DESC, se.INSPECTION_TIME_END DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 列表(全部) -->
|
|
|
|
|
<select id="listAll" parameterType="pd" resultType="pd">
|
|
|
|
|