Bläddra i källkod

互联互通对接调试:类名称修改,日志修改等

skyline 1 år sedan
förälder
incheckning
784e964398

+ 1 - 1
common/src/main/java/com/kym/common/constant/ResponseEnum.java

@@ -53,7 +53,7 @@ public enum ResponseEnum implements BusinessExceptionAssert {
     // EN+
     EN_PLUS_API_EXCEPTION(90000, "接口数据异常"),
     EN_PLUS_QUERY_TOKEN_ERROR(90001, "TOKEN获取异常"),
-    EN_PLUS_PUSH_SIGN_FAIL(90002, "EN+推送数据验签失败"),
+    EN_PLUS_PUSH_SIGN_FAIL(90002, "推送数据验签失败"),
     EN_PLUS_TOKEN_EXCEPTION(90003,"EN+TOKEN过期");
 
     private final Integer code;

+ 1 - 1
miniapp/src/main/java/com/kym/miniapp/controller/ChargerController.java

@@ -269,7 +269,7 @@ public class ChargerController {
     //====================================================以下是手动同步数据接口==============================================================
 
     /**
-     * 拉取EN+充电站信息数据并更新本地服务器数据
+     * 拉取充电站信息数据并更新本地服务器数据
      *
      * @return
      */

+ 7 - 7
service/src/main/java/com/kym/service/admin/impl/StationServiceImpl.java

@@ -48,17 +48,17 @@ import java.util.stream.Stream;
 @Slf4j
 public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station> implements StationService {
 
-    private final PlatformApiService enPlusService;
+    private final PlatformApiService platformApiService;
     private final EquipmentInfoService equipmentInfoService;
     private final ConnectorInfoService connectorInfoService;
     private final EquipmentRelationService equipmentRelationService;
     private final ActivityStationService activityStationService;
     private final ActivityService activityService;
 
-    public StationServiceImpl(PlatformApiService enPlusService, EquipmentInfoService equipmentInfoService,
+    public StationServiceImpl(PlatformApiService platformApiService, EquipmentInfoService equipmentInfoService,
                               ConnectorInfoService connectorInfoService, EquipmentRelationService equipmentRelationService,
                               ActivityStationService activityStationService, @Lazy ActivityService activityService) {
-        this.enPlusService = enPlusService;
+        this.platformApiService = platformApiService;
         this.equipmentInfoService = equipmentInfoService;
         this.connectorInfoService = connectorInfoService;
         this.equipmentRelationService = equipmentRelationService;
@@ -94,7 +94,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
                     "LastQueryTime":""
                 }
                 """.formatted(pageNum, pageSize);
-        var response = enPlusService.platformPost(platformName, CommonApi.EN_PLUS_QUERY_STATION_INFO.getApi(platformName), enPlusService.buildPlatformParams(platformName, param));
+        var response = platformApiService.platformPost(platformName, CommonApi.EN_PLUS_QUERY_STATION_INFO.getApi(platformName), platformApiService.buildPlatformParams(platformName, param));
         var enStations = parsePlatformResponseData(response, platformName);
         var stationList = enStations.getJSONArray("StationInfos").toJavaList(StationVo.class);
         // 我方station表数据
@@ -141,7 +141,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
                     "LastQueryTime":""
                 }
                 """.formatted(pageNum, pageSize);
-        var response = enPlusService.platformPost(platformName, CommonApi.EN_PLUS_QUERY_STATION_INFO.getApi(platformName), enPlusService.buildPlatformParams(platformName, param));
+        var response = platformApiService.platformPost(platformName, CommonApi.EN_PLUS_QUERY_STATION_INFO.getApi(platformName), platformApiService.buildPlatformParams(platformName, param));
         var enStations = parsePlatformResponseData(response, platformName);
         var stationList = enStations.getJSONArray("StationInfos").toJavaList(StationVo.class);
         // 我方station表数据
@@ -240,7 +240,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
                         "StationIDs":["%s"]
                     }
                     """.formatted(String.join("\",\"", ids));
-            var response = enPlusService.platformPost(platformName, CommonApi.EN_PLUS_QUERY_STATION_STATUS.getApi(platformName), enPlusService.buildPlatformParams(platformName, param));
+            var response = platformApiService.platformPost(platformName, CommonApi.EN_PLUS_QUERY_STATION_STATUS.getApi(platformName), platformApiService.buildPlatformParams(platformName, param));
             var platform = PlatformCache.INSTANCE.getPlatformByName(platformName);
             var enStationStatus = JSONObject.parseObject(PlatformAesUtil.decrypt(platform.getDataSecret(), platform.getDataSecretIv(), response.getData()));
             res.addAll(enStationStatus.getJSONArray("StationStatusInfos").toJavaList(PlatformStationStatusInfo.class));
@@ -267,7 +267,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
                 }
                 """.formatted(stationId, startTime, endTime);
         var platformName = PlatformCache.INSTANCE.getPlatformNameByStationId(stationId);
-        var response = enPlusService.platformPost(platformName, CommonApi.EN_PLUS_QUERY_STATION_STATS.getApi(platformName), enPlusService.buildPlatformParams(platformName, param));
+        var response = platformApiService.platformPost(platformName, CommonApi.EN_PLUS_QUERY_STATION_STATS.getApi(platformName), platformApiService.buildPlatformParams(platformName, param));
         // TODO: 2023-08-12 包装成自己的数据格式
         var enStationStats = parsePlatformResponseData(response, platformName);
         return enStationStats.getJSONObject("StationStats").toJavaObject(PlatformStationStatsInfo.class);

+ 9 - 9
service/src/main/java/com/kym/service/miniapp/impl/ChargeServiceImpl.java

@@ -58,7 +58,7 @@ public class ChargeServiceImpl implements ChargeService {
     private final UserCouponService userCouponService;
     private final OrderCouponService orderCouponService;
     private final AccountService accountService;
-    private final PlatformApiService enPlusService;
+    private final PlatformApiService platformApiService;
     private final DelayService<DelayChargeOrder> startDelayService;
     private final DelayService<DelayChargeOrder> stopDelayService;
 
@@ -66,7 +66,7 @@ public class ChargeServiceImpl implements ChargeService {
                              ConnectorInfoService connectorInfoService, ChargeOrderService chargeOrderService,
                              OrderRechargeRightsService orderRechargeRightsService, UserRechargeRightsService userRechargeRightsService,
                              UserCouponService userCouponService, OrderCouponService orderCouponService,
-                             AccountService accountService, PlatformApiService enPlusService,
+                             AccountService accountService, PlatformApiService platformApiService,
                              @Qualifier("StartChargeDelayJob") @Lazy DelayService<DelayChargeOrder> startDelayService,
                              @Qualifier("StopChargeDelayJob") @Lazy DelayService<DelayChargeOrder> stopDelayService, StringRedisTemplate redisTemplate) {
         this.equipmentRelationService = equipmentRelationService;
@@ -78,7 +78,7 @@ public class ChargeServiceImpl implements ChargeService {
         this.userCouponService = userCouponService;
         this.orderCouponService = orderCouponService;
         this.accountService = accountService;
-        this.enPlusService = enPlusService;
+        this.platformApiService = platformApiService;
         this.startDelayService = startDelayService;
         this.stopDelayService = stopDelayService;
         this.redisTemplate = redisTemplate;
@@ -370,7 +370,7 @@ public class ChargeServiceImpl implements ChargeService {
     private Map<String, String> startCharge(ChargeOrder order, String connectorId, int balance) {
 
         // 请求设备认证
-        var equipAuth = enPlusService.queryEquipAuth(PlatformCache.INSTANCE.getPlatformNameByConnectorId(connectorId), connectorId, order.getStartChargeSeq());
+        var equipAuth = platformApiService.queryEquipAuth(PlatformCache.INSTANCE.getPlatformNameByConnectorId(connectorId), connectorId, order.getStartChargeSeq());
 
         if (equipAuth.containsKey("SuccStat") && equipAuth.getIntValue("SuccStat") == 0) {
             // 启动充电
@@ -379,15 +379,15 @@ public class ChargeServiceImpl implements ChargeService {
             try {
                 // 二维码文本
                 var qrCode = "";
-                startCharge = enPlusService.queryStartCharge(PlatformCache.INSTANCE.getPlatformNameByConnectorId(connectorId), order.getStartChargeSeq(), connectorId, qrCode, balance);
+                startCharge = platformApiService.queryStartCharge(PlatformCache.INSTANCE.getPlatformNameByConnectorId(connectorId), order.getStartChargeSeq(), connectorId, qrCode, balance);
             } catch (Exception e) {
                 // 这里可能超时,忽略
-                LOGGER.error("EN+启动充电超时,订单:{}", order.getStartChargeSeq());
+                LOGGER.error("启动充电超时,订单:{}", order.getStartChargeSeq());
                 // 启动充电超时,更新订单状态为取消
                 chargeOrderService.lambdaUpdate()
                         .set(ChargeOrder::getOrderStatus, ChargeOrder.CHARGE_STATUS_已取消)
                         .set(ChargeOrder::getChargeStatus, ChargeOrder.CHARGE_STATUS_已取消)
-                        .set(ChargeOrder::getStopReason, "EN+启动充电超时")
+                        .set(ChargeOrder::getStopReason, "启动充电超时")
                         .eq(ChargeOrder::getStartChargeSeq, order.getStartChargeSeq()).update();
                 return Map.of("startChargeSeq", order.getStartChargeSeq());
             }
@@ -547,7 +547,7 @@ public class ChargeServiceImpl implements ChargeService {
             LOGGER.error("用户:{}请求停止充电异常,设备:{}无进行中的订单", userId, connectorId);
             throw new BusinessException(ResponseEnum.NO_ORDER_IN_PROGRESS);
         }
-        var data = enPlusService.queryStopCharge(PlatformCache.INSTANCE.getPlatformNameByConnectorId(connectorId), chargeOrder.getStartChargeSeq(), connectorId);
+        var data = platformApiService.queryStopCharge(PlatformCache.INSTANCE.getPlatformNameByConnectorId(connectorId), chargeOrder.getStartChargeSeq(), connectorId);
         if (data.containsKey("SuccStat") && data.getIntValue("SuccStat") != 0) {
             // 记录失败原因
             LOGGER.error("订单:{}停止充电失败,返回结果:{}", chargeOrder.getStartChargeSeq(), data);
@@ -567,7 +567,7 @@ public class ChargeServiceImpl implements ChargeService {
     public PlatformBusinessPolicy queryEquipBusinessPolicy(String connectorId) {
         var platformName = PlatformCache.INSTANCE.getPlatformNameByConnectorId(connectorId);
         var equipBizSeq = OrderUtils.getOrderNo(PlatformCache.INSTANCE.getPlatformByName(platformName).getOperatorId());
-        var data = enPlusService.queryEquipBusinessPolicy(platformName, equipBizSeq, connectorId);
+        var data = platformApiService.queryEquipBusinessPolicy(platformName, equipBizSeq, connectorId);
         return data.toJavaObject(PlatformBusinessPolicy.class);
     }
 

+ 13 - 13
service/src/main/java/com/kym/service/platform/impl/PlatformNotifyServiceImpl.java

@@ -50,7 +50,7 @@ import java.util.stream.Collectors;
 public class PlatformNotifyServiceImpl implements PlatformNotifyService {
     private static final Logger LOGGER = LoggerFactory.getLogger(PlatformNotifyServiceImpl.class);
     public final StringRedisTemplate redisTemplate;
-    private final PlatformApiService enPlusService;
+    private final PlatformApiService platformApiService;
     private final ChargeOrderService chargeOrderService;
     private final ChargeService chargeService;
     private final AccountService accountService;
@@ -63,8 +63,8 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
     @Value("${kym.notify-email}")
     private String notifyEmail;
 
-    public PlatformNotifyServiceImpl(PlatformApiService enPlusService, ChargeOrderService chargeOrderService, ChargeService chargeService, AccountService accountService, WalletDetailService walletDetailService, MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService, ConnectorInfoService connectorInfoService, StringRedisTemplate redisTemplate, UserStationService userStationService) {
-        this.enPlusService = enPlusService;
+    public PlatformNotifyServiceImpl(PlatformApiService platformApiService, ChargeOrderService chargeOrderService, ChargeService chargeService, AccountService accountService, WalletDetailService walletDetailService, MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService, ConnectorInfoService connectorInfoService, StringRedisTemplate redisTemplate, UserStationService userStationService) {
+        this.platformApiService = platformApiService;
         this.chargeOrderService = chargeOrderService;
         this.chargeService = chargeService;
         this.accountService = accountService;
@@ -83,7 +83,7 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
 
     @Override
     public String queryToken(String platformName, JSONObject json) {
-        var data = enPlusService.signValidation(platformName, json);
+        var data = platformApiService.signValidation(platformName, json);
         LOGGER.info("【{}互联互通平台推送】收到请求快与慢Token:{},解密数据:{}", platformName, json, data);
         var platform = PlatformCache.INSTANCE.getPlatformByName(platformName);
         // 查询缓存,存在则返回值和过期时间,不存在则重新生成并缓存
@@ -118,7 +118,7 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
     @Override
     @DS("db-admin")
     public String handleNotificationStationStatus(String platformName, JSONObject json) {
-        var data = enPlusService.signValidation(platformName, json);
+        var data = platformApiService.signValidation(platformName, json);
         LOGGER.info("【{}互联互通平台推送】收到充电桩设备状态变化推送:{},解密数据:{}", platformName, json, data);
         // 更新数据库,存入redis,发送邮件通知
         var connectorStatusInfo = JSONObject.parseObject(data).getJSONObject("ConnectorStatusInfo").toJavaObject(PlatformConnectorStatusInfo.class);
@@ -182,8 +182,8 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
     @Transactional(rollbackFor = Exception.class)
     @DS("db-miniapp")
     public String handleNotificationStartChargeResult(String platformName, JSONObject json) {
-        var data = enPlusService.signValidation(platformName, json);
-        LOGGER.info("【EN+推送】收到启动充电结果推送:{},解密数据:{}", json, data);
+        var data = platformApiService.signValidation(platformName, json);
+        LOGGER.info("【{}互联互通平台推送】收到启动充电结果推送:{},解密数据:{}", platformName, json, data);
         var obj = JSONObject.parseObject(data);
         var startChargeSeq = obj.getString("StartChargeSeq");
         var startChargeSeqStat = obj.getIntValue("StartChargeSeqStat");
@@ -219,9 +219,9 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String handleNotificationEquipChargeStatus(String platformName, JSONObject json) {
-        var dataStr = enPlusService.signValidation(platformName, json);
+        var dataStr = platformApiService.signValidation(platformName, json);
         var data = JSONObject.parseObject(dataStr);
-        LOGGER.info("【EN+推送】 :{},解密数据:{}", json, data);
+        LOGGER.info("【{}互联互通平台推送】 :{},解密数据:{}", platformName, json, data);
         var startChargeSeq = data.getString("StartChargeSeq");
         var chargeOrder = chargeOrderService.getChargingOrderByStartChargeSeq(startChargeSeq);
         // 更新订单信息
@@ -257,9 +257,9 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String handleNotificationStopChargeResult(String platformName, JSONObject json) {
-        var dataStr = enPlusService.signValidation(platformName, json);
+        var dataStr = platformApiService.signValidation(platformName, json);
         var data = JSONObject.parseObject(dataStr);
-        LOGGER.info("【EN+推送】收到停止充电结果推送:{},解密数据:{}", json, data);
+        LOGGER.info("【{}互联互通平台推送】收到停止充电结果推送:{},解密数据:{}", platformName, json, data);
         var startChargeSeq = data.getString("StartChargeSeq");
         var chargeOrder = chargeOrderService.getChargingOrderByStartChargeSeq(startChargeSeq);
         if (data.containsKey("SuccStat") && data.getIntValue("SuccStat") == 0) {
@@ -286,9 +286,9 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
     @Override
     @DSTransactional(rollbackFor = Exception.class)
     public String handleNotificationChargeOrderInfo(String platformName, JSONObject json) {
-        var dataStr = enPlusService.signValidation(platformName, json);
+        var dataStr = platformApiService.signValidation(platformName, json);
         var data = JSONObject.parseObject(dataStr);
-        LOGGER.info("【EN+推送】收到充电订单信息推送:{},解密数据:{}", json, data);
+        LOGGER.info("【{}互联互通平台推送】收到充电订单信息推送:{},解密数据:{}", platformName, json, data);
         var startChargeSeq = data.getString("StartChargeSeq");
         var chargeOrder = chargeOrderService.getChargingOrderByStartChargeSeq(startChargeSeq);
 

+ 4 - 4
service/src/main/java/com/kym/service/wechat/impl/WxPayServiceImpl.java

@@ -105,7 +105,7 @@ public class WxPayServiceImpl implements WxPayService {
 
     private final InvoiceTitleService invoiceTitleService;
 
-    private final PlatformApiService enPlusService;
+    private final PlatformApiService platformApiService;
 
     private final ActivityService activityService;
 
@@ -123,7 +123,7 @@ public class WxPayServiceImpl implements WxPayService {
     public WxPayServiceImpl(WxPayConfig conf, WxFapiaoConfig fapiaoConfig, WalletDetailService walletDetailService,
                             PayLogService payLogService, AccountService accountService, ChargeOrderService chargeOrderService,
                             RefundLogService refundLogService, InvoiceService invoiceService, InvoiceTitleService invoiceTitleService,
-                            PlatformApiService enPlusService, ActivityService activityService, UserRechargeRightsService userRechargeRightsService, InvoiceDetailService invoiceDetailService) {
+                            PlatformApiService platformApiService, ActivityService activityService, UserRechargeRightsService userRechargeRightsService, InvoiceDetailService invoiceDetailService) {
         this.conf = conf;
         this.fapiaoConfig = fapiaoConfig;
         this.walletDetailService = walletDetailService;
@@ -133,7 +133,7 @@ public class WxPayServiceImpl implements WxPayService {
         this.refundLogService = refundLogService;
         this.invoiceService = invoiceService;
         this.invoiceTitleService = invoiceTitleService;
-        this.enPlusService = enPlusService;
+        this.platformApiService = platformApiService;
         this.activityService = activityService;
         this.userRechargeRightsService = userRechargeRightsService;
         this.invoiceDetailService = invoiceDetailService;
@@ -361,7 +361,7 @@ public class WxPayServiceImpl implements WxPayService {
                 if (chargingOrder != null) {
                     var account = accountService.getAccountByUserId(walletDetail.getUserId());
                     // TODO: 2023-11-30 快充这里考虑过充的金额要提高
-                    var res = enPlusService.updateBalanceByQueryEquipChargeStatus(PlatformCache.INSTANCE.getPlatformNameByConnectorId(chargingOrder.getConnectorId()), chargingOrder.getStartChargeSeq(), account.getBalance() - 50);
+                    var res = platformApiService.updateBalanceByQueryEquipChargeStatus(PlatformCache.INSTANCE.getPlatformNameByConnectorId(chargingOrder.getConnectorId()), chargingOrder.getStartChargeSeq(), account.getBalance() - 50);
                     LOGGER.info("用户:{}充电过程中充值,已更新en+充电金额,en+返回数据:{}", account.getUserId(), res);
                 }
                 return ResponseEntity.status(HttpStatus.OK).build();