mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-28 11:08:12 +08:00
新增 广西平台Service相关方法
This commit is contained in:
@@ -28,6 +28,8 @@ public enum ThirdPlatformTypeEnum {
|
|||||||
GAN_SU_PLATFORM("17", "甘肃省平台", "MA01H3BQ9"),
|
GAN_SU_PLATFORM("17", "甘肃省平台", "MA01H3BQ9"),
|
||||||
GUI_ZHOU_PLATFORM("18", "贵州省平台", "009390404"),
|
GUI_ZHOU_PLATFORM("18", "贵州省平台", "009390404"),
|
||||||
NAN_RUI_PLATFORM("19", "南瑞平台", ""),
|
NAN_RUI_PLATFORM("19", "南瑞平台", ""),
|
||||||
|
|
||||||
|
GUANG_XI_PLATFORM("20", "广西平台", ""),
|
||||||
;
|
;
|
||||||
|
|
||||||
private String typeCode;
|
private String typeCode;
|
||||||
|
|||||||
@@ -75,4 +75,28 @@ public class QueryStartChargeDTO {
|
|||||||
* 支付方式(1-余额支付;3-白名单支付;4-微信支付;5-支付宝支付)
|
* 支付方式(1-余额支付;3-白名单支付;4-微信支付;5-支付宝支付)
|
||||||
*/
|
*/
|
||||||
private String payMode;
|
private String payMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询页码
|
||||||
|
*/
|
||||||
|
@JsonProperty(value = "PageNo")
|
||||||
|
private Integer pageNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页数量
|
||||||
|
*/
|
||||||
|
@JsonProperty(value = "PageSize")
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上次查询时间
|
||||||
|
*/
|
||||||
|
@JsonProperty(value = "LastQueryTime")
|
||||||
|
private String lastQueryTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上次查询结束时间
|
||||||
|
*/
|
||||||
|
@JsonProperty(value = "LastQueryEndTime")
|
||||||
|
private String lastQueryEndTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ public class QueryStationInfoDTO {
|
|||||||
@JsonProperty(value = "StationIDs")
|
@JsonProperty(value = "StationIDs")
|
||||||
private List<String> stationIds;
|
private List<String> stationIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更多标志
|
||||||
|
*/
|
||||||
|
@JsonProperty(value = "MoreFlag")
|
||||||
|
private Integer moreFlag;
|
||||||
|
|
||||||
|
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jsowell.pile.mapper;
|
package com.jsowell.pile.mapper;
|
||||||
|
|
||||||
|
import com.alipay.api.domain.ChargeOrderInfo;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
import com.jsowell.pile.domain.OrderDetail;
|
import com.jsowell.pile.domain.OrderDetail;
|
||||||
import com.jsowell.pile.dto.*;
|
import com.jsowell.pile.dto.*;
|
||||||
@@ -394,4 +395,11 @@ public interface OrderBasicInfoMapper {
|
|||||||
|
|
||||||
|
|
||||||
List<String> tempGetOrderCodes(QueryOrderDTO dto);
|
List<String> tempGetOrderCodes(QueryOrderDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询第三方平台订单列表
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrderVO> selectThirdPartyOrderList(@Param("dto") QueryStartChargeDTO dto);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jsowell.pile.service;
|
package com.jsowell.pile.service;
|
||||||
|
|
||||||
|
import com.alipay.api.domain.ChargeOrderInfo;
|
||||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
import com.jsowell.adapay.response.PaymentReverseResponse;
|
import com.jsowell.adapay.response.PaymentReverseResponse;
|
||||||
import com.jsowell.adapay.vo.OrderSplitResult;
|
import com.jsowell.adapay.vo.OrderSplitResult;
|
||||||
@@ -476,6 +477,12 @@ public interface OrderBasicInfoService{
|
|||||||
*/
|
*/
|
||||||
void createReservationOrder(ReservationChargingStartupResult chargingStartupResult);
|
void createReservationOrder(ReservationChargingStartupResult chargingStartupResult);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询第三方平台订单列表
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
List<OrderVO> selectThirdPartyOrderList(QueryStartChargeDTO dto);
|
||||||
|
|
||||||
|
|
||||||
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 后管小程序 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 后管小程序 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.jsowell.pile.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.alipay.api.domain.ChargeOrderInfo;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
@@ -2592,7 +2593,18 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AccumulativeInfoVO> getAccumulativeInfoForLianLian(QueryStationInfoDTO dto) {
|
public List<AccumulativeInfoVO> getAccumulativeInfoForLianLian(QueryStationInfoDTO dto) {
|
||||||
return orderBasicInfoMapper.getAccumulativeInfoForLianLian(dto);
|
List<AccumulativeInfoVO> accumulativeInfoList = orderBasicInfoMapper.getAccumulativeInfoForLianLian(dto);
|
||||||
|
for (AccumulativeInfoVO accumulativeInfoVO : accumulativeInfoList) {
|
||||||
|
String startTime = accumulativeInfoVO.getStartTime();
|
||||||
|
String endTime = accumulativeInfoVO.getEndTime();
|
||||||
|
if (startTime == null || endTime == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 计算充电时长
|
||||||
|
int chargingTime = Integer.parseInt(String.valueOf(DateUtils.intervalTime(startTime, endTime))) * 60;
|
||||||
|
accumulativeInfoVO.setChargingTime(String.valueOf(chargingTime));
|
||||||
|
}
|
||||||
|
return accumulativeInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4096,6 +4108,15 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
orderPayRecordService.batchInsert(Lists.newArrayList(principalPayRecord));
|
orderPayRecordService.batchInsert(Lists.newArrayList(principalPayRecord));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询第三方平订单列表
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<OrderVO> selectThirdPartyOrderList(QueryStartChargeDTO dto) {
|
||||||
|
return orderBasicInfoMapper.selectThirdPartyOrderList(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1224,7 +1224,6 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
|||||||
public List<EquipmentInfo> getPileListForLianLian(String stationId) {
|
public List<EquipmentInfo> getPileListForLianLian(String stationId) {
|
||||||
List<EquipmentInfo> resultList = new ArrayList<>();
|
List<EquipmentInfo> resultList = new ArrayList<>();
|
||||||
// 通过站点id查询桩基本信息
|
// 通过站点id查询桩基本信息
|
||||||
// List<PileBasicInfo> list = this.getPileListByStationId(stationId);
|
|
||||||
List<PileDetailInfoVO> list = getPileDetailInfoList(stationId);
|
List<PileDetailInfoVO> list = getPileDetailInfoList(stationId);
|
||||||
// 封装成联联平台对象
|
// 封装成联联平台对象
|
||||||
for (PileDetailInfoVO pileDetailInfoVO : list) {
|
for (PileDetailInfoVO pileDetailInfoVO : list) {
|
||||||
@@ -1245,19 +1244,6 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
|||||||
equipmentInfo.setEquipmentType(Integer.valueOf(pileDetailInfoVO.getSpeedType()));
|
equipmentInfo.setEquipmentType(Integer.valueOf(pileDetailInfoVO.getSpeedType()));
|
||||||
equipmentInfo.setEquipmentModel(pileDetailInfoVO.getModelName());
|
equipmentInfo.setEquipmentModel(pileDetailInfoVO.getModelName());
|
||||||
|
|
||||||
// Map<String, String> pileStatus = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileBasicInfo.getSn()));
|
|
||||||
// Map<String, String> pileStatusMap = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileSn));
|
|
||||||
// String pileStatus = pileStatusMap.get(pileSn);
|
|
||||||
// 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.setEquipmentStatus(Integer.valueOf(pileDetailInfoVO.getPileStatus()));
|
equipmentInfo.setEquipmentStatus(Integer.valueOf(pileDetailInfoVO.getPileStatus()));
|
||||||
equipmentInfo.setEquipmentPower(new BigDecimal(pileDetailInfoVO.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
|
equipmentInfo.setEquipmentPower(new BigDecimal(pileDetailInfoVO.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
|
||||||
equipmentInfo.setNewNationalStandard(1);
|
equipmentInfo.setNewNationalStandard(1);
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ public class AccumulativeInfoVO {
|
|||||||
*/
|
*/
|
||||||
private String endTime;
|
private String endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电时长
|
||||||
|
*/
|
||||||
|
private String chargingTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 枪口充电量
|
* 枪口充电量
|
||||||
*/
|
*/
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -29,4 +29,16 @@ public class ConnectorStatsInfo {
|
|||||||
*/
|
*/
|
||||||
@JSONField(name = "ConnectorElectricity")
|
@JSONField(name = "ConnectorElectricity")
|
||||||
private BigDecimal connectorElectricity;
|
private BigDecimal connectorElectricity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电时长(单位:s)
|
||||||
|
*/
|
||||||
|
@JSONField(name = "ConnectorDuration")
|
||||||
|
private Integer connectorDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电次数
|
||||||
|
*/
|
||||||
|
@JSONField(name = "ConnectorNum")
|
||||||
|
private Integer connectorNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,18 @@ public class EquipmentStatsInfo {
|
|||||||
@JSONField(name = "EquipmentElectricity")
|
@JSONField(name = "EquipmentElectricity")
|
||||||
private BigDecimal equipmentElectricity;
|
private BigDecimal equipmentElectricity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电时长(单位:s)
|
||||||
|
*/
|
||||||
|
@JSONField(name = "ConnectorDuration")
|
||||||
|
private Integer connectorDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电次数
|
||||||
|
*/
|
||||||
|
@JSONField(name = "ConnectorNum")
|
||||||
|
private Integer connectorNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电设备接口统计信息列表 Y
|
* 充电设备接口统计信息列表 Y
|
||||||
* 充设备的所有充电设备接口统计对象集合
|
* 充设备的所有充电设备接口统计对象集合
|
||||||
|
|||||||
@@ -44,6 +44,18 @@ public class StationStatsInfo {
|
|||||||
@JSONField(name = "StationElectricity")
|
@JSONField(name = "StationElectricity")
|
||||||
private BigDecimal stationElectricity;
|
private BigDecimal stationElectricity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电时长(单位:s)
|
||||||
|
*/
|
||||||
|
@JSONField(name = "ConnectorDuration")
|
||||||
|
private Integer connectorDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电次数
|
||||||
|
*/
|
||||||
|
@JSONField(name = "ConnectorNum")
|
||||||
|
private Integer connectorNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电设备统计信息列表
|
* 充电设备统计信息列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ public class ChargeOrderInfo {
|
|||||||
@JSONField(name = "ConnectorID")
|
@JSONField(name = "ConnectorID")
|
||||||
private String connectorId;
|
private String connectorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户发起充电类型
|
||||||
|
*/
|
||||||
|
@JSONField(name = "StartChargeType")
|
||||||
|
private Integer startChargeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电订单号
|
* 充电订单号
|
||||||
*/
|
*/
|
||||||
@@ -110,6 +116,19 @@ public class ChargeOrderInfo {
|
|||||||
@JSONField(name = "TotalElecMoney")
|
@JSONField(name = "TotalElecMoney")
|
||||||
private BigDecimal totalElecMoney;
|
private BigDecimal totalElecMoney;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累计电费
|
||||||
|
*/
|
||||||
|
@JSONField(name = "ElecMoney")
|
||||||
|
private BigDecimal elecMoney;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累计服务费
|
||||||
|
*/
|
||||||
|
@JSONField(name = "SeviceMoney")
|
||||||
|
private BigDecimal seviceMoney;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本次充电服务费金额
|
* 本次充电服务费金额
|
||||||
* 保留小数点后 2 位
|
* 保留小数点后 2 位
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ public class StationInfo extends BaseStationInfo {
|
|||||||
@JSONField(name = "AreaCode")
|
@JSONField(name = "AreaCode")
|
||||||
private String areaCode;
|
private String areaCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 街道编码
|
||||||
|
*/
|
||||||
|
@JSONField(name = "StreetCode")
|
||||||
|
private String streetCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 详细地址 Y
|
* 详细地址 Y
|
||||||
* <=50字符
|
* <=50字符
|
||||||
@@ -254,6 +260,20 @@ public class StationInfo extends BaseStationInfo {
|
|||||||
@JSONField(name = "EquipmentInfos")
|
@JSONField(name = "EquipmentInfos")
|
||||||
private List<EquipmentInfo> equipmentInfos;
|
private List<EquipmentInfo> equipmentInfos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 投建日期
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@JSONField(name = "RunDate")
|
||||||
|
private String runDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 投建日期
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@JSONField(name = "BuildDate")
|
||||||
|
private String buildDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否独立报桩 (0-否;1-是) Y
|
* 是否独立报桩 (0-否;1-是) Y
|
||||||
* 如果是独立报桩需要填写户号以及容量
|
* 如果是独立报桩需要填写户号以及容量
|
||||||
|
|||||||
@@ -205,6 +205,16 @@ public interface ThirdPartyPlatformService extends InitializingBean {
|
|||||||
throw new UnsupportedOperationException("This method is not yet implemented");
|
throw new UnsupportedOperationException("This method is not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询已完成订单列表信息接口
|
||||||
|
* query_finish_orders
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default Map<String, String> queryFinishOrders(QueryStartChargeDTO dto) {
|
||||||
|
throw new UnsupportedOperationException("This method is not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VIN码充电 insert_start_charge
|
* VIN码充电 insert_start_charge
|
||||||
* 华为平台
|
* 华为平台
|
||||||
|
|||||||
@@ -1,8 +1,63 @@
|
|||||||
package com.jsowell.thirdparty.platform.service.impl;
|
package com.jsowell.thirdparty.platform.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
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.thirdparty.BusinessInformationExchangeEnum;
|
||||||
|
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||||
|
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||||
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||||
|
import com.jsowell.common.enums.ykc.StartModeEnum;
|
||||||
|
import com.jsowell.common.exception.BusinessException;
|
||||||
|
import com.jsowell.common.util.DateUtils;
|
||||||
|
import com.jsowell.common.util.JWTUtils;
|
||||||
|
import com.jsowell.common.util.PageUtils;
|
||||||
|
import com.jsowell.common.util.StringUtils;
|
||||||
|
import com.jsowell.pile.domain.AreaCodeInfo;
|
||||||
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
|
import com.jsowell.pile.domain.OrderDetail;
|
||||||
|
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
||||||
|
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||||
|
import com.jsowell.pile.service.*;
|
||||||
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||||
|
import com.jsowell.pile.thirdparty.EquipmentInfo;
|
||||||
|
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||||
|
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||||
|
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||||
|
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
|
||||||
|
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.customer.OrderVO;
|
||||||
|
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||||
|
import com.jsowell.pile.vo.web.PileStationVO;
|
||||||
|
import com.jsowell.thirdparty.lianlian.domain.*;
|
||||||
|
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
|
||||||
|
import com.jsowell.thirdparty.platform.common.ChargeOrderInfo;
|
||||||
|
import com.jsowell.thirdparty.platform.domain.SupChargeDetails;
|
||||||
|
import com.jsowell.thirdparty.platform.domain.SupEquipChargeStatusInfo;
|
||||||
|
import com.jsowell.thirdparty.platform.domain.SupStationInfo;
|
||||||
|
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
|
||||||
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
||||||
|
import com.jsowell.thirdparty.platform.util.Cryptos;
|
||||||
|
import com.jsowell.thirdparty.platform.util.HttpRequestUtil;
|
||||||
|
import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils;
|
||||||
|
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||||
|
import com.yi.business.geo.GeoCodeInfo;
|
||||||
|
import com.yi.business.geo.TermRelationTreeCoordinate;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 广西省平台Service
|
* 广西省平台Service
|
||||||
*
|
*
|
||||||
@@ -11,9 +66,609 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService {
|
public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||||
|
// 平台类型
|
||||||
|
private final String thirdPlatformType = ThirdPlatformTypeEnum.GUANG_XI_PLATFORM.getTypeCode();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PileStationInfoService pileStationInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PileBasicInfoService pileBasicInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PileBillingTemplateService pileBillingTemplateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PileConnectorInfoService pileConnectorInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderBasicInfoService orderBasicInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAreaCodeInfoService areaCodeInfoService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
ThirdPartyPlatformFactory.register(thirdPlatformType, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询令牌 query_token
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> queryToken(CommonParamsDTO dto) {
|
||||||
|
AccessTokenVO vo = new AccessTokenVO();
|
||||||
|
// 0:成功;1:失败
|
||||||
|
int succStat = 0;
|
||||||
|
// 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义
|
||||||
|
int failReason = 0;
|
||||||
|
|
||||||
|
String operatorId = dto.getOperatorID();
|
||||||
|
// token缓存key值
|
||||||
|
String redisKey = operatorId + "_token:";
|
||||||
|
// 通过operatorId 查出 operatorSecret
|
||||||
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuangXiSecretInfo();
|
||||||
|
if (thirdPartySecretInfoVO == null) {
|
||||||
|
failReason = 1;
|
||||||
|
succStat = 1;
|
||||||
|
} else {
|
||||||
|
String ourOperatorSecret = thirdPartySecretInfoVO.getOurOperatorSecret();
|
||||||
|
String dataSecret = thirdPartySecretInfoVO.getOurDataSecret();
|
||||||
|
String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv();
|
||||||
|
// 解密data 获取参数中的OperatorSecret
|
||||||
|
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
|
||||||
|
String inputOperatorSecret = null;
|
||||||
|
if (StringUtils.isNotBlank(decrypt)) {
|
||||||
|
inputOperatorSecret = JSON.parseObject(decrypt).getString("OperatorSecret");
|
||||||
|
}
|
||||||
|
// 对比密钥
|
||||||
|
if (!StringUtils.equals(ourOperatorSecret, inputOperatorSecret)) {
|
||||||
|
failReason = 1;
|
||||||
|
succStat = 1;
|
||||||
|
} else {
|
||||||
|
// 先查缓存中是否有已生成的token
|
||||||
|
String token = redisCache.getCacheObject(redisKey);
|
||||||
|
int expiredTime = (int) redisCache.getExpire(redisKey);
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
// 生成token
|
||||||
|
token = JWTUtils.createToken(operatorId, ourOperatorSecret, JWTUtils.ttlMillis);
|
||||||
|
expiredTime = (int) (JWTUtils.ttlMillis / 1000);
|
||||||
|
}
|
||||||
|
vo.setAccessToken(token);
|
||||||
|
vo.setTokenAvailableTime(expiredTime);
|
||||||
|
// 设置缓存
|
||||||
|
redisCache.setCacheObject(redisKey, token, expiredTime, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 组装返回参数
|
||||||
|
vo.setOperatorID(operatorId);
|
||||||
|
vo.setFailReason(failReason);
|
||||||
|
vo.setSuccStat(succStat);
|
||||||
|
|
||||||
|
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(vo, thirdPartySecretInfoVO.getOurDataSecret()
|
||||||
|
, thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getOurSigSecret());
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询充电站信息 query_stations_info
|
||||||
|
*
|
||||||
|
* @param dto 查询站点信息dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> queryStationsInfo(QueryStationInfoDTO dto) {
|
||||||
|
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
||||||
|
int pageSize = dto.getPageSize() == null ? 50 : dto.getPageSize();
|
||||||
|
dto.setThirdPlatformType(thirdPlatformType);
|
||||||
|
|
||||||
|
PageUtils.startPage(pageNo, pageSize);
|
||||||
|
List<ThirdPartyStationInfoVO> stationInfos = pileStationInfoService.selectStationInfosByThirdParty(dto);
|
||||||
|
if (CollectionUtils.isEmpty(stationInfos)) {
|
||||||
|
// 未查到数据
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuangXiSecretInfo();
|
||||||
|
|
||||||
|
PageInfo<ThirdPartyStationInfoVO> pageInfo = new PageInfo<>(stationInfos);
|
||||||
|
List<SupStationInfo> resultList = new ArrayList<>();
|
||||||
|
for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) {
|
||||||
|
SupStationInfo info = SupStationInfo.builder()
|
||||||
|
.stationID(String.valueOf(pileStationInfo.getId()))
|
||||||
|
.operatorID(Constants.OPERATORID_JIANG_SU)
|
||||||
|
.equipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileStationInfo.getOrganizationCode()))
|
||||||
|
.stationName(pileStationInfo.getStationName())
|
||||||
|
.countryCode(pileStationInfo.getCountryCode())
|
||||||
|
// .areaCode()
|
||||||
|
// .streetCode()
|
||||||
|
.address(pileStationInfo.getAddress())
|
||||||
|
.serviceTel(pileStationInfo.getServiceTel())
|
||||||
|
.stationType(Integer.parseInt(pileStationInfo.getStationType()))
|
||||||
|
.stationStatus(Integer.parseInt(pileStationInfo.getStationStatus()))
|
||||||
|
.parkNums(Integer.parseInt(pileStationInfo.getParkNums()))
|
||||||
|
.stationLng(new BigDecimal(pileStationInfo.getStationLng()))
|
||||||
|
.stationLat(new BigDecimal(pileStationInfo.getStationLat()))
|
||||||
|
.construction(Integer.parseInt(pileStationInfo.getConstruction()))
|
||||||
|
// .electricityFee()
|
||||||
|
// .serviceFee()
|
||||||
|
// .equipmentInfos()
|
||||||
|
.runDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileStationInfo.getCreateTime()))
|
||||||
|
.buildDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileStationInfo.getCreateTime()))
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
JSONObject electricityFee = new JSONObject();
|
||||||
|
JSONObject serviceFee = new JSONObject();
|
||||||
|
// 查询计费模板
|
||||||
|
List<BillingPriceVO> priceList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileStationInfo.getId()));
|
||||||
|
for (BillingPriceVO billingPriceVO : priceList) {
|
||||||
|
electricityFee.put(billingPriceVO.getStartTime() + ":00-" + billingPriceVO.getEndTime() + ":00", billingPriceVO.getElectricityPrice());
|
||||||
|
serviceFee.put(billingPriceVO.getStartTime() + ":00-" + billingPriceVO.getEndTime() + ":00", billingPriceVO.getServicePrice());
|
||||||
|
}
|
||||||
|
info.setElectricityFee(electricityFee.toJSONString());
|
||||||
|
info.setServiceFee(serviceFee.toJSONString());
|
||||||
|
|
||||||
|
// AreaCode
|
||||||
|
String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213
|
||||||
|
// 根据逗号分组
|
||||||
|
String[] split = StringUtils.split(areaCode, ",");
|
||||||
|
// 只取最后一部分 330213
|
||||||
|
String subAreaCode = split[split.length - 1];
|
||||||
|
info.setAreaCode(subAreaCode);
|
||||||
|
|
||||||
|
List<EquipmentInfo> pileList = pileBasicInfoService.getPileListForLianLian(String.valueOf(pileStationInfo.getId()));
|
||||||
|
if (CollectionUtils.isNotEmpty(pileList)) {
|
||||||
|
info.setEquipmentInfos(pileList); // 充电设备信息列表
|
||||||
|
}
|
||||||
|
|
||||||
|
// areaCodeCountryside
|
||||||
|
GeoCodeInfo geoCode = TermRelationTreeCoordinate.completeGeoCode(pileStationInfo.getAddress());
|
||||||
|
if (geoCode == null) {
|
||||||
|
// String areaCodeCountryside = geoCode.getCounty_code();
|
||||||
|
info.setStreetCode("123456789101");
|
||||||
|
} else {
|
||||||
|
AreaCodeInfo areaCodeInfo = new AreaCodeInfo();
|
||||||
|
if (StringUtils.isNotBlank(geoCode.getTownName())) {
|
||||||
|
String townName = geoCode.getTownName();
|
||||||
|
areaCodeInfo.setName(townName);
|
||||||
|
} else {
|
||||||
|
String countyName = geoCode.getCountyName();
|
||||||
|
areaCodeInfo.setName(countyName);
|
||||||
|
}
|
||||||
|
List<AreaCodeInfo> areaCodeInfoList = areaCodeInfoService.selectAreaCodeInfoList(areaCodeInfo);
|
||||||
|
info.setStreetCode(String.valueOf(areaCodeInfoList.get(0).getAreaCode()));
|
||||||
|
}
|
||||||
|
resultList.add(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
map.put("PageNo", pageInfo.getPageNum());
|
||||||
|
map.put("PageCount", pageInfo.getPages());
|
||||||
|
map.put("ItemSize", pageInfo.getTotal());
|
||||||
|
map.put("StationInfos", resultList);
|
||||||
|
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
|
||||||
|
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备接口状态查询接口 query_station_status
|
||||||
|
* @param dto 查询站点信息dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> queryStationStatus(QueryStationInfoDTO dto) {
|
||||||
|
List<String> stationIds = dto.getStationIds();
|
||||||
|
List<StationStatusInfo> stationStatusInfos = new ArrayList<>();
|
||||||
|
List<Object> connectorStatusInfos = new ArrayList<>();
|
||||||
|
// 查询密钥信息
|
||||||
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuangXiSecretInfo();
|
||||||
|
|
||||||
|
// 根据站点idList查询枪口列表
|
||||||
|
List<ConnectorInfoVO> list = pileConnectorInfoService.batchSelectConnectorList(stationIds);
|
||||||
|
// 根据站点id分组
|
||||||
|
Map<String, List<ConnectorInfoVO>> collect = list.stream()
|
||||||
|
.collect(Collectors.groupingBy(ConnectorInfoVO::getStationId));
|
||||||
|
// 封装参数
|
||||||
|
for (Map.Entry<String, List<ConnectorInfoVO>> entry : collect.entrySet()) {
|
||||||
|
String stationId = entry.getKey();
|
||||||
|
List<ConnectorInfoVO> voList = entry.getValue();
|
||||||
|
StationStatusInfo stationStatusInfo = new StationStatusInfo();
|
||||||
|
|
||||||
|
stationStatusInfo.setStationId(stationId);
|
||||||
|
stationStatusInfo.setStationStatus(50); // 50-正常使用
|
||||||
|
ConnectorStatusInfo connectorStatusInfo;
|
||||||
|
for (ConnectorInfoVO connectorInfoVO : voList) {
|
||||||
|
connectorStatusInfo = ConnectorStatusInfo.builder()
|
||||||
|
.connectorID(connectorInfoVO.getPileConnectorCode())
|
||||||
|
.status(Integer.parseInt(connectorInfoVO.getConnectorStatus()))
|
||||||
|
|
||||||
|
.build();
|
||||||
|
connectorStatusInfos.add(connectorStatusInfo);
|
||||||
|
}
|
||||||
|
stationStatusInfo.setConnectorStatusInfos(connectorStatusInfos);
|
||||||
|
|
||||||
|
stationStatusInfos.add(stationStatusInfo);
|
||||||
|
}
|
||||||
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
map.put("StationStatusInfos", stationStatusInfos);
|
||||||
|
|
||||||
|
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
|
||||||
|
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送设备状态变化接口 notification_stationStatus
|
||||||
|
* @param stationId 站点id
|
||||||
|
* @param pileConnectorCode 充电桩枪口编号
|
||||||
|
* @param status
|
||||||
|
* @param secretInfoVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String notificationStationStatus(String stationId, String pileConnectorCode, String status, ThirdPartySecretInfoVO secretInfoVO) {
|
||||||
|
// 查询相关配置信息
|
||||||
|
ThirdPartySecretInfoVO ganSuSecretInfo = getGuangXiSecretInfo();
|
||||||
|
|
||||||
|
String operatorId = Constants.OPERATORID_JIANG_SU;
|
||||||
|
String operatorSecret = ganSuSecretInfo.getTheirOperatorSecret();
|
||||||
|
String signSecret = ganSuSecretInfo.getTheirSigSecret();
|
||||||
|
String dataSecret = ganSuSecretInfo.getTheirDataSecret();
|
||||||
|
String dataSecretIv = ganSuSecretInfo.getTheirDataSecretIv();
|
||||||
|
String urlAddress = ganSuSecretInfo.getTheirUrlPrefix();
|
||||||
|
|
||||||
|
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue();
|
||||||
|
ConnectorStatusInfo info = ConnectorStatusInfo.builder()
|
||||||
|
.connectorID(pileConnectorCode)
|
||||||
|
.status(Integer.parseInt(status))
|
||||||
|
.build();
|
||||||
|
// 调用联联平台接口
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("DataType", Constants.ZERO);
|
||||||
|
json.put("ConnectorStatusInfo", info);
|
||||||
|
String jsonString = JSON.toJSONString(json);
|
||||||
|
// 获取令牌
|
||||||
|
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||||
|
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询统计信息接口 query_station_stats
|
||||||
|
* @param dto 查询站点信息dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> queryStationStats(QueryStationInfoDTO dto) {
|
||||||
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuangXiSecretInfo();
|
||||||
|
// 根据站点id 查出这段时间的充电量
|
||||||
|
List<AccumulativeInfoVO> list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto);
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据充电桩编号分组 key=充电桩编号
|
||||||
|
Map<String, List<AccumulativeInfoVO>> pileMap = list.stream()
|
||||||
|
.collect(Collectors.groupingBy(AccumulativeInfoVO::getPileSn));
|
||||||
|
|
||||||
|
// 存放所有充电桩设备
|
||||||
|
List<EquipmentStatsInfo> equipmentStatsInfoList = Lists.newArrayList();
|
||||||
|
// 站点用电量
|
||||||
|
BigDecimal stationElectricity = BigDecimal.ZERO;
|
||||||
|
int stationChargingTime = Constants.zero;
|
||||||
|
// 用于记录桩充电量 在循环每个枪口的时候初始化
|
||||||
|
BigDecimal pileElec;
|
||||||
|
// 桩充电次数
|
||||||
|
int pileChargingNum;
|
||||||
|
// 桩充电时长
|
||||||
|
int pileChargingTime;
|
||||||
|
for (String pileSn : pileMap.keySet()) {
|
||||||
|
// 该充电桩下 所有枪口的用电数据
|
||||||
|
List<AccumulativeInfoVO> accumulativeInfoVOS = pileMap.get(pileSn);
|
||||||
|
if (CollectionUtils.isEmpty(accumulativeInfoVOS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 存放充电桩用电量
|
||||||
|
pileElec = BigDecimal.ZERO;
|
||||||
|
// 充电桩充电次数
|
||||||
|
pileChargingNum = Constants.zero;
|
||||||
|
// 充电桩充电时长
|
||||||
|
pileChargingTime = Constants.zero;
|
||||||
|
|
||||||
|
// key=枪口编号 value 该枪口的用电数据
|
||||||
|
Map<String, List<AccumulativeInfoVO>> collect = accumulativeInfoVOS.stream()
|
||||||
|
.collect(Collectors.groupingBy(AccumulativeInfoVO::getPileConnectorCode));
|
||||||
|
|
||||||
|
List<ConnectorStatsInfo> connectorStatsInfos = Lists.newArrayList();
|
||||||
|
for (Map.Entry<String, List<AccumulativeInfoVO>> entry : collect.entrySet()) {
|
||||||
|
String pileConnectorCode = entry.getKey();
|
||||||
|
List<AccumulativeInfoVO> value = entry.getValue();
|
||||||
|
// 枪口用电量求和
|
||||||
|
BigDecimal connectorElec = value.stream()
|
||||||
|
.map(AccumulativeInfoVO::getConnectorElectricity)
|
||||||
|
.map(BigDecimal::new)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
// 充电时长求和
|
||||||
|
BigDecimal chargingTime = value.stream()
|
||||||
|
.map(AccumulativeInfoVO::getChargingTime)
|
||||||
|
.map(BigDecimal::new)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|
||||||
|
// 充电次数
|
||||||
|
long chargingNumLong = accumulativeInfoVOS.stream()
|
||||||
|
.map(x -> x.getPileConnectorCode().equals(pileConnectorCode))
|
||||||
|
.count();
|
||||||
|
int chargingNum = Integer.parseInt(String.valueOf(chargingNumLong));
|
||||||
|
|
||||||
|
connectorStatsInfos.add(
|
||||||
|
ConnectorStatsInfo.builder()
|
||||||
|
.connectorID(pileConnectorCode)
|
||||||
|
.connectorElectricity(connectorElec)
|
||||||
|
.connectorDuration(chargingTime.intValue())
|
||||||
|
.connectorNum(chargingNum)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
// 充电桩电量为枪口用电量累计
|
||||||
|
pileElec = pileElec.add(connectorElec);
|
||||||
|
// 充电桩充电次数为枪口充电次数累计
|
||||||
|
pileChargingNum += chargingNum;
|
||||||
|
// 充电时长
|
||||||
|
pileChargingTime += chargingTime.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
EquipmentStatsInfo build = EquipmentStatsInfo.builder()
|
||||||
|
.equipmentID(pileSn)
|
||||||
|
.equipmentElectricity(pileElec)
|
||||||
|
.connectorDuration(pileChargingTime)
|
||||||
|
.connectorNum(pileChargingNum)
|
||||||
|
.connectorStatsInfos(connectorStatsInfos)
|
||||||
|
.build();
|
||||||
|
equipmentStatsInfoList.add(build);
|
||||||
|
|
||||||
|
// 所有充电桩用电量之和
|
||||||
|
stationElectricity = stationElectricity.add(pileElec);
|
||||||
|
// 充电时长
|
||||||
|
stationChargingTime += pileChargingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
StationStatsInfo stationStatsInfo = StationStatsInfo.builder()
|
||||||
|
.stationID(dto.getStationID())
|
||||||
|
.startTime(dto.getStartTime())
|
||||||
|
.endTime(dto.getEndTime())
|
||||||
|
.stationElectricity(stationElectricity)
|
||||||
|
.connectorDuration(stationChargingTime)
|
||||||
|
.connectorNum(list.size())
|
||||||
|
.equipmentStatsInfos(equipmentStatsInfoList) // 设备列表
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
map.put("StationStats", stationStatsInfo);
|
||||||
|
|
||||||
|
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
|
||||||
|
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送已完成订单信息接口 notification_charge_order_info
|
||||||
|
* @param orderCode
|
||||||
|
* @param secretInfoVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) {
|
||||||
|
// 根据订单号查询出信息
|
||||||
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||||
|
if (orderBasicInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String operatorId = Constants.OPERATORID_JIANG_SU;
|
||||||
|
String operatorSecret = secretInfoVO.getTheirOperatorSecret();
|
||||||
|
String signSecret = secretInfoVO.getTheirSigSecret();
|
||||||
|
String dataSecret = secretInfoVO.getTheirDataSecret();
|
||||||
|
String dataSecretIv = secretInfoVO.getTheirDataSecretIv();
|
||||||
|
String urlAddress = secretInfoVO.getTheirUrlPrefix();
|
||||||
|
|
||||||
|
// 推送地址
|
||||||
|
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue();
|
||||||
|
|
||||||
|
// 根据订单号查询订单详情
|
||||||
|
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||||||
|
if (orderDetail == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder()
|
||||||
|
.startChargeSeq(orderCode)
|
||||||
|
// .startChargeType()
|
||||||
|
.connectorId(orderBasicInfo.getPileConnectorCode())
|
||||||
|
.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())
|
||||||
|
// .totalElecMoney(orderDetail.getTotalElectricityAmount())
|
||||||
|
// .totalSeviceMoney(orderDetail.getTotalServiceAmount())
|
||||||
|
.elecMoney(orderDetail.getTotalElectricityAmount())
|
||||||
|
.seviceMoney(orderDetail.getTotalServiceAmount())
|
||||||
|
.totalMoney(orderDetail.getTotalOrderAmount())
|
||||||
|
|
||||||
|
.build();
|
||||||
|
// startChargeType
|
||||||
|
String startMode = orderBasicInfo.getStartMode();
|
||||||
|
if (StringUtils.equals(StartModeEnum.AUTH_CARD.getValue(), startMode)
|
||||||
|
|| StringUtils.equals(StartModeEnum.OFFLINE_CARD.getValue(), startMode)) {
|
||||||
|
chargeOrderInfo.setStartChargeType(3); // 3-卡启动
|
||||||
|
}else {
|
||||||
|
chargeOrderInfo.setStartChargeType(Constants.one);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取令牌
|
||||||
|
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调用平台接口
|
||||||
|
String jsonString = JSON.toJSONString(chargeOrderInfo);
|
||||||
|
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询已完成订单列表信息接口 query_finish_orders
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> queryFinishOrders(QueryStartChargeDTO dto) {
|
||||||
|
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
||||||
|
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||||
|
List<ChargeOrderInfo> orderInfos = new ArrayList<>();
|
||||||
|
|
||||||
|
PageUtils.startPage(pageNo, pageSize);
|
||||||
|
List<OrderVO> orderVOS = orderBasicInfoService.selectThirdPartyOrderList(dto);
|
||||||
|
|
||||||
|
PageInfo<OrderVO> pageInfo = new PageInfo<>(orderVOS);
|
||||||
|
|
||||||
|
for (OrderVO orderVO : pageInfo.getList()) {
|
||||||
|
ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder()
|
||||||
|
.startChargeSeq(orderVO.getOrderCode())
|
||||||
|
// .startChargeType()
|
||||||
|
.connectorId(orderVO.getPileConnectorCode())
|
||||||
|
.startTime(orderVO.getStartTime())
|
||||||
|
.endTime(orderVO.getStartTime())
|
||||||
|
.totalPower(new BigDecimal(orderVO.getTotalPower()))
|
||||||
|
.elecMoney(orderVO.getTotalElectricityAmount())
|
||||||
|
.seviceMoney(orderVO.getTotalServiceAmount())
|
||||||
|
.totalMoney(orderVO.getOrderAmount())
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// startChargeType
|
||||||
|
String startMode = orderVO.getStartMode();
|
||||||
|
if (StringUtils.equals(StartModeEnum.AUTH_CARD.getValue(), startMode)
|
||||||
|
|| StringUtils.equals(StartModeEnum.OFFLINE_CARD.getValue(), startMode)) {
|
||||||
|
chargeOrderInfo.setStartChargeType(3); // 3-卡启动
|
||||||
|
}else {
|
||||||
|
chargeOrderInfo.setStartChargeType(Constants.one);
|
||||||
|
}
|
||||||
|
|
||||||
|
orderInfos.add(chargeOrderInfo);
|
||||||
|
}
|
||||||
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuangXiSecretInfo();
|
||||||
|
|
||||||
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
map.put("PageNo", pageInfo.getPageNum());
|
||||||
|
map.put("PageCount", pageInfo.getPages());
|
||||||
|
map.put("ItemSize", pageInfo.getTotal());
|
||||||
|
map.put("ChargeOrders", orderInfos);
|
||||||
|
map.put("LastQueryTime", dto.getLastQueryTime());
|
||||||
|
map.put("LastQueryEndTime", dto.getLastQueryEndTime());
|
||||||
|
|
||||||
|
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
|
||||||
|
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* 推送充电状态接口 notification_equip_charge_status
|
||||||
|
* @param orderCode 订单编号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String notificationEquipChargeStatus(String orderCode) {
|
||||||
|
// 根据订单号查询订单信息
|
||||||
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||||
|
// 查询相关配置信息
|
||||||
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuangXiSecretInfo();
|
||||||
|
|
||||||
|
String operatorId = Constants.OPERATORID_JIANG_SU;
|
||||||
|
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
|
||||||
|
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
|
||||||
|
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
|
||||||
|
String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv();
|
||||||
|
String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
|
||||||
|
|
||||||
|
// 查询枪口实时状态
|
||||||
|
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode());
|
||||||
|
RealTimeMonitorData realTimeMonitorData;
|
||||||
|
if (CollectionUtils.isEmpty(chargingRealTimeData)) {
|
||||||
|
realTimeMonitorData = RealTimeMonitorData.builder()
|
||||||
|
.chargingDegree(Constants.ZERO)
|
||||||
|
.connectorStatus("3")
|
||||||
|
.build();
|
||||||
|
chargingRealTimeData.add(realTimeMonitorData);
|
||||||
|
} else {
|
||||||
|
realTimeMonitorData = chargingRealTimeData.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询枪口状态
|
||||||
|
PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
|
||||||
|
if (Objects.isNull(info)) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
String orderStatus = orderInfo.getOrderStatus();
|
||||||
|
if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) {
|
||||||
|
// 充电中
|
||||||
|
orderStatus = "2";
|
||||||
|
} else if (StringUtils.equals(OrderStatusEnum.ORDER_COMPLETE.getValue(), orderStatus)) {
|
||||||
|
// 充电完成
|
||||||
|
orderStatus = "4";
|
||||||
|
}
|
||||||
|
BigDecimal current = realTimeMonitorData.getOutputCurrent() == null ? BigDecimal.ZERO : info.getCurrent();
|
||||||
|
BigDecimal voltage = realTimeMonitorData.getOutputVoltage() == null ? BigDecimal.ZERO : info.getVoltage();
|
||||||
|
String soc = realTimeMonitorData.getSOC() == null ? Constants.ZERO : info.getSOC();
|
||||||
|
|
||||||
|
String dateTime = DateUtils.getDateTime();
|
||||||
|
SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder()
|
||||||
|
.startChargeSeq(orderInfo.getOrderCode())
|
||||||
|
.startChargeSeqStat(Integer.parseInt(orderStatus))
|
||||||
|
.connectorID(orderInfo.getPileConnectorCode())
|
||||||
|
.connectorStatus(Integer.parseInt(realTimeMonitorData.getConnectorStatus())) // 3-充电中
|
||||||
|
.currentA(current.setScale(1, RoundingMode.HALF_UP))
|
||||||
|
.voltageA(voltage.setScale(1, RoundingMode.HALF_UP))
|
||||||
|
.soc(new BigDecimal(soc))
|
||||||
|
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime()))
|
||||||
|
.endTime(dateTime)
|
||||||
|
.totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree()))
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue();
|
||||||
|
// 调用平台接口
|
||||||
|
String jsonString = JSON.toJSONString(supEquipChargeStatusInfo);
|
||||||
|
|
||||||
|
// 获取令牌
|
||||||
|
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||||
|
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取广西平台密钥信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ThirdPartySecretInfoVO getGuangXiSecretInfo() {
|
||||||
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType);
|
||||||
|
if (thirdPartySecretInfoVO == null) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
||||||
|
}
|
||||||
|
thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU);
|
||||||
|
return thirdPartySecretInfoVO;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user