pdf출력시 모자이크 표시 추가

main
이범준 11 months ago
parent 2edc98ad6f
commit e23d643603

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

@ -58,4 +58,18 @@ public class PstnAndSize {
this.height = this.height * 2.0f; this.height = this.height * 2.0f;
return this; return this;
} }
public PstnAndSize transXY(float transX, float transY) {
this.left = this.left * transX;
this.top = this.top * transY;
this.width = this.width * transX;
this.height = this.height * transY;
return this;
}
public PstnAndSize addPstn(Pstn pstn) {
this.left = this.left + pstn.getLeft();
this.top = this.top + pstn.getTop();
return this;
}
} }

@ -107,6 +107,9 @@ public class Advntce extends PDFFormat {
case "rprsCrdnPhoto" -> { //대표사진 case "rprsCrdnPhoto" -> { //대표사진
result = dataObject.string("CRDN_PHOTO1"); result = dataObject.string("CRDN_PHOTO1");
} }
case "rprsCrdnPhotoKey" -> { //대표사진
result = dataObject.string("CRDN_PHOTO1"+"KEY");
}
case "rtpyrNm" -> { case "rtpyrNm" -> {
result = dataObject.string("RTPYR_NM"); result = dataObject.string("RTPYR_NM");
} }
@ -294,6 +297,13 @@ public class Advntce extends PDFFormat {
i++; i++;
} }
} }
case "crdnPhotoKey" -> {
int i = 1;
while(!dataObject.string("CRDN_PHOTO"+i+"KEY").equals("")) {
result.add(dataObject.string("CRDN_PHOTO"+i+"KEY"));
i++;
}
}
} }
return result; return result;

@ -114,6 +114,9 @@ public class Nht extends PDFFormat {
case "rprsCrdnPhoto" -> { //대표사진 case "rprsCrdnPhoto" -> { //대표사진
result = dataObject.string("CRDN_PHOTO1"); result = dataObject.string("CRDN_PHOTO1");
} }
case "rprsCrdnPhotoKey" -> { //대표사진
result = dataObject.string("CRDN_PHOTO1"+"KEY");
}
case "rtpyrNm" -> { case "rtpyrNm" -> {
result = dataObject.string("RTPYR_NM"); result = dataObject.string("RTPYR_NM");
} }

@ -1,12 +1,17 @@
package cokr.xit.fims.cmmn.service.bean; package cokr.xit.fims.cmmn.service.bean;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.imageio.ImageIO;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import cokr.xit.fims.cmmn.dao.MosaicMapper; import cokr.xit.fims.cmmn.dao.MosaicMapper;
import cokr.xit.fims.cmmn.pdf.PstnAndSize;
import cokr.xit.foundation.AbstractComponent; import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
@ -23,4 +28,40 @@ public class MosaicBean extends AbstractComponent {
public List<DataObject> getMosaicList(String fileId){ public List<DataObject> getMosaicList(String fileId){
return mosaicMapper.selectMosaicList(fileId); return mosaicMapper.selectMosaicList(fileId);
} }
public List<PstnAndSize> getTransformedMosaic(String imageKey, String imagePath, PstnAndSize pstnAndSize_in_print) {
List<PstnAndSize> result = new ArrayList<>();
try {
BufferedImage image = ImageIO.read(new File(imagePath));
float originalWidth = image.getWidth(null);
float originalHeight = image.getHeight(null);
float transX = pstnAndSize_in_print.getWidth() / originalWidth;
float transY = pstnAndSize_in_print.getHeight() / originalHeight;
List<DataObject> mosaicInfos = this.getMosaicList(imageKey);
if(mosaicInfos != null) {
for(int k=0; k < mosaicInfos.size(); k++) {
DataObject mosaicInfo = mosaicInfos.get(k);
float x = mosaicInfo.number("X_AXS").floatValue();
float y = mosaicInfo.number("Y_AXS").floatValue();
float w = mosaicInfo.number("MOSC_LT").floatValue();
float h = mosaicInfo.number("MOSC_HG").floatValue();
PstnAndSize mosaic = new PstnAndSize(x, y, w, h);
mosaic.transXY(transX, transY);
mosaic.addPstn(pstnAndSize_in_print.getPstn());
result.add(mosaic);
}
}
} catch (Exception e) {
throw new RuntimeException("이미지 모자이크 처리 오류");
}
return result;
}
} }

