diff --git a/src/main/java/cokr/xit/adds/DocController.java b/src/main/java/cokr/xit/adds/DocController.java deleted file mode 100644 index 9ca2ccb..0000000 --- a/src/main/java/cokr/xit/adds/DocController.java +++ /dev/null @@ -1,248 +0,0 @@ -package cokr.xit.adds; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import javax.annotation.Resource; - -import org.egovframe.rte.fdl.string.EgovStringUtil; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.servlet.ModelAndView; - -import cokr.xit.adds.cmmn.hwp.format.DisposeProcessDetails; -import cokr.xit.adds.cmmn.hwp.format.DisposeResultReport; -import cokr.xit.applib.Print; -import cokr.xit.applib.PrintOption; -import cokr.xit.base.file.FileInfo; -import cokr.xit.base.file.FileInfo.Relation; -import cokr.xit.base.file.service.FileQuery; -import cokr.xit.base.file.service.FileService; -import cokr.xit.foundation.data.DataObject; -import cokr.xit.foundation.web.AbstractController; - -@Controller -@RequestMapping(value="/doc") -public class DocController extends AbstractController { - - @Resource(name="fileService") - FileService fileService; - - @RequestMapping(value="/makeDisposeResultReportHwp.do") - public ModelAndView makeDisposeResultReportHwp(String dscdmngId) { - - ModelAndView mav = new ModelAndView(); - mav.setViewName("jsonView"); - - if(dscdmngId == null || dscdmngId.equals("")) { - - return mav; - } - - - //출력일시,출력작업자 - Print print = new Print(); - print.setPrintRequestUserInfo(currentUser()); - - //개인정보표시여부,기관장 등 - PrintOption printOption = new PrintOption(); - Map globalVariable = new HashMap(); - printOption.setGlobalVariable(globalVariable); - - //상품 사진 갯수 체크 - List totalProduct = fileService.getFileList( - new FileQuery().setInfoKeys(dscdmngId).setInfoType("100") - ); - int totalProductCnt = 0; - if(totalProduct != null && !totalProduct.isEmpty()) { - totalProductCnt = totalProduct.size(); - } - - //샘플 데이터 생성 - List dataobjectList = this.makeSample(dscdmngId,totalProductCnt); - - for(DataObject data : dataobjectList) { - String infKey = data.string("dscdmngId"); - String subType = data.string("dscdmngSn"); - - List fileinfo = fileService.getFileList( - new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType) - ); - if(fileinfo == null || fileinfo.isEmpty()) { - data.put("filePath", ""); - } else { - data.put("filePath", fileinfo.get(0).string("FILE_PATH")); - } - - } - - DisposeResultReport form = new DisposeResultReport(print, printOption, dataobjectList); - String resultFilePath = form.makeFile().andGetPath(); - - File file = new File(resultFilePath); - Relation rel = new Relation().setInfoType("200").setSubType("01").setInfoKey(dscdmngId); - FileInfo fileInfo = new FileInfo.Factory().create(rel, file); - fileInfo.setName(print.getFormatKorName()+".hwp"); - int effected= fileService.create(fileInfo); - String fileId = fileInfo.getId(); - file.delete(); - - mav.addObject("fileId",fileId); - return mav; - } - - - - @RequestMapping(value="/makeDisposeProcessDetailsHwp.do") - public ModelAndView makeDisposeProcessDetailsHwp(String dscdmngId) { - - ModelAndView mav = new ModelAndView(); - mav.setViewName("jsonView"); - - if(dscdmngId == null || dscdmngId.equals("")) { - - return mav; - } - - //출력일시,출력작업자 - Print print = new Print(); - print.setPrintRequestUserInfo(currentUser()); - - //개인정보표시여부,기관장 등 - PrintOption printOption = new PrintOption(); - Map globalVariable = new HashMap(); - printOption.setGlobalVariable(globalVariable); - - //폐기증거사진 - List dsuseimgs = fileService.getFileList( - new FileQuery().setInfoType("110").setInfoKeys(dscdmngId) - ); - List dataobjectList2 = new ArrayList<>(); - for(DataObject dsuseimg : dsuseimgs) { - dataobjectList2.add(dsuseimg.string("FILE_PATH")); - } - - //상품사진갯수 체크 - List totalProduct = fileService.getFileList( - new FileQuery().setInfoKeys(dscdmngId).setInfoType("100").setOrderBy("SUB_TYPE") - ); - int totalProductCnt = 0; - if(totalProduct != null && !totalProduct.isEmpty()) { - totalProductCnt = totalProduct.size(); - } - - //샘플 데이터 생성 - List dataobjectList = this.makeSample(dscdmngId,totalProductCnt); - - for(DataObject data : dataobjectList) { - String infKey = data.string("dscdmngId"); - String subType = data.string("dscdmngSn"); - - List fileinfo = fileService.getFileList( - new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType) - ); - if(fileinfo == null || fileinfo.isEmpty()) { - data.put("filePath", ""); - } else { - data.put("filePath", fileinfo.get(0).string("FILE_PATH")); - } - - } - - DisposeProcessDetails form = new DisposeProcessDetails(print, printOption, dataobjectList, dataobjectList2); - String resultFilePath = form.makeFile().andGetPath(); - - File file = new File(resultFilePath); - Relation rel = new Relation().setInfoType("200").setSubType("02").setInfoKey(dscdmngId); - FileInfo fileInfo = new FileInfo.Factory().create(rel, file); - fileInfo.setName(print.getFormatKorName()+".hwp"); - int effected= fileService.create(fileInfo); - String fileId = fileInfo.getId(); - file.delete(); - - mav.addObject("fileId",fileId); - return mav; - } - - - public List makeSample(String dscdmngId, int totalProductCnt){ - List dataobjectList = new ArrayList(); - - for(int i=0; i fileInfos = fileService.getFileList(fileQuery); @@ -138,6 +150,114 @@ public class AddsNimsController extends ApplicationController { return setCollectionInfo(new ModelAndView("jsonView"), dsuseMgtDocService.getDsuseMgtDocList(query),"",""); } + + @RequestMapping(value="/makeDisposeResultReportHwp.do", name="폐기결과보고서 HWP파일 생성") + public ModelAndView makeDisposeResultReportHwp(String dtls) { + + ModelAndView mav = new ModelAndView(); + mav.setViewName("jsonView"); + + List dataForDoc = fromJson(dtls, new TypeReference>() {}); + + //출력일시,출력작업자 + Print print = new Print(); + print.setPrintRequestUserInfo(currentUser()); + + //개인정보표시여부,기관장 등 + PrintOption printOption = new PrintOption(); + Map globalVariable = new HashMap(); + printOption.setGlobalVariable(globalVariable); + + + for(DataObject data : dataForDoc) { + String infKey = data.string("dscdmngId"); + String subType = data.string("dscdmngSn"); + + List fileinfo = fileService.getFileList( + new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType) + ); + if(fileinfo == null || fileinfo.isEmpty()) { + data.put("filePath", ""); + } else { + data.put("filePath", fileinfo.get(0).string("FILE_PATH")); + } + + } + + DisposeResultReport form = new DisposeResultReport(print, printOption, dataForDoc); + String resultFilePath = form.makeFile().andGetPath(); + + File file = new File(resultFilePath); + Relation rel = new Relation().setInfoType("200").setSubType("01").setInfoKey(dataForDoc.get(0).string("dscdmngId")); + FileInfo fileInfo = new FileInfo.Factory().create(rel, file); + fileInfo.setName(print.getFormatKorName()+".hwp"); + int effected= fileService.create(fileInfo); + String fileId = fileInfo.getId(); + file.delete(); + + mav.addObject("fileId",fileId); + mav.addObject("saved", true); + return mav; + } + + + + @RequestMapping(value="/makeDisposeProcessDetailsHwp.do", name="폐기 처리 내역 및 사진 HWP파일 생성") + public ModelAndView makeDisposeProcessDetailsHwp(String dtls) { + + ModelAndView mav = new ModelAndView(); + mav.setViewName("jsonView"); + + List dataForDoc = fromJson(dtls, new TypeReference>() {}); + + //출력일시,출력작업자 + Print print = new Print(); + print.setPrintRequestUserInfo(currentUser()); + + //개인정보표시여부,기관장 등 + PrintOption printOption = new PrintOption(); + Map globalVariable = new HashMap(); + printOption.setGlobalVariable(globalVariable); + + //폐기증거사진 + List dsuseimgs = fileService.getFileList( + new FileQuery().setInfoType("110").setInfoKeys(dataForDoc.get(0).string("dscdmngId")) + ); + List dsuseimgPaths = new ArrayList<>(); + for(DataObject dsuseimg : dsuseimgs) { + dsuseimgPaths.add(dsuseimg.string("FILE_PATH")); + } + + for(DataObject data : dataForDoc) { + String infKey = data.string("dscdmngId"); + String subType = data.string("dscdmngSn"); + + List fileinfo = fileService.getFileList( + new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType) + ); + if(fileinfo == null || fileinfo.isEmpty()) { + data.put("filePath", ""); + } else { + data.put("filePath", fileinfo.get(0).string("FILE_PATH")); + } + + } + + DisposeProcessDetails form = new DisposeProcessDetails(print, printOption, dataForDoc, dsuseimgPaths); + String resultFilePath = form.makeFile().andGetPath(); + + File file = new File(resultFilePath); + Relation rel = new Relation().setInfoType("200").setSubType("02").setInfoKey(dataForDoc.get(0).string("dscdmngId")); + FileInfo fileInfo = new FileInfo.Factory().create(rel, file); + fileInfo.setName(print.getFormatKorName()+".hwp"); + int effected= fileService.create(fileInfo); + String fileId = fileInfo.getId(); + file.delete(); + + mav.addObject("fileId",fileId); + mav.addObject("saved", true); + return mav; + } //------------------------------------------------------------------------------------------------- // 보고 문서 관리 //------------------------------------------------------------------------------------------------- @@ -200,6 +320,7 @@ public class AddsNimsController extends ApplicationController { mav.addObject("DEPTList", deptList); mav.addObject("pageName", "dsuseMgtDoc"); + mav.addObject("apiHost", apiHost); return mav; } //------------------------------------------------------------------------------------------------- diff --git a/src/main/resources/template/hwp/dispose_result_report.hwp b/src/main/resources/template/hwp/dispose_result_report.hwp index f3d8469..a13b219 100644 Binary files a/src/main/resources/template/hwp/dispose_result_report.hwp and b/src/main/resources/template/hwp/dispose_result_report.hwp differ diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp index 26ed1b6..fab35ed 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp @@ -313,15 +313,12 @@ } //문서 생성 버튼 이벤트 - $P.fnCreateDoc = (ADDS12) => { + $P.fnClickCreateDoc = (ADDS12) => { - let url = ""; let docName = ""; if(ADDS12 == "01"){ - url = wctx.url("/doc/makeDisposeResultReportHwp.do"); docName = "폐기결과보고서"; } else if(ADDS12 == "02"){ - url = wctx.url("/doc/makeDisposeProcessDetailsHwp.do"); docName = "폐기처리내역"; } else { return; @@ -331,23 +328,80 @@ content: "선택한 폐기관리 정보로 "+ docName+" 파일을 생성 하시겠습니까?" , init: () => { setDialogZindex(); } , onOK: () => { - let dscdmngId = $P.control.getCurrent().dscdmngId; - ajax.get({ - url: url, - data: { dscdmngId : dscdmngId }, - success:resp => { - - //$P.control.load($P.control.pageNum); - - } - }); + $P.getDataForDocument(ADDS12); } }); - } + }; + + //한글문서파일 생성을 위한 데이터 조회 + $P.getDataForDocument = (ADDS12) => { + + let dscdmngId = $P.control.getCurrent().dscdmng_id; + ajax.post({ + url: '', + contentType : "application/json; charset=utf-8", + + data: JSON.stringify({ + "dscdmngIds" : [dscdmngId], + "userId" : "${currentUser.account}", + "deptCd": "", + "prgrsSttsCd": "" + }), + success:resp => { + if(!resp.success){ + dialog.alert({ + content: resp.message + }); + return; + } + $P.fnCreateDoc(resp.data[0], ADDS12); + } + }); + + }; + + //한글문서파일 생성 요청 + $P.fnCreateDoc = (respData, ADDS12) => { + + respData.dsuseMgtDtls.map((dtl) => { + keys = Object.keys(respData); + for(let key of keys){ + if(key == "dsuseMgtDtls"){ + continue; + } + if(dtl[key] == undefined){ + dtl[key] = respData[key]; + } + } + return dtl; + }); + + let dtls = respData.dsuseMgtDtls; + + let url = ""; + if(ADDS12 == "01"){ + url = wctx.url("/adds/nims/makeDisposeResultReportHwp.do"); + } else if(ADDS12 == "02"){ + url = wctx.url("/adds/nims/makeDisposeProcessDetailsHwp.do"); + } else { + return; + } + + let dscdmngId = $P.control.getCurrent().dscdmng_id; + ajax.get({ + url: url, + data: { dtls : JSON.stringify(dtls) } , + success:resp => { + if(resp.saved){ + $P.control.load($P.control.pageNum); + } + } + }); + }; - // 전자우편 안내문 등록 버튼 이벤트 - $P.fnSearchBssh = (title) => { + // 업체 검색 버튼 이벤트 + $P.fnSearchBssh = () => { $P.control.getBsshInfo(); } @@ -415,11 +469,11 @@ // 폐기결과보고서 생성 버튼 이벤트 $("#btnCreateDsuseRsltDoc--${pageName}").on("click", function() { - $P.fnCreateDoc("01"); + $P.fnClickCreateDoc("01"); }); // 폐기처리내역및사진 생성 버튼 이벤트 $("#btnCreateDsuseRsltListPhoto--${pageName}").on("click", function() { - $P.fnCreateDoc("02"); + $P.fnClickCreateDoc("02"); }); // form-date 항목에서 키보드로 입력시 날짜 포맷팅 적용 @@ -435,9 +489,9 @@ }); }); - // 안내문 등록 버튼 이벤트 + // 업체 검색 버튼 이벤트 $("#btnBsshSearch--${pageName}").on("click", function() { - $P.fnSearchBssh($(this).attr("title")); + $P.fnSearchBssh(); }); // DataTables width 변경 조정 (업무별 그리드가 존재 한다면.. crdn06010-main.jsp 참고) diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp index 973763a..6885931 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp @@ -63,7 +63,7 @@