This commit is contained in:
Lemon
2024-03-26 15:35:16 +08:00
28 changed files with 1434 additions and 198 deletions

View File

@@ -40,6 +40,7 @@ import com.jsowell.pile.dto.PayOrderDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cglib.beans.BeanMap;
@@ -88,10 +89,10 @@ public class AdapayService {
// log.info("===============使用汇付支付-获取支付参数");
// 相同参数重复请求,返回同一个支付对象
String redisKey = CacheConstants.ADAPAY_ORDER_PARAM + dto.getOrderCode();
Map<String, Object> cacheObject = redisCache.getCacheObject(redisKey);
if (cacheObject != null) {
Map<String, Object> resultMap = redisCache.getCacheObject(redisKey);
if (resultMap != null) {
// 表示已经获取到支付参数了,后续再有支付请求就拒绝
return cacheObject;
return resultMap;
}
// 获取支付配置
@@ -115,11 +116,8 @@ public class AdapayService {
String delayMode = pileMerchantInfoService.getDelayModeByWechatAppId(dto.getWechatAppId());
String payMode = MerchantDelayModeEnum.getAdapayPayMode(delayMode);
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
// 请求订单号
// 请求订单号, 防止请求订单号重复,结尾拼接时间
String orderNo = dto.getOrderCode() + "_" + DateUtils.dateTimeNow();
// if (ScenarioEnum.OCCUPY.getValue().equals(type)) {
// orderNo = orderNo + "_" + DateUtils.dateTimeNow();
// }
createAdaPaymentParam.setOrder_no(orderNo);
createAdaPaymentParam.setPay_amt(amount);
createAdaPaymentParam.setApp_id(config.getAdapayAppId());
@@ -151,18 +149,21 @@ public class AdapayService {
}
JSONObject expend = JSONObject.parseObject(response.get("expend").toString());
JSONObject pay_info = expend.getJSONObject("pay_info");
Map<String, Object> resultMap = JSONObject.parseObject(pay_info.toJSONString(), new TypeReference<Map<String, Object>>() {
});
if (resultMap != null) {
// 请求参数放入缓存15分钟以内返回同一个支付参数
redisCache.setCacheObject(redisKey, resultMap, 15, TimeUnit.MINUTES);
}
return resultMap;
resultMap = JSONObject.parseObject(pay_info.toJSONString(), new TypeReference<Map<String, Object>>() {});
}
} catch (BaseAdaPayException e) {
log.error("汇付-获取支付对象发生异常", e);
log.error("汇付-获取支付对象发生异常, orderCode:{}", dto.getOrderCode(), e);
}
return null;
// 放缓存
if (resultMap != null) {
// 请求参数放入缓存15分钟以内返回同一个支付参数
redisCache.setCacheObject(redisKey, resultMap, 15, TimeUnit.MINUTES);
// 请求订单号放redis
redisCache.setCacheObject(CacheConstants.ORDER_WECHAT_PAY_PARAMETERS + dto.getOrderCode(), orderNo, 30, TimeUnit.MINUTES);
}
return resultMap;
}
/**
@@ -1192,10 +1193,29 @@ public class AdapayService {
return resultList;
}
/**
* 根据请求号,查询支付信息列表
*/
public List<PaymentInfo> queryPaymentInfosByOrderNo(String orderNo, String wechatAppId) throws BaseAdaPayException {
List<PaymentInfo> resultList = Lists.newArrayList();
List<AdaPayment> adaPayments = queryPaymentsByOrderNo(orderNo, wechatAppId);
if (CollectionUtils.isEmpty(adaPayments)) {
return resultList;
}
for (AdaPayment adaPayment : adaPayments) {
PaymentInfo paymentInfo = PaymentInfo.builder()
.paymentId(adaPayment.getId())
.amount(adaPayment.getPay_amt())
.build();
resultList.add(paymentInfo);
}
return resultList;
}
/**
* 查询支付列表
*/
public List<AdaPayment> queryPaymentByOrderNo(String orderNo, String wechatAppId) throws BaseAdaPayException {
public List<AdaPayment> queryPaymentsByOrderNo(String orderNo, String wechatAppId) throws BaseAdaPayException {
List<AdaPayment> resultList = Lists.newArrayList();
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId);
if (config == null) {
@@ -1215,13 +1235,13 @@ public class AdapayService {
queryListParam.put("page_size", pageSize);
queryListParam.put("order_no", orderNo);
System.out.println("查询支付对象列表请求参数:" + JSON.toJSONString(queryListParam));
// System.out.println("查询支付对象列表请求参数:" + JSON.toJSONString(queryListParam));
Map<String, Object> paymentListResult = Payment.queryList(queryListParam, wechatAppId);
if (paymentListResult == null) {
break;
}
String jsonString = JSON.toJSONString(paymentListResult);
System.out.println("查询支付对象列表result" + jsonString);
// System.out.println("查询支付对象列表result" + jsonString);
JSONObject jsonObject = JSON.parseObject(jsonString);
List<AdaPayment> list = jsonObject.getList("payments", AdaPayment.class, JSONReader.Feature.FieldBased);

View File

@@ -1,14 +1,34 @@
package com.jsowell.adapay.vo;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import java.util.Objects;
/**
* 付款信息对象
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PaymentInfo {
// 支付id
private String paymentId;
// 金额
private String amount;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PaymentInfo that = (PaymentInfo) o;
return paymentId.equals(that.paymentId);
}
@Override
public int hashCode() {
return Objects.hash(paymentId);
}
}

View File

@@ -31,6 +31,8 @@ public interface OrderPayRecordService{
List<OrderPayRecord> getOrderPayRecordList(String orderCode);
List<PaymentInfo> queryPaymentInfosByOrderCode(String orderCode);
List<OrderDetailInfoVO.PayRecord> selectOrderPayInfoList(String orderCode);
List<PaymentInfo> parseDeductionRecord(String deductionRecord);

View File

@@ -1,7 +1,10 @@
package com.jsowell.pile.service;
import com.jsowell.pile.thirdparty.ConnectorInfo;
import com.jsowell.pile.thirdparty.EquipmentInfo;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.pile.domain.PileBasicInfo;
import com.jsowell.pile.domain.PileStationInfo;
import com.jsowell.pile.dto.IndexQueryDTO;
import com.jsowell.pile.dto.QueryPileDTO;
import com.jsowell.pile.dto.ReplaceMerchantStationDTO;
@@ -190,4 +193,8 @@ public interface PileBasicInfoService {
* 获取最新建一条桩的信息
*/
PileBasicInfo getMaxNumPileInfo();
List<EquipmentInfo> getPileList(PileStationInfo pileStationInfo);
List<ConnectorInfo> getConnectorList(PileBasicInfo pileBasicInfo);
}

View File

@@ -12,6 +12,8 @@ import java.util.List;
* @date 2023-06-06
*/
public interface ThirdPartyStationRelationService {
// 保存到数据库
int insertInfo2DataBase(String thirdPartyType, String stationId);
/**
* 查询站点、第三方推送平台配置对应
*

View File

@@ -97,7 +97,7 @@ public class MemberWalletInfoServiceImpl implements MemberWalletInfoService {
MemberWalletVO memberWalletVO = memberWalletInfoMapper.selectMemberWalletInfo(walletCode);
// 累计消费金额 = 累计充值 + 累计赠送 - 本金余额 - 赠送金余额
BigDecimal accumulatedConsumptionAmount = memberWalletVO.getAccumulatedRechargeAmount()
.add(memberWalletVO.getAccumulatedRechargeAmount())
.add(memberWalletVO.getAccumulatedRechargeGift())
.subtract(memberWalletVO.getPrincipalBalance())
.subtract(memberWalletVO.getGiftBalance());
memberWalletVO.setAccumulatedConsumptionAmount(accumulatedConsumptionAmount);

View File

@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.jsowell.adapay.dto.QueryConfirmReverseDTO;
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
@@ -1907,7 +1908,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
.orderBasicInfo(orderBasicInfo)
.orderDetail(orderDetail)
.build();
pileTransactionService.doCreateOrder(createOrderTransactionDTO);
pileTransactionService.doCreateOrder(createOrderTransactionDTO); // 保存异常订单到订单主表
}
/**
@@ -2029,7 +2030,8 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
public List<OrderBasicInfo> getUnpaidOrderListOver15Min() {
Date now = DateUtils.addMinute(new Date(), -15);
String nowString = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now);
return orderBasicInfoMapper.getUnpaidOrderListOver15Min(nowString);
List<OrderBasicInfo> list = orderBasicInfoMapper.getUnpaidOrderListOver15Min(nowString);
return CollectionUtils.isNotEmpty(list) ? list : Lists.newArrayList();
}
/**
@@ -2047,18 +2049,19 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
public int close15MinutesOfUnpaidOrders() {
List<OrderBasicInfo> orderList = getUnpaidOrderListOver15Min();
if (CollectionUtils.isNotEmpty(orderList)) {
List<String> orderIdList = orderList.stream()
.map(x -> String.valueOf(x.getId()))
.collect(Collectors.toList());
// 修改订单状态
updateOrderStatusById(orderIdList, OrderStatusEnum.ORDER_CLOSE_TIMEOUT.getValue());
for (OrderBasicInfo orderBasicInfo : orderList) {
this.cleanCacheByOrderCode(orderBasicInfo.getOrderCode(), orderBasicInfo.getTransactionCode());
// 通过订单号查询汇付有没有支付单
checkUnpaidOrder(orderBasicInfo);
}
// 订单id集合
List<String> orderIdList = orderList.stream()
.map(x -> String.valueOf(x.getId()))
.collect(Collectors.toList());
// 根据orderIdList修改订单状态
updateOrderStatusById(orderIdList, OrderStatusEnum.ORDER_CLOSE_TIMEOUT.getValue());
}
return orderList.size();
}
@@ -2075,59 +2078,40 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
String merchantId = orderBasicInfo.getMerchantId();
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId);
String delayMode = pileMerchantInfoService.getDelayModeByWechatAppId(wechatAppId);
// List<AdaPayment> adaPayments = null;
// try {
// adaPayments = adapayService.queryPaymentByOrderNo(orderCode, wechatAppId);
// } catch (BaseAdaPayException e) {
// throw new RuntimeException(e);
// }
// if (CollectionUtils.isEmpty(adaPayments)) {
// return;
// }
// 订单总金额
BigDecimal orderAmount = orderBasicInfo.getOrderAmount() == null ? BigDecimal.ZERO : orderBasicInfo.getOrderAmount();
if (orderAmount.compareTo(BigDecimal.ZERO) > 0) {
return;
}
// 如果超时关闭的订单,存在支付信息,都退款处理
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
logger.info("校验未支付订单orderCode:{}, 支付信息:{}", orderCode, JSON.toJSONString(orderPayRecordList));
if (CollectionUtils.isNotEmpty(orderPayRecordList)) {
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
List<PaymentInfo> paymentInfos = orderPayRecordService.parseDeductionRecord(orderPayRecord.getDeductionRecord());
for (PaymentInfo paymentInfo : paymentInfos) {
String paymentId = paymentInfo.getPaymentId();
BigDecimal payAmt = new BigDecimal(paymentInfo.getAmount());
if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) {
// 延时分账商户,创建交易撤销请求
adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
} else {
// 实时分账商户,创建交易退款请求
adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
}
Set<PaymentInfo> paymentInfoSet = Sets.newHashSet();
List<PaymentInfo> paymentInfos1 = orderPayRecordService.queryPaymentInfosByOrderCode(orderCode);
paymentInfoSet.addAll(paymentInfos1);
try {
String redisKey = CacheConstants.ORDER_WECHAT_PAY_PARAMETERS + orderCode;
String orderNo = redisCache.getCacheObject(redisKey);
if (StringUtils.isNotBlank(orderNo)) {
List<PaymentInfo> paymentInfos2 = adapayService.queryPaymentInfosByOrderNo(orderNo, wechatAppId);
paymentInfoSet.addAll(paymentInfos2);
}
} catch (BaseAdaPayException e) {
throw new RuntimeException(e);
}
if (CollectionUtils.isNotEmpty(paymentInfoSet)) {
for (PaymentInfo paymentInfo : paymentInfoSet) {
String paymentId = paymentInfo.getPaymentId();
BigDecimal payAmt = new BigDecimal(paymentInfo.getAmount());
if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) {
// 延时分账商户,创建交易撤销请求
adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
} else {
// 实时分账商户,创建交易退款请求
adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
}
}
}
// 退款
// for (AdaPayment adaPayment : adaPayments) {
// String status = adaPayment.getStatus();
// if (!AdapayStatusEnum.SUCCEEDED.getValue().equals(status)) {
// // 不是交易完成状态,就跳过
// continue;
// }
// String paymentId = adaPayment.getId();
// BigDecimal payAmt = new BigDecimal(adaPayment.getPay_amt());
// if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) {
// // 延时分账商户,创建交易撤销请求
// adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
// } else {
// // 实时分账商户,创建交易退款请求
// adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
// }
// }
}
/**
@@ -2593,7 +2577,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
.orderBasicInfo(orderBasicInfo)
.orderDetail(orderDetail)
.build();
pileTransactionService.doCreateOrder(createOrderTransactionDTO);
pileTransactionService.doCreateOrder(createOrderTransactionDTO); // 联联平台生成订单
// 组装结果集
Map<String, Object> resultMap = Maps.newHashMap();
@@ -3083,7 +3067,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
orderInfo.setPayMode(dto.getPayMode());
orderInfo.setPayStatus(OrderPayStatusEnum.paid.getValue());
BigDecimal orderPayAmount = orderInfo.getPayAmount() == null ? BigDecimal.ZERO : orderInfo.getPayAmount();
orderInfo.setPayAmount(orderPayAmount.add(payAmount));
// 2024年3月25日12点26分 发现重复记录的情况
if(orderPayAmount.compareTo(payAmount) != 0) {
orderInfo.setPayAmount(orderPayAmount.add(payAmount));
}
orderInfo.setPayTime(new Date());
if (sendStartCharging) {
@@ -3515,7 +3502,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
.pileConnectorCode(dto.getPileSn() + dto.getConnectorCode())
.startMode(dto.getStartMode())
.payStatus(Constants.ZERO)
.payAmount(dto.getChargeAmount()) // 支付完成后填入支付金额
// .payAmount(dto.getChargeAmount()) // 支付完成后填入支付金额
.payMode(dto.getPayMode())
.plateNumber(plateNumber)
.orderAmount(BigDecimal.ZERO)

View File

@@ -78,6 +78,19 @@ public class OrderPayRecordServiceImpl implements OrderPayRecordService {
return orderPayRecordMapper.getOrderPayRecordList(orderCode);
}
@Override
public List<PaymentInfo> queryPaymentInfosByOrderCode(String orderCode) {
List<PaymentInfo> resultList = Lists.newArrayList();
List<OrderPayRecord> orderPayRecordList = getOrderPayRecordList(orderCode);
if (CollectionUtils.isNotEmpty(orderPayRecordList)) {
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
List<PaymentInfo> paymentInfos = this.parseDeductionRecord(orderPayRecord.getDeductionRecord());
resultList.addAll(paymentInfos);
}
}
return resultList;
}
/**
* 查询订单支付信息
* 加缓存
@@ -119,33 +132,18 @@ public class OrderPayRecordServiceImpl implements OrderPayRecordService {
|| StringUtils.equals(payMode, OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())) {
// 使用余额支付
payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue());
payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_BALANCE.getLabel());
String payModeDesc = null;
if (StringUtils.isNotBlank(OrderPayRecordEnum.getPayModeDescription(payMode))) {
payModeDesc = OrderPayRecordEnum.getPayModeDescription(payMode);
} else {
payModeDesc = OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue();
}
payInfo.setPayModeDesc(payModeDesc);
} else if (StringUtils.equals(payMode, OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())) {
// 使用微信支付
payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue());
payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getLabel());
// 判断是微信支付还是汇付支付
// MemberTransactionRecord record = memberTransactionRecordService.selectByOrderCode(orderCode, ActionTypeEnum.FORWARD.getValue());
// if (record != null) {
// String paymentInstitutions = record.getPaymentInstitutions();
// if (StringUtils.equals(paymentInstitutions, PaymentInstitutionsEnum.WECHAT_PAY.getValue())) {
// // 查微信支付回调记录
// WxpayCallbackRecord wxpayCallbackRecord = wxpayCallbackRecordService.selectByOrderCode(orderCode);
// if (wxpayCallbackRecord != null) {
// payInfo.setOutTradeNo(wxpayCallbackRecord.getOutTradeNo());
// payInfo.setTransactionId(wxpayCallbackRecord.getTransactionId());
// }
// } else if (StringUtils.equals(paymentInstitutions, PaymentInstitutionsEnum.ADAPAY.getValue())) {
// // 查询汇付支付回调
// AdapayCallbackRecord adapayCallbackRecord = adapayCallbackRecordService.selectByOrderCode(orderCode);
// if (adapayCallbackRecord != null) {
// payInfo.setOutTradeNo(adapayCallbackRecord.getPaymentId());
// payInfo.setTransactionId(adapayCallbackRecord.getOutTransId());
// }
// }
// }
// 判断是微信支付还是汇付支付
String paymentInstitutions = orderPayRecord.getAcquirer();
if (StringUtils.equals(paymentInstitutions, PaymentInstitutionsEnum.WECHAT_PAY.getValue())) {
@@ -173,7 +171,7 @@ public class OrderPayRecordServiceImpl implements OrderPayRecordService {
payRecordList.add(payInfo);
}
redisCache.setCacheList(redisKey, payRecordList);
redisCache.expire(redisKey, CacheConstants.cache_expire_time_10d);
redisCache.expire(redisKey, CacheConstants.cache_expire_time_1d);
return payRecordList;
}

View File

@@ -4,21 +4,22 @@ import com.alibaba.fastjson2.JSON;
import com.google.common.collect.Lists;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.pile.thirdparty.ConnectorInfo;
import com.jsowell.pile.thirdparty.EquipmentInfo;
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
import com.jsowell.common.core.domain.ykc.GroundLockData;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.DelFlagEnum;
import com.jsowell.common.enums.lianlian.LianLianPileStatusEnum;
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
import com.jsowell.common.enums.ykc.PileConnectorStatusEnum;
import com.jsowell.common.enums.ykc.PileStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.*;
import com.jsowell.pile.domain.PileBasicInfo;
import com.jsowell.pile.domain.PileConnectorInfo;
import com.jsowell.pile.domain.PileModelInfo;
import com.jsowell.pile.domain.PileSimInfo;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.IndexQueryDTO;
import com.jsowell.pile.dto.QueryPileDTO;
import com.jsowell.pile.dto.ReplaceMerchantStationDTO;
@@ -927,4 +928,97 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
public PileBasicInfo getMaxNumPileInfo() {
return pileBasicInfoMapper.getMaxNumPileInfo();
}
/**
* 获取桩列表信息
*
* @param pileStationInfo
* @return
*/
@Override
public List<EquipmentInfo> getPileList(PileStationInfo pileStationInfo) {
List<EquipmentInfo> resultList = new ArrayList<>();
// 通过站点id查询桩基本信息
List<PileBasicInfo> list = this.getPileListByStationId(String.valueOf(pileStationInfo.getId()));
// MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId()));
// 封装成联联平台对象
for (PileBasicInfo pileBasicInfo : list) {
EquipmentInfo equipmentInfo = new EquipmentInfo();
String pileSn = pileBasicInfo.getSn();
equipmentInfo.setEquipmentID(pileSn);
equipmentInfo.setManufacturerID(Constants.OPERATORID_LIANLIAN);
equipmentInfo.setConstructionTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileBasicInfo.getCreateTime()));
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
equipmentInfo.setEquipmentType(Integer.valueOf(modelInfo.getSpeedType()));
// 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(pileStatus));
equipmentInfo.setEquipmentPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
equipmentInfo.setNewNationalStandard(1);
equipmentInfo.setVinFlag(1);
List<ConnectorInfo> connectorList = getConnectorList(pileBasicInfo);
equipmentInfo.setConnectorInfos(connectorList);
resultList.add(equipmentInfo);
}
return resultList;
}
/**
* 获取枪口列表
*
* @param pileBasicInfo
* @return
*/
@Override
public List<ConnectorInfo> getConnectorList(PileBasicInfo pileBasicInfo) {
List<ConnectorInfo> resultList = new ArrayList<>();
List<PileConnectorInfo> list = pileConnectorInfoService.selectPileConnectorInfoList(pileBasicInfo.getSn());
for (PileConnectorInfo pileConnectorInfo : list) {
ConnectorInfo connectorInfo = new ConnectorInfo();
connectorInfo.setConnectorID(pileConnectorInfo.getPileConnectorCode());
String pileSn = pileConnectorInfo.getPileSn();
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
int connectorType = StringUtils.equals("1", modelInfo.getSpeedType()) ? 4 : 3;
connectorInfo.setConnectorType(connectorType);
// 车位号
if (StringUtils.isNotBlank(pileConnectorInfo.getParkNo())) {
connectorInfo.setParkNo(pileConnectorInfo.getParkNo());
}
connectorInfo.setVoltageUpperLimits(Integer.valueOf(modelInfo.getRatedVoltage()));
connectorInfo.setVoltageLowerLimits(Integer.valueOf(modelInfo.getRatedVoltage()));
connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent()));
if (!StringUtils.equals(modelInfo.getConnectorNum(), "1")) {
// 如果不是单枪,则枪口功率需要除以枪口数量
String ratedPowerStr = modelInfo.getRatedPower();
BigDecimal ratedPower = new BigDecimal(ratedPowerStr);
connectorInfo.setPower(ratedPower.divide(new BigDecimal(modelInfo.getConnectorNum()), 1, BigDecimal.ROUND_HALF_UP));
}else {
connectorInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
}
resultList.add(connectorInfo);
}
return resultList;
}
}

