|
@@ -19,6 +19,7 @@ import com.tmzn.devicelinkykc.frameMsg.frameType.LoginFrame;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.RealTimeStatusPushFrame;
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.RealTimeStatusPushFrame;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.TransactionFlowPushFrame;
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.TransactionFlowPushFrame;
|
|
|
import com.tmzn.devicelinkykc.msgEnum.DeviceSendYkc;
|
|
import com.tmzn.devicelinkykc.msgEnum.DeviceSendYkc;
|
|
|
|
|
+import com.tmzn.devicelinkykc.openfeign.transdata.RpcResult;
|
|
|
import com.tmzn.devicelinkykc.redis.RedisCache;
|
|
import com.tmzn.devicelinkykc.redis.RedisCache;
|
|
|
import com.tmzn.devicelinkykc.service.*;
|
|
import com.tmzn.devicelinkykc.service.*;
|
|
|
import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
|
|
import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
|
|
@@ -142,6 +143,16 @@ public class DeviceMsgHandle {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void testMsg(String msg) throws Exception {
|
|
|
|
|
+ logger.info("testmsg>>>" + msg);
|
|
|
|
|
+ JSONObject jsonObject = null;
|
|
|
|
|
+ jsonObject = JSONObject.parseObject(msg);
|
|
|
|
|
+ //设备状态更新,true:没有type不是设备上送类型不往云快充处理 false:需要根据设备消息类型往下处理是不是需要上报云快充
|
|
|
|
|
+ if (checkDeviceStatus(jsonObject)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void checkActive(String s) {
|
|
private void checkActive(String s) {
|
|
|
|
|
|
|
|
Long now = System.currentTimeMillis();
|
|
Long now = System.currentTimeMillis();
|
|
@@ -185,6 +196,52 @@ public class DeviceMsgHandle {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private boolean checkAutoStop(int power,String imei,int portId){
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+ String hkey = imei+"_"+portId;
|
|
|
|
|
+ Integer lastPower0Times = 0;
|
|
|
|
|
+ if(power>0){
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ lastPower0Times = redisCache.getCacheMapValue(RedisConstant.POWER_ZERO_TIMES,hkey);
|
|
|
|
|
+ if(lastPower0Times == null){
|
|
|
|
|
+ lastPower0Times = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ lastPower0Times = lastPower0Times+1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ redisCache.setCacheMapValue(RedisConstant.POWER_ZERO_TIMES,hkey,lastPower0Times);
|
|
|
|
|
+
|
|
|
|
|
+ if(lastPower0Times<5){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //查找订单开始时间 如果开始时间过过2分钟 且连续power为0 就需要停止充电
|
|
|
|
|
+ QueryWrapper<OrderStatus> orderStatusQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ orderStatusQueryWrapper.eq("device_imei", imei).eq("guns_code", portId).orderByDesc("create_time").last("limit 1");
|
|
|
|
|
+ OrderStatus one = orderStatusService.getOne(orderStatusQueryWrapper);
|
|
|
|
|
+ if(one.getNowOrderStatus()!=StatusConstant.NOW_ORDER_STATUS_CHARGING){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if((System.currentTimeMillis()- one.getCreateTime())<120*1000){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //连续3次功率0 就要停止充电
|
|
|
|
|
+ RpcResult rpcResult = deviceControlerService.stopCharge(imei, imei, (int) portId);
|
|
|
|
|
+ logger.info("{}-{}触发无功率自停{}",imei,portId,lastPower0Times);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ logger.error("无功率检测异常{}",e.getMessage());
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 设备状态按照设备上报和设备心跳上送时间校验修改,这里就必须更新状态的修改时间;通过定时任务判断在线设备接收心跳包超10分钟改为离线
|
|
* 设备状态按照设备上报和设备心跳上送时间校验修改,这里就必须更新状态的修改时间;通过定时任务判断在线设备接收心跳包超10分钟改为离线
|
|
|
*
|
|
*
|
|
@@ -225,6 +282,17 @@ public class DeviceMsgHandle {
|
|
|
// if (port_second_status != null&&power==0&&port_second_status==PortStatusConstant.CHARGING){
|
|
// if (port_second_status != null&&power==0&&port_second_status==PortStatusConstant.CHARGING){
|
|
|
// port_second_status=PortStatusConstant.FREE;
|
|
// port_second_status=PortStatusConstant.FREE;
|
|
|
// }
|
|
// }
|
|
|
|
|
+
|
|
|
|
|
+ //判断连续无功率就自动停止
|
|
|
|
|
+ if(port_first_status==PortStatusConstant.CHARGING){
|
|
|
|
|
+ checkAutoStop(power,imei,1);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if(port_second_status==PortStatusConstant.CHARGING){
|
|
|
|
|
+ checkAutoStop(power,imei,2);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
redisCache.setCacheObject(RedisConstant.DEVICE_PORT_STATUS + imei, data, 15, TimeUnit.MINUTES);
|
|
redisCache.setCacheObject(RedisConstant.DEVICE_PORT_STATUS + imei, data, 15, TimeUnit.MINUTES);
|
|
|
if (port_first_status != null) {
|
|
if (port_first_status != null) {
|
|
|
checkPort(port_first_status, 1, imei, type);
|
|
checkPort(port_first_status, 1, imei, type);
|
|
@@ -718,6 +786,8 @@ public class DeviceMsgHandle {
|
|
|
if (one == null) {
|
|
if (one == null) {
|
|
|
logger.info("当前设备imei:" + imei + ",没有绑定ykc桩编码!!!!!!!!!!!!!!!!!!");
|
|
logger.info("当前设备imei:" + imei + ",没有绑定ykc桩编码!!!!!!!!!!!!!!!!!!");
|
|
|
return;
|
|
return;
|
|
|
|
|
+ }else{
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
statusServiceOne = new DeviceStatus();
|
|
statusServiceOne = new DeviceStatus();
|
|
|
statusServiceOne.setDeviceImei(imei);
|
|
statusServiceOne.setDeviceImei(imei);
|