불법조업 외국어선 통계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,23 +381,31 @@
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
from crackdown_info a
inner join (select cds_key, count(*) as ship_cnt
from illegal_ship_info
where status &lt;> 'DST008'
group by cds_key) d on a.cds_key = d.cds_key
where a.status &lt;> 'DST008'
) aa
group by year) it
left outer join (
select year,
sum(violation_5_1) as violation_5_1,
sum(violation_5_2) as violation_5_2
from ( select a.cds_key ,
EXTRACT(YEAR FROM a.napo_dt) as year, EXTRACT(YEAR FROM a.napo_dt) as year,
case when b.violation = 'VT002' then ship_cnt else 0 end as violation_1,
case when b.violation = 'VT003' then ship_cnt else 0 end as violation_2_1,
case when b.violation = 'VT004' then ship_cnt else 0 end as violation_2_2,
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,
case when b.violation = 'VT001' then ship_cnt else 0 end as violation_4,
case when b.violation = 'VT028' then 1 else 0 end as violation_5_1, case when b.violation = 'VT028' then 1 else 0 end as violation_5_1,
case when b.violation = 'VT028' then ship_cnt else 0 end as violation_5_2 case when b.violation = 'VT028' then ship_cnt else 0 end as violation_5_2
from crackdown_info a from crackdown_info a
@ -408,9 +415,9 @@
where status &lt;> 'DST008' where status &lt;> 'DST008'
group by cds_key) d on a.cds_key = d.cds_key group by cds_key) d on a.cds_key = d.cds_key
where a.status &lt;> 'DST008' where a.status &lt;> 'DST008'
) vi ) aa
group by year group by year
) vt ) vt on it.year = vt.year
left outer join ( left outer join (
select EXTRACT(YEAR FROM a.napo_dt) as year, select EXTRACT(YEAR FROM a.napo_dt) as year,
sum(b.deposit_payment) as deposit_payment, sum(b.deposit_payment) as deposit_payment,