불법조업 외국어선 통계1 쿼리 수정.

master
강석 최 2023-09-14 13:12:28 +09:00
parent cda93a2819
commit c03c0dd5de
3 changed files with 90 additions and 85 deletions

View File

@ -21,8 +21,7 @@ public class CaptureStatistics {
private Integer captureCnt=0; private Integer captureCnt=0;
private Integer eezCnt=0; private Integer eezCnt=0;
private Integer violation1=0; private Integer violation1=0;
private Integer violation21=0; private Integer violation2=0;
private Integer violation22=0;
private Integer violation3=0; private Integer violation3=0;
private Integer violation4=0; private Integer violation4=0;
private Integer violation51=0; private Integer violation51=0;

View File

@ -305,13 +305,12 @@ public class UnlawfulFishingService {
total.setYearStr("총계"); total.setYearStr("총계");
for(CaptureStatistics stat: temp){ for(CaptureStatistics stat: temp){
stat.setYearStr(stat.getYear().toString().substring(2)+"년"); stat.setYearStr(stat.getYear().toString().substring(2)+"년");
stat.setEezCnt(stat.getViolation1()+stat.getViolation21()+stat.getViolation22()+stat.getViolation3()); stat.setEezCnt(stat.getViolation1()+stat.getViolation2()+stat.getViolation3());
stat.setCaptureCnt(stat.getEezCnt()+stat.getViolation4()); stat.setCaptureCnt(stat.getEezCnt()+stat.getViolation4());
total.setCaptureCnt(total.getCaptureCnt()+stat.getCaptureCnt()); total.setCaptureCnt(total.getCaptureCnt()+stat.getCaptureCnt());
total.setEezCnt(total.getEezCnt()+stat.getEezCnt()); total.setEezCnt(total.getEezCnt()+stat.getEezCnt());
total.setViolation1(total.getViolation1()+stat.getViolation1()); total.setViolation1(total.getViolation1()+stat.getViolation1());
total.setViolation21(total.getViolation21()+stat.getViolation21()); total.setViolation2(total.getViolation2()+stat.getViolation2());
total.setViolation22(total.getViolation22()+stat.getViolation22());
total.setViolation3(total.getViolation3()+stat.getViolation3()); total.setViolation3(total.getViolation3()+stat.getViolation3());
total.setViolation4(total.getViolation4()+stat.getViolation4()); total.setViolation4(total.getViolation4()+stat.getViolation4());
total.setViolation51(total.getViolation51()+stat.getViolation51()); total.setViolation51(total.getViolation51()+stat.getViolation51());

View File

@ -367,14 +367,13 @@
</sql> </sql>
<select id="selectStatisticsListType1" parameterType="StatisticsParam" resultType="CaptureStatistics"> <select id="selectStatisticsListType1" parameterType="StatisticsParam" resultType="CaptureStatistics">
select vt.year, select it.year,
violation_1, it.violation_1,
violation_2_1, it.violation_2,
violation_2_2, it.violation_3,
violation_3, it.violation_4,
violation_4, vt.violation_5_1,
violation_5_1, vt.violation_5_2,
violation_5_2,
deposit_unpaid, deposit_unpaid,
deposit_payment, deposit_payment,
detention_cnt, detention_cnt,
@ -382,78 +381,86 @@
forfeit_cnt, forfeit_cnt,
dispose_cnt, dispose_cnt,
etc etc
from ( from ( select year,
select year, sum(violation_1) as violation_1,
sum(violation_1) as violation_1, --무허가조업 sum(violation_2) as violation_2,
sum(violation_2_1) as violation_2_1, --무허가조업(특정금지) sum(violation_3) as violation_3,
sum(violation_2_2) as violation_2_2, -- 정선명령불응(특정금지) sum(violation_4) as violation_4
sum(violation_3) as violation_3, -- 제한조건위반 from ( select a.cds_key ,
sum(violation_4) as violation_4, -- 영해침범 EXTRACT(YEAR FROM a.napo_dt) as year,
sum(violation_5_1) as violation_5_1, -- 공무집행방해(건) case when a.invasion_type = 'IST001' then ship_cnt else 0 end as violation_1,
sum(violation_5_2) as violation_5_2 -- 공무집행방해(척) case when a.invasion_type = 'IST002' then ship_cnt else 0 end as violation_2,
from ( case when a.invasion_type = 'IST003' then ship_cnt else 0 end as violation_3,
select a.cds_key , case when a.invasion_type = 'IST004' then ship_cnt else 0 end as violation_4
EXTRACT(YEAR FROM a.napo_dt) as year, from crackdown_info a
case when b.violation = 'VT002' then ship_cnt else 0 end as violation_1, inner join (select cds_key, count(*) as ship_cnt
case when b.violation = 'VT003' then ship_cnt else 0 end as violation_2_1, from illegal_ship_info
case when b.violation = 'VT004' then ship_cnt else 0 end as violation_2_2, where status &lt;> 'DST008'
case when substring(b.violation, 3, 3)::int >= 7 and substring(b.violation, 3, 3)::int &lt;= 26 then ship_cnt else 0 end as violation_3, group by cds_key) d on a.cds_key = d.cds_key
case when b.violation = 'VT001' then ship_cnt else 0 end as violation_4, where a.status &lt;> 'DST008'
case when b.violation = 'VT028' then 1 else 0 end as violation_5_1, ) aa
case when b.violation = 'VT028' then ship_cnt else 0 end as violation_5_2 group by year) it
from crackdown_info a left outer join (
inner join violation_info b on a.cds_key = b.cds_key select year,
inner join (select cds_key, count(*) as ship_cnt sum(violation_5_1) as violation_5_1,
from illegal_ship_info sum(violation_5_2) as violation_5_2
where status &lt;> 'DST008' from ( select a.cds_key ,
group by cds_key) d on a.cds_key = d.cds_key EXTRACT(YEAR FROM a.napo_dt) as year,
where a.status &lt;> 'DST008' case when b.violation = 'VT028' then 1 else 0 end as violation_5_1,
) vi case when b.violation = 'VT028' then ship_cnt else 0 end as violation_5_2
group by year from crackdown_info a
) vt inner join violation_info b on a.cds_key = b.cds_key
left outer join ( inner join (select cds_key, count(*) as ship_cnt
select EXTRACT(YEAR FROM a.napo_dt) as year, from illegal_ship_info
sum(b.deposit_payment) as deposit_payment, where status &lt;> 'DST008'
sum(b.deposit_unpaid) as deposit_unpaid group by cds_key) d on a.cds_key = d.cds_key
from crackdown_info a where a.status &lt;> 'DST008'
inner join ( ) aa
select cds_key, sum(deposit_payment) as deposit_payment, sum(deposit_unpaid) as deposit_unpaid group by year
from illegal_ship_info ) vt on it.year = vt.year
where status &lt;> 'DST008' left outer join (
group by cds_key select EXTRACT(YEAR FROM a.napo_dt) as year,
) b on a.cds_key = b.cds_key sum(b.deposit_payment) as deposit_payment,
where a.status &lt;> 'DST008' sum(b.deposit_unpaid) as deposit_unpaid
group by year from crackdown_info a
) dps on vt.year = dps.year inner join (
left outer join ( select cds_key, sum(deposit_payment) as deposit_payment, sum(deposit_unpaid) as deposit_unpaid
select year, from illegal_ship_info
sum(detention_cnt) as detention_cnt, where status &lt;> 'DST008'
sum(detention_not_cnt) as detention_not_cnt group by cds_key
from ( ) b on a.cds_key = b.cds_key
select EXTRACT(YEAR FROM a.napo_dt) as year, where a.status &lt;> 'DST008'
case when is_restriction = 'Y' then 1 else 0 end as detention_cnt, group by year
case when is_restriction = 'N' then 1 else 0 end as detention_not_cnt ) dps on vt.year = dps.year
from crackdown_info a left outer join (
inner join illegal_ship_info b on a.cds_key = b.cds_key and b.status &lt;> 'DST008' select year,
inner join illegal_ship_sailor c on b.fb_key = c.fb_key and c.status &lt;> 'DST008' sum(detention_cnt) as detention_cnt,
) a sum(detention_not_cnt) as detention_not_cnt
group by year from (
) si on vt.year = si.year select EXTRACT(YEAR FROM a.napo_dt) as year,
left outer join ( case when is_restriction = 'Y' then 1 else 0 end as detention_cnt,
select year, case when is_restriction = 'N' then 1 else 0 end as detention_not_cnt
sum(forfeit_cnt) as forfeit_cnt, from crackdown_info a
sum(dispose_cnt) as dispose_cnt inner join illegal_ship_info b on a.cds_key = b.cds_key and b.status &lt;> 'DST008'
from ( inner join illegal_ship_sailor c on b.fb_key = c.fb_key and c.status &lt;> 'DST008'
select EXTRACT(YEAR FROM a.napo_dt) as year, ) a
case when c.process_status = 'PR002' or c.process_status = 'PR003' then 1 else 0 end as forfeit_cnt, group by year
case when c.process_status = 'PR005' or c.process_status = 'PR006' then 1 else 0 end as dispose_cnt ) si on vt.year = si.year
from crackdown_info a left outer join (
inner join illegal_ship_info b on a.cds_key = b.cds_key and b.status &lt;> 'DST008' select year,
inner join ship_process_info c on b.fb_key = c.fb_key and c.status &lt;> 'DST008' sum(forfeit_cnt) as forfeit_cnt,
) sp sum(dispose_cnt) as dispose_cnt
group by year from (
) sp on sp.year = vt.year select EXTRACT(YEAR FROM a.napo_dt) as year,
left outer join ship_statistics_etc etc on vt.year = etc.year case when c.process_status = 'PR002' or c.process_status = 'PR003' then 1 else 0 end as forfeit_cnt,
case when c.process_status = 'PR005' or c.process_status = 'PR006' then 1 else 0 end as dispose_cnt
from crackdown_info a
inner join illegal_ship_info b on a.cds_key = b.cds_key and b.status &lt;> 'DST008'
inner join ship_process_info c on b.fb_key = c.fb_key and c.status &lt;> 'DST008'
) sp
group by year
) sp on sp.year = vt.year
left outer join ship_statistics_etc etc on vt.year = etc.year
where vt.year &lt;= ${year} and vt.year >= ${year}-5 where vt.year &lt;= ${year} and vt.year >= ${year}-5
order by year desc order by year desc
</select> </select>