|
|
@@ -1,52 +0,0 @@
|
|
|
-package com.ydtech.modules.ins.service.impl;
|
|
|
-
|
|
|
-import com.ydtech.core.page.HttpResult;
|
|
|
-import com.ydtech.exception.SystemException;
|
|
|
-import com.ydtech.modules.ins.convert.PinganCarInfoConvert;
|
|
|
-import com.ydtech.modules.ins.model.request.PinganCarInfo;
|
|
|
-import com.ydtech.modules.ins.model.request.PinganVinSearchBody;
|
|
|
-import com.ydtech.modules.ins.model.request.RenbaoCarSearchResponse;
|
|
|
-import com.ydtech.modules.ins.model.ya.CarModelDTO;
|
|
|
-import com.ydtech.modules.ins.service.InsPinganService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
-
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@Service
|
|
|
-public class InsPinganServiceImpl implements InsPinganService {
|
|
|
-
|
|
|
- @Value("${pa.vin.search.url}")
|
|
|
- private String paVinSearchUrl;
|
|
|
-
|
|
|
- private final RestTemplate restTemplate;
|
|
|
-
|
|
|
- public InsPinganServiceImpl(RestTemplate restTemplate) {
|
|
|
- this.restTemplate = restTemplate;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public HttpResult vinSearch(String vin) {
|
|
|
- HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
- httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("vin", vin);
|
|
|
- HttpEntity<Map<String, Object>> mapHttpEntity = new HttpEntity<>(map, httpHeaders);
|
|
|
- ResponseEntity<PinganVinSearchBody> entity = restTemplate.postForEntity(paVinSearchUrl, mapHttpEntity, PinganVinSearchBody.class);
|
|
|
- PinganVinSearchBody body = entity.getBody();
|
|
|
- if (body == null) {
|
|
|
- throw new SystemException("平安接口请求失败");
|
|
|
- }
|
|
|
- List<PinganCarInfo> encodeDict = body.getEncodeDict();
|
|
|
- List<CarModelDTO> carModelDTOList = PinganCarInfoConvert.INSTANCE.map(encodeDict);
|
|
|
- return HttpResult.ok(carModelDTOList);
|
|
|
- }
|
|
|
-}
|