新增 内蒙古平台推送充换电站用能统计信息接口

This commit is contained in:
Lemon
2025-04-10 09:09:49 +08:00
parent 480ef63493
commit fd90a5e312
3 changed files with 110 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
@@ -11,10 +12,7 @@ import com.jsowell.thirdparty.lianlian.common.CommonResult;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@@ -153,4 +151,24 @@ public class NeiMengGuController extends ThirdPartyBaseController {
}
}
/**
* 推送充换电站用能统计信息 notificationOperationStatsInfo
* @return
*/
@GetMapping("/v1/notificationOperationStatsInfo/{stationId}")
public RestApiResponse<?> notificationOperationStatsInfo(@PathVariable String stationId) {
logger.info("{}-推送充换电站用能统计信息 params:{}", platformName, stationId);
RestApiResponse<?> response = null;
try {
// 执行逻辑
String result = platformLogic.notificationOperationStatsInfo(stationId);
response = new RestApiResponse<>(result);
} catch (Exception e) {
logger.error("{}-推送充换电站用能统计信息", platformName, e);
response = new RestApiResponse<>(e);
}
logger.info("{}-推送充换电站用能统计信息 result:{}", platformName, response);
return response;
}
}

View File

@@ -56,6 +56,30 @@ public class SupStationStatsInfo {
@JSONField(name = "StationElectricity")
private BigDecimal stationElectricity;
/**
* 累计充电量
*/
@JSONField(name = "DailyChargeEnergy")
private BigDecimal dailyChargeEnergy;
/**
* 累计其他电量
*/
@JSONField(name = "DailyOtherEnergy")
private BigDecimal dailyOtherEnergy;
/**
* 累计换电次数
*/
@JSONField(name = "DailySwapNum")
private Integer dailySwapNum;
/**
* 累计充电次数
*/
@JSONField(name = "DailyChargeNum")
private Integer dailyChargeNum;
/**
* 充换电站累计充电量
*/

View File

@@ -34,6 +34,7 @@ import com.jsowell.pile.service.*;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.thirdparty.EquipmentInfo;
import com.jsowell.pile.util.MerchantUtils;
import com.jsowell.pile.vo.SupStationStatsVO;
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
import com.jsowell.pile.vo.base.ConnectorInfoVO;
import com.jsowell.pile.vo.base.MerchantInfoVO;
@@ -66,6 +67,7 @@ import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -836,7 +838,65 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
*/
@Override
public String notificationOperationStatsInfo(String stationId) {
return ThirdPartyPlatformService.super.notificationOperationStatsInfo(stationId);
List<SupStationStatsInfo> resultList = new ArrayList<>();
// 根据站点id查询订单记录 (新建Service方法)
List<SupStationStatsVO> orderVOS = orderBasicInfoService.queryOrderListByStationId(stationId);
// 根据订单信息汇总出站点充电数据
BigDecimal stationTotalElectricity = BigDecimal.ZERO; // 充电站累计用电量
int stationChargeTime = Constants.zero; // 充电站累计充电次数
for (SupStationStatsVO orderVO : orderVOS) {
// 充电站累计用电量
BigDecimal totalPower = orderVO.getTotalPower();
if (totalPower == null || orderVO.getChargingTime() == null) {
continue;
}
stationTotalElectricity = stationTotalElectricity.add(totalPower);
// 充电站累计充电时长(分钟)
stationChargeTime += orderVO.getChargingTime();
}
// 创建对象
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)
.equipmentOwnerId(ThirdPartyPlatformUtils.extractEquipmentOwnerID(orderVOS.get(0).getOrganizationCode()))
// .stationClassification(1)
.startTime(startTime)
.endTime(endTime)
.stationElectricity(stationTotalElectricity)
.dailyChargeEnergy(stationTotalElectricity)
.dailyOtherEnergy(new BigDecimal("0"))
.dailySwapNum(0)
.dailyChargeNum(orderVOS.size())
.stationTotalChargeTime(stationChargeTime)
.stationTotalSwapTime(0)
.stationTotalWarningNum(0)
.build();
resultList.add(supStationStatsInfo);
JSONObject json = new JSONObject();
json.put("StationStatsInfos", resultList);
String jsonString = JSON.toJSONString(json);
// 发送推送请求
ThirdPartySecretInfoVO ningXiaSecretInfo = getNeiMengGuPlatformSecretInfo();
String operatorId = Constants.OPERATORID_LIANLIAN;
String operatorSecret = ningXiaSecretInfo.getTheirOperatorSecret();
String signSecret = ningXiaSecretInfo.getTheirSigSecret();
String dataSecret = ningXiaSecretInfo.getTheirDataSecret();
String dataSecretIv = ningXiaSecretInfo.getTheirDataSecretIv();
String urlAddress = ningXiaSecretInfo.getTheirUrlPrefix();
String url = urlAddress + "supervise_notification_operation_stats_info";
// 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
if (StringUtils.isBlank(token)) {
return null;
}
// 调用平台接口
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType);
return result;
}
/**
@@ -887,9 +947,9 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
return null;
}
// 调用联联平台接口
JSONObject json = new JSONObject();
json.put("ChargeOrderInfo", orderInfo);
String jsonString = JSON.toJSONString(json);
// JSONObject json = new JSONObject();
// json.put("ChargeOrderInfo", orderInfo);
String jsonString = JSON.toJSONString(orderInfo);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType);
return result;
}