mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
73 lines
2.9 KiB
Java
73 lines
2.9 KiB
Java
package com.jsowell.amap;
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.jsowell.common.annotation.Anonymous;
|
|
import com.jsowell.common.core.controller.BaseController;
|
|
import com.jsowell.pile.dto.QueryPileDTO;
|
|
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
|
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.springframework.beans.factory.annotation.Autowired;
|
|
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("/charging")
|
|
public class AMapController extends BaseController {
|
|
|
|
@Autowired
|
|
private AMapService aMapService;
|
|
|
|
@PostMapping("/queryStationInfo")
|
|
public AMapCommonResult queryStationInfo(@RequestParam Map<String, String> requestMap) {
|
|
AMapCommonResult result = new AMapCommonResult();
|
|
String paramString = JSON.toJSONString(requestMap);
|
|
logger.info("高德拉取充电站静态数据 params:{}", paramString);
|
|
try {
|
|
// Map map = JSON.parseObject(paramString, Map.class);
|
|
// Map<String, String> paramMap = (Map<String, String>)JSON.parse(paramString);
|
|
if (AMapUtils.checkSign(requestMap)) {
|
|
// true 验签成功
|
|
String bizContent = requestMap.get("biz_content");
|
|
GetStationInfoDTO dto = JSON.parseObject(bizContent, GetStationInfoDTO.class);
|
|
// List<AMapStationInfo> stationInfos = aMapService.getStationInfos(dto);
|
|
List<AMapStationInfo> stationInfos = aMapService.getStationInfosV2(dto);
|
|
logger.info("高德拉取充电站静态数据 success result:{}", JSON.toJSONString(stationInfos));
|
|
return result.successResponse(stationInfos);
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
logger.error("高德拉取充电站静态数据 error", e);
|
|
return result.failedResponse();
|
|
}
|
|
logger.error("高德拉取充电站静态数据验签失败");
|
|
return result.checkSignFailed();
|
|
// logger.info("高德拉取充电站静态数据 result:{}", );
|
|
}
|
|
|
|
|
|
@PostMapping("/pushStationStatus")
|
|
public AMapCommonResult pushStationStatus(@RequestBody QueryPileDTO dto) {
|
|
AMapCommonResult result = new AMapCommonResult();
|
|
logger.info("商家推送充电设备动态数据");
|
|
try {
|
|
String pushResult = aMapService.pushChargingDeviceDynamics(dto.getPileConnectorCode());
|
|
return result.successResponse(pushResult);
|
|
} catch (Exception e) {
|
|
logger.error("商家推送充电设备动态数据 error", e);
|
|
}
|
|
return result.failedResponse();
|
|
}
|
|
}
|