fix:외사분실현황 완료

TaehunPark 2022-10-05 14:25:34 +09:00
parent 00c2f04f63
commit e7b600a9a6
11 changed files with 189 additions and 50 deletions

View File

@ -3,24 +3,29 @@ package com.dbnt.faisp.fipTarget;
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.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.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.ui.Model;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
@ -43,22 +48,22 @@ public class FipTargetController {
//엑셀다운
if(partInfo.getExcel() != null && partInfo.getExcel().equals("Y")){
ParamMap header = fipTargetService.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[] headers = { "mgt_organ", "land_police", "terminal_nm", "mp_work_type", "mp_people_cnt", "mp_description", "pl_work_type", "pl_people_cnt", "pl_description", "pi_manager_name", "rent_price", "utility_price", "wrt_dt"};
String[] headerNames = { "해경서", "육경서","터미넡명", "해경", "", "", "육경", "", "", "", "", "",""};
String[] headerNames2 = null;
if(header != null) {
headerNames2 = new String[] { "", "", "상주 "+header.getString("mp_sangju")+"개소 "+header.getString("mp_sangju_total")+"명"
headerNames2 = new String[] { "", "", "", "상주 "+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")+"명"
, "", "", "", "", "" };
, "", "", "", "" };
}else {
headerNames2 = new String[] { "", "", "상주 0개소 0명","비상주 0개소 0명","폐쇄 0개소 0명","상주 0개소 0명","비상주 0개소 0명","폐쇄 0개소 0명", "", "", "", "", "" };
headerNames2 = new String[] { "", "","", "상주 0개소 0명","비상주 0개소 0명","폐쇄 0개소 0명","상주 0개소 0명","비상주 0개소 0명","폐쇄 0개소 0명", "", "", "", "" };
}
String[] headerNames3 = { "", "", "근무방법", "명", "비고", "근무방법", "명", "비고", "터미널명", "담당자", "임차료", "공공요금", "최종수정일" };
String[] columnType = { "String", "String", "String", "int", "String", "String", "int", "String", "String", "String", "String","String", "String"};
String[] headerNames3 = { "", "","", "근무방법", "명", "비고", "근무방법", "명", "비고", "담당자", "임차료", "공공요금", "최종수정일" };
String[] columnType = { "String", "String","String", "String", "int", "String", "String", "int", "String", "String", "String","String", "String"};
String sheetName = "외사 분실 현황";
String excelFileName = "외사 분실 현황";
List<PartInfo> partInfoList= fipTargetService.selectPartInfoList(partInfo);
@ -71,7 +76,7 @@ public class FipTargetController {
return null;
}
//메뉴권한 확인
String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/equipStatus").get(0).getAccessAuth();
String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/target/partInfoList").get(0).getAccessAuth();
mav.addObject("accessAuth", accessAuth);
partInfo.setDownOrganCdList(loginUser.getDownOrganCdList());
partInfo.setQueryInfo();
@ -122,6 +127,11 @@ public class FipTargetController {
mav.addObject("managerList", fipTargetService.selectPartInfoManagerList(param));
partInfoView.setFileList(fipTargetService.selectPartInfoFile(partInfo));
mav.addObject("partInfo", partInfoView);
//메뉴권한 확인
String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/target/partInfoList").get(0).getAccessAuth();
mav.addObject("accessAuth", accessAuth);
mav.addObject("userId", loginUser.getUserId());
mav.addObject("wrtId", fipTargetService.selectPartInfoFirstId(partInfo));
return mav;
}
@ -132,6 +142,7 @@ public class FipTargetController {
partInfo.setMultipartFileList(request.getMultiFileMap().get("uploadFiles"));
partInfo.setWrtUserSeq(loginUser.getUserSeq());
partInfo.setWrtNm(loginUser.getUserId());
partInfo.setWrtOrgan(loginUser.getOgCd());
partInfo.setWrtPart(loginUser.getOfcCd());
partInfo.setWrtDt(LocalDateTime.now());
fipTargetService.updatePartInfo(partInfo,deleteFileSeq);
@ -158,6 +169,84 @@ public class FipTargetController {
public void deletePartInfo(@RequestBody PartInfo partInfo) {
fipTargetService.deletePartInfo(partInfo);
}
@GetMapping("/partInfoFileDownload")
public void fileDownload(HttpServletRequest request,
HttpServletResponse response,
Integer fileSeq,
Integer piSeq,
Integer versionNo) {
PartInfoFile downloadFile = null;
downloadFile = fipTargetService.selectPartInfoFileDown(fileSeq, piSeq,versionNo);
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();
}
}
private void setDisposition(String filename, HttpServletRequest request, HttpServletResponse response) throws IOException {
String browser = getBrowser(request);
String dispositionPrefix = "attachment; filename=";
String encodedFilename = null;
if (browser.equals("MSIE")) {
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
} else if (browser.equals("Trident")) { // IE11 문자열 깨짐 방지
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
} else if (browser.equals("Firefox")) {
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
} else if (browser.equals("Opera")) {
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
} else if (browser.equals("Chrome")) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < filename.length(); i++) {
char c = filename.charAt(i);
if (c > '~') {
sb.append(URLEncoder.encode("" + c, "UTF-8"));
} else {
sb.append(c);
}
}
encodedFilename = sb.toString();
} else {
throw new IOException("Not supported browser");
}
response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename);
if ("Opera".equals(browser)) {
response.setContentType("application/octet-stream;charset=UTF-8");
}
}
private String getBrowser(HttpServletRequest request) {
String header = request.getHeader("User-Agent");
if (header.indexOf("MSIE") > -1) {
return "MSIE";
} else if (header.indexOf("Trident") > -1) { // IE11 문자열 깨짐 방지
return "Trident";
} else if (header.indexOf("Chrome") > -1) {
return "Chrome";
} else if (header.indexOf("Opera") > -1) {
return "Opera";
}
return "Firefox";
}
//외사분실 운영현황 끝

