feat: paintweb 저장 진행

main
Jonguk. Lim 2 years ago
parent a2273b9ced
commit a6d6b6cf10

@ -16,7 +16,8 @@ import sun.misc.BASE64Decoder;
@Controller
public class ImageEditor{
private String filePath = "c:/users/xitdev/temp";
//private String filePath = "c:/users/xitdev/temp";
private String filePath = "/Users/minuk/temp";
@RequestMapping(value = "/imageEditor")
public String imageEditor() {

@ -67,7 +67,7 @@ public class CmmFileMgtController {
}
@PostMapping(value = "/upload", consumes = "multipart/form-data")
public ModelAndView saveFiles(final CmmFileDTO.Request cmmFileDto) {
public ModelAndView upload(final CmmFileDTO.Request cmmFileDto) {
if(Checks.isEmpty(cmmFileDto)) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 정보가 존재하지 않습니다.");
if(Checks.isEmpty(cmmFileDto.getJobSeCode())) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다.");
if(Checks.isEmpty(cmmFileDto.getFileJobId())) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다.");
@ -83,6 +83,23 @@ public class CmmFileMgtController {
return mav;
}
@PostMapping(value = "/uploadPaintweb")//, consumes = "multipart/form-data")
public ModelAndView uploadPaintweb(final CmmFileDTO.Request cmmFileDto, MultipartFile imageFile) {
// if(Checks.isEmpty(cmmFileDto)) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 정보가 존재하지 않습니다.");
// if(Checks.isEmpty(cmmFileDto.getJobSeCode())) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다.");
// if(Checks.isEmpty(cmmFileDto.getFileJobId())) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다.");
ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW);
CmmFileDTO.FileMst cmmFileMst = CmmFileDTO.FileMst.builder()
.fileMastrId(cmmFileDto.getFileMastrId())
.jobSeCode(cmmFileDto.getJobSeCode())
.fileJobId(cmmFileDto.getFileJobId())
.build();
cmmFileService.saveFiles(cmmFileMst, Arrays.asList(cmmFileDto.getFiles()));
AjaxMessageMapRenderer.success(mav, MessageKey.CMM_INSERT_SUCCESS);
return mav;
}
@PostMapping(value = "/upload2", consumes = "multipart/form-data")
public ModelAndView saveFiles2(final CmmFileDTO.FileMst cmmFileMst, @RequestParam("files") final MultipartFile[] files) {
if(Checks.isEmpty(cmmFileMst)) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 정보가 존재하지 않습니다.");

@ -124,10 +124,10 @@ exception.log.trace=true
# k byte
file.upload.allow.max-size: 2048
file.upload.allow.ext=
#file.upload.root=/Users/minuk/data/fims/upload
file.upload.root=D:/data/fims/upload
file.upload.root=/Users/minuk/data/fims/upload
#file.upload.root=D:/data/fims/upload
file.upload.natl-newspaper.path=/natl-newspaper
#file.rcv.root=/Users/minuk/project_data/fims/01. \uC5F0\uACC4/01. \uAD6D\uBBFC\uC2E0\uBB38\uACE0
file.rcv.root=D:/project_data/fims/01. \uC5F0\uACC4/01. \uAD6D\uBBFC\uC2E0\uBB38\uACE0r
file.rcv.root=/Users/minuk/project_data/fims/01. \uC5F0\uACC4/01. \uAD6D\uBBFC\uC2E0\uBB38\uACE0
#file.rcv.root=D:/project_data/fims/01. \uC5F0\uACC4/01. \uAD6D\uBBFC\uC2E0\uBB38\uACE0r
file.rcv.natl-newspaper.path=/rcv

@ -247,7 +247,11 @@
,data: {interfaceSeqN: '${reqDTO.interfaceSeqN}'}
,success: (res) => {
// 이미지 클릭시 image editor open
imgDownload(res.data?.contents, '#ctznImg', '${reqDTO.ctznSttemntDetailSn}', true);
const pr = {
interfaceSeqN: '${reqDTO.interfaceSeqN}',
ctznSttemntDetailSn: '${reqDTO.ctznSttemntDetailSn}'
}
imgDownload(res.data?.contents, '#ctznImg', pr, true);
}
})
}

@ -33,6 +33,7 @@
pw.config.imageLoad = editImg;
pw.config.imageSaveURL = "/saveImage.do"; // imageSave == image upload
//pw.config.imageSaveURL = "/framework/biz/cmm/file/uploadPaintweb.do"; // imageSave == image upload
pw.config.imageDownloadURL = "/fileDownload.do";
pw.config.afterImageSave = afterImageSave;
@ -44,6 +45,7 @@
$(document).ready(function () {
srcImg = window.opener.document.getElementById('<c:out value="${imageTagId}"/>');
editImg = document.getElementById('editableImage');
editImg.src = srcImg.src;
editImg.onload = function () {

@ -2667,6 +2667,13 @@ function PaintWeb (win, doc) {
progressBar.appendChild(progressRate);
var url = srcImg.src;
const map = new Map(Object.entries(srcImg.dataset));
let pr = '';
map.forEach((v,k)=>{
//pr += ` ${k}="${v}";`;
pr += ` name="${k}"${crlf}${crlf}${v};`;
})
var filename = url.match(ex)[1];
var boundary = 'multipartformboundary' + (new Date).getTime();
@ -2676,8 +2683,10 @@ function PaintWeb (win, doc) {
var builder = dashdash + boundary + crlf + 'Content-Disposition: form-data; name="imageFile"' +
'; filename="' + filename + '";' + crlf + ' Content-Type: application/octet-stream' + crlf + crlf;
// '; filename="' + filename + '";' + pr + crlf + ' Content-Type: application/octet-stream' + crlf + crlf;
builder += idata;
builder += crlf + dashdash + boundary + crlf + 'Content-Disposition: form-data; name="filename"' + crlf + crlf + filename;
//builder += crlf + dashdash + boundary + crlf + 'Content-Disposition: form-data; name="filename"' + crlf + crlf + filename + pr;
builder += crlf + dashdash + boundary + dashdash + crlf;
xhr.onload = function () {
@ -2698,6 +2707,7 @@ function PaintWeb (win, doc) {
}
}
}, false);
xhr.send(builder);
}
/**

@ -6,15 +6,15 @@
* 이미지 url 사용
* @param {object} cmmFileDtls
* @param {string} appendElementId - '#ctznImg'
* @param {string} dtlSeq - 시민신고상세순번
* @param {object} stmtDtlDTO - 시민신고상세정보
* </pre>
*/
function imgDownload(cmmFileDtls, appendElementId, dtlSeq, isEditor) {
function imgDownload(cmmFileDtls, appendElementId, reqDTO, isEditor) {
const downloadUrl = '/framework/biz/cmm/file/download.do';
cmmFileDtls.forEach((dtl, idx) => {
const params = "?filename=" +dtl.orginlFileNm+ $.param(dtl);
const title = dtlSeq ? dtl.orginlFileNm+'['+dtlSeq+']' : dtl.orginlFileNm;
const title = reqDTO ? dtl.orginlFileNm+'['+reqDTO.ctznSttemntDetailSn+']' : dtl.orginlFileNm;
const x = document.createElement("img");
x.setAttribute("src", downloadUrl+params);
x.setAttribute("id", dtl.fileId);
@ -24,9 +24,13 @@ function imgDownload(cmmFileDtls, appendElementId, dtlSeq, isEditor) {
//x.setAttribute("height", "228");
x.setAttribute("title", title);
x.setAttribute("alt", dtl.orginlFileNm);
//x.setAttribute("id", dtl.fileMastrId);
x.setAttribute("name", dtl.orginlFileNm);
x.setAttribute("ctznSttemntDetailSn", dtlSeq);
x.setAttribute("data-file-mastr-id", dtl.fileMastrId);
x.setAttribute("data-file-id", dtl.fileId);
if(reqDTO) {
x.setAttribute("data-interface-seq-n", reqDTO.interfaceSeqN);
x.setAttribute("data-ctzn-sttemnt-detail-sn", reqDTO.ctznSttemntDetailSn);
}
x.addEventListener('click', (e)=>{
if(isEditor) {
fnBiz.pagePopup('imageEditor', {imageTagId: dtl.fileId});
@ -40,56 +44,6 @@ function imgDownload(cmmFileDtls, appendElementId, dtlSeq, isEditor) {
})
}
function imageSaveTo(idata, width, height){
var ex = /\?filename=([a-z0-9\-]+)\&?/i;
var dashdash = '--';
var crlf = '\r\n';
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var progressBar = doc.createElement("div");
progressBar.style.left = ((w-200)/2) + "px";
progressBar.className = "progressBar";
document.body.appendChild(progressBar);
var progressRate = doc.createElement("div");
progressRate.innerText = "Saving";
progressRate.className = "progressRate";
progressBar.appendChild(progressRate);
var url = srcImg.src;
var filename = url.match(ex)[1];
var boundary = 'multipartformboundary' + (new Date).getTime();
var xhr = new XMLHttpRequest();
xhr.open("POST", _self.config.imageSaveURL);
xhr.setRequestHeader('content-type', 'multipart/form-data; boundary='+ boundary);
var builder = dashdash + boundary + crlf + 'Content-Disposition: form-data; name="imageFile"' +
'; filename="' + filename + '";' + crlf + ' Content-Type: application/octet-stream' + crlf + crlf;
builder += idata;
builder += crlf + dashdash + boundary + crlf + 'Content-Disposition: form-data; name="filename"' + crlf + crlf + filename;
builder += crlf + dashdash + boundary + dashdash + crlf;
xhr.onload = function () {
var newImg = document.createElement("IMG");
newImg.onload = function () {
srcImg.src = newImg.src + "#img" + (new Date()).getTime();
if (_self.config.afterImageSave) _self.config.afterImageSave();
}
newImg.src = _self.config.imageDownloadURL + "?filename=" + filename+ "#img" + (new Date()).getTime();
};
xhr.upload.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var p = evt.loaded / evt.total * 100;
progressRate.style.width = p + "%";
progressRate.innerText = progressRate.style.width;
if (p==100) {
progressRate.innerText = "Saved";
}
}
}, false);
xhr.send(builder);
}
/**
* <pre>
@ -126,6 +80,7 @@ function imgDownload2(cmmFileDtls, appendElementId, dtlSeq) {
x.setAttribute("alt", dtl.orginlFileNm);
//x.setAttribute("id", dtl.fileMastrId);
x.setAttribute("name", dtl.orginlFileNm);
x.setAttribute("fileMastrId", dtl.fileMastrId);
x.setAttribute("ctznSttemntDetailSn", dtlSeq);
x.addEventListener('click', (e)=>{
$('#uploadImage').attr("src", url);

Loading…
Cancel
Save