mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update空指针接口
This commit is contained in:
@@ -11,6 +11,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.lianlian.LianLianPileStatusEnum;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
@@ -53,8 +54,12 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -94,6 +99,9 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
@Autowired
|
||||
private PileMerchantInfoService pileMerchantInfoService;
|
||||
|
||||
@Autowired
|
||||
RedisCache redisCache;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -273,11 +281,12 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
SupStationInfoDTO stationInfo = new SupStationInfoDTO();
|
||||
stationInfo.setStationID(String.valueOf(pileStationInfo.getId()));
|
||||
stationInfo.setOperatorID(Constants.OPERATORID_JIANG_SU); // 组织机构代码
|
||||
String organizationCode = pileStationInfo.getOrganizationCode();
|
||||
// 充电服务运营商
|
||||
stationInfo.setEquipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(organizationCode));
|
||||
// 充电服务运营商 填写为个人
|
||||
stationInfo.setEquipmentOwnerID("999999999");
|
||||
|
||||
stationInfo.setStationName(pileStationInfo.getStationName());
|
||||
stationInfo.setCountryCode(pileStationInfo.getCountryCode());
|
||||
|
||||
String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213
|
||||
// 根据逗号分组
|
||||
String[] split = StringUtils.split(areaCode, ",");
|
||||
@@ -374,7 +383,6 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
map.put("PageCount", pageInfo.getPages());
|
||||
map.put("PageNo", pageInfo.getPageNum());
|
||||
map.put("StationInfos", resultList);
|
||||
log.info("queryStationsInfo result : " + JSON.toJSONString(map));
|
||||
|
||||
return ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO);
|
||||
}
|
||||
@@ -404,6 +412,7 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
SupStationInfoDTO info = SupStationInfoDTO.builder()
|
||||
.stationID(stationId)
|
||||
.operatorID(Constants.OPERATORID_JIANG_SU)
|
||||
.equipmentOwnerID("999999999")//充换电服务运营商ID,所属方 为个人时填写999999999
|
||||
.stationName(pileStationInfo.getStationName())
|
||||
.countryCode(pileStationInfo.getCountryCode())
|
||||
.areaCode(pileStationInfo.getAreaCode())
|
||||
@@ -482,12 +491,6 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
if (StringUtils.isBlank(info.getAreaCodeCountryside())){
|
||||
info.setAreaCodeCountryside("12345678901");
|
||||
}
|
||||
// 截取运营商组织机构代码(去除最后一位后的最后九位)
|
||||
MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId()));
|
||||
String organizationCode = merchantInfo.getOrganizationCode();
|
||||
|
||||
info.setEquipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(organizationCode));
|
||||
|
||||
|
||||
// 站点图片
|
||||
if (StringUtils.isNotBlank(pileStationInfo.getPictures())) {
|
||||
@@ -537,19 +540,16 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
List<ConnectorInfoVO> voList = entry.getValue();
|
||||
StationStatusInfo stationStatusInfo = new StationStatusInfo();
|
||||
|
||||
PileStationVO stationInfo = pileStationInfoService.getStationInfo(stationId);
|
||||
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(String.valueOf(stationInfo.getId()));
|
||||
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
|
||||
|
||||
stationStatusInfo.setOperatorId(Constants.OPERATORID_JIANG_SU);
|
||||
stationStatusInfo.setEquipmentOwnerId(ThirdPartyPlatformUtils.extractEquipmentOwnerID(organizationCode));
|
||||
stationStatusInfo.setEquipmentOwnerId("999999999");
|
||||
stationStatusInfo.setStationId(stationId);
|
||||
|
||||
ConnectorStatusInfo connectorStatusInfo;
|
||||
for (ConnectorInfoVO connectorInfoVO : voList) {
|
||||
connectorStatusInfo = ConnectorStatusInfo.builder()
|
||||
.operatorId(Constants.OPERATORID_JIANG_SU)
|
||||
.equipmentOwnerId(ThirdPartyPlatformUtils.extractEquipmentOwnerID(organizationCode))
|
||||
.equipmentOwnerId("999999999")
|
||||
.stationId(connectorInfoVO.getStationId())
|
||||
.equipmentId(connectorInfoVO.getPileSn())
|
||||
.connectorID(connectorInfoVO.getPileConnectorCode())
|
||||
@@ -596,7 +596,7 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
|
||||
SupConnectorStatusInfo info = SupConnectorStatusInfo.builder()
|
||||
.operatorID(Constants.OPERATORID_JIANG_SU)
|
||||
.equipmentOwnerID(MerchantUtils.getOperatorID(merchantInfoVO.getOrganizationCode()))
|
||||
.equipmentOwnerID("999999999")
|
||||
.stationID(connectorInfo.getStationId())
|
||||
.equipmentID(connectorInfo.getPileSn())
|
||||
.connectorID(pileConnectorCode)
|
||||
@@ -644,8 +644,6 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
|
||||
// 查询站点信息
|
||||
PileStationVO stationInfo = pileStationInfoService.getStationInfo(orderInfo.getStationId());
|
||||
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(String.valueOf(stationInfo.getId()));
|
||||
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
|
||||
|
||||
// 查询枪口实时状态
|
||||
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode());
|
||||
@@ -665,11 +663,6 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
if (Objects.isNull(info)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
|
||||
}
|
||||
String merchantId = info.getMerchantId();
|
||||
MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(merchantId);
|
||||
if (Objects.isNull(merchantInfoVO)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
|
||||
}
|
||||
String orderStatus = orderInfo.getOrderStatus();
|
||||
if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) {
|
||||
// 充电中
|
||||
@@ -692,11 +685,11 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
BigDecimal current = realTimeMonitorData.getOutputCurrent() == null ? BigDecimal.ZERO : new BigDecimal(realTimeMonitorData.getOutputCurrent());
|
||||
BigDecimal voltage = realTimeMonitorData.getOutputVoltage() == null ? BigDecimal.ZERO : new BigDecimal(realTimeMonitorData.getOutputVoltage());
|
||||
String soc = realTimeMonitorData.getSOC() == null ? Constants.ZERO : realTimeMonitorData.getSOC();
|
||||
|
||||
BigDecimal totalPower = realTimeMonitorData.getChargingDegree() == null ? BigDecimal.ZERO : new BigDecimal(realTimeMonitorData.getChargingDegree());
|
||||
String dateTime = DateUtils.getDateTime();
|
||||
SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder()
|
||||
.operatorID(Constants.OPERATORID_JIANG_SU)
|
||||
.equipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(organizationCode))
|
||||
.equipmentOwnerID("999999999")
|
||||
.stationID(orderInfo.getStationId())
|
||||
.equipmentID(orderInfo.getPileSn())
|
||||
.connectorID(orderInfo.getPileConnectorCode())
|
||||
@@ -710,10 +703,10 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
.soc(new BigDecimal(soc).setScale(1, RoundingMode.HALF_UP))
|
||||
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime()))
|
||||
.endTime(dateTime)
|
||||
.totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree()).setScale(4, BigDecimal.ROUND_HALF_UP))
|
||||
.totalPower(totalPower.setScale(4, RoundingMode.HALF_UP))
|
||||
.build();
|
||||
|
||||
supEquipChargeStatusInfo.setEquipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(stationInfo.getOrganizationCode()));
|
||||
supEquipChargeStatusInfo.setEquipmentOwnerID("999999999");
|
||||
|
||||
String url = urlAddress + "supervise_notification_equip_charge_status";
|
||||
// 调用平台接口
|
||||
@@ -734,135 +727,191 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
*/
|
||||
@Override
|
||||
public String notificationOperationStatsInfo(String stationId) {
|
||||
SupStationStatsInfo.EquipmentStatsInfo equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
|
||||
List<SupStationStatsInfo.EquipmentStatsInfo> equipmentStatsInfoList = new ArrayList<>();
|
||||
// 1. 获取统计时间范围(前一日的00:00:00至23:59:59)
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime startOfYesterday = yesterday.atStartOfDay();
|
||||
LocalDateTime endOfYesterday = yesterday.atTime(23, 59, 59);
|
||||
String startTime = startOfYesterday.format(formatter);
|
||||
String endTime = endOfYesterday.format(formatter);
|
||||
|
||||
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() != null) ? orderVO.getTotalPower() : BigDecimal.ZERO;
|
||||
int chargingTime = (orderVO.getChargingTime() != null) ? orderVO.getChargingTime() : Constants.zero;
|
||||
|
||||
stationTotalElectricity = stationTotalElectricity.add(totalPower);
|
||||
// 充电站累计充电时长(分钟)
|
||||
stationChargeTime += chargingTime;
|
||||
// 2. 查询站点下时间段的订单
|
||||
List<SupStationStatsVO> orderBasicInfos;
|
||||
try {
|
||||
orderBasicInfos = orderBasicInfoService.queryOrderListByStationIdAndTime(stationId, startTime, endTime);
|
||||
if (CollectionUtils.isEmpty(orderBasicInfos)) {
|
||||
log.info("站点{}没有查询到前一日的订单信息", stationId);
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("查询站点{}订单信息失败", stationId, e);
|
||||
return "查询订单失败: " + e.getMessage();
|
||||
}
|
||||
|
||||
// 根据枪口排序,分组,将充电时长和充电量累加
|
||||
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);
|
||||
// 3. 统计站点充电数据
|
||||
BigDecimal stationTotalElectricity = BigDecimal.ZERO;
|
||||
int stationTotalChargeTime = 0;
|
||||
String startChargeTime = null;
|
||||
String endChargeTime = null;
|
||||
|
||||
for (SupStationStatsVO orderVO : orderBasicInfos) {
|
||||
// 处理用电量
|
||||
BigDecimal power = orderVO.getTotalPower();
|
||||
if (power != null) {
|
||||
stationTotalElectricity = stationTotalElectricity.add(power);
|
||||
}
|
||||
|
||||
// 处理充电时长
|
||||
String start = orderVO.getStartTime();
|
||||
String end = orderVO.getEndTime();
|
||||
if (start != null && end != null) {
|
||||
try {
|
||||
long chargeTime = DateUtils.intervalTime(start, end);
|
||||
stationTotalChargeTime += (int) chargeTime;
|
||||
|
||||
// 更新统计开始和结束时间
|
||||
if (startChargeTime == null || start.compareTo(startChargeTime) < 0) {
|
||||
startChargeTime = start;
|
||||
}
|
||||
if (endChargeTime == null || end.compareTo(endChargeTime) > 0) {
|
||||
endChargeTime = end;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("计算订单{}充电时长失败", orderVO.getOrderCode(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果未获取到统计开始或结束时间,使用默认值
|
||||
if (startChargeTime == null) {
|
||||
startChargeTime = startTime;
|
||||
log.warn("站点{}未获取到有效订单开始时间,使用默认开始时间: {}", stationId, startTime);
|
||||
}
|
||||
if (endChargeTime == null) {
|
||||
endChargeTime = endTime;
|
||||
log.warn("站点{}未获取到有效订单结束时间,使用默认结束时间: {}", stationId, endTime);
|
||||
}
|
||||
|
||||
// 4. 按枪口排序,分组,将充电时长和充电量累加
|
||||
Map<String, List<SupStationStatsVO>> collect = orderBasicInfos.stream()
|
||||
.filter(vo -> vo.getChargingTime() != null)
|
||||
.collect(Collectors.groupingBy(SupStationStatsVO::getPileConnectorCode));
|
||||
TreeMap<String, List<SupStationStatsVO>> sortedMap = new TreeMap<>(collect);
|
||||
|
||||
List<SupStationStatsInfo.EquipmentStatsInfo> equipmentStatsInfoList = new ArrayList<>();
|
||||
// 初始化相关数据
|
||||
String pileSn = "";
|
||||
BigDecimal pileTotalPower = BigDecimal.ZERO;
|
||||
int pileChargeTime = Constants.zero;
|
||||
// key : pileConnectorCode
|
||||
// value: SupStationStatsVO
|
||||
for (Map.Entry<String, SupStationStatsVO> entry : sortedMap.entrySet()) {
|
||||
int pileChargeTime = 0;
|
||||
|
||||
for (Map.Entry<String, List<SupStationStatsVO>> entry : sortedMap.entrySet()) {
|
||||
String pileConnectorCode = entry.getKey();
|
||||
SupStationStatsVO vo = entry.getValue();
|
||||
List<SupStationStatsVO> voList = entry.getValue();
|
||||
|
||||
connectorStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo();
|
||||
SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo connectorStatsInfo = null;
|
||||
List<SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo> connectorStatsInfoList = new ArrayList<>();
|
||||
|
||||
// 先封装枪口数据
|
||||
connectorStatsInfo.setConnectorId(pileConnectorCode);
|
||||
for (SupStationStatsVO vo : voList) {
|
||||
connectorStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo();
|
||||
|
||||
connectorStatsInfo.setEquipmentClassification(1);
|
||||
connectorStatsInfo.setConnectorElectricity(((vo.getTotalPower() != null) ? vo.getTotalPower() : BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP));
|
||||
connectorStatsInfo.setConnectorTotalChargeTime((vo.getChargingTime() != null) ? vo.getChargingTime() : Constants.zero);
|
||||
connectorStatsInfo.setConnectorTotalChargeNum(orderVOS.size());
|
||||
connectorStatsInfo.setConnectorTotalWarningNum(0);
|
||||
// 先封装枪口数据
|
||||
connectorStatsInfo.setConnectorId(pileConnectorCode);
|
||||
connectorStatsInfo.setEquipmentClassification(1);
|
||||
|
||||
// 对比这次循环到的桩编号和上次的桩编号,如果是同一台桩,将数据进行汇总,如果不是,新建桩数据,并将之前的累计数据清0
|
||||
String newPileSn = vo.getPileSn();
|
||||
if (!StringUtils.equals(pileSn, newPileSn)) {
|
||||
pileSn = newPileSn;
|
||||
pileTotalPower = BigDecimal.ZERO;
|
||||
pileChargeTime = Constants.zero;
|
||||
BigDecimal power = vo.getTotalPower();
|
||||
if (power != null) {
|
||||
connectorStatsInfo.setConnectorElectricity(power.setScale(4, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
|
||||
connectorStatsInfoList = new ArrayList<>();
|
||||
String newPileSn = vo.getPileSn();
|
||||
if (!StringUtils.equals(pileSn, newPileSn)) {
|
||||
if (!pileSn.isEmpty()) {
|
||||
SupStationStatsInfo.EquipmentStatsInfo equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
|
||||
equipmentStatsInfo.setEquipmentId(pileSn);
|
||||
equipmentStatsInfo.setEquipmentClassification(1);
|
||||
equipmentStatsInfo.setEquipmentElectricity(pileTotalPower.setScale(4, RoundingMode.HALF_UP));
|
||||
equipmentStatsInfo.setEquipmentTotalChargeTime(pileChargeTime);
|
||||
equipmentStatsInfo.setEquipmentTotalChargeNum(voList.size());
|
||||
equipmentStatsInfo.setEquipmentTotalWarningNum(0);
|
||||
equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList);
|
||||
equipmentStatsInfo.setSupconnectorStatsInfos(connectorStatsInfoList);
|
||||
equipmentStatsInfoList.add(equipmentStatsInfo);
|
||||
}
|
||||
pileSn = newPileSn;
|
||||
pileTotalPower = BigDecimal.ZERO;
|
||||
pileChargeTime = 0;
|
||||
connectorStatsInfoList = new ArrayList<>();
|
||||
}
|
||||
|
||||
Integer chargingTime = vo.getChargingTime();
|
||||
if (chargingTime != null) {
|
||||
pileChargeTime += chargingTime;
|
||||
}
|
||||
|
||||
power = vo.getTotalPower();
|
||||
if (power != null) {
|
||||
pileTotalPower = pileTotalPower.add(power);
|
||||
}
|
||||
|
||||
connectorStatsInfo.setConnectorTotalChargeTime(chargingTime != null? chargingTime : 0);
|
||||
connectorStatsInfo.setConnectorTotalChargeNum(voList.size());
|
||||
connectorStatsInfo.setConnectorTotalWarningNum(0);
|
||||
connectorStatsInfoList.add(connectorStatsInfo);
|
||||
}
|
||||
|
||||
if (!pileSn.isEmpty()) {
|
||||
SupStationStatsInfo.EquipmentStatsInfo equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
|
||||
equipmentStatsInfo.setEquipmentId(pileSn);
|
||||
equipmentStatsInfo.setEquipmentClassification(1);
|
||||
equipmentStatsInfo.setEquipmentElectricity(((vo.getTotalPower() != null) ? vo.getTotalPower() : BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP));
|
||||
equipmentStatsInfo.setEquipmentTotalChargeTime((vo.getChargingTime() != null) ? vo.getChargingTime() : Constants.zero);
|
||||
equipmentStatsInfo.setEquipmentTotalChargeNum(orderVOS.size());
|
||||
equipmentStatsInfo.setEquipmentElectricity(pileTotalPower.setScale(4, RoundingMode.HALF_UP));
|
||||
equipmentStatsInfo.setEquipmentTotalChargeTime(pileChargeTime);
|
||||
equipmentStatsInfo.setEquipmentTotalChargeNum(voList.size());
|
||||
equipmentStatsInfo.setEquipmentTotalWarningNum(0);
|
||||
|
||||
pileTotalPower = pileTotalPower.add((vo.getTotalPower() != null) ? vo.getTotalPower() : BigDecimal.ZERO);
|
||||
pileChargeTime += (vo.getChargingTime() != null) ? vo.getChargingTime() : Constants.zero;
|
||||
|
||||
connectorStatsInfoList.add(connectorStatsInfo);
|
||||
equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList);
|
||||
equipmentStatsInfo.setSupconnectorStatsInfos(connectorStatsInfoList);
|
||||
equipmentStatsInfoList.add(equipmentStatsInfo);
|
||||
} else {
|
||||
// 同一台桩,枪口号不同,累加桩数据,将枪口数据新建
|
||||
pileTotalPower = pileTotalPower.add((vo.getTotalPower() != null) ? vo.getTotalPower() : BigDecimal.ZERO);
|
||||
pileChargeTime += (vo.getChargingTime() != null) ? vo.getChargingTime() : Constants.zero;
|
||||
|
||||
equipmentStatsInfo.setEquipmentElectricity(pileTotalPower); // 第一次判断时一定不会进入到这里,所以不用判断 equipmentStatsInfo 是否为 null
|
||||
equipmentStatsInfo.setEquipmentTotalChargeTime(pileChargeTime);
|
||||
|
||||
connectorStatsInfoList.add(connectorStatsInfo);
|
||||
equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList);
|
||||
equipmentStatsInfoList.add(equipmentStatsInfo);
|
||||
}
|
||||
}
|
||||
|
||||
PileStationVO stationInfo = pileStationInfoService.getStationInfo(stationId);
|
||||
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(String.valueOf(stationInfo.getId()));
|
||||
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
|
||||
// 5. 获取站点和商户信息
|
||||
PileStationVO stationInfo;
|
||||
PileMerchantInfoVO pileMerchantInfoVO;
|
||||
try {
|
||||
stationInfo = pileStationInfoService.getStationInfo(stationId);
|
||||
pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(String.valueOf(stationInfo.getId()));
|
||||
} catch (Exception e) {
|
||||
log.error("查询站点{}或商户信息失败", stationId, e);
|
||||
return "查询站点/商户信息失败: " + e.getMessage();
|
||||
}
|
||||
|
||||
// 创建对象
|
||||
String startTime = DateUtils.getYesterdayStr();
|
||||
String endTime = DateUtils.getYesterdayStr();
|
||||
// 6. 构建请求对象
|
||||
SupStationStatsInfo supStationStatsInfo = SupStationStatsInfo.builder()
|
||||
.stationId(stationId)
|
||||
.operatorId(Constants.OPERATORID_JIANG_SU)
|
||||
.equipmentOwnerId(ThirdPartyPlatformUtils.extractEquipmentOwnerID(organizationCode))
|
||||
.equipmentOwnerId("999999999")
|
||||
.stationClassification(1)
|
||||
.startTime(startTime)
|
||||
.endTime(endTime)
|
||||
.startTime(startChargeTime)
|
||||
.endTime(endChargeTime)
|
||||
.stationElectricity(stationTotalElectricity)
|
||||
.stationTotalChargeEnergy(stationTotalElectricity)
|
||||
.stationTotalOtherEnergy(new BigDecimal(Constants.zero).setScale(4, RoundingMode.HALF_UP)) //累计其它电量
|
||||
.stationTotalSwapChargeNum(Constants.zero)
|
||||
.stationTotalChargeNum(orderVOS.size())
|
||||
.stationTotalChargeTime(stationChargeTime)
|
||||
.stationTotalSwapTime(Constants.zero)
|
||||
.stationTotalOtherEnergy(new BigDecimal(0).setScale(4, RoundingMode.HALF_UP))
|
||||
.stationTotalSwapChargeNum(0)
|
||||
.stationTotalChargeNum(orderBasicInfos.size())
|
||||
.stationTotalChargeTime(stationTotalChargeTime)
|
||||
.stationTotalSwapTime(0)
|
||||
.stationTotalWarningNum(0)
|
||||
.equipmentStatsInfos(equipmentStatsInfoList)
|
||||
.supEquipmentStatsInfos(equipmentStatsInfoList)
|
||||
.build();
|
||||
|
||||
// 7. 构建请求JSON
|
||||
JSONObject json = new JSONObject();
|
||||
List<SupStationStatsInfo> supStationStatsInfoList = new ArrayList<>();
|
||||
supStationStatsInfoList.add(supStationStatsInfo);
|
||||
json.put("StationStatsInfos", supStationStatsInfoList);
|
||||
json.put("StationStatsInfos", Collections.singletonList(supStationStatsInfo));
|
||||
String jsonString = JSON.toJSONString(json);
|
||||
|
||||
// 发送推送请求
|
||||
// 8. 发送推送请求
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getSiChuanSecretInfo();
|
||||
|
||||
String operatorId = Constants.OPERATORID_JIANG_SU;
|
||||
|
||||
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
|
||||
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
|
||||
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
|
||||
@@ -980,11 +1029,7 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
|
||||
supStationPowerInfo.setOperatorId(Constants.OPERATORID_JIANG_SU);
|
||||
// 查询运营商基本信息
|
||||
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(stationId);
|
||||
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
|
||||
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
|
||||
supStationPowerInfo.setEquipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(organizationCode));
|
||||
}
|
||||
supStationPowerInfo.setEquipmentOwnerID("999999999");
|
||||
supStationPowerInfo.setStationId(stationId);
|
||||
supStationPowerInfo.setStationClassification(Constants.one);
|
||||
supStationPowerInfo.setDataTime(dateTimeNow);
|
||||
@@ -1102,40 +1147,33 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
* @return
|
||||
*/
|
||||
private ChargeOrderInfo transformChargeOrderInfo(OrderBasicInfo orderBasicInfo , OrderDetail orderDetail) {
|
||||
PileStationVO stationInfo = pileStationInfoService.getStationInfo(orderBasicInfo.getStationId());
|
||||
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(String.valueOf(stationInfo.getId()));
|
||||
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
|
||||
//空指针
|
||||
String chargeStartTime = orderBasicInfo.getChargeStartTime() == null ? "" : DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS , orderBasicInfo.getChargeStartTime());
|
||||
String chargeEndTime = orderBasicInfo.getChargeEndTime() == null ? "" : DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime());
|
||||
BigDecimal totalPower = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount();
|
||||
BigDecimal totalMoney = orderDetail.getTotalOrderAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalOrderAmount();
|
||||
BigDecimal totalServiceMoney = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount();
|
||||
BigDecimal totalElecMoney = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount();
|
||||
String reason = orderBasicInfo.getReason() == null ? "" : orderBasicInfo.getReason();
|
||||
|
||||
ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder()
|
||||
.operatorID(Constants.OPERATORID_JIANG_SU)
|
||||
.equipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(organizationCode))
|
||||
.equipmentOwnerID("999999999") //表示为个人
|
||||
.stationID(orderBasicInfo.getStationId())
|
||||
.equipmentID(orderBasicInfo.getPileSn())
|
||||
.orderNo(orderBasicInfo.getOrderCode())
|
||||
.connectorID(orderBasicInfo.getPileConnectorCode())
|
||||
.equipmentClassification(1)
|
||||
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime()))
|
||||
.endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime()))
|
||||
.totalPower(orderDetail.getTotalUsedElectricity().setScale(4, RoundingMode.HALF_UP))
|
||||
.startTime(chargeStartTime)
|
||||
.endTime(chargeEndTime)
|
||||
.totalPower(totalPower.setScale(4, RoundingMode.HALF_UP))
|
||||
.pushTimeStamp(DateUtils.getDateTime())
|
||||
.totalElecMoney(orderDetail.getTotalElectricityAmount().setScale(4, RoundingMode.HALF_UP))
|
||||
.totalServiceMoney(orderDetail.getTotalServiceAmount().setScale(4, RoundingMode.HALF_UP))
|
||||
.totalMoney(orderDetail.getTotalOrderAmount())
|
||||
.totalElecMoney(totalElecMoney.setScale(4, RoundingMode.HALF_UP))
|
||||
.totalServiceMoney(totalServiceMoney.setScale(4, RoundingMode.HALF_UP))
|
||||
.totalMoney(totalMoney.setScale(4, RoundingMode.HALF_UP))
|
||||
.stopReason(2)
|
||||
.stopDesc(orderBasicInfo.getReason())
|
||||
.stopDesc(reason)
|
||||
.build();
|
||||
if (orderBasicInfo.getPlateNumber() != null) {
|
||||
chargeOrderInfo.setLicensePlate(orderBasicInfo.getPlateNumber());
|
||||
}
|
||||
if (orderBasicInfo.getVinCode() != null) {
|
||||
chargeOrderInfo.setVin(orderBasicInfo.getVinCode());
|
||||
}
|
||||
if (orderBasicInfo.getStartSoc() != null) {
|
||||
chargeOrderInfo.setStartSOC(orderBasicInfo.getStartSoc());
|
||||
}
|
||||
if (orderBasicInfo.getEndSoc() != null) {
|
||||
chargeOrderInfo.setEndSOC(orderBasicInfo.getEndSoc());
|
||||
}
|
||||
return chargeOrderInfo;
|
||||
}
|
||||
|
||||
@@ -1175,19 +1213,6 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
}
|
||||
equipmentInfo.setEquipmentType(Integer.valueOf(pileDetailInfoVO.getSpeedType()));
|
||||
equipmentInfo.setEquipmentPower(new BigDecimal(pileDetailInfoVO.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
|
||||
|
||||
String pileStatus = pileDetailInfoVO.getPileStatus();
|
||||
if (StringUtils.equals(PileStatusEnum.ON_LINE.getValue(), pileStatus)) {
|
||||
// 1-在线
|
||||
pileStatus = LianLianPileStatusEnum.NORMAL.getCode();
|
||||
} else if (StringUtils.equals(PileStatusEnum.OFF_LINE.getValue(), pileStatus)) {
|
||||
// 2-离线
|
||||
pileStatus = LianLianPileStatusEnum.CLOSE_OFFLINE.getCode();
|
||||
} else if (StringUtils.equals(PileStatusEnum.FAULT.getValue(), pileStatus)) {
|
||||
// 3-故障
|
||||
pileStatus = LianLianPileStatusEnum.UNDER_MAINTENANCE.getCode();
|
||||
}
|
||||
|
||||
equipmentInfo.setPower(new BigDecimal(pileDetailInfoVO.getRatedPower()).setScale(4, RoundingMode.HALF_UP));
|
||||
|
||||
// 枪口列表
|
||||
@@ -1239,15 +1264,6 @@ public class SiChuanPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
connectorInfo.setAuxPower(3); // 3-兼容12V和24V
|
||||
connectorInfo.setOpreateStatus(50); // 50-正常使用
|
||||
|
||||
/* if (!StringUtils.equals(pileDetailInfoVO.getConnectorNum(), "1")) {
|
||||
// 如果不是单枪,则枪口功率需要除以枪口数量
|
||||
String ratedPowerStr = pileDetailInfoVO.getRatedPower();
|
||||
BigDecimal ratedPower = new BigDecimal(ratedPowerStr);
|
||||
connectorInfo.setPower(ratedPower.divide(new BigDecimal(pileDetailInfoVO.getConnectorNum()), 1, BigDecimal.ROUND_HALF_UP));
|
||||
}else {
|
||||
connectorInfo.setPower(new BigDecimal(pileDetailInfoVO.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
|
||||
}*/
|
||||
|
||||
resultList.add(connectorInfo);
|
||||
}
|
||||
return resultList;
|
||||
|
||||
Reference in New Issue
Block a user