View File

@ -29,6 +29,8 @@ public interface FipTargetMapper {
List<PartInfoFile> selectPartInfoFileHistoryView(PartInfo partInfo);
String selectPartInfoFirstId(Integer piSeq);

View File

@ -3,6 +3,7 @@ package com.dbnt.faisp.fipTarget.service;
import com.dbnt.faisp.config.BaseService;
import com.dbnt.faisp.config.FileInfo;
import com.dbnt.faisp.equip.model.Equip;
import com.dbnt.faisp.equip.model.Equip.EquipId;
import com.dbnt.faisp.fipTarget.mapper.FipTargetMapper;
@ -135,8 +136,7 @@ public class FipTargetService extends BaseService {
partTmp.setWrtUserSeq(partInfo.getWrtUserSeq());
partTmp.setWrtNm(partInfo.getWrtNm());
partTmp.setWrtPart(partInfo.getWrtPart());
//첫번째 작성자 관서그대로입력
partTmp.setWrtOrgan(dbPart.getWrtOrgan());
partTmp.setWrtOrgan(partInfo.getWrtOrgan());
partTmp.setWrtDt(partInfo.getWrtDt());
partInfoRepository.save(partTmp);
//업데이트하는 버전 파일조회
@ -198,6 +198,14 @@ public class FipTargetService extends BaseService {
partInfoRepository.deleteByPiSeq(partInfo.getPiSeq());
}
public PartInfoFile selectPartInfoFileDown(Integer fileSeq, Integer piSeq, Integer versionNo) {
return partInfoFileRepository.findById(new PartInfoFileId(fileSeq, piSeq,versionNo)).orElse(null);
}
public String selectPartInfoFirstId(PartInfo partInfo) {
return fipTargetMapper.selectPartInfoFirstId(partInfo.getPiSeq());
}

View File

@ -422,13 +422,13 @@ public class Utils {
Row row = sheet.createRow(i+3);
rowData.set("mgt_organ", partInfoList.get(i).getMgtOrgan());
rowData.set("land_police", partInfoList.get(i).getLandPolice());
rowData.set("terminal_nm", partInfoList.get(i).getTerminalNm());
rowData.set("mp_work_type", partInfoList.get(i).getMpWorkType());
rowData.set("mp_people_cnt", partInfoList.get(i).getMpPeopleCnt());
rowData.set("mp_description", partInfoList.get(i).getMpDescription());
rowData.set("pl_work_type", partInfoList.get(i).getPlWorkType());
rowData.set("pl_people_cnt", partInfoList.get(i).getPlPeopleCnt());
rowData.set("pl_description", partInfoList.get(i).getPlDescription());
rowData.set("terminal_nm", partInfoList.get(i).getTerminalNm());
rowData.set("pi_manager_name", partInfoList.get(i).getPiManagerName());
if(partInfoList.get(i).getRentType().equals("Y")) {
rowData.set("rent_price", partInfoList.get(i).getRentPrice().toString()+"만");
@ -482,9 +482,10 @@ public class Utils {
}
sheet.addMergedRegion(new CellRangeAddress(0,2,0,0));
sheet.addMergedRegion(new CellRangeAddress(0,2,1,1));
sheet.addMergedRegion(new CellRangeAddress(0,0,2,4));
sheet.addMergedRegion(new CellRangeAddress(0,0,5,7));
sheet.addMergedRegion(new CellRangeAddress(0,1,8,12));
sheet.addMergedRegion(new CellRangeAddress(0,2,2,2));
sheet.addMergedRegion(new CellRangeAddress(0,0,3,5));
sheet.addMergedRegion(new CellRangeAddress(0,0,6,8));
sheet.addMergedRegion(new CellRangeAddress(0,1,9,12));
//엑셀이름 한글깨짐방지
String outputFileName = new String(excelFileName.getBytes("KSC5601"), "8859_1");

View File

@ -40,7 +40,7 @@
from part_info group by pi_seq) b
where pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
and wrt_organ in
and mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
@ -93,7 +93,7 @@
from part_info group by pi_seq) b
where pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
and wrt_organ in
and mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
@ -186,7 +186,7 @@
from part_info group by pi_seq) b
where pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
and wrt_organ in
and mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
@ -311,5 +311,13 @@
where pi_seq = #{piSeq}
and version_no = #{versionNo}
</select>
<select id="selectPartInfoFirstId" resultType="String" parameterType="int">
select wrt_nm
from part_info
where pi_seq = #{piSeq}
order by version_no asc
limit 1
</select>
</mapper>

View File

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

View File

@ -93,6 +93,11 @@ $(document).on('click', '#savePartInfo', function (){
$('#piUserSeq').focus();
return false;
}
if($('#terminalNm').val() == ''){
alert('터미널명을 입력해주세요');
$('#terminalNm').focus();
return false;
}
if($('#mpWorkType').val() != ''){
if($('#mpPeopleCnt').val() == ''){
alert('해경 인원수를 입력해주세요');
@ -223,6 +228,11 @@ $(document).on('click', '#updatePartInfo', function (){
$('#mPiUserSeq').focus();
return false;
}
if($('#mTerminalNm').val() == ''){
alert('터미널명을 입력해주세요');
$('#mTerminalNm').focus();
return false;
}
if($('#mMpWorkType').val() != ''){
if($('#mMpPeopleCnt').val() == ''){
alert('해경 인원수를 입력해주세요');
@ -370,4 +380,22 @@ $(document).on('click', '#deletePartInfo', function (){
}
})
$(document).on('click', '.fileDownPartInfo', function (){
const target = $(this)
let url = "/target/partInfoFileDownload?"
url += "&fileSeq="+target.attr("data-fileSeq");
url += "&piSeq="+target.attr("data-piSeq");
url += "&versionNo="+target.attr("data-verNo");
window.open(encodeURI(url));
})
$(document).on('click', '#closeModal', function (){
location.reload();
})
$(document).on('click', '#btn-close', function (){
location.reload();
})

View File

@ -34,6 +34,12 @@
</select>
</div>
</div>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">터미널명</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="terminalNm" name="terminalNm" placeholder="직접입력">
</div>
</div>
<br><br>
<h6>해경</h6>
<div class="mb-3 row">
@ -75,13 +81,7 @@
<input type="text" class="form-control" id="plDescription" name="plDescription">
</div>
</div>
<br><br>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">터미널명</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="terminalNm" name="terminalNm" placeholder="직접입력">
</div>
</div>
<br><br>
<div class="mb-3 row">
<label for="ofcCd" class="col-sm-2 col-form-label text-center">임차료</label>
<div class="col-sm-2">
@ -122,7 +122,7 @@
</div>
<div class="modal-footer justify-content-between">
<div class="col-auto">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
<button type="button" id="btn-close" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
<button type="button" class="btn btn-primary" id="savePartInfo">저장</button>
</div>
</div>

View File

@ -68,6 +68,12 @@
<input type="text" class="form-control" id="hPiUserSeq" readonly>
</div>
</div>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">터미널명</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="hTerminalNm" readonly>
</div>
</div>
<br>
<h6>해경</h6>
<div class="mb-3 row">
@ -106,12 +112,6 @@
</div>
</div>
<br>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">터미널명</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="hTerminalNm" readonly>
</div>
</div>
<div class="mb-3 row">
<label for="ofcCd" class="col-sm-2 col-form-label text-center">임차료</label>
<div class="col-sm-3">
@ -140,7 +140,7 @@
</div>
<div class="modal-footer justify-content-between">
<div class="col-auto">
<button type="button" class="btn btn-secondary"
<button type="button" id="btn-close" class="btn btn-secondary"
data-bs-dismiss="modal">닫기</button>
</div>
</div>

View File

@ -90,9 +90,9 @@
<tr>
<th rowspan="3">해경서</th>
<th rowspan="3">육경서</th>
<th colspan="3">해경</th>
<th colspan="3">육경</th>
<th rowspan="3">터미널명</th>
<th colspan="3">해경</th>
<th colspan="3">육경</th>
<th rowspan="3">담당자</th>
<th rowspan="3">임차료</th>
<th rowspan="3">공공요금</th>
@ -132,13 +132,13 @@
</th:block>
<td th:text="${pi.mgtOrgan}"></td>
<td th:text="${pi.landPolice}"></td>
<td th:text="${pi.terminalNm}"></td>
<td th:text="${pi.mpWorkType}"></td>
<td th:text="${pi.mpPeopleCnt}"></td>
<td th:text="${pi.mpDescription}"></td>
<td th:text="${pi.plWorkType}"></td>
<td th:text="${pi.plPeopleCnt}"></td>
<td th:text="${pi.plDescription}"></td>
<td th:text="${pi.terminalNm}"></td>
<td th:text="${pi.plDescription}"></td>
<td th:text="${pi.piManagerName}"></td>
<td th:text="|${pi.rentPrice}만|" th:if="${pi.rentType eq 'Y'}"></td>
<td th:unless="${pi.rentType eq 'Y'}">무상</td>
@ -175,7 +175,7 @@
</ul>
</nav>
<div class="col-auto">
<input type="button" class="btn btn-success" value="등록" id="addPartInfo" >
<input type="button" class="btn btn-success" value="등록" id="addPartInfo" th:unless="${accessAuth eq 'ACC001'}">
<button id="goExcel">엑셀다운</button>
</div>
</div>

View File

@ -47,6 +47,12 @@
</select>
</div>
</div>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">터미널명</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="mTerminalNm" name="terminalNm" th:value="${partInfo.terminalNm}" placeholder="직접입력">
</div>
</div>
<br><br>
<h6>해경</h6>
<div class="mb-3 row">
@ -89,12 +95,6 @@
</div>
</div>
<br><br>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">터미널명</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="terminalNm" name="terminalNm" th:value="${partInfo.terminalNm}" placeholder="직접입력">
</div>
</div>
<div class="mb-3 row">
<label for="ofcCd" class="col-sm-2 col-form-label text-center">임차료</label>
<div class="col-sm-2">
@ -131,6 +131,7 @@
<th:block th:unless="${#strings.isEmpty(partInfo.fileList[0].origNm)}">
<div class='row-col-6' th:each="infoFile:${partInfo.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-piSeq="${infoFile.piSeq}" th:data-verNo="${infoFile.versionNo}">다운</a>
<a href='#' class='uploadedFileDelete text-danger text-decoration-none'>삭제</a>
</div>
</th:block>
@ -143,9 +144,9 @@
</div>
<div class="modal-footer justify-content-between">
<div class="col-auto">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
<button type="button" class="btn btn-danger" id="deletePartInfo">삭제</button>
<button type="button" class="btn btn-primary" id="updatePartInfo">수정</button>
<button type="button" class="btn btn-secondary" id="btn-close" data-bs-dismiss="modal">닫기</button>
<button type="button" class="btn btn-danger" id="deletePartInfo" th:if="${accessAuth eq 'ACC003'} or ${wrtId eq userId}">삭제</button>
<button type="button" class="btn btn-primary" id="updatePartInfo" th:if="${accessAuth eq 'ACC003'} or ${wrtId eq userId}">수정</button>
</div>
</div>
</html>