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

369 lines
13 KiB
XML
Raw Normal View History

2023-05-22 09:16:04 +00:00
<?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.unlawfulFishing.mapper.UnlawfulFishingMapper">
<select id="selectFishingBoatYearParam" resultType="int">
select distinct extract(year from napo_dt) as year
from crackdown_status
where napo_dt is not null
</select>
2023-06-05 09:25:02 +00:00
<select id="selectCrackdownInfoList" resultType="CrackdownInfo" parameterType="UnlawfulFishingParam">
select a.cds_key ,
case_num ,
napo_dt ,
napo_sea_point_lon ,
napo_sea_point_lat ,
napo_sea_point_detail ,
invasion_type ,
nll ,
case_agency ,
case_police_officer ,
crackdown_police ,
crackdown_boat ,
mmsi ,
field_ivsgt ,
wrt_organ ,
wrt_part ,
wrt_user_grd ,
wrt_user_nm ,
wrt_dt ,
violationStr,
violationCode
from crackdown_info a
left outer join (
select aa.cds_key,
array_to_string(array_agg(ab.item_value), ', ') as violationStr,
array_to_string(array_agg(ab.item_cd), ', ') as violationCode
from violation_info aa
inner join code_mgt ab on aa.violation = ab.item_cd
group by aa.cds_key
) vi on a.cds_key = vi.cds_key
<include refid="selectCrackdownInfoListWhere"></include>
order by a.wrt_dt desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectCrackdownInfoListCnt" resultType="int" parameterType="UnlawfulFishingParam">
select count(*)
from crackdown_info a
left outer join (
select aa.cds_key,
array_to_string(array_agg(ab.item_value), ', ') as violationStr,
array_to_string(array_agg(ab.item_cd), ', ') as violationCode
from violation_info aa
inner join code_mgt ab on aa.violation = ab.item_cd
group by aa.cds_key
) vi on a.cds_key = vi.cds_key
<include refid="selectCrackdownInfoListWhere"></include>
</select>
<sql id="selectCrackdownInfoListWhere">
where status &lt;> 'DST008'
<if test='caseAgency != null and caseAgency != ""'>
and case_agency = #{caseAgency}
</if>
<if test='casePoliceOfficer != null and casePoliceOfficer != ""'>
and case_police_officer like '%'||#{casePoliceOfficer}||'%'
</if>
<if test='crackdownPolice != null and crackdownPolice != ""'>
and crackdown_police = #{crackdownPolice}
</if>
<if test='crackdownBoat != null and crackdownBoat != ""'>
and crackdown_boat = #{crackdownBoat}
</if>
<if test='caseNum != null and caseNum != ""'>
and case_num like '%'||#{caseNum}||'%'
</if>
<if test='mmsi != null and mmsi != ""'>
and mmsi like '%'||#{mmsi}||'%'
</if>
<if test='napoPoint != null and napoPoint != ""'>
and (napo_sea_point_lon like '%'||#{napoPoint}||'%'
or napo_sea_point_lat like '%'||#{napoPoint}||'%'
or napo_sea_point_detail like '%'||#{napoPoint}||'%')
</if>
<if test='dateSelector == "napoDt"'>
<if test='startDate != null and startDate != ""'>
and napo_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and napo_dt &lt;= #{endDate}::date
</if>
</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
</if>
</if>
<choose>
<when test='accessAuth == "ACC003"'>
and case_agency in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</when>
<otherwise>
and case_agency = #{viewOrgan}
</otherwise>
</choose>
2023-06-05 09:25:02 +00:00
</sql>
<select id="selectIllegalShipInfoList" resultType="IllegalShipInfo" parameterType="UnlawfulFishingParam">
select fb_key,
a.cds_key ,
b.case_num ,
boat_name_kr,
permit_num,
nationality,
sailor_cnt,
ton_cnt,
fishery_type,
boat_material,
boat_nny_sung,
boat_nny_si,
a.wrt_organ ,
a.wrt_part ,
a.wrt_user_grd ,
a.wrt_user_nm ,
a.wrt_dt
from illegal_ship_info a
left outer join crackdown_info b on a.cds_key = b.cds_key
<include refid="selectIllegalShipInfoListWhere"></include>
order by a.wrt_dt desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectIllegalShipInfoListCnt" resultType="int" parameterType="UnlawfulFishingParam">
select count(*)
from illegal_ship_info a
left outer join crackdown_info b on a.cds_key = b.cds_key
<include refid="selectIllegalShipInfoListWhere"></include>
</select>
<sql id="selectIllegalShipInfoListWhere">
where a.status &lt;> 'DST008'
<if test='caseNum != null and caseNum != ""'>
and b.case_num like '%'||#{caseNum}||'%'
</if>
<if test='permitNum != null and permitNum != ""'>
and a.permit_num like '%'||#{permitNum}||'%'
</if>
<if test='boatNny != null and boatNny != ""'>
and (a.boat_nny_sung like '%'||#{boatNny}||'%' or a.boat_nny_si like '%'||#{boatNny}||'%')
</if>
<if test='boatName != null and boatName != ""'>
and (a.boat_name_kr like '%'||#{boatName}||'%' or a.boat_name_cn like '%'||#{boatName}||'%')
</if>
<if test='boatMaterial != null and boatMaterial != ""'>
and a.boat_material = #{boatMaterial}
</if>
<if test='fisheryType != null and fisheryType != ""'>
and a.fishery_type = #{fisheryType}
</if>
<choose>
<when test='dateSelector == "paymentDt"'>
<if test='startDate != null and startDate != ""'>
and a.payment_payment_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and a.payment_payment_dt &lt;= #{endDate}::date+1
</if>
</when>
<when test='dateSelector == "wrtDt"'>
<if test='startDate != null and startDate != ""'>
and a.wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and a.wrt_dt &lt;= #{endDate}::date+1
</if>
</when>
</choose>
<choose>
<when test='accessAuth == "ACC003"'>
and b.case_agency in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</when>
<otherwise>
and b.case_agency = #{viewOrgan}
</otherwise>
</choose>
</sql>
<select id="selectShipProcessInfoList" resultType="ShipProcessInfo" parameterType="UnlawfulFishingParam">
select a.pr_key,
c.case_num ,
b.boat_name_kr ,
c.napo_dt ,
a.process_status ,
a.is_ivsgt_stop ,
a.sentencing_court ,
a.sentencing_detail ,
a.wrt_organ ,
a.wrt_part ,
a.wrt_user_grd ,
a.wrt_user_nm ,
a.wrt_dt
from ship_process_info a
inner join illegal_ship_info b on a.fb_key = b.fb_key
inner join crackdown_info c on b.cds_key = c.cds_key
<include refid="selectShipProcessInfoListWhere"></include>
2023-07-14 09:01:57 +00:00
order by a.wrt_dt desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectShipProcessInfoListCnt" resultType="int" parameterType="UnlawfulFishingParam">
select count(*)
from ship_process_info a
inner join illegal_ship_info b on a.fb_key = b.fb_key
inner join crackdown_info c on b.cds_key = c.cds_key
<include refid="selectShipProcessInfoListWhere"></include>
</select>
<sql id="selectShipProcessInfoListWhere">
where a.status &lt;> 'DST008'
<if test='caseNum != null and caseNum != ""'>
and c.case_num like '%'||#{caseNum}||'%'
</if>
<if test='boatName != null and boatName != ""'>
and (b.boat_name_kr like '%'||#{boatName}||'%' or b.boat_name_cn like '%'||#{boatName}||'%')
</if>
<if test='processStatus != null and processStatus != ""'>
and a.process_status = #{processStatus}
</if>
<if test='isIvsgtStop != null and isIvsgtStop != ""'>
and a.is_ivsgt_stop = #{isIvsgtStop}
</if>
<if test='sentencingCourt != null and sentencingCourt != ""'>
and a.sentencing_court like '%'||#{sentencingCourt}||'%'
</if>
<if test='sentencingDetail != null and sentencingDetail != ""'>
and a.sentencing_detail like '%'||#{sentencingDetail}||'%'
</if>
<choose>
<when test='dateSelector == "napoDt"'>
<if test='startDate != null and startDate != ""'>
and c.napo_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and c.napo_dt &lt;= #{endDate}::date
</if>
</when>
<when test='dateSelector == "wrtDt"'>
<if test='startDate != null and startDate != ""'>
and a.wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and a.wrt_dt &lt;= #{endDate}::date+1
</if>
</when>
</choose>
<choose>
<when test='accessAuth == "ACC003"'>
and c.case_agency in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</when>
<otherwise>
and c.case_agency = #{viewOrgan}
</otherwise>
</choose>
</sql>
2023-07-12 09:24:17 +00:00
<select id="selectIllegalShipSailorList" resultType="IllegalShipSailor" parameterType="UnlawfulFishingParam">
select iss.sailor_key ,
isi.fb_key ,
isi.boat_name_kr ,
ci.case_num ,
iss.sailor_name_kr ,
iss.birthdate ,
iss.position ,
iss.career ,
iss.similar_criminal_history ,
iss.heterogeneous_criminal_history ,
iss.arrest_history ,
iss.wrt_organ ,
iss.wrt_part ,
iss.wrt_user_grd ,
iss.wrt_user_nm ,
iss.wrt_dt
from illegal_ship_sailor iss
inner join illegal_ship_info isi on iss.fb_key = isi.fb_key
inner join crackdown_info ci on isi.cds_key = ci.cds_key
<include refid="selectIllegalShipSailorListWhere"></include>
order by iss.wrt_dt desc
2023-07-14 09:01:57 +00:00
limit #{rowCnt} offset #{firstIndex}
2023-07-12 09:24:17 +00:00
</select>
<select id="selectIllegalShipSailorListCnt" resultType="int" parameterType="UnlawfulFishingParam">
select count(*)
from illegal_ship_sailor iss
inner join illegal_ship_info isi on iss.fb_key = isi.fb_key
inner join crackdown_info ci on isi.cds_key = ci.cds_key
<include refid="selectIllegalShipSailorListWhere"></include>
</select>
<sql id="selectIllegalShipSailorListWhere">
where iss.status &lt;> 'DST008'
<if test='caseNum != null and caseNum != ""'>
and ci.case_num like '%'||#{caseNum}||'%'
</if>
<if test='boatName != null and boatName != ""'>
and (isi.boat_name_kr like '%'||#{boatName}||'%'
or isi.boat_name_cn like '%'||#{boatName}||'%')
</if>
<if test='sailorName != null and sailorName != ""'>
and (iss.sailorName_kr like '%'||#{sailorName}||'%'
or iss.sailorName_cn like '%'||#{sailorName}||'%')
</if>
<if test='position != null and position != ""'>
and iss.position = #{position}
</if>
<if test='career != null and career != ""'>
and iss.career = #{career}
</if>
<if test='similarCriminalHistory != null and similarCriminalHistory != ""'>
and iss.similar_criminal_history = #{similarCriminalHistory}
</if>
<if test='heterogeneousCriminalHistory != null and heterogeneousCriminalHistory != ""'>
and iss.heterogeneous_criminal_history = #{heterogeneousCriminalHistory}
</if>
<if test='arrestHistory != null and arrestHistory != ""'>
and iss.arrest_history = #{arrestHistory}
</if>
<choose>
<when test='dateSelector == "birthdate"'>
<if test='startDate != null and startDate != ""'>
and iss.birthdate >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and iss.birthdate &lt;= #{endDate}::date
</if>
</when>
<when test='dateSelector == "wrtDt"'>
<if test='startDate != null and startDate != ""'>
and iss.wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and iss.wrt_dt &lt;= #{endDate}::date+1
</if>
</when>
</choose>
<choose>
<when test='accessAuth == "ACC003"'>
and ci.case_agency in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</when>
<otherwise>
and ci.case_agency = #{viewOrgan}
</otherwise>
</choose>
2023-07-12 09:24:17 +00:00
</sql>
2023-05-22 09:16:04 +00:00
</mapper>