fix:견문통계 완료(추후 수정필요)

TaehunPark 2022-10-26 13:21:32 +09:00
parent 573e69c8f3
commit c1066f21a8
6 changed files with 184 additions and 159 deletions

View File

@ -259,10 +259,18 @@ public class AffairController { // 첩보수집활동 > 외사경찰 견문관
totalList.add(total); totalList.add(total);
} }
mav.addObject("totalList", totalList); mav.addObject("totalList", totalList);
if(typeStatistics.getCategory1() != null) {
type1List = addTotalRow(typeStatistics.getCategory1(), type1List); type1List = addTotalRow(typeStatistics.getCategory1(), type1List);
}
if(typeStatistics.getCategory2() != null) {
type2List = addTotalRow(typeStatistics.getCategory2(), type2List); type2List = addTotalRow(typeStatistics.getCategory2(), type2List);
}
if(typeStatistics.getCategory3() != null) {
type3List = addTotalRow(typeStatistics.getCategory3(), type3List); type3List = addTotalRow(typeStatistics.getCategory3(), type3List);
}
if(typeStatistics.getCategory4() != null) {
type4List = addTotalRow(typeStatistics.getCategory4(), type4List); type4List = addTotalRow(typeStatistics.getCategory4(), type4List);
}
mav.addObject("type1List", type1List); mav.addObject("type1List", type1List);
mav.addObject("type2List", type2List); mav.addObject("type2List", type2List);
mav.addObject("type3List", type3List); mav.addObject("type3List", type3List);
@ -287,8 +295,12 @@ public class AffairController { // 첩보수집활동 > 외사경찰 견문관
} }
totalList.add(total); totalList.add(total);
} }
if(typeStatistics.getSangbo() != null) {
sangboCntList = addTotalRow(typeStatistics.getSangbo(), sangboCntList); sangboCntList = addTotalRow(typeStatistics.getSangbo(), sangboCntList);
}
if(typeStatistics.getRating() != null) {
arrCntList = addTotalRow(typeStatistics.getRating(), arrCntList); arrCntList = addTotalRow(typeStatistics.getRating(), arrCntList);
}
mav.addObject("totalList", totalList); mav.addObject("totalList", totalList);
mav.addObject("sangboList", sangboCntList); mav.addObject("sangboList", sangboCntList);
mav.addObject("arrCntList", arrCntList); mav.addObject("arrCntList", arrCntList);

View File

