민원내역원본 hwp파일 서식 적용 기능 추가

main
이범준 1 year ago
parent 124cbc7e4b
commit e825b47c4a

@ -39,6 +39,11 @@
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>kr.dogfoot</groupId>
<artifactId>hwplib</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -6,6 +6,7 @@ import java.io.StringWriter;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URLDecoder; import java.net.URLDecoder;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -28,10 +29,17 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import cokr.xit.base.file.dao.FileMapper;
import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.FileQuery;
import cokr.xit.base.file.service.bean.FileBean;
@Controller @Controller
public class FileController extends cokr.xit.base.file.web.FileController { public class FileController extends cokr.xit.base.file.web.FileController {
@Resource(name = "fileMapper")
private FileMapper fileMapper;
@Resource(name="fileBean")
private FileBean fileBean;
@GetMapping(name = "SVG 이미지 파일 색상 변경", value = "/modifySvg/**") @GetMapping(name = "SVG 이미지 파일 색상 변경", value = "/modifySvg/**")
public void modifySvg(HttpServletRequest request, HttpServletResponse response) throws URISyntaxException, IOException, ParserConfigurationException, SAXException { public void modifySvg(HttpServletRequest request, HttpServletResponse response) throws URISyntaxException, IOException, ParserConfigurationException, SAXException {
@ -140,4 +148,5 @@ public class FileController extends cokr.xit.base.file.web.FileController {
"file" "file"
); );
} }
} }

@ -0,0 +1,12 @@
package cokr.xit.fims.cmmn;
public class CmmnUtil {
public static String escapeHTMLEntity(String str) {
str = str.replaceAll("&lt;", "<");
str = str.replaceAll("&gt;", ">");
str = str.replaceAll("&amp;", "&");
str = str.replaceAll("&quot;", "\\\"");
str = str.replaceAll("#39;", "'");
return str;
}
}

@ -18,7 +18,7 @@ public class CrdnQuery extends QueryRequest {
private String mainOption; private String mainOption;
private String subOption; private String subOption;
private String view;
private String grid; private String grid;
private String thisDay; private String thisDay;
private String currentUserId; private String currentUserId;
@ -70,6 +70,15 @@ public class CrdnQuery extends QueryRequest {
return self(); return self();
} }
public String getView() {
return ifEmpty(view, () -> null);
}
public <T extends CrdnQuery> T setView(String view) {
this.view = view;
return self();
}
public String getGrid() { public String getGrid() {
return ifEmpty(grid, () -> null); return ifEmpty(grid, () -> null);
} }

@ -51,4 +51,10 @@ public interface Crdn01Mapper extends AbstractMapper {
*/ */
DataObject selectCivilComplaintOriginalInfo(CrdnQuery req); DataObject selectCivilComplaintOriginalInfo(CrdnQuery req);
/** .
* @param req
* @return
*/
DataObject selectCivilComplaintOriginalInfoHwp(CrdnQuery req);
} }

@ -29,6 +29,9 @@ public class Crdn01Bean extends AbstractComponent {
} }
public DataObject getCivilComplaintOriginalInfo(CrdnQuery req) { public DataObject getCivilComplaintOriginalInfo(CrdnQuery req) {
if(ifEmpty(req.getView(), () -> "").equals("hwp")) {
return crdn01Mapper.selectCivilComplaintOriginalInfoHwp(req);
}
return crdn01Mapper.selectCivilComplaintOriginalInfo(req); return crdn01Mapper.selectCivilComplaintOriginalInfo(req);
} }

