Pu Zhibing
2 天以前 15dcbd07dfb421e81bf2401cc37b8a6bca6d4211
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -797,6 +797,7 @@
      String key = "AQJC_" + chargingOrder.getChargingGunId();
      List<PlatformStartChargingReply> data = platformStartChargingReplyService.getPlatformStartChargingReply(code);
      log.info(code + ":-------------------开始检查调起充电结果-------------------" + data.toString());
      Site site = siteClient.getSiteByIds(Arrays.asList(chargingOrder.getSiteId())).getData().get(0);
      if (data.size() != 0) {
         PlatformStartChargingReply platformStartChargingReply = data.get(1);
         Integer startup_result = platformStartChargingReply.getStartup_result();
@@ -842,7 +843,7 @@
         
         redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS);
         //推送三方平台订单状态
         if (2 == chargingOrder.getOrderSource()) {
         if (2 == chargingOrder.getOrderSource() && 1 == site.getIsOpenSynchronization()) {
            tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId());
         }
         return true;
@@ -876,7 +877,7 @@
         this.updateById(order);
         redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS);
         //推送三方平台订单状态
         if (2 == chargingOrder.getOrderSource()) {
         if (2 == chargingOrder.getOrderSource() && 1 == site.getIsOpenSynchronization()) {
            tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId());
         }
         return true;
@@ -917,6 +918,7 @@
      if (order.getStatus() != 2) {
         return;
      }
      Site site = siteClient.getSiteByIds(Arrays.asList(order.getSiteId())).getData().get(0);
      String code = order.getCode();
      PreChargeCheck preChargeCheck1 = redisService.getCacheObject("AQJC_" + order.getChargingGunId());
      if (null != preChargeCheck1) {
@@ -940,8 +942,10 @@
         TChargingGun chargingGun = chargingGunClient.getChargingGunById(order.getChargingGunId()).getData();
         chargingGun.setStatus(4);
         chargingGunClient.updateChargingGunById(chargingGun);
         //推送状态给三方平台
         tcecClient.pushChargingGunStatus(chargingGun.getFullNumber(), 4);
         if(1 == site.getIsOpenSynchronization()){
            //推送状态给三方平台
            tcecClient.pushChargingGunStatus(chargingGun.getFullNumber(), 4);
         }
      }
      redisService.setCacheObject("AQJC_" + order.getChargingGunId(), preChargeCheck1, 24L, TimeUnit.HOURS);
      this.updateById(order);
@@ -963,9 +967,12 @@
         result.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
         Operator operator = operatorClient.getOperatorById(order.getOperatorId()).getData();
         result.setOperatorID(operator.getOperatorId());
         tcecClient.notificationStartChargeResult(result);
         if(1 == site.getIsOpenSynchronization()){
            tcecClient.notificationStartChargeResult(result);
            tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId());
         }
         
         tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId());
      }
   }
   
@@ -1270,12 +1277,14 @@
      }
      Long userId = tokenService.getLoginUserApplet().getUserId();
      if (!order.getAppUserId().equals(userId)) {
         log.info("【" + order.getCode() + "】主动停止充电失败,用户权限不足。当前登录用户id:{},订单用户id:{}", userId, order.getAppUserId());
         return AjaxResult.error("权限不足");
      }
      order.setEndTime(LocalDateTime.now());
      order.setStatus(4);
      order.setEndMode(1);
      this.updateById(order);
      log.info("【" + order.getCode() + "】主动停止充电成功,订单状态已被修改。");
      
      String code1 = order.getCode();
      TChargingGun chargingGun = chargingGunClient.getChargingGunById(order.getChargingGunId()).getData();
@@ -1291,8 +1300,9 @@
         log.info(code1 + ":-------------------远程停止充电请求-------------------");
         log.info(platformStopCharging.toString());
      });
      Site site = siteClient.getSiteByIds(Arrays.asList(order.getSiteId())).getData().get(0);
      //推送三方平台
      if (2 == order.getOrderSource()) {
      if (2 == order.getOrderSource() && 1 == site.getIsOpenSynchronization()) {
         tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId());
      }
      
