불법조업 외국어선 통계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 eezCnt=0;
private Integer violation1=0;
private Integer violation21=0;
private Integer violation22=0;
private Integer violation2=0;
private Integer violation3=0;
private Integer violation4=0;
private Integer violation51=0;

View File

@ -305,13 +305,12 @@ public class UnlawfulFishingService {
total.setYearStr("총계");
for(CaptureStatistics stat: temp){
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());
total.setCaptureCnt(total.getCaptureCnt()+stat.getCaptureCnt());
total.setEezCnt(total.getEezCnt()+stat.getEezCnt());
total.setViolation1(total.getViolation1()+stat.getViolation1());
total.setViolation21(total.getViolation21()+stat.getViolation21());
total.setViolation22(total.getViolation22()+stat.getViolation22());
total.setViolation2(total.getViolation2()+stat.getViolation2());
total.setViolation3(total.getViolation3()+stat.getViolation3());
total.setViolation4(total.getViolation4()+stat.getViolation4());
total.setViolation51(total.getViolation51()+stat.getViolation51());

View File

@ -367,14 +367,13 @@
</sql>
<select id="selectStatisticsListType1" parameterType="StatisticsParam" resultType="CaptureStatistics">
select vt.year,
violation_1,
violation_2_1,
violation_2_2,
violation_3,
violation_4,
violation_5_1,
violation_5_2,
select it.year,
it.violation_1,
it.violation_2,
it.violation_3,
it.violation_4,
vt.violation_5_1,
vt.violation_5_2,
deposit_unpaid,
deposit_payment,
detention_cnt,
@ -382,78 +381,86 @@
forfeit_cnt,
dispose_cnt,
etc
from (
select year,
sum(violation_1) as violation_1, --무허가조업
sum(violation_2_1) as violation_2_1, --무허가조업(특정금지)
sum(violation_2_2) as violation_2_2, -- 정선명령불응(특정금지)
sum(violation_3) as violation_3, -- 제한조건위반
sum(violation_4) as violation_4, -- 영해침범
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,
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 ship_cnt else 0 end as violation_5_2
from crackdown_info a
inner join violation_info b on a.cds_key = b.cds_key
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'
) vi
group by year
) vt
left outer join (
select EXTRACT(YEAR FROM a.napo_dt) as year,
sum(b.deposit_payment) as deposit_payment,
sum(b.deposit_unpaid) as deposit_unpaid
from crackdown_info a
inner join (
select cds_key, sum(deposit_payment) as deposit_payment, sum(deposit_unpaid) as deposit_unpaid
from illegal_ship_info
where status &lt;> 'DST008'
group by cds_key
) b on a.cds_key = b.cds_key
where a.status &lt;> 'DST008'
group by year
) dps on vt.year = dps.year
left outer join (
select year,
sum(detention_cnt) as detention_cnt,
sum(detention_not_cnt) as detention_not_cnt
from (
select EXTRACT(YEAR FROM a.napo_dt) as year,
case when is_restriction = 'Y' then 1 else 0 end as detention_cnt,
case when is_restriction = 'N' then 1 else 0 end as detention_not_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 illegal_ship_sailor c on b.fb_key = c.fb_key and c.status &lt;> 'DST008'
) a
group by year
) si on vt.year = si.year
left outer join (
select year,
sum(forfeit_cnt) as forfeit_cnt,
sum(dispose_cnt) as dispose_cnt
from (
select EXTRACT(YEAR FROM a.napo_dt) as 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
from ( select year,
sum(violation_1) as violation_1,
sum(violation_2) as violation_2,
sum(violation_3) as violation_3,
sum(violation_4) as violation_4
from ( select a.cds_key ,
EXTRACT(YEAR FROM a.napo_dt) as year,
case when a.invasion_type = 'IST001' then ship_cnt else 0 end as violation_1,
case when a.invasion_type = 'IST002' then ship_cnt else 0 end as violation_2,
case when a.invasion_type = 'IST003' then ship_cnt else 0 end as violation_3,
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,
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
from crackdown_info a
inner join violation_info b on a.cds_key = b.cds_key
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
) vt on it.year = vt.year
left outer join (
select EXTRACT(YEAR FROM a.napo_dt) as year,
sum(b.deposit_payment) as deposit_payment,
sum(b.deposit_unpaid) as deposit_unpaid
from crackdown_info a
inner join (
select cds_key, sum(deposit_payment) as deposit_payment, sum(deposit_unpaid) as deposit_unpaid
from illegal_ship_info
where status &lt;> 'DST008'
group by cds_key
) b on a.cds_key = b.cds_key
where a.status &lt;> 'DST008'
group by year
) dps on vt.year = dps.year
left outer join (
select year,
sum(detention_cnt) as detention_cnt,
sum(detention_not_cnt) as detention_not_cnt
from (
select EXTRACT(YEAR FROM a.napo_dt) as year,
case when is_restriction = 'Y' then 1 else 0 end as detention_cnt,
case when is_restriction = 'N' then 1 else 0 end as detention_not_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 illegal_ship_sailor c on b.fb_key = c.fb_key and c.status &lt;> 'DST008'
) a
group by year
) si on vt.year = si.year
left outer join (
select year,
sum(forfeit_cnt) as forfeit_cnt,
sum(dispose_cnt) as dispose_cnt
from (
select EXTRACT(YEAR FROM a.napo_dt) as 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
order by year desc
</select>