mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update
This commit is contained in:
@@ -193,6 +193,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
long chargingTime = DateUtils.intervalTime("2023-02-24 16:00:00", "2023-02-24 17:03:06");
|
||||
System.out.println(chargingTime);
|
||||
|
||||
|
||||
String dateToStr = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date());
|
||||
System.out.println(dateToStr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.jsowell.common.util.lianlian;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
@@ -10,6 +14,9 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 联联充电
|
||||
*/
|
||||
@@ -81,5 +88,55 @@ public class HttpRequestUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 联联平台发送请求
|
||||
*
|
||||
* @param token 联联平台令牌
|
||||
* @param data 要传输的JsonString格式数据
|
||||
* @param url 请求地址
|
||||
* @param dataSecret 消息密钥
|
||||
* @param dataSecretIV 消息密钥初始化向量
|
||||
* @param operatorId 运营商id
|
||||
* @param sigSecret 签名密钥
|
||||
* @return
|
||||
*/
|
||||
public static String sendPost(String token, String data, String url, String dataSecret,
|
||||
String dataSecretIV, String operatorId, String sigSecret){
|
||||
//加密
|
||||
byte[] encryptText = Cryptos.aesEncrypt(data.getBytes(),
|
||||
dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
System.out.println("加密数据:" + encryptData);
|
||||
|
||||
Map<String, String> params = Maps.newLinkedHashMap();
|
||||
params.put("OperatorID", operatorId);
|
||||
params.put("Data", encryptData);
|
||||
params.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date()));
|
||||
params.put("Seq", "001");
|
||||
String sign = GBSignUtils.sign(params, sigSecret);
|
||||
params.put("Sig", sign);
|
||||
|
||||
String postData = JSON.toJSONString(params);
|
||||
System.out.println("最终提交数据:" + postData);
|
||||
|
||||
String hutoolRequest = HttpRequest.post(url).header("Authorization", "Bearer " + token).body(postData).execute().body();
|
||||
|
||||
System.out.println("接收到返回数据:" + hutoolRequest);
|
||||
|
||||
Map<String, String> map = (Map<String, String>) JSON.parse(hutoolRequest);
|
||||
|
||||
String rData = map.get("Data");
|
||||
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(rData),
|
||||
dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
String plainData = "";
|
||||
try {
|
||||
plainData = new String(plainText, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("解密数据:" + plainData);
|
||||
return plainData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.*;
|
||||
import com.jsowell.common.util.http.HttpUtils;
|
||||
import com.jsowell.common.util.lianlian.Cryptos;
|
||||
import com.jsowell.common.util.lianlian.Encodes;
|
||||
import com.jsowell.common.util.lianlian.GBSignUtils;
|
||||
import com.jsowell.common.util.lianlian.LianLianUtils;
|
||||
import com.jsowell.common.util.lianlian.*;
|
||||
import com.jsowell.netty.command.ykc.StartChargingCommand;
|
||||
import com.jsowell.netty.command.ykc.StopChargingCommand;
|
||||
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
|
||||
@@ -157,63 +154,59 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
// 调用联联平台接口
|
||||
String url = "http://testdataexchange.evchargeonline.com:82/shevcs/v1/" + "notification_stationInfo";
|
||||
|
||||
// String jsonString = JSON.toJSONString(info);
|
||||
|
||||
// Gson gson = new Gson();
|
||||
// String gsonString = gson.toJson(info);
|
||||
|
||||
String jsonStr = JSONUtil.toJsonStr(info);
|
||||
|
||||
// System.out.println("jsonString : " + jsonString);
|
||||
// System.out.println("gsonString : " + gsonString);
|
||||
System.out.println("jsonStr : " + jsonStr);
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("StationInfo", jsonStr);
|
||||
|
||||
String jsonString = JSONObject.toJSONString(data);
|
||||
System.out.println("jsonString : " + jsonString);
|
||||
|
||||
//加密
|
||||
byte[] encryptText = Cryptos.aesEncrypt(jsonString.getBytes(),
|
||||
dto.getDataSecret().getBytes(), dto.getDataSecretIV().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
System.out.println("加密数据:" + encryptData);
|
||||
String result = HttpRequestUtil.sendPost(dto.getToken(), jsonString, url, dto.getDataSecret()
|
||||
, dto.getDataSecretIV(), dto.getOperatorID(), dto.getSigSecret());
|
||||
|
||||
Map<String, String> params = Maps.newLinkedHashMap();
|
||||
params.put("OperatorID", dto.getOperatorID());
|
||||
params.put("Data", encryptData);
|
||||
params.put("TimeStamp", "20230510145200");
|
||||
params.put("Seq", "001");
|
||||
String sign = GBSignUtils.sign(params, dto.getSigSecret());
|
||||
params.put("Sig", sign);
|
||||
System.out.println(result);
|
||||
|
||||
String postData = JSON.toJSONString(params);
|
||||
System.out.println("最终提交数据:" + postData);
|
||||
|
||||
String hutoolRequest = HttpRequest.post(url).header("Authorization", "Bearer " + dto.getToken()).body(postData).execute().body();
|
||||
|
||||
System.out.println("接收到返回数据:" + hutoolRequest);
|
||||
|
||||
Map<String, String> map = (Map<String, String>) JSON.parse(hutoolRequest);
|
||||
|
||||
String rData = map.get("Data");
|
||||
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(rData),
|
||||
dto.getDataSecret().getBytes(), dto.getDataSecretIV().getBytes());
|
||||
String plainData = "";
|
||||
try {
|
||||
plainData = new String(plainText, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("解密数据:" + plainData);
|
||||
// //加密
|
||||
// byte[] encryptText = Cryptos.aesEncrypt(jsonString.getBytes(),
|
||||
// dto.getDataSecret().getBytes(), dto.getDataSecretIV().getBytes());
|
||||
// String encryptData = Encodes.encodeBase64(encryptText);
|
||||
// System.out.println("加密数据:" + encryptData);
|
||||
//
|
||||
// Map<String, String> params = Maps.newLinkedHashMap();
|
||||
// params.put("OperatorID", dto.getOperatorID());
|
||||
// params.put("Data", encryptData);
|
||||
// params.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date()));
|
||||
// params.put("Seq", "001");
|
||||
// String sign = GBSignUtils.sign(params, dto.getSigSecret());
|
||||
// params.put("Sig", sign);
|
||||
//
|
||||
// String postData = JSON.toJSONString(params);
|
||||
// System.out.println("最终提交数据:" + postData);
|
||||
//
|
||||
// String hutoolRequest = HttpRequest.post(url).header("Authorization", "Bearer " + dto.getToken()).body(postData).execute().body();
|
||||
//
|
||||
// System.out.println("接收到返回数据:" + hutoolRequest);
|
||||
//
|
||||
// Map<String, String> map = (Map<String, String>) JSON.parse(hutoolRequest);
|
||||
//
|
||||
// String rData = map.get("Data");
|
||||
//
|
||||
// byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(rData),
|
||||
// dto.getDataSecret().getBytes(), dto.getDataSecretIV().getBytes());
|
||||
// String plainData = "";
|
||||
// try {
|
||||
// plainData = new String(plainText, "UTF-8");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// System.out.println("解密数据:" + plainData);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
public static void main(String[] args){
|
||||
BigDecimal bigDecimal = new BigDecimal("7").setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||
System.out.println(bigDecimal);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -696,7 +689,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String pileSn = pileBasicInfo.getSn();
|
||||
|
||||
equipmentInfo.setEquipmentID(pileSn);
|
||||
equipmentInfo.setManufacturerID(merchantInfo.getOrganizationCode());
|
||||
equipmentInfo.setManufacturerID("987654321");
|
||||
equipmentInfo.setConstructionTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileBasicInfo.getCreateTime()));
|
||||
|
||||
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
|
||||
|
||||
Reference in New Issue
Block a user