From 61bbbed153053e2f117334e5ddc60b66fae8aa32 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Thu, 25 Jul 2024 13:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E8=83=BD=E7=A9=BA=E8=B0=83=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E5=85=B3=E6=9C=BA=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/api/EleAirStrategyFeignClient.java | 5 +- .../EleAirStrategyFallbackFactory.java | 2 +- .../controller/EleAirStrategyController.java | 4 +- .../energy/service/EleAirStrategyService.java | 2 +- .../impl/EleAirStrategyServiceImpl.java | 58 ++++++++----------- .../service/impl/HighAnalyticServiceImpl.java | 2 - .../tasks/energy/AirControllerRunner.java | 19 ++++++ 7 files changed, 51 insertions(+), 41 deletions(-) create mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/energy/AirControllerRunner.java diff --git a/pqs-energy/energy-api/src/main/java/com/njcn/energy/pojo/api/EleAirStrategyFeignClient.java b/pqs-energy/energy-api/src/main/java/com/njcn/energy/pojo/api/EleAirStrategyFeignClient.java index 15d870178..d9ba91688 100644 --- a/pqs-energy/energy-api/src/main/java/com/njcn/energy/pojo/api/EleAirStrategyFeignClient.java +++ b/pqs-energy/energy-api/src/main/java/com/njcn/energy/pojo/api/EleAirStrategyFeignClient.java @@ -2,6 +2,7 @@ package com.njcn.energy.pojo.api; import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.response.HttpResult; +import com.njcn.energy.pojo.api.fallback.EleAirStrategyFallbackFactory; import com.njcn.energy.pojo.api.fallback.EleOnlineRateFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -14,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam; * @author cdf * @date 2022/4/22 */ -@FeignClient(value = ServerInfo.ENERGY,path = "/air",fallbackFactory = EleOnlineRateFallbackFactory.class) +@FeignClient(value = ServerInfo.ENERGY,path = "/air",fallbackFactory = EleAirStrategyFallbackFactory.class) public interface EleAirStrategyFeignClient { /** @@ -23,6 +24,6 @@ public interface EleAirStrategyFeignClient { * @date 2022/4/22 */ @GetMapping("dealAirStrategyId") - HttpResult dealAirStrategyId(@RequestParam("id") String id,@RequestParam("operation") String operation); + HttpResult dealAirStrategyId(@RequestParam("operation") String operation); } diff --git a/pqs-energy/energy-api/src/main/java/com/njcn/energy/pojo/api/fallback/EleAirStrategyFallbackFactory.java b/pqs-energy/energy-api/src/main/java/com/njcn/energy/pojo/api/fallback/EleAirStrategyFallbackFactory.java index cef336c12..15a9b4bd2 100644 --- a/pqs-energy/energy-api/src/main/java/com/njcn/energy/pojo/api/fallback/EleAirStrategyFallbackFactory.java +++ b/pqs-energy/energy-api/src/main/java/com/njcn/energy/pojo/api/fallback/EleAirStrategyFallbackFactory.java @@ -33,7 +33,7 @@ public class EleAirStrategyFallbackFactory implements FallbackFactory finalExceptionEnum = exceptionEnum; return new EleAirStrategyFeignClient() { @Override - public HttpResult dealAirStrategyId(String id,String operation) { + public HttpResult dealAirStrategyId(String operation) { log.error("{}异常,降级处理,异常为:{}","空调控制策略数据",cause.toString()); throw new BusinessException(finalExceptionEnum); } diff --git a/pqs-energy/energy-boot/src/main/java/com/njcn/energy/controller/EleAirStrategyController.java b/pqs-energy/energy-boot/src/main/java/com/njcn/energy/controller/EleAirStrategyController.java index 5ea28598f..ffb399413 100644 --- a/pqs-energy/energy-boot/src/main/java/com/njcn/energy/controller/EleAirStrategyController.java +++ b/pqs-energy/energy-boot/src/main/java/com/njcn/energy/controller/EleAirStrategyController.java @@ -201,8 +201,8 @@ public class EleAirStrategyController extends BaseController { @OperateInfo(info = LogEnum.SYSTEM_COMMON) @GetMapping("/dealAirStrategyId") @ApiOperation("根据策略定时开启关闭空调") - public void dealAirStrategyId(@RequestParam("id")String id,@RequestParam("operation")String operation) { - eleAirStrategyService.dealAirStrategyId(id, operation); + public void dealAirStrategyId(@RequestParam("operation")String operation) { + eleAirStrategyService.dealAirStrategyId(operation); } diff --git a/pqs-energy/energy-boot/src/main/java/com/njcn/energy/service/EleAirStrategyService.java b/pqs-energy/energy-boot/src/main/java/com/njcn/energy/service/EleAirStrategyService.java index ef492a7c4..cebfa2fda 100644 --- a/pqs-energy/energy-boot/src/main/java/com/njcn/energy/service/EleAirStrategyService.java +++ b/pqs-energy/energy-boot/src/main/java/com/njcn/energy/service/EleAirStrategyService.java @@ -74,7 +74,7 @@ public interface EleAirStrategyService extends IService { * @author cdf * @date 2022/4/22 */ - void dealAirStrategyId(String id,String operation); + void dealAirStrategyId(String operation); diff --git a/pqs-energy/energy-boot/src/main/java/com/njcn/energy/service/impl/EleAirStrategyServiceImpl.java b/pqs-energy/energy-boot/src/main/java/com/njcn/energy/service/impl/EleAirStrategyServiceImpl.java index 89a702cad..412f85584 100644 --- a/pqs-energy/energy-boot/src/main/java/com/njcn/energy/service/impl/EleAirStrategyServiceImpl.java +++ b/pqs-energy/energy-boot/src/main/java/com/njcn/energy/service/impl/EleAirStrategyServiceImpl.java @@ -32,11 +32,11 @@ import com.njcn.energy.pojo.vo.AirStrategyVO; import com.njcn.energy.service.EleAirStrategyService; import com.njcn.energy.service.IEleSetService; import com.njcn.influx.utils.InfluxDbUtils; -import com.njcn.job.api.JobFeignClient; -import com.njcn.job.model.XxlJobInfo; +//import com.njcn.job.api.JobFeignClient; +//import com.njcn.job.model.XxlJobInfo; import com.njcn.web.factory.PageFactory; import com.njcn.web.utils.RequestUtil; -import com.xxl.job.core.biz.model.ReturnT; +//import com.xxl.job.core.biz.model.ReturnT; import lombok.RequiredArgsConstructor; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.influxdb.dto.QueryResult; @@ -66,7 +66,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl result = jobFeignClient.addJob(xxlJobInfo); if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) { throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR); @@ -176,7 +176,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl result = jobFeignClient.removeJob(Integer.parseInt(xxlId)); if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) { throw new BusinessException(EnergyResponseEnum.TASK_DEL_ERROR); } - } + }*/ return true; } @@ -389,13 +391,13 @@ public class EleAirStrategyServiceImpl extends ServiceImpl result = jobFeignClient.stopJob(Integer.parseInt(xxlId)); if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) { throw new BusinessException(EnergyResponseEnum.TASK_STOP_ERROR); } - } + }*/ this.lambdaUpdate() .set(AirStrategy::getStatus, 4) @@ -430,21 +432,21 @@ public class EleAirStrategyServiceImpl extends ServiceImpl result = jobFeignClient.startTask(Integer.parseInt(xxlId)); if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) { throw new BusinessException(EnergyResponseEnum.TASK_RUNING); } - } + }*/ this.lambdaUpdate().set(AirStrategy::getStatus, 1).eq(AirStrategy::getId, id).update(); } else if (airStrategy.getStatus() == 1) { //已经执行中 - for (String xxlId : ids) { + /* for (String xxlId : ids) { HttpResult result = jobFeignClient.stopJob(Integer.parseInt(xxlId)); if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) { throw new BusinessException(EnergyResponseEnum.TASK_DEL_ERROR); } - } + }*/ this.lambdaUpdate().set(AirStrategy::getStatus, 0).eq(AirStrategy::getId, id).update(); } else { //已经完成 @@ -455,16 +457,16 @@ public class EleAirStrategyServiceImpl extends ServiceImpl()).get(0); if (Objects.isNull(airStrategy)) { throw new BusinessException(CommonResponseEnum.FAIL); } LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(AirSet::getId, id); + lambdaQueryWrapper.eq(AirSet::getId, airStrategy.getId()); List list = iEleSetService.list(lambdaQueryWrapper); if (CollectionUtil.isNotEmpty(list)) { List lineIds = list.stream().map(AirSet::getLineId).collect(Collectors.toList()); @@ -528,8 +530,6 @@ public class EleAirStrategyServiceImpl extends ServiceImpl