물건정보 저장 - QSP 설계의뢰 물건정보 업데이트 개발 추가

This commit is contained in:
LAPTOP-L3VE7KK2\USER 2024-10-14 13:17:17 +09:00
parent 969325ef4a
commit b3a21f959c
6 changed files with 131 additions and 7 deletions

View File

@ -47,7 +47,7 @@ public class ObjectController {
return objectService.selectSaleStoreList(saleStoreId);
}
@Operation(description = "물건정보 목록을 조회한다.11")
@Operation(description = "물건정보 목록을 조회한다.")
@GetMapping("/list")
@ResponseStatus(HttpStatus.OK)
public List<ObjectResponse> 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 = "물건정보의 플랜정보를 추가한다.")

View File

@ -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<String, Object> map = (Map<String, Object>) 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<String, Object> map = (Map<String, Object>) 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())

View File

@ -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;

View File

@ -13,6 +13,9 @@ public class ObjectResponse {
@Schema(description = "물건번호")
private String objectNo;
@Schema(description = "플랜번호")
private String planReqNo;
@Schema(description = "판매점 ID")
private String saleStoreId;

View File

@ -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;

View File

@ -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}