Jelajahi Sumber

[功能修复]7状态上线

liuf 1 tahun lalu
induk
melakukan
b4cbedafa7

+ 20 - 4
src/main/java/com/tmzn/devicelinkykc/message/DeviceMsgHandle.java

@@ -540,10 +540,10 @@ public class DeviceMsgHandle {
             //充电完成状态是7,先处理一波
             logger.info("charnging Portstatus>>" + portStatus + ";type:" + type);
 
-                if (deviceOnline(imei, port, (byte) PortStatusConstant.CHARGING_END, StatusConstant.INSERT_GUNS_YES, type)){
-                    //状态是7时,处理过订单返回才是true
-                    return;
-                }
+            if (deviceOnline(imei, port, (byte) PortStatusConstant.CHARGING_END, StatusConstant.INSERT_GUNS_YES, type)){
+                //状态是7时,处理过订单返回才是true
+                return;
+            }
 
             logger.info("charnging Port>>b>>>>");
             //再去保证设备状态变化处理7为空闲插枪
@@ -590,6 +590,22 @@ public class DeviceMsgHandle {
             orderStatusQueryWrapper.eq("device_imei", imei).eq("guns_code", port).orderByDesc("create_time").last("limit 1");
             OrderStatus one = orderStatusService.getOne(orderStatusQueryWrapper);
 
+            //可能会触发不了上线
+            if (!socketHandle.existDeviceConnection(one.getPileCode())) {
+                try {
+                    QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
+                    deviceQueryWrapper.eq("pile_code", one.getPileCode()).eq("disabled", DeviceOnlineStatus.NORMAL);
+                    Device device = deviceService.getOne(deviceQueryWrapper);
+                    socketHandle.addDeviceConnection(device.getIp(),port,one.getPileCode(), one.getDeviceImei(), one.getDeviceSn());
+                    loginFrame.loginMsgSend(socketHandle.getDeviceConnection(one.getPileCode()), device);
+                    //从新登录可能造成通讯上的问题,这里不在往下进行状态操作
+                } catch (IOException e) {
+                    logger.info("device:" + one.getDeviceSn() + " open socket Exception!!!");
+                    e.printStackTrace();
+                }
+            }
+
+
             //7状态小于30秒内且订单原因不是远程停充
             if((System.currentTimeMillis()- one.getCreateTime())<60*1000
                     &&one.getReasonStopCharging()!=TransConstant.APP_REMOTE_STOP){