diff --git a/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java b/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java index 63715cdf..ed39d559 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java @@ -5,6 +5,7 @@ import com.dbnt.faisp.authMgt.service.AuthMgtService; import com.dbnt.faisp.fipTarget.model.PartInfo; import com.dbnt.faisp.fipTarget.model.PartInfoFile; import com.dbnt.faisp.fipTarget.model.PartWork; +import com.dbnt.faisp.fipTarget.model.PartWorkFile; import com.dbnt.faisp.fipTarget.service.FipTargetService; import com.dbnt.faisp.organMgt.service.OrganConfigService; import com.dbnt.faisp.userInfo.model.UserInfo; @@ -175,15 +176,12 @@ public class FipTargetController { } @GetMapping("/partInfoFileDownload") - public void fileDownload(HttpServletRequest request, + public void partInfoFileDownload(HttpServletRequest request, HttpServletResponse response, Integer fileSeq, Integer piSeq, Integer versionNo) { - PartInfoFile downloadFile = null; - - downloadFile = fipTargetService.selectPartInfoFileDown(fileSeq, piSeq,versionNo); - + PartInfoFile downloadFile = fipTargetService.selectPartInfoFileDown(fileSeq, piSeq,versionNo); BufferedInputStream in; BufferedOutputStream out; @@ -257,11 +255,26 @@ public class FipTargetController { public ModelAndView partWorkList(@AuthenticationPrincipal UserInfo loginUser,PartWork partWork, HttpServletResponse response) { ModelAndView mav = new ModelAndView("fipTarget/partWorkList"); partWork.setDownOrganCdList(loginUser.getDownOrganCdList()); - - //메뉴권한 확인 + //엑셀다운 + if(partWork.getExcel() != null && partWork.getExcel().equals("Y")){ + String[] headers = { "terminal_nm", "wrt_nm", "work_dt", "work_type_ch", "work_type_poci", "work_type_sri", "work_type_ji", "work_type_mt", "work_type_etc", "description", "file_cnt","wrt_dt"}; + String[] headerNames = { "외사 터미널명", "작성자","일시", "종류", "", "", "", "", "", "비고", "첨부파일", "최근수정일"}; + String[] headerNames2 = { "", "","", "사건처리", "범죄첩보제공", "SRI", "합동점검", "회의", "기타", "", "", ""}; + String[] columnType = { "String", "String","String", "String", "String", "String", "String", "String", "String", "String", "String","String"}; + String sheetName = "외사분실 실적"; + String excelFileName = "외사분실 실적"; + List partWorkList= fipTargetService.selectPartWorkList(partWork); + + try { + Utils.partWorkListToExcel(partWorkList, response, headers, headerNames,headerNames2, columnType, sheetName, excelFileName); + } catch (IOException e) { + + } + return null; + } + //메뉴권한 확인 String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/target/partWorkList").get(0).getAccessAuth(); mav.addObject("accessAuth", accessAuth); - partWork.setQueryInfo(); mav.addObject("partWorkList", fipTargetService.selectPartWorkList(partWork)); partWork.setContentCnt(fipTargetService.selectPartWorkListCnt(partWork)); @@ -313,15 +326,43 @@ public class FipTargetController { MultipartHttpServletRequest request, @RequestParam(value = "fileSeq", required = false) List < Integer > deleteFileSeq){ partWork.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); - partWork.setWrtNm(loginUser.getUserId()); - partWork.setWrtPart(loginUser.getOfcCd()); - partWork.setWrtUserSeq(loginUser.getUserSeq()); - partWork.setWrtOrgan(loginUser.getOgCd()); partWork.setWrtDt(LocalDateTime.now()); fipTargetService.updatePartWork(partWork,deleteFileSeq); return partWork; } + @PostMapping("/deletePartWork") + @ResponseBody + public void deletePartWork(@RequestBody PartWork partWork) { + fipTargetService.deletePartWork(partWork); + } + + @GetMapping("/partWorkFileDownload") + public void partWorkFileDownload(HttpServletRequest request, + HttpServletResponse response, + Integer fileSeq, + Integer pwSeq, + Integer piSeq) { + PartWorkFile downloadFile = fipTargetService.selectPartWorkFileDown(fileSeq, pwSeq,piSeq); + + BufferedInputStream in; + BufferedOutputStream out; + try { + File file = new File(downloadFile.getFilePath(), downloadFile.getConvNm()); + + setDisposition(downloadFile.getOrigNm()+'.'+downloadFile.getFileExtn(), request, response); + in = new BufferedInputStream(new FileInputStream(file)); + out = new BufferedOutputStream(response.getOutputStream()); + FileCopyUtils.copy(in, out); + out.flush(); + if(out!=null) out.close(); + if(in!=null )in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +//외사분실실적 끝 + diff --git a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkFileRepository.java b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkFileRepository.java index 811c1db5..d47c1d2f 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkFileRepository.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkFileRepository.java @@ -1,9 +1,8 @@ package com.dbnt.faisp.fipTarget.repository; -import com.dbnt.faisp.fipTarget.model.PartInfoFile; import com.dbnt.faisp.fipTarget.model.PartWorkFile; -import com.dbnt.faisp.publicBoard.model.PublicFile; + import java.util.List; @@ -19,6 +18,10 @@ public interface PartWorkFileRepository extends JpaRepository findByPwSeqAndPiSeq(Integer pwSeq, Integer piSeq); + void deleteByPwSeqAndPiSeq(Integer pwSeq, Integer piSeq); + + List findByPiSeq(Integer piSeq); + diff --git a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkRepository.java b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkRepository.java index 8a5363ad..2fb186be 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkRepository.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkRepository.java @@ -11,6 +11,10 @@ public interface PartWorkRepository extends JpaRepository partWorkFileList = partWorkFileRepository.findByPiSeq(partInfo.getPiSeq()); + if(partWorkFileList != null) { + for(PartWorkFile file: partWorkFileList){ + deleteStoredFile(new File(file.getFilePath(), file.getConvNm())); + partWorkFileRepository.deleteByPwSeqAndPiSeq(file.getPwSeq(),file.getPiSeq()); + } + } + partWorkRepository.deleteByPiSeq(partInfo.getPiSeq()); + //외사분실운영현황파일삭제 List partInfoFileList= selectPartInfoFile(partInfo); for(PartInfoFile file: partInfoFileList){ if(file.getOrigNm() != null){ @@ -276,6 +285,11 @@ public class FipTargetService extends BaseService { @Transactional public void updatePartWork(PartWork partWork, List deleteFileSeq) { + PartWork dbParkWork = partWorkRepository.findById(new PartWorkId(partWork.getPwSeq(),partWork.getPiSeq())).orElse(null); + partWork.setWrtNm(dbParkWork.getWrtNm()); + partWork.setWrtOrgan(dbParkWork.getWrtOrgan()); + partWork.setWrtPart(dbParkWork.getWrtPart()); + partWork.setWrtUserSeq(dbParkWork.getWrtUserSeq()); partWorkRepository.save(partWork); if(deleteFileSeq!=null && deleteFileSeq.size()>0){ deletePartWorkFile(partWork, deleteFileSeq); @@ -294,6 +308,23 @@ public class FipTargetService extends BaseService { } } } + + @Transactional + public void deletePartWork(PartWork partWork) { + //파일삭제 + List partWorkFileList= partWorkFileRepository.findByPwSeqAndPiSeq(partWork.getPwSeq(),partWork.getPiSeq()); + if(partWorkFileList != null) { + for(PartWorkFile file: partWorkFileList){ + deleteStoredFile(new File(file.getFilePath(), file.getConvNm())); + } + } + partWorkFileRepository.deleteByPwSeqAndPiSeq(partWork.getPwSeq(),partWork.getPiSeq()); + partWorkRepository.deleteByPwSeqAndPiSeq(partWork.getPwSeq(),partWork.getPiSeq()); + } + + public PartWorkFile selectPartWorkFileDown(Integer fileSeq, Integer pwSeq, Integer piSeq) { + return partWorkFileRepository.findById(new PartWorkFileId(fileSeq, pwSeq,piSeq)).orElse(null); + } diff --git a/src/main/java/com/dbnt/faisp/util/Utils.java b/src/main/java/com/dbnt/faisp/util/Utils.java index dfbc54cf..5d881c19 100644 --- a/src/main/java/com/dbnt/faisp/util/Utils.java +++ b/src/main/java/com/dbnt/faisp/util/Utils.java @@ -26,6 +26,7 @@ import org.apache.poi.xssf.usermodel.XSSFDataFormat; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.dbnt.faisp.fipTarget.model.PartInfo; +import com.dbnt.faisp.fipTarget.model.PartWork; public class Utils { @@ -513,6 +514,137 @@ public class Utils { out.close(); } } + + public static void partWorkListToExcel(List partWorkList, HttpServletResponse response, String[] headers, + String[] headerNames, String[] headerNames2, String[] columnType, String sheetName, String excelFileName) throws IOException { + if(Utils.isNotEmpty(partWorkList)) { + // 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다. + XSSFWorkbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet(sheetName); + Row headerRow = sheet.createRow(0); + Row headerRow2 = sheet.createRow(1); + 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 0) { + rowData.set("file_cnt", "●"); + }else { + rowData.set("file_cnt", ""); + } + rowData.set("wrt_dt", partWorkList.get(i).getWrtDt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))); + for(int j=0; j"); + 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 9ae3dac0..723f18d8 100644 --- a/src/main/resources/mybatisMapper/FipTarget.xml +++ b/src/main/resources/mybatisMapper/FipTarget.xml @@ -376,7 +376,9 @@ #{item} order by wrt_dt desc - limit #{rowCnt} offset #{firstIndex} + + limit #{rowCnt} offset #{firstIndex} +
-
+
@@ -23,7 +23,8 @@ -
+
+
@@ -125,7 +126,7 @@
- +
diff --git a/src/main/resources/templates/fipTarget/partWorkModifyModal.html b/src/main/resources/templates/fipTarget/partWorkModifyModal.html index de742434..0fca2542 100644 --- a/src/main/resources/templates/fipTarget/partWorkModifyModal.html +++ b/src/main/resources/templates/fipTarget/partWorkModifyModal.html @@ -10,7 +10,7 @@ - +
@@ -72,7 +72,7 @@ @@ -84,6 +84,11 @@
\ No newline at end of file