Compare commits

...

2 Commits

6 changed files with 114 additions and 37 deletions

View File

@ -189,15 +189,6 @@ public class AffairController { // 첩보수집활동 > 외사경찰 견문관
@PostMapping("/affairStateChange") @PostMapping("/affairStateChange")
public Integer affairStateChange(@AuthenticationPrincipal UserInfo loginUser, AffairRating rating){ public Integer affairStateChange(@AuthenticationPrincipal UserInfo loginUser, AffairRating rating){
String apprvType = "section"; return affairService.affairStateChange(loginUser, rating);
if(rating.getHeadApprv() == null){
rating.setSectionNm(loginUser.getUserNm());
rating.setSectionApprvDt(LocalDateTime.now());
}else{
apprvType = "head";
rating.setHeadNm(loginUser.getUserNm());
rating.setHeadApprvDt(LocalDateTime.now());
}
return affairService.affairStateChange(apprvType, rating);
} }
} }

View File

@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -115,20 +116,36 @@ public class AffairService extends BaseService { // 견문보고
} }
} }
public Integer affairStateChange(String apprvType, AffairRating rating) { @Transactional
public Integer affairStateChange(UserInfo loginUser, AffairRating rating) {
AffairBoard savedAffair = affairBoardRepository.findById(rating.getAffairKey()).orElse(null);
AffairRating savedRating = affairRatingRepository.findById(new AffairRating.AffairRatingId(rating.getAffairKey(), rating.getRatingOrgan())).orElse(null); AffairRating savedRating = affairRatingRepository.findById(new AffairRating.AffairRatingId(rating.getAffairKey(), rating.getRatingOrgan())).orElse(null);
if(savedRating != null){ if(savedAffair!= null && savedRating != null){
if(apprvType.equals("section")){ if(rating.getHeadApprv() == null){
savedRating.setSectionNm(rating.getSectionNm()); savedAffair.setAffairStatus(rating.getSectionApprv());
savedRating.setSectionApprvDt(rating.getSectionApprvDt()); savedRating.setSectionNm(loginUser.getUserNm());
savedRating.setSectionApprvDt(LocalDateTime.now());
savedRating.setSectionApprv(rating.getSectionApprv()); savedRating.setSectionApprv(rating.getSectionApprv());
savedRating.setSectionEtc(rating.getSectionEtc()); savedRating.setSectionEtc(rating.getSectionEtc());
}else{ }else{
savedRating.setHeadNm(rating.getHeadNm()); savedAffair.setAffairStatus(rating.getHeadApprv());
savedRating.setHeadApprvDt(rating.getHeadApprvDt()); savedRating.setHeadNm(loginUser.getUserNm());
savedRating.setHeadApprvDt(LocalDateTime.now());
savedRating.setHeadApprv(rating.getHeadApprv()); savedRating.setHeadApprv(rating.getHeadApprv());
savedRating.setHeadEtc(rating.getHeadEtc()); savedRating.setHeadEtc(rating.getHeadEtc());
savedRating.setAffairRate(rating.getAffairRate());
savedRating.setOrganUp(rating.getOrganUp());
if(rating.getOrganUp().equals("T")){
List<String> organList = loginUser.getUpOrganCdList();
String upOrgan = organList.get(organList.indexOf(savedRating.getRatingOrgan())-1);
AffairRating upRating = new AffairRating();
upRating.setRatingOrgan(upOrgan);
upRating.setAffairKey(savedRating.getAffairKey());
affairRatingRepository.save(upRating);
savedAffair.setAffairStatus("DST002");
}
} }
affairBoardRepository.save(savedAffair);
affairRatingRepository.save(savedRating); affairRatingRepository.save(savedRating);
} }
return rating.getAffairKey(); return rating.getAffairKey();

View File

@ -66,11 +66,11 @@
a.wrt_dt, a.wrt_dt,
b.fileCnt b.fileCnt
from affair_board a from affair_board a
left outer join (select affair_key, left outer join (select affair_key,
count(file_seq) as fileCnt count(file_seq) as fileCnt
from affair_file from affair_file
group by affair_key) b group by affair_key) b
on a.affair_key = b.affair_key on a.affair_key = b.affair_key
<include refid="selectAffairBoardWhere"></include> <include refid="selectAffairBoardWhere"></include>
order by affair_key desc order by affair_key desc
limit #{rowCnt} offset #{firstIndex} limit #{rowCnt} offset #{firstIndex}

View File

@ -46,6 +46,44 @@ $(document).on('click', '#saveAffairBtn', function (){
$(document).on('click', '#saveTempBtn', function (){ $(document).on('click', '#saveTempBtn', function (){
saveAffair('DST001') saveAffair('DST001')
}) })
$(document).on('click', '.apprvBtn', function (){
const apprvType = $(this).attr("data-apprvtype");
let flag = true;
if(apprvType==="head"){
if(!$("#affairRate").val()){
alert("견문평가를 선택해주세요.")
flag = false;
}
}
if(flag){
if(confirm($(this).val()+"하시겠습니까?")){
$((apprvType === "section"?"#sectionApprv":"#headApprv")).val($(this).attr("data-affairstate"))
const ratingOrganCd = $(".ratingOrganCd")
$("#apprvFormRatingOrgan").val(ratingOrganCd[ratingOrganCd.length-1].value);
const formData = new FormData($("#apprvForm")[0]);
contentFade("in")
$.ajax({
type : 'POST',
data : formData,
url : "/affair/affairStateChange",
processData: false,
contentType: false,
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(result) {
alert("저장되었습니다")
getAffairViewModal(result);
contentFade("out");
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.");
contentFade("out");
}
})
}
}
})
function getAffairViewModal(affairKey){ function getAffairViewModal(affairKey){
$.ajax({ $.ajax({

View File

@ -78,6 +78,7 @@ $(document).on('click', '.apprvBtn', function (){
}, },
success : function(result) { success : function(result) {
alert("저장되었습니다") alert("저장되었습니다")
getPlanViewModal(result);
contentFade("out"); contentFade("out");
}, },
error : function(xhr, status) { error : function(xhr, status) {

View File

@ -41,7 +41,7 @@
<div class="col-sm-2"> <div class="col-sm-2">
<th:block th:each="code:${session.commonCode.get('AVS')}"> <th:block th:each="code:${session.commonCode.get('AVS')}">
<th:block th:if="${code.itemCd eq affair.viewStatus}"> <th:block th:if="${code.itemCd eq affair.viewStatus}">
<input type="text" class="form-control form-control-sm border-0" id="viewStatus" th:value="${code.itemValue}"> <input type="text" class="form-control form-control-sm border-0" id="viewStatus" th:value="${code.itemValue}" readonly>
</th:block> </th:block>
</th:block> </th:block>
</div> </div>
@ -51,7 +51,7 @@
<div class="col-sm-2"> <div class="col-sm-2">
<th:block th:each="code:${session.commonCode.get('DC01')}"> <th:block th:each="code:${session.commonCode.get('DC01')}">
<th:block th:if="${code.itemCd eq affair.affairType1}"> <th:block th:if="${code.itemCd eq affair.affairType1}">
<input type="text" class="form-control form-control-sm border-0" id="affairType1" th:value="${code.itemValue}"> <input type="text" class="form-control form-control-sm border-0" id="affairType1" th:value="${code.itemValue}" readonly>
</th:block> </th:block>
</th:block> </th:block>
</div> </div>
@ -59,7 +59,7 @@
<div class="col-sm-2"> <div class="col-sm-2">
<th:block th:each="code:${session.commonCode.get('DC02')}"> <th:block th:each="code:${session.commonCode.get('DC02')}">
<th:block th:if="${code.itemCd eq affair.affairType2}"> <th:block th:if="${code.itemCd eq affair.affairType2}">
<input type="text" class="form-control form-control-sm border-0" id="affairType2" th:value="${code.itemValue}"> <input type="text" class="form-control form-control-sm border-0" id="affairType2" th:value="${code.itemValue}" readonly>
</th:block> </th:block>
</th:block> </th:block>
</div> </div>
@ -67,7 +67,7 @@
<div class="col-sm-2"> <div class="col-sm-2">
<th:block th:each="code:${session.commonCode.get('DC03')}"> <th:block th:each="code:${session.commonCode.get('DC03')}">
<th:block th:if="${code.itemCd eq affair.affairType3}"> <th:block th:if="${code.itemCd eq affair.affairType3}">
<input type="text" class="form-control form-control-sm border-0" id="affairType3" th:value="${code.itemValue}"> <input type="text" class="form-control form-control-sm border-0" id="affairType3" th:value="${code.itemValue}" readonly>
</th:block> </th:block>
</th:block> </th:block>
</div> </div>
@ -75,7 +75,7 @@
<div class="col-sm-2"> <div class="col-sm-2">
<th:block th:each="code:${session.commonCode.get('DC04')}"> <th:block th:each="code:${session.commonCode.get('DC04')}">
<th:block th:if="${code.itemCd eq affair.affairType4}"> <th:block th:if="${code.itemCd eq affair.affairType4}">
<input type="text" class="form-control form-control-sm border-0" id="affairType4" th:value="${code.itemValue}"> <input type="text" class="form-control form-control-sm border-0" id="affairType4" th:value="${code.itemValue}" readonly>
</th:block> </th:block>
</th:block> </th:block>
</div> </div>
@ -170,7 +170,7 @@
<div class="row" th:if="${rate.headApprv ne null}"> <div class="row" th:if="${rate.headApprv ne null}">
<div class="col-auto"> <div class="col-auto">
<th:block th:each="commonCode:${session.commonCode.get('AAR')}"> <th:block th:each="commonCode:${session.commonCode.get('AAR')}">
<span th:if="${commonCode.itemCd eq rate.affairRate}" th:text="|견문평가: ${commonCode.itemValue} ${rate.organ_up eq 'T'?'(상보)':''}|"></span> <span th:if="${commonCode.itemCd eq rate.affairRate}" th:text="|견문평가: ${commonCode.itemValue} ${rate.organUp eq 'T'?'(상보)':''}|"></span>
</th:block> </th:block>
<span th:text="|결재자: ${rate.headNm}|"></span> <span th:text="|결재자: ${rate.headNm}|"></span>
</div> </div>
@ -188,20 +188,50 @@
</div> </div>
<div class="col-12" th:if="${apprvAuth ne null}"> <div class="col-12" th:if="${apprvAuth ne null}">
<form action="#" method="post" id="apprvForm"> <form action="#" method="post" id="apprvForm">
<div class="row"> <input type="hidden" name="affairKey" th:value="${affair.affairKey}">
<div class="col-10"> <input type="hidden" name="ratingOrgan" id="apprvFormRatingOrgan">
<input type="hidden" name="affairKey" id="apprvFormAffairKey"> <th:block th:if="${(apprvAuth eq 'APC003' or apprvAuth eq 'APC004') and affair.affairStatus eq 'DST002'}">
<input type="hidden" name="state" id="viewModalApprvValue"> <input type="hidden" name="sectionApprv" id="sectionApprv">
<input type="text" class="form-control form-control-sm" name="etc" placeholder="추가의견, 반려사유 기입"> <div class="row">
<input type="text" class="d-none" id="submitPrevention"> <div class="col-10">
<input type="text" class="form-control form-control-sm" name="sectionEtc" placeholder="추가의견, 반려사유 기입">
<input type="text" class="d-none" id="submitPrevention">
</div>
<div class="col-auto">
<input type="button" class="btn btn-sm btn-success apprvBtn" data-apprvtype="section" data-affairstate="DST004" value="승인">
</div>
<div class="col-auto">
<input type="button" class="btn btn-sm btn-danger apprvBtn" data-apprvtype="section" data-affairstate="DST003" value="반려">
</div>
</div> </div>
<div class="col-auto"> </th:block>
<input type="button" class="btn btn-sm btn-success apprvBtn" th:data-affairstate="${apprvAuth eq 'APC004'||apprvAuth eq 'APC003'?'DST004':'DST006'}" value="승인"> <th:block th:if="${(apprvAuth eq 'APC001' or apprvAuth eq 'APC002') and affair.affairStatus eq 'DST004'}">
<input type="hidden" name="headApprv" id="headApprv">
<div class="row">
<div class="col-8">
<input type="text" class="form-control form-control-sm" name="headEtc" placeholder="추가의견, 반려사유 기입">
<input type="text" class="d-none" id="submitPrevention">
</div>
<div class="col-auto">
<select class="form-select form-select-sm" name="affairRate" id="affairRate">
<option value="">견문평가</option>
<th:block th:each="commonCode:${session.commonCode.get('AAR')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"></option>
</th:block>
</select>
</div>
<div class="col-auto">
<label for="organUp" class="form-check-label">상보여부</label>
<input type="checkbox" id="organUp" name="organUp" value="T">
</div>
<div class="col-auto">
<input type="button" class="btn btn-sm btn-success apprvBtn" data-apprvtype="head" data-affairstate="DST006" value="승인">
</div>
<div class="col-auto">
<input type="button" class="btn btn-sm btn-danger apprvBtn" data-apprvtype="head" data-affairstate="DST005" value="반려">
</div>
</div> </div>
<div class="col-auto"> </th:block>
<input type="button" class="btn btn-sm btn-danger apprvBtn" th:data-affairstate="${apprvAuth eq 'APC004'||apprvAuth eq 'APC003'?'DST003':'DST005'}" value="반려">
</div>
</div>
</form> </form>
</div> </div>
</div> </div>