방첩공작 작업완료

master
강석 최 2023-01-04 09:12:17 +09:00
parent 215c45ccdd
commit df1801fe70
9 changed files with 242 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package com.dbnt.faisp.main.counterIntelligence;
import com.dbnt.faisp.main.authMgt.service.AuthMgtService; import com.dbnt.faisp.main.authMgt.service.AuthMgtService;
import com.dbnt.faisp.main.codeMgt.service.CodeMgtService; import com.dbnt.faisp.main.codeMgt.service.CodeMgtService;
import com.dbnt.faisp.main.counterIntelligence.model.CiWorkStatistics;
import com.dbnt.faisp.main.counterIntelligence.model.CounterIntelligenceWork; import com.dbnt.faisp.main.counterIntelligence.model.CounterIntelligenceWork;
import com.dbnt.faisp.main.counterIntelligence.service.CounterIntelligenceService; import com.dbnt.faisp.main.counterIntelligence.service.CounterIntelligenceService;
import com.dbnt.faisp.main.userInfo.model.UserInfo; import com.dbnt.faisp.main.userInfo.model.UserInfo;
@ -58,7 +59,9 @@ public class CounterIntelligenceController {
}else{ }else{
ciWork = ciService.selectCounterIntelligenceWork(ciWork.getCiwKey()); ciWork = ciService.selectCounterIntelligenceWork(ciWork.getCiwKey());
} }
String accessAuth = authMgtService.selectAccessConfigList
(loginUser.getUserSeq(), "/counterIntelligence/ciWorkList").get(0).getAccessAuth();
mav.addObject("accessAuth", accessAuth);
mav.addObject("atCodeList", codeMgtService.selectCodeMgtList("AT")); mav.addObject("atCodeList", codeMgtService.selectCodeMgtList("AT"));
mav.addObject("at2CodeList", ciWork.getCiwKey()!=null?codeMgtService.selectCodeMgtList(ciWork.getArrestType1()):null); mav.addObject("at2CodeList", ciWork.getCiwKey()!=null?codeMgtService.selectCodeMgtList(ciWork.getArrestType1()):null);
mav.addObject("ciWork", ciWork); mav.addObject("ciWork", ciWork);
@ -70,6 +73,9 @@ public class CounterIntelligenceController {
ModelAndView mav = new ModelAndView("counterIntelligence/ciWorkViewModal"); ModelAndView mav = new ModelAndView("counterIntelligence/ciWorkViewModal");
mav.addObject("lineSeparator", '\n'); mav.addObject("lineSeparator", '\n');
mav.addObject("viewUserSeq", loginUser.getUserSeq()); mav.addObject("viewUserSeq", loginUser.getUserSeq());
String accessAuth = authMgtService.selectAccessConfigList
(loginUser.getUserSeq(), "/counterIntelligence/ciWorkList").get(0).getAccessAuth();
mav.addObject("accessAuth", accessAuth);
mav.addObject("ciWork", ciService.selectCounterIntelligenceWork(ciWork.getCiwKey())); mav.addObject("ciWork", ciService.selectCounterIntelligenceWork(ciWork.getCiwKey()));
return mav; return mav;
} }
@ -80,4 +86,25 @@ public class CounterIntelligenceController {
ciWork.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); ciWork.setMultipartFileList(request.getMultiFileMap().get("uploadFiles"));
return ciService.saveCiWork(ciWork, deleteFileSeq); return ciService.saveCiWork(ciWork, deleteFileSeq);
} }
@PostMapping("/deleteCiWork")
public Integer deleteCiWork(@AuthenticationPrincipal UserInfo loginUser, CounterIntelligenceWork ciWork){
String accessAuth = authMgtService.selectAccessConfigList
(loginUser.getUserSeq(), "/counterIntelligence/ciWorkList").get(0).getAccessAuth();
if(accessAuth.equals("ACC003")){
return ciService.deleteCiWork(ciWork.getCiwKey());
}else{
return 0;
}
}
@GetMapping("/CiWorkStatistics")
public ModelAndView ciWorkStatistics(CiWorkStatistics ciWorkStatistics){
if(ciWorkStatistics.getYear()==null){
ciWorkStatistics.setYear(LocalDateTime.now().getYear());
}
ModelAndView mav = new ModelAndView("/counterIntelligence/ciWorkStatistics");
mav.addObject("yearList", ciService.selectCiWorkYearList());
mav.addObject("ciWorkStatisticsList", ciService.selectCiWorkStatisticsList(ciWorkStatistics));
mav.addObject("searchParams", ciWorkStatistics);
return mav;
}
} }