@ -126,21 +126,21 @@
and wrt_dt <= #{endDate}::date+1 and wrt_dt <= #{endDate}::date+1
</if> </if>
<if test='rating != null and rating != "" or sangbo != null and sangbo != ""'> <if test='rating != null and rating != "" or sangbo != null and sangbo != ""'>
and affair_key in ( and ab.affair_key in (
select affair_key select affair_key
from affair_rating aa from affair_rating ar2
inner join organ_config ab inner join organ_config oc2
on aa.rating_organ = ab.organ_cd on ar2.rating_organ = oc2.organ_cd
<where> <where>
<if test='rating != null and rating != ""'> <if test='rating != null and rating != ""'>
and aa.affair_rate in and ar2.affair_rate in
<foreach collection="rating" item="item" index="index" separator="," open="(" close=")"> <foreach collection="rating" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test='sangbo != null and sangbo != ""'> <if test='sangbo != null and sangbo != ""'>
and aa.organ_up = 'T' and ar2.organ_up = 'T'
and ab.organ_type in and oc2.organ_type in
<foreach collection="sangbo" item="item" index="index" separator="," open="(" close=")"> <foreach collection="sangbo" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
@ -230,8 +230,10 @@
order by item_cd asc) a left outer join order by item_cd asc) a left outer join
(select wrt_organ, (select wrt_organ,
count(*) as cnt count(*) as cnt
from affair_board from affair_board ab,
<trim prefix="WHERE" prefixOverrides="AND |OR "> affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
<if test='userNm != null and userNm != ""'> <if test='userNm != null and userNm != ""'>
and wrt_user_nm like '%'||#{userNm}||'%' and wrt_user_nm like '%'||#{userNm}||'%'
</if> </if>
@ -242,21 +244,21 @@
and wrt_dt &lt;= #{endDate}::date+1 and wrt_dt &lt;= #{endDate}::date+1
</if> </if>
<if test='rating != null and rating != "" or sangbo != null and sangbo != ""'> <if test='rating != null and rating != "" or sangbo != null and sangbo != ""'>
and affair_key in ( and ab.affair_key in (
select affair_key select affair_key
from affair_rating aa from affair_rating ar2
inner join organ_config ab inner join organ_config oc2
on aa.rating_organ = ab.organ_cd on ar2.rating_organ = oc2.organ_cd
<where> <where>
<if test='rating != null and rating != ""'> <if test='rating != null and rating != ""'>
and aa.affair_rate in and ar2.affair_rate in
<foreach collection="rating" item="item" index="index" separator="," open="(" close=")"> <foreach collection="rating" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test='sangbo != null and sangbo != ""'> <if test='sangbo != null and sangbo != ""'>
and aa.organ_up = 'T' and ar2.organ_up = 'T'
and ab.organ_type in and oc2.organ_type in
<foreach collection="sangbo" item="item" index="index" separator="," open="(" close=")"> <foreach collection="sangbo" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
@ -288,7 +290,6 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
</trim>
group by wrt_organ)b on group by wrt_organ)b on
a.item_cd = b.wrt_organ a.item_cd = b.wrt_organ
order by wrt_organ asc order by wrt_organ asc
@ -322,10 +323,11 @@
(select wrt_organ, (select wrt_organ,
affair_type1 as affair_type, affair_type1 as affair_type,
count(*) as cnt count(*) as cnt
from affair_board from affair_board ab,
<where> affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
<include refid="searchStatistics"></include> <include refid="searchStatistics"></include>
</where>
group by wrt_organ,affair_type1) c group by wrt_organ,affair_type1) c
on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ
order by wrt_organ,affair_type asc order by wrt_organ,affair_type asc
@ -359,10 +361,11 @@
(select wrt_organ, (select wrt_organ,
affair_type2 as affair_type, affair_type2 as affair_type,
count(*) as cnt count(*) as cnt
from affair_board from affair_board ab,
<where> affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
<include refid="searchStatistics"></include> <include refid="searchStatistics"></include>
</where>
group by wrt_organ,affair_type2) c group by wrt_organ,affair_type2) c
on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ
order by wrt_organ,affair_type asc order by wrt_organ,affair_type asc
@ -396,10 +399,11 @@
(select wrt_organ, (select wrt_organ,
affair_type3 as affair_type, affair_type3 as affair_type,
count(*) as cnt count(*) as cnt
from affair_board from affair_board ab,
<where> affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
<include refid="searchStatistics"></include> <include refid="searchStatistics"></include>
</where>
group by wrt_organ,affair_type3) c group by wrt_organ,affair_type3) c
on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ
order by wrt_organ,affair_type asc order by wrt_organ,affair_type asc
@ -433,83 +437,73 @@
(select wrt_organ, (select wrt_organ,
affair_type4 as affair_type, affair_type4 as affair_type,
count(*) as cnt count(*) as cnt
from affair_board from affair_board ab,
<where> affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
<include refid="searchStatistics"></include> <include refid="searchStatistics"></include>
</where>
group by wrt_organ,affair_type4) c group by wrt_organ,affair_type4) c
on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ
order by wrt_organ,affair_type asc order by wrt_organ,affair_type asc
</select> </select>
<sql id="raitingSearch"> <sql id="raitingSearch">
<choose> <if test='userNm != null and userNm != ""'>
<when test='sangbo != null and sangbo != ""'> and wrt_user_nm like '%'||#{userNm}||'%'
and ar.organ_up = 'T' </if>
and oc.organ_type in <if test='startDate != null and startDate != ""'>
and wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and wrt_dt &lt;= #{endDate}::date+1
</if>
<if test='rating != null and rating != "" or sangbo != null and sangbo != ""'>
and ab.affair_key in (
select affair_key
from affair_rating ar2
inner join organ_config oc2
on ar2.rating_organ = oc2.organ_cd
<where>
<if test='rating != null and rating != ""'>
and ar2.affair_rate in
<foreach collection="rating" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test='sangbo != null and sangbo != ""'>
and ar2.organ_up = 'T'
and oc2.organ_type in
<foreach collection="sangbo" item="item" index="index" separator="," open="(" close=")"> <foreach collection="sangbo" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</when> </if>
<otherwise> </where>
and oc.organ_type not in ('OGC002','OGC003') )
</otherwise> </if>
</choose> <if test='category1 != null and category1 != ""'>
<choose>
<when test='category1 != null and category1 != ""'>
and affair_type1 in and affair_type1 in
<foreach collection="category1" item="item" index="index" separator="," open="(" close=")"> <foreach collection="category1" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</when> </if>
<otherwise> <if test='category2 != null and category2 != ""'>
and affair_type1 not in (select item_cd from code_mgt where category_cd = 'DC01')
</otherwise>
</choose>
<choose>
<when test='category2 != null and category2 != ""'>
and affair_type2 in and affair_type2 in
<foreach collection="category2" item="item" index="index" separator="," open="(" close=")"> <foreach collection="category2" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</when> </if>
<otherwise> <if test='category3 != null and category3 != ""'>
and affair_type2 not in (select item_cd from code_mgt where category_cd = 'DC02')
</otherwise>
</choose>
<choose>
<when test='category3 != null and category3 != ""'>
and affair_type3 in and affair_type3 in
<foreach collection="category3" item="item" index="index" separator="," open="(" close=")"> <foreach collection="category3" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</when> </if>
<otherwise> <if test='category4 != null and category4 != ""'>
and affair_type3 not in (select item_cd from code_mgt where category_cd = 'DC03')
</otherwise>
</choose>
<choose>
<when test='category4 != null and category4 != ""'>
and affair_type4 in and affair_type4 in
<foreach collection="category4" item="item" index="index" separator="," open="(" close=")"> <foreach collection="category4" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</when> </if>
<otherwise>
and affair_type4 not in (select item_cd from code_mgt where category_cd = 'DC04')
</otherwise>
</choose>
<choose>
<when test='rating != null and rating != ""'>
and affair_rate in
<foreach collection="rating" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</when>
<otherwise>
and affair_rate not in (select item_cd from code_mgt where category_cd = 'AAR')
</otherwise>
</choose>
</sql> </sql>
<select id="selectRatingStatusTotal" resultType="TypeStatistics" parameterType="TypeStatistics"> <select id="selectRatingStatusTotal" resultType="TypeStatistics" parameterType="TypeStatistics">
@ -521,18 +515,28 @@
item_value item_value
from code_mgt from code_mgt
where category_cd = 'OG' where category_cd = 'OG'
and use_chk = 'T') a and use_chk = 'T'
<choose>
<when test='organList != null and organList != ""'>
and item_cd in
<foreach collection="organList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</when>
<otherwise>
and item_cd not in (select item_cd from code_mgt where category_cd = 'OG' and use_chk = 'T')
</otherwise>
</choose>
) a
left outer join left outer join
(select ab.wrt_organ, (select ab.wrt_organ,
oc.organ_type,
count(*) as cnt count(*) as cnt
from affair_board ab, from affair_board ab,
affair_rating ar, affair_rating ar
organ_config oc
where ab.affair_key = ar.affair_key where ab.affair_key = ar.affair_key
and ar.rating_organ = oc.organ_cd and (ar.organ_up != 'T' or ar.organ_up is null)
<include refid="raitingSearch"></include> <include refid="raitingSearch"></include>
group by ab.wrt_organ,oc.organ_type) c group by ab.wrt_organ) c
on a.item_cd = c.wrt_organ on a.item_cd = c.wrt_organ
order by item_cd asc order by item_cd asc
</select> </select>
@ -573,6 +577,7 @@
organ_config oc organ_config oc
where ab.affair_key = ar.affair_key where ab.affair_key = ar.affair_key
and ar.rating_organ = oc.organ_cd and ar.rating_organ = oc.organ_cd
and (ar.organ_up != 'T' or ar.organ_up is null)
<include refid="raitingSearch"></include> <include refid="raitingSearch"></include>
group by ab.wrt_organ,oc.organ_type) c group by ab.wrt_organ,oc.organ_type) c
on a.item_cd = c.wrt_organ and b.organ_type = c.organ_type on a.item_cd = c.wrt_organ and b.organ_type = c.organ_type
@ -609,12 +614,9 @@
ar.affair_rate, ar.affair_rate,
count(*) as cnt count(*) as cnt
from affair_board ab, from affair_board ab,
affair_rating ar, affair_rating ar
organ_config oc
where ab.affair_key = ar.affair_key where ab.affair_key = ar.affair_key
and ar.rating_organ = oc.organ_cd and (ar.organ_up != 'T' or ar.organ_up is null)
and ar.affair_rate is not null
and ar.affair_rate != ''
<include refid="raitingSearch"></include> <include refid="raitingSearch"></include>
group by ab.wrt_organ,ar.affair_rate) c group by ab.wrt_organ,ar.affair_rate) c
on c.wrt_organ = a.item_cd and c.affair_rate = b.item_cd on c.wrt_organ = a.item_cd and c.affair_rate = b.item_cd

