한글문서파일 생성 기능 추가

dev
이범준 5 months ago
parent 91323c6e36
commit 2a1b991ca3

@ -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<String,String> globalVariable = new HashMap<String,String>();
printOption.setGlobalVariable(globalVariable);
//상품 사진 갯수 체크
List<DataObject> totalProduct = fileService.getFileList(
new FileQuery().setInfoKeys(dscdmngId).setInfoType("100")
);
int totalProductCnt = 0;
if(totalProduct != null && !totalProduct.isEmpty()) {
totalProductCnt = totalProduct.size();
}
//샘플 데이터 생성
List<DataObject> dataobjectList = this.makeSample(dscdmngId,totalProductCnt);
for(DataObject data : dataobjectList) {
String infKey = data.string("dscdmngId");
String subType = data.string("dscdmngSn");
List<DataObject> 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<String,String> globalVariable = new HashMap<String,String>();
printOption.setGlobalVariable(globalVariable);
//폐기증거사진
List<DataObject> dsuseimgs = fileService.getFileList(
new FileQuery().setInfoType("110").setInfoKeys(dscdmngId)
);
List<String> dataobjectList2 = new ArrayList<>();
for(DataObject dsuseimg : dsuseimgs) {
dataobjectList2.add(dsuseimg.string("FILE_PATH"));
}
//상품사진갯수 체크
List<DataObject> totalProduct = fileService.getFileList(
new FileQuery().setInfoKeys(dscdmngId).setInfoType("100").setOrderBy("SUB_TYPE")
);
int totalProductCnt = 0;
if(totalProduct != null && !totalProduct.isEmpty()) {
totalProductCnt = totalProduct.size();
}
//샘플 데이터 생성
List<DataObject> dataobjectList = this.makeSample(dscdmngId,totalProductCnt);
for(DataObject data : dataobjectList) {
String infKey = data.string("dscdmngId");
String subType = data.string("dscdmngSn");
List<DataObject> 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<DataObject> makeSample(String dscdmngId, int totalProductCnt){
List<DataObject> dataobjectList = new ArrayList<DataObject>();
for(int i=0; i<totalProductCnt; i++) {
DataObject newObj = this.getRandomObj();
newObj.set("dscdmngId", dscdmngId);
newObj.set("dscdmngSn", EgovStringUtil.lPad(""+(i+1), 3, '0'));
dataobjectList.add(newObj);
}
return dataobjectList;
}
public DataObject getRandomObj() {
DataObject[] items = {
new DataObject()
.set("bsshNm", "메디칼약국")
.set("indutyNm", "마약류취급소매업자")
.set("bsshCd", "D04343033")
.set("dsuseDe", "20240501")
.set("dsuseSeCdNm", "공무원임회") //ADDS03
.set("dsusePrvCdNm", "유효기간경과") //ADDS04
.set("dsuseLoc", "수지구보건소 검사실")
.set("dsuseMthCdNm", "가수분해") //ADDS05
.set("nrcdSeNm", "마약")
.set("prductNm", "자낙스정0.5mg")
.set("prductCd", "08806489012648")
.set("minDistbQy", "30")
.set("stdPackngStleNm", "정")
.set("mnfNo", "FJ6892")
.set("prdValidDe", "20240323")
.set("pceQy", "2")
.set("pceCoUnitNm", "정"),
new DataObject()
.set("bsshNm", "메디칼약국")
.set("indutyNm", "마약류취급소매업자")
.set("bsshCd", "D04343033")
.set("dsuseDe", "20240501")
.set("dsuseSeCdNm", "공무원임회") //ADDS03
.set("dsusePrvCdNm", "유효기간경과") //ADDS04
.set("dsuseLoc", "수지구보건소 검사실")
.set("dsuseMthCdNm", "가수분해") //ADDS05
.set("nrcdSeNm", "마약")
.set("prductNm", "아쿠아폴주")
.set("prductCd", "08806489012648")
.set("minDistbQy", "30")
.set("stdPackngStleNm", "정")
.set("mnfNo", "FJ6892")
.set("prdValidDe", "20240323")
.set("pceQy", "2")
.set("pceCoUnitNm", "정"),
new DataObject()
.set("bsshNm", "메디칼약국")
.set("indutyNm", "마약류취급소매업자")
.set("bsshCd", "D04343033")
.set("dsuseDe", "20240501")
.set("dsuseSeCdNm", "공무원임회") //ADDS03
.set("dsusePrvCdNm", "유효기간경과") //ADDS04
.set("dsuseLoc", "수지구보건소 검사실")
.set("dsuseMthCdNm", "가수분해") //ADDS05
.set("nrcdSeNm", "마약")
.set("prductNm", "베리콜시럽")
.set("prductCd", "08806489012648")
.set("minDistbQy", "30")
.set("stdPackngStleNm", "정")
.set("mnfNo", "FJ6892")
.set("prdValidDe", "20240323")
.set("pceQy", "2")
.set("pceCoUnitNm", "정")
};
Random rand = new Random();
return items[rand.nextInt(3)];
}
}

@ -134,9 +134,9 @@ public class DisposeProcessDetails extends HWPFormat {
return (DataObject) new DataObject()
.set("번호", i)
.set("업소명", one.string("bsshNm"))
.set("폐기사유", one.string("dsusePrvCdNm"))
.set("폐기사유", one.string("dsusePrvNm"))
.set("폐기장소", one.string("dsuseLoc"))
.set("폐기방법", one.string("dsuseMthCdNm"))
.set("폐기방법", one.string("dsuseMthNm"))
.set("구분", one.string("nrcdSeNm"))
.set("제품명", one.string("prductNm"))
.set("품목코드", one.string("prductCd"))

@ -33,10 +33,10 @@ public class DisposeResultReport extends HWPFormat {
.set("폐기신청인-허가종별", one.string("indutyNm"))
.set("폐기신청인-마약류취급자식별번호", one.string("bsshCd"))
.set("폐기정보-폐기일자", DataFormat.yyyy_mm_dd(one.string("dsuseDe")))
.set("폐기정보-폐기종류", one.string("dsuseSeCdNm"))
.set("폐기정보-폐기사유", one.string("dsusePrvCdNm"))
.set("폐기정보-폐기종류", one.string("dsuseSeNm"))
.set("폐기정보-폐기사유", one.string("dsusePrvNm"))
.set("폐기정보-폐기장소", one.string("dsuseLoc"))
.set("폐기정보-폐기방법", one.string("dsuseMthCdNm"))
.set("폐기정보-폐기방법", one.string("dsuseMthNm"))
.set("제품정보-구분", one.string("nrcdSeNm"))
.set("제품정보-제품명", one.string("prductNm"))
.set("제품정보-품목코드", one.string("prductCd"))

@ -1,5 +1,8 @@
package cokr.xit.adds.nims.web;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -10,15 +13,23 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.core.type.TypeReference;
import cokr.xit.adds.cmm.model.DsuseMappingInfo;
import cokr.xit.adds.cmm.model.DsuseRsltInfo;
import cokr.xit.adds.cmmn.hwp.format.DisposeProcessDetails;
import cokr.xit.adds.cmmn.hwp.format.DisposeResultReport;
import cokr.xit.adds.nims.DsuseMgtDocQuery;
import cokr.xit.adds.nims.DsuseMgtReceiptQuery;
import cokr.xit.adds.nims.service.DsuseMgtDocService;
import cokr.xit.adds.nims.service.DsuseMgtReceiptService;
import cokr.xit.applib.Print;
import cokr.xit.applib.PrintOption;
import cokr.xit.applib.ogdp.OgdpQuery;
import cokr.xit.applib.ogdp.service.bean.DefaultOgdpBean;
import cokr.xit.base.code.CommonCode;
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.base.web.ApplicationController;
@ -139,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<DataObject> dataForDoc = fromJson(dtls, new TypeReference<ArrayList<DataObject>>() {});
//출력일시,출력작업자
Print print = new Print();
print.setPrintRequestUserInfo(currentUser());
//개인정보표시여부,기관장 등
PrintOption printOption = new PrintOption();
Map<String,String> globalVariable = new HashMap<String,String>();
printOption.setGlobalVariable(globalVariable);
for(DataObject data : dataForDoc) {
String infKey = data.string("dscdmngId");
String subType = data.string("dscdmngSn");
List<DataObject> 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<DataObject> dataForDoc = fromJson(dtls, new TypeReference<ArrayList<DataObject>>() {});
//출력일시,출력작업자
Print print = new Print();
print.setPrintRequestUserInfo(currentUser());
//개인정보표시여부,기관장 등
PrintOption printOption = new PrintOption();
Map<String,String> globalVariable = new HashMap<String,String>();
printOption.setGlobalVariable(globalVariable);
//폐기증거사진
List<DataObject> dsuseimgs = fileService.getFileList(
new FileQuery().setInfoType("110").setInfoKeys(dataForDoc.get(0).string("dscdmngId"))
);
List<String> 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<DataObject> 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;
}
//-------------------------------------------------------------------------------------------------
// 보고 문서 관리
//-------------------------------------------------------------------------------------------------
@ -201,6 +320,7 @@ public class AddsNimsController extends ApplicationController {
mav.addObject("DEPTList", deptList);
mav.addObject("pageName", "dsuseMgtDoc");
mav.addObject("apiHost", apiHost);
return mav;
}
//-------------------------------------------------------------------------------------------------

@ -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.getDataForDocument(ADDS12);
}
});
};
//한글문서파일 생성을 위한 데이터 조회
$P.getDataForDocument = (ADDS12) => {
//$P.control.load($P.control.pageNum);
let dscdmngId = $P.control.getCurrent().dscdmng_id;
ajax.post({
url: '<c:url value="${apiHost}/api/biz/nims/v1/getDsuseMgtListForRptDoc" />',
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;
}
// 전자우편 안내문 등록 버튼 이벤트
$P.fnSearchBssh = (title) => {
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 = () => {
$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 참고)

Loading…
Cancel
Save