@ -1,16 +1,27 @@
package cokr.xit.fims.crdn.service.bean; package cokr.xit.fims.crdn.service.bean;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.file.FileInfo;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.CrdnQuery;
import cokr.xit.fims.crdn.dao.Crdn01Mapper; import cokr.xit.fims.crdn.dao.Crdn01Mapper;
import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.crdn.service.CrdnService;
import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
import kr.dogfoot.hwplib.object.HWPFile;
import kr.dogfoot.hwplib.reader.HWPReader;
import kr.dogfoot.hwplib.tool.objectfinder.FieldFinder;
import kr.dogfoot.hwplib.writer.HWPWriter;
/** /**
* @author leebj * @author leebj
@ -47,5 +58,70 @@ public class Crdn01ServiceBean extends AbstractServiceBean implements CrdnServic
return crdn01Bean.removeCivilComplaint(crdnIDs); return crdn01Bean.removeCivilComplaint(crdnIDs);
} }
public ModelAndView makeFileFromHwpFormat(CrdnQuery crdnQuery) {
crdnQuery.setView("hwp");
DataObject dataObject = crdn01Bean.getCivilComplaintOriginalInfo(crdnQuery);
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
SimpleDateFormat ymdFormat = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat ymdHypenFormat = new SimpleDateFormat("yyyy-MM-dd");
String formatFilePath = "files" + File.separator + "format" + File.separator + "cvlcptOrgnl.hwp";
HWPFile hwpFile;
try {
hwpFile = HWPReader.fromFile(formatFilePath);
ArrayList<String> strings = new ArrayList<String>();
strings.add(dataObject.string("CVLCPT_APLCNT_NM"));
FieldFinder.setClickHereText(hwpFile, "신청자", strings);
strings = new ArrayList<String>();
String cvlcptRcptYmd = dataObject.string("CVLCPT_RCPT_YMD");
cvlcptRcptYmd = ymdHypenFormat.format(ymdFormat.parse(cvlcptRcptYmd));
strings.add(cvlcptRcptYmd);
FieldFinder.setClickHereText(hwpFile, "접수일자", strings);
strings = new ArrayList<String>();
String cvlcptRrcsPrnmntDt = dataObject.string("CVLCPT_PRCS_PRNMNT_DT");
cvlcptRrcsPrnmntDt = ymdHypenFormat.format(ymdFormat.parse(cvlcptRrcsPrnmntDt));
strings.add(cvlcptRrcsPrnmntDt);
FieldFinder.setClickHereText(hwpFile, "처리기한", strings);
strings = new ArrayList<String>();
strings.add(dataObject.string("CVLCPT_RCPT_NO"));
FieldFinder.setClickHereText(hwpFile, "접수번호", strings);
strings = new ArrayList<String>();
String cvlcptAplyCn = dataObject.string("CVLCPT_APLY_CN");
cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn);
strings.add(cvlcptAplyCn);
FieldFinder.setClickHereText(hwpFile, "민원내용", strings);
//TODO : 사진삽입
String currentTime = ymdhmsFormat.format(new Date());
String resultPath = "files" + File.separator + "result" + File.separator + currentTime + ".hwp";
HWPWriter.toFile(hwpFile, resultPath);
FileInfo fileInfo = new FileInfo();
fileInfo.setPath(resultPath);
fileInfo.setName(currentTime+".hwp");
fileInfo.setMimeType("application/vnd.hancom.hwpx");
fileInfo.setExtension("hwp");
fileInfo.setSize(new File(resultPath).length());
String downlaodFileName = "민원내역원본_" + currentTime + ".hwp";
ModelAndView mav = new ModelAndView("jsonView");
mav.addObject("filePath", resultPath);
mav.addObject("fileName", downlaodFileName);
return mav;
} catch (Exception e) {
return new ModelAndView("errorView");
}
}
} }

@ -174,4 +174,12 @@ public class Crdn01Controller extends ApplicationController {
return new ModelAndView("jsonView") return new ModelAndView("jsonView")
.addObject("saved", saved); .addObject("saved", saved);
} }
/** .
* @return hwp
*/
@RequestMapping(name="민원내역 원본 한글 파일 생성", value="/050/makeFileFromHwpFormat.do")
public ModelAndView makeFileFromHwpFormat(CrdnQuery crdnQuery) {
return crdn01Service.makeFileFromHwpFormat(crdnQuery);
}
} }

