mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 03:09:48 +08:00
update 海南平台对接
This commit is contained in:
@@ -3,6 +3,7 @@ package com.jsowell.common.util;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
@@ -19,27 +20,13 @@ import java.util.Base64;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class AdapayUtil {
|
public class AdapayUtil {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String amount = "1110.5309";
|
|
||||||
String s = formatAmount(amount);
|
|
||||||
System.out.println(s);
|
|
||||||
|
|
||||||
BigDecimal bigDecimal = new BigDecimal(amount);
|
|
||||||
String s2 = formatAmount(bigDecimal);
|
|
||||||
System.out.println(s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化数字 保留两位小数,不足补0
|
* 格式化数字 保留两位小数,不足补0
|
||||||
* @param amount
|
* @param amount
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String formatAmount(String amount) {
|
public static String formatAmount(String amount) {
|
||||||
//保留2位小数
|
return formatAmount(new BigDecimal(amount));
|
||||||
double d = new BigDecimal(amount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
||||||
//不足两位则补0
|
|
||||||
DecimalFormat decimalFormat = new DecimalFormat("0.00#");
|
|
||||||
return decimalFormat.format(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,7 +35,34 @@ public class AdapayUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String formatAmount(BigDecimal amount) {
|
public static String formatAmount(BigDecimal amount) {
|
||||||
return formatAmount(amount.toString());
|
return formatAmount(amount, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化数字 保留n位小数,不足补0
|
||||||
|
* @param amount
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String formatAmount(BigDecimal amount, int n) {
|
||||||
|
//保留2位小数
|
||||||
|
double d = amount.setScale(n, RoundingMode.DOWN).doubleValue();
|
||||||
|
//不足则补0
|
||||||
|
StringBuilder pattern = new StringBuilder("0");
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (i == 0) {
|
||||||
|
pattern.append(".");
|
||||||
|
}
|
||||||
|
pattern.append("0");
|
||||||
|
}
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat(pattern.toString());
|
||||||
|
return decimalFormat.format(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
BigDecimal bigDecimal = new BigDecimal("1236.8369");
|
||||||
|
System.out.println(formatAmount(bigDecimal, 0));
|
||||||
|
System.out.println(formatAmount(bigDecimal, 2));
|
||||||
|
System.out.println(formatAmount(bigDecimal, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,12 +3,9 @@ package com.jsowell.thirdparty.platform.hainan.domain;
|
|||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import com.jsowell.thirdparty.zhongdianlian.domain.ZDLStationInfo;
|
import com.jsowell.thirdparty.zhongdianlian.domain.ZDLStationInfo;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*
|
*
|
||||||
@@ -20,12 +17,6 @@ import java.util.List;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class HNStationInfo extends ZDLStationInfo {
|
public class HNStationInfo extends ZDLStationInfo {
|
||||||
|
|
||||||
/**
|
|
||||||
* 站点照片
|
|
||||||
*/
|
|
||||||
@JSONField(name = "Pictures")
|
|
||||||
private List<String> pictures;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电费描述
|
* 电费描述
|
||||||
*/
|
*/
|
||||||
@@ -38,10 +29,4 @@ public class HNStationInfo extends ZDLStationInfo {
|
|||||||
@JSONField(name = "ServiceFee")
|
@JSONField(name = "ServiceFee")
|
||||||
private String serviceFee;
|
private String serviceFee;
|
||||||
|
|
||||||
/**
|
|
||||||
* 停车费描述
|
|
||||||
*/
|
|
||||||
@JSONField(name = "ParkFee")
|
|
||||||
private String parkFee;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,21 +12,21 @@ import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
|
|||||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||||
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||||
|
import com.jsowell.common.util.AdapayUtil;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.PageUtils;
|
import com.jsowell.common.util.PageUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.*;
|
import com.jsowell.pile.domain.*;
|
||||||
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
||||||
import com.jsowell.pile.domain.ykcCommond.StopChargingCommand;
|
import com.jsowell.pile.domain.ykcCommond.StopChargingCommand;
|
||||||
import com.jsowell.pile.dto.QueryEquipChargeStatusDTO;
|
import com.jsowell.pile.dto.*;
|
||||||
import com.jsowell.pile.dto.QueryEquipmentDTO;
|
|
||||||
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
|
||||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
|
||||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||||
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.base.ThirdPartyStationRelationVO;
|
||||||
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
||||||
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||||
|
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||||
|
import com.jsowell.pile.vo.web.EchoBillingTemplateVO;
|
||||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||||
import com.jsowell.pile.vo.web.PileStationVO;
|
import com.jsowell.pile.vo.web.PileStationVO;
|
||||||
import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO;
|
import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO;
|
||||||
@@ -41,8 +41,8 @@ import com.jsowell.thirdparty.lianlian.vo.QueryStartChargeVO;
|
|||||||
import com.jsowell.thirdparty.lianlian.vo.QueryStopChargeVO;
|
import com.jsowell.thirdparty.lianlian.vo.QueryStopChargeVO;
|
||||||
import com.jsowell.thirdparty.platform.AbsInterfaceWithPlatformLogic;
|
import com.jsowell.thirdparty.platform.AbsInterfaceWithPlatformLogic;
|
||||||
import com.jsowell.thirdparty.platform.InterfaceWithPlatformLogicFactory;
|
import com.jsowell.thirdparty.platform.InterfaceWithPlatformLogicFactory;
|
||||||
|
import com.jsowell.thirdparty.platform.hainan.domain.HNStationInfo;
|
||||||
import com.jsowell.thirdparty.zhongdianlian.domain.ZDLEquipmentInfo;
|
import com.jsowell.thirdparty.zhongdianlian.domain.ZDLEquipmentInfo;
|
||||||
import com.jsowell.thirdparty.zhongdianlian.domain.ZDLStationInfo;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -83,7 +83,6 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ZDLStationInfo> resultList = new ArrayList<>();
|
|
||||||
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
||||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||||
|
|
||||||
@@ -98,15 +97,18 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PageInfo<ThirdPartyStationInfoVO> pageInfo = new PageInfo<>(stationInfos);
|
PageInfo<ThirdPartyStationInfoVO> pageInfo = new PageInfo<>(stationInfos);
|
||||||
|
List<HNStationInfo> resultList = new ArrayList<>();
|
||||||
|
HNStationInfo stationInfo = null;
|
||||||
for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) {
|
for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) {
|
||||||
ZDLStationInfo stationInfo = new ZDLStationInfo();
|
stationInfo = new HNStationInfo();
|
||||||
stationInfo.setStationId(String.valueOf(pileStationInfo.getId()));
|
String stationId = String.valueOf(pileStationInfo.getId());
|
||||||
|
stationInfo.setStationId(stationId);
|
||||||
stationInfo.setOperatorId(Constants.OPERATORID_JIANG_SU); // 组织机构代码
|
stationInfo.setOperatorId(Constants.OPERATORID_JIANG_SU); // 组织机构代码
|
||||||
String organizationCode = pileStationInfo.getOrganizationCode();
|
String organizationCode = pileStationInfo.getOrganizationCode();
|
||||||
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
|
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
|
||||||
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
|
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
|
||||||
stationInfo.setEquipmentOwnerId(equipmentOwnerId);
|
stationInfo.setEquipmentOwnerId(equipmentOwnerId);
|
||||||
}else {
|
} else {
|
||||||
stationInfo.setEquipmentOwnerId(Constants.OPERATORID_JIANG_SU);
|
stationInfo.setEquipmentOwnerId(Constants.OPERATORID_JIANG_SU);
|
||||||
}
|
}
|
||||||
stationInfo.setStationName(pileStationInfo.getStationName());
|
stationInfo.setStationName(pileStationInfo.getStationName());
|
||||||
@@ -138,6 +140,13 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
if (CollectionUtils.isNotEmpty(pileList)) {
|
if (CollectionUtils.isNotEmpty(pileList)) {
|
||||||
stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表
|
stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, String> priceDescription = getPriceDescription(stationId);
|
||||||
|
// 充电费描述
|
||||||
|
stationInfo.setElectricityFee(priceDescription.get("electricityFee"));
|
||||||
|
// 服务费描述
|
||||||
|
stationInfo.setServiceFee(priceDescription.get("serviceFee"));
|
||||||
|
|
||||||
resultList.add(stationInfo);
|
resultList.add(stationInfo);
|
||||||
}
|
}
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
@@ -160,6 +169,59 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, String> getPriceDescription(String stationId) {
|
||||||
|
Map<String, String> resultMap = Maps.newHashMap();
|
||||||
|
StringBuilder electricityFee = new StringBuilder("电费:");
|
||||||
|
StringBuilder serviceFee = new StringBuilder("服务费:");
|
||||||
|
|
||||||
|
// 查询站点当前使用的计费模板
|
||||||
|
BillingTemplateVO billingTemplate = pileBillingTemplateService.queryUsedBillingTemplate(stationId);
|
||||||
|
if (billingTemplate == null) {
|
||||||
|
resultMap.put("electricityFee", electricityFee.toString());
|
||||||
|
resultMap.put("serviceFee", serviceFee.toString());
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
EchoBillingTemplateVO echoBillingTemplateVO = pileBillingTemplateService.queryPileBillingTemplateById(Long.parseLong(billingTemplate.getTemplateId()));
|
||||||
|
if (echoBillingTemplateVO == null) {
|
||||||
|
resultMap.put("electricityFee", electricityFee.toString());
|
||||||
|
resultMap.put("serviceFee", serviceFee.toString());
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<BillingTimeDTO> timeArray = echoBillingTemplateVO.getTimeArray();
|
||||||
|
for (BillingTimeDTO billingTimeDTO : timeArray) {
|
||||||
|
String type = billingTimeDTO.getType();
|
||||||
|
String startTime = billingTimeDTO.getStartTime();
|
||||||
|
String endTime = billingTimeDTO.getEndTime();
|
||||||
|
|
||||||
|
BigDecimal electricityPrice;
|
||||||
|
BigDecimal servicePrice;
|
||||||
|
if (StringUtils.equals(type, "1")) {
|
||||||
|
electricityPrice = echoBillingTemplateVO.getElectricityPriceA();
|
||||||
|
servicePrice = echoBillingTemplateVO.getServicePriceA();
|
||||||
|
} else if (StringUtils.equals(type, "2")) {
|
||||||
|
electricityPrice = echoBillingTemplateVO.getElectricityPriceB();
|
||||||
|
servicePrice = echoBillingTemplateVO.getServicePriceB();
|
||||||
|
} else if (StringUtils.equals(type, "3")) {
|
||||||
|
electricityPrice = echoBillingTemplateVO.getElectricityPriceC();
|
||||||
|
servicePrice = echoBillingTemplateVO.getServicePriceC();
|
||||||
|
} else {
|
||||||
|
electricityPrice = echoBillingTemplateVO.getElectricityPriceD();
|
||||||
|
servicePrice = echoBillingTemplateVO.getServicePriceD();
|
||||||
|
}
|
||||||
|
|
||||||
|
electricityFee.append(startTime).append("~").append(endTime).append(":").append(AdapayUtil.formatAmount(electricityPrice, 4)).append(",");
|
||||||
|
serviceFee.append(startTime).append("~").append(endTime).append(":").append(AdapayUtil.formatAmount(servicePrice, 4)).append(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
electricityFee.deleteCharAt(electricityFee.length() - 1);
|
||||||
|
serviceFee.deleteCharAt(serviceFee.length() - 1);
|
||||||
|
|
||||||
|
resultMap.put("electricityFee", electricityFee.toString());
|
||||||
|
resultMap.put("serviceFee", serviceFee.toString());
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 6.3 设备状态变化推送
|
* 6.3 设备状态变化推送
|
||||||
*
|
*
|
||||||
@@ -261,7 +323,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
}
|
}
|
||||||
ConnectorStatusInfo connectorStatusInfo;
|
ConnectorStatusInfo connectorStatusInfo;
|
||||||
for (String stationId : stationIds) {
|
for (String stationId : stationIds) {
|
||||||
StationStatusInfo stationStatusInfo= new StationStatusInfo();
|
StationStatusInfo stationStatusInfo = new StationStatusInfo();
|
||||||
stationStatusInfo.setStationId(stationId);
|
stationStatusInfo.setStationId(stationId);
|
||||||
// 根据站点id查询
|
// 根据站点id查询
|
||||||
List<ConnectorInfoVO> list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId));
|
List<ConnectorInfoVO> list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId));
|
||||||
@@ -276,7 +338,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
|
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
|
||||||
if(CollectionUtils.isNotEmpty(chargingRealTimeData)) {
|
if (CollectionUtils.isNotEmpty(chargingRealTimeData)) {
|
||||||
RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0);
|
RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0);
|
||||||
|
|
||||||
info.setStartChargeSeq(orderBasicInfo.getOrderCode());
|
info.setStartChargeSeq(orderBasicInfo.getOrderCode());
|
||||||
@@ -612,6 +674,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求开始充电
|
* 请求开始充电
|
||||||
|
*
|
||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -707,7 +770,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) {
|
if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) {
|
||||||
// 充电中
|
// 充电中
|
||||||
orderStatus = "2";
|
orderStatus = "2";
|
||||||
}else if (StringUtils.equals(orderStatus, OrderStatusEnum.ORDER_COMPLETE.getValue())) {
|
} else if (StringUtils.equals(orderStatus, OrderStatusEnum.ORDER_COMPLETE.getValue())) {
|
||||||
// 充电完成
|
// 充电完成
|
||||||
orderStatus = "4";
|
orderStatus = "4";
|
||||||
} else {
|
} else {
|
||||||
@@ -720,7 +783,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
// 查询当前枪口状态
|
// 查询当前枪口状态
|
||||||
PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
|
PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
|
||||||
connectorStatus = connectorInfoVO.getStatus();
|
connectorStatus = connectorInfoVO.getStatus();
|
||||||
}else {
|
} else {
|
||||||
connectorStatus = Integer.parseInt(status);
|
connectorStatus = Integer.parseInt(status);
|
||||||
}
|
}
|
||||||
BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount();
|
BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount();
|
||||||
@@ -957,7 +1020,6 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送充电订单对账信息
|
* 推送充电订单对账信息
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> checkChargeOrders() {
|
public Map<String, String> checkChargeOrders() {
|
||||||
|
|||||||
Reference in New Issue
Block a user