mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-18 06:09:58 +08:00
update
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3721,9 +3721,11 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
public List<SupStationStatsVO> queryOrderListByStationId(String stationId) {
|
||||
List<SupStationStatsVO> 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;
|
||||
}
|
||||
|
||||
@@ -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<String, SupStationStatsVO> 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<String, SupStationStatsVO> sortedMap = new TreeMap<>(collect);
|
||||
|
||||
// 初始化相关数据
|
||||
String pileSn = "";
|
||||
BigDecimal pileTotalPower = BigDecimal.ZERO;
|
||||
int pileChargeTime = Constants.zero;
|
||||
for (Map.Entry<String, SupStationStatsVO> entry: collect.entrySet()) {
|
||||
// key : pileConnectorCode
|
||||
// value: SupStationStatsVO
|
||||
for (Map.Entry<String, SupStationStatsVO> 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user