@ -255,6 +255,7 @@ SELECT C.CRDN_ID <!-- 단속 ID -->
</update> </update>
<select id="selectCivilComplaintOriginalInfo" parameterType="cokr.xit.fims.crdn.Crdn" resultType="dataobject"> <select id="selectCivilComplaintOriginalInfo" parameterType="cokr.xit.fims.crdn.Crdn" resultType="dataobject">
/* 민원내역 원본 보기(crdn01Mapper.selectCivilComplaintOriginalInfo) */
SELECT C.CRDN_ID <!-- 단속 ID --> SELECT C.CRDN_ID <!-- 단속 ID -->
, CC.CVLCPT_RCPT_NO <!-- 민원 접수 번호 --> , CC.CVLCPT_RCPT_NO <!-- 민원 접수 번호 -->
, CC.CVLCPT_APLCNT_NM <!-- 민원 신청인 명 --> , CC.CVLCPT_APLCNT_NM <!-- 민원 신청인 명 -->
@ -267,4 +268,18 @@ SELECT C.CRDN_ID <!-- 단속 ID -->
WHERE C.DEL_YN = 'N' AND CC.DEL_YN = 'N' WHERE C.DEL_YN = 'N' AND CC.DEL_YN = 'N'
AND C.CRDN_ID = #{crdnId} AND C.CRDN_ID = #{crdnId}
</select> </select>
<select id="selectCivilComplaintOriginalInfoHwp" parameterType="cokr.xit.fims.crdn.Crdn" resultType="dataobject">
/* 민원내역 원본 보기(한글 파일)(crdn01Mapper.selectCivilComplaintOriginalInfoHwp) */
SELECT C.CRDN_ID <!-- 단속 ID -->
, CC.CVLCPT_RCPT_NO <!-- 민원 접수 번호 -->
, CC.CVLCPT_APLCNT_NM <!-- 민원 신청인 명 -->
, CC.CVLCPT_RCPT_YMD <!-- 민원 접수 일자 -->
, CC.CVLCPT_PRCS_PRNMNT_DT <!-- 민원 처리 예정 일시 -->
, CC.CVLCPT_APLY_CN <!-- 민원 신청 내용 -->
FROM TB_CRDN C
INNER JOIN TB_CRDN_CVLCPT CC ON (C.CRDN_ID = CC.CRDN_ID)
WHERE C.DEL_YN = 'N' AND CC.DEL_YN = 'N'
AND C.CRDN_ID = #{crdnId}
</select>
</mapper> </mapper>

@ -36,6 +36,10 @@
<input type="text" id="cvlcptPrcsPrnmtDt--${pageName}" name="cvlcptPrcsPrnmtDt" data-map="CVLCPT_PRCS_PRNMNT_DT" <input type="text" id="cvlcptPrcsPrnmtDt--${pageName}" name="cvlcptPrcsPrnmtDt" data-map="CVLCPT_PRCS_PRNMNT_DT"
class="form-control" readonly /> class="form-control" readonly />
</div> </div>
<div class="col-md-4">
<button type="button" class="btn btn-blue" id="btnMakeHwp--${pageName}" title="한글파일 다운">한글파일 다운</button>
<div id="tempArea--${pageName}"></div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<label for="cvlcptAplyCn--${pageName}" class="w-px-150 bg-lighter pe-2 col-form-label text-sm-center"> <label for="cvlcptAplyCn--${pageName}" class="w-px-150 bg-lighter pe-2 col-form-label text-sm-center">
민원 내용 민원 내용
@ -151,11 +155,30 @@ $(document).ready(function() {
}); });
} }
$P.fnMakeHwp = () => {
ajax.post({
url : wctx.url("/"+$P.taskSeCd+"/crdn/crdn01/050/makeFileFromHwpFormat.do"),
data : { crdnId : $("#crdnId--${pageName}").val() },
success : resp => {
var a = document.createElement("a");
a.href = resp.filePath;
a.download = resp.fileName;
document.getElementById("tempArea--${pageName}").appendChild(a);
a.click();
document.getElementById("tempArea--${pageName}").removeChild(a);
}
});
}
/************************************************************************** /**************************************************************************
* element.on * element.on
**************************************************************************/ **************************************************************************/
$("#btnPrev--${pageName}").on("click", () => $P.fnPrev() ); $("#btnPrev--${pageName}").on("click", () => $P.fnPrev() );
$("#btnNext--${pageName}").on("click", () => $P.fnNext() ); $("#btnNext--${pageName}").on("click", () => $P.fnNext() );
$("#btnMakeHwp--${pageName}").on("click", () => $P.fnMakeHwp() );
/************************************************************************** /**************************************************************************
* 초기화 * 초기화

Loading…
Cancel
Save