민원 수정
parent
a9ac79b805
commit
43e955153c
@ -0,0 +1,47 @@
|
||||
package cokr.xit.fims.crdn.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cokr.xit.base.file.FileInfo;
|
||||
import cokr.xit.fims.crdn.Crdn;
|
||||
import cokr.xit.fims.crdn.CrdnQuery;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
|
||||
public interface CrdnCvlcptService {
|
||||
|
||||
/** 민원 원본 상세정보를 조회한다.
|
||||
* @param crdnQuery 조회 요청
|
||||
* @return 민원원본정보
|
||||
*/
|
||||
DataObject getCivilComplaintOriginalInfo(CrdnQuery crdnQuery);
|
||||
|
||||
/** 민원 답변 미리보기 정보를 조회한다.
|
||||
* @param crdnQuery 조회 요청
|
||||
* @return 민원 답변 정보
|
||||
*/
|
||||
DataObject getAnswerPreview(CrdnQuery crdnQuery);
|
||||
|
||||
/** 민원접수 초기자료 상세정보를 조회한다.
|
||||
* @param crdnQuery 조회 요청
|
||||
* @return 민원초기자료 정보
|
||||
*/
|
||||
DataObject getCivilComplaintReceiptInitialDataInfo(CrdnQuery crdnQuery);
|
||||
|
||||
/** 한글 서식 출력물을 생성한다.
|
||||
* @param crdnQuery 출력 요청
|
||||
* @return map 출력 요청 결과
|
||||
* <ul><li>filePath: 결과 파일 경로</li>
|
||||
* <li>fileName: 다운로드 파일명</li>
|
||||
* </ul>
|
||||
*/
|
||||
Map<String, String> makeFileFromHwpFormat(CrdnQuery crdnQuery);
|
||||
|
||||
/** 단속민원 부과요청을 수용한다.
|
||||
* @param crdn 단속정보, newFileInfoList 업로드 파일 목록
|
||||
* @return 저장여부
|
||||
*/
|
||||
boolean updateCvlcptPrcs(Map<String, Object> nonQueryRequest, Crdn crdn, List<FileInfo> newFileInfoList);
|
||||
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package cokr.xit.fims.crdn.service.bean;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import cokr.xit.foundation.AbstractComponent;
|
||||
|
||||
/** 민원 개별 등록 Bean
|
||||
* @author leebj
|
||||
*/
|
||||
@Component("crdn02Bean")
|
||||
public class Crdn02Bean extends AbstractComponent {
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,260 @@
|
||||
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.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.assertj.core.util.Arrays;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import cokr.xit.base.file.FileInfo;
|
||||
import cokr.xit.base.file.service.FileQuery;
|
||||
import cokr.xit.base.file.service.bean.FileBean;
|
||||
import cokr.xit.fims.cmmn.CmmnUtil;
|
||||
import cokr.xit.fims.cmmn.hwp.AddingParagraphBetweenHWPFile;
|
||||
import cokr.xit.fims.cmmn.hwp.InsertingImageCell;
|
||||
import cokr.xit.fims.crdn.Crdn;
|
||||
import cokr.xit.fims.crdn.CrdnCvlcpt;
|
||||
import cokr.xit.fims.crdn.CrdnQuery;
|
||||
import cokr.xit.fims.crdn.dao.CrdnCvlcptMapper;
|
||||
import cokr.xit.fims.crdn.service.CrdnCvlcptService;
|
||||
import cokr.xit.fims.sprt.Sprt;
|
||||
import cokr.xit.foundation.component.AbstractServiceBean;
|
||||
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;
|
||||
|
||||
@Service("crdnCvlcptService")
|
||||
public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCvlcptService {
|
||||
|
||||
@Resource(name="fileBean")
|
||||
private FileBean fileBean;
|
||||
|
||||
@Resource(name="crdnCvlcptBean")
|
||||
protected CrdnCvlcptBean crdnCvlcptBean;
|
||||
|
||||
@Resource(name = "crdnCvlcptMapper")
|
||||
private CrdnCvlcptMapper crdnCvlcptMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, String> makeFileFromHwpFormat(CrdnQuery crdnQuery) {
|
||||
String baseFormatFilePath = ("classpath:format/cvlcptOrgnl_text.hwp");
|
||||
String attachFormatFilePath = ("classpath:format/cvlcptOrgnl_photo.hwp");
|
||||
|
||||
crdnQuery.setViewType("hwp");
|
||||
DataObject dataObject = crdnCvlcptBean.getCivilComplaintOriginalInfo(crdnQuery);
|
||||
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
SimpleDateFormat ymdFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
SimpleDateFormat ymdHypenFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
try {
|
||||
|
||||
File file = ResourceUtils.getFile(baseFormatFilePath);
|
||||
|
||||
HWPFile baseFormatFile = HWPReader.fromFile(file);
|
||||
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
strings.add(dataObject.string("CVLCPT_APLCNT_NM"));
|
||||
FieldFinder.setClickHereText(baseFormatFile, "신청자", strings);
|
||||
|
||||
strings = new ArrayList<String>();
|
||||
String cvlcptRcptYmd = dataObject.string("CVLCPT_RCPT_YMD");
|
||||
cvlcptRcptYmd = ymdHypenFormat.format(ymdFormat.parse(cvlcptRcptYmd));
|
||||
strings.add(cvlcptRcptYmd);
|
||||
FieldFinder.setClickHereText(baseFormatFile, "접수일자", strings);
|
||||
|
||||
strings = new ArrayList<String>();
|
||||
String cvlcptRrcsPrnmntDt = dataObject.string("CVLCPT_PRCS_PRNMNT_DT");
|
||||
cvlcptRrcsPrnmntDt = ymdHypenFormat.format(ymdFormat.parse(cvlcptRrcsPrnmntDt));
|
||||
strings.add(cvlcptRrcsPrnmntDt);
|
||||
FieldFinder.setClickHereText(baseFormatFile, "처리기한", strings);
|
||||
|
||||
strings = new ArrayList<String>();
|
||||
strings.add(dataObject.string("CVLCPT_RCPT_NO"));
|
||||
FieldFinder.setClickHereText(baseFormatFile, "접수번호", strings);
|
||||
|
||||
strings = new ArrayList<String>();
|
||||
String cvlcptAplyCn = dataObject.string("CVLCPT_APLY_CN");
|
||||
cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn);
|
||||
strings.add(cvlcptAplyCn);
|
||||
FieldFinder.setClickHereText(baseFormatFile, "민원내용", strings);
|
||||
|
||||
String currentTime = ymdhmsFormat.format(new Date());
|
||||
|
||||
String formatFileResultRootPath = "files" + File.separator + "result";
|
||||
File formatFileResultRootFolder = new File(formatFileResultRootPath);
|
||||
if(!formatFileResultRootFolder.exists()) {
|
||||
formatFileResultRootFolder.mkdirs();
|
||||
}
|
||||
String resultPath = formatFileResultRootPath + File.separator + currentTime + ".hwp";
|
||||
|
||||
HWPWriter.toFile(baseFormatFile, resultPath);
|
||||
|
||||
HWPFile resultFile = HWPReader.fromFile(resultPath);
|
||||
|
||||
String linkTblNm = dataObject.string("LINK_TBL_NM");
|
||||
if(!linkTblNm.equals("")) {
|
||||
FileQuery fileQuery = new FileQuery();
|
||||
|
||||
if(linkTblNm.equals("TB_ESB_INTERFACE")) {
|
||||
fileQuery.setInfoType("010");
|
||||
} else if(linkTblNm.equals("TB_SAEOL")) {
|
||||
fileQuery.setInfoType("020");
|
||||
} else {
|
||||
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
|
||||
}
|
||||
|
||||
fileQuery.setInfoKeys(dataObject.string("LINK_ID"));
|
||||
|
||||
List<DataObject> fileInfoList = fileBean.getFileList(fileQuery);
|
||||
|
||||
fileInfoList = fileInfoList.stream()
|
||||
.filter(fileInfo -> fileInfo.string("MIME_TYPE").startsWith("image"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if(fileInfoList != null && fileInfoList.size() > 0) {
|
||||
int photoCnt = fileInfoList.size();
|
||||
int PHOTO_COUNT_PER_PAGE = 4;
|
||||
|
||||
for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) {
|
||||
file = ResourceUtils.getFile(attachFormatFilePath);
|
||||
HWPFile attachFormatFile = HWPReader.fromFile(file);
|
||||
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽위사진", fileInfoList.get(i).string("URL"));
|
||||
if(i+1 < photoCnt)
|
||||
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽위사진", fileInfoList.get(i+1).string("URL"));
|
||||
if(i+2 < photoCnt)
|
||||
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽아래사진", fileInfoList.get(i+2).string("URL"));
|
||||
if(i+3 < photoCnt)
|
||||
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽아래사진", fileInfoList.get(i+3).string("URL"));
|
||||
AddingParagraphBetweenHWPFile.fileMerge(attachFormatFile, resultFile);
|
||||
}
|
||||
|
||||
HWPWriter.toFile(resultFile, resultPath);
|
||||
}
|
||||
}
|
||||
|
||||
String downlaodFileName = "민원내역원본_" + currentTime + ".hwp";
|
||||
Map<String, String> result = Map.of(
|
||||
"filePath", resultPath,
|
||||
"fileName", downlaodFileName
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObject getCivilComplaintOriginalInfo(CrdnQuery req) {
|
||||
return crdnCvlcptBean.getCivilComplaintOriginalInfo(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObject getAnswerPreview(CrdnQuery req) {
|
||||
return crdnCvlcptMapper.selectAnswerPreview(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObject getCivilComplaintReceiptInitialDataInfo(CrdnQuery req) {
|
||||
//민원조회
|
||||
DataObject dataObject = crdnCvlcptMapper.selectCivilComplaintReceiptInitialDataInfo(req);
|
||||
|
||||
//첨부파일 조회
|
||||
FileQuery fileQuery = new FileQuery();
|
||||
fileQuery.setInfoType(Crdn.INF_TYPE);
|
||||
fileQuery.setInfoKeys(req.getCrdnId());
|
||||
List<DataObject> fileList = fileBean.getFileList(fileQuery);
|
||||
if(fileList != null && !fileList.isEmpty()) {
|
||||
dataObject.set("fileList", fileList);
|
||||
}
|
||||
|
||||
//동영상 존재 여부 확인
|
||||
dataObject.set("videoExist", "N");
|
||||
String linkTblNm = dataObject.string("LINK_TBL_NM");
|
||||
if(!linkTblNm.equals("")) {
|
||||
|
||||
if(linkTblNm.equals("TB_ESB_INTERFACE")) {
|
||||
fileQuery.setInfoType("010");
|
||||
} else if(linkTblNm.equals("TB_SAEOL")) {
|
||||
fileQuery.setInfoType("020");
|
||||
} else {
|
||||
throw new RuntimeException("파일 조회 중 오류가 발생하였습니다.");
|
||||
}
|
||||
|
||||
fileQuery.setInfoKeys(dataObject.string("LINK_ID"));
|
||||
List<DataObject> linkFileList = fileBean.getFileList(fileQuery);
|
||||
if(linkFileList != null && !linkFileList.isEmpty()) {
|
||||
for(int i=0; i < linkFileList.size(); i++) {
|
||||
String mimeType = linkFileList.get(i).string("MIME_TYPE");
|
||||
if(Arrays.asList(Sprt.VIDEO_MIME_TYPE).contains(mimeType)) {
|
||||
dataObject.set("videoExist", "Y");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateCvlcptPrcs(Map<String, Object> nonQueryRequest, Crdn crdn, List<FileInfo> newFileInfoList) {
|
||||
boolean saved = false;
|
||||
|
||||
int fileInsertEffected = 0;
|
||||
int fileDeleteEffected = 0;
|
||||
|
||||
if(newFileInfoList != null && !newFileInfoList.isEmpty()) {
|
||||
fileInsertEffected = fileBean.create(newFileInfoList);
|
||||
}
|
||||
|
||||
if((String[])nonQueryRequest.get("deleteFileKeyList") != null) {
|
||||
fileDeleteEffected = fileBean.remove((String[])nonQueryRequest.get("deleteFileKeyList"));
|
||||
}
|
||||
|
||||
int changeFileCnt = (fileInsertEffected - fileDeleteEffected);
|
||||
|
||||
|
||||
CrdnCvlcpt crdnCvlcpt = new CrdnCvlcpt();
|
||||
|
||||
crdnCvlcpt.setCvlcptLinkId(crdn.getLinkId());
|
||||
|
||||
String acceptType = (String)nonQueryRequest.get("acceptType");
|
||||
|
||||
if(acceptType.equals("someAccept")) {
|
||||
///call 부과제외
|
||||
} else if(acceptType.equals("nonAccept")) {
|
||||
///call 부과제외
|
||||
}
|
||||
|
||||
//TODO : 전송코드,처리코드 결정
|
||||
crdnCvlcpt.setCvlcptPrcsCd("");
|
||||
crdnCvlcpt.setCvlcptTrsmCd("02");
|
||||
|
||||
//TODO : 전송문구 조회
|
||||
crdnCvlcpt.setCvlcptPrcsSumry("요약요약요약");
|
||||
crdnCvlcpt.setCvlcptPrcsRsltCn("결과결과결과");
|
||||
|
||||
//민원정보변경
|
||||
saved = crdnCvlcptBean.updateCvlcptPrcs(crdnCvlcpt);
|
||||
|
||||
|
||||
nonQueryRequest.put("changeFileCnt", changeFileCnt);
|
||||
//단속정보변경
|
||||
saved = crdnCvlcptBean.updateCrdn(nonQueryRequest, crdn);
|
||||
return saved;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue