Browse Source

[功能修复]ykc

liuf 1 year ago
parent
commit
d26a9d9b97

+ 11 - 11
src/main/java/com/tmzn/devicelinkykc/DeviceLinkYkcApplication.java

@@ -25,18 +25,18 @@ public class DeviceLinkYkcApplication {
             RedisCache redisCache = context.getBean(RedisCache.class);
             //Set<String> cacheObject = redisCache.getCacheObject(RedisConstant.DEVICE_INFO);
 
-            Set<String> set = (Set<String>) redisCache.keys(RedisConstant.KEYS + "*");
+           // Set<String> set = (Set<String>) redisCache.keys(RedisConstant.KEYS + "*");
            // set.stream().forEach(a -> System.out.println(a));
-            if (set.size()>0){
-                set.stream().forEach(key->{
-                   // System.out.println("keys,delete>>>"+key);
-                    redisCache.deleteObject(key);
-                });
-            }
-            redisCache.deleteObject(RedisConstant.YKC_KEY_MAP);
-            if (redisCache.hasKey(RedisConstant.DEVICE_INFO)){
-                redisCache.deleteObject(RedisConstant.DEVICE_INFO);
-            }
+//            if (set.size()>0){
+//                set.stream().forEach(key->{
+//                   // System.out.println("keys,delete>>>"+key);
+//                    redisCache.deleteObject(key);
+//                });
+//            }
+//            redisCache.deleteObject(RedisConstant.YKC_KEY_MAP);
+//            if (redisCache.hasKey(RedisConstant.DEVICE_INFO)){
+//                redisCache.deleteObject(RedisConstant.DEVICE_INFO);
+//            }
             // 例如,可以在这里关闭数据库连接,清理资源等
         }));
     }

+ 20 - 13
src/main/java/com/tmzn/devicelinkykc/frameMsg/TransMoney.java

