From 31d216f03c0793acff5627771a7c618967725918 Mon Sep 17 00:00:00 2001 From: "LAPTOP-L3VE7KK2\\USER" Date: Wed, 13 Nov 2024 14:33:16 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=EC=A7=80=EB=B6=95=EC=9E=AC=20=EC=97=91?= =?UTF-8?q?=EC=85=80=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=20API=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qcast/biz/estimate/EstimateMapper.java | 6 ++ .../qcast/biz/estimate/EstimateService.java | 21 +++++ .../biz/estimate/dto/EstimateRequest.java | 11 ++- .../biz/estimate/dto/RoofInfoResponse.java | 6 ++ .../qcast/biz/estimate/dto/RoofResponse.java | 15 ++++ .../mappers/estimate/estimateMapper.xml | 83 ++++++++++++++++++- 6 files changed, 135 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java index 8fcc17b6..caa65943 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java @@ -24,6 +24,12 @@ public interface EstimateMapper { // 견적서 지붕재 목록 조회 public List selectEstimateRoofList(EstimateRequest estimateRequest); + // 견적서 지붕재 PC 목록 조회 + public List selectEstimateRoofPcList(EstimateRequest estimateRequest); + + // 견적서 지붕재 용량 목록 조회 + public List selectEstimateRoofVolList(EstimateRequest estimateRequest); + // 견적서 특이사항 목록 조회 public List selectEstimateNoteList(NoteRequest noteRequest); diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java index fb0f62a0..55a51206 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java @@ -683,9 +683,30 @@ public class EstimateService { } // 지붕재 목록 조회 + estimateRequest.setSchItemGroup("MODULE_"); + RoofInfoResponse roofInfoResponse = new RoofInfoResponse(); List roofList = estimateMapper.selectEstimateRoofList(estimateRequest); + List roofPcList = estimateMapper.selectEstimateRoofPcList(estimateRequest); + List roofVolList = estimateMapper.selectEstimateRoofVolList(estimateRequest); + + BigDecimal moduleTotAmount = BigDecimal.ZERO; + BigDecimal moduleTotVol = BigDecimal.ZERO; + for (RoofResponse roofVol : roofVolList) { + BigDecimal amount = + new BigDecimal(StringUtils.isEmpty(roofVol.getAmount()) ? "0" : roofVol.getAmount()); + BigDecimal vol = + new BigDecimal(StringUtils.isEmpty(roofVol.getVol()) ? "0" : roofVol.getVol()); + + moduleTotAmount = moduleTotAmount.add(amount); + moduleTotVol = moduleTotVol.add(vol); + } + roofInfoResponse.setModuleTotAmount(String.valueOf(moduleTotAmount)); + roofInfoResponse.setModuleTotVol(String.valueOf(moduleTotVol)); + roofInfoResponse.setRoofList(roofList); + roofInfoResponse.setRoofPcList(roofPcList); + roofInfoResponse.setRoofVolList(roofVolList); estimateResponse.setRoofInfo(roofInfoResponse); diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateRequest.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateRequest.java index daee7689..55950d59 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateRequest.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateRequest.java @@ -163,18 +163,21 @@ public class EstimateRequest { private String[] arrItemId; // 다운로드 관련 조건 - @Schema(description = "다운로드 정가 표시여부") + @Schema(description = "검색 - 다운로드 정가 표시여부") private String schUnitPriceFlg; - @Schema(description = "다운로드 표시여부") + @Schema(description = "검색 - 다운로드 표시여부") private String schDisplayFlg; - @Schema(description = "가대중량표 포함 여부") + @Schema(description = "검색 - 가대중량표 포함 여부") private String schWeightFlg; - @Schema(description = "도면 포함 여부") + @Schema(description = "검색 - 도면 포함 여부") private String schDrawingFlg; + @Schema(description = "검색 - 아이템 그룹") + private String schItemGroup; + // 데이터 목록 관련 정보 @Schema(description = "지붕재 목록") List roofList; diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/RoofInfoResponse.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/RoofInfoResponse.java index 3f090e04..c367eb4a 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/dto/RoofInfoResponse.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/RoofInfoResponse.java @@ -9,6 +9,12 @@ import lombok.Setter; @Getter @Setter public class RoofInfoResponse { + @Schema(description = "모듈 총 수") + private String moduleTotAmount; + + @Schema(description = "모듈 총 용량") + private String moduleTotVol; + @Schema(description = "지붕면 목록") private List roofList; diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/RoofResponse.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/RoofResponse.java index e4d131b2..81c95d57 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/dto/RoofResponse.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/RoofResponse.java @@ -64,4 +64,19 @@ public class RoofResponse { @Schema(description = "설치높이") private String setupHeight; + + @Schema(description = "아이템 ID") + private String itemId; + + @Schema(description = "아이템 번호") + private String itemNo; + + @Schema(description = "매수") + private String amount; + + @Schema(description = "용량") + private String vol; + + @Schema(description = "Pc 모듈 매수") + private String pcModuleAmount; } diff --git a/src/main/resources/mappers/estimate/estimateMapper.xml b/src/main/resources/mappers/estimate/estimateMapper.xml index 48c295d1..a9c30992 100644 --- a/src/main/resources/mappers/estimate/estimateMapper.xml +++ b/src/main/resources/mappers/estimate/estimateMapper.xml @@ -120,7 +120,7 @@ + + + + + + /* sqlid : com.interplug.qcast.biz.estimate.selectEstimateRoofVolList */ SELECT - T.OBJECT_NO + T.OBJECT_NO , T.PLAN_NO + , T.ROOF_NO , T.ROOF_SURFACE , T.SLOPE , SUM(T.AMOUNT) AS AMOUNT - , ROUND(SUM(T.AMOUNT * T.SPECIFICATION / 1000), 4) AS VOL + , ROUND(SUM(T.AMOUNT * T.SPECIFICATION / 1000), 4) AS VOL_KW FROM ( SELECT P.OBJECT_NO , P.PLAN_NO + , RE.ROOF_NO , RE.ROOF_SURFACE , ROUND(CAST(RE.SLOPE AS FLOAT), 2) AS SLOPE , RIE.AMOUNT @@ -323,7 +367,7 @@ AND I.ITEM_GROUP = #{schItemGroup} ) T - GROUP BY T.OBJECT_NO, T.PLAN_NO, T.ROOF_SURFACE, T.SLOPE + GROUP BY T.OBJECT_NO, T.PLAN_NO, T.ROOF_NO, T.ROOF_SURFACE, T.SLOPE + + /* sqlid : com.interplug.qcast.biz.estimate.updateObject */ UPDATE T_OBJECT @@ -560,6 +569,56 @@ ) + + /* sqlid : com.interplug.qcast.biz.estimate.insertEstimateItemHits */ + INSERT INTO T_PART_ESTIMATE_HIS + ( + HIS_NO + , OBJECT_NO + , PLAN_NO + , DISP_ORDER + , ITEM_ID + , ITEM_NO + , ITEM_NAME + , UNIT + , AMOUNT + , UNIT_PRICE + , SALE_PRICE + + , SPECIAL_NOTE_CD + + , PKG_MATERIAL_FLG + , ITEM_CHANGE_FLG + , FILE_UPLOAD_FLG + , PART_ADD + , DEL_FLG + , CREATE_DATETIME + , CREATE_USER + ) VALUES ( + #{hisNo} + , #{objectNo} + , #{planNo} + , #{dispOrder} + , #{itemId} + , #{itemNo} + , #{itemName} + , #{unit} + , #{amount} + , #{unitPrice} + , #{salePrice} + + , #{specialNoteCd} + + , #{pkgMaterialFlg} + , #{itemChangeFlg} + , #{fileUploadFlg} + , #{partAdd} + , #{delFlg} + , GETDATE() + , #{userId} + ) + + /* sqlid : com.interplug.qcast.biz.estimate.insertEstimateRoof */ @@ -638,21 +697,21 @@ /* sqlid : com.interplug.qcast.biz.estimate.deleteEstimateRoofList */ DELETE FROM T_ROOF_ESTIMATE WHERE OBJECT_NO = #{objectNo} - AND PLAN_NO = #{planNo} + AND PLAN_NO = #{planNo} /* sqlid : com.interplug.qcast.biz.estimate.deleteEstimateRoofItemList */ DELETE FROM T_ROOF_ITEM_ESTIMATE WHERE OBJECT_NO = #{objectNo} - AND PLAN_NO = #{planNo} + AND PLAN_NO = #{planNo} /* sqlid : com.interplug.qcast.biz.estimate.deleteEstimateItemList */ DELETE FROM T_PART_ESTIMATE WHERE OBJECT_NO = #{objectNo} - AND PLAN_NO = #{planNo} + AND PLAN_NO = #{planNo} From e9aca66971243854d4ece340dffa50e675f04049 Mon Sep 17 00:00:00 2001 From: "DESKTOP-6ARNG1Q\\dlsgk" Date: Thu, 14 Nov 2024 11:28:02 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=ED=94=8C=EB=9E=9C?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interplug/qcast/biz/pwrGnrSimulation/PwrGnrSimService.java | 1 - src/main/resources/mappers/file/fileMapper.xml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/interplug/qcast/biz/pwrGnrSimulation/PwrGnrSimService.java b/src/main/java/com/interplug/qcast/biz/pwrGnrSimulation/PwrGnrSimService.java index 066faf51..7c4af5a5 100644 --- a/src/main/java/com/interplug/qcast/biz/pwrGnrSimulation/PwrGnrSimService.java +++ b/src/main/java/com/interplug/qcast/biz/pwrGnrSimulation/PwrGnrSimService.java @@ -1418,7 +1418,6 @@ public class PwrGnrSimService { + "'>"); sb2.append(""); } - System.err.println("htmlx :: " + sb2.toString()); elm = doc.getElementById("htmlX"); elm.append(sb2.toString()); } diff --git a/src/main/resources/mappers/file/fileMapper.xml b/src/main/resources/mappers/file/fileMapper.xml index 3f65ad61..b18361ce 100644 --- a/src/main/resources/mappers/file/fileMapper.xml +++ b/src/main/resources/mappers/file/fileMapper.xml @@ -7,6 +7,7 @@ SELECT TOP 1 U.OBJECT_NO + , U.PLAN_NO , U.NO , U.FAILE_NAME , U.CATEGORY From 9ee29819dd3efb296ebe3d63afbe6a8575d1a22f Mon Sep 17 00:00:00 2001 From: "DESKTOP-6ARNG1Q\\dlsgk" Date: Thu, 14 Nov 2024 11:41:39 +0900 Subject: [PATCH 7/7] =?UTF-8?q?Pdf=20Utill=20section=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qcast/biz/estimate/EstimateService.java | 5 +- .../com/interplug/qcast/util/PdfUtil.java | 110 ++++++++++-------- 2 files changed, 64 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java index 270ac867..f5ac681f 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java @@ -793,17 +793,18 @@ public class EstimateService { estimateResponse.setPwrGnrSim(pwrGnrSimResponse); - if (true) { + if (true) { // PDF 다운로드 String[] arrSection = new String[3]; // TODO Section 갯수 넣기 int iSection = 0; - // PDF 다운로드 String pdfFileName = "Quation_Detail_" + new SimpleDateFormat("yyyyMMdd").format(new Date()); String templateFilePath = "pdf_download_quotation_detail_template.html"; // 템플릿 html 조회 Document doc = PdfUtil.getPdfDoc(request, templateFilePath); + + // 삭제하려는 element Element elm; // 발전시뮬레이션 pdf Html 생성 diff --git a/src/main/java/com/interplug/qcast/util/PdfUtil.java b/src/main/java/com/interplug/qcast/util/PdfUtil.java index cc6697f8..ae25eb62 100644 --- a/src/main/java/com/interplug/qcast/util/PdfUtil.java +++ b/src/main/java/com/interplug/qcast/util/PdfUtil.java @@ -78,68 +78,57 @@ public class PdfUtil { PdfWriter writer = new PdfWriter(os); PdfDocument pdfDoc = new PdfDocument(writer)) { - // ConverterProperties 생성 - ConverterProperties properties = new ConverterProperties(); - // 폰트 설정 - DefaultFontProvider fontProvider = new DefaultFontProvider(false, false, false); + ConverterProperties properties = new ConverterProperties(); String fontPath = "template/pdf/BIZUDPGothic-Regular.ttf"; - InputStream fontStream = PdfUtil.class.getClassLoader().getResourceAsStream(fontPath); + properties.setFontProvider(setFontProvider(fontPath)); - if (fontStream != null) { - File tempFontFile = Files.createTempFile("BIZUDPGothic-Regular", ".ttf").toFile(); - Files.copy( - fontStream, tempFontFile.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); - fontProvider.addFont(tempFontFile.getAbsolutePath()); - fontStream.close(); - tempFontFile.deleteOnExit(); + // arrSection이 비어 있는 경우 HTML 전체를 변환 + if (arrSection == null || arrSection.length == 0) { + // HTML 전체를 pdfDoc에 직접 변환 + HtmlConverter.convertToPdf( + new ByteArrayInputStream(doc.html().getBytes(StandardCharsets.UTF_8)), os, properties); + os.flush(); } else { - log.error("폰트 파일을 찾을 수 없습니다: " + fontPath); - } - properties.setFontProvider(fontProvider); + // arrSection이 있는 경우 각 섹션을 개별적으로 변환 후 병합 + String headHtml = doc.select("head").outerHtml(); - // 원본 HTML에서 내용을 추출 - String headHtml = doc.select("head").outerHtml(); // 의 전체 내용을 가져옵니다. + PdfMerger merger = new PdfMerger(pdfDoc); + for (String section : arrSection) { + if (section != null && !"".equals(section)) { + Elements eSections = doc.select(section); + if (eSections != null && eSections.size() > 0) { + for (Element eSection : eSections) { - PdfMerger merger = new PdfMerger(pdfDoc); // 최종 문서에 병합할 PdfMerger 생성 - // arrSection의 각 섹션을 PDF에 추가 - for (String section : arrSection) { - if (section != null && !"".equals(section)) { - Elements eSections = doc.select(section); // 섹션 선택 - if (eSections != null && eSections.size() > 0) { - for (Element eSection : eSections) { + String sectionHtml = + "" + headHtml + "" + eSection.outerHtml() + ""; - String sectionHtml = - "" + headHtml + "" + eSection.outerHtml() + ""; + try (ByteArrayOutputStream tempOutputStream = new ByteArrayOutputStream(); + PdfWriter tempWriter = new PdfWriter(tempOutputStream); + PdfDocument tempPdfDoc = new PdfDocument(tempWriter)) { - // 각 섹션을 임시 PDF 파일에 변환 - try (ByteArrayOutputStream tempOutputStream = new ByteArrayOutputStream(); - PdfWriter tempWriter = new PdfWriter(tempOutputStream); - PdfDocument tempPdfDoc = new PdfDocument(tempWriter)) { + HtmlConverter.convertToPdf( + new ByteArrayInputStream(sectionHtml.getBytes(StandardCharsets.UTF_8)), + tempPdfDoc, + properties); - HtmlConverter.convertToPdf( - new ByteArrayInputStream(sectionHtml.getBytes(StandardCharsets.UTF_8)), - tempPdfDoc, - properties); + PdfDocument tempDoc = + new PdfDocument( + new PdfReader(new ByteArrayInputStream(tempOutputStream.toByteArray()))); + merger.merge(tempDoc, 1, tempDoc.getNumberOfPages()); + tempDoc.close(); - // tempPdfDoc을 메인 pdfDoc에 병합 - PdfDocument tempDoc = - new PdfDocument( - new PdfReader(new ByteArrayInputStream(tempOutputStream.toByteArray()))); - merger.merge(tempDoc, 1, tempDoc.getNumberOfPages()); - tempDoc.close(); - - // 마지막 섹션이 아닐 경우 새 페이지 추가 - if (!eSection.equals(eSections.last())) { - pdfDoc.addNewPage(); + if (!eSection.equals(eSections.last())) { + pdfDoc.addNewPage(); + } } } - } // for - } // if - } // if + } + } + } + pdfDoc.close(); + os.flush(); } - pdfDoc.close(); // 전체 PDF 문서 작성이 끝난 후에 한번만 닫기 - os.flush(); } catch (Exception e) { log.error("PDF 생성 중 오류 발생: " + e.getMessage(), e); if (!response.isCommitted()) { @@ -148,4 +137,27 @@ public class PdfUtil { } } } + + /** + * 폰트 설정 메서드 + * + * @param fontPath 폰트 파일 경로 + * @return 설정된 FontProvider + */ + private static DefaultFontProvider setFontProvider(String fontPath) throws IOException { + DefaultFontProvider fontProvider = new DefaultFontProvider(false, false, false); + InputStream fontStream = PdfUtil.class.getClassLoader().getResourceAsStream(fontPath); + + if (fontStream != null) { + File tempFontFile = Files.createTempFile("BIZUDPGothic-Regular", ".ttf").toFile(); + Files.copy( + fontStream, tempFontFile.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); + fontProvider.addFont(tempFontFile.getAbsolutePath()); + fontStream.close(); + tempFontFile.deleteOnExit(); + } else { + log.error("폰트 파일을 찾을 수 없습니다: " + fontPath); + } + return fontProvider; + } }