FAISP/src/main/resources/mybatisMapper/InternationalCrimeArrestMap...

149 lines
5.7 KiB
XML
Raw Normal View History

<?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.faStatistics.internationalCrimeArrest.mapper.InternationalCrimeArrestMapper">
<sql id="selectInternationalCrimeArrestListWhere">
<where>
2023-04-20 09:41:02 +00:00
status &lt;> 'DST008'
<if test='organ != null and organ != ""'>
AND organ = #{organ}
</if>
<if test='department != null and department != ""'>
AND department = #{department}
</if>
<if test='crimeType != null and crimeType != ""'>
AND crime_type = #{crimeType}
</if>
<if test='violationType != null and violationType != ""'>
AND violation_type = #{violationType}
</if>
<if test='caseNum != null and caseNum != ""'>
AND case_num = #{caseNum}
</if>
<if test='crimeName != null and crimeName != ""'>
AND crime_name LIKE CONCAT('%', #{crimeName}, '%')
</if>
<if test='occurTable != null and occurTable != ""'>
AND occur_table LIKE CONCAT('%', #{occurTable}, '%')
</if>
<if test='arrestTable != null and arrestTable != ""'>
AND arrest_table LIKE CONCAT('%', #{arrestTable}, '%')
</if>
<if test='suspectTable != null and suspectTable != ""'>
AND suspect_table LIKE CONCAT('%', #{suspectTable}, '%')
</if>
<if test='crimeAwarenessDt != null'>
And crime_awareness_dt = #{crimeAwarenessDt}::DATE
</if>
<if test='caseSentDt != null'>
AND case_sent_dt = #{caseSentDt}::DATE
</if>
<if test='processResult != null and processResult != ""'>
2023-04-20 09:41:02 +00:00
AND ica_key in (
select ica_key
from ica_suspect_info
where process_result = #{processResult}
)
</if>
<if test='dateSelector == "wrtDt"'>
<if test='startDate != null and startDate != ""'>
And wrt_dt >= #{startDate}::DATE
</if>
<if test='endDate != null and endDate != ""'>
AND wrt_dt &lt;= #{endDate}::DATE+1
</if>
</if>
</where>
</sql>
<select id="selectInternationalCrimeArrestList" resultType="InternationalCrimeArrest" parameterType="InternationalCrimeArrest">
2023-04-20 09:41:02 +00:00
SELECT a.ica_key,
a.organ,
a.department,
a.case_officer,
2023-04-20 09:41:02 +00:00
a.crime_type,
a.violation_type,
a.crime_name,
a.occur_table,
a.arrest_table,
a.suspect_table,
a.crime_awareness_dt,
a.case_sent_dt,
a.case_num,
a.wrt_organ,
a.wrt_part,
a.wrt_user_grd,
a.wrt_user_nm,
a.wrt_dt
2023-04-20 09:41:02 +00:00
FROM international_crime_arrest a
<include refid="selectInternationalCrimeArrestListWhere"></include>
2023-04-20 09:41:02 +00:00
ORDER BY a.ica_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
</select>
<select id="selectInternationalCrimeArrestListCnt" resultType="int" parameterType="InternationalCrimeArrest">
SELECT count(*)
2023-04-20 09:41:02 +00:00
FROM international_crime_arrest a
<include refid="selectInternationalCrimeArrestListWhere"></include>
</select>
<select id="selectSuspectPersonInfoParamList" resultType="com.dbnt.faisp.util.ParamMap" parameterType="int">
SELECT
s.spi_key,
s.ica_key,
s.sex,
s.age,
s.country,
s.stay_qualification,
s.stay_period_expired_dt,
s.entry_visa
FROM suspect_person_info s
INNER JOIN international_crime_arrest i
ON s.ica_key = i.ica_key
WHERE s.ica_key = #{icaKey}
</select>
<select id="selectIcaStatistics" resultType="IcaStatistics" parameterType="IcaStatistics">
select a.item_value as crime_type ,
b.item_value as violation_type,
coalesce(c.caseCnt, 0) as caseCnt,
coalesce(c.suspectCnt, 0) as suspectCnt,
coalesce(c.arrestCnt, 0) as arrestCnt,
coalesce(c.arrestSuspectCnt, 0) as arrestSuspectCnt,
coalesce(c.pcr001Cnt, 0) as pcr001Cnt,
coalesce(c.pcr002Cnt, 0) as pcr002Cnt,
coalesce(c.pcr003Cnt, 0) as pcr003Cnt,
coalesce(c.pcr004Cnt, 0) as pcr004Cnt,
coalesce(c.pcr005Cnt, 0) as pcr005Cnt
from code_mgt a
inner join code_mgt b on a.category_cd = 'CTH' and a.item_cd = b.category_cd
left outer join (
select aa.crime_type,
aa.violation_type,
count(distinct aa.ica_key) as caseCnt,
count(*) as suspectCnt,
0 as arrestCnt,
0 as arrestSuspectCnt,
sum(case when ab.process_result = 'PCR001' then 1 else 0 end) as pcr001Cnt,
sum(case when ab.process_result = 'PCR002' then 1 else 0 end) as pcr002Cnt,
sum(case when ab.process_result = 'PCR003' then 1 else 0 end) as pcr003Cnt,
sum(case when ab.process_result = 'PCR004' then 1 else 0 end) as pcr004Cnt,
sum(case when ab.process_result = 'PCR005' then 1 else 0 end) as pcr005Cnt
from international_crime_arrest aa
inner join ica_suspect_info ab on aa.ica_key = ab.ica_key
where department = #{organ}
and EXTRACT(YEAR FROM wrt_dt) = ${year}
and EXTRACT(MONTH FROM wrt_dt) = ${month}
group by crime_type, violation_type
) c on a.item_cd = c.crime_type and b.item_cd = c.violation_type
order by a.item_cd, b.item_cd
</select>
<select id="selectYearOptionList" resultType="int" parameterType="string">
select distinct EXTRACT(YEAR FROM wrt_dt)
from international_crime_arrest
where department = #{organ}
</select>
</mapper>