From b3a21f959c6c0a0ebda1fb7b211797ad8ccafc0c Mon Sep 17 00:00:00 2001 From: "LAPTOP-L3VE7KK2\\USER" Date: Mon, 14 Oct 2024 13:17:17 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=BC=EA=B1=B4=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20-=20QSP=20=EC=84=A4=EA=B3=84=EC=9D=98?= =?UTF-8?q?=EB=A2=B0=20=EB=AC=BC=EA=B1=B4=EC=A0=95=EB=B3=B4=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EA=B0=9C=EB=B0=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qcast/biz/object/ObjectController.java | 8 +- .../qcast/biz/object/ObjectService.java | 111 +++++++++++++++++- .../qcast/biz/object/dto/ObjectRequest.java | 6 + .../qcast/biz/object/dto/ObjectResponse.java | 3 + .../qcast/biz/object/dto/PlanReqRequest.java | 6 + .../resources/mappers/object/objectMapper.xml | 4 + 6 files changed, 131 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/object/ObjectController.java b/src/main/java/com/interplug/qcast/biz/object/ObjectController.java index 1501f548..5c4deb91 100644 --- a/src/main/java/com/interplug/qcast/biz/object/ObjectController.java +++ b/src/main/java/com/interplug/qcast/biz/object/ObjectController.java @@ -47,7 +47,7 @@ public class ObjectController { return objectService.selectSaleStoreList(saleStoreId); } - @Operation(description = "물건정보 목록을 조회한다.11") + @Operation(description = "물건정보 목록을 조회한다.") @GetMapping("/list") @ResponseStatus(HttpStatus.OK) public List selectObjectList(ObjectRequest objectRequest) throws Exception { @@ -78,8 +78,10 @@ public class ObjectController { @Operation(description = "물건정보을 삭제한다.") @DeleteMapping("/{objectNo}") @ResponseStatus(HttpStatus.NO_CONTENT) - public void deleteObject(@PathVariable String objectNo) throws Exception { - objectService.deleteObject(objectNo); + public void deleteObject(@PathVariable String objectNo, ObjectRequest objectRequest) + throws Exception { + objectRequest.setObjectNo(objectNo); + objectService.deleteObject(objectRequest); } @Operation(description = "물건정보의 플랜정보를 추가한다.") diff --git a/src/main/java/com/interplug/qcast/biz/object/ObjectService.java b/src/main/java/com/interplug/qcast/biz/object/ObjectService.java index 4ca99fc3..0a395214 100644 --- a/src/main/java/com/interplug/qcast/biz/object/ObjectService.java +++ b/src/main/java/com/interplug/qcast/biz/object/ObjectService.java @@ -12,6 +12,7 @@ import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.List; +import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomStringUtils; @@ -85,6 +86,18 @@ public class ObjectService { int result = 0; String objectNo = ""; + // Validation + if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) { + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Sale Store ID")); + } + if (StringUtils.isEmpty(objectRequest.getSaleStoreLevel())) { + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Sale Store Level")); + } + // 물건번호 등록/조회 if ("0".equals(objectRequest.getTempFlg())) { objectRequest.setDelFlg("0"); @@ -135,6 +148,34 @@ public class ObjectService { planRequest.setUserId(objectRequest.getUserId()); result += objectMapper.insertPlan(planRequest); + // 플랜번호 존재 시 물건번호 업데이트 + if ("0".equals(objectRequest.getTempFlg()) + && !StringUtils.isEmpty(objectRequest.getPlanReqNo())) { + PlanReqResponse response = null; + + PlanReqRequest planReqRequest = new PlanReqRequest(); + planReqRequest.setSaleStoreId(objectRequest.getSaleStoreId()); + planReqRequest.setSaleStoreLevel(objectRequest.getSaleStoreLevel()); + planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo()); + planReqRequest.setObjectNo(objectRequest.getObjectNo()); + + String strResponse = + interfaceQsp.callApi( + HttpMethod.POST, QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest); + if (!"".equals(strResponse)) { + com.fasterxml.jackson.databind.ObjectMapper om = + new com.fasterxml.jackson.databind.ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + response = om.readValue(strResponse, PlanReqResponse.class); + + Map map = (Map) response.getResult(); + if ("E".equals(String.valueOf(map.get("resultCode")))) { + throw new QcastException( + ErrorCode.INTERNAL_SERVER_ERROR, String.valueOf(map.get("resultMsg"))); + } + } + } + // 결과 데이터 리턴 ObjectResponse objectResponse = new ObjectResponse(); objectResponse.setObjectNo(objectNo); @@ -147,6 +188,18 @@ public class ObjectService { int result = 0; boolean tempChgFlg = false; + // Validation + if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) { + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Sale Store ID")); + } + if (StringUtils.isEmpty(objectRequest.getSaleStoreLevel())) { + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Sale Store Level")); + } + // object 상세 정보 조회 ObjectResponse objectResponse = objectMapper.selectObjectDetail(objectRequest.getObjectNo()); @@ -178,6 +231,33 @@ public class ObjectService { if (tempChgFlg) { objectMapper.updateObjectNoChange(objectRequest); objectMapper.updatePlanObjectNoChange(objectRequest); + + // 플랜번호 존재 시 물건번호 업데이트 + if (!StringUtils.isEmpty(objectRequest.getPlanReqNo())) { + PlanReqResponse response = null; + + PlanReqRequest planReqRequest = new PlanReqRequest(); + planReqRequest.setSaleStoreId(objectRequest.getSaleStoreId()); + planReqRequest.setSaleStoreLevel(objectRequest.getSaleStoreLevel()); + planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo()); + planReqRequest.setObjectNo(objectRequest.getNewObjectNo()); + + String strResponse = + interfaceQsp.callApi( + HttpMethod.POST, QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest); + if (!"".equals(strResponse)) { + com.fasterxml.jackson.databind.ObjectMapper om = + new com.fasterxml.jackson.databind.ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + response = om.readValue(strResponse, PlanReqResponse.class); + + Map map = (Map) response.getResult(); + if ("E".equals(String.valueOf(map.get("resultCode")))) { + throw new QcastException( + ErrorCode.INTERNAL_SERVER_ERROR, String.valueOf(map.get("resultMsg"))); + } + } + } } } @@ -188,18 +268,30 @@ public class ObjectService { return objectResponse; } - public int deleteObject(String objectNo) throws Exception { + public int deleteObject(ObjectRequest objectRequest) throws Exception { int result = 0; + // Validation + if (StringUtils.isEmpty(objectRequest.getObjectNo())) { + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Object No")); + } + // 물건정보 삭제 - ObjectRequest objectRequest = new ObjectRequest(); - objectRequest.setObjectNo(objectNo); result = objectMapper.deleteObject(objectRequest); return result; } public String insertPlan(PlanRequest planRequest) throws Exception { + // Validation + if (StringUtils.isEmpty(planRequest.getObjectNo())) { + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Object No")); + } + // 추가 Plan 등록 planRequest.setRoofKindId("0"); planRequest.setStatus("1"); @@ -220,6 +312,18 @@ public class ObjectService { public PlanReqResponse selectPlanReqList(PlanReqRequest planReqRequest) throws Exception { + // Validation + if (StringUtils.isEmpty(planReqRequest.getSaleStoreId())) { + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Sale Store ID")); + } + if (StringUtils.isEmpty(planReqRequest.getSaleStoreLevel())) { + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "Sale Store Level")); + } + PlanReqResponse response = null; /* [1]. QSP API (url + param) Setting */ @@ -233,7 +337,6 @@ public class ObjectService { URLEncoder.encode(planReqRequest.getSchPlanReqName(), StandardCharsets.UTF_8); String url = QSP_API_URL + "/api/planReq/list"; - System.out.println(url); String apiUrl = UriComponentsBuilder.fromHttpUrl(url) .queryParam("saleStoreId", planReqRequest.getSaleStoreId()) diff --git a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java index 46c276ef..8a2b25b9 100644 --- a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java +++ b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java @@ -11,6 +11,9 @@ public class ObjectRequest { @Schema(description = "생성 물건번호") private String newObjectNo; + @Schema(description = "플랜번호") + private String planReqNo; + @Schema(description = "판매오더코드") private String workNo; @@ -72,6 +75,9 @@ public class ObjectRequest { @Schema(description = "판매점ID") private String saleStoreId; + @Schema(description = "판매점Level") + private String saleStoreLevel; + @Schema(description = "판매점명") private String saleStoreName; diff --git a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectResponse.java b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectResponse.java index 88435b10..fbdb7b0f 100644 --- a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectResponse.java +++ b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectResponse.java @@ -13,6 +13,9 @@ public class ObjectResponse { @Schema(description = "물건번호") private String objectNo; + @Schema(description = "플랜번호") + private String planReqNo; + @Schema(description = "판매점 ID") private String saleStoreId; diff --git a/src/main/java/com/interplug/qcast/biz/object/dto/PlanReqRequest.java b/src/main/java/com/interplug/qcast/biz/object/dto/PlanReqRequest.java index 7d763d67..a1aa3cd6 100644 --- a/src/main/java/com/interplug/qcast/biz/object/dto/PlanReqRequest.java +++ b/src/main/java/com/interplug/qcast/biz/object/dto/PlanReqRequest.java @@ -11,6 +11,12 @@ public class PlanReqRequest { @Schema(description = "판매점 레벨") private String saleStoreLevel; + @Schema(description = "플랜번호") + private String planReqNo; + + @Schema(description = "물건번호") + private String objectNo; + @Schema(description = "검색 - 설계의뢰번호") private String schPlanReqNo; diff --git a/src/main/resources/mappers/object/objectMapper.xml b/src/main/resources/mappers/object/objectMapper.xml index cf6e27e8..5e15d84d 100644 --- a/src/main/resources/mappers/object/objectMapper.xml +++ b/src/main/resources/mappers/object/objectMapper.xml @@ -230,6 +230,7 @@ SELECT O.OBJECT_NO , O.SALE_STORE_ID + , O.PLAN_REQ_NO , O.WORK_NO , O.OBJECT_STATUS_ID , O.OBJECT_NAME @@ -371,6 +372,7 @@ , LAST_EDIT_USER , EDIT_AGENCY , NORTH_ARRANGEMENT + , PLAN_REQ_NO , AREA_ID , WIND_SPEED , VERTICAL_SNOW_COVER @@ -414,6 +416,7 @@ , #{userId} , '0' , '0' + , #{planReqNo} , #{areaId} , #{windSpeed} , #{verticalSnowCover} @@ -443,6 +446,7 @@ , REMARKS = #{remarks} , RECEIVE_USER = #{receiveUser} , CONTENTS_PATH = #{contentsPath} + , PLAN_REQ_NO = #{planReqNo} , AREA_ID = #{areaId} , WIND_SPEED = #{windSpeed} , VERTICAL_SNOW_COVER = #{verticalSnowCover}