Bladeren bron

[功能修复]优化103

liuf 1 jaar geleden
bovenliggende
commit
3f30b05b09

+ 1 - 0
src/main/java/com/tmzn/devicelinkykc/entity/OrderStatus.java

@@ -52,6 +52,7 @@ public class OrderStatus implements Serializable {
     private byte[] originalText;
     private long createTime;
     private long endTime;
+    private int retryTime;
 
 
 }

+ 2 - 0
src/main/java/com/tmzn/devicelinkykc/frameMsg/frameType/TransactionFlowPushFrame.java

@@ -95,6 +95,7 @@ public class TransactionFlowPushFrame {
             }
             byte[] bytes = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getFrameType(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getEncryptFlag(), encrypt, encrypt.length, deviceConnectionMsg.getIs18());
             try {
+                log.info("pileCode:" + pileCode + " 发送订单{}",DataConversion.bytesToHexString(bytes));
                 deviceConnectionMsg.getOutputStream().write(bytes);
                 deviceConnectionMsg.getOutputStream().flush();
                 deviceConnectionMsg.incrementMessageCount();
@@ -128,6 +129,7 @@ public class TransactionFlowPushFrame {
         }
         byte[] bytes = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(),frameType , 0, encrypt, encrypt.length, deviceConnectionMsg.getIs18());
         try {
+            log.info("pileCode:" + pileCode + " 发送订单{}",DataConversion.bytesToHexString(bytes));
             deviceConnectionMsg.getOutputStream().write(bytes);
             deviceConnectionMsg.getOutputStream().flush();
             deviceConnectionMsg.incrementMessageCount();

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

@@ -225,7 +225,7 @@ public class DeviceMsgHandle {
     }
 
 
-    private void checkConnection(String pileCode, String imei) throws IOException {
+    public boolean checkConnection(String pileCode, String imei) throws IOException {
         boolean needLogin = false;
         if (!socketHandle.existDeviceConnection(pileCode)) {
             needLogin = true;
@@ -238,7 +238,7 @@ public class DeviceMsgHandle {
         }
 
         if (!needLogin) {
-            return;
+            return true;
         }
         logger.info("桩上线{}", imei);
         QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
@@ -246,10 +246,11 @@ public class DeviceMsgHandle {
         Device device = deviceService.getOne(deviceQueryWrapper);
         if (device == null) {
             logger.info("{}已禁用{}", imei, pileCode);
-            return;
+            return false;
         }
         socketHandle.addDeviceConnection(device.getIp(), device.getPort(), device.getPileCode(), device.getDeviceImei(), device.getDeviceSn(), device.getCommProtocolVer());
         loginFrame.loginMsgSend(socketHandle.getDeviceConnection(device.getPileCode()), device);
+        return false;
 
     }
 
@@ -469,7 +470,6 @@ public class DeviceMsgHandle {
         JSONObject data = jsonObject.getJSONObject("real_data");
         Integer port_first_status = data.getInteger("port_first_status");
         Integer port_second_status = data.getInteger("port_second_status");
-        Integer power = data.getInteger("power");
         //功率为0时,还是充电中状态,将状态转换成空闲,结束充电
 //              20240608现场使用时出现充电状态第一次103上来就是power是0情况
 //                if (port_first_status != null&&power==0&&port_first_status==PortStatusConstant.CHARGING){
@@ -487,6 +487,7 @@ public class DeviceMsgHandle {
             checkPort(port_first_status, 1, imei, type);
 
             if (port_first_status == PortStatusConstant.CHARGING) {
+                Integer power = data.getInteger("power");
                 checkNoPowerAutoStop(power, imei, 1);
             }
         }
@@ -494,6 +495,7 @@ public class DeviceMsgHandle {
             checkPort(port_second_status, 2, imei, type);
 
             if (port_second_status == PortStatusConstant.CHARGING) {
+                Integer power = data.getInteger("power_1");
                 checkNoPowerAutoStop(power, imei, 2);
             }
         }

+ 1 - 1
src/main/java/com/tmzn/devicelinkykc/taskQueue/DeviceStatusPushTask.java

@@ -39,7 +39,7 @@ public class DeviceStatusPushTask {
                 msgCharngingQueue.add(deviceConnectionMsgMap);
             }
         };
-        scheduler.scheduleAtFixedRate(task,0,12*1000, TimeUnit.MILLISECONDS);
+        scheduler.scheduleAtFixedRate(task,0,15*1000, TimeUnit.MILLISECONDS);
     }
 
     /**

+ 2 - 1
src/main/java/com/tmzn/devicelinkykc/taskQueue/TranscationTask.java

@@ -32,7 +32,8 @@ public class TranscationTask {
                 msgTranscationQueue.add(deviceConnectionMsgMap);
             }
         };
-        scheduler.scheduleAtFixedRate(task,10,30*1000, TimeUnit.MILLISECONDS);
+        //每50分钟检测要执行的订单
+        scheduler.scheduleAtFixedRate(task,10,50*1000, TimeUnit.MILLISECONDS);
 
     }
 }

+ 102 - 323
src/main/java/com/tmzn/devicelinkykc/taskQueue/runner/MsgCharngingRunner.java

@@ -16,6 +16,7 @@ import com.tmzn.devicelinkykc.frameMsg.frameType.HeartFrameSend;
 import com.tmzn.devicelinkykc.frameMsg.frameType.LoginFrame;
 import com.tmzn.devicelinkykc.frameMsg.frameType.RealTimeStatusPushFrame;
 import com.tmzn.devicelinkykc.frameMsg.frameType.TransactionFlowPushFrame;
+import com.tmzn.devicelinkykc.message.DeviceMsgHandle;
 import com.tmzn.devicelinkykc.redis.RedisCache;
 import com.tmzn.devicelinkykc.service.*;
 import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
@@ -65,6 +66,10 @@ public class MsgCharngingRunner {
     private SocketHandle socketHandle;
 
 
+    @Autowired
+    DeviceMsgHandle deviceMsgHandle;
+
+
     @Autowired
     private DeviceControlerService deviceControlerService;
     @Autowired
@@ -75,27 +80,20 @@ public class MsgCharngingRunner {
 
     @Async("charngingTaskAsyncPool")
     public void chargingMsg(Map<String, DeviceConnectionMsg> map) {
-        log.info("======Charging status push task starting=====");
+        log.info("======充电中数据上报检测=====");
         //这边需要给充电中的状态进行查询流水号,流水号是由云快充启动充电时的下发指令带来存库的,
         if (map.size() < 1) {
             return;
         }
-        Set<String> devicePileCodes = map.keySet();
-        QueryWrapper<BillingModel> billWapper = new QueryWrapper<>();
-        billWapper.in("pile_code", devicePileCodes);
-        List<BillingModel> billingModels = billingModelService.list(billWapper);
-
-        if (billingModels.size() < 1) {
-            log.info("无计费可上报模型");
-            return;
-        }
 
+        //查找所有充电中的订单
         QueryWrapper<OrderStatus> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("now_order_status", 0); //充电中状态上报
 
+        //忽略10天前的订单
         long nowTime = System.currentTimeMillis();
-        long tm = nowTime-86400*10;
-
+        long tm = nowTime-86400*10*1000;
+        //10天前的就算了
         queryWrapper.gt("create_time",tm ); //充电中状态上报
         queryWrapper.orderByDesc("id");
 
@@ -106,28 +104,29 @@ public class MsgCharngingRunner {
             return;
         }
 
+        Set<String> devicePileCodes = map.keySet();
+        QueryWrapper<BillingModel> billWapper = new QueryWrapper<>();
+        billWapper.in("pile_code", devicePileCodes);
+        List<BillingModel> billingModels = billingModelService.list(billWapper);
+        if (billingModels.size() < 1) {
+            log.info("无计费可上报模型");
+            return;
+        }
+
         Map<String, BillingModel> billingModelMap = billingModels.stream()
                 .collect(Collectors.toMap(BillingModel::getPileCode, billingModel -> billingModel));
 
-
         //只上传最近的订单
         Map<String, Boolean> dealMap = new HashMap<>();
         list.forEach(item -> {
             try {
-                BillingModel b = billingModelMap.get(item.getPileCode());
-                DeviceConnectionMsg deviceConnectionMsg = map.get(item.getPileCode());
-
-                int mi = (int) (System.currentTimeMillis() - item.getCreateTime());
-                if(mi>86400*10){
-                    log.info("{}10天前的订单忽略吧", item.getPileCode());
+                if(!deviceMsgHandle.checkConnection(item.getPileCode(),item.getDeviceImei())){
+                    log.info("{}重新连接句柄不存在等待下次执行",item.getPileCode());
                     return;
                 }
 
-
-                if (deviceConnectionMsg == null) {
-                    log.info("{}上报充电中未连接", item.getPileCode());
-                    return;
-                }
+                DeviceConnectionMsg deviceConnectionMsg = map.get(item.getPileCode());
+                BillingModel b = billingModelMap.get(item.getPileCode());
                 if (b == null) {
                     log.info("{}上报充电中未匹配计费模型", item.getPileCode());
                     return;
@@ -135,7 +134,7 @@ public class MsgCharngingRunner {
 
                 String k = item.getPileCode() + "_" + item.getGunsCode();
                 if (dealMap.containsKey(k)) {
-                    log.info("{}本轮已上报充电中", k);
+                    log.info("{}本轮已上报充电中只报最后一个订单", k);
                 } else {
                     reportOne(item, b, deviceConnectionMsg);
                     dealMap.put(k, true);
@@ -149,65 +148,105 @@ public class MsgCharngingRunner {
         log.info("======Charging status push task ending=====");
     }
 
+    public void try103(OrderStatus orderStatus){
+
+        String key = "try103:_"+orderStatus.getDeviceImei();
+        if(redisCache.hasKey(key)){
+            log.info("{}-{}忽略下发103", orderStatus.getPileCode(), orderStatus.getGunsCode());
+            return;
+        }
+
+        log.info("{}-{}2分钟内无状态下发一次103", orderStatus.getPileCode(), orderStatus.getGunsCode());
+        deviceControlerService.sendImeiDetail(orderStatus.getDeviceImei());
+        redisCache.setCacheObject(key, System.currentTimeMillis(),120, TimeUnit.SECONDS);
+        return;
+    }
+
+    public void stopOne(OrderStatus orderStatus){
+        int port = (int) orderStatus.getGunsCode();
+        orderStatus.setNowOrderStatus(StatusConstant.NOW_ORDER_STATUS_CHARGING_ENDING);
+        orderStatus.setEndTime(System.currentTimeMillis());
+        orderStatusService.save(orderStatus);
+        //发送停止充电指令
+        orderStatus.setEndTime(System.currentTimeMillis() - 1000 * 60 * 5);
+        orderStatus.setReasonStopCharging(TransConstant.INSUFFICIENT_BALANCE_EXCEPTION_STOP);
+        orderStatus.setNowOrderStatus(StatusConstant.NOW_ORDER_STATUS_CHARGING_ENDING);
+        orderStatusService.updateById(orderStatus);
+        deviceControlerService.stopCharge(orderStatus.getDeviceImei(), orderStatus.getDeviceImei(), port);
+        log.info("{}--id:{}已停止充电",orderStatus.getPileCode(),orderStatus.getId());
+    }
+
     public void reportOne(OrderStatus orderStatus, BillingModel billingModel, DeviceConnectionMsg deviceConnectionMsg) {
         //获取订单状态
         String cacheKey = orderStatus.getGunsCode() == 1 ? RedisConstant.ONLINE_DEVICE_ONE : RedisConstant.ONLINE_DEVICE_TWO;
         DeviceStatus deviceStatus = redisCache.getCacheMapValue(cacheKey, orderStatus.getPileCode());
-        if (deviceStatus == null) {
-            log.info("{}-{}无状态记录", orderStatus.getPileCode(), orderStatus.getGunsCode());
-            return;
-        }
-        if (deviceStatus.getGunStatus() != StatusConstant.CHARGING) {
-            log.info("{}-{}已不在充电状态" + deviceStatus.getGunStatus(), orderStatus.getPileCode(), orderStatus.getGunsCode());
-            //todo 是否要结束?
-            return;
-        }
-        //存在设备上送充电状态
-        if (deviceConnectionMsg.getLoginStatus() == Constant.DEVICE_NOT_LOGIN_STATUS) {
-            QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
-            Long heartTime = deviceConnectionMsg.getHeartTime();
-            if (deviceStatus.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
-                deviceQueryWrapper.eq("pile_code", orderStatus.getPileCode()).eq("disabled", DeviceOnlineStatus.NORMAL);
-                Device device = deviceService.getOne(deviceQueryWrapper);
-                log.info("charngingTaskAsyncPool-1>not longin and heart normal>>" + orderStatus.getPileCode());
-                loginFrame.loginMsgSend(deviceConnectionMsg, device);
+
+        long t = System.currentTimeMillis()-orderStatus.getCreateTime();
+
+        int port = (int) orderStatus.getGunsCode();
+
+        if(deviceStatus==null){
+            if(t<15*60*1000){
+                try103(orderStatus);
+                return;
+            }else{
+                log.info("{}-{}无15分钟还没有记录要停止充电", orderStatus.getPileCode(), orderStatus.getGunsCode());
+                //状态那我为
+                stopOne(orderStatus);
             }
-            log.info("charngingTaskAsyncPool-1>not longin>>" + orderStatus.getPileCode());
             return;
         }
 
-        if (deviceConnectionMsg.getLoginStatus() != 1) {
-            return;
+
+        if(deviceStatus.getGunStatus() != StatusConstant.CHARGING){
+            if(t<5*60*1000){
+                log.info("{}-{}5分钟内还未变充电状态忽略", orderStatus.getPileCode(), orderStatus.getGunsCode());
+                return;
+            }else{
+                log.info("{}-{}5分钟后还不是充电状态录要停止充电", orderStatus.getPileCode(), orderStatus.getGunsCode());
+                //状态那我为
+                stopOne(orderStatus);
+                return;
+            }
         }
 
+        //上送充电状态
         JSONObject statusJSON = redisCache.getCacheObject(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei());
         if(statusJSON==null){
+            log.info("无最近103数据{}",orderStatus.getPileCode());
+            try103(orderStatus);
             return;
         }
 
-        Integer voltage = statusJSON.getInteger("voltage");
-        Integer power = statusJSON.getInteger("power");
+        Integer voltage;
+        Integer power;
+
+        if(port==1){
+             voltage = statusJSON.getInteger("voltage");
+             power = statusJSON.getInteger("power");
+        }else{
+            voltage = statusJSON.getInteger("voltage_1");
+            power = statusJSON.getInteger("power_1");
+        }
 
         //计算实时数据
         long endTime = System.currentTimeMillis();
         //算电量
-        Map<String, BigDecimal> start = null;
-        try {
-            start = transMoney.getTransData();
-        } 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 {
+        Map<String, BigDecimal> start = transMoney.getTransData();
+
+        String transCacheKey = "ChargingTrans:"+orderStatus.getId();
+        if(redisCache.hasKey(transCacheKey)){
+            start = redisCache.getCacheObject(cacheKey);
+        }else{
+            //缓存120秒避免重复计算电量
             try {
-                start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime);
+                start = transMoney.compute(port, billingModel, orderStatus.getCreateTime(), endTime);
             } catch (Exception e) {
                 e.printStackTrace();
+                log.error("计算订单异常{},{}",orderStatus.getPileCode(),e.getMessage());
+                return;
             }
-            redisCache.setCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1, start, 60, TimeUnit.SECONDS);
+            redisCache.setCacheObject(cacheKey, start, 120, TimeUnit.SECONDS);
         }
 
         BigDecimal elec = start.get("elec");
@@ -229,273 +268,13 @@ public class MsgCharngingRunner {
             orderStatus.setReasonStopCharging(TransConstant.INSUFFICIENT_BALANCE_EXCEPTION_STOP);
             orderStatus.setNowOrderStatus(StatusConstant.NOW_ORDER_STATUS_CHARGING_ENDING);
             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");
+            return;
         }
         int mi = (int) (System.currentTimeMillis() - orderStatus.getCreateTime()) / 1000 / 60;
-
-        log.info("↑↑↑{},{},{}充电中实时状态上报 ",orderStatus.getPileCode(),orderStatus.getGunsCode(),orderStatus.getId());
         realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, orderStatus.getTransOrder(), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), voltage, power, elec, money, mi);
-
+        log.info("↑↑↑{},{},{}充电中实时状态上报 ",orderStatus.getPileCode(),orderStatus.getGunsCode(),orderStatus.getId());
 
     }
 
-    //////        System.out.println(list);
-    ////        Map<String, OrderStatus> orderStatusMap = list.stream()
-    ////                .collect(Collectors.toMap(OrderStatus::getPileCode, orderStatus -> orderStatus,
-    ////                        (existing, replacement) -> (Instant.ofEpochMilli(existing.getCreateTime()).atZone(ZoneId.systemDefault()).toLocalDateTime()).isAfter(Instant.ofEpochMilli(replacement.getCreateTime()).atZone(ZoneId.systemDefault()).toLocalDateTime()) ? existing : replacement));
-    ////        List<OrderStatus> orderStatuses = orderStatusMap.values().stream()
-    ////                .collect(Collectors.toList());
-    ////
-    ////
-    ////        //redis取出在线设备集合
-    ////        devicePileCodes.stream().forEach(devicePileCode -> {
-    ////            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;
-    ////                        }
-    ////                        //存在设备上送充电状态
-    ////                        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, 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 {
-    ////                                                        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);
-    ////                            }
-    ////                            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 {
-    ////                                                        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());
-    //////                                                    deviceControlerService.sendPortDetailCmd(deviceParam);
-    //////                                                    deviceControlerService.stopCharge(orderStatus.getDeviceImei(), orderStatus.getDeviceImei(), 2);
-    //////
-    //////                                                    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);
-    ////                                                });
-    ////                                            }
-    ////                                        });
-    ////                                    }
-    ////                                }
-    ////                            }
-    ////                        }
-    ////                    }
-    ////                }
-    ////            } catch (Exception e) {
-    ////                log.info("charging status push exception===" + e.toString());
-    ////                e.printStackTrace();
-    ////            }
-    ////        });
-    ///*
-    //
-    //        if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_ONE)) {
-    //            List<DeviceStatus> listOne = redisCache.getCacheObject(RedisConstant.ONLINE_DEVICE_ONE);
-    //            listOne.stream().forEach(deviceStatus -> {
-    //                //根据状态上报,15s的只报充电状态
-    //                DeviceConnectionMsg deviceConnectionMsg = map.get(deviceStatus.getPileCode());
-    //                if (deviceStatus.getGunStatus() == StatusConstant.CHARGING) {
-    //                    if (redisCache.hasKey(RedisConstant.DEVICE_PORT_STATUS+deviceStatus.getDeviceImei())){
-    //                        //++++ 20240319-15 这里费用计算需要用到计费模型
-    //                        JSONObject statusJSON = redisCache.getCacheObject(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei());
-    //                        Integer voltage = statusJSON.getInteger("voltage");
-    //                        Integer power = statusJSON.getInteger("power");
-    //
-    //                        //++++
-    //                        realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, FrameDataSplicing.transactionNum(deviceStatus.getPileCode(), deviceConnectionMsg.getMessageCount()), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), 0, 0, 0, 0, 0);
-    //                    }
-    //                }
-    //            });
-    //        }
-    //        if (redisCache.hasKey(RedisConstant.ONLINE_DEVICE_TWO)) {
-    //            List<DeviceStatus> listTwo = redisCache.getCacheObject(RedisConstant.ONLINE_DEVICE_TWO);
-    //            listTwo.stream().forEach(deviceStatus -> {
-    //                //根据状态上报,15s的只报充电状态
-    //                DeviceConnectionMsg deviceConnectionMsg = map.get(deviceStatus.getPileCode());
-    //                if (deviceStatus.getGunStatus() == StatusConstant.CHARGING) {
-    //                    //realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, FrameDataSplicing.transactionNum(deviceStatus.getPileCode(), deviceConnectionMsg.getMessageCount()), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), 0, 0, 0, 0, 0);
-    //                }
-    //            });
-    //        }*/
-
-
 }

+ 101 - 122
src/main/java/com/tmzn/devicelinkykc/taskQueue/runner/MsgTranscationRunner.java

@@ -1,24 +1,37 @@
 package com.tmzn.devicelinkykc.taskQueue.runner;
 
+import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.tmzn.devicelinkykc.constant.Constant;
 import com.tmzn.devicelinkykc.constant.DeviceOnlineStatus;
 import com.tmzn.devicelinkykc.constant.RedisConstant;
+import com.tmzn.devicelinkykc.constant.ykc.StatusConstant;
+import com.tmzn.devicelinkykc.entity.BillingModel;
 import com.tmzn.devicelinkykc.entity.Device;
 import com.tmzn.devicelinkykc.entity.DeviceStatus;
 import com.tmzn.devicelinkykc.entity.OrderStatus;
+import com.tmzn.devicelinkykc.frameMsg.DataConversion;
+import com.tmzn.devicelinkykc.frameMsg.TransMoney;
+import com.tmzn.devicelinkykc.frameMsg.frameType.CharngingPushFrame;
 import com.tmzn.devicelinkykc.frameMsg.frameType.HeartFrameSend;
 import com.tmzn.devicelinkykc.frameMsg.frameType.LoginFrame;
+import com.tmzn.devicelinkykc.frameMsg.frameType.TransactionFlowPushFrame;
+import com.tmzn.devicelinkykc.message.DeviceMsgHandle;
 import com.tmzn.devicelinkykc.redis.RedisCache;
+import com.tmzn.devicelinkykc.service.BillingModelService;
 import com.tmzn.devicelinkykc.service.DeviceService;
 import com.tmzn.devicelinkykc.service.OrderStatusService;
 import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
 import com.tmzn.devicelinkykc.socket.SocketHandle;
 import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
+import java.io.IOException;
+import java.math.BigDecimal;
 import java.time.Instant;
 import java.time.ZoneId;
 import java.util.List;
@@ -40,144 +53,110 @@ public class MsgTranscationRunner {
     @Autowired
     private SocketHandle socketHandle;
 
-    public void handleOne(OrderStatus item){
+    @Autowired
+    DeviceMsgHandle deviceMsgHandle;
 
-        if ((System.currentTimeMillis() - item.getEndTime()) > 5 * 60 * 1000 && item.getTransactionOrderReplyStatus() != 5) {
-            //五分钟上送最后一次结束,上送
-            if(socketHandle.existDeviceConnection(item.getPileCode())){
-                log.info("{}重新上报句柄不存在",item.getPileCode());
-                return;
-            }
-            DeviceConnectionMsg deviceConnectionMsg = socketHandle.getDeviceConnection(item.getPileCode());
-            try {
-                //String bytes = redisCache.getCacheObject(orderStatus.getPileCode());
-                //byte[] bytes1 = Encrytion.aesEncrypt(orderStatus.getOriginalText(), bytes.getBytes());
-                //byte[] spliceing = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getFrameType(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getEncryptFlag(), bytes1, bytes1.length);
-                deviceConnectionMsg.getOutputStream().write(item.getOriginalText());
-                deviceConnectionMsg.getOutputStream().flush();
-                deviceConnectionMsg.incrementMessageCount();
-            } catch (Exception e) {
-                e.printStackTrace();
+    @Autowired
+    TransMoney transMoney;
+
+    @Autowired
+    BillingModelService billingModelService;
+
+    @Autowired
+    TransactionFlowPushFrame transactionFlowPushFrame;
+
+    @Autowired
+    CharngingPushFrame charngingPushFrame;
+
+    @Autowired
+     RedisCache redisCache;
+
+    private static final Logger logger = LoggerFactory.getLogger(DeviceMsgHandle.class);
+
+    public void rebillOne(OrderStatus statusServiceOne) throws IOException {
+
+        if(!deviceMsgHandle.checkConnection(statusServiceOne.getPileCode(),statusServiceOne.getDeviceImei())){
+            log.info("{}重新上报句柄不存在等待下次执行",statusServiceOne.getPileCode());
+            return;
+        }
+        DeviceConnectionMsg deviceConnection = socketHandle.getDeviceConnection(statusServiceOne.getPileCode());
+        String imei = statusServiceOne.getDeviceImei();
+
+        int port = statusServiceOne.getGunsCode();
+
+        //获取缓存的最终结果
+        QueryWrapper<BillingModel> billingModelQueryWrapper = new QueryWrapper<>();
+        billingModelQueryWrapper.eq("device_imei", statusServiceOne.getDeviceImei());
+        BillingModel model = billingModelService.getOne(billingModelQueryWrapper);
+
+        statusServiceOne.setRetryTime(statusServiceOne.getRetryTime()+1);
+
+        Map<String, BigDecimal> map ;
+        //最终计算结果
+        String cacheKey = "compute_finish:"+statusServiceOne.getId();
+        if(redisCache.hasKey(cacheKey)){
+            map = redisCache.getCacheObject(cacheKey);
+            log.info("{}从缓存获取map{}",statusServiceOne.getDeviceImei(), JSON.toJSONString(map));
+        }else{
+            try{
+                map = transMoney.compute(port, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime());
+                //10分钟内只查询一次
+                log.info("{}重新获取map{}",statusServiceOne.getDeviceImei(), JSON.toJSONString(map));
+                redisCache.setCacheObject(cacheKey,map);
+                redisCache.expire(cacheKey,600);
+            }catch (Exception e){
+                orderStatusService.updateById(statusServiceOne);
+                log.info("计算金额异常{},{},重试第{}次",statusServiceOne.getDeviceImei(),e.getMessage(),statusServiceOne.getRetryTime());
+                return ;
             }
-            //将恢复结果状态转成5,记录为充电记录上传5分钟后失败
-            item.setTransactionOrderReplyStatus((byte) 5);
-            orderStatusService.updateById(item);
-            log.info("最新未收到上报的订单list5分钟推送最后一次>>" + item.toString());
         }
 
+        byte[] encrypt = new byte[0];
+        //查询计费模板
+        encrypt = transactionFlowPushFrame.sendTrans(deviceConnection, statusServiceOne.getTransOrder(), statusServiceOne.getPileCode(), statusServiceOne.getGunsCode(), statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), model, statusServiceOne.getCard(), map, statusServiceOne.getReasonStopCharging());
+
+        if (encrypt == null || encrypt.length <= 0) {
+            logger.info("订单上送重试{} 需要重新上报{}", statusServiceOne.getRetryTime(),statusServiceOne.getPileCode());
+            orderStatusService.updateById(statusServiceOne);
+            return;
+        } else {
+            logger.info("订单上送成功{}", statusServiceOne.getPileCode());
+            statusServiceOne.setTransactionOrderReportingActionStatus(StatusConstant.TRANSACTION_ORDER_REPORTING_ACTION_STATUS_OK);
+            statusServiceOne.setOriginalText(encrypt);
+        }
+        orderStatusService.updateById(statusServiceOne);
+
     }
 
+
+
+
+
     @Async("transactionTaskAsyncPool")
     public void transactionMsg(Map<String, DeviceConnectionMsg> map) throws Exception {
-        log.info("======transaction push task starting=====");
+        //处理已结束的订单 未上报的 离线上报
+        log.info("======离线订单记录补送=====");
         //任务处理 1.上报交易流水消息后没有响应回复的情况,30秒上送一次三次后停止,五分钟后上送最后一次,不管是否成功都不再上送:有结束时间,充电状态是结束充电的
+        long t = System.currentTimeMillis()-60 *1000;
         QueryWrapper<OrderStatus> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("now_order_status", 1).orderByDesc("id"); //充电完成
-//        queryWrapper.eq("transaction_order_reporting_action_status", 1); //已上送
+        queryWrapper.eq("now_order_status", StatusConstant.NOW_ORDER_STATUS_CHARGING_ENDING).orderByDesc("id"); //充电完成
+        //已经停止一分钟了 还没有上送成功的
+        queryWrapper.lt("end_time",t);
         queryWrapper.eq("transaction_order_reply_status", 0); //未回复的
-        queryWrapper.last("limit 1000");
-
+        queryWrapper.lt("retry_time",10);
+        queryWrapper.last("limit 500");
         List<OrderStatus> list = orderStatusService.list(queryWrapper);
 
         list.forEach(item->{
-            log.info("检测订单上报{}",item.getPileCode());
-            handleOne(item);
+            try{
+                log.info("检测订单上报{}--{}",item.getPileCode(),item.getId());
+                rebillOne(item);
+            }catch (Exception e){
+                log.info("离线上报失败{},{}",item.getPileCode(),e.getMessage());
+
+            }
         });
 
-//        System.out.println(list);
-
-//        Map<String, OrderStatus> orderStatusMap = list.stream()
-//                .collect(Collectors.toMap(
-//                        OrderStatus::getPileCode, orderStatus
-//                                -> orderStatus,(existing, replacement)
-//                                -> (Instant.ofEpochMilli(existing.getCreateTime())
-//                                .atZone(ZoneId.systemDefault()).toLocalDateTime())
-//                                .isAfter(Instant.ofEpochMilli(replacement.getCreateTime())
-//                                        .atZone(ZoneId.systemDefault()).toLocalDateTime())
-//                                ? existing : replacement));
-//        List<OrderStatus> orderStatuses = orderStatusMap.values().stream()
-//                .collect(Collectors.toList());
-
-        //过滤充电状态是结束的且已经上送未收到订单恢复的,说明交易订单上报没收到云快充消息,如果时间充电结束时间到现在大于30秒上送
-//        List<OrderStatus> collect = list.stream().filter(orderStatus -> orderStatus.getNowOrderStatus() == 1 && orderStatus.getTransactionOrderReplyStatus() == 0 && orderStatus.getTransactionOrderReportingActionStatus() == 1).collect(Collectors.toList());
-        //看订单时间进行重新上送
-//        if (collect.size() > 0) {
-//            collect.stream().forEach(orderStatus -> {
-//                //上送订单并且订单上送大于5分钟但是没有变成充电状态的订单,当成空上报一次
-//
-//               /* if ((((System.currentTimeMillis()-orderStatus.getEndTime())/1000) / 30 )==1||(((System.currentTimeMillis()-orderStatus.getEndTime()) /1000) / 60 )==1||(((System.currentTimeMillis()-orderStatus.getEndTime()) /1000) / 90)==1){
-//                    //各上送一次订单记录
-//                    DeviceConnectionMsg deviceConnectionMsg = map.get(orderStatus.getPileCode());
-//                    try {
-//                        String bytes = redisCache.getCacheObject(orderStatus.getPileCode());
-//                        byte[] bytes1 = Encrytion.aesEncrypt(orderStatus.getOriginalText(), bytes.getBytes());
-//                        deviceConnectionMsg.getOutputStream().write(bytes1);
-//                        deviceConnectionMsg.getOutputStream().flush();
-//                        deviceConnectionMsg.incrementMessageCount();
-//                    } catch (Exception e) {
-//                        e.printStackTrace();
-//                    }
-//                }else*/
-//                if ((System.currentTimeMillis() - orderStatus.getEndTime()) > 5 * 60 * 1000 && orderStatus.getTransactionOrderReplyStatus() != 5) {
-//                    //五分钟上送最后一次结束,上送
-//                    DeviceConnectionMsg deviceConnectionMsg = map.get(orderStatus.getPileCode());
-//                    if (deviceConnectionMsg!=null&&deviceConnectionMsg.getLoginStatus()== Constant.DEVICE_NOT_LOGIN_STATUS){
-//                        //wshizhengjuezhe zhewanyier meishajishuhanlian danshi zhedongxi  queshi xilan
-//                        return;
-//                    }
-//                    try {
-//                        //String bytes = redisCache.getCacheObject(orderStatus.getPileCode());
-//                        //byte[] bytes1 = Encrytion.aesEncrypt(orderStatus.getOriginalText(), bytes.getBytes());
-//
-//                        //byte[] spliceing = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getFrameType(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getEncryptFlag(), bytes1, bytes1.length);
-//
-//                        deviceConnectionMsg.getOutputStream().write(orderStatus.getOriginalText());
-//                        deviceConnectionMsg.getOutputStream().flush();
-//                        deviceConnectionMsg.incrementMessageCount();
-//                    } catch (Exception e) {
-//                        e.printStackTrace();
-//                    }
-//                    //将恢复结果状态转成5,记录为充电记录上传5分钟后失败
-//                    orderStatus.setTransactionOrderReplyStatus((byte) 5);
-//                    orderStatusService.updateById(orderStatus);
-//                    log.info("最新未收到上报的订单list5分钟推送最后一次>>" + orderStatuses.toString());
-//                }
-//            });
-//        }
-//        List<OrderStatus> collects = list.stream().filter(orderStatus -> orderStatus.getOriginalText()==null||orderStatus.getEndTime()==0).collect(Collectors.toList());
-//        if (collects.size()>0){
-//            collects.forEach(orderStatus -> {
-//            log.info(orderStatus.getPileCode()+":检查订单状态>orderStatus.getOriginalText()==null||orderStatus.getEndTime()==0>>"+orderStatus.getCreateTime());
-//            QueryWrapper<DeviceStatus> queryWrapper = new QueryWrapper<>();
-//            queryWrapper.eq("pile_code",orderStatus.getPileCode());
-//            DeviceStatus one = deviceStatusService.getOne(queryWrapper);
-//
-//            QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
-//            deviceQueryWrapper.eq("pile_code", orderStatus.getPileCode()).eq("disabled", DeviceOnlineStatus.NORMAL);
-//            Device device = deviceService.getOne(deviceQueryWrapper);
-//
-//            QueryWrapper<BillingModel> billingModelQueryWrapper = new QueryWrapper<>();
-//            billingModelQueryWrapper.eq("pile_code", orderStatus.getPileCode());
-//            BillingModel model = billingModelService.getOne(billingModelQueryWrapper);
-//
-//            if ((System.currentTimeMillis() - orderStatus.getCreateTime()) > 5 * 60 * 1000 && (one.getGunStatus()!=StatusConstant.CHARGING)) {
-//                log.info(orderStatus.getPileCode()+":上送订单并且订单上送大于5分钟但是没有变成充电状态的订单,当成空上报一次>"+orderStatus.getCreateTime());
-//                DeviceConnectionMsg deviceConnectionMsg = map.get(orderStatus.getPileCode());
-//                try {
-//                    Map<String, BigDecimal> compute = transMoney.compute(1, new BillingModel(), 0L, 0L, false);
-//                    byte[] e=transactionFlowPushFrame.sendTrans(deviceConnectionMsg, orderStatus.getTransOrder(), orderStatus.getPileCode(), (byte) 1, orderStatus.getCreateTime(), System.currentTimeMillis() + 3 * 60 * 1000, model, orderStatus.getCard(), compute, TransConstant.OTHER_STOP);
-//                    orderStatus.setOriginalText(e);
-//                    orderStatus.setEndTime(1);
-//                    orderStatus.setNowOrderStatus(StatusConstant.NOW_ORDER_STATUS_CHARGING_ENDING);
-//                    orderStatus.setReasonStopCharging(TransConstant.OTHER_STOP);
-//                    orderStatusService.updateById(orderStatus);
-//
-//                } catch (Exception e) {
-//                    e.printStackTrace();
-//                }
-//            }
-//            });
-//        }
 
         log.info("======transaction push task ending=====");
     }