diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/neimenggu/NMGController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/neimenggu/NMGController.java index 6a26157b1..d5fe9681c 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/neimenggu/NMGController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/neimenggu/NMGController.java @@ -1,20 +1,40 @@ package com.jsowell.web.controller.thirdparty.neimenggu; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.jsowell.common.annotation.Anonymous; -import com.jsowell.thirdparty.lianlian.common.CommonResult; +import com.jsowell.common.core.controller.BaseController; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.dto.QueryOperatorInfoDTO; +import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.service.ThirdPartyPlatformConfigService; import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.thirdparty.lianlian.common.CommonResult; +import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.util.Cryptos; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Map; + /** * 内蒙古接口 */ @Anonymous @RestController @RequestMapping("/evcs") -public class NMGController { +public class NMGController extends BaseController { + @Autowired + @Qualifier("neiMengGuPlatformServiceImpl") + private ThirdPartyPlatformService platformLogic; + + @Autowired + private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; /** * 获取token接口 @@ -22,7 +42,35 @@ public class NMGController { */ @PostMapping("/v1/query_token") public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { - return null; + logger.info("海南平台请求令牌 params:{}", JSON.toJSONString(dto)); + try { + Map map = platformLogic.queryToken(dto); + logger.info("海南平台请求令牌 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("海南平台 请求令牌接口 异常", e); + return CommonResult.failed("获取token发生异常"); + } + } + + // 解析DTO + private T parseDto(CommonParamsDTO dto, Class targetClass) { + // 解密 + String operatorId = dto.getOperatorID(); + // 通过operatorId 查出 operatorSecret + ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); + if (platformConfig == null) { + throw new BusinessException("1", "无此对接平台"); + } + + String operatorSecret = platformConfig.getOperatorSecret(); + String dataSecret = platformConfig.getDataSecret(); + String dataSecretIv = platformConfig.getDataSecretIv(); + String signSecret = platformConfig.getSignSecret(); + + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + return JSONObject.parseObject(decrypt, targetClass); } /** @@ -34,7 +82,16 @@ public class NMGController { */ @PostMapping("/v1/supervise_query_operator_info") public CommonResult queryOperatorInfo(@RequestBody CommonParamsDTO dto) { - return null; + logger.info("海南平台查询运营商信息 params:{}", JSON.toJSONString(dto)); + try { + QueryOperatorInfoDTO paramDTO = parseDto(dto, QueryOperatorInfoDTO.class); + Map map = platformLogic.queryOperatorInfo(paramDTO); + logger.info("海南平台查询运营商信息 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("海南平台查询运营商信息 异常", e); + return CommonResult.failed("查询运营商信息发生异常"); + } } /** @@ -44,4 +101,39 @@ public class NMGController { * 接口频率:每天一次或多次 * 超时时间:120秒 */ + @PostMapping("/v1/supervise_query_stations_info") + public CommonResult queryStationsInfo(@RequestBody CommonParamsDTO dto) { + logger.info("海南平台查询运营商信息 params:{}", JSON.toJSONString(dto)); + try { + QueryStationInfoDTO paramDTO = parseDto(dto, QueryStationInfoDTO.class); + Map map = platformLogic.queryStationsInfo(paramDTO); + logger.info("海南平台查询运营商信息 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("海南平台查询运营商信息 异常", e); + return CommonResult.failed("查询运营商信息发生异常"); + } + } + + /** + * 查询充换电站状态信息 + * supervise_query_station_status + */ + @PostMapping("/v1/supervise_query_station_status") + public CommonResult queryStationStatus(@RequestBody CommonParamsDTO dto) { + logger.info("海南平台查询充换电站状态信息 params:{}", JSON.toJSONString(dto)); + try { + QueryStationInfoDTO paramDTO = parseDto(dto, QueryStationInfoDTO.class); + Map map = platformLogic.queryStationStatus(paramDTO); + logger.info("海南平台查询充换电站状态信息 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "查询充换电站状态信息成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("海南平台查询充换电站状态信息异常", e); + return CommonResult.failed("查询充换电站状态信息发生异常"); + } + } + + /** + * + */ } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java index d79547e22..ffc06c67f 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java @@ -40,10 +40,10 @@ import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; -import com.jsowell.thirdparty.platform.common.StationInfo; import com.jsowell.thirdparty.platform.neimenggu.domain.ChargeOrderInfo; import com.jsowell.thirdparty.platform.neimenggu.domain.SupChargeDetails; import com.jsowell.thirdparty.platform.neimenggu.domain.SupOperatorInfo; +import com.jsowell.thirdparty.platform.neimenggu.domain.SupStationInfo; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import com.jsowell.thirdparty.platform.util.HttpRequestUtil; @@ -192,9 +192,9 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { return null; } PageInfo pageInfo = new PageInfo<>(stationInfos); - List resultList = new ArrayList<>(); + List resultList = new ArrayList<>(); for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { - StationInfo stationInfo = new StationInfo(); + SupStationInfo stationInfo = new SupStationInfo(); String stationId = String.valueOf(pileStationInfo.getId()); stationInfo.setStationID(stationId); // MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId())); @@ -228,12 +228,10 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { stationInfo.setPrinterFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())); stationInfo.setBarrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())); stationInfo.setParkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())); - List pileList = pileBasicInfoService.getPileListForLianLian(stationId); if (CollectionUtils.isNotEmpty(pileList)) { stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 } - resultList.add(stationInfo); } Map map = new LinkedHashMap<>(); @@ -241,7 +239,6 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { map.put("PageCount", pageInfo.getPages()); map.put("ItemSize", resultList.size()); map.put("StationInfos", resultList); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, configInfo); return resultMap; }