외사정보보고 수신자 추가 기능 추가.

master
최강석 2023-05-18 16:28:17 +09:00
parent 3bae73fdbc
commit 4f0ee09711
9 changed files with 175 additions and 26 deletions

View File

@ -95,6 +95,14 @@ public class FaRptController {
return mav;
}
@GetMapping("/faRptReadUserModal")
public ModelAndView faRptReadUserModal(@AuthenticationPrincipal UserInfo loginUser, FaRptBoard faRptBoard){
ModelAndView mav = new ModelAndView("faRpt/faRptReadUserModal");
faRptBoard = faRptService.selectFaRptBoard(faRptBoard.getFaRptKey(), null);
mav.addObject("faRpt", faRptBoard);
return mav;
}
@GetMapping("/faRptViewModal")
public ModelAndView faRptViewModal(@AuthenticationPrincipal UserInfo loginUser, FaRptBoard faRptBoard){
ModelAndView mav = new ModelAndView("faRpt/faRptViewModal");
@ -122,6 +130,11 @@ public class FaRptController {
return mav;
}
@PostMapping("/updateReadUser")
public void updateReadUser(FaRptBoard faRptBoard){
faRptService.updateReadUser(faRptBoard.getFaRptKey(), faRptBoard.getReadUserList());
}
@PostMapping("/deleteFaRpt")
@ResponseBody
public void deleteFaRpt (@RequestBody FaRptBoard faRpt){

View File

@ -74,7 +74,7 @@ public class FaRptService extends BaseService {
faRptBoard.setReadUserList(faRptReadUserRepository.findByFaRptKey(faRptKey));
if(faRptBoard.getStatus().equals("DST007")){
for(FaRptReadUser readUser: faRptBoard.getReadUserList()){
if(readUser.getUserSeq().equals(userSeq)){
if(readUser.getUserSeq().equals(userSeq) && !readUser.getReadYn().equals("T")){
readUser.setReadYn("T");
faRptReadUserRepository.save(readUser);
}
@ -87,16 +87,30 @@ public class FaRptService extends BaseService {
private void saveFaRptReadUser(Integer faRptKey, List<FaRptReadUser> readUserList) {
faRptReadUserRepository.deleteByFaRptKey(faRptKey);
List<FaRptReadUser> saveReadUserList = faRptReadUserRepository.findByFaRptKey(faRptKey);
List<UserAlarm> alarmList = new ArrayList<>();
LocalDateTime dateTime = LocalDateTime.now();
for(FaRptReadUser readUser: readUserList){
readUser.setFaRptKey(faRptKey);
UserAlarm alarm = userAlarmService.makeUserAlarm
(dateTime, readUser.getUserSeq(), faRptKey, 1, "외사정보보고에 수신 문서가 있습니다.");
alarmList.add(alarm);
readUser.setReadYn("F");
boolean savedFlag = false;
for(FaRptReadUser savedUser: saveReadUserList){
if(savedUser.getUserSeq().equals(readUser.getUserSeq())){
readUser.setReadYn(savedUser.getReadYn());
savedFlag = true;
break;
}
}
if(!savedFlag){
UserAlarm alarm = userAlarmService.makeUserAlarm
(dateTime, readUser.getUserSeq(), faRptKey, 1, "외사정보보고에 수신 문서가 있습니다.");
alarmList.add(alarm);
}
}
userAlarmService.saveAlarmList(alarmList);
faRptReadUserRepository.deleteByFaRptKey(faRptKey);
faRptReadUserRepository.saveAll(readUserList);
}
@ -150,4 +164,9 @@ public class FaRptService extends BaseService {
public void deleteFaRpt(Integer faRptKey) {
faRptBoardRepository.bulkModifyingByFaRptKeyToStatus(faRptKey, "DST008");
}
@Transactional
public void updateReadUser(Integer faRptKey, List<FaRptReadUser> readUserList) {
saveFaRptReadUser(faRptKey, readUserList);
}
}

View File

@ -70,7 +70,7 @@
group by fa_rpt_key) b
on a.fa_rpt_key = b.fa_rpt_key
left outer join (select fa_rpt_key,
count(read_yn='T') as readCnt,
sum(case when read_yn='T' then 1 else 0 end) as readCnt,
count(*) as userCnt
from fa_rpt_read_user
group by fa_rpt_key) c

View File

@ -71,6 +71,33 @@ $(document).on('click', '#saveTempBtn', function (){
saveFaRpt('DST001')
})
$(document).on('click', '#saveFaRptReadUserBtn', function () {
const formData = new FormData($("#faRptReadUserForm")[0]);
$.each($(".readUserRow"), function (idx, row){
formData.append('readUserList['+idx+'].userSeq', $(row).find('.userSeq').val());
formData.append('readUserList['+idx+'].ogCd', $(row).find('.ogCd').val());
formData.append('readUserList['+idx+'].ofcCd', $(row).find('.ofcCd').val());
formData.append('readUserList['+idx+'].titleCd', $(row).find('.titleCd').val());
formData.append('readUserList['+idx+'].userNm', $(row).find('.userNm').val());
});
contentFade("in")
$.ajax({
type : 'POST',
url : "/faRpt/updateReadUser",
data : formData,
processData: false,
contentType: false,
success : function(html) {
contentFade("out")
alert("저장되었습니다.")
location.reload();
},
error : function(xhr, status) {
}
})
})
$(document).on('click', '.faRptTr', function (){
const chkBox = $(this).find(".rowChkBox");
if(chkBox.length>0){
@ -91,6 +118,10 @@ $(document).on('click', '#reSendBtn', function (){
}
getFaRptEditModal(faRpt);
})
$(document).on('click', '#addReceiveUserBtn', function (){
$("#faRptViewModal").modal('hide');
getFaRptReadUserModal($(this).attr("data-farptkey"));
})
$(document).on('click', '#deleteBtn', function (){
if(confirm("삭제하시겠습니까?\n되돌릴 수 없습니다.")){
@ -122,7 +153,8 @@ function getFaRptViewModal(faRptKey){
type: 'GET',
dataType:"html",
success: function(html){
$("#faRptViewBody").empty().append(html)
$(".mainModalContent").empty()
$("#faRptViewBody").append(html)
$("#faRptViewModal").modal('show');
},
error:function(e){
@ -138,7 +170,8 @@ function getFaRptEditModal(faRpt){
type: 'GET',
dataType:"html",
success: function(html){
$("#faRptEditModalContent").empty().append(html)
$(".mainModalContent").empty()
$("#faRptEditModalContent").append(html)
setUploadDiv();
setEditor('editor', '500');
$("#faRptEditModal").modal('show');
@ -148,6 +181,23 @@ function getFaRptEditModal(faRpt){
}
});
}
function getFaRptReadUserModal(faRptKey){
$.ajax({
url: '/faRpt/faRptReadUserModal',
data: {faRptKey: faRptKey},
type: 'GET',
dataType:"html",
success: function(html){
$(".mainModalContent").empty()
$("#faRptReadUserBody").append(html)
$("#faRptReadUserModal").modal('show');
},
error:function(e){
ajaxErrorAction(e);
}
});
}
function saveFaRpt(faRptState){
if(contentCheck()){
if(confirm("송신하시겠습니까?")){

View File

@ -177,14 +177,21 @@
<div class="modal fade" id="faRptEditModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="faRptEditModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xxl modal-dialog-scrollable">
<div class="modal-content" id="faRptEditModalContent">
<div class="modal-content mainModalContent" id="faRptEditModalContent">
</div>
</div>
</div>
<div class="modal fade" id="faRptViewModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="faRptViewModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content" id="faRptViewBody">
<div class="modal-content mainModalContent" id="faRptViewBody">
</div>
</div>
</div>
<div class="modal fade" id="faRptReadUserModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="faRptReadUserModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable">
<div class="modal-content mainModalContent" id="faRptReadUserBody">
</div>
</div>

View File

@ -106,9 +106,9 @@
<th:block th:each="code:${session.commonCode.get(readUser.ogCd)}">
<th:block th:if="${code.itemCd eq readUser.ofcCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<!--<th:block th:each="code:${session.commonCode.get('JT')}">
<th:block th:each="code:${session.commonCode.get('JT')}">
<th:block th:if="${code.itemCd eq readUser.titleCd}" th:text="${code.itemValue}"></th:block>
</th:block>-->
</th:block>
<th:block th:text="${readUser.userNm}"></th:block>
</div>
<div class="col-2">

View File

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="modal-header bg-dark">
<h5 class="modal-title text-white" id="faRptReadUserModalLabel">수신자 추가</h5>
<button type="button" class="btn-close f-invert" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="faRptReadUserBody">
<form action="#" method="post" id="faRptReadUserForm">
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<input type="hidden" name="faRptKey" th:value="${faRpt.faRptKey}">
<div class="row">
<div class="col-12 pb-2">
<div class="row justify-content-between">
<div class="col-auto">■ 수신자</div>
<div class="col-auto"><button type="button" class="btn btn-sm btn-info" id="addReadUserBtn">추가</button></div>
</div>
</div>
<div class="col-1">no</div>
<div class="col-9">수신자</div>
<div class="col-2">삭제</div>
</div>
<hr class="my-1">
<div class="row" id="defaultUserRow">
<div class="col-12">
<th:block th:each="readUser, idx:${faRpt.readUserList}">
<div class="row my-1 readUserRow">
<input type="hidden" class="userSeq" th:value="${readUser.userSeq}">
<input type="hidden" class="ogCd" th:value="${readUser.ogCd}">
<input type="hidden" class="ofcCd" th:value="${readUser.ofcCd}">
<input type="hidden" class="titleCd" th:value="${readUser.titleCd}">
<input type="hidden" class="userNm" th:value="${readUser.userNm}">
<div class="col-1 rowSeq" th:text="${idx.index+1}"></div>
<div class="col-9">
<th:block th:each="code:${session.commonCode.get('OG')}">
<th:block th:if="${code.itemCd eq readUser.ogCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<th:block th:each="code:${session.commonCode.get(readUser.ogCd)}">
<th:block th:if="${code.itemCd eq readUser.ofcCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<th:block th:each="code:${session.commonCode.get('JT')}">
<th:block th:if="${code.itemCd eq readUser.titleCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<th:block th:text="${readUser.userNm}"></th:block>
</div>
<!--<div class="col-2">
<button type="button" class="btn btn-sm btn-outline-danger rowDeleteBtn"><i class="bi bi-x"></i></button>
</div>-->
</div>
</th:block>
</div>
<div class="col-12" id="readUserRow">
</div>
</div>
</form>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-primary" id="saveFaRptReadUserBtn">저장</button>
</div>

View File

@ -58,15 +58,15 @@
<div class="row my-1">
<div class="col-1" th:text="${idx.index+1}"></div>
<div class="col-9">
<th:block th:each="commonCode:${session.commonCode.get('OG')}">
<th:block th:if="${commonCode.itemCd eq readUser.ogCd}" th:text="${commonCode.itemValue}"></th:block>
<th:block th:each="code:${session.commonCode.get('OG')}">
<th:block th:if="${code.itemCd eq readUser.ogCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get(readUser.ogCd)}">
<th:block th:if="${commonCode.itemCd eq readUser.ofcCd}" th:text="${commonCode.itemValue}"></th:block>
<th:block th:each="code:${session.commonCode.get(readUser.ogCd)}">
<th:block th:if="${code.itemCd eq readUser.ofcCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<th:block th:each="code:${session.commonCode.get('JT')}">
<th:block th:if="${code.itemCd eq readUser.titleCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<!--<th:block th:each="commonCode:${session.commonCode.get('JT')}">
<th:block th:if="${commonCode.itemCd eq readUser.titleCd}" th:text="|${commonCode.itemValue} ${readUser.userNm}|"></th:block>
</th:block>-->
<th:block th:text="${readUser.userNm}"></th:block>
</div>
<div class="col-2">
@ -119,6 +119,7 @@
</th:block>
<th:block th:each="readUser:${faRpt.readUserList}">
<th:block th:if="${readUser.userSeq eq userSeq}">
<button type="button" class="btn btn-warning" id="addReceiveUserBtn" th:data-farptkey="${faRpt.faRptKey}">수신자 추가</button>
<button type="button" class="btn btn-success" id="reSendBtn" th:data-farptkey="${faRpt.faRptKey}">회신</button>
</th:block>
</th:block>

View File

@ -9,15 +9,15 @@
<input type="hidden" class="userNm" th:value="${readUser.userNm}">
<div class="col-1 rowSeq"></div>
<div class="col-9">
<th:block th:each="commonCode:${session.commonCode.get('OG')}">
<th:block th:if="${commonCode.itemCd eq readUser.ogCd}" th:text="${commonCode.itemValue}"></th:block>
<th:block th:each="code:${session.commonCode.get('OG')}">
<th:block th:if="${code.itemCd eq readUser.ogCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get(readUser.ogCd)}">
<th:block th:if="${commonCode.itemCd eq readUser.ofcCd}" th:text="${commonCode.itemValue}"></th:block>
<th:block th:each="code:${session.commonCode.get(readUser.ogCd)}">
<th:block th:if="${code.itemCd eq readUser.ofcCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<th:block th:each="code:${session.commonCode.get('JT')}">
<th:block th:if="${code.itemCd eq readUser.titleCd}" th:text="${code.itemValue}"></th:block>
</th:block>
<!--<th:block th:each="commonCode:${session.commonCode.get('JT')}">
<th:block th:if="${commonCode.itemCd eq readUser.titleCd}" th:text="|${commonCode.itemValue} ${readUser.userNm}|"></th:block>
</th:block>-->
<th:block th:text="${readUser.userNm}"></th:block>
</div>
<div class="col-2">