diff --git a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc02Controller.java b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc02Controller.java index 2714ae44..266ee587 100644 --- a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc02Controller.java +++ b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc02Controller.java @@ -1,6 +1,5 @@ package cokr.xit.fims.cvlc.web; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -11,17 +10,20 @@ import javax.servlet.http.HttpServletRequest; import org.apache.poi.ss.usermodel.CellStyle; import org.springframework.web.servlet.ModelAndView; -import com.fasterxml.jackson.core.type.TypeReference; - import cokr.xit.base.code.CommonCode; +import cokr.xit.base.file.service.FileQuery; +import cokr.xit.base.file.service.bean.FileBean; import cokr.xit.base.file.xls.XLSWriter; import cokr.xit.base.file.xls.XLSWriter.CellDef; +import cokr.xit.base.file.xls.XLSWriter.CommentSupport; import cokr.xit.base.file.xls.XLSWriter.Styler; import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; +import cokr.xit.fims.cmmn.CellDecorator; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.service.bean.StngBean; +import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.GlobalStngMapper; import cokr.xit.fims.crdn.service.CrdnService; @@ -63,6 +65,9 @@ public class Cvlc02Controller extends ApplicationController { @Resource(name = "stngBean") private StngBean stngBean; + @Resource(name = "fileBean") + private FileBean fileBean; + /** 민원 답변 대상 자료 메인화면을 연다. * @return fims/cvlc/cvlc02010-main */ @@ -95,7 +100,12 @@ public class Cvlc02Controller extends ApplicationController { query.setSggCd(sggCd); if("xls".equals(query.getDownload())) { - ArrayList cellDefs = fromJson(query.getCellDefs(), new TypeReference>() {}); + List cellDefs = fromJson(query.getCellDefs(), CellDef.listType()); + + if(ifEmpty(query.getIncludePhoto(), () -> "").equals("Y")) { + cellDefs.add((new CellDef()).setLabel("사진1").setWidth(18).setField("CRDN_PHOTO_PATH1")); + cellDefs.add((new CellDef()).setLabel("사진2").setWidth(18).setField("CRDN_PHOTO_PATH2")); + } XLSWriter xlsx = new XLSWriter() .setFilename("민원답변대상자료 목록.xlsx") @@ -107,6 +117,21 @@ public class Cvlc02Controller extends ApplicationController { CellStyle dateDT = xlsx.yyyy_mm_dd_hh_mm_ss(); List list = crdnCvlcptService.getCivilComplaintList(query.setFetchSize(0)); + if(ifEmpty(query.getIncludePhoto(), () -> "").equals("Y")) { + for(DataObject crdn : list) { + String crdnId = crdn.string("CRDN_ID"); + FileQuery fileQuery = new FileQuery(); + fileQuery.setInfoType(Crdn.INF_TYPE); + fileQuery.setInfoKeys(crdnId); + List fileInfoList = fileBean.getFileList(fileQuery); + + if(fileInfoList != null && fileInfoList.size() > 0) { + for(int j=0; (j < fileInfoList.size()) && (j < 2); j++) { + crdn.set("CRDN_PHOTO_PATH"+(j+1), fileInfoList.get(j).string("FILE_PATH")); + } + } + } + } Map valueMap = new HashMap(); valueMap.put("접수번호", xlsx.style("CVLCPT_RCPT_NO", center)); @@ -127,6 +152,17 @@ public class Cvlc02Controller extends ApplicationController { valueMap.put("차량번호", "VHRNO"); valueMap.put("서손/계고사유", xlsx.style("LEVY_EXCL_RSN_NM", center)); valueMap.put("특기사항", "ETC_CN"); + + if(ifEmpty(query.getIncludePhoto(), () -> "").equals("Y")) { + CommentSupport commentSupport = new CommentSupport(xlsx); + + CellDecorator col1 = CmmnUtil.photoCellForApproval(commentSupport, "CRDN_PHOTO_PATH1"); + CellDecorator col2 = CmmnUtil.photoCellForApproval(commentSupport, "CRDN_PHOTO_PATH2"); + + valueMap.put("사진1", xlsx.format(col1.value()).onCell(col1.memo())); + valueMap.put("사진2", xlsx.format(col2.value()).onCell(col2.memo())); + } + CellDef.setValues(cellDefs, valueMap); xlsx.cell(0, 0) diff --git a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02010-main.jsp index 12676ca1..c4028851 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/cvlc/cvlc02010-main.jsp @@ -16,6 +16,9 @@ + @@ -396,6 +399,28 @@ $(document).ready(function(){ $P.crdnControl.load($P.crdnControl.query.pageNum + 1); } + $P.fnExcelDown = (forApproval) => { + + if($P.crdnControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } + + var cellDefs = getCellDefs($("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)").not(":eq(0)"), + $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)").not(":eq(0)")); + $P.crdnControl.query.cellDefs = cellDefs; + + if(forApproval){ + $P.crdnControl.query.includePhoto = "Y"; + } else { + $P.crdnControl.query.includePhoto = "N"; + } + + $P.crdnControl.download(); + + $P.crdnControl.query.includePhoto = null; + }; + $P.clickCrdnList = (dataKey, auto) => { if(dataKey == ""){ return; @@ -675,19 +700,9 @@ $(document).ready(function(){ **************************************************************************/ $('#btnReset--${pageName}').on('click', () => $P.fnReset()); $('#btnSearch--${pageName}').on('click', () => $P.searchCrdnList()); - $('#btnExcel--${pageName}').on('click', function(){ - - if($P.crdnControl.dataset.empty){ - alert("조회된 자료가 없습니다."); - return; - } - - var cellDefs = getCellDefs($("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)").not(":eq(0)"), - $($("#crdnRow--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)").not(":eq(0)")); - $P.crdnControl.query.cellDefs = cellDefs; - - $P.crdnControl.download(); - }); + $('#btnExcel--${pageName}').on('click', () => $P.fnExcelDown(false)); + $('#btnExcelForApproval--${pageName}').on('click', () => $P.fnExcelDown(true)); + $("#btnOpenCvlcptOrgnl--${pageName}").on("click", () => $P.fnOpenCvlcptOrgnl()); $("#btnOpenAnswerPreview--${pageName}").on("click", () => $P.fnOpenAnswerPreview()); $("#btnExecuteAnswer--${pageName}").on("click", () => $P.fnExecuteAnswer());