Merge branch 'dev-zzx' into dev-new

# Conflicts:
#	jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java
This commit is contained in:
Lemon
2024-11-29 10:21:07 +08:00
5 changed files with 185 additions and 3 deletions

View File

@@ -24,6 +24,14 @@ public class SupStationInfo extends StationInfo {
@JSONField(name = "StationUniqueNumber")
private String stationUniqueNumber;
/**
* 设备接口分类
* 1车辆充电设备接口
* 2换电站内的电池箱充电设备接口
*/
@JSONField(name = "EquipmentClassification")
private Integer equipmentClassification;
/**
* 充换电站所在县以下行政区划代码
* 填写内容为12位行政区划代码1-6位为县及以上行政区划代码7-12位为县以下区划代码

View File

@@ -25,8 +25,10 @@ import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.thirdparty.ConnectorInfo;
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;
@@ -34,6 +36,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.web.PileMerchantInfoVO;
import com.jsowell.pile.vo.web.PileModelInfoVO;
import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo;
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
@@ -59,6 +62,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -85,6 +89,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired
private OrderBasicInfoService orderBasicInfoService;
@Autowired
private PileModelInfoService pileModelInfoService;
@Autowired
private PileBillingTemplateService pileBillingTemplateService;
@Autowired
private RedisCache redisCache;
@@ -195,7 +201,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
/**
* 查询充电站信息 query_stations_info
* supervise_query_operator_info
* supervise_query_stations_info
* 此接口用于查询对接平台的充电站的信息
*
* @param dto 查询站点信息dto
@@ -236,6 +242,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat()));
stationInfo.setConstruction(Integer.valueOf(pileStationInfo.getConstruction()));
stationInfo.setOpenAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay()));
stationInfo.setPeriodFee(1);
// stationInfo.setMinElectricityPrice(pileStationInfo); // 最低充电电费率
// stationInfo.setElectricityFee(); // 电费 xx元/度
// stationInfo.setServiceFee(); // 服务费 xx元/度
@@ -243,6 +250,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
stationInfo.setPayment(pileStationInfo.getPayment());
stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder()));
// stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型
stationInfo.setBusinessExpandType(Integer.parseInt(pileStationInfo.getAloneApply()));
stationInfo.setToiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag()));
stationInfo.setStoreFlag(Integer.valueOf(pileStationInfo.getStoreFlag()));
stationInfo.setRestaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag()));
@@ -308,6 +316,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
.parkFree(Integer.valueOf(pileStationInfo.getParkFree()))
.supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder()))
.parkFeeType(0)
.periodFee(1) // 峰谷分时 0-否1-是
.equipmentClassification(1)
.toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag()))
.storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag()))
.restaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag()))
@@ -539,6 +549,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
.connectorID(orderInfo.getPileConnectorCode())
.orderNo(orderInfo.getOrderCode())
.orderStatus(2)
.equipmentClassification(1)
.pushTimeStamp(dateTime)
.connectorStatus(info.getStatus()) // 3-充电中
.currentA(current.setScale(1, BigDecimal.ROUND_HALF_UP))
@@ -686,6 +697,155 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
return result;
}
/**
* 推送充换电站用能统计信息 supervise_notification_operation_stats_info
*
* @param stationId
* @throws UnsupportedOperationException 未实现异常
*/
@Override
public String notificationOperationStatsInfo(String stationId) {
SupStationStatsInfo.
EquipmentStatsInfo equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
List<SupStationStatsInfo.
EquipmentStatsInfo> equipmentStatsInfoList = new ArrayList<>();
SupStationStatsInfo.
EquipmentStatsInfo.
ConnectorStatsInfo connectorStatsInfo = null;
List<SupStationStatsInfo.
EquipmentStatsInfo.
ConnectorStatsInfo> connectorStatsInfoList = 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();
}
// 根据枪口排序,分组,将充电时长和充电量累加
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;
// key : pileConnectorCode
// value: SupStationStatsVO
for (Map.Entry<String, SupStationStatsVO> entry : sortedMap.entrySet()) {
String pileConnectorCode = entry.getKey();
SupStationStatsVO vo = entry.getValue();
connectorStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo();
// 先封装枪口数据
connectorStatsInfo.setConnectorId(pileConnectorCode);
connectorStatsInfo.setEquipmentClassification(1);
connectorStatsInfo.setConnectorElectricity(vo.getTotalPower());
connectorStatsInfo.setConnectorTotalChargeTime(vo.getChargingTime());
// TODO connectorStatsInfo.setConnectorTotalChargeNum();
connectorStatsInfo.setConnectorTotalWarningNum(0);
// 对比这次循环到的桩编号和上次的桩编号如果是同一台桩将数据进行汇总如果不是新建桩数据并将之前的累计数据清0
String newPileSn = vo.getPileSn();
if (!StringUtils.equals(pileSn, newPileSn)) {
pileSn = newPileSn;
pileTotalPower = BigDecimal.ZERO;
pileChargeTime = Constants.zero;
equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
connectorStatsInfoList = new ArrayList<>();
equipmentStatsInfo.setEquipmentId(pileSn);
equipmentStatsInfo.setEquipmentClassification(1);
equipmentStatsInfo.setEquipmentElectricity(vo.getTotalPower());
equipmentStatsInfo.setEquipmentTotalChargeTime(vo.getChargingTime());
// TODO equipmentStatsInfo.setEquipmentTotalChargeNum();
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);
}
}
// 创建对象
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(orderVOS.get(0).getOrganizationCode())
.stationClassification(1)
.startTime(startTime)
.endTime(endTime)
.stationElectricity(stationTotalElectricity)
.stationTotalChargeEnergy(stationTotalElectricity)
.stationTotalChargeNum(orderVOS.size())
.stationTotalChargeTime(stationChargeTime)
.stationTotalWarningNum(0)
.equipmentStatsInfos(equipmentStatsInfoList)
.build();
JSONObject json = new JSONObject();
json.put("StationStatsInfos", supStationStatsInfo);
String jsonString = JSON.toJSONString(json);
// 发送推送请求
ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo();
String operatorId = guiZhouPlatformSecretInfo.getOurOperatorId();
String operatorSecret = guiZhouPlatformSecretInfo.getTheirOperatorSecret();
String signSecret = guiZhouPlatformSecretInfo.getTheirSigSecret();
String dataSecret = guiZhouPlatformSecretInfo.getTheirDataSecret();
String dataSecretIv = guiZhouPlatformSecretInfo.getTheirDataSecretIv();
String urlAddress = guiZhouPlatformSecretInfo.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);
return result;
}
/**
* 推送充换电站实时功率 supervise_notification_realtime_power_info
*
@@ -802,7 +962,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() {
String thirdPartyType = ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode();
// 通过第三方平台类型查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode());
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPartyType);
if (thirdPartySecretInfoVO == null) {
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
}