2022-12-22 01:55:19 +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.crackdownsStatus.mapper.CrackdownStatusMapper" >
<sql id= "selectCrackdownStatusListWhere" >
<where >
<if test= 'year != null and year != ""' >
And EXTRACT(YEAR FROM pr.wrt_dt) = #{year}::NUMERIC
</if>
<if test= 'month != null and month != ""' >
And EXTRACT(MONTH FROM pr.wrt_dt) = #{month}::NUMERIC
</if>
<if test= 'caseNum != null and caseNum != ""' >
2023-01-10 09:35:52 +00:00
AND case_num = #{caseNum}
2022-12-22 01:55:19 +00:00
</if>
<if test= 'nll != null and nll != ""' >
AND nll = #{nll}
</if>
<if test= 'napoDate != null' >
AND napo_dt::DATE = #{napoDate}::DATE
</if>
<if test= 'violation != null and violation != ""' >
AND violation = #{violation}
</if>
<if test= 'invasionType != null and invasionType != ""' >
AND invasion_type = #{invasionType}
</if>
<if test= 'napoSeaPointDetail != null and napoSeaPointDetail != ""' >
AND (
napo_sea_point_detail LIKE CONCAT('%', #{napoSeaPointDetail}, '%')
OR napo_sea_point_lon LIKE CONCAT('%', #{napoSeaPointDetail}, '%')
OR napo_sea_point_lat LIKE CONCAT('%', #{napoSeaPointDetail}, '%')
)
</if>
<if test= 'obstrExspdCnt != null and obstrExspdCnt != ""' >
AND obstr_exspd_cnt = #{obstrExspdCnt}
</if>
<if test= 'personDamageCnt != null and personDamageCnt != ""' >
AND person_damage_cnt = #{personDamageCnt}
</if>
<if test= 'personDamageAmount != null and personDamageAmount != ""' >
AND person_damage_amount = #{personDamageAmount}
</if>
<if test= 'personDamageDetail != null and personDamageDetail != ""' >
AND person_damage_detail LIKE CONCAT('%', #{personDamageDetail}, '%')
</if>
<if test= 'materialDamageCnt != null and materialDamageCnt != ""' >
AND material_damage_cnt = #{materialDamageCnt}
</if>
<if test= 'materialDamageAmount != null and materialDamageAmount != ""' >
AND material_damage_amount = #{materialDamageAmount}
</if>
<if test= 'materialDamageDetail != null and materialDamageDetail != ""' >
AND material_damage_detail LIKE CONCAT('%', #{materialDamageDetail}, '%')
</if>
<if test= 'caseAgency != null and caseAgency != ""' >
AND case_agency = #{caseAgency}
</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= 'mmsi != null and mmsi != ""' >
AND mmsi LIKE CONCAT('%', #{mmsi}, '%')
</if>
<if test= 'boatNameKr != null and boatNameKr != ""' >
AND boat_name_kr LIKE CONCAT('%', #{boatNameKr}, '%')
</if>
<if test= 'tonStartCnt != null and tonStartCnt != ""' >
AND ton_cnt <![CDATA[>=]]> #{tonStartCnt}
</if>
<if test= 'tonEndCnt != null and tonEndCnt != ""' >
AND ton_cnt <![CDATA[<=]]> #{tonEndCnt}
</if>
<if test= 'boatMaterial != null and boatMaterial != ""' >
AND boat_material = #{boatMaterial}
</if>
<if test= 'boatNnySung != null and boatNnySung != ""' >
AND boat_nny_sung LIKE CONCAT('%', #{boatNnySung}, '%')
</if>
<if test= 'boatNnySi != null and boatNnySi != ""' >
AND boat_nny_si LIKE CONCAT('%', #{boatNnySi}, '%')
</if>
<if test= 'sailorNameKr != null and sailorNameKr != ""' >
AND sailor_name_kr LIKE CONCAT('%', #{sailorNameKr}, '%')
</if>
<if test= 'fisheryType != null and fisheryType != ""' >
AND fishery_type = #{fisheryType}
</if>
<if test= 'catchFishSpecies != null and catchFishSpecies != ""' >
AND catch_fish_species LIKE CONCAT('%', #{catchFishSpecies}, '%')
</if>
<if test= 'catchCnt != null and catchCnt != ""' >
AND catch_cnt = #{catchCnt}
</if>
<if test= 'offenseFishSpecies != null and offenseFishSpecies != ""' >
AND offense_fish_species LIKE CONCAT('%', #{offenseFishSpecies}, '%')
</if>
<if test= 'offenseCatchCnt != null and offenseCatchCnt != ""' >
AND offense_catch_cnt = #{offenseCatchCnt}
</if>
<if test= 'offenseIllegalWasteQuantity != null and offenseIllegalWasteQuantity != ""' >
AND offense_illegal_waste_quantity = #{offenseIllegalWasteQuantity}
</if>
<if test= 'offenseQuantity != null and offenseQuantity != ""' >
AND offense_quantity = #{offenseQuantity}
</if>
<if test= 'offenseAmount != null and offenseAmount != ""' >
AND offense_amount = #{offenseAmount}
</if>
<if test= 'processStatus != null and processStatus != ""' >
AND process_status = #{processStatus}
</if>
<if test= 'damboPayment != null and damboPayment != ""' >
AND dambo_payment = #{damboPayment}
</if>
<if test= 'paymentPaymentDate != null' >
AND payment_payment_dt::DATE = #{paymentPaymentDate}::DATE
</if>
<if test= 'damboUnpaidAmount != null and damboUnpaidAmount != ""' >
AND dambo_unpaid_amount = #{damboUnpaidAmount}
</if>
<if test= 'isDamboUnpaidAmount != null and isDamboUnpaidAmount != ""' >
<if test= 'isDamboUnpaidAmount == "Y"' >
AND (
dambo_unpaid_amount IS NOT NULL
AND dambo_unpaid_amount > 0
)
</if>
<if test= 'isDamboUnpaidAmount == "N"' >
AND (
direct_handover_dt IS NULL
OR dambo_unpaid_amount = 0
)
</if>
</if>
<if test= 'isDirectHandoverDt != null and isDirectHandoverDt != ""' >
<if test= 'isDirectHandoverDt == "Y"' >
AND direct_handover_dt IS NOT NULL
</if>
<if test= 'isDirectHandoverDt == "N"' >
AND direct_handover_dt IS NULL
</if>
</if>
<!-- <if test='evictionDt != null'>
AND eviction_dt = #{evictionDt}::DATE
</if> -->
<if test= 'isEvictionDt != null and isEvictionDt != ""' >
<if test= 'isEvictionDt == "Y"' >
AND eviction_dt IS NOT NULL
</if>
<if test= 'isEvictionDt == "N"' >
AND eviction_dt IS NULL
</if>
</if>
<!-- <if test='returnDt != null'>
AND return_dt = #{returnDt}::DATE
</if> -->
<if test= 'isReturnDt != null and isReturnDt != ""' >
<if test= 'isReturnDt == "Y"' >
AND return_dt IS NOT NULL
</if>
<if test= 'isReturnDt == "N"' >
AND return_dt IS NULL
</if>
</if>
<if test= 'consignmentStartDate != null' >
AND consignment_start_dt = #{consignmentStartDate}::DATE
</if>
<if test= 'consignmentEndDate != null' >
AND consignment_end_dt = #{consignmentEndDate}::DATE
</if>
<!-- <if test='confiscationDt != null'>
AND confiscation_dt = #{confiscationDt}::DATE
</if> -->
<if test= 'isConfiscationDt != null and isConfiscationDt != ""' >
<if test= 'isConfiscationDt == "Y"' >
AND confiscation_dt IS NOT NULL
</if>
<if test= 'isConfiscationDt == "N"' >
AND confiscation_dt IS NULL
</if>
</if>
<if test= 'isConsignmentStartDt != null and isConsignmentStartDt != ""' >
<if test= 'isConsignmentStartDt == "Y"' >
AND consignment_start_dt IS NOT NULL
</if>
<if test= 'isConsignmentStartDt == "N"' >
AND consignment_start_dt IS NULL
</if>
</if>
<!-- <if test='isBoatDisposal != null'>
AND boat_disposal_dt = #{boatDisposalDt}::DATE
</if> -->
<if test= 'boatDisposalType != null and boatDisposalType != ""' >
AND boat_disposal_type = #{boatDisposalType}
</if>
<if test= 'directHandoverDate != null' >
AND direct_handover_dt::DATE = #{directHandoverDate}::DATE
</if>
<if test= 'handoverSeaPointDetail != null and handoverSeaPointDetail != ""' >
AND (
handover_sea_point_lat LIKE CONCAT('%', #{handoverSeaPointDetail}, '%')
OR handover_sea_point_lon LIKE CONCAT('%', #{handoverSeaPointDetail}, '%')
OR handover_sea_point_detail LIKE CONCAT('%', #{handoverSeaPointDetail}, '%')
)
</if>
<if test= 'handoverBoat != null and handoverBoat != ""' >
AND handover_boat LIKE CONCAT('%', #{handoverBoat}, '%')
</if>
<if test= 'middleTakeoverBoat != null and middleTakeoverBoat != ""' >
AND middle_takeover_boat LIKE CONCAT('%', #{middleTakeoverBoat}, '%')
</if>
<if test= 'captin != null and captin != ""' >
AND (
position = 'POS001'
AND is_restriction = #{captin}
)
</if>
<if test= 'mate != null and mate != ""' >
AND (
position = 'POS002'
AND is_restriction = #{mate}
)
</if>
<if test= 'warden != null and warden != ""' >
AND (
position = 'POS003'
AND is_restriction = #{warden}
)
</if>
<if test= 'fieldIvsgtNapoDate != null' >
AND field_ivsgt_napo_dt::DATE = #{fieldIvsgtNapoDate}::DATE
</if>
<if test= 'fieldIvsgtReleaseDate != null' >
AND field_ivsgt_release_dt::DATE = #{fieldIvsgtReleaseDate}::DATE
</if>
<!-- <if test='pressurizedStartDt != null'>
AND pressurizedStartDt = #{pressurizedStartDt}::DATE
</if>
<if test= 'pressurizedEndDt != null' >
AND pressurizedEndDt = #{pressurizedEndDt}::DATE
</if> -->
<if test= 'distance != null and distance != ""' >
AND distance = #{distance}
</if>
<if test= 'confiscationFrame != null and confiscationFrame != ""' >
AND confiscation_frame = #{confiscationFrame}
</if>
<if test= 'confiscationWidth != null and confiscationWidth != ""' >
AND confiscation_width = #{confiscationWidth}
</if>
<if test= 'confiscationJo != null and confiscationJo != ""' >
AND confiscation_jo = #{confiscationJo}
</if>
<if test= 'confiscationGae != null and confiscationGae != ""' >
AND confiscation_gae = #{confiscationGae}
</if>
<if test= 'confiscationEtc != null and confiscationEtc != ""' >
AND confiscation_etc = #{confiscationEtc}
</if>
</where>
</sql>
<select id= "selectCrackdownStatusList" resultType= "CrackdownStatus" parameterType= "CrackdownStatus" >
SELECT DISTINCT
cs.cds_key
, cs.case_num
, cs.napo_dt
, cs.napo_sea_point_lon
, cs.napo_sea_point_lat
, cs.napo_sea_point_detail
, cs.invasion_type
, cs.nll
, cs.case_agency
, cs.case_police_officer
, cs.crackdown_boat
, cs.crackdown_police
, cs.mmsi
, cs.field_ivsgt
, cs.obstr_exspd_cnt
, cs.person_damage_cnt
, cs.person_damage_amount
, cs.person_damage_detail
, cs.material_damage_cnt
, cs.material_damage_amount
, cs.material_damage_detail
, cs.field_ivsgt_napo_dt
, cs.field_ivsgt_release_dt
, cs.field_ivsgt_time_taken
, cs.pressurized_start_dt
, cs.pressurized_end_dt
, cs.distance
, cs.wrt_organ
, cs.wrt_user_seq
, cs.wrt_user_nm
, cs.wrt_dt
, fb.fb_key
, fb.boat_name_kr
, fb.boat_name_cn
, fb.ton_cnt
, fb.fishery_type
, fb.boat_material
, fb.boat_nny_sung
, fb.boat_nny_si
, fb.offense_quantity
, fb.offense_amount
, fb.offense_illegal_waste_quantity
, fb.dambo_unpaid_amount
, fb.dambo_payment
, fb.payment_payment_dt
, fb.confiscation_frame
, fb.confiscation_width
, fb.confiscation_jo
, fb.confiscation_gae
, fb.confiscation_etc
, fb.catch_fish_species
, fb.catch_cnt
, fb.offense_fish_species
, fb.offense_catch_cnt
2023-01-13 02:02:37 +00:00
, fb.status
2022-12-22 01:55:19 +00:00
, pr.pr_key
, pr.process_status
, pr.eviction_dt
, pr.direct_handover_dt
, pr.handover_sea_point_lon
, pr.handover_sea_point_lat
, pr.handover_sea_point_detail
, pr.handover_boat
, pr.middle_takeover_boat
, pr.consignment_start_dt
, pr.consignment_end_dt
, pr.confiscation_dt
, pr.boat_disposal_dt
, pr.boat_disposal_type
, pr.return_dt
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.is_restriction = 'Y' AND s.position != 'POS004') AS restrictionTotal
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.is_restriction = 'N' AND s.position != 'POS004') AS notRestrictionTotal
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.position = 'POS001' AND s.is_restriction = 'Y') AS restrictionCaptin
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.position = 'POS001' AND s.is_restriction = 'N') AS notRestrictionCaptin
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.position = 'POS002' AND s.is_restriction = 'Y') AS restrictionMate
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.position = 'POS003' AND s.is_restriction = 'Y') AS restrictionWarden
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.position = 'POS002' AND s.is_restriction = 'N') AS notRestrictionMate
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.position = 'POS003' AND s.is_restriction = 'N') AS notRestrictionWarden
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.is_restriction = 'Y' AND (s.position = 'POS005' or s."position" = 'POS006')) AS restrictionSailor
, (SELECT count(*) FROM sailor s WHERE s.fb_key = fb.fb_key AND s.is_restriction = 'N' AND (s.position = 'POS005' or s."position" = 'POS006')) AS notRestrictionSailor
FROM crackdown_status cs
INNER JOIN fishing_boat fb
ON cs.cds_key = fb.cds_key
INNER JOIN process_result pr
ON cs.cds_key = pr.cds_key
LEFT JOIN sailor s
ON fb.fb_key = s.fb_key
LEFT JOIN violation v
ON fb.fb_key = v.fb_key
<include refid= "selectCrackdownStatusListWhere" > </include>
ORDER BY cs.cds_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
</select>
<select id= "selectCrackdownStatusListCnt" resultType= "int" parameterType= "CrackdownStatus" >
SELECT count(*)
FROM crackdown_status cs
INNER JOIN fishing_boat fb
ON cs.cds_key = fb.cds_key
INNER JOIN process_result pr
ON cs.cds_key = pr.cds_key
<include refid= "selectCrackdownStatusListWhere" > </include>
</select>
<sql id= "selectFishingBoatListWhere" >
<where >
2023-01-31 04:42:13 +00:00
<if test= "year != null and year != 0" >
and extract(year from a.napo_dt) = ${year}
</if>
<if test= "caseAgency != null and caseAgency != ''" >
and a.case_agency = #{caseAgency}
</if>
<if test= "crackdownPolice != null and crackdownPolice != ''" >
and a.crackdown_police = #{crackdownPolice}
</if>
<if test= "crackdownBoat != null and crackdownBoat != ''" >
and a.crackdown_boat = #{crackdownBoat}
</if>
<if test= "boatNameKr != null and boatNameKr != ''" >
and b.boat_name_kr like '%'||#{boatNameKr}||'%'
</if>
<if test= "boatNnySung != null and boatNnySung != ''" >
and b.boat_nny_sung like '%'||#{boatNnySung}||'%'
</if>
<if test= "boatNnySi != null and boatNnySi != ''" >
and b.boat_nny_si like '%'||#{boatNnySi}||'%'
</if>
<if test= "boatMaterial != null and boatMaterial != ''" >
and b.boat_material = #{boatMaterial}
</if>
<if test= "fisheryType != null and fisheryType != ''" >
and b.fishery_type = #{fisheryType}
</if>
<if test= "processStatus != null and processStatus != ''" >
and c.process_status = #{processStatus}
</if>
<if test= "tonMin != null and tonMin > 0" >
and b.ton_cnt >= #{tonMin}
</if>
<if test= "tonMax != null and tonMax > 0" >
and b.ton_cnt < = #{tonMax}
</if>
<if test= 'violationList != null' >
and
<foreach collection= "violationList" item= "violation" index= "index" separator= " or " open= "(" close= ")" >
e.violationCode like '%'||#{violation}||'%'
</foreach>
</if>
<choose >
<when test= 'dateSelector == "napoDt"' >
<if test= 'startDate != null' >
and a.napo_dt >= #{startDate}::date
</if>
<if test= 'endDate != null' >
and a.napo_dt < = #{endDate}::date+1
</if>
</when>
<when test= 'dateSelector == "evictionDt"' >
<if test= 'startDate != null' >
and c.eviction_dt >= #{startDate}::date
</if>
<if test= 'endDate != null' >
and c.eviction_dt < = #{endDate}::date+1
</if>
</when>
<when test= 'dateSelector == "directHandoverDt"' >
<if test= 'startDate != null' >
and c.direct_handover_dt >= #{startDate}::date
</if>
<if test= 'endDate != null' >
and c.direct_handover_dt < = #{endDate}::date+1
</if>
</when>
<when test= 'dateSelector == "consignmentDt"' >
<if test= 'startDate != null' >
and c.consignment_dt >= #{startDate}::date
</if>
<if test= 'endDate != null' >
and c.consignment_dt < = #{endDate}::date+1
</if>
</when>
<when test= 'dateSelector == "confiscationDt"' >
<if test= 'startDate != null' >
and c.confiscation_dt >= #{startDate}::date
</if>
<if test= 'endDate != null' >
and c.confiscation_dt < = #{endDate}::date+1
</if>
</when>
<when test= 'dateSelector == "boatDisposalDt"' >
<if test= 'startDate != null' >
and c.boat_disposal_dt >= #{startDate}::date
</if>
<if test= 'endDate != null' >
and c.boat_disposal_dt < = #{endDate}::date+1
</if>
</when>
<when test= 'dateSelector == "returnDt"' >
<if test= 'startDate != null' >
and c.return_dt >= #{startDate}::date
</if>
<if test= 'endDate != null' >
and c.return_dt < = #{endDate}::date+1
</if>
</when>
<when test= 'dateSelector == "wrtDt"' >
<if test= 'startDate != null' >
and a.wrt_dt >= #{startDate}::date
</if>
<if test= 'endDate != null' >
and a.wrt_dt < = #{endDate}::date+1
</if>
</when>
</choose>
2022-12-22 01:55:19 +00:00
</where>
</sql>
2023-01-31 04:42:13 +00:00
<select id= "selectFishingBoatList" resultType= "CrackdownStatus" parameterType= "UnlawfulFishingParam" >
2022-12-22 01:55:19 +00:00
select a.cds_key,
a.napo_dt,
a.napo_sea_point_lon,
a.napo_sea_point_lat,
a.napo_sea_point_detail,
a.case_agency,
a.crackdown_police,
a.crackdown_boat,
b.boat_name_kr,
b.fishery_type,
b.boat_nny_sung,
b.boat_nny_si,
b.ton_cnt,
b.boat_material,
b.wrt_organ,
b.wrt_user_grd,
b.wrt_user_nm,
b.wrt_dt,
c.process_status,
d.sailor_name_kr,
e.violationStr
from crackdown_status a
inner join fishing_boat b
on a.cds_key = b.cds_key
inner join process_result c
on a.cds_key = c.cds_key
left outer join sailor d
on b.fb_key = d.fb_key and d.position = 'POS001'
left outer join (
2023-01-31 04:42:13 +00:00
select aa.fb_key,
array_to_string(array_agg(ab.item_value), ', ') as violationStr,
array_to_string(array_agg(ab.item_cd), ', ') as violationCode
2022-12-22 01:55:19 +00:00
from violation aa
inner join code_mgt ab
on aa.violation = ab.item_cd
group by aa.fb_key
) e on b.fb_key = e.fb_key
<include refid= "selectFishingBoatListWhere" > </include>
order by a.cds_key desc
limit #{rowCnt} offset #{firstIndex}
</select>
2023-01-31 04:42:13 +00:00
<select id= "selectFishingBoatListCnt" resultType= "int" parameterType= "UnlawfulFishingParam" >
2022-12-22 01:55:19 +00:00
select count(*)
from crackdown_status a
inner join fishing_boat b
on a.cds_key = b.cds_key
inner join process_result c
on a.cds_key = c.cds_key
left outer join sailor d
on b.fb_key = d.fb_key and d.position = 'POS001'
2023-01-31 04:42:13 +00:00
left outer join (
select aa.fb_key,
array_to_string(array_agg(ab.item_value), ', ') as violationStr,
array_to_string(array_agg(ab.item_cd), ', ') as violationCode
from violation aa
inner join code_mgt ab
on aa.violation = ab.item_cd
group by aa.fb_key
) e on b.fb_key = e.fb_key
2022-12-22 01:55:19 +00:00
<include refid= "selectFishingBoatListWhere" > </include>
</select>
2023-01-31 04:42:13 +00:00
<select id= "selectFishingBoatYearParam" resultType= "int" parameterType= "UnlawfulFishingParam" >
select distinct extract(year from napo_dt) as year
from crackdown_status
where napo_dt is not null
</select>
2023-01-19 02:45:31 +00:00
<select id= "selectCrackdownStatusVersionList" resultType= "CrackdownStatusVersion" parameterType= "int" >
select cds_key,
2022-12-22 01:55:19 +00:00
version_no,
wrt_organ,
wrt_part,
wrt_user_grd,
wrt_user_nm,
wrt_dt
2023-01-19 02:45:31 +00:00
from crackdown_status_version
where cds_key = #{cds_key}
2022-12-22 01:55:19 +00:00
order by version_no desc
</select>
</mapper>