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

237 lines
8.4 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.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>
<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>
</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
<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>
<if 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>
</if>
<if 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>
</if>
</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>
</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'
</sql>
<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>
</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'
</sql>
</mapper>