mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-25 21:45:08 +08:00
新增 第三方平台配置后管页面
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
package com.jsowell.web.controller.thirdparty;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.pile.domain.ThirdPartySettingInfo;
|
||||
import com.jsowell.pile.service.IThirdPartySettingInfoService;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 第三方平台配置Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2023-11-29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/thirdParty/thirdPartySetting")
|
||||
public class ThirdPartySettingInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IThirdPartySettingInfoService thirdPartySettingInfoService;
|
||||
|
||||
/**
|
||||
* 查询第三方平台配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('thirdParty:thirdPartySetting:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ThirdPartySettingInfo thirdPartySettingInfo) {
|
||||
startPage();
|
||||
List<ThirdPartySettingInfo> list = thirdPartySettingInfoService.selectThirdPartySettingInfoList(thirdPartySettingInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出第三方平台配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('thirdParty:thirdPartySetting:export')")
|
||||
@Log(title = "第三方平台配置", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ThirdPartySettingInfo thirdPartySettingInfo) {
|
||||
List<ThirdPartySettingInfo> list = thirdPartySettingInfoService.selectThirdPartySettingInfoList(thirdPartySettingInfo);
|
||||
ExcelUtil<ThirdPartySettingInfo> util = new ExcelUtil<ThirdPartySettingInfo>(ThirdPartySettingInfo.class);
|
||||
util.exportExcel(response, list, "第三方平台配置数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第三方平台配置详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('thirdParty:thirdPartySetting:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(thirdPartySettingInfoService.selectThirdPartySettingInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增第三方平台配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('thirdParty:thirdPartySetting:add')")
|
||||
@Log(title = "第三方平台配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ThirdPartySettingInfo thirdPartySettingInfo) {
|
||||
return toAjax(thirdPartySettingInfoService.insertThirdPartySettingInfo(thirdPartySettingInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改第三方平台配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('thirdParty:thirdPartySetting:edit')")
|
||||
@Log(title = "第三方平台配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ThirdPartySettingInfo thirdPartySettingInfo) {
|
||||
return toAjax(thirdPartySettingInfoService.updateThirdPartySettingInfo(thirdPartySettingInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除第三方平台配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('thirdParty:thirdPartySetting:remove')")
|
||||
@Log(title = "第三方平台配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(thirdPartySettingInfoService.deleteThirdPartySettingInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
75
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/amap/AMapController.java
vendored
Normal file
75
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/amap/AMapController.java
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.jsowell.web.controller.thirdparty.amap;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
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);
|
||||
result = result.successResponse(stationInfos);
|
||||
// logger.info("高德拉取充电站静态数据 success 业务参数:{}", JSON.toJSONString(stationInfos));
|
||||
logger.info("高德拉取充电站静态数据 success result:{}", JSON.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
} 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("商家推送充电设备动态数据 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
String pushResult = aMapService.pushChargingDeviceDynamics(dto.getStationId());
|
||||
return result.successResponse(pushResult);
|
||||
} catch (Exception e) {
|
||||
logger.error("商家推送充电设备动态数据 error", e);
|
||||
}
|
||||
return result.failedResponse();
|
||||
}
|
||||
}
|
||||
671
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/lianlian/LianLianController.java
vendored
Normal file
671
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/lianlian/LianLianController.java
vendored
Normal file
@@ -0,0 +1,671 @@
|
||||
package com.jsowell.web.controller.thirdparty.lianlian;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.IThirdPartyPlatformConfigService;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 对接联联平台controller
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/4/10 14:58
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/LianLian")
|
||||
public class LianLianController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private LianLianService lianLianService;
|
||||
|
||||
/**
|
||||
* 推送充电站信息 notification_stationInfo
|
||||
* http://localhost:8080/LianLian/pushStationInfo
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/pushStationInfo")
|
||||
public RestApiResponse<?> pushStationInfo(@RequestBody PushStationInfoDTO dto) {
|
||||
logger.info("推送联联平台充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
lianLianService.pushStationInfo(dto);
|
||||
response = new RestApiResponse<>();
|
||||
}catch (BusinessException e) {
|
||||
logger.error("推送联联平台充电站信息 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("推送联联平台充电站信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("推送联联平台充电站信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 联联平台设备状态变化推送
|
||||
* http://localhost:8080/LianLian/pushStationStatus
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/pushStationStatus")
|
||||
public RestApiResponse<?> pushStationStatus(@RequestBody PushInfoParamDTO dto) {
|
||||
logger.info("联联平台设备状态变化推送 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) ||
|
||||
StringUtils.isBlank(String.valueOf(dto.getStatus()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String result = lianLianService.pushConnectorStatus(dto.getPileConnectorCode(), dto.getStatus());
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("联联平台设备状态变化推送 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("联联平台设备状态变化推送 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("联联平台设备状态变化推送 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送订单信息
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushOrderInfo/{orderCode}")
|
||||
public RestApiResponse<?> pushOrderInfo(@PathVariable("orderCode")String orderCode) {
|
||||
logger.info("联联平台推送订单信息 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(orderCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String result = lianLianService.pushOrderInfo(orderCode);
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("联联平台推送订单信息 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("联联平台推送订单信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("联联平台推送订单信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备充电中状态变化推送
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushPileChargeStatusChange/{orderCode}")
|
||||
public RestApiResponse<?> pushPileChargeStatusChange(@PathVariable("orderCode")String orderCode) {
|
||||
logger.info("联联平台设备充电中状态变化推送 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(orderCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String result = lianLianService.pushPileChargeStatusChange(orderCode);
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("联联平台设备充电中状态变化推送 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("联联平台设备充电中状态变化推送 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("联联平台设备充电中状态变化推送 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 联联平台查询充电站信息
|
||||
* http://localhost:8080/LianLian/query_stations_info
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
// @PostMapping("/query_stations_info")
|
||||
// public RestApiResponse<?> query_stations_info(@RequestBody QueryStationInfoDTO dto) {
|
||||
// logger.info("联联平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
// RestApiResponse<?> response = null;
|
||||
// try {
|
||||
// // 校验签名
|
||||
// // lianLianService.checkoutSign();
|
||||
// LianLianPageResponse pageResponse = lianLianService.query_stations_info(dto);
|
||||
// response = new RestApiResponse<>(pageResponse);
|
||||
// }catch (BusinessException e) {
|
||||
// logger.error("联联平台查询充电站信息 error",e);
|
||||
// response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
// }catch (Exception e) {
|
||||
// logger.error("联联平台查询充电站信息 error", e);
|
||||
// response = new RestApiResponse<>(e);
|
||||
// }
|
||||
// logger.info("联联平台查询充电站信息 result:{}", response);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 联联平台查询充电站状态信息
|
||||
* http://localhost:8080/LianLian/query_station_status
|
||||
* @param StationIDs
|
||||
* @return
|
||||
*/
|
||||
// @PostMapping("/query_station_status")
|
||||
// public RestApiResponse<?> query_station_status(@RequestBody ArrayList<String> StationIDs) {
|
||||
// logger.info("联联平台查询充电站状态信息 params:{}", StationIDs);
|
||||
// RestApiResponse<?> response;
|
||||
// try {
|
||||
// if (CollectionUtils.isEmpty(StationIDs)) {
|
||||
// return null;
|
||||
// }
|
||||
// LianLianPageResponse pageResponse = lianLianService.query_station_status(StationIDs);
|
||||
// response = new RestApiResponse<>(pageResponse);
|
||||
// }catch (BusinessException e) {
|
||||
// logger.error("联联平台查询充电站状态信息 error",e);
|
||||
// response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
// }catch (Exception e) {
|
||||
// logger.error("联联平台查询充电站状态信息 error", e);
|
||||
// response = new RestApiResponse<>(e);
|
||||
// }
|
||||
// logger.info("联联平台查询充电站状态信息 result:{}", response);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询统计信息
|
||||
* http://localhost:8080/LianLian/query_station_stats
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
// @PostMapping("/query_station_stats")
|
||||
// public RestApiResponse<?> query_station_stats(@RequestBody QueryStationInfoDTO dto) {
|
||||
// logger.info("联联平台查询统计信息 params :{}", JSONObject.toJSONString(dto));
|
||||
// RestApiResponse<?> response;
|
||||
// try {
|
||||
// StationStatsInfo stationStatsInfo = lianLianService.query_station_stats(dto);
|
||||
// response = new RestApiResponse<>(stationStatsInfo);
|
||||
// }catch (BusinessException e) {
|
||||
// logger.error("联联平台查询统计信息 error",e);
|
||||
// response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
// } catch (Exception e) {
|
||||
// logger.error("联联平台查询统计信息 error", e);
|
||||
// response = new RestApiResponse<>(e);
|
||||
// }
|
||||
// logger.info("联联平台查询统计信息 result :{}", response);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 请求设备认证
|
||||
* http://localhost:8080/LianLian/query_equip_auth
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
// @PostMapping("/query_equip_auth")
|
||||
// public RestApiResponse<?> query_equip_auth(@RequestBody QueryEquipmentDTO dto) {
|
||||
// logger.info("联联平台请求设备认证 params :{}", JSONObject.toJSONString(dto));
|
||||
// RestApiResponse<?> response;
|
||||
// try {
|
||||
// EquipmentAuthVO equipmentAuthVO = lianLianService.query_equip_auth(dto);
|
||||
// response = new RestApiResponse<>(equipmentAuthVO);
|
||||
// }catch (BusinessException e) {
|
||||
// logger.error("联联平台请求设备认证 error",e);
|
||||
// response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
// } catch (Exception e) {
|
||||
// logger.error("联联平台请求设备认证 error", e);
|
||||
// response = new RestApiResponse<>(e);
|
||||
// }
|
||||
// logger.info("联联平台请求设备认证 result :{}", response);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 请求设备认证
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_equip_auth")
|
||||
public CommonResult<?> query_equip_auth(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台请求设备认证 param:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryEquipmentDTO queryEquipmentDTO = JSONObject.parseObject(dataStr, QueryEquipmentDTO.class);
|
||||
queryEquipmentDTO.setOperatorID(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.query_equip_auth(queryEquipmentDTO);
|
||||
|
||||
return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("联联平台请求设备认证 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("请求设备认证发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求启动充电
|
||||
* http://localhost:8080/LianLian/query_start_charge
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
// @PostMapping("/query_start_charge")
|
||||
// public RestApiResponse<?> query_start_charge(@RequestBody QueryStartChargeDTO dto) {
|
||||
// logger.info("联联平台请求启动充电 params :{}", JSONObject.toJSONString(dto));
|
||||
// RestApiResponse<?> response;
|
||||
// try {
|
||||
// QueryStartChargeVO queryStartChargeVO = lianLianService.query_start_charge(dto);
|
||||
// response = new RestApiResponse<>(queryStartChargeVO);
|
||||
// }catch (BusinessException e) {
|
||||
// logger.error("联联平台请求启动充电 error",e);
|
||||
// response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
// } catch (Exception e) {
|
||||
// logger.error("联联平台请求启动充电 error", e);
|
||||
// response = new RestApiResponse<>(e);
|
||||
// }
|
||||
// logger.info("联联平台请求启动充电 result :{}", response);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 请求启动充电
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_start_charge")
|
||||
public CommonResult<?> query_start_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台请求启动充电 params :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
|
||||
queryStartChargeDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.query_start_charge(queryStartChargeDTO);
|
||||
|
||||
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("联联平台请求启动充电 error", e);
|
||||
}
|
||||
return CommonResult.failed("请求启动充电发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电状态
|
||||
* http://localhost:8080/LianLian/query_equip_charge_status/{startChargeSeq}
|
||||
* @param startChargeSeq
|
||||
* @return
|
||||
*/
|
||||
// @GetMapping("/query_equip_charge_status/{startChargeSeq}")
|
||||
// public RestApiResponse<?> query_equip_charge_status(@PathVariable("startChargeSeq") String startChargeSeq) {
|
||||
// logger.info("联联平台查询充电状态 params :{}", startChargeSeq);
|
||||
// RestApiResponse<?> response;
|
||||
// try {
|
||||
// QueryChargingStatusVO vo = lianLianService.query_equip_charge_status(startChargeSeq);
|
||||
// response = new RestApiResponse<>(vo);
|
||||
// }catch (BusinessException e) {
|
||||
// logger.error("联联平台查询充电状态 error",e);
|
||||
// response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
// } catch (Exception e) {
|
||||
// logger.error("联联平台查询充电状态 error", e);
|
||||
// response = new RestApiResponse<>(e);
|
||||
// }
|
||||
// logger.info("联联平台查询充电状态 result :{}", response);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询充电状态
|
||||
* http://localhost:8080/LianLian/query_equip_charge_status/{startChargeSeq}
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_equip_charge_status")
|
||||
public CommonResult<?> query_equip_charge_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台查询充电状态 params :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
|
||||
queryEquipChargeStatusDTO.setOperatorID(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.query_equip_charge_status(queryEquipChargeStatusDTO);
|
||||
|
||||
return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("联联平台查询充电状态 error", e);
|
||||
}
|
||||
return CommonResult.failed("联联平台查询充电状态发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求停止充电
|
||||
* http://localhost:8080/LianLian/query_stop_charge
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
// @PostMapping("/query_stop_charge")
|
||||
// public RestApiResponse<?> query_stop_charge(@RequestBody QueryStartChargeDTO dto) {
|
||||
// logger.info("联联平台请求停止充电 params :{}", JSONObject.toJSONString(dto));
|
||||
// RestApiResponse<?> response;
|
||||
// try {
|
||||
// QueryStopChargeVO queryStopChargeVO = lianLianService.query_stop_charge(dto);
|
||||
// response = new RestApiResponse<>(queryStopChargeVO);
|
||||
// }catch (BusinessException e) {
|
||||
// logger.error("联联平台请求停止充电 error",e);
|
||||
// response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
// } catch (Exception e) {
|
||||
// logger.error("联联平台请求停止充电 error", e);
|
||||
// response = new RestApiResponse<>(e);
|
||||
// }
|
||||
// logger.info("联联平台请求停止充电 result :{}", response);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 请求停止充电
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_stop_charge")
|
||||
public CommonResult<?> query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台请求停止充电 params :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
|
||||
queryStartChargeDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.query_stop_charge(queryStartChargeDTO);
|
||||
|
||||
return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("联联平台请求停止充电 error", e);
|
||||
}
|
||||
return CommonResult.failed("联联平台请求停止充电发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token接口
|
||||
* http://localhost:8080/LianLian/v1/query_token
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台请求令牌 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = lianLianService.generateToken(dto);
|
||||
logger.info("联联平台请求令牌 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error("获取token接口 异常");
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送订单结算信息 (联联推给我们)
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/notification_order_settlement_info")
|
||||
public CommonResult<?> notification_order_settlement_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台推送订单结算信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
PushOrderSettlementDTO pushOrderSettlementDTO = JSONObject.parseObject(dataStr, PushOrderSettlementDTO.class);
|
||||
pushOrderSettlementDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.pushOrderSettlementInfo(pushOrderSettlementDTO);
|
||||
|
||||
return CommonResult.success(0, "推送订单结算信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("联联平台推送订单结算信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("推送订单结算信息发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 联联平台查询充电站信息
|
||||
* http://localhost:8080/LianLian/query_stations_info
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.query_stations_info(queryStationInfoDTO);
|
||||
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("联联平台查询充电站信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 联联平台查询充电站状态信息
|
||||
* http://localhost:8080/LianLian/query_station_status
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_status")
|
||||
public CommonResult<?> query_station_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台查询充电站状态信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.query_station_status(queryStationInfoDTO);
|
||||
|
||||
return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("联联平台查询充电站状态信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询充电站状态信息发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询统计信息
|
||||
* http://localhost:8080/LianLian/query_station_stats
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_stats")
|
||||
public CommonResult<?> query_station_stats(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("联联平台查询统计信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, "UTF-8");
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.query_station_stats(queryStationInfoDTO);
|
||||
return CommonResult.success(0, "查询统计信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("联联平台查询统计信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询统计信息发生异常");
|
||||
}
|
||||
}
|
||||
286
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/nanrui/NRController.java
vendored
Normal file
286
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/nanrui/NRController.java
vendored
Normal file
@@ -0,0 +1,286 @@
|
||||
package com.jsowell.web.controller.thirdparty.nanrui;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.PushStationInfoDTO;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.dto.nanrui.GetTokenDTO;
|
||||
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
|
||||
import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.nanrui.service.NRService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 江苏平台 controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/10/11 13:26
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/jiangsu")
|
||||
public class NRController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private NRService nrService;
|
||||
|
||||
/**
|
||||
* 查询充电站信息
|
||||
* @param dto
|
||||
*/
|
||||
@RequestMapping("/v1/query_stations_info")
|
||||
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("江苏平台查询充电站信息 params:{}", JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = nrService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
Map<String, String> map = nrService.query_stations_info(queryStationInfoDTO);
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("江苏平台查询充电站信息 error", e);
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备接口状态
|
||||
* @param dto
|
||||
*/
|
||||
@RequestMapping("/v1/query_station_status")
|
||||
public CommonResult<?> query_station_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("江苏平台查询设备接口状态 params:{}", JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = nrService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = nrService.query_station_status(queryStationInfoDTO);
|
||||
return CommonResult.success(0, "查询设备接口状态成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("江苏平台查询设备接口状态 error", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询设备接口状态异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电电量信息
|
||||
* @param dto
|
||||
*/
|
||||
@RequestMapping("/v1/query_order_info")
|
||||
public CommonResult<?> query_order_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("江苏平台查询充电电量信息 params:{}", JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = nrService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
NRQueryOrderDTO nrQueryOrderDTO = JSONObject.parseObject(dataStr, NRQueryOrderDTO.class);
|
||||
nrQueryOrderDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = nrService.query_order_info(nrQueryOrderDTO);
|
||||
return CommonResult.success(0, "查询充电电量信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("江苏平台查询充电电量信息 error", e);
|
||||
}
|
||||
return CommonResult.failed("查询充电电量信息异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token接口
|
||||
* http://localhost:8080/nanrui/v1/query_token
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("江苏平台请求令牌 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = nrService.generateToken(dto);
|
||||
logger.info("江苏平台请求令牌 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error("获取token接口 异常");
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/v1/getToken")
|
||||
public String getToken(@RequestBody GetTokenDTO dto) {
|
||||
String token = nrService.getToken(dto.getUrlAddress(), dto.getOperatorId(), dto.getOperatorSecret(),
|
||||
dto.getDataSecretIv(), dto.getSignSecret(), dto.getDataSecret());
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送充电站信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/pushStationInfo")
|
||||
public RestApiResponse<?> pushStationInfo(@RequestBody PushStationInfoDTO dto) {
|
||||
logger.info("推送江苏平台充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String s = nrService.pushStationInfo(dto);
|
||||
response = new RestApiResponse<>(s);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("推送江苏平台充电站信息 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("推送江苏平台充电站信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("推送江苏平台充电站信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送告警信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/pushAlarmInfo")
|
||||
public RestApiResponse<?> pushAlarmInfo(@RequestBody PushAlarmInfoDTO dto) {
|
||||
logger.info("推送江苏平台告警信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String s = nrService.pushAlarmInfo(dto);
|
||||
response = new RestApiResponse<>(s);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("推送江苏平台告警信息 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("推送江苏平台告警信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("推送江苏平台告警信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备状态变化推送
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/pushPileStatus")
|
||||
public RestApiResponse<?> pushPileStatus(@RequestBody RealTimeMonitorData data) {
|
||||
logger.info("推送江苏平台设备状态变化推送 params:{}", JSONObject.toJSONString(data));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String s = nrService.pushPileStatus(data);
|
||||
response = new RestApiResponse<>(s);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("推送江苏平台设备状态变化推送 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("推送江苏平台设备状态变化推送 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("推送江苏平台设备状态变化推送 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 充电电量信息推送
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/pushOrderInfo/{orderCode}")
|
||||
public RestApiResponse<?> pushOrderInfo(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("江苏平台充电电量信息推送 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String s = nrService.pushOrderInfo(orderCode);
|
||||
response = new RestApiResponse<>(s);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("江苏平台充电电量信息推送 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("江苏平台充电电量信息推送 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("江苏平台充电电量信息推送 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
230
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ningxiajiaotou/NXJTController.java
vendored
Normal file
230
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ningxiajiaotou/NXJTController.java
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
package com.jsowell.web.controller.thirdparty.ningxiajiaotou;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.ningxiajiaotou.service.NXJTService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 宁夏交投 Controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/11/15 8:36:42
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/nxjt")
|
||||
public class NXJTController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private NXJTService nxjtService;
|
||||
|
||||
@Autowired
|
||||
private LianLianService lianLianService;
|
||||
|
||||
/**
|
||||
* 获取token接口
|
||||
* http://localhost:8080/nxjt/v1/query_token
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("宁夏交投平台请求令牌 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = nxjtService.generateToken(dto);
|
||||
logger.info("宁夏交投平台请求令牌 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error("获取token接口 异常");
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 宁夏交投平台查询充电站信息
|
||||
* http://localhost:8080/nxjt/v1/query_stations_info
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResult<?> queryStationsInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("宁夏交投平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
NXJTQueryStationInfoDTO nxjtQueryStationInfoDTO = JSONObject.parseObject(dataStr, NXJTQueryStationInfoDTO.class);
|
||||
nxjtQueryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = nxjtService.queryStationsInfo(nxjtQueryStationInfoDTO);
|
||||
// return CommonResult.success(map);
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("宁夏交投平台查询充电站信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 宁夏交投平台查询充电站中空闲桩数量
|
||||
* http://localhost:8080/nxjt/v1/query_free_pile_number
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_free_pile_number")
|
||||
public CommonResult<?> queryFreePileNumber(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("宁夏交投平台查询充电站中空闲桩数量 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
NXJTQueryStationInfoDTO nxjtQueryStationInfoDTO = JSONObject.parseObject(dataStr, NXJTQueryStationInfoDTO.class);
|
||||
nxjtQueryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = nxjtService.queryFreePileNumber(nxjtQueryStationInfoDTO);
|
||||
// return CommonResult.success(map);
|
||||
return CommonResult.success(0, "查询充电站中空闲桩数量信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("宁夏交投平台查询充电站中空闲桩数量 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询充电站中空闲桩数量信息发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 宁夏交投平台查询某车牌号消费记录
|
||||
* http://localhost:8080/nxjt/v1/query_free_pile_number
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_orders_info_by_Plate_number")
|
||||
public CommonResult<?> queryOrdersInfoByPlateNumber(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("宁夏交投平台查询某车牌号消费记录 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
NXJTQueryOrdersInfoDTO nxjtQueryOrdersInfoDTO = JSONObject.parseObject(dataStr, NXJTQueryOrdersInfoDTO.class);
|
||||
nxjtQueryOrdersInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = nxjtService.queryOrdersInfoByPlateNumber(nxjtQueryOrdersInfoDTO);
|
||||
// return CommonResult.success(map);
|
||||
return CommonResult.success(0, "查询充电站中空闲桩数量信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("宁夏交投平台查询某车牌号消费记录 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询某车牌号消费记录发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 宁夏交投平台查询某段时间内消费记录
|
||||
* http://localhost:8080/nxjt/v1/query_orders_info
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_orders_info")
|
||||
public CommonResult<?> queryOrdersInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("宁夏交投平台查询某段时间内消费记录 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
NXJTQueryOrdersInfoDTO nxjtQueryOrdersInfoDTO = JSONObject.parseObject(dataStr, NXJTQueryOrdersInfoDTO.class);
|
||||
nxjtQueryOrdersInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = nxjtService.queryOrdersInfo(nxjtQueryOrdersInfoDTO);
|
||||
// return CommonResult.success(map);
|
||||
return CommonResult.success(0, "查询充电站中空闲桩数量信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("宁夏交投平台查询某段时间内消费记录 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询某段时间内消费记录发生异常");
|
||||
}
|
||||
}
|
||||
43
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ruanjie/RJController.java
vendored
Normal file
43
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ruanjie/RJController.java
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.jsowell.web.controller.thirdparty.ruanjie;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.dto.ruanjie.UseCouponDTO;
|
||||
import com.jsowell.thirdparty.ruanjie.service.RJService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 软杰controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/9/22 9:00
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/ruanjie")
|
||||
public class RJController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private RJService rjService;
|
||||
|
||||
@PostMapping("/useCoupon")
|
||||
public RestApiResponse<?> useCoupon(@RequestBody UseCouponDTO dto) {
|
||||
logger.info("软杰--使用优惠券 params:{}", JSON.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = rjService.useCoupon(dto);
|
||||
response = new RestApiResponse<>(result);
|
||||
} catch (Exception e) {
|
||||
logger.error("软杰--使用优惠券 error, ", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("软杰--使用优惠券 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
457
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/yongchengboche/YCBCController.java
vendored
Normal file
457
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/yongchengboche/YCBCController.java
vendored
Normal file
@@ -0,0 +1,457 @@
|
||||
package com.jsowell.web.controller.thirdparty.yongchengboche;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.yongchengboche.dto.YCBCGetTokenDTO;
|
||||
import com.jsowell.thirdparty.yongchengboche.service.YCBCService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 甬城泊车controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/11/3 9:39:21
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/ycbc")
|
||||
public class YCBCController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private YCBCService ycbcService;
|
||||
|
||||
@Autowired
|
||||
private LianLianService lianLianService;
|
||||
|
||||
/**
|
||||
* 获取token接口
|
||||
* http://localhost:8080/ycbc/v1/query_token
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("甬城泊车平台请求令牌 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = ycbcService.generateToken(dto);
|
||||
logger.info("甬城泊车平台请求令牌 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error("甬城泊车平台 请求令牌接口 异常");
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token接口
|
||||
* http://localhost:8080/ycbc/v1/query_token
|
||||
*/
|
||||
@PostMapping("/v1/ycbcQuery_token")
|
||||
public String ycbcQueryToken(@RequestBody YCBCGetTokenDTO dto) {
|
||||
logger.info("请求甬城泊车平台令牌 params:{}", JSONObject.toJSONString(dto));
|
||||
String token = "";
|
||||
try {
|
||||
token = ycbcService.YCBCGetToken(dto);
|
||||
logger.info("请求甬城泊车平台令牌 result:{}", token);
|
||||
} catch (Exception e) {
|
||||
logger.error("请求甬城泊车平台令牌接口 异常");
|
||||
return "";
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 甬城泊车平台查询充电站信息
|
||||
* http://localhost:8080/ycbc/query_stations_info
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("甬城泊车平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = ycbcService.queryStationsInfo(queryStationInfoDTO);
|
||||
logger.info("甬城泊车平台查询充电站信息 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("甬城泊车平台查询充电站信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 甬城泊车平台查询充电站状态信息
|
||||
* http://localhost:8080/ycbc/query_station_status
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_status")
|
||||
public CommonResult<?> query_station_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("甬城泊车平台查询充电站状态信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = ycbcService.queryStationStatus(queryStationInfoDTO);
|
||||
logger.info("甬城泊车平台查询充电站状态信息 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("甬城泊车平台查询充电站状态信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询充电站状态信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 甬城泊车平台设备状态变化推送
|
||||
* http://localhost:8080/ycbc/pushStationStatus
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/pushStationStatus")
|
||||
public RestApiResponse<?> pushStationStatus(@RequestBody PushInfoParamDTO dto) {
|
||||
logger.info("甬城泊车平台设备状态变化推送 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) ||
|
||||
StringUtils.isBlank(String.valueOf(dto.getStatus()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String result = ycbcService.notificationStationStatus(dto.getPileConnectorCode(), dto.getStatus());
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("甬城泊车平台设备状态变化推送 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("甬城泊车平台设备状态变化推送 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("甬城泊车平台设备状态变化推送 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 甬城泊车推送启动充电结果
|
||||
* http://localhost:8080/ycbc/pushStartChargeResult
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushStartChargeResult/{orderCode}")
|
||||
public RestApiResponse<?> pushStartChargeResult(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("甬城泊车平台推送启动充电结果 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = ycbcService.pushStartChargeResult(orderCode);
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("甬城泊车平台推送启动充电结果 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("甬城泊车平台推送启动充电结果 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("甬城泊车平台推送启动充电结果 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求设备认证
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_equip_auth")
|
||||
public CommonResult<?> query_equip_auth(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("甬城泊车平台请求设备认证 param:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryEquipmentDTO queryEquipmentDTO = JSONObject.parseObject(dataStr, QueryEquipmentDTO.class);
|
||||
queryEquipmentDTO.setOperatorID(dto.getOperatorID());
|
||||
Map<String, String> map = ycbcService.queryEquipAuth(queryEquipmentDTO);
|
||||
logger.info("甬城泊车平台请求设备认证 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("甬城泊车平台请求设备认证 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("请求设备认证发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求启动充电
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_start_charge")
|
||||
public CommonResult<?> query_start_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("甬城泊车平台请求启动充电 params :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
|
||||
queryStartChargeDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = ycbcService.queryStartCharge(queryStartChargeDTO);
|
||||
logger.info("甬城泊车平台请求启动充电 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("甬城泊车平台请求启动充电 error", e);
|
||||
}
|
||||
return CommonResult.failed("请求启动充电发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电状态
|
||||
* http://localhost:8080/LianLian/query_equip_charge_status/{startChargeSeq}
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_equip_charge_status")
|
||||
public CommonResult<?> query_equip_charge_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("甬城泊车平台查询充电状态 params :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
|
||||
queryEquipChargeStatusDTO.setOperatorID(dto.getOperatorID());
|
||||
Map<String, String> map = ycbcService.queryEquipChargeStatus(queryEquipChargeStatusDTO);
|
||||
logger.info("甬城泊车平台查询充电状态 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("甬城泊车平台查询充电状态 error", e);
|
||||
}
|
||||
return CommonResult.failed("甬城泊车平台查询充电状态发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 甬城泊车推送充电状态
|
||||
* http://localhost:8080/ycbc/pushStartChargeResult
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushChargeStatus/{orderCode}")
|
||||
public RestApiResponse<?> pushChargeStatus(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("甬城泊车平台推送充电状态 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = ycbcService.pushChargeStatus(orderCode);
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("甬城泊车平台推送充电状态 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("甬城泊车平台推送充电状态 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("甬城泊车平台推送充电状态 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求停止充电
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_stop_charge")
|
||||
public CommonResult<?> query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("甬城泊车平台请求停止充电 params :{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
|
||||
queryStartChargeDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = ycbcService.queryStopCharge(queryStartChargeDTO);
|
||||
logger.info("甬城泊车平台请求停止充电 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("甬城泊车平台请求停止充电 error", e);
|
||||
}
|
||||
return CommonResult.failed("甬城泊车平台请求停止充电发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 甬城泊车推送停止充电结果
|
||||
* http://localhost:8080/ycbc/pushStartChargeResult
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushStopChargeResult/{orderCode}")
|
||||
public RestApiResponse<?> pushStopChargeResult(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("甬城泊车平台推送停止充电结果 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = ycbcService.pushStopChargeResult(orderCode);
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("甬城泊车平台推送停止充电结果 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("甬城泊车平台推送停止充电结果 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("甬城泊车平台推送停止充电结果 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 甬城泊车推送充电订单信息
|
||||
* http://localhost:8080/ycbc/pushChargeOrderInfo
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushChargeOrderInfo/{orderCode}")
|
||||
public RestApiResponse<?> pushChargeOrderInfo(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("甬城泊车平台推送充电订单信息 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = ycbcService.pushChargeOrderInfo(orderCode);
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("甬城泊车平台推送充电订单信息 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("甬城泊车平台推送充电订单信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("甬城泊车平台推送充电订单信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
278
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/zhongdianlian/ZDLController.java
vendored
Normal file
278
jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/zhongdianlian/ZDLController.java
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
package com.jsowell.web.controller.thirdparty.zhongdianlian;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.PushInfoParamDTO;
|
||||
import com.jsowell.pile.dto.PushStationInfoDTO;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.service.IThirdPartyPlatformConfigService;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.zhongdianlian.service.ZDLService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 中电联 controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/9/14 15:31
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/zdl")
|
||||
public class ZDLController extends BaseController {
|
||||
@Autowired
|
||||
private ZDLService zdlService;
|
||||
|
||||
@Autowired
|
||||
private LianLianService lianLianService;
|
||||
|
||||
/**
|
||||
* 获取token接口
|
||||
* http://localhost:8080/zdl/v1/query_token
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("中电联平台请求令牌 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = zdlService.generateToken(dto);
|
||||
logger.info("中电联平台请求令牌 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error("中电联平台 请求令牌接口 异常");
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 中电联平台查询充电站信息
|
||||
* http://localhost:8080/zdl/v1/query_stations_info
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("中电联平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
queryStationInfoDTO.setAddress("宁波");
|
||||
Map<String, String> map = zdlService.queryStationsInfo(queryStationInfoDTO);
|
||||
logger.info("中电联平台查询充电站信息 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("中电联平台查询充电站信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 中电联平台查询统计信息
|
||||
* http://localhost:8080/zdl/v1/query_stations_stats
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_stats")
|
||||
public CommonResult<?> queryStationStats(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("中电联平台查询统计信息 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = zdlService.queryStationStats(queryStationInfoDTO);
|
||||
logger.info("中电联平台查询统计信息 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "查询统计信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("中电联平台查询统计信息 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("查询统计信息发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 中电联平台设备接口状态查询
|
||||
* http://localhost:8080/zdl/v1/query_stations_status
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_status")
|
||||
public CommonResult<?> queryStationStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("中电联平台设备接口状态查询 params:{}", JSONObject.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
// 校验签名
|
||||
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
if (resultMap == null) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
}
|
||||
String operatorSecret = resultMap.get("OperatorSecret");
|
||||
String dataString = resultMap.get("Data");
|
||||
String dataSecret = resultMap.get("DataSecret");
|
||||
String dataSecretIV = resultMap.get("DataSecretIV");
|
||||
|
||||
// String dataString = "L31IkD83nw7bm+eWcvfB1U27uIqSBg29+CHyZu6+qlQ=";
|
||||
// String dataSecret = "vj3RWNsWIxT5MC2K";
|
||||
// String dataSecretIV = "jjkySnGlM3pbOUki";
|
||||
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = zdlService.queryStationStatus(queryStationInfoDTO);
|
||||
logger.info("中电联平台设备接口状态查询 result:{}", JSONObject.toJSONString(map));
|
||||
return CommonResult.success(0, "设备接口状态查询成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("中电联平台设备接口状态查询 error:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.failed("设备接口状态查询发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送充电站信息 notification_stationInfo
|
||||
* http://localhost:8080/zdl/v1/pushStationInfo
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/pushStationInfo")
|
||||
public RestApiResponse<?> pushStationInfo(@RequestBody PushStationInfoDTO dto) {
|
||||
logger.info("推送中电联平台充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
zdlService.pushStationInfo(dto);
|
||||
response = new RestApiResponse<>();
|
||||
}catch (BusinessException e) {
|
||||
logger.error("推送中电联平台充电站信息 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("推送中电联平台充电站信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("推送中电联平台充电站信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 联联平台设备状态变化推送
|
||||
* http://localhost:8080/zdl/v1/pushStationStatus
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/pushStationStatus")
|
||||
public RestApiResponse<?> pushStationStatus(@RequestBody PushInfoParamDTO dto) {
|
||||
logger.info("中电联平台设备状态变化推送 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) ||
|
||||
StringUtils.isBlank(String.valueOf(dto.getStatus()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String result = zdlService.notificationStationStatus(dto.getPileConnectorCode(), dto.getStatus());
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("中电联平台设备状态变化推送 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("中电联平台设备状态变化推送 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("中电联平台设备状态变化推送 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送订单信息
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pushOrderInfo/{orderCode}")
|
||||
public RestApiResponse<?> pushOrderInfo(@PathVariable("orderCode")String orderCode) {
|
||||
logger.info("中电联平台推送订单信息 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(orderCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String result = zdlService.pushChargeOrderInfo(orderCode);
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (BusinessException e) {
|
||||
logger.error("中电联平台推送订单信息 error",e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("中电联平台推送订单信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("中电联平台推送订单信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user