|
|
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Component;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.Instant;
|
|
|
import java.time.ZoneId;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
@@ -37,7 +38,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Component
|
|
|
-@Slf4j(topic = "MsgHeartRunner")
|
|
|
+@Slf4j(topic = "MsgChargingRunner")
|
|
|
public class MsgCharngingRunner {
|
|
|
|
|
|
@Autowired
|
|
|
@@ -75,269 +76,418 @@ public class MsgCharngingRunner {
|
|
|
@Async("charngingTaskAsyncPool")
|
|
|
public void chargingMsg(Map<String, DeviceConnectionMsg> map) {
|
|
|
log.info("======Charging status push task starting=====");
|
|
|
- //TODO:这边需要给充电中的状态进行查询流水号,流水号是由云快充启动充电时的下发指令带来存库的,
|
|
|
- if (map.size()<1){
|
|
|
+ //这边需要给充电中的状态进行查询流水号,流水号是由云快充启动充电时的下发指令带来存库的,
|
|
|
+ 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); //充电中状态上报
|
|
|
-
|
|
|
-
|
|
|
+ queryWrapper.orderByDesc("id");
|
|
|
//查询所有充电中设备的最新的订单记录,来上报设备状态消息.........?????????????????
|
|
|
List<OrderStatus> list = orderStatusService.list(queryWrapper);
|
|
|
-// 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());
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ log.info("无充电中订单上报");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //拿到当前计费模板
|
|
|
- List<BillingModel> billingModels = billingModelService.list();
|
|
|
+ Map<String, BillingModel> billingModelMap = billingModels.stream()
|
|
|
+ .collect(Collectors.toMap(BillingModel::getPileCode, billingModel -> billingModel));
|
|
|
|
|
|
- //redis取出在线设备集合
|
|
|
- Set<String> devicePileCodes = map.keySet();
|
|
|
- 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);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ //只上传最近的订单
|
|
|
+ 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());
|
|
|
+ return;
|
|
|
}
|
|
|
- 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);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ if (deviceConnectionMsg == null) {
|
|
|
+ log.info("{}上报充电中未连接", item.getPileCode());
|
|
|
+ return;
|
|
|
}
|
|
|
- }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 (b == null) {
|
|
|
+ log.info("{}上报充电中未匹配计费模型", item.getPileCode());
|
|
|
+ return;
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
- 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);
|
|
|
+
|
|
|
+ String k = item.getPileCode() + "_" + item.getGunsCode();
|
|
|
+ if (dealMap.containsKey(k)) {
|
|
|
+ log.info("{}本轮已上报充电中", k);
|
|
|
+ } else {
|
|
|
+ reportOne(item, b, deviceConnectionMsg);
|
|
|
+ dealMap.put(k, true);
|
|
|
}
|
|
|
- });
|
|
|
- }*/
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("{}上报充电中异常", item.getPileCode());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
log.info("======Charging status push task ending=====");
|
|
|
}
|
|
|
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ log.info("charngingTaskAsyncPool-1>not longin>>" + orderStatus.getPileCode());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deviceConnectionMsg.getLoginStatus() != 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject statusJSON = redisCache.getCacheObject(RedisConstant.DEVICE_PORT_STATUS + deviceStatus.getDeviceImei());
|
|
|
+ if(statusJSON==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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("{}-{}充电中=>实时elec>>>" + elec,orderStatus.getPileCode(),orderStatus.getGunsCode());
|
|
|
+
|
|
|
+ //????????????????????????????
|
|
|
+ if (money.compareTo(orderStatus.getStartMoney()) > 0) {
|
|
|
+ //余额没有了,停充
|
|
|
+ log.info("{},{},{}实时状态校验时余额不足>>>>>>停充>>>>",orderStatus.getPileCode(),orderStatus.getGunsCode(),orderStatus.getId());
|
|
|
+ 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("↑↑↑{},{},{}充电中实时状态上报 ",orderStatus.getPileCode(),orderStatus.getGunsCode(),orderStatus.getId());
|
|
|
+ realTimeStatusPushFrame.deviceStatusPush(deviceConnectionMsg, orderStatus.getTransOrder(), deviceStatus.getPileCode(), deviceStatus.getGunPort(), deviceStatus.getGunStatus(), deviceStatus.getInsertGunStatus(), voltage, power, elec, money, mi);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ ////// 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);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }*/
|
|
|
+
|
|
|
|
|
|
}
|