FAICS/src/main/resources/sqlmapper/mappers/report/report.xml

1309 lines
40 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="Report">
<resultMap id="reportMap" type="reportVO">
<id property="inSeq" column="in_seq" />
<result property="inAgencyCode" column="in_agency_code" />
<result property="inPlaceCode" column="in_place_code" />
<result property="inPlaceName" column="in_place_name" />
<result property="inPlaceNum" column="in_place_num" />
<result property="inType" column="in_type" />
<result property="inCategory1" column="in_category1" />
<result property="inCategory2" column="in_category2" />
<result property="inCategory3" column="in_category3" />
<result property="inCategory4" column="in_category4" />
<result property="inUseCategory1" column="inUseCategory1" />
<result property="inUseCategory2" column="inUseCategory2" />
<result property="inUseCategory3" column="inUseCategory3" />
<result property="inUseCategory4" column="inUseCategory4" />
<result property="inSubject" column="in_subject" />
<result property="inMemo" column="in_memo" />
<result property="inPlace1" column="in_place1" />
<result property="inPlace2" column="in_place2" />
<result property="inPosition" column="in_position" />
<result property="inName" column="in_name" />
<result property="inUserid" column="in_userid" />
<result property="inIp" column="in_ip" />
<result property="inContent" column="in_content" />
<result property="inFile1" column="in_file1" />
<result property="inFile2" column="in_file2" />
<result property="inFile3" column="in_file3" />
<result property="inFile4" column="in_file4" />
<result property="inFile5" column="in_file5" />
<result property="inFsseq" column="in_fsseq" />
<result property="inInfodate" column="in_infodate" />
<result property="inInfoYear" column="in_info_year" />
<result property="inInfoMonth" column="in_info_month" />
<result property="inInfoDay" column="in_info_day" />
<result property="inRegdate" column="in_regdate" />
<result property="inJudge" column="in_judge" />
<result property="inJudge1" column="in_judge1" />
<result property="inJudge2" column="in_judge2" />
<result property="inJudge3" column="in_judge3" />
<result property="inReport" column="in_report" />
<result property="inReport1" column="in_report1" />
<result property="inReport2" column="in_report2" />
<result property="inReport3" column="in_report3" />
<result property="inJuseq1Section" column="in_juseq1_section" />
<result property="inJuseq1Head" column="in_juseq1_head" />
<result property="inJuseq2Section" column="in_juseq2_section" />
<result property="inJuseq2Head" column="in_juseq2_head" />
<result property="inJuseq3Section" column="in_juseq3_section" />
<result property="inJuseq3Head" column="in_juseq3_head" />
<result property="inOfflineType" column="in_offline_type" />
<result property="inOfflineUserid" column="in_offline_userid" />
<result property="inComplete" column="in_complete" />
<result property="inOld" column="in_old" />
<result property="inDelete" column="in_delete" />
<result property="inStateCode" column="in_state_code" />
<result property="inJudge4" column="in_judge4" />
<result property="inJudge5" column="in_judge5" />
<result property="inJudge6" column="in_judge6" />
<result property="inReport4" column="in_report4" />
<result property="inReport5" column="in_report5" />
<result property="inReport6" column="in_report6" />
<result property="inCategory1Str" column="inCategory1Str" />
<result property="inCategory2Str" column="inCategory2Str" />
<result property="inCategory3Str" column="inCategory3Str" />
<result property="inCategory4Str" column="inCategory4Str" />
<result property="inAutoRemove" column="in_auto_remove" />
<result property="docNo" column="docNo" />
<result property="judgeStr" column="judgeStr" />
<result property="fullReportStr" column="fullReportStr" />
<result property="cateStrOrder" column="cateStrOrder" />
</resultMap>
<select id="Report.selectCategory" parameterType="int" resultType="reportCategoryVO" >
SELECT
code, name
FROM
RPT_CATEGORY
WHERE
type = #{type}
ORDER BY
code
</select>
<select id="Report.selectUseCategory" parameterType="int" resultType="reportCategoryVO" >
SELECT
code, name
FROM
RPT_CATEGORY
WHERE
type = #{type} AND
USE_YN = 'Y'
ORDER BY
code
</select>
<select id="Report.selectPlaceNum" parameterType="reportVO" resultType="int">
SELECT
COALESCE(MAX(in_place_num), 0) + 1 AS inPlaceNum
FROM
RPT_INFO
WHERE
IN_PLACE_CODE = #{inPlaceCode}
</select>
<select id="Report.select" parameterType="reportVO" resultMap="reportMap">
SELECT rc1.name AS inCategory1Str,
rc2.name AS inCategory2Str,
rc3.name AS inCategory3Str,
rc4.name AS inCategory4Str,
rc1.use_yn AS inUseCategory1,
rc2.use_yn AS inUseCategory2,
rc3.use_yn AS inUseCategory3,
rc4.use_yn AS inUseCategory4,
(IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
(CASE
WHEN IN_REPORT = 0 AND IN_REPORT1 = 0 AND IN_REPORT2 = 0 THEN '-'
WHEN IN_REPORT2 > 0 THEN '상보(' || (SELECT CODENM
FROM TCODE
WHERE CODE1 = 'DC05'
AND cast(CODE2 as integer) = in_judge3)|| ')'
ELSE '상보'
END) AS fullReportStr,
ri.*
from rpt_info ri
left outer join Rpt_Category rc1 on rc1.type = 1 and rc1.code = ri.in_category1
left outer join Rpt_Category rc2 on rc2.type = 2 and rc2.code = ri.in_category2
left outer join Rpt_Category rc3 on rc3.type = 3 and rc3.code = ri.in_category3
left outer join Rpt_Category rc4 on rc4.type = 4 and rc4.code = ri.in_category4
WHERE in_seq = #{inSeq}
</select>
<select id="Report.selectSaveList" parameterType="reportSearchVO" resultMap="reportMap">
SELECT (ROW_NUMBER() OVER()) AS RNUM,
rpt.*
FROM rpt_info rpt
where in_state_code = '99'
and in_type = #{type}
<choose>
<when test='type != null and type.equals("1")'>
and in_userid = #{userid}
</when>
<when test='type == null or type != "1"'>
and in_userid IN (#{userid}, '''' || #{usegrade} || '''')
</when>
</choose>
<choose>
<when test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
order by ${orderCol} ${orderAsc}
</when>
<otherwise>
order by in_seq desc
</otherwise>
</choose>
limit #{recordCountPerPage} offset #{firstIndex}
</select>
<select id="Report.selectSaveListCnt" parameterType="reportSearchVO" resultType="int">
SELECT COUNT(*)
FROM RPT_INFO
WHERE IN_STATE_CODE = '99'
AND IN_TYPE = #{type}
<choose>
<when test='type != null and type.equals("1")'>
AND IN_USERID = #{userid}
</when>
<when test='type == null or type != "1"'>
AND IN_USERID IN (#{userid}, '''' || #{usegrade} || '''')
</when>
</choose>
</select>
<insert id="Report.insert" parameterType="reportVO">
INSERT INTO RPT_INFO (
in_agency_code,
in_place_code,
in_place_name,
in_place_num,
in_category1,
in_category2,
in_category3,
in_category4,
in_memo,
in_subject,
in_type,
in_place1,
in_place2,
in_position,
in_name,
in_userid,
in_ip,
in_fsseq,
in_infodate,
in_info_year,
in_info_month,
in_info_day,
in_regdate,
in_state_code,
in_content,
in_auto_remove,
in_offline_type,
in_offline_userid,
in_report,
in_report1,
in_report2,
in_report3,
in_report4,
in_report5,
in_report6,
in_judge,
in_judge1,
in_judge2,
in_judge3,
in_judge4,
in_judge5,
in_judge6
) VALUES (
#{inAgencyCode},
#{inPlaceCode},
#{inPlaceName},
#{inPlaceNum},
#{inCategory1},
#{inCategory2},
#{inCategory3},
#{inCategory4},
#{inMemo},
#{inSubject},
#{inType},
#{inPlace1},
#{inPlace2},
#{inPosition},
#{inName},
#{inUserid},
#{inIp},
#{inFsseq},
TO_DATE(#{inInfoYear} || '/' || #{inInfoMonth} || '/' || #{inInfoDay}, 'YY/MM/DD'),
#{inInfoYear},
#{inInfoMonth},
#{inInfoDay},
NOW(),
#{inStateCode},
#{inContent},
#{inAutoRemove},
#{inOfflineType},
#{inOfflineUserid},
#{inReport},
#{inReport1},
#{inReport2},
#{inReport3},
#{inReport4},
#{inReport5},
#{inReport6},
#{inJudge},
#{inJudge1},
#{inJudge2},
#{inJudge3},
#{inJudge4},
#{inJudge5},
#{inJudge6}
)
<selectKey resultType="int" keyProperty="inSeq" order="AFTER">
SELECT currval('rpt_info_in_seq') as inSeq
</selectKey>
</insert>
<update id="Report.update" parameterType="reportVO">
UPDATE
RPT_INFO
SET
in_agency_code = #{inAgencyCode},
in_place_code = #{inPlaceCode},
in_place_name = #{inPlaceName},
in_place_num = #{inPlaceNum},
in_category1 = #{inCategory1},
in_category2 = #{inCategory2},
in_category3 = #{inCategory3},
in_category4 = #{inCategory4},
in_memo = #{inMemo},
in_subject = #{inSubject},
in_type = #{inType},
in_place1 = #{inPlace1},
in_place2 = #{inPlace2},
in_position = #{inPosition},
in_name = #{inName},
in_userid = #{inUserid},
in_ip = #{inIp},
in_fsseq = #{inFsseq},
in_infodate = TO_DATE(#{inInfoYear} || '/' || #{inInfoMonth} || '/' || #{inInfoDay}, 'YY/MM/DD'),
in_info_year = #{inInfoYear},
in_info_month = #{inInfoMonth},
in_info_day = #{inInfoDay},
in_state_code = #{inStateCode},
in_content = #{inContent},
in_auto_remove = #{inAutoRemove},
in_complete = #{inComplete},
in_report = #{inReport},
in_report1 = #{inReport1},
in_report2 = #{inReport2},
in_report3 = #{inReport3},
in_report4 = #{inReport4},
in_report5 = #{inReport5},
in_report6 = #{inReport6},
in_judge = #{inJudge},
in_judge1 = #{inJudge1},
in_judge2 = #{inJudge2},
in_judge3 = #{inJudge3},
in_judge4 = #{inJudge4},
in_judge5 = #{inJudge5},
in_judge6 = #{inJudge6},
in_juseq1_section = #{inJuseq1Section},
in_juseq1_head = #{inJuseq1Head},
in_juseq2_section = #{inJuseq2Section},
in_juseq2_head = #{inJuseq2Head},
in_juseq3_section = #{inJuseq3Section},
in_juseq3_head = #{inJuseq3Head}
WHERE
in_seq = #{inSeq}
</update>
<delete id="Report.delete" parameterType="reportVO">
DELETE
FROM
RPT_INFO
WHERE
in_seq = #{inSeq}
</delete>
<!-- 자동삭제 -->
<select id="Report.selectAutoRemoveList" resultType="String">
SELECT
LISTAGG(IN_SEQ, ',') WITHIN GROUP (ORDER BY IN_SEQ) AS RESULT
FROM
RPT_INFO
WHERE
IN_REGDATE &lt;= NOW() + interval '-3 month'
AND
IN_AUTO_REMOVE = 1
</select>
<!-- 검색 -->
<select id="Report.selectListAll" parameterType="reportSearchVO" resultMap="reportMap">
/*Report.selectListAll*/
SELECT
ALL_LIST.*,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 1 AND CODE = ALL_LIST.IN_CATEGORY1) AS inCategory1Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 2 AND CODE = ALL_LIST.IN_CATEGORY2) AS inCategory2Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 3 AND CODE = ALL_LIST.IN_CATEGORY3) AS inCategory3Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 4 AND CODE = ALL_LIST.IN_CATEGORY4) AS inCategory4Str,
(ALL_LIST.IN_PLACE_NAME || '외사-' || ALL_LIST.IN_PLACE_NUM) AS docNo,
(CASE WHEN IN_REPORT = 0 AND IN_REPORT1 = 0 AND IN_REPORT2 = 0 THEN '-'
WHEN IN_REPORT2 > 0 THEN '상보(' || (SELECT CODENM FROM TCODE WHERE CODE1 = 'DC05' AND cast(CODE2 as integer) = in_judge3)|| ')'
ELSE '상보' END) AS fullReportStr,
(CASE
WHEN judge = 1 THEN '특보' WHEN judge = 2 THEN '판단' WHEN judge = 3 THEN '중보' WHEN judge = 4 THEN '통보'
WHEN judge = 5 THEN '기록' WHEN judge = 6 THEN '조사' WHEN judge = 7 THEN '참고'
END) AS judgeStr
FROM
(
SELECT
RPT.*,
<choose>
<when test="myGroupCode.equals(3)">
(CASE
WHEN IN_JUDGE3 > 0 THEN IN_JUDGE3
WHEN IN_JUDGE2 > 0 THEN IN_JUDGE2
WHEN IN_JUDGE1 > 0 THEN IN_JUDGE1
ELSE NULL
END)
</when>
<when test="myGroupCode.equals(2)">
(CASE
WHEN IN_JUDGE2 > 0 THEN IN_JUDGE2
WHEN IN_JUDGE1 > 0 THEN IN_JUDGE1
ELSE NULL
END)
</when>
<when test="myGroupCode.equals(1)">
(CASE
WHEN IN_JUDGE1 > 0 THEN IN_JUDGE1
ELSE NULL
END)
</when>
<otherwise>
NULL
</otherwise>
</choose>
AS judge
FROM
RPT_INFO RPT
WHERE
IN_COMPLETE = '1' AND
IN_STATE_CODE &lt;&gt; '99'
<choose>
<when test="myGroupCode.equals(3)">
AND 3 = 3
</when>
<when test="myGroupCode.equals(2)">
AND 2 = 2
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND 1 = 1
AND IN_PLACE_CODE = #{userPlace}
</when>
<otherwise></otherwise>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="writeName != null and writeName != ''">
AND IN_NAME = #{writeName}
</if>
<if test="writeId != null and writeId != ''">
AND IN_USERID = #{writeId}
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="filename != null and filename != ''">
AND (IN_FILE1 LIKE '%'||#{filename}||'%'
OR IN_FILE3 LIKE '%'||#{filename}||'%'
OR IN_FILE3 LIKE '%'||#{filename}||'%'
OR IN_FILE4 LIKE '%'||#{filename}||'%'
OR IN_FILE5 LIKE '%'||#{filename}||'%')
</if>
<if test="policeType != null and policeType.length > 0">
AND IN_TYPE IN
<foreach collection="policeType" item="type" open="(" close=")" separator=",">
#{type}
</foreach>
</if>
<if test="places != null and places.length > 0">
AND IN_PLACE_CODE IN
<foreach collection="places" item="place" open="(" close=")" separator=",">
#{place}
</foreach>
</if>
<if test="judges != null and judges.length > 0">
AND IN_JUDGE IN
<foreach collection="judges" item="judge" open="(" close=")" separator=",">
#{judge}
</foreach>
</if>
<if test="fullReport != null and fullReport.length > 0">
AND
<foreach collection="fullReport" item="report" open="(" close=")" separator=" OR ">
IN_REPORT${report} = 1
</foreach>
</if>
<if test="category1 != null and category1.length > 0">
AND IN_CATEGORY1 IN
<foreach collection="category1" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category2 != null and category2.length > 0">
AND IN_CATEGORY2 IN
<foreach collection="category2" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category3 != null and category3.length > 0">
AND IN_CATEGORY3 IN
<foreach collection="category3" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category4 != null and category4.length > 0">
AND IN_CATEGORY4 IN
<foreach collection="category4" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY
${orderCol} ${orderAsc}
</if>
) ALL_LIST
</select>
<select id="Report.selectTotalCnt" parameterType="reportSearchVO" resultType="int">
SELECT
COUNT(*)
FROM
RPT_INFO
WHERE
IN_COMPLETE = '1' AND
IN_STATE_CODE &lt;&gt; '99'
<choose>
<when test="myGroupCode.equals(3)"></when>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
<otherwise></otherwise>
</choose>
</select>
<select id="Report.selectList" parameterType="reportSearchVO" resultMap="reportMap">
/*Report.selectList*/
SELECT *
FROM (
SELECT
ALL_LIST.*,
(row_number() over()) as RNUM,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 1 AND CODE = ALL_LIST.IN_CATEGORY1) AS inCategory1Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 2 AND CODE = ALL_LIST.IN_CATEGORY2) AS inCategory2Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 3 AND CODE = ALL_LIST.IN_CATEGORY3) AS inCategory3Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 4 AND CODE = ALL_LIST.IN_CATEGORY4) AS inCategory4Str,
(ALL_LIST.IN_PLACE_NAME || '외사-' || ALL_LIST.IN_PLACE_NUM) AS docNo,
(CASE WHEN IN_REPORT = 0 AND IN_REPORT1 = 0 AND IN_REPORT2 = 0 THEN '-'
WHEN IN_REPORT2 > 0 THEN '상보(' || (SELECT CODENM
FROM TCODE
WHERE CODE1 = 'DC05'
AND cast(CODE2 as integer) = in_judge3)|| ')'
ELSE '상보' END) AS fullReportStr,
(CASE
WHEN judge = 1
THEN '특보'
WHEN judge = 2
THEN '판단'
WHEN judge = 3
THEN '중보'
WHEN judge = 4
THEN '통보'
WHEN judge = 5
THEN '기록'
WHEN judge = 6
THEN '조사'
WHEN judge = 7
THEN '참고'
END) AS judgeStr
FROM
(SELECT
RPT.*,
<choose>
<when test="myGroupCode.equals(3)">
(CASE
WHEN IN_JUDGE3 &gt; 0 THEN IN_JUDGE3
WHEN IN_JUDGE2 &gt; 0 THEN IN_JUDGE2
WHEN IN_JUDGE1 &gt; 0 THEN IN_JUDGE1
ELSE NULL
END)
</when>
<when test="myGroupCode.equals(2)">
(CASE
WHEN IN_JUDGE2 &gt; 0 THEN IN_JUDGE2
WHEN IN_JUDGE1 &gt; 0 THEN IN_JUDGE1
ELSE NULL
END)
</when>
<when test="myGroupCode.equals(1)">
(CASE
WHEN IN_JUDGE1 &gt; 0 THEN IN_JUDGE1
ELSE NULL
END)
</when>
<otherwise>
NULL
</otherwise>
</choose>
AS judge
FROM
RPT_INFO RPT
WHERE
IN_COMPLETE = '1' AND
IN_STATE_CODE &lt;&gt; '99'
<choose>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="writeName != null and writeName != ''">
AND IN_NAME = #{writeName}
</if>
<if test="writeId != null and writeId != ''">
AND IN_USERID = #{writeId}
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="filename != null and filename != ''">
AND (IN_FILE1 LIKE '%'||#{filename}||'%'
OR IN_FILE3 LIKE '%'||#{filename}||'%'
OR IN_FILE3 LIKE '%'||#{filename}||'%'
OR IN_FILE4 LIKE '%'||#{filename}||'%'
OR IN_FILE5 LIKE '%'||#{filename}||'%')
</if>
<if test="policeType != null and policeType.length > 0">
AND IN_TYPE IN
<foreach collection="policeType" item="type" open="(" close=")" separator=",">
#{type}
</foreach>
</if>
<if test="places != null and places.length > 0">
AND IN_PLACE_CODE IN
<foreach collection="places" item="place" open="(" close=")" separator=",">
#{place}
</foreach>
</if>
<if test="judges != null and judges.length > 0">
AND IN_JUDGE IN
<foreach collection="judges" item="judge" open="(" close=")" separator=",">
#{judge}
</foreach>
</if>
<if test="fullReport != null and fullReport.length > 0">
AND
<foreach collection="fullReport" item="report" open="(" close=")" separator=" OR ">
IN_REPORT${report} = 1
</foreach>
</if>
<if test="category1 != null and category1.length > 0">
AND IN_CATEGORY1 IN
<foreach collection="category1" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category2 != null and category2.length > 0">
AND IN_CATEGORY2 IN
<foreach collection="category2" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category3 != null and category3.length > 0">
AND IN_CATEGORY3 IN
<foreach collection="category3" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category4 != null and category4.length > 0">
AND IN_CATEGORY4 IN
<foreach collection="category4" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
) ALL_LIST
) as sl
WHERE
RNUM &gt; #{firstIndex}
AND
RNUM &lt;= #{firstIndex} + #{recordCountPerPage}
</select>
<select id="Report.selectListCnt" parameterType="reportSearchVO" resultType="int">
SELECT
COUNT(*)
FROM
RPT_INFO
WHERE
IN_COMPLETE = '1' AND
IN_STATE_CODE &lt;&gt; '99'
<choose>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="writeName != null and writeName != ''">
AND IN_NAME = #{writeName}
</if>
<if test="writeId != null and writeId != ''">
AND IN_USERID = #{writeId}
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="filename != null and filename != ''">
AND (IN_FILE1 LIKE '%'||#{filename}||'%'
OR IN_FILE3 LIKE '%'||#{filename}||'%'
OR IN_FILE3 LIKE '%'||#{filename}||'%'
OR IN_FILE4 LIKE '%'||#{filename}||'%'
OR IN_FILE5 LIKE '%'||#{filename}||'%')
</if>
<if test="policeType != null and policeType.length > 0">
AND IN_TYPE IN
<foreach collection="policeType" item="type" open="(" close=")" separator=",">
#{type}
</foreach>
</if>
<if test="places != null and places.length > 0">
AND IN_PLACE_CODE IN
<foreach collection="places" item="place" open="(" close=")" separator=",">
#{place}
</foreach>
</if>
<if test="judges != null and judges.length > 0">
AND IN_JUDGE IN
<foreach collection="judges" item="judge" open="(" close=")" separator=",">
#{judge}
</foreach>
</if>
<if test="fullReport != null and fullReport.length > 0">
AND
<foreach collection="fullReport" item="report" open="(" close=")" separator=" OR ">
IN_REPORT${report} = 1
</foreach>
</if>
<if test="category1 != null and category1.length > 0">
AND IN_CATEGORY1 IN
<foreach collection="category1" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category2 != null and category2.length > 0">
AND IN_CATEGORY2 IN
<foreach collection="category2" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category3 != null and category3.length > 0">
AND IN_CATEGORY3 IN
<foreach collection="category3" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
<if test="category4 != null and category4.length > 0">
AND IN_CATEGORY4 IN
<foreach collection="category4" item="category" open="(" close=")" separator=",">
#{category}
</foreach>
</if>
</select>
<!-- 결재 대기 목록 -->
<select id="Report.selectWaitList" parameterType="reportSearchVO" resultMap="reportMap">
select (ROW_NUMBER() OVER()) AS RNUM,
(ri.IN_PLACE_NAME || '외사-' || ri.IN_PLACE_NUM) AS docNo ,
rc1.name as inCategory1Str,
rc2.name as inCategory2Str,
rc3.name as inCategory3Str,
rc4.name as inCategory4Str,
*
from rpt_info ri
left outer join Rpt_Category rc1 on rc1.type = 1 and rc1.code = ri.in_category1
left outer join Rpt_Category rc2 on rc2.type = 2 and rc2.code = ri.in_category2
left outer join Rpt_Category rc3 on rc3.type = 3 and rc3.code = ri.in_category3
left outer join Rpt_Category rc4 on rc4.type = 4 and rc4.code = ri.in_category4
where IN_STATE_CODE &lt;> '99'
<choose>
<when test="dutiesForApprove.equals(2)">
AND (IN_STATE_CODE = #{myGroupCode}||'1' OR IN_STATE_CODE = #{myGroupCode}||'3')
</when>
<otherwise>
AND (IN_STATE_CODE = #{myGroupCode}||'1' OR IN_STATE_CODE = #{myGroupCode}||'2')
</otherwise>
</choose>
<choose>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
</choose>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
limit #{recordCountPerPage} offset #{firstIndex}
</select>
<select id="Report.selectWaitListAll" parameterType="reportSearchVO" resultMap="reportMap">
select (ROW_NUMBER() OVER()) AS RNUM,
(ri.IN_PLACE_NAME || '외사-' || ri.IN_PLACE_NUM) AS docNo ,
rc1.name as inCategory1Str,
rc2.name as inCategory2Str,
rc3.name as inCategory3Str,
rc4.name as inCategory4Str,
*
from rpt_info ri
left outer join Rpt_Category rc1 on rc1.type = 1 and rc1.code = ri.in_category1
left outer join Rpt_Category rc2 on rc2.type = 2 and rc2.code = ri.in_category2
left outer join Rpt_Category rc3 on rc3.type = 3 and rc3.code = ri.in_category3
left outer join Rpt_Category rc4 on rc4.type = 4 and rc4.code = ri.in_category4
where IN_STATE_CODE &lt;> '99'
AND (IN_STATE_CODE = #{myGroupCode}||'1'
OR IN_STATE_CODE =
(CASE
WHEN #{duties} = '계장' THEN #{myGroupCode}||'3'
ELSE #{myGroupCode}||'2'
END)
)
<choose>
<when test="dutiesForApprove.equals(2)">
AND (IN_STATE_CODE = #{myGroupCode}||'1' OR IN_STATE_CODE = #{myGroupCode}||'3')
</when>
<otherwise>
AND (IN_STATE_CODE = #{myGroupCode}||'1' OR IN_STATE_CODE = #{myGroupCode}||'2')
</otherwise>
</choose>
<choose>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
</choose>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
</select>
<select id="Report.selectWaitListCnt" parameterType="reportSearchVO" resultType="int">
select count(*)
from rpt_info ri
where IN_STATE_CODE &lt;> '99'
AND (IN_STATE_CODE = #{myGroupCode}||'1'
OR IN_STATE_CODE = (CASE WHEN #{duties} = '계장'
THEN #{myGroupCode}||'3'
ELSE #{myGroupCode}||'2' END))
<choose>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
</choose>
</select>
<!-- 견문 결재 처리 목록 -->
<select id="Report.selectAprList" parameterType="reportSearchVO" resultMap="reportMap">
SELECT
(ROW_NUMBER() OVER()) AS RNUM,
(IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
I.*
FROM RPT_INFO I
INNER JOIN RPT_JUDGE_HISTORY J ON I.IN_SEQ = J.JU_INSEQ
WHERE
IN_STATE_CODE != '99'
AND IN_TYPE = #{type}
AND JU_USERID = #{userid}
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
limit #{recordCountPerPage} offset #{firstIndex}
</select>
<select id="Report.selectAprListCnt" parameterType="reportSearchVO" resultType="int">
SELECT COUNT(*)
FROM RPT_INFO I
INNER JOIN RPT_JUDGE_HISTORY J ON I.IN_SEQ = J.JU_INSEQ
WHERE IN_STATE_CODE != '99'
AND IN_TYPE = #{type}
AND JU_USERID = #{userid}
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
</select>
<select id="Report.selectAprListAll" parameterType="reportSearchVO" resultMap="reportMap">
SELECT
(ROW_NUMBER() OVER()) AS RNUM,
(IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
I.*
FROM RPT_INFO I
INNER JOIN RPT_JUDGE_HISTORY J ON I.IN_SEQ = J.JU_INSEQ
WHERE IN_STATE_CODE != '99'
AND IN_TYPE = #{type}
AND JU_USERID = #{userid}
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
</select>
<!-- 내 실적 목록 -->
<select id="Report.selectMyList" parameterType="reportSearchVO" resultMap="reportMap">
select (ROW_NUMBER() OVER()) AS RNUM,
cat1.name AS inCategory1Str,
cat2.name AS inCategory2Str,
cat3.name AS inCategory3Str,
cat4.name AS inCategory4Str,
a.*
from (
select (IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
RPT.*
FROM RPT_INFO RPT
WHERE IN_STATE_CODE != '99'
AND IN_TYPE = #{type}
<choose>
<when test="type != null and type == '1'">
AND IN_USERID = #{userid}
</when>
<when test="type == null or type != '1'">
AND IN_USERID IN (#{userid}, '''' || #{usegrade} || '''')
</when>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
limit #{recordCountPerPage} offset #{firstIndex}
) a
inner join Rpt_Category CAT1 on CAT1.type = 1 and cat1.code = a.IN_CATEGORY1
inner join Rpt_Category CAT2 on CAT2.type = 2 and cat2.code = a.IN_CATEGORY2
inner join Rpt_Category CAT3 on CAT3.type = 3 and cat3.code = a.IN_CATEGORY3
inner join Rpt_Category CAT4 on CAT4.type = 4 and cat4.code = a.IN_CATEGORY4
</select>
<select id="Report.selectMyListCnt" parameterType="reportSearchVO" resultType="int">
SELECT
COUNT(*)
FROM
RPT_INFO
WHERE
IN_STATE_CODE != '99'
AND IN_TYPE = #{type}
<choose>
<when test="type != null and type.equals(1)">
AND IN_USERID = #{userid}
</when>
<when test="type == null or type != 1">
AND IN_USERID IN (#{userid}, '''' || #{usegrade} || '''')
</when>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
</select>
<select id="Report.selectMyListAll" parameterType="reportSearchVO" resultMap="reportMap">
SELECT
(ROW_NUMBER() OVER()) AS RNUM, T.*
FROM
(SELECT
(IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 1 AND CODE = RPT.IN_CATEGORY1) AS inCategory1Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 2 AND CODE = RPT.IN_CATEGORY2) AS inCategory2Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 3 AND CODE = RPT.IN_CATEGORY3) AS inCategory3Str,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 4 AND CODE = RPT.IN_CATEGORY4) AS inCategory4Str,
RPT.*
FROM
RPT_INFO RPT
WHERE
IN_STATE_CODE != '99'
AND IN_TYPE = #{type}
<choose>
<when test="type != null and type.equals(1)">
AND IN_USERID = #{userid}
</when>
<when test="type == null or type != 1">
AND IN_USERID IN (#{userid}, '''' || #{usegrade} || '''')
</when>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
) T
</select>
<!-- 견문 제출 현황 -->
<select id="Report.selectPresentList" parameterType="reportSearchVO" resultMap="reportMap">
SELECT *
FROM (
SELECT
(ROW_NUMBER() OVER()) AS RNUM, T.*
FROM
(SELECT
(IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 1 AND CODE = IN_CATEGORY1) || ' > ' ||
(SELECT NAME FROM Rpt_Category WHERE TYPE = 2 AND CODE = IN_CATEGORY2) || ' > ' ||
(SELECT NAME FROM Rpt_Category WHERE TYPE = 3 AND CODE = IN_CATEGORY3) || ' > ' ||
(SELECT NAME FROM Rpt_Category WHERE TYPE = 4 AND CODE = IN_CATEGORY4) AS cateStrOrder,
I.*
FROM
RPT_INFO I
WHERE
IN_STATE_CODE != '99'
<choose>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="writeName != null and writeName != ''">
AND IN_NAME LIKE '%'||#{writeName}||'%'
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
) T
) AS LIST
WHERE
RNUM > #{firstIndex} AND
RNUM &lt;= #{firstIndex} + #{recordCountPerPage}
</select>
<select id="Report.selectPresentListCnt" parameterType="reportSearchVO" resultType="int">
SELECT
COUNT(*)
FROM
RPT_INFO I
WHERE
IN_STATE_CODE != '99'
<choose>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="writeName != null and writeName != ''">
AND IN_NAME LIKE '%'||#{writeName}||'%'
</if>
</select>
<select id="Report.selectPresentListAll" parameterType="reportSearchVO" resultMap="reportMap">
SELECT
*
FROM
(SELECT
(IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
(SELECT NAME FROM Rpt_Category WHERE TYPE = 1 AND CODE = IN_CATEGORY1) || ' > ' ||
(SELECT NAME FROM Rpt_Category WHERE TYPE = 2 AND CODE = IN_CATEGORY2) || ' > ' ||
(SELECT NAME FROM Rpt_Category WHERE TYPE = 3 AND CODE = IN_CATEGORY3) || ' > ' ||
(SELECT NAME FROM Rpt_Category WHERE TYPE = 4 AND CODE = IN_CATEGORY4) AS cateStrOrder,
I.*
FROM
RPT_INFO I
WHERE
IN_STATE_CODE != '99'
<choose>
<when test="myGroupCode.equals(2)">
AND IN_AGENCY_CODE = #{userPlace}
</when>
<when test="myGroupCode.equals(1)">
AND IN_PLACE_CODE = #{userPlace}
</when>
</choose>
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="subject != null and subject != ''">
AND IN_SUBJECT LIKE '%'||#{subject}||'%'
</if>
<if test="writeName != null and writeName != ''">
AND IN_NAME LIKE '%'||#{writeName}||'%'
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
)
</select>
<!-- 평가기록부 -->
<select id="Report.selectRecordList" parameterType="reportSearchVO" resultMap="reportMap">
SELECT (ROW_NUMBER() OVER()) AS RNUM,
T.*
FROM (
SELECT (IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
R.*
FROM RPT_INFO R
WHERE IN_STATE_CODE != '99'
AND IN_COMPLETE = '1'
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="placeGroup != null and placeGroup != ''">
AND IN_PLACE_CODE = #{placeGroup}
</if>
<if test="placeGroup == null or placeGroup == ''">
AND IN_PLACE_CODE = #{userPlace}
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
) T
limit #{recordCountPerPage} offset #{firstIndex}
</select>
<select id="Report.selectRecordListCnt" parameterType="reportSearchVO" resultType="int">
SELECT
COUNT(*)
FROM
RPT_INFO
WHERE
IN_STATE_CODE != '99'
AND IN_COMPLETE = '1'
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="placeGroup != null and placeGroup != ''">
AND IN_PLACE_CODE = #{placeGroup}
</if>
<if test="placeGroup == null or placeGroup == ''">
AND IN_PLACE_CODE = #{userPlace}
</if>
</select>
<select id="Report.selectRecordListAll" parameterType="reportSearchVO" resultMap="reportMap">
SELECT
(ROW_NUMBER() OVER()) AS RNUM, T.*
FROM
(SELECT
(IN_PLACE_NAME || '외사-' || IN_PLACE_NUM) AS docNo,
R.*
FROM
RPT_INFO R
WHERE
IN_STATE_CODE != '99'
AND IN_COMPLETE = 1
<if test="dateStart != null and dateStart != ''">
AND IN_INFODATE &gt;= #{dateStart}::date
</if>
<if test="dateEnd != null and dateEnd != ''">
AND IN_INFODATE &lt;= #{dateEnd}::date
</if>
<if test="placeGroup != null and placeGroup != ''">
AND IN_PLACE_CODE = #{placeGroup}
</if>
<if test="placeGroup == null or placeGroup == ''">
AND IN_PLACE_CODE = #{userPlace}
</if>
<if test="orderCol != null and orderCol != '' and orderAsc != null and orderAsc != ''">
ORDER BY ${orderCol} ${orderAsc}
</if>
) T
</select>
</mapper>