@@ -2594,9 +2604,9 @@
         redisService.setCacheObject("chargingOrderStatus:" + vo.getTransaction_serial_number(), 5, 100L, TimeUnit.SECONDS);
         
         chargingOrder = this.getById(chargingOrder.getId());
         Site site = siteClient.getSiteByIds(Arrays.asList(chargingOrder.getSiteId())).getData().get(0);
         //推送三方平台
         if (2 == chargingOrder.getOrderSource()) {
         if (2 == chargingOrder.getOrderSource() && 1 == site.getIsOpenSynchronization()) {
            TChargingOrder finalChargingOrder = chargingOrder;
            new Thread(new Runnable() {
               @Override
@@ -2632,7 +2642,7 @@
         chargingGunClient.updateChargingGunById(chargingGun);
         chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData();
         //推送状态给三方平台
         if (2 == chargingOrder.getOrderSource()) {
         if (2 == chargingOrder.getOrderSource() && 1 == site.getIsOpenSynchronization()) {
            tcecClient.pushChargingGunStatus(chargingGun.getFullNumber(), 2);
         }
         
@@ -4108,9 +4118,11 @@
//            scheduler.shutdown();
//         }
//      }, 5, 1, TimeUnit.SECONDS);
      //推送三方平台订单状态
      tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId());
      Site site = siteClient.getSiteByIds(Arrays.asList(chargingOrder.getSiteId())).getData().get(0);
      if(1 == site.getIsOpenSynchronization()){
         //推送三方平台订单状态
         tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId());
      }
      return R.ok();
   }
   
@@ -4123,12 +4135,16 @@
    */
   @Override
   public R tripartitePlatformStopCharge(String startChargeSeq) {
      log.info("三方平台请求停止充电:" + startChargeSeq);
      TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getStartChargeSeq, startChargeSeq));
      Integer status = order.getStatus();
      String code1 = order.getCode();
      if (status != 3) {
         log.info("【" + code1 + "】三方平台请求停止充电失败:还未开始充电");
         return R.fail("还未开始充电");
      }
      if (status == 4 || status == 5) {
         log.info("【" + code1 + "】三方平台请求停止充电:不能重复操作");
         return R.fail("不能重复操作");
      }
      TChargingOrder chargingOrder = new TChargingOrder();
@@ -4138,9 +4154,10 @@
      chargingOrder.setStatus(4);
      chargingOrder.setEndMode(1);
      this.updateById(chargingOrder);
      tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId());
      String code1 = order.getCode();
      Site site = siteClient.getSiteByIds(Arrays.asList(order.getSiteId())).getData().get(0);
      if(1 == site.getIsOpenSynchronization()){
         tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId());
      }
      TChargingGun chargingGun = chargingGunClient.getChargingGunById(order.getChargingGunId()).getData();
      //异步线程处理停机
      ExecutorService cachedThreadPool = Executors.newFixedThreadPool(1);
@@ -4150,8 +4167,9 @@
         PlatformStopCharging platformStopCharging = new PlatformStopCharging();
         platformStopCharging.setCharging_pile_code(chargingPile.getCode());
         platformStopCharging.setCharging_gun_code(chargingGun.getCode());
         log.info("【" + code1 + "】三方平台请求停止充电发起消息:" + JSON.toJSONString(platformStopCharging));
         sendMessageClient.platformStopCharging(platformStopCharging);
         log.info(code1 + ":-------------------远程停止充电请求-------------------");
         log.info("【" + code1 + "】三方平台请求停止充电发起消息结束");
         log.info(platformStopCharging.toString());
      });
      return R.ok();
@@ -4191,8 +4209,7 @@
//      tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId());
//      tcecClient.notificationStopChargeResult(chargingOrder.getStartChargeSeq(), chargingOrder.getChargingGunId().toString(),
//            chargingOrder.getOperatorId());
      tcecClient.notificationChargeOrderInfo(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId());
      return R.ok();
      return tcecClient.notificationChargeOrderInfo(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId());
   }