|
|
@@ -2,7 +2,9 @@ package com.tmzn.devicelinkykc.frameMsg.frameType;
|
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.tmzn.devicelinkykc.constant.RedisConstant;
|
|
|
+import com.tmzn.devicelinkykc.constant.ykc.StatusConstant;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.DataConversion;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.FrameDataSplicing;
|
|
|
import com.tmzn.devicelinkykc.msgEnum.DeviceSendYkc;
|
|
|
@@ -32,10 +34,11 @@ public class RealTimeStatusPushFrame {
|
|
|
public void deviceStatusPush(DeviceConnectionMsg deviceConnectionMsg, byte[] trans, String pileCode, byte guns, byte gunsStatus, byte gunsInsert, double voltage, double power, BigDecimal elec, BigDecimal money, int time) {
|
|
|
byte[] encrypt = new byte[0];
|
|
|
|
|
|
+
|
|
|
int encFlag = DeviceSendYkc.UPLOAD_DEVICE_STATUS_RESPONSE.getEncryptFlag();
|
|
|
if(deviceConnectionMsg.getIs18()){
|
|
|
try {
|
|
|
- byte[] send = upStatusDevice(trans, pileCode, guns, gunsStatus, gunsInsert, voltage, power, elec, money, time);
|
|
|
+ byte[] send = upStatusDevice(deviceConnectionMsg,trans, pileCode, guns, gunsStatus, gunsInsert, voltage, power, elec, money, time);
|
|
|
log.info("deviceStatusPush>{}reporting>>>"+DataConversion.bytesToHexString(send),pileCode);
|
|
|
// String key = redisCache.getCacheObject(RedisConstant.KEYS+deviceConnectionMsg.getDeviceId());
|
|
|
String key = redisCache.getCacheMapValue(RedisConstant.YKC_KEY_MAP,deviceConnectionMsg.getDeviceId());
|
|
|
@@ -48,7 +51,7 @@ public class RealTimeStatusPushFrame {
|
|
|
}
|
|
|
}else{
|
|
|
try {
|
|
|
- byte[] send = upStatusDevice(trans, pileCode, guns, gunsStatus, gunsInsert, voltage, power, elec, money, time);
|
|
|
+ byte[] send = upStatusDevice(deviceConnectionMsg,trans, pileCode, guns, gunsStatus, gunsInsert, voltage, power, elec, money, time);
|
|
|
log.info("deviceStatusPush>reporting-save>>>"+DataConversion.bytesToHexString(send));
|
|
|
// log.info("deviceStatusPush>设备实时状态key>>>"+key);
|
|
|
encrypt = send;
|
|
|
@@ -88,7 +91,39 @@ public class RealTimeStatusPushFrame {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private byte[] upStatusDevice(byte[] trans, String pileCode, byte guns, byte gunsStatus, byte gunsInsert, double voltage, double power, BigDecimal elec, BigDecimal money, int time) throws Exception {
|
|
|
+ private byte[] upStatusDevice(DeviceConnectionMsg deviceConnectionMsg,byte[] trans, String pileCode, byte guns, byte gunsStatus, byte gunsInsert, double voltage, double power, BigDecimal elec, BigDecimal money, int time) throws Exception {
|
|
|
+
|
|
|
+ //剩余
|
|
|
+ byte[] soc = new byte[]{0x00};
|
|
|
+ //电池组最高温度
|
|
|
+ byte[] battery_temp = {0x32};
|
|
|
+ //剩余时间
|
|
|
+ byte[] remain_time = {0x00, 0x00};
|
|
|
+ //枪线温度
|
|
|
+ byte[] guns_line_temp = new byte[1];
|
|
|
+ //9.枪线温度
|
|
|
+ guns_line_temp[0] = 0x32;
|
|
|
+
|
|
|
+ if(deviceConnectionMsg.getIsDc()){
|
|
|
+ try{
|
|
|
+ //重置电压 直流电压放大10倍
|
|
|
+ voltage = voltage/10;
|
|
|
+ if(gunsStatus== StatusConstant.CHARGING){
|
|
|
+ JSONArray dataArray = redisCache.getCacheMapValue("device_last_163",deviceConnectionMsg.getImei()+"_"+guns);
|
|
|
+ if(dataArray != null){
|
|
|
+ //获取soc和剩余时间
|
|
|
+ //重置soc
|
|
|
+ soc[0] = dataArray.getByte(21+3);
|
|
|
+ remain_time[0] = dataArray.getByte(22+3);
|
|
|
+ remain_time[1] = dataArray.getByte(23+3);
|
|
|
+ log.info("充电中-soc:{},remain:{}",soc,remain_time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
byte[] msg = new byte[60];
|
|
|
//1.交易流水号,,空闲自己生成上报状态,充电拿到交易流水
|
|
|
@@ -138,11 +173,11 @@ public class RealTimeStatusPushFrame {
|
|
|
System.arraycopy(out_A, 0, msg, index, out_A.length);
|
|
|
index += out_A.length;
|
|
|
|
|
|
- byte[] guns_line_temp = new byte[1];
|
|
|
- //9.枪线温度
|
|
|
- guns_line_temp[0] = 0x32;
|
|
|
+
|
|
|
System.arraycopy(guns_line_temp, 0, msg, index, guns_line_temp.length);
|
|
|
index += guns_line_temp.length;
|
|
|
+
|
|
|
+
|
|
|
//10.枪线编码
|
|
|
byte[] guns_line_num = new byte[8];
|
|
|
guns_line_num[0] = 0x00;
|
|
|
@@ -155,22 +190,29 @@ public class RealTimeStatusPushFrame {
|
|
|
guns_line_num[7] = 0x00;
|
|
|
System.arraycopy(guns_line_num, 0, msg, index, guns_line_num.length);
|
|
|
index += guns_line_num.length;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//11.SOC
|
|
|
- byte[] soc = new byte[]{0x00};
|
|
|
+
|
|
|
System.arraycopy(soc, 0, msg, index, soc.length);
|
|
|
index += soc.length;
|
|
|
//12.电池组最高温度
|
|
|
- byte[] battery_temp = {0x32};
|
|
|
+
|
|
|
System.arraycopy(battery_temp, 0, msg, index, battery_temp.length);
|
|
|
index += battery_temp.length;
|
|
|
+
|
|
|
//13. 累计充电时间 BIN 码 2 单位:min;待机置零
|
|
|
byte[] charnging_Time = new byte[2];
|
|
|
charnging_Time[1] = (byte) ((time >> 8) & 0xFF);
|
|
|
charnging_Time[0] = (byte) (time & 0xFF);
|
|
|
System.arraycopy(charnging_Time, 0, msg, index, charnging_Time.length);
|
|
|
index += charnging_Time.length;
|
|
|
+
|
|
|
+
|
|
|
//14. 剩余时间 BIN 码 2 单位:min;待机置零、交流桩置零
|
|
|
- byte[] remain_time = {0x00, 0x00};
|
|
|
+
|
|
|
System.arraycopy(remain_time, 0, msg, index, remain_time.length);
|
|
|
index += remain_time.length;
|
|
|
|