@@ -40,30 +40,35 @@ public class TransMoney {
     @Autowired
     private BillingModelMapping billingModelMapping;
 
-    /**
-     * 调用后台计费
-     * @param port
-     * @param billingModel
-     * @param startTime
-     * @param endTime
-     * @param retMap
-     * @return
-     */
-    public Map<String,BigDecimal> compute(int port,BillingModel billingModel,Long startTime,Long endTime,boolean retMap) throws Exception{
+    public Map<String,BigDecimal> getTransData(){
         BigDecimal bigDecimal = new BigDecimal("0.0000");
         transData.put("elec",bigDecimal);
         transData.put("elec1",bigDecimal);
         transData.put("elec2",bigDecimal);
         transData.put("elec3",bigDecimal);
         transData.put("elec4",bigDecimal);
+        transData.put("elec5",bigDecimal);
         transData.put("money",bigDecimal);
         transData.put("money1",bigDecimal);
         transData.put("money2",bigDecimal);
         transData.put("money3",bigDecimal);
         transData.put("money4",bigDecimal);
-        if (!retMap){
-            return transData;
-        }
+        transData.put("money5",bigDecimal);
+        return transData;
+    }
+
+    /**
+     * 调用后台计费
+     * @param port
+     * @param billingModel
+     * @param startTime
+     * @param endTime
+     * @param retMap
+     * @return
+     */
+    public Map<String,BigDecimal> compute(int port,BillingModel billingModel,Long startTime,Long endTime) throws Exception{
+
+        Map<String,BigDecimal>   transData = getTransData();
         try {
             TimeUnit.MILLISECONDS.sleep(3000);
         } catch (Exception e) {
@@ -135,11 +140,13 @@ public class TransMoney {
                     transData.put("elec2",parseObjectJSONObject.getBigDecimal("elec2").divide(precise,4,BigDecimal.ROUND_DOWN));
                     transData.put("elec3",parseObjectJSONObject.getBigDecimal("elec3").divide(precise,4,BigDecimal.ROUND_DOWN));
                     transData.put("elec4",parseObjectJSONObject.getBigDecimal("elec4").divide(precise,4,BigDecimal.ROUND_DOWN));
+                    transData.put("elec5",parseObjectJSONObject.getBigDecimal("elec5").divide(precise,4,BigDecimal.ROUND_DOWN));
                     transData.put("money",parseObjectJSONObject.getBigDecimal("money").divide(precise,4,BigDecimal.ROUND_DOWN));
                     transData.put("money1",parseObjectJSONObject.getBigDecimal("money1").divide(precise,4,BigDecimal.ROUND_DOWN));
                     transData.put("money2",parseObjectJSONObject.getBigDecimal("money2").divide(precise,4,BigDecimal.ROUND_DOWN));
                     transData.put("money3",parseObjectJSONObject.getBigDecimal("money3").divide(precise,4,BigDecimal.ROUND_DOWN));
                     transData.put("money4",parseObjectJSONObject.getBigDecimal("money4").divide(precise,4,BigDecimal.ROUND_DOWN));
+                    transData.put("money5",parseObjectJSONObject.getBigDecimal("money5").divide(precise,4,BigDecimal.ROUND_DOWN));
                     return transData;
                 }
             }catch (Exception e){

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

@@ -199,6 +199,12 @@ public class TransactionFlowPushFrame {
         //4.开始时间
         Date sdate = new Date(createTime);
         byte[] startTime = new byte[7];
+
+
+
+
+
+
         SimpleDateFormat se = new SimpleDateFormat("SS-ss-mm-HH-dd-MM-yy");
         String sformat = se.format(sdate).substring(1);
         startTime = CP56Time2a.timeCP56Time2a(sformat);

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

@@ -467,7 +467,7 @@ public class DeviceMsgHandle {
                     }
                     ////计算电量费用后上报,手动停止和余额不足的情况
                     // DeviceStatus deviceStatus = redisCache.getCacheMapValue(RedisConstant.ONLINE_DEVICE_ONE, statusServiceOne.getPileCode());
-                    Map<String, BigDecimal> map = transMoney.compute(port, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), true);
+                    Map<String, BigDecimal> map = transMoney.compute(port, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime());
                     logger.info(statusServiceOne.getPileCode() + ":停止充电上送交易记录" + DataConversion.bytesToHexString(statusServiceOne.getTransOrder()));
                     encrypt = transactionFlowPushFrame.sendTrans(deviceConnection, statusServiceOne.getTransOrder(), statusServiceOne.getPileCode(), (byte) 1, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), model, statusServiceOne.getCard(), map, statusServiceOne.getReasonStopCharging());
                     statusServiceOne.setOriginalText(encrypt);
@@ -489,7 +489,7 @@ public class DeviceMsgHandle {
                     byte[] encrypt = new byte[0];
                     statusServiceOne.setReasonStopCharging(TransConstant.INSUFFICIENT_BALANCE_EXCEPTION_STOP);
                     //计算电量
-                    Map<String, BigDecimal> map = transMoney.compute(port, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), true);
+                    Map<String, BigDecimal> map = transMoney.compute(port, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime());
                     logger.info(statusServiceOne.getPileCode() + ":余额用完充电上送交易记录" + DataConversion.bytesToHexString(statusServiceOne.getTransOrder()));
                     encrypt = transactionFlowPushFrame.sendTrans(deviceConnection, statusServiceOne.getTransOrder(), statusServiceOne.getPileCode(), (byte) 2, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), model, statusServiceOne.getCard(), map, statusServiceOne.getReasonStopCharging());
                     statusServiceOne.setOriginalText(encrypt);
@@ -545,13 +545,13 @@ public class DeviceMsgHandle {
                 if (port == 1) {
                     //急停停充:急停状态下:1.向设备发起结束充电,结算交易订单(交给结束充电处理;但是要考虑是急停的原因),2.上报的充电结束的订单式
 
-                    Map<String, BigDecimal> map = transMoney.compute(1, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), true);
+                    Map<String, BigDecimal> map = transMoney.compute(1, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime());
 
                     encrypt = transactionFlowPushFrame.sendTrans(deviceConnection, statusServiceOne.getTransOrder(), statusServiceOne.getPileCode(), (byte) 1, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), model, statusServiceOne.getCard(), map, TransConstant.EMERGENCY_STOP_EXCEPTION_STOP);
                 } else if (port == 2) {
                     //TODO:这里还是模拟数据上报
 
-                    Map<String, BigDecimal> map = transMoney.compute(2, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), true);
+                    Map<String, BigDecimal> map = transMoney.compute(2, model, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime());
                     //模拟3.5千瓦
                     encrypt = transactionFlowPushFrame.sendTrans(deviceConnection, statusServiceOne.getTransOrder(), statusServiceOne.getPileCode(), (byte) 2, statusServiceOne.getCreateTime(), statusServiceOne.getEndTime(), model, statusServiceOne.getCard(), map, TransConstant.EMERGENCY_STOP_EXCEPTION_STOP);
                 }
