diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java index da0167301..677d66602 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java @@ -214,4 +214,24 @@ public class NingXiaController extends ThirdPartyBaseController { logger.info("宁夏平台推送充电站历史充电订单信息 result:{}", result); return response; } + + /** + * 推送充换电站用能统计信息 + * @param stationId + * @return + */ + @GetMapping("/v1/notificationOperationStatsInfo/{stationId}") + public RestApiResponse notificationOperationStatsInfo(@PathVariable("stationId") String stationId) { + RestApiResponse response = null; + String result = null; + try { + result = platformLogic.notificationOperationStatsInfo(stationId); + response = new RestApiResponse<>(result); + } catch (Exception e) { + logger.error("宁夏平台推送充换电站用能统计信息 error", e); + return new RestApiResponse<>(e); + } + logger.info("宁夏平台推送充换电站用能统计信息 result:{}", result); + return response; + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index b6a4c22d4..cd9f4c372 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -3721,9 +3721,11 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { public List queryOrderListByStationId(String stationId) { List orderVOS = orderBasicInfoMapper.queryOrderListByStationId(stationId); for (SupStationStatsVO orderVO : orderVOS) { - // 计算每笔订单充电时长(分钟) - long intervalTime = DateUtils.intervalTime(orderVO.getStartTime(), orderVO.getEndTime()); - orderVO.setChargingTime(Integer.parseInt(String.valueOf(intervalTime))); + if (StringUtils.isNotBlank(orderVO.getStartTime()) && StringUtils.isNotBlank(orderVO.getEndTime())) { + // 计算每笔订单充电时长(分钟) + long intervalTime = DateUtils.intervalTime(orderVO.getStartTime(), orderVO.getEndTime()); + orderVO.setChargingTime(Integer.parseInt(String.valueOf(intervalTime))); + } } return orderVOS; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java index 3081fe306..59459ee68 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java @@ -678,26 +678,34 @@ public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService { for (SupStationStatsVO orderVO : orderVOS) { // 充电站累计用电量 BigDecimal totalPower = orderVO.getTotalPower(); + if (totalPower == null || orderVO.getChargingTime() == null) { + continue; + } stationTotalElectricity = stationTotalElectricity.add(totalPower); // 充电站累计充电时长(分钟) - stationChargeTime+= orderVO.getChargingTime(); + stationChargeTime += orderVO.getChargingTime(); } // 根据枪口排序,分组,将充电时长和充电量累加 Map collect = orderVOS.stream() .sorted(Comparator.comparing(SupStationStatsVO::getPileConnectorCode)) + .filter(vo -> vo.getChargingTime() != null && vo.getTotalPower() != null) .collect(Collectors.toMap(SupStationStatsVO::getPileConnectorCode, Function.identity(), (a, b) -> { a.setChargingTime(a.getChargingTime() + b.getChargingTime()); a.setTotalPower(a.getTotalPower().add(b.getTotalPower())); return a; })); + TreeMap sortedMap = new TreeMap<>(collect); // 初始化相关数据 String pileSn = ""; BigDecimal pileTotalPower = BigDecimal.ZERO; int pileChargeTime = Constants.zero; - for (Map.Entry entry: collect.entrySet()) { + // key : pileConnectorCode + // value: SupStationStatsVO + for (Map.Entry entry: sortedMap.entrySet()) { + String pileConnectorCode = entry.getKey(); SupStationStatsVO vo = entry.getValue(); @@ -720,7 +728,9 @@ public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService { pileChargeTime = Constants.zero; equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo(); - equipmentStatsInfo.setEquipmentId(newPileSn); + connectorStatsInfoList = new ArrayList<>(); + + equipmentStatsInfo.setEquipmentId(pileSn); equipmentStatsInfo.setEquipmentClassification(1); equipmentStatsInfo.setEquipmentElectricity(vo.getTotalPower()); equipmentStatsInfo.setEquipmentTotalChargeTime(vo.getChargingTime()); @@ -728,23 +738,29 @@ public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService { pileTotalPower = pileTotalPower.add(vo.getTotalPower()); pileChargeTime += vo.getChargingTime(); + + connectorStatsInfoList.add(connectorStatsInfo); + equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList); + equipmentStatsInfoList.add(equipmentStatsInfo); }else { - // 同一台桩,累加数据 + // 同一台桩,枪口号不同,累加桩数据,将枪口数据新建 + pileTotalPower = pileTotalPower.add(vo.getTotalPower()); pileChargeTime += vo.getChargingTime(); equipmentStatsInfo.setEquipmentElectricity(pileTotalPower); // 第一次判断时一定不会进入到这里,所以不用判断 equipmentStatsInfo 是否为 null equipmentStatsInfo.setEquipmentTotalChargeTime(pileChargeTime); + connectorStatsInfoList.add(connectorStatsInfo); + equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList); + equipmentStatsInfoList.add(equipmentStatsInfo); } - equipmentStatsInfoList.add(equipmentStatsInfo); - connectorStatsInfoList.add(connectorStatsInfo); + } - equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList); // 创建对象 - String startTime = DateUtils.getYesterdayStr() + "00:00:00"; - String endTime = DateUtils.getYesterdayStr() + "23:59:59"; + String startTime = DateUtils.getYesterdayStr() + " 00:00:00"; + String endTime = DateUtils.getYesterdayStr() + " 23:59:59"; SupStationStatsInfo supStationStatsInfo = SupStationStatsInfo.builder() .stationId(stationId) .operatorId(Constants.OPERATORID_JIANG_SU) @@ -760,6 +776,9 @@ public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService { .equipmentStatsInfos(equipmentStatsInfoList) .build(); + JSONObject json = new JSONObject(); + json.put("StationStatsInfos", supStationStatsInfo); + String jsonString = JSON.toJSONString(json); // 发送推送请求 ThirdPartySecretInfoVO ningXiaSecretInfo = getNingXiaPlatformSecretInfo(); @@ -776,9 +795,6 @@ public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService { return null; } // 调用平台接口 - JSONObject json = new JSONObject(); - json.put("StationStatsInfos", supStationStatsInfo); - String jsonString = JSON.toJSONString(json); String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result;