View File

@ -1,5 +1,6 @@
package com.dbnt.faisp.main.counterIntelligence.mapper; package com.dbnt.faisp.main.counterIntelligence.mapper;
import com.dbnt.faisp.main.counterIntelligence.model.CiWorkStatistics;
import com.dbnt.faisp.main.counterIntelligence.model.CounterIntelligenceWork; import com.dbnt.faisp.main.counterIntelligence.model.CounterIntelligenceWork;
import com.dbnt.faisp.main.faRpt.model.FaRptBoard; import com.dbnt.faisp.main.faRpt.model.FaRptBoard;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -15,4 +16,8 @@ public interface CounterIntelligenceMapper {
Integer selectCounterIntelligenceWorkCnt(CounterIntelligenceWork ciWork); Integer selectCounterIntelligenceWorkCnt(CounterIntelligenceWork ciWork);
String selectHashTags(Integer ciwKey); String selectHashTags(Integer ciwKey);
List<CiWorkStatistics> selectCiWorkStatisticsList(CiWorkStatistics ciWorkStatistics);
List<Integer> selectCiWorkYearList();
} }

View File

@ -0,0 +1,20 @@
package com.dbnt.faisp.main.counterIntelligence.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class CiWorkStatistics {
private String workRating;
private Integer newWorkCnt=0;
private Integer doingWorkCnt=0;
private Integer prevYearWorkEndCnt=0;
private Integer thisYearWorkEndCnt=0;
private Integer year;
}

View File

@ -3,6 +3,7 @@ package com.dbnt.faisp.main.counterIntelligence.service;
import com.dbnt.faisp.config.BaseService; import com.dbnt.faisp.config.BaseService;
import com.dbnt.faisp.config.FileInfo; import com.dbnt.faisp.config.FileInfo;
import com.dbnt.faisp.main.counterIntelligence.mapper.CounterIntelligenceMapper; import com.dbnt.faisp.main.counterIntelligence.mapper.CounterIntelligenceMapper;
import com.dbnt.faisp.main.counterIntelligence.model.CiWorkStatistics;
import com.dbnt.faisp.main.counterIntelligence.model.CiwFile; import com.dbnt.faisp.main.counterIntelligence.model.CiwFile;
import com.dbnt.faisp.main.counterIntelligence.model.CounterIntelligenceWork; import com.dbnt.faisp.main.counterIntelligence.model.CounterIntelligenceWork;
import com.dbnt.faisp.main.counterIntelligence.model.HashTagLinkCiw; import com.dbnt.faisp.main.counterIntelligence.model.HashTagLinkCiw;
@ -104,4 +105,28 @@ public class CounterIntelligenceService extends BaseService {
public FileInfo selectCiWorkFile(Integer ciwKey, Integer fileSeq) { public FileInfo selectCiWorkFile(Integer ciwKey, Integer fileSeq) {
return ciwFileRepository.findById(new CiwFile.CiwFileId(ciwKey, fileSeq)).orElse(null); return ciwFileRepository.findById(new CiwFile.CiwFileId(ciwKey, fileSeq)).orElse(null);
} }
@Transactional
public Integer deleteCiWork(Integer ciwKey) {
CounterIntelligenceWork ciWork = ciwRepository.findById(ciwKey).orElse(null);
ciWork.setStatus("DST008");
return ciwKey;
}
public List<Integer> selectCiWorkYearList() {
return ciMapper.selectCiWorkYearList();
}
public List<CiWorkStatistics> selectCiWorkStatisticsList(CiWorkStatistics ciWorkStatistics) {
List<CiWorkStatistics> ciWorkStatisticsList = ciMapper.selectCiWorkStatisticsList(ciWorkStatistics);
CiWorkStatistics totalStatistics = new CiWorkStatistics();
for(CiWorkStatistics statistics: ciWorkStatisticsList){
totalStatistics.setNewWorkCnt(totalStatistics.getNewWorkCnt()+statistics.getNewWorkCnt());
totalStatistics.setDoingWorkCnt(totalStatistics.getDoingWorkCnt()+statistics.getDoingWorkCnt());
totalStatistics.setPrevYearWorkEndCnt(totalStatistics.getPrevYearWorkEndCnt()+statistics.getPrevYearWorkEndCnt());
totalStatistics.setThisYearWorkEndCnt(totalStatistics.getThisYearWorkEndCnt()+statistics.getThisYearWorkEndCnt());
}
ciWorkStatisticsList.add(totalStatistics);
return ciWorkStatisticsList;
}
} }