@@ -592,7 +592,7 @@ public class DeviceMsgHandle {
         if (portStatus.equals(PortStatusConstant.FREE)) {
             if (type == NormalChargeConstant.PORT_STATUS) {
                 //这里116状态是1可能是直接拔枪时的操作,直接拔枪时结束充电消息会直接上送,这里只记录停止原因不做交易订单上送
-                deviceOnline(imei, port, (byte) PortStatusConstant.FREE, StatusConstant.INSERT_GUNS_NO, type);
+                handleStatus7(imei, port, (byte) PortStatusConstant.FREE, StatusConstant.INSERT_GUNS_NO, type);
             }
             //处理特殊情况之后还要看枪状态变位上送
             deviceOnline(imei, port, StatusConstant.FREE, StatusConstant.INSERT_GUNS_NO);
@@ -607,7 +607,7 @@ public class DeviceMsgHandle {
             //充电完成状态是7,先处理一波
             logger.info("charnging Portstatus>>" + portStatus + ";type:" + type);
 
-            if (deviceOnline(imei, port, (byte) PortStatusConstant.CHARGING_END, StatusConstant.INSERT_GUNS_YES, type)){
+            if (handleStatus7(imei, port, (byte) PortStatusConstant.CHARGING_END, StatusConstant.INSERT_GUNS_YES, type)){
                 //状态是7时,处理过订单返回才是true
                 return;
             }
@@ -631,7 +631,7 @@ public class DeviceMsgHandle {
      * @param insertGunStatus
      * @param type            指令类型
      */
-    private boolean deviceOnline(String imei, int port, byte gunsStatus, byte insertGunStatus, int type)  throws Exception{
+    private boolean handleStatus7(String imei, int port, byte gunsStatus, byte insertGunStatus, int type)  throws Exception{
         logger.info("处理7状态>>>>>>");
         QueryWrapper<BillingModel> billingModelQueryWrapper = new QueryWrapper<>();
         billingModelQueryWrapper.eq("device_imei", imei);
@@ -928,12 +928,12 @@ public class DeviceMsgHandle {
                         Long endTime=System.currentTimeMillis();
                         if (port == 1) {
                             logger.info("订单状态orderStatus>>"+one.toString());
-                            Map<String, BigDecimal> map = transMoney.compute(1, model, one.getCreateTime(), endTime + 3 * 60 * 1000, true);
+                            Map<String, BigDecimal> map = transMoney.compute(1, model, one.getCreateTime(), endTime + 3 * 60 * 1000);
                             //logger.info("断网中停充>>>上报交易记录>>>");
                             encrypt = transactionFlowPushFrame.sendTrans(deviceConnectionMsg, one.getTransOrder(), statusServiceOne.getPileCode(), (byte) 1, one.getCreateTime(), statusServiceOneTemp.getUpdateTime() + 3 * 60 * 1000, model, one.getCard(), map, one.getReasonStopCharging());
                         } else if (port == 2) {
 
-                            Map<String, BigDecimal> map = transMoney.compute(2, model, one.getCreateTime(), endTime + 3 * 60 * 1000, true);
+                            Map<String, BigDecimal> map = transMoney.compute(2, model, one.getCreateTime(), endTime + 3 * 60 * 1000);
                             BigDecimal elec = map.get("elec");
                             BigDecimal money = map.get("money");
                             encrypt = transactionFlowPushFrame.sendTrans(deviceConnectionMsg, one.getTransOrder(), statusServiceOne.getPileCode(), (byte) 2, one.getCreateTime(), statusServiceOneTemp.getUpdateTime() + 3 * 60 * 1000, model, one.getCard(), map, statusServiceOneTemp.getFlage() == 2 ? TransConstant.CHARGING_STATION_POWER_OUTAGE : TransConstant.EMERGENCY_STOP_EXCEPTION_STOP);

+ 2 - 2
src/main/java/com/tmzn/devicelinkykc/message/YkcMsgHandle.java

@@ -355,7 +355,7 @@ public class YkcMsgHandle {
             if (temp) {
                 logger.info("启动失败{}:reason:{}" ,deviceConnectionMsg.getDeviceId(), reason);
                 charngingPushFrame.startStatus(deviceConnectionMsg, transOrder, guns[0], result, reason);
-                Map<String, BigDecimal> compute = transMoney.compute(guns[0], new BillingModel(), 0L, 0L, false);
+                Map<String, BigDecimal> compute = transMoney.getTransData();
                 transactionFlowPushFrame.sendTrans(deviceConnectionMsg, transOrder, deviceStatus.getPileCode(), guns[0], System.currentTimeMillis(), System.currentTimeMillis(), new BillingModel(), card, compute, TransConstant.START_FAIL);
                 return;
             }
@@ -504,7 +504,7 @@ public class YkcMsgHandle {
         BillingModel model = billingModelService.getOne(billingModelQueryWrapper);
 
         //后台计费
-        Map<String, BigDecimal> map = transMoney.compute(1, model, statusServiceOne.getCreateTime(), System.currentTimeMillis(), true);
+        Map<String, BigDecimal> map = transMoney.compute(1, model, statusServiceOne.getCreateTime(), System.currentTimeMillis());
         BigDecimal money = statusServiceOne.getStartMoney().subtract(map.get("money")).setScale(4, BigDecimal.ROUND_DOWN);
         BigDecimal add = money.add(bigDecimal);
         statusServiceOne.setStartMoney(add);

+ 1 - 0
src/main/java/com/tmzn/devicelinkykc/socket/SocketHandle.java

@@ -76,6 +76,7 @@ public class SocketHandle {
         return deviceConnectionMsgMap;
     }
 
+
     //
     public void updateDeviceConnectionMsgMap(DeviceConnectionMsg deviceConnectionMsg) {
         deviceConnectionMsgMap.put(deviceConnectionMsg.getDeviceId(),deviceConnectionMsg);

+ 8 - 2
src/main/java/com/tmzn/devicelinkykc/taskQueue/runner/MsgCharngingRunner.java

@@ -92,7 +92,13 @@ public class MsgCharngingRunner {
 
         QueryWrapper<OrderStatus> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("now_order_status", 0); //充电中状态上报
+
+        long nowTime = System.currentTimeMillis();
+        long tm = nowTime-86400*10;
+
+        queryWrapper.gt("create_time",tm ); //充电中状态上报
         queryWrapper.orderByDesc("id");
+
         //查询所有充电中设备的最新的订单记录,来上报设备状态消息.........?????????????????
         List<OrderStatus> list = orderStatusService.list(queryWrapper);
         if (list.isEmpty()) {
@@ -187,7 +193,7 @@ public class MsgCharngingRunner {
         //算电量
         Map<String, BigDecimal> start = null;
         try {
-            start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime, false);
+            start = transMoney.getTransData();
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -197,7 +203,7 @@ public class MsgCharngingRunner {
             start = redisCache.getCacheObject(RedisConstant.DEVICE_CHARNGING_INFO + orderStatus.getPileCode() + 1);
         } else {
             try {
-                start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime, true);
+                start = transMoney.compute(1, billingModel, orderStatus.getCreateTime(), endTime);
             } catch (Exception e) {
                 e.printStackTrace();
             }

+ 93 - 58
src/main/java/com/tmzn/devicelinkykc/taskQueue/runner/MsgTranscationRunner.java

@@ -37,78 +37,113 @@ public class MsgTranscationRunner {
     @Autowired
     private OrderStatusService orderStatusService;
 
+    @Autowired
+    private SocketHandle socketHandle;
+
+    public void handleOne(OrderStatus item){
+
+        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();
+            }
+            //将恢复结果状态转成5,记录为充电记录上传5分钟后失败
+            item.setTransactionOrderReplyStatus((byte) 5);
+            orderStatusService.updateById(item);
+            log.info("最新未收到上报的订单list5分钟推送最后一次>>" + item.toString());
+        }
+
+    }
 
     @Async("transactionTaskAsyncPool")
     public void transactionMsg(Map<String, DeviceConnectionMsg> map) throws Exception {
         log.info("======transaction push task starting=====");
         //任务处理 1.上报交易流水消息后没有响应回复的情况,30秒上送一次三次后停止,五分钟后上送最后一次,不管是否成功都不再上送:有结束时间,充电状态是结束充电的
         QueryWrapper<OrderStatus> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("now_order_status", 1); //充电完成
-        queryWrapper.eq("transaction_order_reporting_action_status", 1); //未上报
-        queryWrapper.eq("transaction_order_reply_status", 0); //未上报
+        queryWrapper.eq("now_order_status", 1).orderByDesc("id"); //充电完成
+//        queryWrapper.eq("transaction_order_reporting_action_status", 1); //已上送
+        queryWrapper.eq("transaction_order_reply_status", 0); //未回复的
+        queryWrapper.last("limit 1000");
 
         List<OrderStatus> list = orderStatusService.list(queryWrapper);
 
+        list.forEach(item->{
+            log.info("检测订单上报{}",item.getPileCode());
+            handleOne(item);
+        });
+
 //        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());
+//        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 = orderStatuses.stream().filter(orderStatus -> orderStatus.getNowOrderStatus() == 1 && orderStatus.getTransactionOrderReplyStatus() == 0 && orderStatus.getTransactionOrderReportingActionStatus() == 1).collect(Collectors.toList());
+//        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());
-                }
-            });
-        }
+//        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 -> {

+ 1 - 1
src/main/resources/application-prod.yml

@@ -18,7 +18,7 @@ redisMsgChanel: redisMsgChanel
 #本地
 msgService: http://172.16.187.37:8051
 #后台计费地址
-billingInterface: http://wetiandi.com/app/index.php?i=1&j=1&c=auth&a=calculate_cost&do=compute_elec_all
+billingInterface: http://wetiandi.com/app/index.php?i=1&j=1&c=auth&a=calculate_cost_new&do=compute_elec_all
 #集测IP
 #ip: 114.55.7.88