update 高德地图工具类

This commit is contained in:
Lemon
2023-06-16 16:08:17 +08:00
parent 1874808419
commit cea3464cdc
7 changed files with 151 additions and 34 deletions

View File

@@ -11,27 +11,11 @@ import lombok.NoArgsConstructor;
* @Date 2023/6/14 13:11
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AMapCommonResult {
private Response response;
@Data
public static class Response{
private String code;
private String msg;
private Object data;
}
public AMapCommonResult(Response response) {
this.response = response;
}
public AMapCommonResult() {
}
private AMapResponse response;
/**
* 成功响应
@@ -39,17 +23,24 @@ public class AMapCommonResult {
* @return
*/
public AMapCommonResult successResponse(Object responseData) {
AMapCommonResult result = new AMapCommonResult();
result.response.setCode("1000");
result.response.setMsg("请求成功");
result.response.setData(responseData);
return new AMapCommonResult(result.response);
AMapResponse response = new AMapResponse();
response.setCode("1000");
response.setMsg("请求成功");
response.setData(responseData);
return new AMapCommonResult(response);
}
public AMapCommonResult failedResponse() {
AMapCommonResult result = new AMapCommonResult();
result.response.setCode("40004");
result.response.setMsg("接口异常");
return new AMapCommonResult(result.response);
AMapResponse response = new AMapResponse();
response.setCode("40004");
response.setMsg("接口异常");
return new AMapCommonResult(response);
}
public AMapCommonResult checkSignFailed() {
AMapResponse response = new AMapResponse();
response.setCode("40002");
response.setMsg("验签错误,请检查!");
return new AMapCommonResult(response);
}
}

View File

@@ -0,0 +1,18 @@
package com.jsowell.thirdparty.amap.common;
import lombok.Data;
/**
* TODO
*
* @author Lemon
* @Date 2023/6/16 15:50
*/
@Data
public class AMapResponse {
private String code;
private String msg;
private Object data;
}

View File

@@ -28,4 +28,11 @@ public interface AMapService {
* @throws Exception
*/
String pushChargingDeviceDynamics(String pileConnectorCode) throws Exception;
/**
* 商家推送充电订单信息
* @param orderCode
* @return
*/
String pushChargingOrderInfo(String orderCode);
}

View File

@@ -5,6 +5,7 @@ import com.jsowell.common.constant.Constants;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.PageUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.OrderBasicInfo;
import com.jsowell.pile.domain.PileBasicInfo;
import com.jsowell.pile.domain.PileStationInfo;
import com.jsowell.pile.dto.amap.ChargeDeviceDynamicsDTO;
@@ -52,6 +53,9 @@ public class AMapServiceImpl implements AMapService {
@Autowired
private IPileModelInfoService pileModelInfoService;
@Autowired
private IOrderBasicInfoService orderBasicInfoService;
/**
* 高德拉取充电站静态数据
* @param dto
@@ -125,6 +129,7 @@ public class AMapServiceImpl implements AMapService {
*/
@Override
public String pushChargingDeviceDynamics(String pileConnectorCode) throws Exception {
// 根据枪口号查出桩信息
PileConnectorDetailVO pileConnectorDetailVO = pileBasicInfoService.queryPileConnectorDetail(pileConnectorCode);
if (pileConnectorDetailVO == null) {
@@ -155,6 +160,24 @@ public class AMapServiceImpl implements AMapService {
return AMapUtils.sendPost(map);
}
/**
* 商家推送充电订单信息
* @param orderCode
* @return
*/
@Override
public String pushChargingOrderInfo(String orderCode) {
// 根据订单编号查询信息
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
// 拼装业务参数
JSONObject json = new JSONObject();
json.put("", "");
return null;
}
/**
* 根据站点id查询计费模板

View File

@@ -6,6 +6,7 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
@@ -19,22 +20,38 @@ import java.util.*;
/**
* 高德地图工具类
*/
@Component
public class AMapUtils {
private static String MERCHANT_PRIVATE_KEY;
private static String AMAP_PUBLIC_KEY;
private static String APP_ID;
private static String DEV_URL;
private static String PRD_URL;
@Value("${aMap.merchantPrivateKey}")
private static String MERCHANT_PRIVATE_KEY;
public static void setMerchantPrivateKey(String merchantPrivateKey) {
AMapUtils.MERCHANT_PRIVATE_KEY = merchantPrivateKey;
}
@Value("${aMap.aMapPublicKey}")
private static String AMAP_PUBLIC_KEY;
public void setAmapPublicKey(String amapPublicKey) {
AMapUtils.AMAP_PUBLIC_KEY = amapPublicKey;
}
@Value("${aMap.appId}")
private static String APP_ID;
public void setAppId(String appId) {
AMapUtils.APP_ID = appId;
}
@Value("${aMap.devUrl}")
private static String DEV_URL;
public void setDevUrl(String devUrl) {
AMapUtils.DEV_URL = devUrl;
}
@Value("${aMap.prdUrl}")
private static String PRD_URL;
public void setPrdUrl(String prdUrl) {
AMapUtils.PRD_URL = prdUrl;
}
/**
* 使用商家私钥生成签名