diff --git a/src/main/java/com/dbnt/faisp/main/equip/EquipController.java b/src/main/java/com/dbnt/faisp/main/equip/EquipController.java index 119b1e59..c5e50298 100644 --- a/src/main/java/com/dbnt/faisp/main/equip/EquipController.java +++ b/src/main/java/com/dbnt/faisp/main/equip/EquipController.java @@ -322,8 +322,8 @@ public class EquipController { mav.addObject("useList", equipService.selectUseInfoList(useInfo)); useInfo.setContentCnt(equipService.selectUseInfoListCnt(useInfo)); useInfo.setPaginationInfo(); - mav.addObject("organList", equipService.selectOrganList(useInfo)); mav.addObject("searchParams", useInfo); + mav.addObject("downOrganList", loginUser.getDownOrganCdList()); return mav; } @@ -333,15 +333,20 @@ public class EquipController { useInfo.setDownOrganCdList(loginUser.getDownOrganCdList()); mav.addObject("downOrganList", loginUser.getDownOrganCdList()); mav.addObject("useType", useInfo.getUseType()); + if(useInfo.getUseKey()!=null){ + mav.addObject("useInfo", equipService.selectUseInfo(useInfo)); + }else{ + mav.addObject("useInfo", new UseInfo()); + } + mav.addObject("historyInfo", useInfo.getUseKey()==null?null:equipService.selectUseHistoryList(useInfo)); //메뉴권한 확인 - String accessAuth; + String accessAuth = null; if(useInfo.getUseType().equals("PVRE")) { accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/pvreUseList").get(0).getAccessAuth(); - mav.addObject("accessAuth", accessAuth); }else if(useInfo.getUseType().equals("QIR")) { accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/qirUseList").get(0).getAccessAuth(); - mav.addObject("accessAuth", accessAuth); } + mav.addObject("accessAuth", accessAuth); return mav; } @@ -357,50 +362,6 @@ public class EquipController { equipService.saveUseInfo(useInfo); } - @GetMapping("/useModifyModal") - public ModelAndView useModifyModal(@AuthenticationPrincipal UserInfo loginUser, UseInfo useInfo) { - ModelAndView mav = new ModelAndView("equip/useModifyModal"); - useInfo.setDownOrganCdList(loginUser.getDownOrganCdList()); - mav.addObject("organList", equipService.selectOrganList(useInfo)); - mav.addObject("info", equipService.selectUseInfo(useInfo)); - mav.addObject("userSeq", loginUser.getUserSeq()); - - //메뉴권한 확인 - String accessAuth; - if(useInfo.getUseType().equals("PVRE")) { - accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/pvreUseList").get(0).getAccessAuth(); - mav.addObject("accessAuth", accessAuth); - }else if(useInfo.getUseType().equals("QIR")) { - accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/qirUseList").get(0).getAccessAuth(); - mav.addObject("accessAuth", accessAuth); - } - return mav; - } - - @PostMapping("/updateUse") - public UseInfo uadateUse(@AuthenticationPrincipal UserInfo loginUser, UseInfo useInfo){ - useInfo.setWrtOrgan(loginUser.getOgCd()); - useInfo.setWrtPart(loginUser.getOfcCd()); - useInfo.setWrtUserGrd(loginUser.getTitleCd()); - useInfo.setWrtUserSeq(loginUser.getUserSeq()); - useInfo.setWrtUserNm(loginUser.getUserNm()); - useInfo.setWrtDt(LocalDateTime.now()); - return equipService.updateUse(useInfo); - } - - @GetMapping("/useHistory") - public ModelAndView useHistory(@AuthenticationPrincipal UserInfo loginUser, UseInfo useInfo) { - ModelAndView mav = new ModelAndView("equip/useHistory"); - mav.addObject("infoList", equipService.selectUseHistoryList(useInfo)); - return mav; - } - - @GetMapping("/HistoryView") - @ResponseBody - public UseInfo HistoryView(UseInfo useInfo){ - return equipService.selectUseInfo(useInfo); - } - @PostMapping("/useDelete") public void useDelete(@RequestBody List useInfo){ equipService.useDelete(useInfo); diff --git a/src/main/java/com/dbnt/faisp/main/equip/repository/UseInfoVersionRepository.java b/src/main/java/com/dbnt/faisp/main/equip/repository/UseInfoVersionRepository.java index 21ddf9b5..b641a785 100644 --- a/src/main/java/com/dbnt/faisp/main/equip/repository/UseInfoVersionRepository.java +++ b/src/main/java/com/dbnt/faisp/main/equip/repository/UseInfoVersionRepository.java @@ -3,10 +3,13 @@ package com.dbnt.faisp.main.equip.repository; import com.dbnt.faisp.main.equip.model.UseInfoVersion; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; import java.util.Optional; public interface UseInfoVersionRepository extends JpaRepository { - Optional findByUseKey(Integer useKey); + Optional findTop1ByUseKeyOrderByVersionNoDesc(Integer useKey); + + List findByUseKey(Integer useKey); } diff --git a/src/main/java/com/dbnt/faisp/main/equip/service/EquipService.java b/src/main/java/com/dbnt/faisp/main/equip/service/EquipService.java index 7ab5790d..5f2ac863 100644 --- a/src/main/java/com/dbnt/faisp/main/equip/service/EquipService.java +++ b/src/main/java/com/dbnt/faisp/main/equip/service/EquipService.java @@ -303,27 +303,22 @@ public class EquipService extends BaseService { @Transactional public void saveUseInfo(UseInfo useInfo) { - String year = ((Integer) useInfo.getUseDt().getYear()).toString(); - useInfo.setYear(year); - Integer useNo = equipMapper.selectLastUseNo(useInfo); - if(useNo == null) { - useInfo.setUseNo(year+"-001"); - } else { - useInfo.setUseNo(year+"-"+String.format("%03d", useNo+1)); + if(useInfo.getUseKey()==null){ + String year = ((Integer) useInfo.getUseDt().getYear()).toString(); + useInfo.setYear(year); + Integer useNo = equipMapper.selectLastUseNo(useInfo); + if(useNo == null) { + useInfo.setUseNo(year+"-001"); + } else { + useInfo.setUseNo(year+"-"+String.format("%03d", useNo+1)); + } } useInfoRepository.save(useInfo); saveUseInfoVersion(useInfo); } - @Transactional - public UseInfo updateUse(UseInfo useInfo) { - useInfoRepository.save(useInfo); - saveUseInfoVersion(useInfo); - return useInfo; - } - private void saveUseInfoVersion(UseInfo useInfo){ - UseInfoVersion savedInfo = useInfoVersionRepository.findByUseKey(useInfo.getUseKey()).orElse(null); + UseInfoVersion savedInfo = useInfoVersionRepository.findTop1ByUseKeyOrderByVersionNoDesc(useInfo.getUseKey()).orElse(null); UseInfoVersion versionInfo = new UseInfoVersion(); BeanUtils.copyProperties(useInfo, versionInfo); versionInfo.setVersionNo(savedInfo==null?1:(savedInfo.getVersionNo()+1)); @@ -343,8 +338,8 @@ public class EquipService extends BaseService { } - public List selectUseHistoryList(UseInfo useInfo) { - return equipMapper.selectUseHistoryList(useInfo); + public List selectUseHistoryList(UseInfo useInfo) { + return useInfoVersionRepository.findByUseKey(useInfo.getUseKey()); } @Transactional diff --git a/src/main/resources/static/js/equip/use.js b/src/main/resources/static/js/equip/use.js index 9ef43fae..860e4924 100644 --- a/src/main/resources/static/js/equip/use.js +++ b/src/main/resources/static/js/equip/use.js @@ -8,12 +8,12 @@ $(function(){ $(document).on('click', '#addPvre', function (){ const useType = "PVRE"; - showEditModal(useType); + showEditModal(null, useType); }) $(document).on('click', '#addQir', function (){ const useType = "QIR"; - showEditModal(useType); + showEditModal(null, useType); }) $(document).on('change', '#mgtOrgan', function (){ @@ -22,10 +22,10 @@ $(document).on('change', '#mgtOrgan', function (){ partSelector.find('.'+this.value).show(); }) -function showEditModal(useType){ +function showEditModal(useKey, useType){ $.ajax({ url: '/equip/useEditModal', - data: {useType: useType}, + data: {useKey: useKey, useType: useType}, type: 'GET', dataType:"html", success: function(html){ @@ -36,7 +36,6 @@ function showEditModal(useType){ language: "ko", autoclose: true }); - $('#detailSelf').hide(); }, error:function(e){ ajaxErrorAction(e); @@ -85,36 +84,11 @@ $(document).on('change', '#detailType', function (){ $(document).on('click', '.useTr', function (event){ const target = event.target; if(!(target.className === "useChk" ||$(target).parents("td").length>0)){ - showModifyModal($(target).parent('tr').attr("data-usekey")); + const tr = $(target).parent('tr') + showEditModal(tr.attr("data-usekey"), tr.attr("data-usetype")); } }); -function showModifyModal(useKey){ - $.ajax({ - url: '/equip/useModifyModal', - data: {useKey: useKey}, - type: 'GET', - dataType:"html", - success: function(html){ - $("#useEditModalContent").empty().append(html); - $("#useEditModal").modal('show'); - $("#mUseDt").datepicker({ - format: "yyyy-mm-dd", - language: "ko", - autoclose: true - }); - if($('#mDetailType').val() != 'PVREUSE007' && $('#mDetailType').val() != 'QIRUSE006'){ - $('#mDetailSelf').hide(); - }else{ - $('#mDetailSelf').show(); - } - }, - error:function(e){ - ajaxErrorAction(e); - } - }); -} - $(document).on('change', '#mDetailType', function (){ if($(this).val() == 'PVREUSE007' || $(this).val() == 'QIRUSE006'){ $('#mDetailSelf').show(); @@ -139,7 +113,7 @@ $(document).on('click', '#updateUse', function (){ success : function(data) { alert("수정되었습니다."); contentFade("out"); - showModifyModal(data.useNo,data.useType,data.mgtOrgan); + showEditModal(data.useKey,data.useType); }, error : function(xhr, status) { alert("수정에 실패하였습니다.") @@ -180,41 +154,28 @@ $(document).on('click', '#historyBtn', function (){ }); }) -$(document).on('click', '.historyTr', function (event){ - const target = event.target; - $(this).find('.hisChk').prop('checked',true) - if($(this).find('.hisChk').prop('checked')){ - $('.hisChk').prop('checked',false); - $(this).find('.hisChk').prop('checked',true) +$(document).on('click', '.historyTr', function (){ + $(".historyCheckBox").prop('checked', false); + const selectedTr = $(this); + selectedTr.find(".historyCheckBox").prop('checked', true); + + const historyDiv = $('#historyDiv'); + historyDiv.find('input,select').removeAttr('disabled') + + $("#historyMgtOrgan").val(selectedTr.find(".mgtOrgan").val()); + $("#historyMgtPart").val(selectedTr.find(".mgtPart").val()); + $("#historyUseDt").val(selectedTr.find(".useDt").val()); + const detailTypeVal = selectedTr.find(".detailType").val() + $("#historyDetailType").val(detailTypeVal); + if(detailTypeVal === "PVREUSE007" || detailTypeVal === "QIRUSE006"){ + $("#historyDetailSelf").show().val(selectedTr.find(".detailSelf").val()); + }else{ + $("#historyDetailSelf").hide(); } - $.ajax({ - url: '/equip/HistoryView', - data: { - useNo: $(target).parents('tr').data("useno"), - versionNo : Number($(target).parents('tr').data("verno")), - useType : $(target).parents('tr').data("usetype"), - mgtOrgan : $(target).parents('tr').data("mgtorgan") - }, - type: 'GET', - dataType:"json", - success: function(data){ - $('#vSosok').val(data.sosok); - $('#vUseDt').val(data.useDt); - $('#vDetailType').val(data.detailTypeName); - if(data.detailType != 'PVREUSE007' && data.detailType != 'QIRUSE006'){ - $('#vDetailSelf').hide(); - $('#vDetailSelf').val(''); - }else{ - $('#vDetailSelf').show(); - $('#vDetailSelf').val(data.detailSelf); - } - $('#vCnt').val(data.peopleCnt); - $('#vDescription').val(data.description); - }, - error:function(e){ - ajaxErrorAction(e); - } - }); + $("#historyPeopleCnt").val(selectedTr.find(".peopleCnt").val()); + $("#historyDescription").val(selectedTr.find(".description").val()); + + historyDiv.find('input,select').attr('disabled', 'disabled') }) $(document).on('click', '#deleteUse', function (){ @@ -227,9 +188,7 @@ $(document).on('click', '#deleteUse', function (){ $('input:checkbox[name=useChk]:checked').each(function (idx, el){ checkArr.push({}); const target = $(el); - checkArr[idx].useNo = target.parents('tr').data("useno"); - checkArr[idx].mgtOrgan = target.parents('tr').data("mgtorgan"); - checkArr[idx].useType = target.parents('tr').data("usetype"); + checkArr[idx].useKey = target.parents('tr').attr("data-usekey"); }) deleteUse(checkArr); } diff --git a/src/main/resources/templates/equip/pvreUseList.html b/src/main/resources/templates/equip/pvreUseList.html index b0597fe2..059c4a13 100644 --- a/src/main/resources/templates/equip/pvreUseList.html +++ b/src/main/resources/templates/equip/pvreUseList.html @@ -39,8 +39,10 @@
@@ -50,8 +52,8 @@
@@ -78,7 +80,7 @@ - + @@ -89,16 +91,18 @@ - - - - - - - - - - + + + + + + + + +
연번 경찰서 사용일시
+ + +
@@ -106,7 +110,6 @@
-
diff --git a/src/main/resources/templates/equip/qirUseList.html b/src/main/resources/templates/equip/qirUseList.html index f2cffc6b..95455eb8 100644 --- a/src/main/resources/templates/equip/qirUseList.html +++ b/src/main/resources/templates/equip/qirUseList.html @@ -40,7 +40,9 @@
@@ -90,7 +92,7 @@ - + diff --git a/src/main/resources/templates/equip/useEditModal.html b/src/main/resources/templates/equip/useEditModal.html index f5568679..f263291e 100644 --- a/src/main/resources/templates/equip/useEditModal.html +++ b/src/main/resources/templates/equip/useEditModal.html @@ -2,76 +2,203 @@