View File

@ -5,11 +5,29 @@ $(function(){
}); });
}) })
$(document).on('click', '#downExcel', function (){ $(document).on('click', '#fieldDownExcel', function (){
exportExcel(); exportExcel('분야별');
}) })
function exportExcel(){ $(document).on('click', '#ratingDownExcel', function (){
exportExcel('평가별');
})
function exportExcel(name){
var excelHandler = {
getExcelFileName : function(){
return '견문통계'+'_'+name+'_'+getToday()+'.xlsx'; //파일명
},
getSheetName : function(){
return '견문통계'+'_'+name;
},
getExcelData : function(){
return document.getElementById('tableData'); //TABLE id
},
getWorksheet : function(){
return XLSX.utils.table_to_sheet(this.getExcelData());
}
}
// step 1. workbook 생성 // step 1. workbook 생성
var wb = XLSX.utils.book_new(); var wb = XLSX.utils.book_new();
@ -26,21 +44,6 @@ function exportExcel(){
saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), excelHandler.getExcelFileName()); saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), excelHandler.getExcelFileName());
} }
var excelHandler = {
getExcelFileName : function(){
return '견문통계'+'_'+getToday()+'.xlsx'; //파일명
},
getSheetName : function(){
return 'Table Test Sheet'; //시트명
},
getExcelData : function(){
return document.getElementById('tableData'); //TABLE id
},
getWorksheet : function(){
return XLSX.utils.table_to_sheet(this.getExcelData());
}
}
function s2ab(s) { function s2ab(s) {
var buf = new ArrayBuffer(s.length); //convert s to arrayBuffer var buf = new ArrayBuffer(s.length); //convert s to arrayBuffer
var view = new Uint8Array(buf); //create uint8array as viewer var view = new Uint8Array(buf); //create uint8array as viewer
@ -89,9 +92,17 @@ function goFieldStatistics(){
} }
$(document).on('click', '#ratingSearch', function (){ $(document).on('click', '#ratingSearch', function (){
if($('input:checkbox[name=rating]:checked').length < 1){
alert("평가항목을 선택해주세요");
return false;
}
goRatingStatistics(); goRatingStatistics();
}) })
$(document).on('click', '#ratingTab', function (){ $(document).on('click', '#ratingTab', function (){
if($('input:checkbox[name=rating]:checked').length < 1){
alert("평가항목을 선택해주세요");
return false;
}
goRatingStatistics(); goRatingStatistics();
}) })

View File

@ -92,8 +92,8 @@
</ul> </ul>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<input id="category11" name="sangbo" type="checkbox" value="OGC003" checked>경찰서상보<br> <input id="category11" name="sangbo" type="checkbox" value="OGC003">경찰서상보<br>
<input id="category11" name="sangbo" type="checkbox" value="OGC002" checked>지방청상보 <input id="category11" name="sangbo" type="checkbox" value="OGC002">지방청상보
</div> </div>
<div class="col-1 d-grid gap-2"> <div class="col-1 d-grid gap-2">
<button type="button" id="fieldSearch" class="btn btn-lg btn-primary col-auto">분야별 검색</button> <button type="button" id="fieldSearch" class="btn btn-lg btn-primary col-auto">분야별 검색</button>

View File

@ -10,7 +10,7 @@
</ul> </ul>
<div class="card-body"> <div class="card-body">
<button id="showMenu">검색조건열기</button> <button id="showMenu">검색조건열기</button>
<button id="downExcel">엑셀다운</button> <button id="fieldDownExcel">엑셀다운</button>
<div class="row" id="statisticsDiv"> <div class="row" id="statisticsDiv">
<table class="table table-hover table-bordered border-dark" <table class="table table-hover table-bordered border-dark"
id="tableData"> id="tableData">

View File

@ -10,7 +10,7 @@
</ul> </ul>
<div class="card-body"> <div class="card-body">
<button id="showMenu">검색조건열기</button> <button id="showMenu">검색조건열기</button>
<button id="downExcel">엑셀다운</button> <button id="ratingDownExcel">엑셀다운</button>
<div class="row" id="statisticsDiv"> <div class="row" id="statisticsDiv">
<table class="table table-hover table-bordered border-dark" <table class="table table-hover table-bordered border-dark"
id="tableData"> id="tableData">