From f87ad18f9c3175cee155c4f0c06302369ec7ea9d Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 18 四月 2025 09:24:26 +0800 Subject: [PATCH] 临时屏蔽监管上传代码,暂停使用消息队列 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 14 + ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java | 36 +++- ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/ChargingMessageUtil.java | 203 ++++++++++-------------- ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java | 167 ++++++++------------ ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java | 9 5 files changed, 198 insertions(+), 231 deletions(-) diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java index e63f085..bdf4a07 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java @@ -264,8 +264,13 @@ tChargingGun1.setId(tChargingGun.getId()); tChargingGun1.setStatus(2); chargingGunService.updateById(tChargingGun1); - //推送状态给三方平台 - tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); + new Thread(new Runnable() { + @Override + public void run() { + //推送状态给三方平台 + tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); + } + }).start(); if(chargingPile.getStatus() != 1){ TChargingPile chargingPile1 = new TChargingPile(); @@ -287,8 +292,13 @@ tChargingGun1.setId(tChargingGun.getId()); tChargingGun1.setStatus(7); chargingGunService.updateById(tChargingGun1); - //推送状态给三方平台 - tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); + new Thread(new Runnable() { + @Override + public void run() { + //推送状态给三方平台 + tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); + } + }).start(); //桩处于正常,桩所属的枪都处于非正常,修改桩状态为异常 List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0)); @@ -335,15 +345,25 @@ tChargingGun1.setId(tChargingGun.getId()); chargingGunService.updateById(tChargingGun1); } - //推送状态给三方平台 - tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); + new Thread(new Runnable() { + @Override + public void run() { + //推送状态给三方平台 + tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); + } + }).start(); }else{ TChargingGun tChargingGun1 = new TChargingGun(); tChargingGun1.setId(tChargingGun.getId()); tChargingGun1.setStatus(3); chargingGunService.updateById(tChargingGun1); - //推送状态给三方平台 - tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); + new Thread(new Runnable() { + @Override + public void run() { + //推送状态给三方平台 + tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); + } + }).start(); } List<TFaultMessage> list = faultMessageService.list(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingGunId, tChargingGun.getId()) diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java index bf9828a..ac9279c 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java @@ -715,8 +715,13 @@ chargingGun1.setId(chargingGun.getId()); chargingGun1.setStatus(1); chargingGunService.updateById(chargingGun1); - //推送状态给三方平台 - tcecClient.pushChargingGunStatus(chargingGun1.getFullNumber(), chargingGun1.getStatus()); + new Thread(new Runnable() { + @Override + public void run() { + //推送状态给三方平台 + tcecClient.pushChargingGunStatus(chargingGun1.getFullNumber(), chargingGun1.getStatus()); + } + }).start(); //桩处于正常,桩所属的枪都处于非正常,修改桩状态为异常 TChargingPile chargingPile = this.getById(chargingGun.getChargingPileId()); diff --git a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java index 53b3c40..db9c638 100644 --- a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java +++ b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java @@ -86,23 +86,18 @@ OnlineMessage onlineMessage = JSON.parseObject(content.toJSONString(),OnlineMessage.class); chargingMessage.setOnlineMessage(onlineMessage); chargingMessageUtil.handleMessage(chargingMessage); - new Thread(new Runnable() { - @Override - public void run() { - // 响应硬件 - // 业务处理 登录认证应答 - OnlineReply onlineReply = new OnlineReply(); - onlineReply.setCharging_pile_code(onlineMessage.getCharging_pile_code()); - onlineReply.setOnline_result(0); - String result = iotMessageProduce.sendMessage(onlineReply.getCharging_pile_code(), ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply)); - log.info("充电桩登录认证-返回结果:{}",result); - // 响应硬件 对时设置应答 - TimingSettingReply timingSettingReplyOnline = new TimingSettingReply(); - timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code()); - timingSettingReplyOnline.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date())); - iotMessageProduce.sendMessage(timingSettingReplyOnline.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReplyOnline)); - } - }).start(); + // 响应硬件 + // 业务处理 登录认证应答 + OnlineReply onlineReply = new OnlineReply(); + onlineReply.setCharging_pile_code(onlineMessage.getCharging_pile_code()); + onlineReply.setOnline_result(0); + result = iotMessageProduce.sendMessage(onlineReply.getCharging_pile_code(), ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply)); + log.info("充电桩登录认证-返回结果:{}",result); + // 响应硬件 对时设置应答 + TimingSettingReply timingSettingReplyOnline = new TimingSettingReply(); + timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code()); + timingSettingReplyOnline.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date())); + iotMessageProduce.sendMessage(timingSettingReplyOnline.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReplyOnline)); // sendResult = enhanceProduce.chargingMessage(chargingMessage); break; case SendTagConstant.PING: @@ -110,16 +105,11 @@ chargingMessage.setPingMessage(pingMessage); chargingMessageUtil.handleMessage(chargingMessage); // 响应硬件 - new Thread(new Runnable() { - @Override - public void run() { - Pong pong = new Pong(); - pong.setCharging_pile_code(pingMessage.getCharging_pile_code()); - pong.setCharging_gun_code(pingMessage.getCharging_gun_code()); - pong.setCharging_gun_status(0); - iotMessageProduce.sendMessage(pong.getCharging_pile_code(), ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong)); - } - }).start(); + Pong pong = new Pong(); + pong.setCharging_pile_code(pingMessage.getCharging_pile_code()); + pong.setCharging_gun_code(pingMessage.getCharging_gun_code()); + pong.setCharging_gun_status(0); + iotMessageProduce.sendMessage(pong.getCharging_pile_code(), ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong)); // sendResult = enhanceProduce.chargingMessage(chargingMessage); break; case SendTagConstant.END_CHARGE: @@ -141,33 +131,28 @@ chargingMessage.setBillingModeVerifyMessage(billingModeVerifyMessage); chargingMessageUtil.handleMessage(chargingMessage); // 响应硬件 - new Thread(new Runnable() { - @Override - public void run() { - BillingModeVerifyReply billingModeVerifyReply = new BillingModeVerifyReply(); - if(billingModeVerifyMessage.getBilling_model_code().equals("0")){ - // 首次 - billingModeVerifyReply.setCharging_pile_code(billingModeVerifyMessage.getCharging_pile_code()); - billingModeVerifyReply.setBilling_model_code("0"); - billingModeVerifyReply.setBilling_model_result(1); - }else { - // 查询桩使用的模版 - CheckChargingStrategyDTO dto = new CheckChargingStrategyDTO(); - dto.setCode(billingModeVerifyMessage.getCharging_pile_code()); - dto.setStrategyDetailId(Integer.valueOf(billingModeVerifyMessage.getBilling_model_code())); - Boolean check = accountingStrategyDetailClient.checkChargingStrategy(dto).getData(); - // 校验计费模版是否准确 - billingModeVerifyReply.setCharging_pile_code(billingModeVerifyMessage.getCharging_pile_code()); - billingModeVerifyReply.setBilling_model_code(billingModeVerifyMessage.getBilling_model_code()); - if(check){ - billingModeVerifyReply.setBilling_model_result(0); - }else { - billingModeVerifyReply.setBilling_model_result(1); - } - } - iotMessageProduce.sendMessage(billingModeVerifyReply.getCharging_pile_code(), ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply)); + BillingModeVerifyReply billingModeVerifyReply = new BillingModeVerifyReply(); + if(billingModeVerifyMessage.getBilling_model_code().equals("0")){ + // 首次 + billingModeVerifyReply.setCharging_pile_code(billingModeVerifyMessage.getCharging_pile_code()); + billingModeVerifyReply.setBilling_model_code("0"); + billingModeVerifyReply.setBilling_model_result(1); + }else { + // 查询桩使用的模版 + CheckChargingStrategyDTO dto = new CheckChargingStrategyDTO(); + dto.setCode(billingModeVerifyMessage.getCharging_pile_code()); + dto.setStrategyDetailId(Integer.valueOf(billingModeVerifyMessage.getBilling_model_code())); + Boolean check = accountingStrategyDetailClient.checkChargingStrategy(dto).getData(); + // 校验计费模版是否准确 + billingModeVerifyReply.setCharging_pile_code(billingModeVerifyMessage.getCharging_pile_code()); + billingModeVerifyReply.setBilling_model_code(billingModeVerifyMessage.getBilling_model_code()); + if(check){ + billingModeVerifyReply.setBilling_model_result(0); + }else { + billingModeVerifyReply.setBilling_model_result(1); } - }).start(); + } + iotMessageProduce.sendMessage(billingModeVerifyReply.getCharging_pile_code(), ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply)); // sendResult = enhanceProduce.chargingMessage(chargingMessage); break; case SendTagConstant.ACQUISITION_BILLING_MODE: @@ -175,23 +160,18 @@ chargingMessage.setAcquisitionBillingModeMessage(acquisitionBillingModeMessage); chargingMessageUtil.handleMessage(chargingMessage); // 响应硬件 计费模型请求应答 1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段 - new Thread(new Runnable() { - @Override - public void run() { - List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailClient.getDetailListByCode(acquisitionBillingModeMessage.getCharging_pile_code()).getData(); - Map<Integer, TAccountingStrategyDetail> strategyPrice = StrategyUtil.getStrategyPrice(accountingStrategyDetails); - // 价格设置 - AcquisitionBillingModeReply acquisitionBillingModeReply = new AcquisitionBillingModeReply(); - StrategyUtil.setStrategyPrice(strategyPrice,acquisitionBillingModeReply); - // 时段设置 - StrategyUtil.setTime(accountingStrategyDetails,acquisitionBillingModeReply); - TAccountingStrategyDetail accountingStrategyDetail = accountingStrategyDetailClient.getDetailByCode(acquisitionBillingModeMessage.getCharging_pile_code()).getData(); - acquisitionBillingModeReply.setBilling_model_code(accountingStrategyDetail.getId().toString()); - acquisitionBillingModeReply.setCharging_pile_code(acquisitionBillingModeMessage.getCharging_pile_code()); - acquisitionBillingModeReply.setLoss_ratio(BigDecimal.ZERO); - iotMessageProduce.sendMessage(acquisitionBillingModeReply.getCharging_pile_code(), ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply)); - } - }).start(); + List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailClient.getDetailListByCode(acquisitionBillingModeMessage.getCharging_pile_code()).getData(); + Map<Integer, TAccountingStrategyDetail> strategyPrice = StrategyUtil.getStrategyPrice(accountingStrategyDetails); + // 价格设置 + AcquisitionBillingModeReply acquisitionBillingModeReply = new AcquisitionBillingModeReply(); + StrategyUtil.setStrategyPrice(strategyPrice,acquisitionBillingModeReply); + // 时段设置 + StrategyUtil.setTime(accountingStrategyDetails,acquisitionBillingModeReply); + TAccountingStrategyDetail accountingStrategyDetail = accountingStrategyDetailClient.getDetailByCode(acquisitionBillingModeMessage.getCharging_pile_code()).getData(); + acquisitionBillingModeReply.setBilling_model_code(accountingStrategyDetail.getId().toString()); + acquisitionBillingModeReply.setCharging_pile_code(acquisitionBillingModeMessage.getCharging_pile_code()); + acquisitionBillingModeReply.setLoss_ratio(BigDecimal.ZERO); + iotMessageProduce.sendMessage(acquisitionBillingModeReply.getCharging_pile_code(), ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply)); // sendResult = enhanceProduce.chargingMessage(chargingMessage); break; case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA: @@ -247,19 +227,14 @@ chargingMessage.setChargingPileStartsChargingMessage(chargingPileStartsChargingMessage); chargingMessageUtil.handleMessage(chargingMessage); // 响应硬件 - new Thread(new Runnable() { - @Override - public void run() { - PlatformConfirmationCharging platformConfirmationCharging = new PlatformConfirmationCharging(); - platformConfirmationCharging.setCharging_pile_code(chargingPileStartsChargingMessage.getCharging_pile_code()); - platformConfirmationCharging.setCharging_gun_code(chargingPileStartsChargingMessage.getCharging_gun_code()); - platformConfirmationCharging.setCard_number(chargingPileStartsChargingMessage.getAccount()); - platformConfirmationCharging.setAccount_balance(BigDecimal.ZERO); - platformConfirmationCharging.setAuthentication(1); - // TODO 若是失败,给出失败原因 - iotMessageProduce.sendMessage(platformConfirmationCharging.getCharging_pile_code(), ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getKey(),messageUtil.platformConfirmationCharging(platformConfirmationCharging)); - } - }).start(); + PlatformConfirmationCharging platformConfirmationCharging = new PlatformConfirmationCharging(); + platformConfirmationCharging.setCharging_pile_code(chargingPileStartsChargingMessage.getCharging_pile_code()); + platformConfirmationCharging.setCharging_gun_code(chargingPileStartsChargingMessage.getCharging_gun_code()); + platformConfirmationCharging.setCard_number(chargingPileStartsChargingMessage.getAccount()); + platformConfirmationCharging.setAccount_balance(BigDecimal.ZERO); + platformConfirmationCharging.setAuthentication(1); + // TODO 若是失败,给出失败原因 + iotMessageProduce.sendMessage(platformConfirmationCharging.getCharging_pile_code(), ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getKey(),messageUtil.platformConfirmationCharging(platformConfirmationCharging)); // sendResult = enhanceProduce.chargingMessage(chargingMessage); break; case SendTagConstant.PLATFORM_START_CHARGING_REPLY: @@ -282,15 +257,10 @@ chargingMessage.setTransactionRecordMessage(transactionRecordMessage); chargingMessageUtil.handleMessage(chargingMessage); // 响应硬件 - new Thread(new Runnable() { - @Override - public void run() { - ConfirmTransactionRecord confirmTransactionRecord = new ConfirmTransactionRecord(); - confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number()); - confirmTransactionRecord.setConfirm_result(0); - iotMessageProduce.sendMessage(transactionRecordMessage.getCharging_pile_code(), ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord)); - } - }).start(); + ConfirmTransactionRecord confirmTransactionRecord = new ConfirmTransactionRecord(); + confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number()); + confirmTransactionRecord.setConfirm_result(0); + iotMessageProduce.sendMessage(transactionRecordMessage.getCharging_pile_code(), ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord)); // sendResult = enhanceProduce.chargingMessage(chargingMessage); break; case SendTagConstant.UPDATE_BALANCE_REPLY: @@ -326,15 +296,10 @@ chargingMessage.setTimingSettingMessage(timingSettingMessage); chargingMessageUtil.handleMessage(chargingMessage); // 响应硬件 对时设置应答 - new Thread(new Runnable() { - @Override - public void run() { - TimingSettingReply timingSettingReply = new TimingSettingReply(); - timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code()); - timingSettingReply.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date())); - iotMessageProduce.sendMessage(timingSettingReply.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply)); - } - }).start(); + TimingSettingReply timingSettingReply = new TimingSettingReply(); + timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code()); + timingSettingReply.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date())); + iotMessageProduce.sendMessage(timingSettingReply.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply)); // sendResult = enhanceProduce.chargingMessage(chargingMessage); break; case SendTagConstant.SETUP_BILLING_MODEL_REPLY: diff --git a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/ChargingMessageUtil.java b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/ChargingMessageUtil.java index 60bd13f..780b998 100644 --- a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/ChargingMessageUtil.java +++ b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/ChargingMessageUtil.java @@ -105,8 +105,8 @@ private QrCodeDeliveryReplyService qrCodeDeliveryReplyService; @Autowired private SecurityDetectionService securityDetectionService; - @Autowired - private TCECPushUtil tcecPushUtil; +// @Autowired +// private TCECPushUtil tcecPushUtil; @Resource private ChargingPileClient chargingPileClient; @@ -146,24 +146,26 @@ pingService.save(ping); //存储缓存中,5分钟有效 redisTemplate.opsForValue().set("ping:" + ping.getCharging_pile_code() + ping.getCharging_gun_code(), ping, 5, TimeUnit.MINUTES); - ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor.execute(new Runnable() { - @Override - public void run() { - UpdateChargingPileStatusVo vo1 = new UpdateChargingPileStatusVo(); - vo1.setGun_code(pingMessage.getCharging_gun_code()); - vo1.setPile_code(pingMessage.getCharging_pile_code()); - vo1.setStatus(pingMessage.getCharging_gun_status()); - chargingPileClient.updateChargingPileStatus(vo1); - try { - tcecPushUtil.pushSuperviseNotificationStationStatus(chargingGunClient.getChargingGunByFullNumber(pingMessage.getCharging_pile_code()+pingMessage.getCharging_gun_code()).getData()); - }catch (Exception e){ - e.printStackTrace(); - System.out.println("设备状态推送监管平台失败:"+e.getMessage()); - } - } - }); + UpdateChargingPileStatusVo vo1 = new UpdateChargingPileStatusVo(); + vo1.setGun_code(pingMessage.getCharging_gun_code()); + vo1.setPile_code(pingMessage.getCharging_pile_code()); + vo1.setStatus(pingMessage.getCharging_gun_status()); + chargingPileClient.updateChargingPileStatus(vo1); + +// ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); +// threadPoolExecutor.execute(new Runnable() { +// @Override +// public void run() { +// +// try { +//// tcecPushUtil.pushSuperviseNotificationStationStatus(chargingGunClient.getChargingGunByFullNumber(pingMessage.getCharging_pile_code()+pingMessage.getCharging_gun_code()).getData()); +// }catch (Exception e){ +// e.printStackTrace(); +// System.out.println("设备状态推送监管平台失败:"+e.getMessage()); +// } +// } +// }); break; case SendTagConstant.END_CHARGE: EndChargeMessage endChargeMessage = message.getEndChargeMessage(); @@ -172,22 +174,22 @@ EndCharge endCharge = new EndCharge(); BeanUtils.copyProperties(endChargeMessage,endCharge); endChargeService.create(endCharge); - ThreadPoolExecutor threadPoolExecutor1 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor1.execute(new Runnable() { - @Override - public void run() { - // 业务处理 - chargingOrderClient.endCharge(endCharge.getTransaction_serial_number()); - try { - TChargingOrder chargingOrder = chargingOrderClient.getOrderByCode(endCharge.getTransaction_serial_number()).getData(); - tcecPushUtil.pushSuperviseNotificationChargeOrderInfo(chargingOrder); - tcecPushUtil.pushSuperviseNotificationEquipChargeStatus(chargingOrder); - }catch (Exception e){ - e.printStackTrace(); - System.out.println("充电结束推送监管平台失败:"+e.getMessage()); - } - } - }); + // 业务处理 + chargingOrderClient.endCharge(endCharge.getTransaction_serial_number()); +// ThreadPoolExecutor threadPoolExecutor1 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); +// threadPoolExecutor1.execute(new Runnable() { +// @Override +// public void run() { +// try { +// TChargingOrder chargingOrder = chargingOrderClient.getOrderByCode(endCharge.getTransaction_serial_number()).getData(); +// tcecPushUtil.pushSuperviseNotificationChargeOrderInfo(chargingOrder); +// tcecPushUtil.pushSuperviseNotificationEquipChargeStatus(chargingOrder); +// }catch (Exception e){ +// e.printStackTrace(); +// System.out.println("充电结束推送监管平台失败:"+e.getMessage()); +// } +// } +// }); break; case SendTagConstant.ERROR_MESSAGE: ErrorMessageMessage errorMessageMessage1 = message.getErrorMessageMessage(); @@ -249,19 +251,19 @@ log.error("数据存储mongo失败"); } - ThreadPoolExecutor threadPoolExecutor2 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor2.execute(new Runnable() { - @Override - public void run() { - // 业务处理 - UploadRealTimeMonitoringDataQuery query = new UploadRealTimeMonitoringDataQuery(); - BeanUtils.copyProperties(uploadRealTimeMonitoringData, query); - chargingOrderClient.chargeMonitoring(query); - chargingOrder.setEndSoc(uploadRealTimeMonitoringDataMessage.getSoc()+""); - - tcecPushUtil.pushSuperviseNotificationEquipChargeStatus(chargingOrder); - } - }); + // 业务处理 + UploadRealTimeMonitoringDataQuery query = new UploadRealTimeMonitoringDataQuery(); + BeanUtils.copyProperties(uploadRealTimeMonitoringData, query); + chargingOrderClient.chargeMonitoring(query); +// ThreadPoolExecutor threadPoolExecutor2 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); +// threadPoolExecutor2.execute(new Runnable() { +// @Override +// public void run() { +// chargingOrder.setEndSoc(uploadRealTimeMonitoringDataMessage.getSoc()+""); +// +// tcecPushUtil.pushSuperviseNotificationEquipChargeStatus(chargingOrder); +// } +// }); } catch (Exception e) { e.printStackTrace(); } @@ -306,14 +308,8 @@ MotorAbort motorAbort = new MotorAbort(); BeanUtils.copyProperties(motorAbortMessage,motorAbort); motorAbortService.create(motorAbort); - ThreadPoolExecutor threadPoolExecutor4 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor4.execute(new Runnable() { - @Override - public void run() { - // 业务处理 - chargingOrderClient.excelEndCharge(motorAbort.getTransaction_serial_number()); - } - }); + // 业务处理 + chargingOrderClient.excelEndCharge(motorAbort.getTransaction_serial_number()); break; case SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION: BmsDemandAndChargerExportationMessage bmsDemandAndChargerExportationMessage = message.getBmsDemandAndChargerExportationMessage(); @@ -322,18 +318,13 @@ BmsDemandAndChargerExportation bmsDemandAndChargerExportation = new BmsDemandAndChargerExportation(); BeanUtils.copyProperties(bmsDemandAndChargerExportationMessage,bmsDemandAndChargerExportation); bmsDemandAndChargerExportationService.create(bmsDemandAndChargerExportation); - ThreadPoolExecutor threadPoolExecutor5 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor5.execute(new Runnable() { - @Override - public void run() { - // 业务处理 - TChargingOrder chargingOrderBms = chargingOrderClient.getOrderByCode(bmsDemandAndChargerExportationMessage.getTransaction_serial_number()).getData(); - if(Objects.nonNull(chargingOrderBms)){ - chargingOrderBms.setNeedElec(bmsDemandAndChargerExportationMessage.getBms_current_requirements()); - chargingOrderClient.updateChargingOrder(chargingOrderBms); - } - } - }); + + // 业务处理 + TChargingOrder chargingOrderBms = chargingOrderClient.getOrderByCode(bmsDemandAndChargerExportationMessage.getTransaction_serial_number()).getData(); + if(Objects.nonNull(chargingOrderBms)){ + chargingOrderBms.setNeedElec(bmsDemandAndChargerExportationMessage.getBms_current_requirements()); + chargingOrderClient.updateChargingOrder(chargingOrderBms); + } break; case SendTagConstant.BMS_INFORMATION: BmsInformationMessage bmsInformationMessage = message.getBmsInformationMessage(); @@ -358,16 +349,11 @@ PlatformStartChargingReply platformStartChargingReply = new PlatformStartChargingReply(); BeanUtils.copyProperties(platformStartChargingReplyMessage,platformStartChargingReply); platformStartChargingReplyService.create(platformStartChargingReply); - ThreadPoolExecutor threadPoolExecutor6 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor6.execute(new Runnable() { - @Override - public void run() { - // 业务处理 - PlatformStartChargingReplyMessageVO message1 = new PlatformStartChargingReplyMessageVO(); - BeanUtils.copyProperties(platformStartChargingReplyMessage, message1); - chargingOrderClient.startChargeSuccessfully(message1); - } - }); + + // 业务处理 + PlatformStartChargingReplyMessageVO message1 = new PlatformStartChargingReplyMessageVO(); + BeanUtils.copyProperties(platformStartChargingReplyMessage, message1); + chargingOrderClient.startChargeSuccessfully(message1); break; case SendTagConstant.PLATFORM_STOP_CHARGING_REPLY: PlatformStopChargingReplyMessage platformStopChargingReplyMessage = message.getPlatformStopChargingReplyMessage(); @@ -376,15 +362,10 @@ PlatformStopChargingReply platformStopChargingReply = new PlatformStopChargingReply(); BeanUtils.copyProperties(platformStopChargingReplyMessage,platformStopChargingReply); platformStopChargingReplyService.create(platformStopChargingReply); - ThreadPoolExecutor threadPoolExecutor7 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor7.execute(new Runnable() { - @Override - public void run() { - PlatformStopChargingReplyVO platformStopChargingReply1 = new PlatformStopChargingReplyVO(); - BeanUtils.copyProperties(platformStopChargingReply, platformStopChargingReply1); - chargingOrderClient.terminateSuccessfulResponse(platformStopChargingReply1); - } - }); + + PlatformStopChargingReplyVO platformStopChargingReply1 = new PlatformStopChargingReplyVO(); + BeanUtils.copyProperties(platformStopChargingReply, platformStopChargingReply1); + chargingOrderClient.terminateSuccessfulResponse(platformStopChargingReply1); break; case SendTagConstant.TRANSACTION_RECORD: TransactionRecordMessage transactionRecordMessage = message.getTransactionRecordMessage(); @@ -394,26 +375,21 @@ TransactionRecord transactionRecord = new TransactionRecord(); BeanUtils.copyProperties(transactionRecordMessage,transactionRecord); transactionRecordService.create(transactionRecord); - ThreadPoolExecutor threadPoolExecutor8 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor8.execute(new Runnable() { - @Override - public void run() { - // 业务处理 - TChargingOrder chargingOrderRecord = chargingOrderClient.getOrderByCode(transactionRecordMessage.getTransaction_serial_number()).getData(); - if(Objects.nonNull(chargingOrderRecord)){ - chargingOrderRecord.setTotalElectricity(transactionRecordMessage.getTotal_electricity()); - chargingOrderClient.updateChargingOrder(chargingOrderRecord); - } - //计算费用 - TransactionRecordMessageVO vo = new TransactionRecordMessageVO(); - BeanUtils.copyProperties(transactionRecordMessage,vo); - int code = chargingOrderClient.endChargeBillingCharge(vo).getCode(); - if(200 != code){ - //失败后添加到队列中继续处理数据 - redisTemplate.opsForSet().add(SendTagConstant.TRANSACTION_RECORD, transactionRecordMessage.getTransaction_serial_number()); - } - } - }); + + // 业务处理 + TChargingOrder chargingOrderRecord = chargingOrderClient.getOrderByCode(transactionRecordMessage.getTransaction_serial_number()).getData(); + if(Objects.nonNull(chargingOrderRecord)){ + chargingOrderRecord.setTotalElectricity(transactionRecordMessage.getTotal_electricity()); + chargingOrderClient.updateChargingOrder(chargingOrderRecord); + } + //计算费用 + TransactionRecordMessageVO vo = new TransactionRecordMessageVO(); + BeanUtils.copyProperties(transactionRecordMessage,vo); + int code = chargingOrderClient.endChargeBillingCharge(vo).getCode(); + if(200 != code){ + //失败后添加到队列中继续处理数据 + redisTemplate.opsForSet().add(SendTagConstant.TRANSACTION_RECORD, transactionRecordMessage.getTransaction_serial_number()); + } // 添加实时上传记录结束记录 @@ -511,15 +487,10 @@ SecurityDetection securityDetection = new SecurityDetection(); BeanUtils.copyProperties(securityDetectionMessage,securityDetection); securityDetectionService.create(securityDetection); - ThreadPoolExecutor threadPoolExecutor9 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - threadPoolExecutor9.execute(new Runnable() { - @Override - public void run() { - SecurityDetectionVO securityDetection1 = new SecurityDetectionVO(); - BeanUtils.copyProperties(securityDetection, securityDetection1); - chargingOrderClient.securityDetection(securityDetection1); - } - }); + + SecurityDetectionVO securityDetection1 = new SecurityDetectionVO(); + BeanUtils.copyProperties(securityDetection, securityDetection1); + chargingOrderClient.securityDetection(securityDetection1); break; default: PlatformRemoteUpdateReplyMessage platformRemoteUpdateReplyMessage = message.getPlatformRemoteUpdateReplyMessage(); diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java index 09cb9c0..f1501af 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java @@ -2421,10 +2421,16 @@ //推送三方平台 if(2 == chargingOrder.getOrderSource()){ - tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); - tcecClient.notificationStopChargeResult(chargingOrder.getStartChargeSeq(), chargingOrder.getChargingGunId().toString(), - chargingOrder.getOperatorId()); - tcecClient.notificationChargeOrderInfo(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); + TChargingOrder finalChargingOrder = chargingOrder; + new Thread(new Runnable() { + @Override + public void run() { + tcecClient.notificationEquipChargeStatus(finalChargingOrder.getStartChargeSeq(), finalChargingOrder.getOperatorId()); + tcecClient.notificationStopChargeResult(finalChargingOrder.getStartChargeSeq(), finalChargingOrder.getChargingGunId().toString(), + finalChargingOrder.getOperatorId()); + tcecClient.notificationChargeOrderInfo(finalChargingOrder.getStartChargeSeq(), finalChargingOrder.getOperatorId()); + } + }).start(); } //开始将优惠券优惠的金额添加到明细中 -- Gitblit v1.7.1