View File

@ -6,6 +6,7 @@
<mapper namespace="com.dbnt.faisp.main.counterIntelligence.mapper.CounterIntelligenceMapper"> <mapper namespace="com.dbnt.faisp.main.counterIntelligence.mapper.CounterIntelligenceMapper">
<sql id="selectCounterIntelligenceWorkListWhere"> <sql id="selectCounterIntelligenceWorkListWhere">
<where> <where>
a.status &lt;> 'DST008'
<if test='wrtUserSeq != null and wrtUserSeq != 0'> <if test='wrtUserSeq != null and wrtUserSeq != 0'>
and ((a.wrt_user_seq = #{wrtUserSeq} and a.status = 'DST002') or a.status = 'DST007') and ((a.wrt_user_seq = #{wrtUserSeq} and a.status = 'DST002') or a.status = 'DST007')
</if> </if>
@ -96,8 +97,8 @@
a.wrt_dt, a.wrt_dt,
b.fileCnt b.fileCnt
from counter_intelligence_work a from counter_intelligence_work a
inner join (select ciw_key, count(*) as fileCnt from ciw_file group by ciw_key) b left outer join (select ciw_key, count(*) as fileCnt from ciw_file group by ciw_key) b
on a.ciw_key = b.ciw_key on a.ciw_key = b.ciw_key
<include refid="selectCounterIntelligenceWorkListWhere"></include> <include refid="selectCounterIntelligenceWorkListWhere"></include>
ORDER BY a.ciw_key DESC ORDER BY a.ciw_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex} LIMIT #{rowCnt} OFFSET #{firstIndex}
@ -105,7 +106,7 @@
<select id="selectCounterIntelligenceWorkCnt" parameterType="CounterIntelligenceWork" resultType="int"> <select id="selectCounterIntelligenceWorkCnt" parameterType="CounterIntelligenceWork" resultType="int">
select count(*) select count(*)
from counter_intelligence_work a from counter_intelligence_work a
inner join (select ciw_key, count(*) as fileCnt from ciw_file group by ciw_key) b left outer join (select ciw_key, count(*) as fileCnt from ciw_file group by ciw_key) b
on a.ciw_key = b.ciw_key on a.ciw_key = b.ciw_key
<include refid="selectCounterIntelligenceWorkListWhere"></include> <include refid="selectCounterIntelligenceWorkListWhere"></include>
</select> </select>
@ -115,4 +116,26 @@
inner join hash_tag b on a.tag_key = b.tag_key inner join hash_tag b on a.tag_key = b.tag_key
where a.ciw_key = #{ciwKey} where a.ciw_key = #{ciwKey}
</select> </select>
<select id="selectCiWorkStatisticsList" resultType="ciWorkStatistics" parameterType="ciWorkStatistics">
select work_rating,
count(case when work_start_date > (#{year}||'-01-01')::date and work_start_date &lt; (#{year}+1||'-01-01')::date then 1 end) as newWorkCnt,
count(case when work_end_date > (#{year}+1||'-01-01')::date and work_end_date &lt; (#{year}+2||'-01-01')::date then 1 end) as doingWorkCnt,
count(case when work_start_date > (#{year}-1||'-01-01')::date and work_start_date &lt; (#{year}||'-01-01')::date and work_end_date > (#{year}||'-01-01')::date and work_end_date &lt; (#{year}+1||'-01-01')::date then 1 end) as prevYearWorkEndCnt,
count(case when work_start_date > (#{year}||'-01-01')::date and work_start_date &lt; (#{year}+1||'-01-01')::date and work_end_date > (#{year}||'-01-01')::date and work_end_date &lt; (#{year}+1||'-01-01')::date then 1 end) as thisYearWorkEndCnt
from counter_intelligence_work a
WHERE a.status = 'DST007'
group by work_rating
order by work_rating
</select>
<select id="selectCiWorkYearList" resultType="int">
select year
from ( select EXTRACT(YEAR FROM work_start_date) AS year
from counter_intelligence_work
where status &lt;> 'DST008'
union
select EXTRACT(YEAR FROM now()) AS year
) a
group by year
order by year desc
</select>
</mapper> </mapper>

View File

@ -1,3 +1,13 @@
$(document).on('click', '#ciWorkTab', function (){
location.href="/counterIntelligence/ciWorkList";
})
$(document).on('click', '#performanceTab', function (){
location.href="/counterIntelligence/CiWorkStatistics";
})
$(document).on('change', '#statisticsYear', function (){
location.href="/counterIntelligence/CiWorkStatistics?year="+this.value;
})
$(document).on('click', '#addCiWorkBtn', function (){ $(document).on('click', '#addCiWorkBtn', function (){
getCiWorkEditModal(null); getCiWorkEditModal(null);
}) })
@ -19,6 +29,10 @@ $(document).on('click', '#editCiWorkBtn', function (){
getCiWorkEditModal($(this).attr("data-ciwkey")); getCiWorkEditModal($(this).attr("data-ciwkey"));
}) })
$(document).on('click', '#deleteCiWorkBtn', function (){
deleteCiWork($(this).attr("data-ciwkey"));
})
function getCiWorkEditModal(ciwKey){ function getCiWorkEditModal(ciwKey){
$.ajax({ $.ajax({
url: '/counterIntelligence/ciWorkEditModal', url: '/counterIntelligence/ciWorkEditModal',
@ -65,6 +79,7 @@ function saveCiWork(status){
flag = contentCheck(); flag = contentCheck();
} }
if(flag){ if(flag){
contentFade("in");
const ciWorkEditForm = $("#ciWorkEditForm"); const ciWorkEditForm = $("#ciWorkEditForm");
ciWorkEditForm.find("#status").val(status); ciWorkEditForm.find("#status").val(status);
const formData = new FormData(ciWorkEditForm[0]); const formData = new FormData(ciWorkEditForm[0]);
@ -97,6 +112,33 @@ function saveCiWork(status){
} }
} }
function deleteCiWork(ciwKey){
if(confirm("삭제하시겠습니까?")){
contentFade("in");
const formData = new FormData();
formData.append('ciwKey', ciwKey);
$.ajax({
type : 'POST',
data : formData,
url : "/counterIntelligence/deleteCiWork",
processData: false,
contentType: false,
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(result) {
alert("삭제되었습니다.");
contentFade("out");
location.reload();
},
error : function(xhr, status) {
alert("삭제를 실패하였습니다.")
contentFade("out");
}
})
}
}
function contentCheck(){ function contentCheck(){
if(!$("#workStartDate").val()){ if(!$("#workStartDate").val()){
alert("착수일을 입력해주세요.") alert("착수일을 입력해주세요.")

View File

@ -45,7 +45,7 @@
<div class="col-sm-2"> <div class="col-sm-2">
<input type="text" class="form-control form-control-sm dateSelector" id="workStartDate" name="workStartDate" th:value="${#temporals.format(ciWork.workStartDate, 'yyyy-MM-dd')}" readonly> <input type="text" class="form-control form-control-sm dateSelector" id="workStartDate" name="workStartDate" th:value="${#temporals.format(ciWork.workStartDate, 'yyyy-MM-dd')}" readonly>
</div> </div>
<label for="workEndDate" class="col-sm-1 col-form-label col-form-label-sm text-center">종결일</label> <label for="workEndDate" class="col-sm-1 col-form-label col-form-label-sm text-center">종결일(예정)</label>
<div class="col-sm-2"> <div class="col-sm-2">
<input type="text" class="form-control form-control-sm dateSelector" id="workEndDate" name="workEndDate" th:value="${#temporals.format(ciWork.workEndDate, 'yyyy-MM-dd')}" readonly> <input type="text" class="form-control form-control-sm dateSelector" id="workEndDate" name="workEndDate" th:value="${#temporals.format(ciWork.workEndDate, 'yyyy-MM-dd')}" readonly>
</div> </div>
@ -127,7 +127,10 @@
</form> </form>
</div> </div>
<div class="modal-footer bg-light"> <div class="modal-footer bg-light">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button> <th:block th:if="${ciWork.ciwKey ne null and accessAuth eq 'ACC003'}">
<button type="button" class="btn btn-danger" id="deleteCiWorkBtn" th:data-ciwkey="${ciWork.ciwKey}">삭제</button>
</th:block>
<button type="button" class="btn btn-warning" id="saveTempBtn" data-status="DST002">임시저장</button> <button type="button" class="btn btn-warning" id="saveTempBtn" data-status="DST002">임시저장</button>
<button type="button" class="btn btn-primary" id="saveCiWorkBtn" data-status="DST007">저장</button> <button type="button" class="btn btn-primary" id="saveCiWorkBtn" data-status="DST007">저장</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
</div> </div>

View File

@ -0,0 +1,87 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
<script type="text/javascript" th:src="@{/js/counterIntelligence/ciWork.js}"></script>
</th:block>
<div layout:fragment="content">
<main>
<div class="row justify-content-between">
<div class="col-auto">
<h4>방첩공작</h4>
</div>
<div class="col-auto">
<p class="mb-0 mt-2">외사방첩관리 > 방첩공작</p>
</div>
</div>
<div class="row mx-0">
<div class="col-12 card bg-light text-center">
<div class="card-body">
<ul class="nav nav-tabs" id="userTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link" id="ciWorkTab" data-bs-toggle="tab" type="button" role="tab">공작 목록</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link active" id="performanceTab" data-bs-toggle="tab" type="button" role="tab">실적</button>
</li>
</ul>
<div class="tab-content bg-white border border-top-0 p-2">
<div class="row justify-content-start pb-1">
<div class="col-auto">
<select class="form-select form-select-sm" id="statisticsYear">
<th:block th:each="year:${yearList}">
<option th:value="${year}" th:text="|${year}년|" th:selected="${year eq searchParams.year}"></option>
</th:block>
</select>
</div>
</div>
<div class="row">
<div class="col-12">
<table class="table table-sm table-bordered table-hover">
<thead>
<tr class="table-secondary">
<th rowspan="2">구분</th>
<th rowspan="2">
<th:block th:text="|${searchParams.year}년 신규 개척|"></th:block>
</th>
<th rowspan="2">진행중(미종결)</th>
<th colspan="2">
<th:block th:text="|${searchParams.year}년 종결${#temporals.year(#temporals.createNow()) eq searchParams.year?'(예정)':''}|"></th:block>
</th>
</tr>
<tr class="table-secondary">
<th>
<th:block th:text="|${searchParams.year-1}년 개척 건 中|"></th:block>
</th>
<th>
<th:block th:text="|${searchParams.year}년 개척 건 中|"></th:block>
</th>
</tr>
</thead>
<tbody class="table-group-divider">
<tr th:each="statistics:${ciWorkStatisticsList}">
<td>
<th:block th:if="${#strings.isEmpty(statistics.workRating)}">총계</th:block>
<th:block th:unless="${#strings.isEmpty(statistics.workRating)}">
<th:block th:each="code:${session.commonCode.get('CIWR')}">
<th:block th:if="${code.itemCd eq statistics.workRating}" th:text="${code.itemValue}"></th:block>
</th:block>
</th:block>
</td>
<td th:text="${statistics.newWorkCnt}"></td>
<td th:text="${statistics.doingWorkCnt}"></td>
<td th:text="${statistics.prevYearWorkEndCnt}"></td>
<td th:text="${statistics.thisYearWorkEndCnt}"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</html>

View File

@ -29,7 +29,7 @@
<div class="row mb-1"> <div class="row mb-1">
<label class="col-sm-1 col-form-label col-form-label-sm text-center fw-bold">착수일</label> <label class="col-sm-1 col-form-label col-form-label-sm text-center fw-bold">착수일</label>
<label class="col-sm-2 col-form-label col-form-label-sm text-start" th:text="${#temporals.format(ciWork.workStartDate, 'yyyy-MM-dd')}"></label> <label class="col-sm-2 col-form-label col-form-label-sm text-start" th:text="${#temporals.format(ciWork.workStartDate, 'yyyy-MM-dd')}"></label>
<label class="col-sm-1 col-form-label col-form-label-sm text-center fw-bold">종결일</label> <label class="col-sm-1 col-form-label col-form-label-sm text-center fw-bold">종결일(예정)</label>
<label class="col-sm-2 col-form-label col-form-label-sm text-start" th:text="${#temporals.format(ciWork.workEndDate, 'yyyy-MM-dd')}"></label> <label class="col-sm-2 col-form-label col-form-label-sm text-start" th:text="${#temporals.format(ciWork.workEndDate, 'yyyy-MM-dd')}"></label>
<label class="col-sm-1 col-form-label col-form-label-sm text-center fw-bold">1차재평가</label> <label class="col-sm-1 col-form-label col-form-label-sm text-center fw-bold">1차재평가</label>
<label class="col-sm-2 col-form-label col-form-label-sm text-start" th:text="${#temporals.format(ciWork.reRatingDate1, 'yyyy-MM-dd')}"></label> <label class="col-sm-2 col-form-label col-form-label-sm text-start" th:text="${#temporals.format(ciWork.reRatingDate1, 'yyyy-MM-dd')}"></label>
@ -108,6 +108,9 @@
</div> </div>
</div> </div>
<div class="modal-footer bg-light"> <div class="modal-footer bg-light">
<th:block th:if="${accessAuth eq 'ACC003'}">
<button type="button" class="btn btn-danger" id="deleteCiWorkBtn" th:data-ciwkey="${ciWork.ciwKey}">삭제</button>
</th:block>
<th:block th:if="${viewUserSeq eq ciWork.wrtUserSeq}"> <th:block th:if="${viewUserSeq eq ciWork.wrtUserSeq}">
<button type="button" class="btn btn-warning" id="editCiWorkBtn" th:data-ciwkey="${ciWork.ciwKey}">수정</button> <button type="button" class="btn btn-warning" id="editCiWorkBtn" th:data-ciwkey="${ciWork.ciwKey}">수정</button>
</th:block> </th:block>