@ -338,6 +338,7 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
for(int j=0; j<fileInfoList.size(); j++) { for(int j=0; j<fileInfoList.size(); j++) {
dataObject.set("CRDN_PHOTO"+(j+1), fileInfoList.get(j).string("URL")); dataObject.set("CRDN_PHOTO"+(j+1), fileInfoList.get(j).string("URL"));
dataObject.set("CRDN_PHOTO"+(j+1)+"KEY", fileInfoList.get(j).string("FILE_ID"));
} }
} }
@ -466,12 +467,37 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
} else if(prototypeStng.getComponentType().equals("image")) { } else if(prototypeStng.getComponentType().equals("image")) {
String imagePath = pdfFormat.getMappingValue(otptArtclNm,defaultValue,forPost,dataObject,printOption,pdfPrintUtil); String imagePath = pdfFormat.getMappingValue(otptArtclNm,defaultValue,forPost,dataObject,printOption,pdfPrintUtil);
String imageKey = "";
if(otptArtclNm.equals("rprsCrdnPhoto")) {
imageKey = pdfFormat.getMappingValue(otptArtclNm+"Key",defaultValue,forPost,dataObject,printOption,pdfPrintUtil);
}
pdfPrintUtil.insertImage(doc, contentStream, imagePath, pstn, size); pdfPrintUtil.insertImage(doc, contentStream, imagePath, pstn, size);
if(otptArtclNm.equals("rprsCrdnPhoto") && !imageKey.equals("")) {
String blackImage = "samplefiles/black.png";
List<PstnAndSize> transformedMosaicInfos = mosaicBean.getTransformedMosaic(
imageKey, imagePath, new PstnAndSize(pstn[0],pstn[1], size[0], size[1])
);
for(int k=0; k < transformedMosaicInfos.size(); k++) {
PstnAndSize mosaicInfo = transformedMosaicInfos.get(k);
pdfPrintUtil.insertImage(doc, contentStream, blackImage,
mosaicInfo.getPstn().to2Float(), mosaicInfo.getSize().to2Float());
}
}
} else if(prototypeStng.getComponentType().equals("images")) { } else if(prototypeStng.getComponentType().equals("images")) {
List<String> imagePaths = pdfFormat.getMappingValues(otptArtclNm,defaultValue,forPost,dataObject,printOption,pdfPrintUtil); List<String> imagePaths = pdfFormat.getMappingValues(otptArtclNm,defaultValue,forPost,dataObject,printOption,pdfPrintUtil);
List<String> imageKeys = new ArrayList<String>();
if(otptArtclNm.equals("crdnPhoto")) {
imageKeys = pdfFormat.getMappingValues(otptArtclNm+"Key",defaultValue,forPost,dataObject,printOption,pdfPrintUtil);
if(rprsCrdnPhotoYn && imagePaths.size() > 0) {
imageKeys.remove(0);
}
}
if(otptArtclNm.equals("crdnPhoto")) { if(otptArtclNm.equals("crdnPhoto")) {
if(rprsCrdnPhotoYn && imagePaths.size() > 0) { if(rprsCrdnPhotoYn && imagePaths.size() > 0) {
@ -492,6 +518,23 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
pdfPrintUtil.insertImage(doc, contentStream, pdfPrintUtil.insertImage(doc, contentStream,
imagePaths.get(i), devideInfo.getPstn().to2Float(), devideInfo.getSize().to2Float()); imagePaths.get(i), devideInfo.getPstn().to2Float(), devideInfo.getSize().to2Float());
if(otptArtclNm.equals("crdnPhoto") && !imageKeys.isEmpty()) {
String blackImage = "samplefiles/black.png";
List<PstnAndSize> transformedMosaicInfos = mosaicBean.getTransformedMosaic(
imageKeys.get(i), imagePaths.get(i), devideInfo
);
for(int k=0; k < transformedMosaicInfos.size(); k++) {
PstnAndSize mosaicInfo = transformedMosaicInfos.get(k);
pdfPrintUtil.insertImage(doc, contentStream, blackImage,
mosaicInfo.getPstn().to2Float(), mosaicInfo.getSize().to2Float());
}
}
} }
} }

@ -247,7 +247,7 @@
선택자료 선택자료
<strong id="curDataVhrno--${pageName}"></strong> <strong id="curDataVhrno--${pageName}"></strong>
<div id="curDataFiles--${pageName}" <div id="curDataFiles--${pageName}"
style="width: 100%;height: 180px;overflow-x: scroll;background-color:#D9DEE3;"> style="width: 100%;height: 180px;overflow-x: scroll;background-color:#D9DEE3;display:flex;">
</div> </div>
</div> </div>
@ -255,7 +255,7 @@
비교자료(선택자료의 다음 자료가 보여집니다.) 비교자료(선택자료의 다음 자료가 보여집니다.)
<strong id="nextDataVhrno--${pageName}"></strong> <strong id="nextDataVhrno--${pageName}"></strong>
<div id="nextDataFiles--${pageName}" <div id="nextDataFiles--${pageName}"
style="width: 100%;height: 180px;overflow-x: scroll;background-color:#D9DEE3;"> style="width: 100%;height: 180px;overflow-x: scroll;background-color:#D9DEE3;display:flex;">
</div> </div>
</div> </div>

@ -8,10 +8,12 @@ export class InspectionControl {
export function fnMakeImgTag(url, title, crdnPhotoId, mosaic) { export function fnMakeImgTag(url, title, crdnPhotoId, mosaic) {
return `<div style="position:relative"> return `<div style="display:flex;min-width:300px;">
<div style="position:relative">
<img src="${url}" alt="${title}" height="150" style="position:absolute;" <img src="${url}" alt="${title}" height="150" style="position:absolute;"
data-crdn-photo-id=${crdnPhotoId} data-crdn-photo-id=${crdnPhotoId}
data-mosaic="${mosaic}" data-mosaic="${mosaic}"
onload="fn_photoMask($('#photoMask--top').is(':checked'),this);" /> onload="fn_photoMask($('#photoMask--top').is(':checked'),this);" />
</div>
</div>`; </div>`;
} }
Loading…
Cancel
Save