mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
Merge branch 'dev' of http://192.168.2.2:8099/jsowell/jsowell-charger-web into dev
This commit is contained in:
@@ -364,22 +364,61 @@ public class LianLianController extends BaseController {
|
||||
* @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;
|
||||
// @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 {
|
||||
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());
|
||||
// 校验令牌
|
||||
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");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
||||
String dataStr = new String(plainText, "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);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("联联平台查询充电状态 result :{}", response);
|
||||
return response;
|
||||
return CommonResult.failed("联联平台查询充电状态发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,22 +427,55 @@ public class LianLianController extends BaseController {
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/query_stop_charge")
|
||||
public RestApiResponse<?> query_stop_charge(@RequestBody QueryStartChargeDTO dto) {
|
||||
// @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;
|
||||
// }
|
||||
|
||||
@PostMapping("/v1/query_stop_charge")
|
||||
public CommonResult<?> query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO 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());
|
||||
// 校验令牌
|
||||
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");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
|
||||
String dataStr = new String(plainText, "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);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("联联平台请求停止充电 result :{}", response);
|
||||
return response;
|
||||
return CommonResult.failed("联联平台请求停止充电发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -137,6 +137,9 @@ public class YKCUtils {
|
||||
String s1 = convertDecimalPoint(bytess, 5);
|
||||
System.out.println(s1);
|
||||
|
||||
String amount = "1000";
|
||||
byte[] priceByte = getPriceByte(amount, 2);
|
||||
System.out.println(BytesUtil.bin2HexStr(priceByte));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jsowell.pile.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 联联平台查询充电状态
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/5/31 15:00
|
||||
*/
|
||||
@Data
|
||||
public class QueryEquipChargeStatusDTO {
|
||||
@JsonProperty(value = "StartChargeSeq")
|
||||
private String StartChargeSeq;
|
||||
|
||||
@JsonProperty(value = "OperatorID")
|
||||
private String OperatorID;
|
||||
}
|
||||
@@ -184,7 +184,7 @@
|
||||
left join member_basic_info t2 on t1.member_id = t2.member_id
|
||||
join pile_station_info t3 on t1.station_id = t3.id
|
||||
join order_detail t4 on t4.order_code = t1.order_code
|
||||
join member_transaction_record t5 on t5.order_code = t1.order_code and action_type = 'forward'
|
||||
left join member_transaction_record t5 on t5.order_code = t1.order_code and action_type = 'forward'
|
||||
where t1.del_flag = '0'
|
||||
<if test="pileSn != null and pileSn != ''">
|
||||
and t1.pile_sn = #{pileSn,jdbcType=VARCHAR}
|
||||
|
||||
@@ -64,16 +64,16 @@ public interface LianLianService {
|
||||
|
||||
/**
|
||||
* 查询充电状态
|
||||
* @param startChargeSeq
|
||||
* @param dto
|
||||
*/
|
||||
QueryChargingStatusVO query_equip_charge_status(String startChargeSeq);
|
||||
Map<String, String> query_equip_charge_status(QueryEquipChargeStatusDTO dto);
|
||||
|
||||
/**
|
||||
* 请求停止充电
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
QueryStopChargeVO query_stop_charge(QueryStartChargeDTO dto);
|
||||
Map<String, String> query_stop_charge(QueryStartChargeDTO dto);
|
||||
|
||||
/**
|
||||
* 联联平台获取令牌
|
||||
@@ -110,7 +110,7 @@ public interface LianLianService {
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
String pushChargeStatus(String orderCode);
|
||||
String pushChargeStatus(String orderCode) throws UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* 推送停止充电结果(仅在 交易记录的帧类型中调用)
|
||||
|
||||
@@ -612,15 +612,19 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
/**
|
||||
* 查询充电状态
|
||||
*
|
||||
* @param startChargeSeq
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public QueryChargingStatusVO query_equip_charge_status(String startChargeSeq) {
|
||||
public Map<String, String> query_equip_charge_status(QueryEquipChargeStatusDTO dto) {
|
||||
// 通过订单号查询订单信息
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(startChargeSeq);
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq());
|
||||
// 通过订单号查询实时数据
|
||||
if (orderInfo == null) {
|
||||
throw new BusinessException("", "");
|
||||
return null;
|
||||
}
|
||||
DockingPlatformConfig configInfo = dockingPlatformConfigService.getInfoByOperatorId(dto.getOperatorID());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode());
|
||||
List<RealTimeMonitorData> realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode());
|
||||
@@ -639,7 +643,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
}
|
||||
// 拼装联联平台数据
|
||||
QueryChargingStatusVO vo = QueryChargingStatusVO.builder()
|
||||
.StartChargeSeq(startChargeSeq) // 订单号
|
||||
.StartChargeSeq(dto.getStartChargeSeq()) // 订单号
|
||||
.StartChargeSeqStat(Integer.parseInt(orderStatus)) // 订单状态
|
||||
.ConnectorID(orderInfo.getPileConnectorCode()) // 枪口编码
|
||||
.ConnectorStatus(Integer.parseInt(data.getConnectorStatus())) // 枪口状态
|
||||
@@ -656,7 +660,19 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
.build();
|
||||
|
||||
|
||||
return vo;
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(vo).getBytes(),
|
||||
configInfo.getOperatorSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getOperatorSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -666,7 +682,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public QueryStopChargeVO query_stop_charge(QueryStartChargeDTO dto) {
|
||||
public Map<String, String> query_stop_charge(QueryStartChargeDTO dto) {
|
||||
QueryStopChargeVO vo = new QueryStopChargeVO();
|
||||
|
||||
String orderCode = dto.getStartChargeSeq();
|
||||
@@ -674,7 +690,11 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
// 根据订单号查询订单信息
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
if (orderInfo == null) {
|
||||
throw new BusinessException("", "");
|
||||
return null;
|
||||
}
|
||||
DockingPlatformConfig configInfo = dockingPlatformConfigService.getInfoByOperatorId(dto.getOperatorID());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
// 若状态为充电中,则发送停机指令
|
||||
if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderInfo.getOrderStatus())) {
|
||||
@@ -687,7 +707,19 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
vo.setStartChargeSeq(orderCode);
|
||||
vo.setStartChargeSeqStat(3); // 3-停止中
|
||||
}
|
||||
return vo;
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(vo).getBytes(),
|
||||
configInfo.getOperatorSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getOperatorSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -980,7 +1012,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String pushChargeStatus(String orderCode) {
|
||||
public String pushChargeStatus(String orderCode) throws UnsupportedEncodingException {
|
||||
// 根据订单号查询订单信息
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
// 通过站点id查询相关配置信息
|
||||
@@ -996,7 +1028,16 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String urlAddress = settingInfo.getUrlAddress();
|
||||
|
||||
// 调用 查询充电状态方法
|
||||
QueryChargingStatusVO vo = query_equip_charge_status(orderCode);
|
||||
QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO();
|
||||
dto.setStartChargeSeq(orderCode);
|
||||
Map<String, String> map = query_equip_charge_status(dto);
|
||||
String data = map.get("Data");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data),
|
||||
operatorSecret.getBytes(), operatorSecret.getBytes());
|
||||
String dataStr = new String(plainText, "UTF-8");
|
||||
// 转成对应的对象
|
||||
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
@@ -1004,7 +1045,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
}
|
||||
String url = urlAddress + "notification_equip_charge_status";
|
||||
// 调用联联平台接口
|
||||
String jsonString = JSONObject.toJSONString(vo);
|
||||
String jsonString = JSONObject.toJSONString(queryEquipChargeStatusDTO);
|
||||
|
||||
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user