diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java index 83fe442ba..6316ace8a 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java @@ -328,6 +328,7 @@ public class LianLianController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryEquipAuth(queryEquipmentDTO); + logger.info("{}-请求设备认证 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { logger.error("{}-请求设备认证 error:", platformName, e); @@ -363,7 +364,7 @@ public class LianLianController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryStartCharge(queryStartChargeDTO); - + logger.info("{}-请求启动充电 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { logger.error("{}-请求启动充电 error", platformName, e); @@ -371,6 +372,31 @@ public class LianLianController extends ThirdPartyBaseController { return CommonResult.failed("请求启动充电发生异常"); } + + /** + * 推送启动充电结果 + * @param + * @return + */ + @GetMapping("/v1/notification_start_charge_result/{orderCode}") + public RestApiResponse notification_start_charge_result(@RequestParam("orderCode") String orderCode) { + logger.info("【{}】推送启动充电结果 params:{}", this.getClass().getSimpleName(), orderCode); + RestApiResponse response = null; + try { + String result = platformLogic.notificationStartChargeResult(orderCode); + logger.info("【{}】推送启动充电结果 result:{}", this.getClass().getSimpleName(), result); + response = new RestApiResponse<>(result); + }catch (BusinessException e) { + logger.error("【{}】推送启动充电结果 error",this.getClass().getSimpleName(), e); + response = new RestApiResponse<>(e.getCode(), e.getMessage()); + }catch (Exception e) { + logger.error("【{}】推送启动充电结果 error", this.getClass().getSimpleName(), e); + response = new RestApiResponse<>(e); + } + logger.info("【{}】推送启动充电结果 result:{}", this.getClass().getSimpleName(), response); + return response; + } + /** * 查询充电状态 * http://localhost:8080/LianLian/query_equip_charge_status/{startChargeSeq} @@ -399,7 +425,7 @@ public class LianLianController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryEquipChargeStatus(queryEquipChargeStatusDTO); - + logger.info("{}-查询充电状态 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { logger.error("{}-查询充电状态 error", platformName, e); @@ -435,7 +461,7 @@ public class LianLianController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryStopCharge(queryStartChargeDTO); - + logger.info("{}-请求停止充电 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { logger.error("{}-请求停止充电 error", platformName, e); @@ -472,7 +498,7 @@ public class LianLianController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.notificationOrderSettlementInfo(pushOrderSettlementDTO); - + logger.info("{}-推送订单结算信息 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "推送订单结算信息成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { logger.info("{}-推送订单结算信息 error:", platformName, e); @@ -481,6 +507,32 @@ public class LianLianController extends ThirdPartyBaseController { return CommonResult.failed("推送订单结算信息发生异常"); } + + /** + * 推送充电状态 + * http://localhost:8080/hainan/notificationEquipChargeStatus + * @param orderCode + * @return + */ + @GetMapping("/v1/notification_equip_charge_status/{orderCode}") + public RestApiResponse notification_equip_charge_status(@PathVariable("orderCode") String orderCode) { + logger.info("推送充电状态 params:{}", orderCode); + RestApiResponse response = null; + try { + String result = platformLogic.notificationEquipChargeStatus(orderCode); + logger.info("推送充电状态 result:{}", result); + response = new RestApiResponse<>(result); + }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; + } + @GetMapping("/pushStationFee/{stationId}") public RestApiResponse pushStationFee(@PathVariable("stationId") String stationId) { RestApiResponse response = null; @@ -494,4 +546,25 @@ public class LianLianController extends ThirdPartyBaseController { return response; } + + /** + * 充电订单信息推送 + */ + @PostMapping("/v1/notification_charge_order_info") + public RestApiResponse notification_charge_order_info(@RequestBody QueryOrderDTO dto) { + RestApiResponse response = null; + try { + String result = platformLogic.pushOrderInfo(dto); + response = new RestApiResponse<>(result); + }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; + } + } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java index dad8c4f56..d4e5da68e 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java @@ -47,6 +47,7 @@ import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.util.*; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,6 +65,7 @@ import java.util.stream.Collectors; /** * 上海联联平台 */ +@Slf4j @Service public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -867,6 +869,28 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + @Override + public String pushOrderInfo(QueryOrderDTO dto) { + ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getLianLianPlatformSecretInfo(); + + // 根据站点id, 开始时间,结束时间查询出所有的订单信息 + // List orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(dto); + List orderCodes = orderBasicInfoService.tempGetOrderCodes(dto); + if (CollectionUtils.isEmpty(orderCodes)) { + return "订单信息为空"; + } + // List orderCodeList = orderListVOS.stream().map(OrderListVO::getOrderCode).collect(Collectors.toList()); + for (String orderCode : orderCodes) { + try { + String result = notificationChargeOrderInfo(orderCode, wangKuaiDianPlatformSecretInfo); + log.info("订单:{} 推送结果:{}", orderCode, result); + }catch (Exception e) { + log.error("订单:{} 推送error, ", orderCode, e); + } + } + return "Success"; + } + /** * 订单信息推送 notification_orderInfo * @@ -1175,6 +1199,12 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + /** + * + * @param stationId + * @param secretInfoVO + * @return + */ @Override public String notificationStationFee(String stationId, ThirdPartySecretInfoVO secretInfoVO) { PushStationFeeVO vo = new PushStationFeeVO(); @@ -1233,7 +1263,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { } /** - * + * 推送订单结算信息 notification_order_settlement_info */ @Override public Map notificationOrderSettlementInfo(PushOrderSettlementDTO dto) { @@ -1443,6 +1473,46 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return resultMap; } + + /** + * 推送启动充电结果 notification_start_charge_result + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStartChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO ningBoSecretInfoVO = getLianLianPlatformSecretInfo(); + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); + String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); + String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); + String dataSecretIv = ningBoSecretInfoVO.getTheirDataSecretIv(); + String urlAddress = ningBoSecretInfoVO.getTheirUrlPrefix(); + + // 推送启动充电结果(调用接口 notification_start_charge_result) + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue(); + // 拼装参数 + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("ConnectorID", orderInfo.getPileConnectorCode()); + json.put("StartChargeSeqStat", 2); // 一定要给 2-充电中 + json.put("StartTime", DateUtils.getDateTime()); + + String jsonString = JSON.toJSONString(json); + log.info("请求参数:{}", jsonString); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** * 查询充电状态 * @@ -1516,6 +1586,48 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return resultMap; } + /** + * 推送停止充电结果 notification_stop_charge_result + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStopChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getLianLianPlatformSecretInfo(); + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = wangKuaiDianPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = wangKuaiDianPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = wangKuaiDianPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = wangKuaiDianPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = wangKuaiDianPlatformSecretInfo.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STOP_CHARGE_RESULT.getValue(); + + // 拼装联联平台参数 + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("StartChargeSeqStat", 4); // 只能给 4-已结束 + json.put("ConnectorID", orderInfo.getPileConnectorCode()); + json.put("SuccStat", 0); + json.put("FailReason", 0); + + String jsonString = JSON.toJSONString(json); + + log.info("请求参数:{}", jsonString); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + + /** * 获取联联平台配置密钥信息 *