fix: 외사분실 실적완료

TaehunPark 2022-10-07 17:47:11 +09:00
parent e6b6655ac3
commit c2a830423c
11 changed files with 292 additions and 25 deletions

View File

@ -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<PartWork> 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();
}
}
//외사분실실적 끝

View File

@ -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<PartWorkFile, Part
List<PartWorkFile> findByPwSeqAndPiSeq(Integer pwSeq, Integer piSeq);
void deleteByPwSeqAndPiSeq(Integer pwSeq, Integer piSeq);
List<PartWorkFile> findByPiSeq(Integer piSeq);

View File

@ -11,6 +11,10 @@ public interface PartWorkRepository extends JpaRepository<PartWork, PartWork.Par
PartWork findTopByPiSeqOrderByPwSeqDesc(Integer piSeq);
void deleteByPwSeqAndPiSeq(Integer pwSeq, Integer piSeq);
void deleteByPiSeq(Integer piSeq);

View File

@ -195,7 +195,16 @@ public class FipTargetService extends BaseService {
@Transactional
public void deletePartInfo(PartInfo partInfo) {
//파일삭제
//외사실적 파일,데이터삭제
List<PartWorkFile> 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<PartInfoFile> 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<Integer> 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<PartWorkFile> 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);
}

View File

@ -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<PartWork> 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<partWorkList.size(); i++) {
ParamMap rowData = new ParamMap();
Row row = sheet.createRow(i+2);
rowData.set("terminal_nm", partWorkList.get(i).getTerminalNm());
rowData.set("wrt_nm", partWorkList.get(i).getWrtNm());
if(partWorkList.get(i).getWorkDt() != null) {
rowData.set("work_dt", partWorkList.get(i).getWorkDt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
}else {
rowData.set("work_dt", "");
}
rowData.set("work_type_ch", partWorkList.get(i).getWorkTypeCh());
rowData.set("work_type_poci", partWorkList.get(i).getWorkTypePoci());
rowData.set("work_type_sri", partWorkList.get(i).getWorkTypeSri());
rowData.set("work_type_ji", partWorkList.get(i).getWorkTypeJi());
rowData.set("work_type_mt", partWorkList.get(i).getWorkTypeMt());
rowData.set("work_type_etc", partWorkList.get(i).getWorkTypeEtc());
rowData.set("description", partWorkList.get(i).getDescription());
if(partWorkList.get(i).getFileCnt() > 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<headers.length; j++) {
Cell cell = row.createCell(j);
if(columnType[j].equalsIgnoreCase("Int")) {
cell.setCellValue(rowData.getInt(headers[j]));
cell.setCellStyle(cellStyle2);
} else if(columnType[j].equalsIgnoreCase("String")) {
cell.setCellValue(rowData.getString(headers[j]));
cell.setCellStyle(cellStyle1);
} else {
cell.setCellValue(rowData.getString(headers[j]));
cell.setCellStyle(cellStyle1);
}
}
}
//헤더
for(int j=0; j<headerNames.length; j++) {
Cell cell = headerRow.createCell(j);
cell.setCellValue(headerNames[j]);
cell.setCellStyle(headerStyle3);
sheet.autoSizeColumn(j);
sheet.setColumnWidth(j, (sheet.getColumnWidth(j)) + 1024);
}
for(int j=0; j<headerNames2.length; j++) {
Cell cell = headerRow2.createCell(j);
cell.setCellValue(headerNames2[j]);
cell.setCellStyle(headerStyle2);
sheet.autoSizeColumn(j);
sheet.setColumnWidth(j, (sheet.getColumnWidth(j)) + 1024);
}
sheet.addMergedRegion(new CellRangeAddress(0,1,0,0));
sheet.addMergedRegion(new CellRangeAddress(0,1,1,1));
sheet.addMergedRegion(new CellRangeAddress(0,1,2,2));
sheet.addMergedRegion(new CellRangeAddress(0,0,3,8));
sheet.addMergedRegion(new CellRangeAddress(0,1,9,9));
sheet.addMergedRegion(new CellRangeAddress(0,1,10,10));
sheet.addMergedRegion(new CellRangeAddress(0,1,11,11));
//엑셀이름 한글깨짐방지
String outputFileName = new String(excelFileName.getBytes("KSC5601"), "8859_1");
response.setHeader("Set-Cookie", "fileDownload=true; path=/");
response.setHeader("Content-Disposition", String.format("attachment; filename=\""+outputFileName+"_"+Utils.getTimeStampString("yyyyMMdd_HHmm")+".xlsx\""));
wb.write(response.getOutputStream());
wb.close();
} else {
response.setHeader("Content-Type", "text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
out.write("<html lang=\"ko\">");
out.write("<head>");
out.write("<script type=\"text/javascript\">");
out.write("alert('데이터가 없습니다.');");
out.write("history.back(-1);");
out.write("</script>");
out.write("</head>");
out.write("</html>");
out.flush();
out.close();
}
}

View File

@ -376,7 +376,9 @@
#{item}
</foreach>
order by wrt_dt desc
limit #{rowCnt} offset #{firstIndex}
<if test='excel != "Y"'>
limit #{rowCnt} offset #{firstIndex}
</if>
</select>
<select id="selectPartWorkListCnt" resultType="int" parameterType="PartWork">
@ -435,6 +437,7 @@
pw.work_info,
work_type,
pw.description,
pw.wrt_nm,
pw.wrt_dt
from part_work pw,
part_info pi,

