160 lines
5.2 KiB
XML
160 lines
5.2 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.counterIntelligence.activityCase.mapper.ActivityCaseMapper">
|
|
<sql id="selectActivityCaseListWhere">
|
|
<where>
|
|
<if test='receiptKey != null and receiptKey != ""'>
|
|
and a.receipt_key = #{receiptKey}
|
|
</if>
|
|
<if test='receiptNum != null and receiptNum != ""'>
|
|
and a.receipt_num like '%'||#{receiptNum}||'%'
|
|
</if>
|
|
<if test='wrtUserNm != null and wrtUserNm != ""'>
|
|
and a.wrt_user_nm like '%'||#{wrtUserNm}||'%'
|
|
</if>
|
|
<if test='wrtOrgan != null and wrtOrgan != ""'>
|
|
and a.wrt_organ = #{wrtOrgan}
|
|
</if>
|
|
<if test='dateSelector == "reportDate"'>
|
|
<if test='startDate != null and startDate != ""'>
|
|
and c.report_date >= #{startDate}::date
|
|
</if>
|
|
<if test='endDate != null and endDate != ""'>
|
|
and c.report_date <= #{endDate}::date+1
|
|
</if>
|
|
</if>
|
|
<if test='dateSelector == "wrtDt"'>
|
|
<if test='startDate != null and startDate != ""'>
|
|
and c.wrt_dt >= #{startDate}::date
|
|
</if>
|
|
<if test='endDate != null and endDate != ""'>
|
|
and c.wrt_dt <= #{endDate}::date+1
|
|
</if>
|
|
</if>
|
|
<if test="downOrganCdList != null">
|
|
and a.wrt_organ in
|
|
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
|
|
#{organCd}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
</sql>
|
|
<select id="selectActivityCaseList" parameterType="ActivityCaseBoard" resultType="ActivityCaseBoard">
|
|
select a.receipt_key,
|
|
a.receipt_num ,
|
|
a.wrt_organ ,
|
|
a.wrt_part ,
|
|
a.wrt_user_seq ,
|
|
a.wrt_user_grd ,
|
|
a.wrt_user_nm ,
|
|
b.reportCnt,
|
|
c.case_type ,
|
|
c.case_num ,
|
|
c.title,
|
|
c.report_date ,
|
|
c.wrt_dt,
|
|
c.status,
|
|
d.suspectCnt,
|
|
e.name as suspectNm
|
|
from activity_case a
|
|
inner join (
|
|
select receipt_key,
|
|
count(*) as reportCnt,
|
|
max(case_key) as case_key
|
|
from activity_case_info
|
|
group by receipt_key
|
|
) b on a.receipt_key = b.receipt_key
|
|
inner join activity_case_info c
|
|
on c.case_key = b.case_key
|
|
inner join (
|
|
select receipt_key,
|
|
count(*) as suspectCnt,
|
|
min(suspect_seq) as suspect_seq
|
|
from activity_case_suspect
|
|
group by receipt_key
|
|
) d on a.receipt_key = d.receipt_key
|
|
inner join activity_case_suspect e
|
|
on a.receipt_key = e.receipt_key and d.suspect_seq = e.suspect_seq
|
|
<include refid="selectActivityCaseListWhere"></include>
|
|
order by c.wrt_dt desc
|
|
limit #{rowCnt} offset #{firstIndex}
|
|
</select>
|
|
<select id="selectActivityCaseCnt" parameterType="ActivityCaseBoard" resultType="int">
|
|
select count(*)
|
|
from activity_case a
|
|
inner join (
|
|
select receipt_key,
|
|
count(*) as reportCnt,
|
|
max(case_key) as case_key
|
|
from activity_case_info
|
|
group by receipt_key
|
|
) b on a.receipt_key = b.receipt_key
|
|
inner join activity_case_info c
|
|
on c.case_key = b.case_key
|
|
inner join (
|
|
select receipt_key,
|
|
count(*) as suspectCnt,
|
|
min(suspect_seq) as suspect_seq
|
|
from activity_case_suspect
|
|
group by receipt_key
|
|
) d on a.receipt_key = d.receipt_key
|
|
inner join activity_case_suspect e
|
|
on a.receipt_key = e.receipt_key and d.suspect_seq = e.suspect_seq
|
|
<include refid="selectActivityCaseListWhere"></include>
|
|
</select>
|
|
|
|
<select id="selectActivityCaseInfoList" parameterType="int" resultType="ActivityCaseSummary">
|
|
select a.receipt_key,
|
|
a.receipt_num ,
|
|
a.wrt_organ ,
|
|
a.wrt_part ,
|
|
a.wrt_user_seq ,
|
|
a.wrt_user_grd ,
|
|
a.wrt_user_nm ,
|
|
b.case_key ,
|
|
b.case_num ,
|
|
b.report_date ,
|
|
b.case_type ,
|
|
b.title,
|
|
b.wrt_dt,
|
|
b.status,
|
|
c.apprvCnt,
|
|
c.allCnt,
|
|
d.fileCnt
|
|
from activity_case a
|
|
inner join activity_case_info b
|
|
on a.receipt_key = b.receipt_key
|
|
left outer join (
|
|
select case_key,
|
|
count(apprv_yn = 'Y' or apprv_yn = 'N') as apprvCnt,
|
|
count(*) as allCnt
|
|
from activity_case_apprv
|
|
group by case_key
|
|
) c on b.case_key = c.case_key
|
|
left outer join (
|
|
select case_key,
|
|
count(*) as fileCnt
|
|
from activity_case_file
|
|
group by case_key
|
|
) d on b.case_key = d.case_key
|
|
where a.receipt_key = #{receiptKey}
|
|
order by b.wrt_dt asc
|
|
</select>
|
|
|
|
<select id="selectReceiptNum" resultType="int" parameterType="int">
|
|
select count(*)+1
|
|
from activity_case
|
|
where receipt_num like #{year}||'%'
|
|
</select>
|
|
<select id="selectCaseNum" resultType="int" parameterType="hashMap">
|
|
select count(*)+1
|
|
from activity_case a
|
|
inner join activity_case_info b
|
|
on a.receipt_key = b.receipt_key
|
|
where a.receipt_num = #{receiptNum}
|
|
and b.case_num like #{year}||'%'
|
|
</select>
|
|
</mapper> |