diff --git a/src/main/java/kr/xit/fims/biz/ec/service/EcCtznSttemntService.java b/src/main/java/kr/xit/fims/biz/ec/service/EcCtznSttemntService.java index 9775432a..540d34e3 100644 --- a/src/main/java/kr/xit/fims/biz/ec/service/EcCtznSttemntService.java +++ b/src/main/java/kr/xit/fims/biz/ec/service/EcCtznSttemntService.java @@ -1,7 +1,15 @@ package kr.xit.fims.biz.ec.service; -import java.util.*; - +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.FileUtils; import org.apache.ibatis.session.RowBounds; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -10,8 +18,13 @@ import org.springframework.transaction.annotation.Transactional; import kr.xit.fims.biz.FimsConst; import kr.xit.fims.biz.ec.mapper.IEcCtznSttemntMapper; import kr.xit.fims.biz.ec.model.CtznStmtDTO; +import kr.xit.fims.biz.ec.model.NatlNewspaperSendXmlDTO; import kr.xit.framework.biz.cmm.model.CmmFileDTO; import kr.xit.framework.biz.cmm.service.ICmmFileService; +import kr.xit.framework.support.exception.BizRuntimeException; +import kr.xit.framework.support.util.Checks; +import kr.xit.framework.support.util.constants.MessageKey; +import kr.xit.framework.support.util.xml.XmlParseUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -26,6 +39,10 @@ public class EcCtznSttemntService implements IEcCtznSttemntService { @Value("#{prop['file.upload.natl-newspaper.path']}") private String uploadNewsPaperPath; + @Value("#{prop['file.res.root']}") + private String uploadResPath; + + private final IEcCtznSttemntMapper mapper; private final ICmmFileService cmmFileService; @@ -112,6 +129,77 @@ public class EcCtznSttemntService implements IEcCtznSttemntService { mapper.updateStatusAndRegltIdOfEcCtznSttemntDetail(dto); } + //----------------------------------------------------- + // 단속 처리 결과 전송 + //----------------------------------------------------- + + @Override + public void sendCtznSttemntRespons(CtznStmtDTO.CtznStmtDtl dto) { + + + + + + List fileDtlList = cmmFileService.findFilesByJobSeCodeAndJobId( + CmmFileDTO.FileMst.builder() + .jobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode()) + .fileJobId(dto.getInterfaceSeqN()+dto.getCtznSttemntDetailSn()) + .build()); + + + + List fileList = new ArrayList<>(); + String tgtPath = null; + for (CmmFileDTO.FileDtl dtl : fileDtlList) { + if (Checks.isEmpty(tgtPath)) + tgtPath = uploadResPath + dtl.getFileCours(); + + try { + // 대상폴더 미 존재시 생성 + File tgtFile = FileUtils.getFile(tgtPath, dtl.getOrginlFileNm()); + + FileUtils.copyFile( + FileUtils.getFile(uploadRoot + dtl.getFileCours(), dtl.getFileId()) + , tgtFile + , true + ); + fileList.add(tgtFile); + + } catch (IOException e) { + throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "단속 응답 데이타 생성시 오류 발생[첨부파일 생성 실패]"); + } + + } + NatlNewspaperSendXmlDTO sendDto = NatlNewspaperSendXmlDTO.builder() + .interfaceSeqN(dto.getInterfaceSeqN()) + .pcdRstContL("1. 교통질서 확립에 힘써주신 점에 대해 감사드립니다.\n" + + "\n" + + "2. 귀하께서 안전신문고를 통해 신청하신 민원에 대한 검토 결과를 다음과 같이 알려드립니다.\n" + + "\n" + + "3. 귀하의 민원내용은 불법 주?정차 신고에 관한 것으로 판단됩니다.\n" + + "\n" + + "4. 귀하의 신고에 대해 검토한 결과는 다음과 같습니다.\n" + + " 가. 해당 차량은 ?도로교통법?제32조, 제33조, 제34조, 제35조에 의거한 불법 주?정차 차량으로 판단됩니다.\n" + + " 나. 따라서, 위반 차량에 대해 주?정차 위반 과태료 부과 처분이 이루어졌음을 알려드립니다.\n" + + "\n" + + "5. 안전을 위한 시민 정신에 감사드리며, 답변 내용에 대한 추가 설명이 필요한 경우 군포시청 차량관리과 주차단속팀 박효주 주무관(☏031-390-0291)에게 연락 주시면 친절히 안내해 드리도록 하겠습니다. 감사합니다.") + .addressV("주소") + .applyGubunC("Y") + .build(); + String xmlStr = XmlParseUtils.writeObjectToXml(sendDto, NatlNewspaperSendXmlDTO.class); + + byte[] bytes = xmlStr.getBytes(); + Path path = Paths.get(tgtPath + "/res.xml"); + try { + Files.write(path, bytes); + } catch (IOException e) { + e.printStackTrace(); + } + fileList.add(path.toFile()); + + log.debug("{}", fileList); + } + @Override @Transactional public void dragAndDropSaveImg(Map paraMap) { diff --git a/src/main/java/kr/xit/fims/biz/ec/service/IEcCtznSttemntService.java b/src/main/java/kr/xit/fims/biz/ec/service/IEcCtznSttemntService.java index 7449cbd0..5efcc5f8 100644 --- a/src/main/java/kr/xit/fims/biz/ec/service/IEcCtznSttemntService.java +++ b/src/main/java/kr/xit/fims/biz/ec/service/IEcCtznSttemntService.java @@ -20,17 +20,21 @@ public interface IEcCtznSttemntService { //----------------------------------------------------- // 단속자료 생성 - 단속 처리 //----------------------------------------------------- - void saveRtReglt(CtznStmtDTO.Request dto); + void saveRtReglt(final CtznStmtDTO.Request dto); //----------------------------------------------------- // 단속자료 생성 - 서손 처리 //----------------------------------------------------- - void saveRtErpp(CtznStmtDTO.Request dto); + void saveRtErpp(final CtznStmtDTO.Request dto); - void dragAndDropSaveImg(MapparaMap); + //----------------------------------------------------- + // 단속 처리 결과 전송 + //----------------------------------------------------- + void sendCtznSttemntRespons(final CtznStmtDTO.CtznStmtDtl dto); + + void dragAndDropSaveImg(final MapparaMap); default String getUserUniqId(){ return XitCmmnUtil.getUserUniqId(); } - } diff --git a/src/main/java/kr/xit/fims/biz/ec/web/EcCctvCrackdownController.java b/src/main/java/kr/xit/fims/biz/ec/web/EcCctvCrackdownController.java index 6c20641b..61b8280f 100644 --- a/src/main/java/kr/xit/fims/biz/ec/web/EcCctvCrackdownController.java +++ b/src/main/java/kr/xit/fims/biz/ec/web/EcCctvCrackdownController.java @@ -145,6 +145,19 @@ public class EcCctvCrackdownController { ); } + @RequestMapping("/sendEcExtrlCrackdownRespons") + public ModelAndView sendEcExtrlCrackdownRespons(final String extrlRegltCntcId, final String regltSeCode) { + return ResultResponse.of( + fileService.findFilesByJobSeCodeAndJobId( + CmmFileDTO.FileMst.builder() + .jobSeCode(getFileJobSeCode(regltSeCode)) + .fileJobId(extrlRegltCntcId) + .build()).stream() + .filter(dtl -> !Objects.equals("png", dtl.getFileExtsn())) + .collect(Collectors.toList()) + ); + } + private static String getFileJobSeCode(String regltSeCode) { // 01 - 고정형CCTV if(Objects.equals(regltSeCode, "01"))//FimsConst.FileJobSeCode.CCTV_FIX)) diff --git a/src/main/java/kr/xit/fims/biz/ec/web/EcCtznSttemntController.java b/src/main/java/kr/xit/fims/biz/ec/web/EcCtznSttemntController.java index 2d943fed..23690c39 100644 --- a/src/main/java/kr/xit/fims/biz/ec/web/EcCtznSttemntController.java +++ b/src/main/java/kr/xit/fims/biz/ec/web/EcCtznSttemntController.java @@ -6,7 +6,11 @@ import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import kr.xit.fims.biz.FimsConst; @@ -140,4 +144,22 @@ public class EcCtznSttemntController { AjaxMessageMapRenderer.success(mav, MessageKey.CMM_SUCCESS); return mav; } + + @RequestMapping("/sendCtznSttemntRespons") + public ModelAndView sendCtznSttemntRespons(final CtznStmtDTO.CtznStmtDtl dto) { + ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); +log.debug(dto.toString()); + service.sendCtznSttemntRespons(dto); + AjaxMessageMapRenderer.success(mav, MessageKey.CMM_SUCCESS); + return mav; + // return ResultResponse.of( + // fileService.findFilesByJobSeCodeAndJobId( + // CmmFileDTO.FileMst.builder() + // .jobSeCode(getFileJobSeCode(regltSeCode)) + // .fileJobId(extrlRegltCntcId) + // .build()).stream() + // .filter(dtl -> !Objects.equals("png", dtl.getFileExtsn())) + // .collect(Collectors.toList()) + // ); + } } diff --git a/src/main/java/kr/xit/framework/support/util/FileUtils.java b/src/main/java/kr/xit/framework/support/util/FileUtils.java new file mode 100644 index 00000000..d9df7600 --- /dev/null +++ b/src/main/java/kr/xit/framework/support/util/FileUtils.java @@ -0,0 +1,72 @@ +package kr.xit.framework.support.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import kr.xit.framework.support.exception.BizRuntimeException; +import kr.xit.framework.support.util.constants.MessageKey; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class FileUtils { + + /** + * zip 파일 생성 + * @param filePath source file path + * @param fileNameList source file name list + * @param zipFilePath zip file folder + * @param zipFileName zip file name + */ + public void compressZip(final String filePath, final List fileNameList, final String zipFilePath, final String zipFileName) { + List fileList = new ArrayList<>(); + + fileNameList.forEach(s -> fileList.add(new File(filePath, s))); + compressZip(fileList, zipFilePath, zipFileName); + } + + /** + * Zip 파일 생성 + * @param fileList zip file name list + * @param zipFilePath zip file folder + * @param zipFileName zip file name + */ + public void compressZip(final List fileList, final String zipFilePath, final String zipFileName) { + File zipFile = new File(zipFilePath, zipFileName); + + byte[] buff = new byte[4096]; + // 압축파일 생성 + try(ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))){ + + // 파일 압축 + fileList.forEach(f -> { + try(FileInputStream fis = new FileInputStream(f)){ + // 압축파일 지정 + ZipEntry ze = new ZipEntry(f.getName()); + zos.putNextEntry(ze); + + // 압축 파일에 추가 + int len; + while ((len = fis.read(buff)) > 0) zos.write(buff, 0, len); + + zos.closeEntry(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + }); + } catch (FileNotFoundException e) { + log.error("zip파일 생성 오류::{}", e.getLocalizedMessage()); + throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "zip 파일생성 오류[대상파일 미존재]"); + } catch (IOException e) { + log.error("zip파일 생성 오류::{}", e.getLocalizedMessage()); + throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "zip 파일생성 오류[대상파일 미존재]"); + } + } +} diff --git a/src/main/java/kr/xit/framework/support/util/xml/XmlParseUtils.java b/src/main/java/kr/xit/framework/support/util/xml/XmlParseUtils.java index 4b952bb7..0e8724b5 100644 --- a/src/main/java/kr/xit/framework/support/util/xml/XmlParseUtils.java +++ b/src/main/java/kr/xit/framework/support/util/xml/XmlParseUtils.java @@ -37,7 +37,7 @@ public class XmlParseUtils { } @SuppressWarnings("UnusedReturnValue") - public static String readObjectToXml(final T t, final Class clz){ + public static String writeObjectToXml(final T t, final Class clz){ StringWriter sw = new StringWriter(); // xml 생성 @@ -82,7 +82,7 @@ public class XmlParseUtils { + "5. 안전을 위한 시민 정신에 감사드리며, 답변 내용에 대한 추가 설명이 필요한 경우 군포시청 차량관리과 주차단속팀 박효주 주무관(☏031-390-0291)에게 연락 주시면 친절히 안내해 드리도록 하겠습니다. 감사합니다.") .addressV("ldlldl") .applyGubunC("Y").build(); - String xmlStr = XmlParseUtils.readObjectToXml(sendDto, NatlNewspaperSendXmlDTO.class); + String xmlStr = XmlParseUtils.writeObjectToXml(sendDto, NatlNewspaperSendXmlDTO.class); log.debug(xmlStr); log.debug("\n\n\n"); diff --git a/src/main/resources/props/dev/globals.properties b/src/main/resources/props/dev/globals.properties index 05101e10..c9825406 100644 --- a/src/main/resources/props/dev/globals.properties +++ b/src/main/resources/props/dev/globals.properties @@ -135,3 +135,5 @@ file.rcv.root=/data/fims/extnl/rcv file.rcv.backup.root=/data/fims/extnl/backup file.rcv.natl-newspaper.path=/natl-newspaper file.rcv.busonly-cctv.path=/busonly + +file.res.root=/data/fims/extnl/res diff --git a/src/main/resources/props/local/globals.properties b/src/main/resources/props/local/globals.properties index a7d48b19..0d3cf3c7 100644 --- a/src/main/resources/props/local/globals.properties +++ b/src/main/resources/props/local/globals.properties @@ -137,3 +137,5 @@ file.rcv.root=D:/data/fims/extnl/rcv file.rcv.backup.root=D:/data/fims/extnl/backup file.rcv.natl-newspaper.path=/natl-newspaper file.rcv.busonly-cctv.path=/busonly + +file.res.root=D:/data/fims/extnl/res diff --git a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCtznSttemntMgtForm.jsp b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCtznSttemntMgtForm.jsp index b099e6d0..b3ad0df3 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCtznSttemntMgtForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCtznSttemntMgtForm.jsp @@ -115,6 +115,16 @@ pageId = GRID.store.data.rawData[props.rowKey]; fnBiz.pagePopup('detail', {interfaceSeqN: rowData.interfaceSeqN, ctznSttemntDetailSn: rowData.ctznSttemntDetailSn}); } + ,onClickSendResponse: function(props){ + const rowData = props.grid.getRow(props.rowKey); + + cmmBizAjax('단속 데이타 전송 처리', { + url: '' + , data: rowData + }) + + //fnBiz.pagePopup('sendResponse', {data: rowData}); + } } /************************************************************************** @@ -207,7 +217,7 @@ }, { header: '처리상태', - name: 'ctznSttemntProcessSttus', + name: 'ctznSttemntDetailProcessSttus', minWidth: 80, sortable: false, align: 'center' @@ -242,6 +252,28 @@ formatter({value}){ return setDateTimeFmt(value); } + }, + { + header: '단속', + name: '단속', + minWidth: 130, + sortable: false, + align: 'center', + renderer: { + type: CustomButtonRenderer, + options: { + formatter: (props)=>{ + if(props.grid.getRow(props.rowKey).ctznSttemntDetailProcessSttus === '01') { + return { + formatter: '단속처리' + , element: "text" + } + } + } + ,eventFunction: fnBiz.onClickSendResponse + ,eventType: "click" + } + } } ]; diff --git a/src/main/webapp/WEB-INF/jsp/framework/layouts/tiles/biz/cmmn/BizIncludeBase.jsp b/src/main/webapp/WEB-INF/jsp/framework/layouts/tiles/biz/cmmn/BizIncludeBase.jsp index 735c830f..10f49287 100644 --- a/src/main/webapp/WEB-INF/jsp/framework/layouts/tiles/biz/cmmn/BizIncludeBase.jsp +++ b/src/main/webapp/WEB-INF/jsp/framework/layouts/tiles/biz/cmmn/BizIncludeBase.jsp @@ -92,12 +92,11 @@ // blockUI 적용 $(document).ajaxStart(function(handler){ const br = '
'; - const msg = '처리중...'+br; + const msg = '처리중...'; const loading = '조회 프로그래스바'; // const loading = '

진행상항

'; $.blockUI({ message : br+msg+br+br+loading+br+br}); }).ajaxStop(function(){ - //closeBar(); $.unblockUI(); }); diff --git a/src/main/webapp/resources/framework/js/cmm/XitCmmnUtil.js b/src/main/webapp/resources/framework/js/cmm/XitCmmnUtil.js index fb09ebf6..c5c7ecdb 100644 --- a/src/main/webapp/resources/framework/js/cmm/XitCmmnUtil.js +++ b/src/main/webapp/resources/framework/js/cmm/XitCmmnUtil.js @@ -297,10 +297,11 @@ const cmmBizAjax = (workType, param, isPopup = true) => { if(workType === 'add') confirmMsg = `등록 ${confirmMsg}`; else if(workType === 'modify') confirmMsg = `변경 ${confirmMsg}`; else if(workType === 'remove') confirmMsg = `삭제 ${confirmMsg}`; - else{ - alert('workType이 부정확 합니다.'); - return false; - } + else confirmMsg = `${workType} ${confirmMsg}`; + // else{ + // alert('workType이 부정확 합니다.'); + // return false; + // } param = $.extend(param, { success: ()=>{