View File

@@ -26,7 +26,6 @@ import com.jsowell.pile.mapper.PileBasicInfoMapper;
import com.jsowell.pile.mapper.PileConnectorInfoMapper;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.base.ConnectorInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.web.PileDetailVO;
import com.jsowell.pile.vo.web.PileModelInfoVO;
@@ -145,8 +144,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
}
if (StringUtils.isNotBlank(pileConnectorCode)) {
// 删除充电桩枪口状态缓存
keys.add(CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode);
keys.add(CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode); // 删除充电桩枪口状态缓存
}
// 批量删除
@@ -584,7 +582,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
if (StringUtils.isBlank(pileConnectorCode) || StringUtils.isBlank(status)) {
return num;
}
String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode;
String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode; // 获取缓存
String redisStatus = redisCache.getCacheObject(redisKey);
// log.info("更新枪口状态-枪口编号:{}, redisKey:{}, 缓存状态:{}, 传来的状态:{}, 状态描述:{}", pileConnectorCode, redisKey,
// redisStatus, status, PileConnectorDataBaseStatusEnum.getStatusDescription(status));
@@ -706,10 +704,10 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
if (CollectionUtils.isNotEmpty(connectorList)) {
// 批量查询redis中的枪口状态
List<String> redisKeyList = connectorList.stream()
.map(x -> CacheConstants.PILE_CONNECTOR_STATUS_KEY + x.getPileConnectorCode())
.collect(Collectors.toList());
List<String> statusList = redisCache.multiGet(redisKeyList);
// List<String> redisKeyList = connectorList.stream()
// .map(x -> CacheConstants.PILE_CONNECTOR_STATUS_KEY + x.getPileConnectorCode())
// .collect(Collectors.toList());
// List<String> statusList = redisCache.multiGet(redisKeyList);
for (ConnectorInfoVO connectorVO : connectorList) {
String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + connectorVO.getPileConnectorCode();

View File

@@ -1,6 +1,9 @@
package com.jsowell.pile.service.impl;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.util.SecurityUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.ThirdPartyStationRelation;
import com.jsowell.pile.mapper.ThirdPartyStationRelationMapper;
import com.jsowell.pile.service.ThirdPartyStationRelationService;
@@ -21,6 +24,25 @@ public class ThirdPartyStationRelationServiceImpl implements ThirdPartyStationRe
@Autowired
private ThirdPartyStationRelationMapper thirdPartyStationRelationMapper;
@Override
public int insertInfo2DataBase(String thirdPartyType, String stationId) {
if (StringUtils.isBlank(thirdPartyType) || StringUtils.isBlank(stationId)) {
return 0;
}
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
relation.setStationId(Long.parseLong(stationId));
relation.setThirdPartyType(thirdPartyType);
if (StringUtils.equals(thirdPartyType, ThirdPlatformTypeEnum.HUA_WEI.getCode())) {
relation.setStartMode(Constants.ONE);
}
ThirdPartyStationRelationVO vo = this.selectRelationInfo(relation);
if (vo != null) {
return 0;
}
// 新增数据库
return this.insertThirdPartyStationRelation(relation);
}
/**
* 查询站点、第三方推送平台配置对应
*

View File

@@ -0,0 +1,72 @@
package com.jsowell.pile.thirdparty;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* 充电设备接口信息
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class ConnectorInfo {
/**
* 充电设备接口编码 Y
* 充电设备接口编码,同一对接平台内唯一
*/
@JSONField(name = "ConnectorID")
private String connectorID;
/**
* 充电设备接口名称 N
*/
// private String ConnectorName;
/**
* 充电设备接口类型 Y
* 1家用插座模式2
* 2交流接口插座模式3连接方式B
* 3交流接口插头带枪线模式3连接方式C
* 4直流接口枪头带枪线模式4
*/
@JSONField(name = "ConnectorType")
private Integer connectorType;
/**
* 额定电压上限(单位V) Y
*/
@JSONField(name = "VoltageUpperLimits")
private Integer voltageUpperLimits;
/**
* 额定电压下限(单位V) Y
*/
@JSONField(name = "VoltageLowerLimits")
private Integer voltageLowerLimits;
/**
* 额定电流(单位A) Y
*/
@JSONField(name = "Current")
private Integer current;
/**
* 额定功率(单位kW) Y
*/
@JSONField(name = "Power")
private BigDecimal power;
/**
* 车位号 N
* 停车场车位编号
*/
@JSONField(name = "ParkNo")
private String parkNo;
}

View File

@@ -0,0 +1,112 @@
package com.jsowell.pile.thirdparty;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
* 充电设备信息
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class EquipmentInfo {
/**
* 设备编码 Y
* 设备唯一编码,对同一对接平台,保证唯一
*/
@JSONField(name = "EquipmentID")
private String equipmentID;
/**
* 设备生产商组织机构代码 Y
*/
@JSONField(name = "ManufacturerID")
private String manufacturerID;
/**
* 设备型号 N
* 由设备生厂商定义的设备型号
*/
// private String EquipmentModel;
/**
* 设备名称 N
*/
// private String EquipmentName;
/**
* 设备生产日期 N
* YYYY-MM-DD
*/
// private String ProductionDate;
/**
* 建设时间 Y
* YYYY-MM-DD
*/
@JSONField(name = "ConstructionTime")
private String constructionTime;
/**
* 设备类型(1-直流设备2-交流设备3-交直流一体设备) Y
*/
@JSONField(name = "EquipmentType")
private Integer equipmentType;
/**
* 设备状态 Y
* 0未知
* 1建设中
* 5关闭下线
* 6维护中
* 50正常使用
*/
@JSONField(name = "EquipmentStatus")
private Integer equipmentStatus;
/**
* 额定功率(单位kW) Y
*/
@JSONField(name = "EquipmentPower")
private BigDecimal equipmentPower;
/**
* 新国标(0-否1-是) Y
* 是否新国标
*/
@JSONField(name = "NewNationalStandard")
private Integer newNationalStandard;
/**
* 充电设备接口列表 Y
* 该充电设备所有的充电设备接口的信息对象集合
*/
@JSONField(name = "ConnectorInfos")
private List<ConnectorInfo> connectorInfos;
/**
* 充电设备经度 N
* GCJ-02坐标系
*/
// private BigDecimal EquipmentLng;
/**
* 充电设备纬度 N
* GCJ-02坐标系
*/
// private BigDecimal EquipmentLat;
/**
* 是否支持VIN码识别(0-否1-是) Y
*/
@JSONField(name = "VinFlag")
private Integer vinFlag;
}