diff --git a/jsowell-admin/src/main/java/com/jsowell/amap/AMapController.java b/jsowell-admin/src/main/java/com/jsowell/amap/AMapController.java new file mode 100644 index 000000000..f4c824824 --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/amap/AMapController.java @@ -0,0 +1,60 @@ +package com.jsowell.amap; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; +import com.jsowell.common.annotation.Anonymous; +import com.jsowell.common.core.controller.BaseController; +import com.jsowell.pile.dto.amap.GetStationInfoDTO; +import com.jsowell.thirdparty.amap.common.AMapCommonParams; +import com.jsowell.thirdparty.amap.common.AMapCommonResult; +import com.jsowell.thirdparty.amap.domain.AMapStationInfo; +import com.jsowell.thirdparty.amap.service.AMapService; +import com.jsowell.thirdparty.amap.util.AMapUtils; +import org.apache.poi.ss.formula.functions.T; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * TODO + * + * @author Lemon + * @Date 2023/6/16 13:56 + */ +@Anonymous +@RestController +@RequestMapping("/amap/charging") +public class AMapController extends BaseController { + + @Autowired + private AMapService aMapService; + + @PostMapping("/queryStationInfo") + public AMapCommonResult queryStationInfo(@RequestParam Map requestMap) { + AMapCommonResult result = new AMapCommonResult(); + String paramString = JSON.toJSONString(requestMap); + logger.info("高德拉取充电站静态数据 params:{}", paramString); + try { + // Map map = JSON.parseObject(paramString, Map.class); + // Map paramMap = (Map)JSON.parse(paramString); + if (AMapUtils.checkSign(requestMap)) { + // true 验签成功 + String bizContent = requestMap.get("biz_content"); + GetStationInfoDTO dto = JSON.parseObject(bizContent, GetStationInfoDTO.class); + List stationInfos = aMapService.getStationInfos(dto); + logger.info("高德拉取充电站静态数据 success"); + return result.successResponse(stationInfos); + } + + } catch (Exception e) { + logger.error("高德拉取充电站静态数据 error", e); + return result.failedResponse(); + } + logger.error("高德拉取充电站静态数据验签失败"); + return result.checkSignFailed(); + // logger.info("高德拉取充电站静态数据 result:{}", ); + } +} diff --git a/jsowell-admin/src/main/resources/application.yml b/jsowell-admin/src/main/resources/application.yml index 9c6ee6106..19e7259d5 100644 --- a/jsowell-admin/src/main/resources/application.yml +++ b/jsowell-admin/src/main/resources/application.yml @@ -133,4 +133,5 @@ aMap: aMapPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArqmh0JZrIhk+tMbF+VE63WaqqLRs+OHZkX3HGyr4cokujgdZb0kAq4jBJa/VjWK2qDXHr2KpoY2/ppmA73oJvNPcuVxR6nwYddcASg6uFCK/vfH5PKVV0W/xKTeOIQ6NTd0wRFZs9zNo1endqgQDvn1d1Rvl1r+18MJ3BXLMjkzCUUurgeO84AIlksYV5Z46hoScyXjSc8lsmwX5r7cwHLajFXdjKo1yOCbzClMqLM29THYuegwHFcT/zp64Nd7+nawWWuPOgfkr0MTGrNCkV8ywpbyG0XVewMkdN6pTaZNvhMnLH00VkXASPB51vUjhs4WBiFZth9q3rZBkaEYSMQIDAQAB appId: 202306150188103814 devUrl: https://restapi.amap.com/rest/openmp/devgw?key=7967738241f0a580b5a1342f43793a61 - prdUrl: https://restapi.amap.com/rest/openmp/gw?key=7967738241f0a580b5a1342f43793a61 \ No newline at end of file + prdUrl: https://restapi.amap.com/rest/openmp/gw?key=7967738241f0a580b5a1342f43793a61 + openId: 2089000923284502 \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonResult.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonResult.java index fed8a1520..6fc83dafa 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonResult.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapCommonResult.java @@ -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); } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapResponse.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapResponse.java new file mode 100644 index 000000000..1076f22da --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/common/AMapResponse.java @@ -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; +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java index 92f489375..f60f56f42 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java @@ -28,4 +28,11 @@ public interface AMapService { * @throws Exception */ String pushChargingDeviceDynamics(String pileConnectorCode) throws Exception; + + /** + * 商家推送充电订单信息 + * @param orderCode + * @return + */ + String pushChargingOrderInfo(String orderCode); } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java index ea4470c8d..8484d707b 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java @@ -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查询计费模板 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/util/AMapUtils.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/util/AMapUtils.java index 9abb9715f..7b9dc9edc 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/util/AMapUtils.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/util/AMapUtils.java @@ -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; + } /** * 使用商家私钥生成签名