From e7f725c0a131ff8eb3aa9bd1a62d5c6bab56d7f0 Mon Sep 17 00:00:00 2001 From: cha Date: Fri, 30 May 2025 15:35:16 +0900 Subject: [PATCH] =?UTF-8?q?[1068]=20=EA=B2=AC=EC=A0=81=EC=84=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/estimate/EstimateController.java | 7 +++ .../qcast/biz/estimate/EstimateMapper.java | 4 ++ .../qcast/biz/estimate/EstimateService.java | 45 ++++++++++++++++- .../mappers/estimate/estimateMapper.xml | 49 +++++++++++++++++++ 4 files changed, 104 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java index 215d8343..2481a695 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java @@ -103,4 +103,11 @@ public class EstimateController { public EstimateApiResponse selectAgencyCustList(PriceRequest priceRequest) throws Exception { return estimateService.selectAgencyCustList(priceRequest); } + + @Operation(description = "견적서를 삭제한다.") + @PostMapping("/delete-estimate") + @ResponseStatus(HttpStatus.CREATED) + public void deleteEstimate(@RequestBody EstimateRequest estimateRequest) throws Exception { + estimateService.deleteEstimate(estimateRequest); + } } 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 6057e7ee..e5ba5d53 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java @@ -146,4 +146,8 @@ public interface EstimateMapper { // 견적서 수정일 변경 public int updateEstimateLastEditDate(EstimateRequest estimateRequest); + + public int updateEstimateInit(EstimateRequest estimateRequest); + + public int updateEstimateInfoInit(EstimateRequest estimateRequest); } 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 9fdcc8d7..474558cf 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java @@ -1628,7 +1628,7 @@ public class EstimateService { } } catch (Exception e) { - e.printStackTrace(); + log.error("Failed to excelDownload estimate. Request: {}", request, e); throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR); } } @@ -2327,4 +2327,47 @@ public class EstimateService { return response; } + + /** + * 견적서 삭제 (복사이후 배치면 저장) + * @param estimateRequest + * @throws Exception + */ + + public void deleteEstimate(EstimateRequest estimateRequest) throws Exception{ + + if (StringUtils.isEmpty(estimateRequest.getObjectNo())) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Object No")); + } + if (StringUtils.isEmpty(estimateRequest.getPlanNo())) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Plan No")); + } + if (StringUtils.isEmpty(estimateRequest.getSaleStoreId())) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Sale Store ID")); + } + if (StringUtils.isEmpty(estimateRequest.getUserId())) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "User ID")); + } + + try { + // T_PLAN + int cnt = estimateMapper.updateEstimateInit(estimateRequest); + // T_PLAN_INFO + int cnt2 = estimateMapper.updateEstimateInfoInit(estimateRequest); + + // 견적서 모든 아이템 제거 + int cnt3 = estimateMapper.deleteEstimateItemList(estimateRequest); + int cnt4 = estimateMapper.deleteEstimateInfoItemList(estimateRequest); + + } catch (Exception e) { + log.error("Failed to delete estimate. Request: {}", estimateRequest, e); + throw e; // 예외를 재던지기하여 상위 계층에서도 예외를 처리할 수 있도록 함 + } + + + } } diff --git a/src/main/resources/mappers/estimate/estimateMapper.xml b/src/main/resources/mappers/estimate/estimateMapper.xml index 1ac641cb..9519b8fa 100644 --- a/src/main/resources/mappers/estimate/estimateMapper.xml +++ b/src/main/resources/mappers/estimate/estimateMapper.xml @@ -729,6 +729,32 @@ AND PLAN_NO = #{planNo} + + /* sqlid : com.interplug.qcast.biz.estimate.updateEstimate */ + UPDATE T_PLAN + SET + CONSTRUCT_SPECIFICATION = NULL + ,SETUP_HEIGHT = NULL + ,WEATHER_POINT = NULL + ,SLOPE = NULL + ,ROOF_MATERIAL_ID = NULL + ,SUPPORT_METHOD_ID = NULL + ,MODULE_MODEL = NULL + ,DRAWING_ESTIMATE_CREATE_DATE = NULL + ,ESTIMATE_VALIDITY_TERM = NULL + ,CAPACITY = NULL + ,SNOWFALL = NULL + ,STANDARD_WIND_SPEED_ID = NULL + ,PC_TYPE_NO = NULL + ,ROOF_MATERIAL_ID_MULTI = NULL + ,SUPPORT_MEAKER_MULTI = NULL + ,SUPPORT_METHOD_ID_MULTI = NULL + ,LAST_EDIT_DATETIME = GETDATE() + ,LAST_EDIT_USER = #{userId} + WHERE OBJECT_NO = #{objectNo} + AND PLAN_NO = #{planNo} + + /* sqlid : com.interplug.qcast.biz.estimate.updateEstimateInfoReset */ UPDATE T_PLAN_INFO @@ -745,6 +771,29 @@ AND PLAN_NO = #{planNo} + + /* sqlid : com.interplug.qcast.biz.estimate.updateEstimateInfoReset */ + UPDATE T_PLAN_INFO + SET + CONSTRUCT_SPECIFICATION_MULTI = NULL + , SURFACE_TYPE = NULL + , ANGLE = NULL + , ESTIMATE_DATE = NULL + , ESTIMATE_TYPE = NULL + , FILE_FLG = 0 + , ESTIMATE_OPTION = NULL + , PKG_ASP = NULL + , DOC_NO = NULL + , PRICE_CD = NULL + , REMARKS = NULL + , TEMP_FLG = 1 + , LOCK_FLG = 0 + , SYNC_FLG = NULL + , SEC_SAP_SALES_STORE_CD = NULL + WHERE OBJECT_NO = #{objectNo} + AND PLAN_NO = #{planNo} + + /* sqlid : com.interplug.qcast.biz.estimate.updateEstimateLock */ UPDATE T_PLAN_INFO