mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-10 10:19:54 +08:00
update 新电途平台Service
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,8 +47,8 @@ public class XDTController extends ThirdPartyBaseController {
|
|||||||
@Qualifier("xinDiantuPlatfromServiceImpl")
|
@Qualifier("xinDiantuPlatfromServiceImpl")
|
||||||
private ThirdPartyPlatformService platformLogic;
|
private ThirdPartyPlatformService platformLogic;
|
||||||
|
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private XDTService xdtService;
|
private XDTService xdtService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取token接口
|
* 获取token接口
|
||||||
@@ -372,23 +373,52 @@ public class XDTController extends ThirdPartyBaseController {
|
|||||||
* @param orderCode
|
* @param orderCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// @GetMapping("/pushChargeOrderInfo/{orderCode}")
|
@GetMapping("/pushChargeOrderInfo/{orderCode}")
|
||||||
// public RestApiResponse<?> pushChargeOrderInfo(@PathVariable("orderCode") String orderCode) {
|
public RestApiResponse<?> pushChargeOrderInfo(@PathVariable("orderCode") String orderCode) {
|
||||||
// logger.info("新电途平台推送充电订单信息 params:{}", orderCode);
|
logger.info("新电途平台推送充电订单信息 params:{}", orderCode);
|
||||||
// RestApiResponse<?> response = null;
|
RestApiResponse<?> response = null;
|
||||||
// try {
|
try {
|
||||||
// String result = xdtService.pushChargeOrderInfo(orderCode);
|
// String result = xdtService.pushChargeOrderInfo(orderCode);
|
||||||
// response = new RestApiResponse<>(result);
|
String result = platformLogic.notificationChargeOrderInfo(orderCode);
|
||||||
// }catch (BusinessException e) {
|
response = new RestApiResponse<>(result);
|
||||||
// logger.error("新电途平台推送充电订单信息 error",e);
|
}catch (BusinessException e) {
|
||||||
// response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
logger.error("新电途平台推送充电订单信息 error",e);
|
||||||
// }catch (Exception e) {
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||||
// logger.error("新电途平台推送充电订单信息 error", e);
|
}catch (Exception e) {
|
||||||
// response = new RestApiResponse<>(e);
|
logger.error("新电途平台推送充电订单信息 error", e);
|
||||||
// }
|
response = new RestApiResponse<>(e);
|
||||||
// logger.info("新电途平台推送充电订单信息 result:{}", response);
|
}
|
||||||
// return response;
|
logger.info("新电途平台推送充电订单信息 result:{}", response);
|
||||||
// }
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量推送订单接口
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/pushChargeOrderInfoList")
|
||||||
|
public RestApiResponse<?> pushChargeOrderInfoList(@RequestBody PushInfoParamDTO dto) {
|
||||||
|
logger.info("新电途平台批量推送充电订单信息 params:{}", JSON.toJSONString(dto));
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
List<String> orderCodeList = dto.getOrderCodeList();
|
||||||
|
for (String orderCode : orderCodeList) {
|
||||||
|
String result = platformLogic.notificationChargeOrderInfo(orderCode);
|
||||||
|
logger.info("新电途平台批量推送充电订单信息 result:{}", result);
|
||||||
|
}
|
||||||
|
response = new RestApiResponse<>();
|
||||||
|
}catch (BusinessException e) {
|
||||||
|
logger.error("新电途平台批量推送充电订单信息 error",e);
|
||||||
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("新电途平台批量推送充电订单信息 error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
|
}
|
||||||
|
logger.info("新电途平台批量推送充电订单信息 result:{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新电途推送充电状态
|
* 新电途推送充电状态
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package com.jsowell.pile.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 练练平台推送信息参数DTO
|
* 平台推送信息参数DTO
|
||||||
*
|
*
|
||||||
* @author JS-ZZA
|
* @author JS-ZZA
|
||||||
* @date 2023/5/26 9:26
|
* @date 2023/5/26 9:26
|
||||||
@@ -15,4 +17,6 @@ public class PushInfoParamDTO {
|
|||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
private String stationId;
|
private String stationId;
|
||||||
|
|
||||||
|
private List<String> orderCodeList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,7 @@ import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
|||||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.*;
|
import com.jsowell.common.util.*;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.*;
|
||||||
import com.jsowell.pile.domain.OrderDetail;
|
|
||||||
import com.jsowell.pile.domain.PileBasicInfo;
|
|
||||||
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
|
||||||
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
||||||
import com.jsowell.pile.dto.*;
|
import com.jsowell.pile.dto.*;
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
@@ -27,6 +24,7 @@ import com.jsowell.pile.thirdparty.EquipmentInfo;
|
|||||||
import com.jsowell.pile.util.MerchantUtils;
|
import com.jsowell.pile.util.MerchantUtils;
|
||||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||||
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
|
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
|
||||||
|
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
|
||||||
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
||||||
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
|
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
|
||||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||||
@@ -46,15 +44,17 @@ 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.*;
|
import com.jsowell.thirdparty.platform.util.*;
|
||||||
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||||
|
import com.jsowell.thirdparty.yongchengboche.dto.YCBCGetTokenDTO;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.bouncycastle.crypto.CryptoException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.LinkedHashMap;
|
import java.security.NoSuchProviderException;
|
||||||
import java.util.List;
|
import java.security.spec.InvalidKeySpecException;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -497,15 +497,14 @@ public class XinDiantuPlatfromServiceImpl implements ThirdPartyPlatformService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送充电订单信息
|
* 推送充电订单信息
|
||||||
* supervise_notification_charge_order_info
|
* notification_charge_order_info
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) {
|
public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) {
|
||||||
// 根据订单号查询出信息
|
|
||||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||||
if (orderBasicInfo == null) {
|
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||||||
return null;
|
|
||||||
}
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinDiantuPlatformSecretInfo();
|
||||||
|
|
||||||
String operatorId = Constants.OPERATORID_JIANG_SU;
|
String operatorId = Constants.OPERATORID_JIANG_SU;
|
||||||
String operatorSecret = secretInfoVO.getTheirOperatorSecret();
|
String operatorSecret = secretInfoVO.getTheirOperatorSecret();
|
||||||
@@ -514,47 +513,79 @@ public class XinDiantuPlatfromServiceImpl implements ThirdPartyPlatformService {
|
|||||||
String dataSecretIv = secretInfoVO.getTheirDataSecretIv();
|
String dataSecretIv = secretInfoVO.getTheirDataSecretIv();
|
||||||
String urlAddress = secretInfoVO.getTheirUrlPrefix();
|
String urlAddress = secretInfoVO.getTheirUrlPrefix();
|
||||||
|
|
||||||
// 根据订单号查询订单详情
|
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue();
|
||||||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
Date chargeStartTime = orderBasicInfo.getChargeStartTime();
|
||||||
if (orderDetail == null) {
|
if (chargeStartTime == null) {
|
||||||
return null;
|
chargeStartTime = orderBasicInfo.getCreateTime();
|
||||||
|
}
|
||||||
|
Date chargeEndTime = orderBasicInfo.getChargeEndTime();
|
||||||
|
if (chargeEndTime == null) {
|
||||||
|
chargeEndTime = orderBasicInfo.getCreateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 推送地址
|
JSONObject json = new JSONObject();
|
||||||
String url = urlAddress + "supervise_notification_charge_order_info";
|
json.put("StartChargeSeq", orderCode);
|
||||||
|
json.put("ConnectorID", orderBasicInfo.getPileConnectorCode());
|
||||||
|
json.put("StartTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeStartTime));
|
||||||
|
json.put("EndTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeEndTime));
|
||||||
|
json.put("TotalPower", orderDetail.getTotalUsedElectricity().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
json.put("TotalElecMoney", orderDetail.getTotalElectricityAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
json.put("TotalSeviceMoney", orderDetail.getTotalServiceAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
json.put("TotalMoney", orderDetail.getTotalOrderAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
json.put("StopReason", 2); // 2:BMS 停止充电
|
||||||
|
|
||||||
// 拼装成平台所需格式对象
|
String jsonString = JSON.toJSONString(json);
|
||||||
ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail);
|
|
||||||
orderInfo.setOperatorID(operatorId);
|
|
||||||
String equipmentOwnerID;
|
|
||||||
if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) {
|
|
||||||
equipmentOwnerID = Constants.OPERATORID_XI_XIAO;
|
|
||||||
} else {
|
|
||||||
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationID());
|
|
||||||
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
|
|
||||||
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
|
|
||||||
equipmentOwnerID = ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileMerchantInfoVO.getOrganizationCode());
|
|
||||||
} else {
|
|
||||||
equipmentOwnerID = Constants.OPERATORID_JIANG_SU;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
orderInfo.setEquipmentOwnerID(equipmentOwnerID);
|
|
||||||
|
|
||||||
List<BillingPriceVO> billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId());
|
|
||||||
// 先将list按照 尖、峰、平、谷 时段排序
|
|
||||||
// List<BillingPriceVO> collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList());
|
|
||||||
// 再循环该list,拼装对应的充电价格、费率
|
|
||||||
List<SupChargeDetails> chargeDetails = transformSupChargeDetails(orderDetail, billingList);
|
|
||||||
orderInfo.setChargeDetails(chargeDetails);
|
|
||||||
|
|
||||||
// 获取令牌
|
// 获取令牌
|
||||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||||
if (StringUtils.isBlank(token)) {
|
// 发送请求
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// 调用联联平台接口
|
|
||||||
String jsonString = JSON.toJSONString(orderInfo);
|
|
||||||
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String notificationChargeOrderInfo(String orderCode) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException, CryptoException {
|
||||||
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||||
|
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||||||
|
|
||||||
|
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinDiantuPlatformSecretInfo();
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue();
|
||||||
|
Date chargeStartTime = orderBasicInfo.getChargeStartTime();
|
||||||
|
if (chargeStartTime == null) {
|
||||||
|
chargeStartTime = orderBasicInfo.getCreateTime();
|
||||||
|
}
|
||||||
|
Date chargeEndTime = orderBasicInfo.getChargeEndTime();
|
||||||
|
if (chargeEndTime == null) {
|
||||||
|
chargeEndTime = orderBasicInfo.getCreateTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("StartChargeSeq", orderCode);
|
||||||
|
json.put("ConnectorID", orderBasicInfo.getPileConnectorCode());
|
||||||
|
json.put("StartTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeStartTime));
|
||||||
|
json.put("EndTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeEndTime));
|
||||||
|
json.put("TotalPower", orderDetail.getTotalUsedElectricity().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
json.put("TotalElecMoney", orderDetail.getTotalElectricityAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
json.put("TotalSeviceMoney", orderDetail.getTotalServiceAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
json.put("TotalMoney", orderDetail.getTotalOrderAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
json.put("StopReason", 2); // 2:BMS 停止充电
|
||||||
|
|
||||||
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user