FAISP/src/main/resources/mybatisMapper/MonitoringMapper.xml

213 lines
7.6 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dbnt.faisp.main.fpiMgt.monitoring.mapper.MonitoringMapper">
<sql id="selectDesignationListWhere">
<where>
md_state &lt;> 'DST008'
<if test='wrtUserSeq != null and wrtUserSeq != ""'>
and md.wrt_user_seq = #{wrtUserSeq}
</if>
<if test='wrtUserNm != null and wrtUserNm != ""'>
and md.wrt_user_nm like '%'||#{wrtUserNm}||'%'
</if>
<if test='wrtOrgan != null and wrtOrgan != ""'>
and md.wrt_organ = #{wrtOrgan}
</if>
<if test='mdTitle != null and mdTitle != ""'>
and md.md_title like '%'||#{mdTitle}||'%'
</if>
<if test='mdState != null and mdState != ""'>
and md.md_state = #{mdState}
</if>
<if test='dateSelector == "mdDt"'>
<if test='startDate != null and startDate != ""'>
and md.md_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and md.md_dt &lt;= #{endDate}::date
</if>
</if>
<if test='dateSelector == "wrtDt"'>
<if test='startDate != null and startDate != ""'>
and md.wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and md.wrt_dt &lt;= #{endDate}::date+1
</if>
</if>
<if test="downOrganCdList != null">
and md.wrt_organ in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</if>
<if test='userType != null and userType != ""'>
<if test='userType == "normalStayList"'>
and md_state in ('DST002', 'DST004')
</if>
<if test='userType == "normalCommitList"'>
and md_state in ('DST003', 'DST005', 'DST006')
</if>
<if test='userType == "sectionCommitList"'>
and md_state in ('DST003', 'DST004', 'DST005', 'DST006')
</if>
<if test='userType == "headCommitList"'>
and md_state in ('DST003', 'DST005', 'DST006')
</if>
<if test='userType == "managerStayList"'>
and md_state in ('DST002', 'DST004')
</if>
<if test='userType == "managerCommitList"'>
and md_state in ('DST003', 'DST005', 'DST006')
</if>
</if>
</where>
</sql>
<select id="selectDesignationList" resultType="MonitoringDesignation" parameterType="MonitoringDesignation">
select md.md_key,
md_dt,
md_title,
md_name,
md_nationality,
md_rank,
md_birth,
md_address,
(select item_value from code_mgt where item_cd = md_state) as md_state,
wrt_user_seq,
(select item_value from code_mgt where item_cd = wrt_organ) as wrt_organ,
(select item_value from code_mgt where item_cd = wrt_part) as wrt_part,
(select item_value from code_mgt where item_cd = wrt_user_grd) as wrt_user_grd,
wrt_user_nm,
wrt_dt,
b.fileCnt
from monitoring_designation md
left outer join (select md_key,
count(file_seq) as fileCnt
from monitoring_designation_file mdf
group by md_key) b
on md.md_key = b.md_key
<include refid="selectDesignationListWhere"></include>
order by md.md_key desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectDesignationListCnt" resultType="Integer" parameterType="MonitoringDesignation">
select count(*)
from monitoring_designation md
<include refid="selectDesignationListWhere"></include>
</select>
<sql id="selectResultListWhere">
and mr_state &lt;> 'DST008'
<if test='wrtUserSeq != null and wrtUserSeq != ""'>
and mr.wrt_user_seq = #{wrtUserSeq}
</if>
<if test='wrtUserNm != null and wrtUserNm != ""'>
and mr.wrt_user_nm like '%'||#{wrtUserNm}||'%'
</if>
<if test='wrtOrgan != null and wrtOrgan != ""'>
and mr.wrt_organ = #{wrtOrgan}
</if>
<if test='clearTitle != null and clearTitle != ""'>
and mr.clear_title like '%'||#{clearTitle}||'%'
</if>
<if test='mrState != null and mrState != ""'>
and mr.mr_state = #{mrState}
</if>
<if test='dateSelector == "mrDt"'>
<if test='startDate != null and startDate != ""'>
and mr.mr_sdate >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and mr.mr_edate &lt;= #{endDate}::date
</if>
</if>
<if test='dateSelector == "wrtDt"'>
<if test='startDate != null and startDate != ""'>
and mr.wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and mr.wrt_dt &lt;= #{endDate}::date+1
</if>
</if>
<if test="downOrganCdList != null">
and mr.wrt_organ in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</if>
<if test='userType != null and userType != ""'>
<if test='userType == "normalStayList"'>
and mr_state in ('DST002', 'DST004')
</if>
<if test='userType == "normalCommitList"'>
and mr_state in ('DST003', 'DST005', 'DST006')
</if>
<if test='userType == "sectionCommitList"'>
and mr_state in ('DST003', 'DST004', 'DST005', 'DST006')
</if>
<if test='userType == "headCommitList"'>
and mr_state in ('DST003', 'DST005', 'DST006')
</if>
<if test='userType == "managerStayList"'>
and mr_state in ('DST002', 'DST004')
</if>
<if test='userType == "managerCommitList"'>
and mr_state in ('DST003', 'DST005', 'DST006')
</if>
</if>
</sql>
<select id="selectResultList" resultType="MonitoringResult" parameterType="MonitoringResult">
select mr_key,
mr_title,
clear_title,
mr_sdate,
mr_edate,
md_dt,
md_name,
md_nationality,
md_rank,
mr.wrt_user_seq,
(select item_value from code_mgt where item_cd = mr.wrt_organ) as wrt_organ,
(select item_value from code_mgt where item_cd = mr.wrt_part) as wrt_part,
(select item_value from code_mgt where item_cd = mr.wrt_user_grd) as wrt_user_grd,
mr.wrt_user_nm,
mr.wrt_dt,
(select item_value from code_mgt where item_cd = mr_state) as mr_state
from monitoring_result mr,
monitoring_designation md
where mr.md_key = md.md_key
<include refid="selectResultListWhere"></include>
order by mr_key desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectResultListCnt" resultType="Integer" parameterType="MonitoringResult">
select count(*)
from(
select mr_key,
mr_title,
mr_sdate,
mr_edate,
md_dt,
md_name,
md_nationality,
md_rank,
mr.wrt_user_seq,
(select item_value from code_mgt where item_cd = mr.wrt_organ) as wrt_organ,
(select item_value from code_mgt where item_cd = mr.wrt_part) as wrt_part,
(select item_value from code_mgt where item_cd = mr.wrt_user_grd) as wrt_user_grd,
mr.wrt_user_nm,
mr.wrt_dt,
(select item_value from code_mgt where item_cd = mr_state) as mr_state
from monitoring_result mr,
monitoring_designation md
where mr.md_key = md.md_key
<include refid="selectResultListWhere"></include>
order by mr_key desc
)a
</select>
</mapper>