|
|
@@ -86,73 +86,78 @@ public class TaskRunner {
|
|
|
Set<String> devicePileCodes = map.keySet();
|
|
|
log.info("heart.deviceConnectionSize>>"+devicePileCodes.size());
|
|
|
devicePileCodes.stream().forEach(devicePileCode -> {
|
|
|
- DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
- Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
- //log.info("heartTime>>>" + new Date(heartTime));
|
|
|
-
|
|
|
- //拿到1枪设备状态
|
|
|
- // log.info("↑↑↑↑↑↑↑↑↑↑");
|
|
|
- if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_ONE)) {
|
|
|
-
|
|
|
- //1:当上一次的心跳和本次的心跳相差大于30秒证明已经3次没收到心跳回复了,进行重新登录
|
|
|
- //2:设备第一次上线时未触发过登录,设备连接集合中初始话的心跳时间还是0,符合该判断,进行登录
|
|
|
- QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
- deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
- Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
- DeviceStatus oneDs = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, devicePileCode);
|
|
|
- if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS) {
|
|
|
- //
|
|
|
- if (oneDs != null&&oneDs.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
- log.info("heartTaskAsyncPool-1>not longin and heart normal>>" + devicePileCode);
|
|
|
- loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
- return;
|
|
|
+ try{
|
|
|
+ DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
+ Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
+ //log.info("heartTime>>>" + new Date(heartTime));
|
|
|
+
|
|
|
+ //拿到1枪设备状态
|
|
|
+ // log.info("↑↑↑↑↑↑↑↑↑↑");
|
|
|
+ if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_ONE)) {
|
|
|
+
|
|
|
+ //1:当上一次的心跳和本次的心跳相差大于30秒证明已经3次没收到心跳回复了,进行重新登录
|
|
|
+ //2:设备第一次上线时未触发过登录,设备连接集合中初始话的心跳时间还是0,符合该判断,进行登录
|
|
|
+ QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
+ deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
+ Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
+ DeviceStatus oneDs = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, devicePileCode);
|
|
|
+ if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS) {
|
|
|
+ //
|
|
|
+ if (oneDs != null&&oneDs.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
+ log.info("heartTaskAsyncPool-1>not longin and heart normal>>" + devicePileCode);
|
|
|
+ loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //log.info("↑1↑1↑1↑1↑1↑1↑1↑1↑1↑1");
|
|
|
- if (oneDs != null) {
|
|
|
- // log.info("oneDes-heart>>>>>>>" + oneDs.toString());
|
|
|
- if (oneDs.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
- log.info("pileCode:" + devicePileCode + " loging... ..." + (System.currentTimeMillis() - heartTime));
|
|
|
- int a = 0;
|
|
|
- if (redisCache.hasKey(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode)) {
|
|
|
- //如果登录次数30秒内登三次就算断开
|
|
|
- a = redisCache.getCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode);
|
|
|
- if (a > 3) {
|
|
|
- socketHandle.removeDeviceConnection(devicePileCode);
|
|
|
+ //log.info("↑1↑1↑1↑1↑1↑1↑1↑1↑1↑1");
|
|
|
+ if (oneDs != null) {
|
|
|
+ // log.info("oneDes-heart>>>>>>>" + oneDs.toString());
|
|
|
+ if (oneDs.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
+ log.info("pileCode:" + devicePileCode + " loging... ..." + (System.currentTimeMillis() - heartTime));
|
|
|
+ int a = 0;
|
|
|
+ if (redisCache.hasKey(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode)) {
|
|
|
+ //如果登录次数30秒内登三次就算断开
|
|
|
+ a = redisCache.getCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode);
|
|
|
+ if (a > 3) {
|
|
|
+ socketHandle.removeDeviceConnection(devicePileCode);
|
|
|
+ } else {
|
|
|
+ loginFrame.loginMsgSend(deviceConnectionMsg, device);
|
|
|
+ }
|
|
|
+ a++;
|
|
|
+ redisCache.setCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode, a,32 * 1000, TimeUnit.MILLISECONDS);
|
|
|
} else {
|
|
|
- loginFrame.loginMsgSend(deviceConnectionMsg, device);
|
|
|
+ redisCache.setCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode, a, 32 * 1000, TimeUnit.MILLISECONDS);
|
|
|
}
|
|
|
- a++;
|
|
|
- redisCache.setCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode, a,32 * 1000, TimeUnit.MILLISECONDS);
|
|
|
- } else {
|
|
|
- redisCache.setCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode, a, 32 * 1000, TimeUnit.MILLISECONDS);
|
|
|
+ }else {
|
|
|
+ //存在设备在线状态的,上送心跳
|
|
|
+ log.info("heartSend-1>>>"+devicePileCode);
|
|
|
+ heartFrameSend.heartSend(deviceConnectionMsg, oneDs);
|
|
|
}
|
|
|
- }else {
|
|
|
- //存在设备在线状态的,上送心跳
|
|
|
- log.info("heartSend-1>>>"+devicePileCode);
|
|
|
- heartFrameSend.heartSend(deviceConnectionMsg, oneDs);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //拿到2枪设备状态
|
|
|
- if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_TWO)) {
|
|
|
- DeviceStatus twoDs = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_TWO, devicePileCode);
|
|
|
- if (twoDs != null) {
|
|
|
- log.info("twoDes-heart>>>>>>>" + twoDs.toString());
|
|
|
- if (twoDs.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
- log.info("twoDs:pileCode:" + devicePileCode + " loging... ..." + (System.currentTimeMillis() - heartTime));
|
|
|
- //1:当上一次的心跳和本次的心跳相差大于30秒证明已经3次没收到心跳回复了,进行重新登录
|
|
|
- //2:设备第一次上线时未触发过登录,设备连接集合中初始话的心跳时间还是0,符合该判断,进行登录
|
|
|
- QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
- deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
- Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
-
|
|
|
- loginFrame.loginMsgSend(deviceConnectionMsg, device);
|
|
|
+ //拿到2枪设备状态
|
|
|
+ if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_TWO)) {
|
|
|
+ DeviceStatus twoDs = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_TWO, devicePileCode);
|
|
|
+ if (twoDs != null) {
|
|
|
+ log.info("twoDes-heart>>>>>>>" + twoDs.toString());
|
|
|
+ if (twoDs.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
+ log.info("twoDs:pileCode:" + devicePileCode + " loging... ..." + (System.currentTimeMillis() - heartTime));
|
|
|
+ //1:当上一次的心跳和本次的心跳相差大于30秒证明已经3次没收到心跳回复了,进行重新登录
|
|
|
+ //2:设备第一次上线时未触发过登录,设备连接集合中初始话的心跳时间还是0,符合该判断,进行登录
|
|
|
+ QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
+ deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
+ Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
+
|
|
|
+ loginFrame.loginMsgSend(deviceConnectionMsg, device);
|
|
|
+ }
|
|
|
+ //存在设备在线状态的,上送心跳
|
|
|
+ log.info("heartSend-2>>>"+devicePileCode);
|
|
|
+ heartFrameSend.heartSend(deviceConnectionMsg, twoDs);
|
|
|
}
|
|
|
- //存在设备在线状态的,上送心跳
|
|
|
- log.info("heartSend-2>>>"+devicePileCode);
|
|
|
- heartFrameSend.heartSend(deviceConnectionMsg, twoDs);
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("Heart beat task exception"+e.toString());
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
});
|
|
|
log.info("======Heart beat task ending=====");
|
|
|
@@ -179,180 +184,181 @@ public class TaskRunner {
|
|
|
//redis取出在线设备集合
|
|
|
Set<String> devicePileCodes = map.keySet();
|
|
|
devicePileCodes.stream().forEach(devicePileCode -> {
|
|
|
- if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_ONE)) {
|
|
|
- DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, devicePileCode);
|
|
|
- if (deviceStatus != null) {
|
|
|
- if(deviceStatus.getGunStatus() != StatusConstant.CHARGING){
|
|
|
- log.info("chargingMsg>>>deviceguns status>>"+deviceStatus.getGunStatus());
|
|
|
- return;
|
|
|
- }
|
|
|
- //存在设备上送充电状态
|
|
|
- DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
- if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
|
|
|
- //
|
|
|
- QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
- deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
- Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
- Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
- if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
- log.info("charngingTaskAsyncPool-1>not longin and heart normal>>" + devicePileCode);
|
|
|
- loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ try{
|
|
|
+ if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_ONE)) {
|
|
|
+ DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, devicePileCode);
|
|
|
+ if (deviceStatus != null) {
|
|
|
+ if(deviceStatus.getGunStatus() != StatusConstant.CHARGING){
|
|
|
+ log.info("chargingMsg>>>deviceguns status>>"+deviceStatus.getGunStatus());
|
|
|
+ return;
|
|
|
}
|
|
|
- log.info("charngingTaskAsyncPool-1>not longin>>"+devicePileCode);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (deviceStatus.getGunStatus() == StatusConstant.CHARGING) {
|
|
|
- if (deviceConnectionMsg.getLoginStatus() == 1) {
|
|
|
- if (redisCache.hasKey(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei())) {
|
|
|
- //TODO:充电时间 电量 金额 按计费模板进行计算后上报,不使用主板消息
|
|
|
- //设备当前状态筛选
|
|
|
- List<OrderStatus> orderStatuselist = orderStatuses.stream().filter(orderStatus -> orderStatus.getPileCode().equals(deviceStatus.getPileCode())).collect(Collectors.toList());
|
|
|
- if (orderStatuselist.size() > 0) {
|
|
|
- orderStatuselist.stream().forEach(orderStatus -> {
|
|
|
- //设备计费模板筛选
|
|
|
- List<BillingModel> billingModelList = billingModels.stream().filter(billingModel -> orderStatus.getPileCode().equals(billingModel.getPileCode())).collect(Collectors.toList());
|
|
|
- if (billingModelList.size() > 0) {
|
|
|
- //费用计算
|
|
|
- billingModelList.stream().forEach(billingModel -> {
|
|
|
- JSONObject statusJSON = redisCache.getCacheObject(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei());
|
|
|
- Integer voltage = statusJSON.getInteger("voltage");
|
|
|
- Integer power = statusJSON.getInteger("power");
|
|
|
-
|
|
|
- //计算实时数据
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
- //算电量
|
|
|
- Map<String, BigDecimal> start = null;
|
|
|
- try {
|
|
|
- start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime, false);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- //log.info(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1 + ">>redis过期的时间" + redisCache.getExpire(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1));
|
|
|
- //log.info(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1 + "redis的键是否存在" + redisCache.hasKey(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1));
|
|
|
- if (redisCache.hasKey(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1) && redisCache.getExpire(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1) > 1) {
|
|
|
- start = redisCache.getCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1);
|
|
|
- } else {
|
|
|
+ //存在设备上送充电状态
|
|
|
+ DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
+ if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
|
|
|
+ //
|
|
|
+ QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
+ deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
+ Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
+ Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
+ if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
+ log.info("charngingTaskAsyncPool-1>not longin and heart normal>>" + devicePileCode);
|
|
|
+ loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ }
|
|
|
+ log.info("charngingTaskAsyncPool-1>not longin>>"+devicePileCode);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (deviceStatus.getGunStatus() == StatusConstant.CHARGING) {
|
|
|
+ if (deviceConnectionMsg.getLoginStatus() == 1) {
|
|
|
+ if (redisCache.hasKey(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei())) {
|
|
|
+ //TODO:充电时间 电量 金额 按计费模板进行计算后上报,不使用主板消息
|
|
|
+ //设备当前状态筛选
|
|
|
+ List<OrderStatus> orderStatuselist = orderStatuses.stream().filter(orderStatus -> orderStatus.getPileCode().equals(deviceStatus.getPileCode())).collect(Collectors.toList());
|
|
|
+ if (orderStatuselist.size() > 0) {
|
|
|
+ orderStatuselist.stream().forEach(orderStatus -> {
|
|
|
+ //设备计费模板筛选
|
|
|
+ List<BillingModel> billingModelList = billingModels.stream().filter(billingModel -> orderStatus.getPileCode().equals(billingModel.getPileCode())).collect(Collectors.toList());
|
|
|
+ if (billingModelList.size() > 0) {
|
|
|
+ //费用计算
|
|
|
+ billingModelList.stream().forEach(billingModel -> {
|
|
|
+ JSONObject statusJSON = redisCache.getCacheObject(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei());
|
|
|
+ Integer voltage = statusJSON.getInteger("voltage");
|
|
|
+ Integer power = statusJSON.getInteger("power");
|
|
|
+
|
|
|
+ //计算实时数据
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ //算电量
|
|
|
+ Map<String, BigDecimal> start = null;
|
|
|
try {
|
|
|
- start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime, true);
|
|
|
+ start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime, false);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1, start, 60, TimeUnit.SECONDS);
|
|
|
- }
|
|
|
- BigDecimal elec = start.get("elec");
|
|
|
- BigDecimal money = start.get("money");
|
|
|
- if (elec.equals(new BigDecimal("0.0000"))){
|
|
|
- elec=elec.add(new BigDecimal("0.0001").setScale(4,BigDecimal.ROUND_DOWN));
|
|
|
- }
|
|
|
- log.info(devicePileCode+"充电中-1=>实时elec>>>"+elec);
|
|
|
- //????????????????????????????
|
|
|
- if (money.compareTo(orderStatus.getStartMoney())>0){
|
|
|
- //余额没有了,停充
|
|
|
- log.info("实时状态校验时余额不足>>>>>>停充>>>>");
|
|
|
- DeviceParam deviceParam = new DeviceParam();
|
|
|
- deviceParam.setDeviceId(orderStatus.getDeviceImei());
|
|
|
- deviceParam.setCcid(orderStatus.getDeviceImei());
|
|
|
- orderStatus.setEndTime(System.currentTimeMillis()-1000*60*5);
|
|
|
- orderStatus.setReasonStopCharging(TransConstant.INSUFFICIENT_BALANCE_EXCEPTION_STOP);
|
|
|
- orderStatusService.updateById(orderStatus);
|
|
|
-
|
|
|
- deviceControlerService.sendPortDetailCmd(deviceParam);
|
|
|
- deviceControlerService.stopCharge(orderStatus.getDeviceImei(),orderStatus.getDeviceImei(),1);
|
|
|
-
|
|
|
- //这里为了保证余额不足的情况时:上报实时状态的最后电量费用不超过余额,上报的最后一帧为前一帧数据
|
|
|
- //Map<String, BigDecimal> map1 = realTimeMoney.start(power/1000, billingModel, orderStatus.getCreateTime(),orderStatus.getEndTime());
|
|
|
- //Map<String, BigDecimal> start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(),orderStatus.getEndTime());
|
|
|
-
|
|
|
- //redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode()+1, start, 5 * 60 , TimeUnit.SECONDS);
|
|
|
- //elec=start.get("elec");
|
|
|
- //money=start.get("money");
|
|
|
- }
|
|
|
- int mi = (int) (System.currentTimeMillis() - orderStatus.getCreateTime()) / 1000 / 60;
|
|
|
-
|
|
|
- log.info("↑↑↑↑↑↑↑↑↑↑↑↑↑充电中实时状态上报-1↑↑↑↑↑↑↑↑↑↑↑↑↑mi " + mi);
|
|
|
- realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, orderStatus.getTransOrder(), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), voltage, power, elec, money, mi);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ //log.info(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1 + ">>redis过期的时间" + redisCache.getExpire(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1));
|
|
|
+ //log.info(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1 + "redis的键是否存在" + redisCache.hasKey(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1));
|
|
|
+ if (redisCache.hasKey(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1) && redisCache.getExpire(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1) > 1) {
|
|
|
+ start = redisCache.getCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1);
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime, true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1, start, 60, TimeUnit.SECONDS);
|
|
|
+ }
|
|
|
+ BigDecimal elec = start.get("elec");
|
|
|
+ BigDecimal money = start.get("money");
|
|
|
+ if (elec.equals(new BigDecimal("0.0000"))){
|
|
|
+ elec=elec.add(new BigDecimal("0.0001").setScale(4,BigDecimal.ROUND_DOWN));
|
|
|
+ }
|
|
|
+ log.info(devicePileCode+"充电中-1=>实时elec>>>"+elec);
|
|
|
+ //????????????????????????????
|
|
|
+ if (money.compareTo(orderStatus.getStartMoney())>0){
|
|
|
+ //余额没有了,停充
|
|
|
+ log.info("实时状态校验时余额不足>>>>>>停充>>>>");
|
|
|
+ DeviceParam deviceParam = new DeviceParam();
|
|
|
+ deviceParam.setDeviceId(orderStatus.getDeviceImei());
|
|
|
+ deviceParam.setCcid(orderStatus.getDeviceImei());
|
|
|
+ orderStatus.setEndTime(System.currentTimeMillis()-1000*60*5);
|
|
|
+ orderStatus.setReasonStopCharging(TransConstant.INSUFFICIENT_BALANCE_EXCEPTION_STOP);
|
|
|
+ orderStatusService.updateById(orderStatus);
|
|
|
+
|
|
|
+ deviceControlerService.sendPortDetailCmd(deviceParam);
|
|
|
+ deviceControlerService.stopCharge(orderStatus.getDeviceImei(),orderStatus.getDeviceImei(),1);
|
|
|
+
|
|
|
+ //这里为了保证余额不足的情况时:上报实时状态的最后电量费用不超过余额,上报的最后一帧为前一帧数据
|
|
|
+ //Map<String, BigDecimal> map1 = realTimeMoney.start(power/1000, billingModel, orderStatus.getCreateTime(),orderStatus.getEndTime());
|
|
|
+ //Map<String, BigDecimal> start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(),orderStatus.getEndTime());
|
|
|
+
|
|
|
+ //redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode()+1, start, 5 * 60 , TimeUnit.SECONDS);
|
|
|
+ //elec=start.get("elec");
|
|
|
+ //money=start.get("money");
|
|
|
+ }
|
|
|
+ int mi = (int) (System.currentTimeMillis() - orderStatus.getCreateTime()) / 1000 / 60;
|
|
|
+
|
|
|
+ log.info("↑↑↑↑↑↑↑↑↑↑↑↑↑充电中实时状态上报-1↑↑↑↑↑↑↑↑↑↑↑↑↑mi " + mi);
|
|
|
+ realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, orderStatus.getTransOrder(), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), voltage, power, elec, money, mi);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_TWO)) {
|
|
|
- DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_TWO, devicePileCode);
|
|
|
- if (deviceStatus != null) {
|
|
|
- //存在设备上送充电状态
|
|
|
- DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
- if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
|
|
|
- //
|
|
|
- QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
- deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
- Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
- Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
- if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
- log.info("charngingTaskAsyncPool-2>not longin and heart normal>>" + devicePileCode);
|
|
|
- loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_TWO)) {
|
|
|
+ DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_TWO, devicePileCode);
|
|
|
+ if (deviceStatus != null) {
|
|
|
+ //存在设备上送充电状态
|
|
|
+ DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
+ if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
|
|
|
+ //
|
|
|
+ QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
+ deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
+ Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
+ Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
+ if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
+ log.info("charngingTaskAsyncPool-2>not longin and heart normal>>" + devicePileCode);
|
|
|
+ loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ }
|
|
|
+ log.info("charngingTaskAsyncPool-2>not longin>>"+devicePileCode);
|
|
|
+ return;
|
|
|
}
|
|
|
- log.info("charngingTaskAsyncPool-2>not longin>>"+devicePileCode);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (deviceStatus.getGunStatus() == StatusConstant.CHARGING) {
|
|
|
- if (deviceConnectionMsg.getLoginStatus() == 1) {
|
|
|
- if (redisCache.hasKey(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei())) {
|
|
|
- //TODO:充电时间 电量 金额 按计费模板进行计算后上报,不使用主板消息
|
|
|
- //设备当前状态筛选
|
|
|
- List<OrderStatus> orderStatusList = orderStatuses.stream().filter(orderStatus -> orderStatus.getPileCode().equals(deviceStatus.getPileCode())).collect(Collectors.toList());
|
|
|
- if (orderStatusList.size() > 0) {
|
|
|
- orderStatusList.stream().forEach(orderStatus -> {
|
|
|
- //设备计费模板筛选
|
|
|
- List<BillingModel> billingModelList = billingModels.stream().filter(billingModel -> orderStatus.getPileCode().equals(billingModel.getPileCode())).collect(Collectors.toList());
|
|
|
- if (billingModelList.size() > 0) {
|
|
|
- //费用计算
|
|
|
- billingModelList.stream().forEach(billingModel -> {
|
|
|
- JSONObject statusJSON = redisCache.getCacheObject(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei());
|
|
|
- Integer voltage = statusJSON.getInteger("voltage");
|
|
|
- Integer power = statusJSON.getInteger("power");
|
|
|
- long endTime = 0L;
|
|
|
- if (endTime == 0) {
|
|
|
- endTime = System.currentTimeMillis();
|
|
|
- }
|
|
|
- Map<String, BigDecimal> start = null;
|
|
|
- try {
|
|
|
- start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime, false);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if (redisCache.hasKey(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2) && redisCache.getExpire(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2) > 60 * 1000) {
|
|
|
- start = redisCache.getCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2);
|
|
|
- } else {
|
|
|
+ if (deviceStatus.getGunStatus() == StatusConstant.CHARGING) {
|
|
|
+ if (deviceConnectionMsg.getLoginStatus() == 1) {
|
|
|
+ if (redisCache.hasKey(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei())) {
|
|
|
+ //TODO:充电时间 电量 金额 按计费模板进行计算后上报,不使用主板消息
|
|
|
+ //设备当前状态筛选
|
|
|
+ List<OrderStatus> orderStatusList = orderStatuses.stream().filter(orderStatus -> orderStatus.getPileCode().equals(deviceStatus.getPileCode())).collect(Collectors.toList());
|
|
|
+ if (orderStatusList.size() > 0) {
|
|
|
+ orderStatusList.stream().forEach(orderStatus -> {
|
|
|
+ //设备计费模板筛选
|
|
|
+ List<BillingModel> billingModelList = billingModels.stream().filter(billingModel -> orderStatus.getPileCode().equals(billingModel.getPileCode())).collect(Collectors.toList());
|
|
|
+ if (billingModelList.size() > 0) {
|
|
|
+ //费用计算
|
|
|
+ billingModelList.stream().forEach(billingModel -> {
|
|
|
+ JSONObject statusJSON = redisCache.getCacheObject(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei());
|
|
|
+ Integer voltage = statusJSON.getInteger("voltage");
|
|
|
+ Integer power = statusJSON.getInteger("power");
|
|
|
+ long endTime = 0L;
|
|
|
+ if (endTime == 0) {
|
|
|
+ endTime = System.currentTimeMillis();
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> start = null;
|
|
|
try {
|
|
|
- start = transMoney.compute(2, billingModel, orderStatus.getCreateTime(), endTime, true);
|
|
|
+ start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime, false);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2, start, 5 * 60 * 1000, TimeUnit.MILLISECONDS);
|
|
|
- }
|
|
|
- BigDecimal elec = start.get("elec");
|
|
|
- BigDecimal money = start.get("money");
|
|
|
- if (elec.equals(BigDecimal.ZERO)){
|
|
|
- elec=elec.add(new BigDecimal("0.0001"));
|
|
|
- }
|
|
|
- log.info(devicePileCode+"充电中-2=>实时elec>>>"+elec);
|
|
|
- if (money.compareTo(orderStatus.getStartMoney()) > 0) {
|
|
|
- //余额没有了,停充
|
|
|
- log.info("实时状态校验时余额不足>>>>>>停充>>>>");
|
|
|
- DeviceParam deviceParam = new DeviceParam();
|
|
|
- deviceParam.setDeviceId(orderStatus.getDeviceImei());
|
|
|
- deviceParam.setCcid(orderStatus.getDeviceImei());
|
|
|
- orderStatus.setEndTime(System.currentTimeMillis()-1000*60*5);
|
|
|
- orderStatus.setReasonStopCharging(TransConstant.INSUFFICIENT_BALANCE_EXCEPTION_STOP);
|
|
|
- orderStatusService.updateById(orderStatus);
|
|
|
-
|
|
|
- deviceControlerService.sendPortDetailCmd(deviceParam);
|
|
|
- deviceControlerService.stopCharge(orderStatus.getDeviceImei(),orderStatus.getDeviceImei(),2);
|
|
|
- //余额没有了,停充
|
|
|
+ if (redisCache.hasKey(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2) && redisCache.getExpire(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2) > 60 * 1000) {
|
|
|
+ start = redisCache.getCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2);
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ start = transMoney.compute(2, billingModel, orderStatus.getCreateTime(), endTime, true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2, start, 5 * 60 * 1000, TimeUnit.MILLISECONDS);
|
|
|
+ }
|
|
|
+ BigDecimal elec = start.get("elec");
|
|
|
+ BigDecimal money = start.get("money");
|
|
|
+ if (elec.equals(BigDecimal.ZERO)){
|
|
|
+ elec=elec.add(new BigDecimal("0.0001"));
|
|
|
+ }
|
|
|
+ log.info(devicePileCode+"充电中-2=>实时elec>>>"+elec);
|
|
|
+ if (money.compareTo(orderStatus.getStartMoney()) > 0) {
|
|
|
+ //余额没有了,停充
|
|
|
+ log.info("实时状态校验时余额不足>>>>>>停充>>>>");
|
|
|
+ DeviceParam deviceParam = new DeviceParam();
|
|
|
+ deviceParam.setDeviceId(orderStatus.getDeviceImei());
|
|
|
+ deviceParam.setCcid(orderStatus.getDeviceImei());
|
|
|
+ orderStatus.setEndTime(System.currentTimeMillis()-1000*60*5);
|
|
|
+ orderStatus.setReasonStopCharging(TransConstant.INSUFFICIENT_BALANCE_EXCEPTION_STOP);
|
|
|
+ orderStatusService.updateById(orderStatus);
|
|
|
+
|
|
|
+ deviceControlerService.sendPortDetailCmd(deviceParam);
|
|
|
+ deviceControlerService.stopCharge(orderStatus.getDeviceImei(),orderStatus.getDeviceImei(),2);
|
|
|
+ //余额没有了,停充
|
|
|
// DeviceParam deviceParam = new DeviceParam();
|
|
|
// deviceParam.setDeviceId(orderStatus.getDeviceImei());
|
|
|
// deviceParam.setCcid(orderStatus.getDeviceImei());
|
|
|
@@ -362,23 +368,27 @@ public class TaskRunner {
|
|
|
// money = orderStatus.getStartMoney();
|
|
|
// orderStatus.setReasonStopCharging(TransConstant.INSUFFICIENT_BALANCE_EXCEPTION_STOP);
|
|
|
// orderStatusService.updateById(orderStatus);
|
|
|
- //这里为了保证余额不足的情况时:上报实时状态的最后电量费用不超过余额,上报的最后一帧为前一帧数据
|
|
|
- //Map<String, BigDecimal> map1 = realTimeMoney.start(power/1000, billingModel, orderStatus.getCreateTime(),orderStatus.getEndTime());
|
|
|
- redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2, start, 5 * 60 * 1000, TimeUnit.MILLISECONDS);
|
|
|
- elec = start.get("elec");
|
|
|
- money = start.get("money");
|
|
|
- }
|
|
|
- int mi = (int) (System.currentTimeMillis() - orderStatus.getCreateTime()) / 1000 / 60;
|
|
|
- log.info("↑↑↑↑↑↑↑↑↑↑↑↑↑充电中实时状态上报-2↑↑↑↑↑↑↑↑↑↑↑↑↑mi " + mi);
|
|
|
- realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, orderStatus.getTransOrder(), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), voltage, power, elec, money, mi);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ //这里为了保证余额不足的情况时:上报实时状态的最后电量费用不超过余额,上报的最后一帧为前一帧数据
|
|
|
+ //Map<String, BigDecimal> map1 = realTimeMoney.start(power/1000, billingModel, orderStatus.getCreateTime(),orderStatus.getEndTime());
|
|
|
+ redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 2, start, 5 * 60 * 1000, TimeUnit.MILLISECONDS);
|
|
|
+ elec = start.get("elec");
|
|
|
+ money = start.get("money");
|
|
|
+ }
|
|
|
+ int mi = (int) (System.currentTimeMillis() - orderStatus.getCreateTime()) / 1000 / 60;
|
|
|
+ log.info("↑↑↑↑↑↑↑↑↑↑↑↑↑充电中实时状态上报-2↑↑↑↑↑↑↑↑↑↑↑↑↑mi " + mi);
|
|
|
+ realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, orderStatus.getTransOrder(), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), voltage, power, elec, money, mi);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("charging status push exception==="+e.toString());
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
});
|
|
|
/*
|
|
|
@@ -423,69 +433,75 @@ public class TaskRunner {
|
|
|
Set<String> devicePileCodes = map.keySet();
|
|
|
log.info("free.deviceConnectionSize>>"+devicePileCodes.size());
|
|
|
devicePileCodes.stream().forEach(devicePileCode -> {
|
|
|
- if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_ONE)) {
|
|
|
- DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, devicePileCode);
|
|
|
- if (deviceStatus != null) {
|
|
|
- if (deviceStatus.getGunStatus() == StatusConstant.CHARGING) {
|
|
|
- log.info("freeMsg>>>deviceguns status>>"+deviceStatus.getGunStatus());
|
|
|
- }
|
|
|
- //存在设备在线状态的上送空闲状态
|
|
|
- DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
- if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
|
|
|
- //
|
|
|
- QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
- deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
- Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
- Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
- if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
- log.info("heartTaskAsyncPool-1>not longin and heart normal>>" + devicePileCode);
|
|
|
- // loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ try{
|
|
|
+ if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_ONE)) {
|
|
|
+ DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, devicePileCode);
|
|
|
+ if (deviceStatus != null) {
|
|
|
+ if (deviceStatus.getGunStatus() == StatusConstant.CHARGING) {
|
|
|
+ log.info("freeMsg>>>deviceguns status>>"+deviceStatus.getGunStatus());
|
|
|
}
|
|
|
- return;
|
|
|
- }
|
|
|
- if (deviceStatus.getGunStatus() != StatusConstant.CHARGING) {
|
|
|
- if (deviceConnectionMsg.getLoginStatus() == 1) {
|
|
|
- log.info("↑↑↑↑↑↑↑↑↑↑↑↑↑空闲实时状态上报1111↑↑↑↑↑↑↑↑↑↑↑↑↑ " + deviceStatus.getGunStatus() + "<>" + (deviceStatus.getGunStatus() == PortStatusConstant.EMERGENCY_STOP));
|
|
|
- if (deviceStatus.getGunStatus() == PortStatusConstant.EMERGENCY_STOP) {
|
|
|
- //急停中也是空闲状态上报
|
|
|
- deviceStatus.setGunStatus(StatusConstant.FREE);
|
|
|
+ //存在设备在线状态的上送空闲状态
|
|
|
+ DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
+ if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
|
|
|
+ //
|
|
|
+ QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
+ deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
+ Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
+ Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
+ if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
+ log.info("heartTaskAsyncPool-1>not longin and heart normal>>" + devicePileCode);
|
|
|
+ // loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (deviceStatus.getGunStatus() != StatusConstant.CHARGING) {
|
|
|
+ if (deviceConnectionMsg.getLoginStatus() == 1) {
|
|
|
+ log.info("↑↑↑↑↑↑↑↑↑↑↑↑↑空闲实时状态上报1111↑↑↑↑↑↑↑↑↑↑↑↑↑ " + deviceStatus.getGunStatus() + "<>" + (deviceStatus.getGunStatus() == PortStatusConstant.EMERGENCY_STOP));
|
|
|
+ if (deviceStatus.getGunStatus() == PortStatusConstant.EMERGENCY_STOP) {
|
|
|
+ //急停中也是空闲状态上报
|
|
|
+ deviceStatus.setGunStatus(StatusConstant.FREE);
|
|
|
+ }
|
|
|
+ realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, FrameDataSplicing.
|
|
|
+ transactionNum(deviceStatus.getPileCode(), deviceConnectionMsg.getMessageCount()), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), 0, 0, zero, zero, 0);
|
|
|
}
|
|
|
- realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, FrameDataSplicing.
|
|
|
- transactionNum(deviceStatus.getPileCode(), deviceConnectionMsg.getMessageCount()), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), 0, 0, zero, zero, 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_TWO)) {
|
|
|
- DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, devicePileCode);
|
|
|
- if (deviceStatus != null) {
|
|
|
- //存在设备在线状态的上送空闲状态
|
|
|
- DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
- if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
|
|
|
- //
|
|
|
- QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
- deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
- Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
- Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
- if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
- log.info("heartTaskAsyncPool-1>not longin and heart normal>>" + devicePileCode);
|
|
|
- loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_TWO)) {
|
|
|
+ DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, devicePileCode);
|
|
|
+ if (deviceStatus != null) {
|
|
|
+ //存在设备在线状态的上送空闲状态
|
|
|
+ DeviceConnectionMsg deviceConnectionMsg = map.get(devicePileCode);
|
|
|
+ if (deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
|
|
|
+ //
|
|
|
+ QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
+ deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
+ Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
+ Long heartTime = deviceConnectionMsg.getHeartTime();
|
|
|
+ if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
+ log.info("heartTaskAsyncPool-1>not longin and heart normal>>" + devicePileCode);
|
|
|
+ loginFrame.loginMsgSend(deviceConnectionMsg,device);
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
- return;
|
|
|
- }
|
|
|
- if (deviceStatus.getGunStatus() != StatusConstant.CHARGING) {
|
|
|
- if (deviceConnectionMsg.getLoginStatus() == 1) {
|
|
|
- if (deviceStatus.getGunStatus() == PortStatusConstant.EMERGENCY_STOP) {
|
|
|
- //急停中也是空闲状态上报
|
|
|
- deviceStatus.setGunStatus(StatusConstant.FREE);
|
|
|
+ if (deviceStatus.getGunStatus() != StatusConstant.CHARGING) {
|
|
|
+ if (deviceConnectionMsg.getLoginStatus() == 1) {
|
|
|
+ if (deviceStatus.getGunStatus() == PortStatusConstant.EMERGENCY_STOP) {
|
|
|
+ //急停中也是空闲状态上报
|
|
|
+ deviceStatus.setGunStatus(StatusConstant.FREE);
|
|
|
+ }
|
|
|
+ log.info("↑↑↑↑↑↑↑↑↑↑↑↑↑空闲实时状态上报2222↑↑↑↑↑↑↑↑↑↑↑↑↑ ");
|
|
|
+ realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, FrameDataSplicing.
|
|
|
+ transactionNum(deviceStatus.getPileCode(), deviceConnectionMsg.getMessageCount()), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), 0, 0, zero, zero, 0);
|
|
|
}
|
|
|
- log.info("↑↑↑↑↑↑↑↑↑↑↑↑↑空闲实时状态上报2222↑↑↑↑↑↑↑↑↑↑↑↑↑ ");
|
|
|
- realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, FrameDataSplicing.
|
|
|
- transactionNum(deviceStatus.getPileCode(), deviceConnectionMsg.getMessageCount()), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), 0, 0, zero, zero, 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("======Free msg exception ===="+e.toString());
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
});
|
|
|
|
|
|
log.info("======Free status push task ending=====");
|