View File

@ -109,8 +109,10 @@ function setUploadDiv(){
}
}).on('click', function (e){
if(e.target.className.indexOf("ileDelete")<0){
if( e.target.className.indexOf("artInfo")<0){
$("#fileInputer").click();
if(e.target.className.indexOf("artInfo")<0){
if(e.target.className.indexOf("artWork")<0){
$("#fileInputer").click();
}
}
}
});

View File

@ -163,6 +163,51 @@ $(document).on('click', '#updateBtn', function (){
}
})
$(document).on('click', '#deletePartWork', function (){
const pwSeq = $('input[name=pwSeq]').val();
const piSeq = $('#mPiSeq').val();
console.log(piSeq);
if(confirm("삭제하시겠습니까?")){
contentFade("in");
$.ajax({
type : 'POST',
url : "/target/deletePartWork",
data : JSON.stringify({pwSeq:pwSeq,
piSeq:piSeq}),
contentType: 'application/json',
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(data) {
alert("삭제 처리되었습니다.");
location.reload();
},
error : function(xhr, status) {
alert("삭제 처리에 실패하였습니다");
}
})
}
})
$(document).on('click', '.fileDownPartWork', function (){
const target = $(this)
let url = "/target/partWorkFileDownload?"
url += "&fileSeq="+target.attr("data-fileSeq");
url += "&pwSeq="+target.attr("data-pwSeq");
url += "&piSeq="+target.attr("data-piSeq");
window.open(encodeURI(url));
})
$(document).on('click', '#goExcel', function (){
if(confirm("엑셀로 다운로드 하시겠습니까?")){
$('input[name=excel]').val('Y');
$('#searchFm').submit();
$('input[name=excel]').val('');
}else{
false;
}
})
$(document).on('click', '.btn-close', function (){
location.reload();
})

View File

@ -2,7 +2,7 @@
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="modal-header">
<h5 class="modal-title" id="menuEditModalLabel">등록</h5>
<h5 class="modal-title" id="menuEditModalLabel">외사분실 현황등록</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -7,13 +7,13 @@
</th:block>
<div layout:fragment="content">
<main class="pt-3">
<h4>외사 분실 현황</h4>
<h4>외사분실 실적</h4>
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div class="row mx-0">
<div class="col-12 card text-center">
<div class="card-body">
<form id="searchFm" method="get" th:action="@{/target/partInfoList}">
<form id="searchFm" method="get" th:action="@{/target/partWorkList}">
<input type="hidden" name="excel">
<input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
<div class="row justify-content-between pe-3 py-1">
@ -23,7 +23,8 @@
<option th:value="${num*10}" th:text="${num*10}" th:selected="${searchParams.rowCnt==num*10}"></option>
</th:block>
</select>
</div>
</div>
<input type="submit" class="btn btn-sm btn-primary col-auto" id="searchBtn" value="검색">
</div>
</form>
<div class="row justify-content-start">
@ -125,7 +126,7 @@
</ul>
</nav>
<div class="col-auto">
<input type="button" class="btn btn-success" value="등록" id="addPartWork">
<input type="button" class="btn btn-success" value="등록" id="addPartWork" th:unless="${accessAuth eq 'ACC001'}">
<button id="goExcel">엑셀다운</button>
</div>
</div>

View File

@ -10,7 +10,7 @@
<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="pwSeq" th:value="${pwInfo.pwSeq}">
<input type="hidden" name="piSeq" th:value="${pwInfo.piSeq}">
<input type="hidden" id="mPiSeq" name="piSeq" th:value="${pwInfo.piSeq}">
<div class="mb-3 row">
<label for="wrtUserNm" class="col-sm-2 col-form-label text-center">터미널명</label>
<div class="col-sm-4">
@ -72,7 +72,7 @@
<th:block th:unless="${#arrays.isEmpty(pwInfo.fileList)}">
<div class='row-col-6' th:each="infoFile:${pwInfo.fileList}">
<span th:data-fileseq="${infoFile.fileSeq}" th:text="|${infoFile.origNm}.${infoFile.fileExtn} ${infoFile.fileSize}|"></span>
<a href='#' class='fileDownPartInfo text-decoration-none' th:data-fileSeq="${infoFile.fileSeq}" th:data-pwSeq="${infoFile.pwSeq}" th:data-piSeq="${infoFile.piSeq}">다운</a>
<a href='#' class='fileDownPartWork text-decoration-none' th:data-fileSeq="${infoFile.fileSeq}" th:data-pwSeq="${infoFile.pwSeq}" th:data-piSeq="${infoFile.piSeq}">다운</a>
<a href='#' class='uploadedFileDelete text-danger text-decoration-none'>삭제</a>
</div>
</th:block>
@ -84,6 +84,11 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="btn-close" data-bs-dismiss="modal">닫기</button>
<th:block th:if="${userId eq pwInfo.wrtNm} or ${accessAuth eq 'ACC003'}">
<button type="button" class="btn btn-danger" id="deletePartWork">삭제</button>
</th:block>
<th:block th:if="${userId eq pwInfo.wrtNm} or ${accessAuth eq 'ACC003'}"><!--작성자 관리자일 경우 수정 허용-->
<button type="button" class="btn btn-primary" id="updateBtn">수정</button>
</th:block>
</div>
</html>