Compare commits
5 Commits
8f1cfd02b3
...
e3d0ac0edf
| Author | SHA1 | Date |
|---|---|---|
|
|
e3d0ac0edf | 1 week ago |
|
|
1c93b9c882 | 1 week ago |
|
|
e26f0ce45a | 1 week ago |
|
|
9012a4bfd6 | 2 weeks ago |
|
|
854fd056c8 | 2 weeks ago |
@ -0,0 +1,38 @@
|
||||
package egovframework.config.WebClient;
|
||||
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import io.netty.handler.timeout.WriteTimeoutHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.client.ExchangeStrategies;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
public class WebClientConf {
|
||||
|
||||
@Bean
|
||||
public WebClient webClient() {
|
||||
HttpClient httpClient = HttpClient.create()
|
||||
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000)
|
||||
.responseTimeout(Duration.ofSeconds(10))
|
||||
.doOnConnected(conn -> conn
|
||||
.addHandlerLast(new ReadTimeoutHandler(10, TimeUnit.SECONDS))
|
||||
.addHandlerLast(new WriteTimeoutHandler(10, TimeUnit.SECONDS)));
|
||||
|
||||
return WebClient.builder()
|
||||
.clientConnector(new ReactorClientHttpConnector(httpClient))
|
||||
.exchangeStrategies(
|
||||
ExchangeStrategies.builder()
|
||||
.codecs(c -> c.defaultCodecs().maxInMemorySize(4 * 1024 * 1024))
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,364 @@
|
||||
package go.kr.project.biz.common.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WebClientCallDto {
|
||||
|
||||
public static class CarInfoRequest {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class BodyWrapper {
|
||||
@JsonProperty("data")
|
||||
private List<Body> data;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class Body {
|
||||
|
||||
// ===== 헤더 영역 =====
|
||||
@JsonProperty("INFO_SYS_ID")
|
||||
private String infoSysId;
|
||||
|
||||
@JsonProperty("INFO_SYS_IP")
|
||||
private String infoSysIp;
|
||||
|
||||
@JsonProperty("SIGUNGU_CODE")
|
||||
private String sigunguCode;
|
||||
|
||||
@JsonProperty("CNTC_INFO_CODE")
|
||||
private String cntcInfoCode;
|
||||
|
||||
@JsonProperty("CHARGER_ID")
|
||||
private String chargerId;
|
||||
|
||||
@JsonProperty("CHARGER_IP")
|
||||
private String chargerIp;
|
||||
|
||||
@JsonProperty("CHARGER_NM")
|
||||
private String chargerNm;
|
||||
|
||||
// record 배열
|
||||
@JsonProperty("record")
|
||||
private List<IfBody> record;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class IfBody {
|
||||
|
||||
@JsonProperty("VHRNO")
|
||||
private String vhrno; // 자동차등록번호
|
||||
|
||||
@JsonProperty("VIN")
|
||||
private String vin; // 차대번호
|
||||
|
||||
@JsonProperty("LEVY_STDDE")
|
||||
private String levyStdde; // 부과기준일
|
||||
|
||||
@JsonProperty("INQIRE_SE_CODE")
|
||||
private String inqireSeCode; // 조회구분코드
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public static class CarInfoResponse {
|
||||
@JsonProperty("LINK_RSLT_CD")
|
||||
private String linkRsltCd;
|
||||
@JsonProperty("LINK_RSLT_DTL")
|
||||
private String linkRsltDtl;
|
||||
private List<CarInfoIfBody> record;
|
||||
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public static class CarInfoIfBody {
|
||||
|
||||
@JsonProperty("VHRNO")
|
||||
private String vhrno;
|
||||
|
||||
@JsonProperty("ATMB_NM")
|
||||
private String atmbNm;
|
||||
|
||||
@JsonProperty("RPRS_OWNR_NM")
|
||||
private String rprsOwnrNm;
|
||||
|
||||
@JsonProperty("RPRSV_OWNR_IDECNO")
|
||||
private String rprsvOwnrIdecno;
|
||||
|
||||
@JsonProperty("ERSR_REG_YMD")
|
||||
private String ersrRegYmd;
|
||||
|
||||
@JsonProperty("PRCS_IMPRTY_RSN_CD")
|
||||
private String prcsImprtyRsnCd;
|
||||
|
||||
@JsonProperty("PRCS_IMPRTY_RSN_DTLS")
|
||||
private String prcsImprtyRsnDtls;
|
||||
|
||||
@JsonProperty("YRIDNW")
|
||||
private String yridnw;
|
||||
|
||||
@JsonProperty("VIN")
|
||||
private String vin;
|
||||
|
||||
@JsonProperty("CNM")
|
||||
private String cnm;
|
||||
|
||||
@JsonProperty("CARMDL_ASORT_NM")
|
||||
private String carmdlAsortNm;
|
||||
|
||||
@JsonProperty("FRST_REG_YMD")
|
||||
private String frstRegYmd;
|
||||
|
||||
@JsonProperty("COLOR_NM")
|
||||
private String colorNm;
|
||||
|
||||
@JsonProperty("STRCT_CHG_CNT")
|
||||
private String strctChgCnt;
|
||||
|
||||
@JsonProperty("NOPLT_CSDY_YN")
|
||||
private String nopltCsdyYn;
|
||||
|
||||
@JsonProperty("NOPLT_CSDY_AVTSMT_YMD")
|
||||
private String nopltCsdyAvtsmtYmd;
|
||||
|
||||
@JsonProperty("INSP_VLD_PD_BGNG_YMD")
|
||||
private String inspVldPdBgngYmd;
|
||||
|
||||
@JsonProperty("INSP_VLD_PD_END_YMD")
|
||||
private String inspVldPdEndYmd;
|
||||
|
||||
@JsonProperty("SPMNNO")
|
||||
private String spmnno;
|
||||
|
||||
@JsonProperty("DRVNG_DSTNC")
|
||||
private String drvngDstnc;
|
||||
|
||||
@JsonProperty("FOM_NM")
|
||||
private String fomNm;
|
||||
|
||||
@JsonProperty("DSPLVL")
|
||||
private String dsplvl;
|
||||
|
||||
@JsonProperty("CARMDL_CLSF_NM")
|
||||
private String carmdlClsfNm;
|
||||
|
||||
@JsonProperty("FBCTN_YMD")
|
||||
private String fbctnYmd;
|
||||
|
||||
@JsonProperty("USGSRHLD_ADDR_NM")
|
||||
private String usgsrhldAddrNm;
|
||||
|
||||
@JsonProperty("MTRS_FOM_NM")
|
||||
private String mtrsFomNm;
|
||||
|
||||
@JsonProperty("RDCPCT_CNT")
|
||||
private String rdcpctCnt;
|
||||
|
||||
@JsonProperty("FRST_REG_APLY_RCPT_NO")
|
||||
private String frstRegAplyRcptNo;
|
||||
|
||||
@JsonProperty("OGNZ_NM")
|
||||
private String ognzNm;
|
||||
|
||||
@JsonProperty("ERSR_REG_SE_NM")
|
||||
private String ersrRegSeNm;
|
||||
|
||||
@JsonProperty("BFR_VHRNO")
|
||||
private String bfrVhrno;
|
||||
|
||||
@JsonProperty("USE_FUEL_CD")
|
||||
private String useFuelCd;
|
||||
|
||||
@JsonProperty("RPRS_OWNR_MBR_SE_CD")
|
||||
private String rprsOwnrMbrSeCd;
|
||||
|
||||
@JsonProperty("RPRS_OWNR_TELNO")
|
||||
private String rprsOwnrTelno;
|
||||
|
||||
@JsonProperty("OWNR_STDG_CD")
|
||||
private String ownrStdgCd;
|
||||
|
||||
@JsonProperty("OWNR_WHOL_ADDR")
|
||||
private String ownrWholAddr;
|
||||
|
||||
@JsonProperty("VHCL_TOTL_WT")
|
||||
private String vhclTotlWt;
|
||||
|
||||
@JsonProperty("MXMM_LDG")
|
||||
private String mxmmLdg;
|
||||
|
||||
@JsonProperty("CBD_LT")
|
||||
private String cbdLt;
|
||||
|
||||
@JsonProperty("CBD_BT")
|
||||
private String cbdBt;
|
||||
|
||||
@JsonProperty("CBD_HG")
|
||||
private String cbdHg;
|
||||
|
||||
@JsonProperty("CARMDL_ASORT_CD")
|
||||
private String carmdlAsortCd;
|
||||
|
||||
@JsonProperty("CARMDL_TYPE_CD")
|
||||
private String carmdlTypeCd;
|
||||
|
||||
@JsonProperty("FUEL_CNSMPRT")
|
||||
private String fuelCnsmprt;
|
||||
|
||||
@JsonProperty("ERSR_REG_SE_CD")
|
||||
private String ersrRegSeCd;
|
||||
|
||||
@JsonProperty("REG_DTL_CD")
|
||||
private String regDtlCd;
|
||||
|
||||
@JsonProperty("USGSRHLD_STDG_CD")
|
||||
private String usgsrhldStdgCd;
|
||||
|
||||
@JsonProperty("USGSRHLD_DONG_CD")
|
||||
private String usgsrhldDongCd;
|
||||
|
||||
@JsonProperty("USGSRHLD_MTN_YN")
|
||||
private String usgsrhldMtnYn;
|
||||
|
||||
@JsonProperty("USGSRHLD_LNBR")
|
||||
private String usgsrhldLnbr;
|
||||
|
||||
@JsonProperty("USGSRHLD_HO")
|
||||
private String usgsrhldHo;
|
||||
|
||||
@JsonProperty("USGSRHLD_ROAD_NM_CD")
|
||||
private String usgsrhldRoadNmCd;
|
||||
|
||||
@JsonProperty("USGSRHLD_UDGD_BLDG_SE_CD")
|
||||
private String usgsrhldUdgdBldgSeCd;
|
||||
|
||||
@JsonProperty("USGSRHLD_BMNO")
|
||||
private String usgsrhldBmno;
|
||||
|
||||
@JsonProperty("USGSRHLD_BSNO")
|
||||
private String usgsrhldBsno;
|
||||
|
||||
@JsonProperty("OWNR_DONG_CD")
|
||||
private String ownrDongCd;
|
||||
|
||||
@JsonProperty("OWNR_MTN_YN")
|
||||
private String ownrMtnYn;
|
||||
|
||||
@JsonProperty("OWNR_LNBR")
|
||||
private String ownrLnbr;
|
||||
|
||||
@JsonProperty("OWNR_HO")
|
||||
private String ownrHo;
|
||||
|
||||
@JsonProperty("OWNR_ADDR_NM")
|
||||
private String ownrAddrNm;
|
||||
|
||||
@JsonProperty("OWNR_ROAD_NM_CD")
|
||||
private String ownrRoadNmCd;
|
||||
|
||||
@JsonProperty("OWNR_UDGD_BLDG_SE_CD")
|
||||
private String ownrUdgdBldgSeCd;
|
||||
|
||||
@JsonProperty("OWNR_BMNO")
|
||||
private String ownrBmno;
|
||||
|
||||
@JsonProperty("OWNR_BSNO")
|
||||
private String ownrBsno;
|
||||
|
||||
@JsonProperty("REAR_VHRNO")
|
||||
private String rearVhrno;
|
||||
|
||||
@JsonProperty("USG_SE_CD")
|
||||
private String usgSeCd;
|
||||
|
||||
@JsonProperty("VEAG_END_YMD")
|
||||
private String veagEndYmd;
|
||||
|
||||
@JsonProperty("CHG_YMD")
|
||||
private String chgYmd;
|
||||
|
||||
@JsonProperty("CARMDL_SE_CD")
|
||||
private String carmdlSeCd;
|
||||
|
||||
@JsonProperty("CARMDL_TYPE_NM")
|
||||
private String carmdlTypeNm;
|
||||
|
||||
@JsonProperty("ACQS_YMD")
|
||||
private String acqsYmd;
|
||||
|
||||
@JsonProperty("ACQS_END_YMD")
|
||||
private String acqsEndYmd;
|
||||
|
||||
@JsonProperty("TRANSR_REG_YMD")
|
||||
private String transrRegYmd;
|
||||
|
||||
@JsonProperty("SPCF_REG_STTS_CD")
|
||||
private String spcfRegSttsCd;
|
||||
|
||||
@JsonProperty("SRC_SE_CD")
|
||||
private String srcSeCd;
|
||||
|
||||
@JsonProperty("NOPLT_SPCFCT_CD")
|
||||
private String nopltSpcfctCd;
|
||||
|
||||
@JsonProperty("ACQS_AMT")
|
||||
private String acqsAmt;
|
||||
|
||||
@JsonProperty("USGSRHLD_GRC_CD")
|
||||
private String usgsrhldGrcCd;
|
||||
|
||||
@JsonProperty("VLNT_ERSR_PRVNTC_AVTSMT_YMD")
|
||||
private String vlntErsrPrvntcAvtsmtYmd;
|
||||
|
||||
@JsonProperty("FRST_MXMM_LDG")
|
||||
private String frstMxmmLdg;
|
||||
|
||||
@JsonProperty("REG_YMD")
|
||||
private String regYmd;
|
||||
|
||||
@JsonProperty("ELCTY_CMPND_FUEL_CNSMPRT")
|
||||
private String elctyCmpndFuelCnsmprt;
|
||||
|
||||
@JsonProperty("USGSRHLD_WHOL_ADDR")
|
||||
private String usgsrhldWholAddr;
|
||||
|
||||
@JsonProperty("MRTG_CNT")
|
||||
private String mrtgCnt;
|
||||
|
||||
@JsonProperty("SZR_CNT")
|
||||
private String szrCnt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package go.kr.project.biz.common.service.impl;
|
||||
|
||||
import go.kr.project.biz.common.dto.WebClientCallDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class WebClientCall {
|
||||
|
||||
private final Environment env;
|
||||
private final WebClient webClient;
|
||||
|
||||
public WebClientCallDto.CarInfoResponse carInfoCall(String mmCarno, String mmDate) {
|
||||
|
||||
|
||||
WebClientCallDto.CarInfoRequest.BodyWrapper reqBody = WebClientCallDto.CarInfoRequest.BodyWrapper.builder()
|
||||
.data(
|
||||
Arrays.asList(
|
||||
WebClientCallDto.CarInfoRequest.Body.builder()
|
||||
.infoSysId("")
|
||||
.infoSysIp("")
|
||||
.sigunguCode("")
|
||||
.cntcInfoCode("")
|
||||
.chargerId("")
|
||||
.chargerIp("")
|
||||
.chargerNm("")
|
||||
.record(
|
||||
Arrays.asList(
|
||||
WebClientCallDto.CarInfoRequest.IfBody.builder()
|
||||
.vhrno(mmCarno)
|
||||
.levyStdde(mmDate)
|
||||
.build()
|
||||
))
|
||||
.build())
|
||||
)
|
||||
.build();
|
||||
|
||||
String PROTOCOL = env.getProperty("car-info.protocol");;
|
||||
String DOMAIN = env.getProperty("car-info.domain");
|
||||
String PORT = env.getProperty("car-info.port");
|
||||
String DIR = env.getProperty("car-info.path.basic");
|
||||
|
||||
Mono<WebClientCallDto.CarInfoResponse> carInfoMono = webClient.post()
|
||||
.uri(PROTOCOL + DOMAIN + PORT + DIR)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(reqBody)
|
||||
.retrieve()
|
||||
.bodyToMono(WebClientCallDto.CarInfoResponse.class);
|
||||
WebClientCallDto.CarInfoResponse res = carInfoMono.block();
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue