This commit is contained in:
YAS\29473
2025-05-23 16:26:54 +08:00
parent 4064a17c93
commit 08589536a0
9 changed files with 292 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package com.jsowell.thirdparty.common;
import com.google.common.collect.Lists;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.StringUtils;
@@ -168,8 +169,14 @@ public class NotificationService {
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
//充电订单信息推送
platformService.notificationChargeOrderInfo(orderCode, secretInfoVO);
//订单信息推送
platformService.notificationChargeOrderInfo(orderCode);
// 测试联联之禾时发现会同时有两条notification_orderInfo请求发送,原因是异步走了lianLianService中的方法,因此请求一条出错,一条成功
// 注释掉另一个异步方法中的判断联联的if判断,看看效果
if(secretInfoVO.getPlatformType().equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode())){
//订单信息推送
platformService.notificationChargeOrderInfo(orderCode);
//推送停止充电结果
platformService.notificationStopChargeResult(orderCode);
}
} catch (Exception e) {
logger.error("充电订单信息推送error", e);
}

View File

@@ -454,6 +454,16 @@ public interface ThirdPartyPlatformService extends InitializingBean {
throw new UnsupportedOperationException("This method is not yet implemented");
}
/**
* 5.10 推送站点累计电量接口( notification_station_electStatsInfo
* 对接平台定时将当天站点累计电量实时电流实时电压推送到市级平台最低推送频率15分钟/次
*
* @return
*/
default String notificationStationElectStatsInfo (String thirdpartyType) {
throw new UnsupportedOperationException("This method is not yet implemented");
}
// -------------------------------------- 以下是公用方法 --------------------------------------- //
/**

View File

@@ -27,6 +27,8 @@ import com.jsowell.common.util.bean.BeanUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
import com.jsowell.pile.dto.*;
import com.jsowell.pile.mapper.OrderDetailMapper;
import com.jsowell.pile.mapper.ThirdPartyStationRelationMapper;
import com.jsowell.pile.service.*;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.thirdparty.EquipmentInfo;
@@ -34,7 +36,9 @@ import com.jsowell.pile.util.MerchantUtils;
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
import com.jsowell.pile.vo.base.*;
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
import com.jsowell.pile.vo.lianlian.OrderTempVO;
import com.jsowell.pile.vo.lianlian.PushStationFeeVO;
import com.jsowell.pile.vo.lianlian.StationElectStatsInfos;
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.web.PileStationVO;
@@ -105,6 +109,12 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired
private ThirdpartySecretInfoService thirdpartySecretInfoService;
@Autowired
private ThirdPartyStationRelationMapper thirdPartyStationRelationMapper;
@Autowired
private OrderDetailMapper orderDetailMapper;
@Override
public void afterPropertiesSet() throws Exception {
ThirdPartyPlatformFactory.register(thirdPlatformType, this);
@@ -654,7 +664,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
* 设备状态变化推送 notification_stationStatus
* 推送充电设备接口状态信息 supervise_notification_station_status
*
* @param dto 枪口状态
* @param
* @throws UnsupportedOperationException 未实现异常
*/
@Override
@@ -1208,6 +1218,122 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
//TODO 5.10 推送站点累计电量接口( notification_station_electStatsInfo
/**
* 5.10 推送站点累计电量接口( notification_station_electStatsInfo
* 对接平台定时将当天站点累计电量实时电流实时电压推送到市级平台最低推送频率15分钟/次
*
* @param thirdPlatformType
* @return
*/
public String notificationStationElectStatsInfo(String thirdPlatformType) {
//获取第三方平台下的站点
List<StationInfoVO> stationInfoVOS = thirdPartyStationRelationMapper.selectStationList(thirdPlatformType);
ThirdPartySecretInfoVO lianLianPlatformSecretInfo = getLianLianPlatformSecretInfo();
String operatorId = lianLianPlatformSecretInfo.getOurOperatorId();
String operatorSecret = lianLianPlatformSecretInfo.getTheirOperatorSecret();
String signSecret = lianLianPlatformSecretInfo.getTheirSigSecret();
String dataSecret = lianLianPlatformSecretInfo.getTheirDataSecret();
String dataSecretIv = lianLianPlatformSecretInfo.getTheirDataSecretIv();
String urlAddress = lianLianPlatformSecretInfo.getTheirUrlPrefix();
String url = urlAddress + "notification_station_electStatsInfo";
if (CollectionUtils.isEmpty(stationInfoVOS)){
return null;
}
List<StationElectStatsInfos> chargeFeeDetailList = new ArrayList<>();
// 循环站点列表
for (StationInfoVO stationInfoVO : stationInfoVOS) {
StationElectStatsInfos chargeFeeDetail = new StationElectStatsInfos();
chargeFeeDetail.setStationId("LC"+stationInfoVO.getStationId());
//获取当前站点的充电订单列表
List<OrderTempVO> tempVOS = orderDetailMapper.selectByStationId(stationInfoVO.getStationId());
if (CollectionUtils.isEmpty(tempVOS)){
return null;
}
// 统计该站点累计电量 保留1位小数
BigDecimal stationElectricity = tempVOS.stream()
.map(OrderTempVO::getTotalUsedElectricity) // 电量
.reduce(BigDecimal.ZERO , BigDecimal::add);// 累计电量
stationElectricity = stationElectricity.setScale(1, RoundingMode.HALF_UP);
chargeFeeDetail.setStationElectricity(stationElectricity);
//开始时间
//将订单列表按字符串时间排序
List<OrderTempVO> sortedOrderList = tempVOS.stream()
.sorted(Comparator.comparing(OrderTempVO::getCreateTime))
.collect(Collectors.toList());
//获取开始时间
String startTime = sortedOrderList.get(0).getCreateTime();
//获取结束时间
String endTime = sortedOrderList.get(sortedOrderList.size() - 1).getCreateTime();
chargeFeeDetail.setStartTime(startTime);
chargeFeeDetail.setEndTime(endTime);
BigDecimal currentOutPut = BigDecimal.ZERO; //当前总输出电流 保2小数
BigDecimal voltageOutPut = BigDecimal.ZERO; //当前总输出电压 保2小数
BigDecimal powerOutPut = BigDecimal.ZERO; //当前总输出功率 保1小数
BigDecimal currentNeed = BigDecimal.ZERO; //站点当前总需求电流 保2小数
BigDecimal VoltageNeed = BigDecimal.ZERO; //站点当前总需求电压 保2小数
BigDecimal PowerNeed = BigDecimal.ZERO; //站点当前总需求功率 保1小数
for (OrderTempVO tempVO : tempVOS) {
//随便获取一个实时数据中的数据
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(tempVO.getTransactionCode());
if (CollectionUtils.isEmpty(chargingRealTimeDataList)) {
// 没有查询到该订单的实时数据
continue;
}
RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.stream()
.filter(data -> data.getOutputCurrent() != null && data.getOutputVoltage() != null && data.getOutputPower() != null)
.findFirst()
.orElse(null); // 过滤出有输出电流、输出电压、输出功率的实时数据
if (realTimeMonitorData == null) {
// 跳过没有输出电流、输出电压、输出功率的实时数据
continue;
}
powerOutPut = powerOutPut.add(new BigDecimal(realTimeMonitorData.getOutputPower()));
currentOutPut = currentOutPut.add(new BigDecimal(realTimeMonitorData.getOutputCurrent()));
voltageOutPut = voltageOutPut.add(new BigDecimal(realTimeMonitorData.getOutputVoltage()));
}
chargeFeeDetail.setCurrentOutput(currentOutPut.setScale(2, RoundingMode.HALF_UP));
chargeFeeDetail.setVoltageOutput(voltageOutPut.setScale(2, RoundingMode.HALF_UP));
chargeFeeDetail.setPowerOutput(powerOutPut.setScale(1, RoundingMode.HALF_UP));
// 总需求电流,电压,功率,就同上
chargeFeeDetail.setCurrentNeed(currentOutPut.setScale(2, RoundingMode.HALF_UP));
chargeFeeDetail.setVoltageNeed(voltageOutPut.setScale(2, RoundingMode.HALF_UP));
chargeFeeDetail.setPowerNeed(powerOutPut.setScale(1, RoundingMode.HALF_UP));
chargeFeeDetailList.add(chargeFeeDetail);
}
// 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
if (StringUtils.isBlank(token)) {
return null;
}
// 调用联联平台接口
JSONObject json = new JSONObject();
json.put("OperatorId", Constants.OPERATORID_LIANLIAN);
json.put("StationElectStatsInfos", chargeFeeDetailList);
String jsonString = JSON.toJSONString(json);
log.info("notificationStationElectStatsInfo jsonString: " + jsonString);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
return result;
}
/**
* 站点费率变化推送 notification_stationFee