From 8e97cb8860f1e8bcd423b24ce870455afb5a5c72 Mon Sep 17 00:00:00 2001 From: TaehunPark Date: Thu, 29 Sep 2022 17:55:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EC=99=B8=EC=82=AC=EB=B6=84=EC=8B=A4?= =?UTF-8?q?=ED=98=84=ED=99=A9=20=EC=A4=91=EA=B0=84=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faisp/fipTarget/FipTargetController.java | 54 ++++-- .../fipTarget/mapper/FipTargetMapper.java | 4 + .../dbnt/faisp/fipTarget/model/PartInfo.java | 16 +- .../faisp/fipTarget/model/PartInfoFile.java | 9 + .../repository/PartInfoFileRepository.java | 4 + .../fipTarget/service/FipTargetService.java | 17 +- src/main/java/com/dbnt/faisp/util/Utils.java | 133 +++++++++++++- .../resources/mybatisMapper/FipTarget.xml | 162 +++++++++++++++++- .../resources/static/js/fipTarget/partInfo.js | 82 +++++++++ .../templates/fipTarget/partInfoList.html | 84 +++++++-- .../fipTarget/partInfoModifyModal.html | 139 +++++++++++++++ ...nfoSelecBox.html => partInfoSelecBox.html} | 0 12 files changed, 674 insertions(+), 30 deletions(-) create mode 100644 src/main/resources/templates/fipTarget/partInfoModifyModal.html rename src/main/resources/templates/fipTarget/{parkInfoSelecBox.html => partInfoSelecBox.html} (100%) diff --git a/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java b/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java index 09533c20..709ae95c 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java @@ -2,25 +2,16 @@ package com.dbnt.faisp.fipTarget; import com.dbnt.faisp.authMgt.service.AuthMgtService; -import com.dbnt.faisp.equip.model.Equip; -import com.dbnt.faisp.equip.model.EquipLog; -import com.dbnt.faisp.equip.service.EquipService; import com.dbnt.faisp.fipTarget.model.PartInfo; import com.dbnt.faisp.fipTarget.service.FipTargetService; import com.dbnt.faisp.organMgt.service.OrganConfigService; -import com.dbnt.faisp.publicBoard.model.PublicBoard; -import com.dbnt.faisp.translator.model.Translator; import com.dbnt.faisp.userInfo.model.UserInfo; import com.dbnt.faisp.util.ParamMap; import com.dbnt.faisp.util.Utils; import lombok.RequiredArgsConstructor; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.time.LocalDateTime; import java.util.List; @@ -43,16 +34,44 @@ public class FipTargetController { private final FipTargetService fipTargetSevice; @GetMapping("/partInfoList") - public ModelAndView partInfoList(@AuthenticationPrincipal UserInfo loginUser,PartInfo partInfo) { + public ModelAndView partInfoList(@AuthenticationPrincipal UserInfo loginUser,PartInfo partInfo, HttpServletResponse response) { ModelAndView mav = new ModelAndView("fipTarget/partInfoList"); + partInfo.setDownOrganCdList(loginUser.getDownOrganCdList()); + //엑셀다운 + if(partInfo.getExcel() != null && partInfo.getExcel().equals("Y")){ + ParamMap header = fipTargetSevice.selectWorkTypeTotal(partInfo); + String[] headers = { "mgt_organ", "land_police", "mp_work_type", "mp_people_cnt", "mp_description", "pl_work_type", "pl_people_cnt", "pl_description", "terminal_nm", "pi_manager_name", "rent_price", "utility_price", "wrt_dt"}; + String[] headerNames = { "해경서", "육경서", "해경", "", "", "육경", "", "", "", "", "", "",""}; + String[] headerNames2 = { "", "", "상주 "+header.getString("mp_sangju")+"개소 "+header.getString("mp_sangju_total")+"명" + ,"상주 "+header.getString("mp_bsangju")+"개소 "+header.getString("mp_bsangju_total")+"명" + ,"상주 "+header.getString("mp_closure")+"개소 "+header.getString("mp_closure_total")+"명" + ,"상주 "+header.getString("pl_sangju")+"개소 "+header.getString("pl_sangju_total")+"명" + ,"상주 "+header.getString("pl_bsangju")+"개소 "+header.getString("pl_bsangju_total")+"명" + ,"상주 "+header.getString("pl_closure")+"개소 "+header.getString("pl_closure_total")+"명" + , "", "", "", "", "" }; + String[] headerNames3 = { "", "", "근무방법", "명", "비고", "근무방법", "명", "비고", "터미널명", "담당자", "임차료", "공공요금", "최종수정일" }; + String[] columnType = { "String", "String", "String", "int", "String", "String", "int", "String", "String", "String", "int","int", "String"}; + String sheetName = "외사 분실 현황"; + String excelFileName = "외사 분실 현황"; + List partInfoList= fipTargetSevice.selectPartInfoList(partInfo); + + try { + Utils.partInfolistToExcel(partInfoList, response, headers, headerNames,headerNames2,headerNames3, columnType, sheetName, excelFileName); + } catch (IOException e) { + + } + return null; + } //메뉴권한 확인 String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/equipStatus").get(0).getAccessAuth(); mav.addObject("accessAuth", accessAuth); partInfo.setDownOrganCdList(loginUser.getDownOrganCdList()); partInfo.setQueryInfo(); + mav.addObject("total", fipTargetSevice.selectWorkTypeTotal(partInfo)); mav.addObject("partInfoList", fipTargetSevice.selectPartInfoList(partInfo)); partInfo.setContentCnt(fipTargetSevice.selectPartInfoListCnt(partInfo)); partInfo.setPaginationInfo(); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); mav.addObject("searchParams", partInfo); return mav; } @@ -67,7 +86,7 @@ public class FipTargetController { @GetMapping("/partInfoSelecBox") public ModelAndView equipTypeSelecBox(String ogCd) { - ModelAndView mav = new ModelAndView("fipTarget/parkInfoSelecBox"); + ModelAndView mav = new ModelAndView("fipTarget/partInfoSelecBox"); ParamMap param = new ParamMap(); param.put("downOrganCdList", organConfigService.selectDownOrganListWhereUserOgCd(ogCd)); mav.addObject("managerList", fipTargetSevice.selectPartInfoManagerList(param)); @@ -85,6 +104,19 @@ public class FipTargetController { fipTargetSevice.savePartInfo(partInfo); } + @GetMapping("/updatePartInfoPage") + public ModelAndView updatePartInfoPage(@AuthenticationPrincipal UserInfo loginUser,PartInfo partInfo) { + ModelAndView mav = new ModelAndView("fipTarget/partInfoModifyModal"); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); + PartInfo partInfoView = fipTargetSevice.selectPartInfo(partInfo); + ParamMap param = new ParamMap(); + param.put("downOrganCdList", organConfigService.selectDownOrganListWhereUserOgCd(partInfoView.getMgtOrgan())); + mav.addObject("managerList", fipTargetSevice.selectPartInfoManagerList(param)); + partInfoView.setFileList(fipTargetSevice.selectPartInfoFile(partInfo)); + mav.addObject("partInfo", partInfoView); + return mav; + } + diff --git a/src/main/java/com/dbnt/faisp/fipTarget/mapper/FipTargetMapper.java b/src/main/java/com/dbnt/faisp/fipTarget/mapper/FipTargetMapper.java index 88f45878..516de93a 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/mapper/FipTargetMapper.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/mapper/FipTargetMapper.java @@ -16,6 +16,10 @@ public interface FipTargetMapper { Integer selectPartInfoListCnt(PartInfo partInfo); + ParamMap selectWorkTypeTotal(PartInfo partInfo); + + PartInfo selectPartInfo(PartInfo partInfo); + diff --git a/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfo.java b/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfo.java index e8ab43e0..92becf1a 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfo.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfo.java @@ -73,6 +73,7 @@ public class PartInfo extends BaseModel implements Serializable{ @Column(name = "wrt_nm") private String wrtNm; @Column(name = "wrt_dt") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") private LocalDateTime wrtDt; @Transient @@ -80,8 +81,17 @@ public class PartInfo extends BaseModel implements Serializable{ @Transient private String piManagerName; + + @Transient + private String excel; + + @Transient + private List fileList; + + + @Override public String toString() { return "PartInfo [piSeq=" + piSeq + ", versionNo=" + versionNo + ", mgtOrgan=" + mgtOrgan + ", piUserSeq=" @@ -90,10 +100,14 @@ public String toString() { + ", mpWorkType=" + mpWorkType + ", mpPeopleCnt=" + mpPeopleCnt + ", mpDescription=" + mpDescription + ", plWorkType=" + plWorkType + ", plPeopleCnt=" + plPeopleCnt + ", plDescription=" + plDescription + ", wrtOrgan=" + wrtOrgan + ", wrtPart=" + wrtPart + ", wrtUserSeq=" + wrtUserSeq + ", wrtNm=" + wrtNm - + ", wrtDt=" + wrtDt + ", multipartFileList=" + multipartFileList + "]"; + + ", wrtDt=" + wrtDt + ", multipartFileList=" + multipartFileList + ", piManagerName=" + piManagerName + + ", fileList=" + fileList + "]"; } + + + @Embeddable @Data @NoArgsConstructor diff --git a/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfoFile.java b/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfoFile.java index a6131b0c..efef2535 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfoFile.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfoFile.java @@ -50,6 +50,15 @@ public class PartInfoFile extends BaseModel implements Serializable{ +@Override +public String toString() { + return "PartInfoFile [fileSeq=" + fileSeq + ", piSeq=" + piSeq + ", versionNo=" + versionNo + ", origNm=" + origNm + + ", convNm=" + convNm + ", fileExtn=" + fileExtn + ", fileSize=" + fileSize + ", filePath=" + filePath + + "]"; +} + + + @Embeddable @Data @NoArgsConstructor diff --git a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoFileRepository.java b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoFileRepository.java index 26d77e08..4bae229c 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoFileRepository.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoFileRepository.java @@ -3,6 +3,8 @@ package com.dbnt.faisp.fipTarget.repository; import com.dbnt.faisp.fipTarget.model.PartInfoFile; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; @@ -11,6 +13,8 @@ public interface PartInfoFileRepository extends JpaRepository findByPiSeqAndVersionNoOrderByFileSeqAsc(Integer piSeq, Integer versionNo); + diff --git a/src/main/java/com/dbnt/faisp/fipTarget/service/FipTargetService.java b/src/main/java/com/dbnt/faisp/fipTarget/service/FipTargetService.java index f011253a..b32e4ad9 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/service/FipTargetService.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/service/FipTargetService.java @@ -3,17 +3,12 @@ package com.dbnt.faisp.fipTarget.service; import com.dbnt.faisp.config.BaseService; -import com.dbnt.faisp.equip.model.Equip; -import com.dbnt.faisp.equip.model.EquipLog; import com.dbnt.faisp.fipTarget.mapper.FipTargetMapper; import com.dbnt.faisp.fipTarget.model.PartInfo; import com.dbnt.faisp.fipTarget.model.PartInfoFile; import com.dbnt.faisp.fipTarget.repository.PartInfoFileRepository; import com.dbnt.faisp.fipTarget.repository.PartInfoRepository; -import com.dbnt.faisp.publicBoard.model.PublicFile; -import com.dbnt.faisp.userInfo.model.UserInfo; import com.dbnt.faisp.util.ParamMap; -import com.dbnt.faisp.util.Utils; import lombok.RequiredArgsConstructor; @@ -97,6 +92,18 @@ public class FipTargetService extends BaseService { public Integer selectPartInfoListCnt(PartInfo partInfo) { return fipTargetMapper.selectPartInfoListCnt(partInfo); } + + public ParamMap selectWorkTypeTotal(PartInfo partInfo) { + return fipTargetMapper.selectWorkTypeTotal(partInfo); + } + + public PartInfo selectPartInfo(PartInfo partInfo) { + return fipTargetMapper.selectPartInfo(partInfo); + } + + public List selectPartInfoFile(PartInfo partInfo) { + return partInfoFileRepository.findByPiSeqAndVersionNoOrderByFileSeqAsc(partInfo.getPiSeq(),partInfo.getVersionNo()); + } diff --git a/src/main/java/com/dbnt/faisp/util/Utils.java b/src/main/java/com/dbnt/faisp/util/Utils.java index 7b77386a..0166118b 100644 --- a/src/main/java/com/dbnt/faisp/util/Utils.java +++ b/src/main/java/com/dbnt/faisp/util/Utils.java @@ -4,7 +4,7 @@ package com.dbnt.faisp.util; import java.io.IOException; import java.io.PrintWriter; - +import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; import java.util.Map; @@ -25,6 +25,8 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFDataFormat; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import com.dbnt.faisp.fipTarget.model.PartInfo; + public class Utils { @@ -373,6 +375,135 @@ public class Utils { } } + + public static void partInfolistToExcel(List partInfoList, HttpServletResponse response, String[] headers, + String[] headerNames,String[] headerNames2,String[] headerNames3, String[] columnType, String sheetName, String excelFileName) throws IOException { + if(Utils.isNotEmpty(partInfoList)) { + // 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다. + XSSFWorkbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet(sheetName); + Row headerRow = sheet.createRow(0); + Row headerRow2 = sheet.createRow(1); + Row headerRow3 = sheet.createRow(2); + CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식 + CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식 + CellStyle headerStyle = wb.createCellStyle(); //숫자양식 + CellStyle headerStyle2 = wb.createCellStyle(); + CellStyle headerStyle3 = wb.createCellStyle(); + + XSSFDataFormat format = wb.createDataFormat(); + cellStyle1.setAlignment(HorizontalAlignment.CENTER); + cellStyle2.setDataFormat(format.getFormat("#,##0")); + cellStyle2.setAlignment(HorizontalAlignment.CENTER); + headerStyle2.setBorderTop(BorderStyle.THIN); + headerStyle2.setBorderBottom(BorderStyle.THIN); + headerStyle2.setBorderLeft(BorderStyle.THIN); + headerStyle2.setBorderRight(BorderStyle.THIN); + headerStyle2.setAlignment(HorizontalAlignment.CENTER); + headerStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle2.setFillForegroundColor((short)3); + headerStyle2.setFillForegroundColor(IndexedColors.LIME.getIndex()); + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle.setFillForegroundColor((short)3); + headerStyle.setFillForegroundColor(IndexedColors.LIME.getIndex()); + headerStyle3.setBorderTop(BorderStyle.THIN); + headerStyle3.setBorderBottom(BorderStyle.THIN); + headerStyle3.setBorderLeft(BorderStyle.THIN); + headerStyle3.setBorderRight(BorderStyle.THIN); + headerStyle3.setAlignment(HorizontalAlignment.CENTER); + headerStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle3.setFillForegroundColor((short)3); + headerStyle3.setFillForegroundColor(IndexedColors.LIME.getIndex()); + + //로우그리기 + for(int i=0; i"); + out.write(""); + out.write(""); + out.write(""); + out.write(""); + out.write(""); + + out.flush(); + out.close(); + } + } diff --git a/src/main/resources/mybatisMapper/FipTarget.xml b/src/main/resources/mybatisMapper/FipTarget.xml index 657fc389..5a80bf90 100644 --- a/src/main/resources/mybatisMapper/FipTarget.xml +++ b/src/main/resources/mybatisMapper/FipTarget.xml @@ -29,6 +29,7 @@ pl_people_cnt, pl_description, (select user_nm from user_info where user_seq = pi_user_seq ) as pi_manager_name, + terminal_nm, rent_type, rent_price, utility_type, @@ -43,8 +44,28 @@ #{item} + + and mgt_organ = #{mgtOrgan} + + + and land_police LIKE CONCAT('%', #{landPolice}, '%') + + + and mp_work_type = #{mpWorkType} + + + and pl_work_type = #{plWorkType} + + + and terminal_nm LIKE CONCAT('%', #{terminalNm}, '%') + + + and to_char(wrt_dt, 'YYYY-MM-DD') = #{startDate} + order by wrt_dt desc - limit #{rowCnt} offset #{firstIndex} + + limit #{rowCnt} offset #{firstIndex} + + + + + \ No newline at end of file diff --git a/src/main/resources/static/js/fipTarget/partInfo.js b/src/main/resources/static/js/fipTarget/partInfo.js index 162d634a..58496871 100644 --- a/src/main/resources/static/js/fipTarget/partInfo.js +++ b/src/main/resources/static/js/fipTarget/partInfo.js @@ -60,6 +60,20 @@ $(document).on('change', '#mgtOrgan', function (){ }); $(document).on('click', '#savePartInfo', function (){ + if($("#rentType").val() == 'Y'){ + if($("#rentPrice").val() == ''){ + alert("임차료를 입력해주세요."); + $('#rentPrice').focus(); + return false; + } + } + if($("#utilityType").val() == 'Y'){ + if($("#utilityPrice").val() == ''){ + alert("공공요금을 입력해주세요."); + $('#utilityPrice').focus(); + return false; + } + } if(confirm("저장하시겠습니까?")){ contentFade("in"); const formData = new FormData($("#partInfoSave")[0]); @@ -86,5 +100,73 @@ $(document).on('click', '#savePartInfo', function (){ } }) +$(document).on('click', '.partInfoTr', function (){ + const piSeq = (Number($(this).find(".piSeq").val())); + const versionNo = (Number($(this).find(".verNo").val())); + const url = '/target/updatePartInfoPage'; + showModal(piSeq,versionNo,url); +}) + +function showModal(piSeq,versionNo,url){ + $.ajax({ + url: url, + data: { + piSeq: piSeq, + versionNo: versionNo + }, + type: 'GET', + dataType:"html", + success: function(html){ + $("#partInfoEditModalEditModalContent").empty().append(html); + $("#partInfoEditModal").modal('show'); + if($("#mRentType").val() != 'Y'){ + $("#mRentPrice").hide(); + } + if($("#mUtilityType").val() != 'Y'){ + $("#mUtilityPrice").hide(); + } + setUploadDiv(); + }, + error:function(){ + + } + }); +} + +$(function(){ + $("#startDate").datepicker({ + format: "yyyy-mm-dd", + language: "ko" + }); +}) + +$(document).on('click', '#goExcel', function (){ + if(confirm("엑셀로 다운로드 하시겠습니까?")){ + $('input[name=excel]').val('Y'); + $('#searchFm').submit(); + $('input[name=excel]').val(''); + }else{ + false; + } +}) + +$(document).on('change', '#mRentType', function (){ + if($("#mRentType").val() == 'Y'){ + $("#mRentPrice").show(); + }else{ + $("#mRentPrice").hide(); + $("#mRentPrice").val(''); + } +}); + +$(document).on('change', '#mUtilityType', function (){ + if($("#mUtilityType").val() == 'Y'){ + $("#mUtilityPrice").show(); + }else{ + $("#mUtilityPrice").hide(); + $("#mUtilityPrice").val(''); + } +}); + diff --git a/src/main/resources/templates/fipTarget/partInfoList.html b/src/main/resources/templates/fipTarget/partInfoList.html index a1740031..105e40ad 100644 --- a/src/main/resources/templates/fipTarget/partInfoList.html +++ b/src/main/resources/templates/fipTarget/partInfoList.html @@ -13,7 +13,7 @@
-
+
@@ -26,10 +26,57 @@
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
@@ -41,15 +88,23 @@ - - + + - - - - - + + + + + + + + + + + + + @@ -60,7 +115,11 @@ - + + + + + @@ -69,12 +128,14 @@ - - + + + + @@ -135,5 +196,6 @@ + \ No newline at end of file diff --git a/src/main/resources/templates/fipTarget/partInfoModifyModal.html b/src/main/resources/templates/fipTarget/partInfoModifyModal.html new file mode 100644 index 00000000..6345eb75 --- /dev/null +++ b/src/main/resources/templates/fipTarget/partInfoModifyModal.html @@ -0,0 +1,139 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/fipTarget/parkInfoSelecBox.html b/src/main/resources/templates/fipTarget/partInfoSelecBox.html similarity index 100% rename from src/main/resources/templates/fipTarget/parkInfoSelecBox.html rename to src/main/resources/templates/fipTarget/partInfoSelecBox.html
해경서육경서해경서육경서 해경 육경터미널명담당자임차료공공요금최종수정일터미널명담당자임차료공공요금최종수정일
근무방법비고