From a432ff3c95923f9929236de9f7a9224e8517bb70 Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期五, 23 五月 2025 20:55:43 +0800
Subject: [PATCH] 大屏

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java |   52 ++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 36 insertions(+), 16 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 8ae8366..52fb479 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
@@ -39,6 +39,7 @@
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -66,9 +67,9 @@
 
     private final TChargingPileService chargingPileService;
     private final TChargingGunService chargingGunService;
-
+	
 	@Resource
-	private RedisService redisService;
+	private RedisTemplate redisTemplate;
 
 	@Resource
 	private TFaultMessageService faultMessageService;
@@ -244,17 +245,16 @@
 	public void updateChargingPileStatus(@RequestBody UpdateChargingPileStatusVo vo){
 		String pile_code = vo.getPile_code();
 		String gun_code = vo.getGun_code();
+		//0:正常,1:故障,2=插枪
 		Integer status = vo.getStatus();
-		Map<String, Object> charging_pile_online = redisService.getCacheMap("charging_gun_online");
-		Long time = (Long) charging_pile_online.get(pile_code + gun_code);
-		//小于30秒才处理数据,防止频繁查询数据
-		if(null != time && (System.currentTimeMillis() - time) < 30000){
+		Long time = (Long) redisTemplate.opsForHash().get("charging_gun_online", (pile_code + gun_code));
+		//小于1分钟才处理数据,防止频繁查询数据
+		if(null != time && (System.currentTimeMillis() - time) < 60000){
 			return;
 		}
 		TChargingGun tChargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getFullNumber, (pile_code + gun_code)).eq(TChargingGun::getDelFlag, 0));
 		if(null != tChargingGun){
-			charging_pile_online.put(tChargingGun.getFullNumber(), System.currentTimeMillis());
-			redisService.setCacheMap("charging_gun_online", charging_pile_online);
+			redisTemplate.opsForHash().put("charging_gun_online", tChargingGun.getFullNumber(), System.currentTimeMillis());
 			
 			TChargingPile chargingPile = chargingPileService.getById(tChargingGun.getChargingPileId());
 			//枪处于离线或者故障,返回状态为正常,则修改其状态
@@ -263,8 +263,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();
@@ -286,8 +291,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));
@@ -334,15 +344,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())

--
Gitblit v1.7.1