update 对接lianlian平台

This commit is contained in:
2024-05-08 18:40:45 +08:00
parent 6a82341c8a
commit 376e14adeb
4 changed files with 222 additions and 22 deletions

View File

@@ -11,6 +11,7 @@ import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.enums.lianlian.PayChannelEnum;
import com.jsowell.common.enums.lianlian.StationPaymentEnum;
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.PileConnectorDataBaseStatusEnum;
@@ -20,10 +21,8 @@ import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.PageUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.PushOrderSettlementDTO;
import com.jsowell.pile.dto.PushRealTimeInfoDTO;
import com.jsowell.pile.dto.QueryEquipmentDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
import com.jsowell.pile.dto.*;
import com.jsowell.pile.service.*;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.thirdparty.EquipmentInfo;
@@ -38,6 +37,7 @@ 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.platform.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.common.ChargeDetail;
import com.jsowell.thirdparty.platform.common.OrderInfo;
@@ -63,6 +63,9 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired
private PileMerchantInfoService pileMerchantInfoService;
@Autowired
private YKCPushCommandService ykcPushCommandService;
@Autowired
private PileStationInfoService pileStationInfoService;
@@ -1200,5 +1203,81 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
return resultMap;
}
/**
* 请求启动充电
*
* @param dto
*/
public Map<String, String> queryStartCharge(QueryStartChargeDTO dto) {
// 通过传过来的订单号和枪口号生成订单
String pileConnectorCode = dto.getConnectorID();
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq());
if (orderInfo != null) {
// 平台已存在订单
return null;
}
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(dto.getOperatorId());
if (thirdPartySecretInfoVO == null) {
return null;
}
// 生成订单
Map<String, Object> map = orderBasicInfoService.generateOrderForThirdParty(dto);
String orderCode = (String) map.get("orderCode");
String transactionCode = (String) map.get("transactionCode");
OrderBasicInfo orderBasicInfo = (OrderBasicInfo) map.get("orderBasicInfo");
// 发送启机指令
StartChargingCommand command = StartChargingCommand.builder()
.pileSn(orderBasicInfo.getPileSn())
.connectorCode(orderBasicInfo.getConnectorCode())
.transactionCode(transactionCode)
.chargeAmount(orderBasicInfo.getPayAmount())
.logicCardNum(null)
.physicsCardNum(null)
.build();
ykcPushCommandService.pushStartChargingCommand(command);
// 拼装对应的数据并返回
QueryStartChargeVO vo = QueryStartChargeVO.builder()
.startChargeSeq(orderCode)
.startChargeSeqStat(2) // 1、启动中 2、充电中3、停止中4、已结束5、未知
.connectorID(pileConnectorCode)
.succStat(0)
.failReason(0)
.build();
String type = ThirdPartyOperatorIdEnum.getTypeByOperatorId(dto.getOperatorId());
if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getTypeCode(), type)) {
// 如果是新电途平台,则将 startChargeSeqStat 改为 1-启动中
vo.setStartChargeSeqStat(1);
}
// 异步推送启动充电结果 2024.01.25改为在0x33帧类型中统一回复
// CompletableFuture.runAsync(() -> {
// try {
// Thread.sleep(200);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// pushStartChargeResult(orderCode);
// });
// 加密
// 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);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO);
return resultMap;
}
}