mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
update
This commit is contained in:
@@ -14,6 +14,7 @@ import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderPayModeEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
@@ -35,9 +36,7 @@ import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||
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.lianlian.vo.EquipmentAuthVO;
|
||||
import com.jsowell.thirdparty.lianlian.vo.QueryStartChargeVO;
|
||||
import com.jsowell.thirdparty.lianlian.vo.*;
|
||||
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
||||
import com.jsowell.thirdparty.platform.common.ChargeDetail;
|
||||
import com.jsowell.thirdparty.platform.common.OrderInfo;
|
||||
@@ -66,6 +65,9 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
@Autowired
|
||||
private PileMerchantInfoService pileMerchantInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileRemoteService pileRemoteService;
|
||||
|
||||
@Autowired
|
||||
private YKCPushCommandService ykcPushCommandService;
|
||||
|
||||
@@ -1283,4 +1285,144 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求停止充电
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> queryStopCharge(QueryStartChargeDTO dto) {
|
||||
QueryStopChargeVO vo = new QueryStopChargeVO();
|
||||
|
||||
String orderCode = dto.getStartChargeSeq();
|
||||
|
||||
// 根据订单号查询订单信息
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
if (orderInfo == null) {
|
||||
return null;
|
||||
}
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
// 若状态为充电中,则发送停机指令
|
||||
if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderInfo.getOrderStatus())) {
|
||||
// 充电中
|
||||
// StopChargingCommand command = StopChargingCommand.builder()
|
||||
// .pileSn(orderInfo.getPileSn())
|
||||
// .connectorCode(orderInfo.getConnectorCode())
|
||||
// .build();
|
||||
// ykcPushCommandService.pushStopChargingCommand(command);
|
||||
pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode(), orderInfo.getTransactionCode());
|
||||
vo.setStartChargeSeq(orderCode);
|
||||
vo.setStartChargeSeqStat(4); // 1、启动中 ;2、充电中;3、停止中;4、已结束;5、未知
|
||||
}
|
||||
vo.setSuccStat(0);
|
||||
vo.setFailReason(0);
|
||||
|
||||
String type = ThirdPartyOperatorIdEnum.getTypeByOperatorId(dto.getOperatorId());
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getTypeCode(), type)) {
|
||||
// 如果是新电途平台,则将 startChargeSeqStat 改为 3-停止中
|
||||
vo.setStartChargeSeqStat(3);
|
||||
}
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(),
|
||||
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电状态
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> queryEquipChargeStatus(QueryEquipChargeStatusDTO dto) {
|
||||
String operatorID = dto.getOperatorID();
|
||||
String type = ThirdPartyOperatorIdEnum.getTypeByOperatorId(operatorID);
|
||||
String operatorName = ThirdPlatformTypeEnum.getTypeLabelByTypeCode(type);
|
||||
// 通过订单号查询订单信息
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq());
|
||||
// logger.info(operatorName + "查询订单信息 orderInfo:{}", orderInfo);
|
||||
if (orderInfo == null) {
|
||||
return null;
|
||||
}
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorID);
|
||||
// logger.info(operatorName + "查询密钥信息 configInfo:{}", configInfo);
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode());
|
||||
// 通过订单号查询实时数据
|
||||
List<RealTimeMonitorData> realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode());
|
||||
QueryChargingStatusVO vo;
|
||||
if (CollectionUtils.isEmpty(realTimeData)) {
|
||||
vo = new QueryChargingStatusVO();
|
||||
} else {
|
||||
RealTimeMonitorData data = realTimeData.get(0);
|
||||
String orderStatus = orderInfo.getOrderStatus();
|
||||
if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) {
|
||||
// 充电中
|
||||
orderStatus = "2";
|
||||
}else if (StringUtils.equals(orderStatus, OrderStatusEnum.ORDER_COMPLETE.getValue())) {
|
||||
// 充电完成
|
||||
orderStatus = "4";
|
||||
} else {
|
||||
// 直接给 5-未知
|
||||
orderStatus = "5";
|
||||
}
|
||||
String status = data.getConnectorStatus();
|
||||
int connectorStatus = 0;
|
||||
if (StringUtils.isBlank(status)) {
|
||||
// 查询当前枪口状态
|
||||
PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
|
||||
connectorStatus = connectorInfoVO.getStatus();
|
||||
}else {
|
||||
connectorStatus = Integer.parseInt(status);
|
||||
}
|
||||
BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount();
|
||||
BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount();
|
||||
// 拼装联联平台数据
|
||||
vo = QueryChargingStatusVO.builder()
|
||||
.startChargeSeq(dto.getStartChargeSeq()) // 订单号
|
||||
.startChargeSeqStat(Integer.parseInt(orderStatus)) // 订单状态
|
||||
.connectorID(orderInfo.getPileConnectorCode()) // 枪口编码
|
||||
.connectorStatus(connectorStatus) // 枪口状态
|
||||
.currentA(new BigDecimal(data.getOutputCurrent())) // 电流
|
||||
.voltageA(new BigDecimal(data.getOutputVoltage())) // 电压
|
||||
.soc(new BigDecimal(data.getSOC()))
|
||||
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) // 开始时间
|
||||
.endTime(DateUtils.getDateTime()) // 本次采样时间
|
||||
.totalPower(new BigDecimal(data.getChargingDegree()).setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计充电量
|
||||
.elecMoney(totalElectricityAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计电费
|
||||
.seviceMoney(totalServiceAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计服务费
|
||||
.totalMoney(new BigDecimal(data.getChargingAmount())) // 已充金额
|
||||
|
||||
.build();
|
||||
}
|
||||
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(),
|
||||
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user