1.用能系统空调关机策略
2.终端模块对外接口
This commit is contained in:
@@ -210,4 +210,14 @@ public interface LineFeignClient {
|
||||
@PostMapping("getDeviceList")
|
||||
HttpResult<List<String>> getDeviceList();
|
||||
|
||||
/**
|
||||
* 获取当前状态在线的监测点数量
|
||||
* @param lineIds 监测点集合
|
||||
* @return 在线的监测点数量
|
||||
* @author cdf
|
||||
* @date 2022/8/1
|
||||
*/
|
||||
@PostMapping("getOnLineCount")
|
||||
HttpResult<Integer> getOnLineCount(@RequestBody List<String> lineIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -161,6 +161,12 @@ public class LineFeignClientFallbackFactory implements FallbackFactory<LineFeign
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Integer> getOnLineCount(List<String> lineIds) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "或取在线监测点数量异常: ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ public class GeneralDeviceInfoController extends BaseController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfoAsDept(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getPracticalRunDeviceInfoAsDept");
|
||||
List<GeneralDeviceDTO> deptDeviceInfos = generalDeviceService.getDeviceInfoAsDept(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
@@ -73,6 +74,7 @@ public class GeneralDeviceInfoController extends BaseController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<List<GeneralDeviceDTO>> getOfflineRunDeviceInfoAsDept(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getOfflineRunDeviceInfoAsDept");
|
||||
List<GeneralDeviceDTO> deptDeviceInfos = generalDeviceService.getDeviceInfoAsDept(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(2).collect(Collectors.toList()));
|
||||
@@ -93,6 +95,7 @@ public class GeneralDeviceInfoController extends BaseController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalAllDeviceInfoAsDept(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getPracticalAllDeviceInfoAsDept");
|
||||
List<GeneralDeviceDTO> deptDeviceInfos = generalDeviceService.getDeviceInfoAsDept(deviceInfoParam, null, Stream.of(1).collect(Collectors.toList()));
|
||||
@@ -120,6 +123,7 @@ public class GeneralDeviceInfoController extends BaseController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfoAsSubstation(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getPracticalRunDeviceInfoAsSubstation");
|
||||
List<GeneralDeviceDTO> substationDeviceInfos = generalDeviceService.getDeviceInfoAsSubstation(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
@@ -139,6 +143,7 @@ public class GeneralDeviceInfoController extends BaseController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfo(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getPracticalRunDeviceInfo");
|
||||
List<GeneralDeviceDTO> deptDeviceInfos = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
@@ -158,6 +163,7 @@ public class GeneralDeviceInfoController extends BaseController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<List<GeneralDeviceDTO>> getOfflineRunDeviceInfo(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getOfflineRunDeviceInfo");
|
||||
List<GeneralDeviceDTO> deptDeviceInfos = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(2).collect(Collectors.toList()));
|
||||
|
||||
@@ -288,4 +288,21 @@ public class LineController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineMapper.getDeviceList(), methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前状态在线的监测点数量
|
||||
* @param lineIds 监测点集合
|
||||
* @return 在线的监测点数量
|
||||
* @author cdf
|
||||
* @date 2022/8/1
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getOnLineCount")
|
||||
@ApiOperation("获取当前状态在线的监测点数量")
|
||||
@ApiImplicitParam(name = "lineIds", value = "监测点集合", required = true)
|
||||
public HttpResult<Integer> getOnLineCount(@RequestBody List<String> lineIds) {
|
||||
String methodDescribe = getMethodDescribe("getOnLineCount");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineMapper.getOnLineCount(lineIds), methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -318,4 +318,10 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
* @return 装置Id
|
||||
*/
|
||||
List<String> getDeviceList();
|
||||
|
||||
/**
|
||||
* 获取当前状态在线的监测点数量
|
||||
* @return 装置Id
|
||||
*/
|
||||
Integer getOnLineCount(@Param("lineIds")List<String> lineIds);
|
||||
}
|
||||
|
||||
@@ -952,4 +952,23 @@ FROM
|
||||
<select id="getDeviceList" resultType="string">
|
||||
SELECT Id FROM pq_device WHERE Dev_Model = 1 AND Dev_Data_Type IN (1,2) AND Run_Flag = 0
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getOnLineCount" resultType="int">
|
||||
SELECT
|
||||
count( f.Com_Flag )
|
||||
FROM
|
||||
pq_line a
|
||||
INNER JOIN pq_line_detail b ON a.id = b.id
|
||||
INNER JOIN pq_line c ON a.pid = c.id
|
||||
INNER JOIN pq_line d ON c.pid = d.id
|
||||
INNER JOIN pq_device f ON d.id = f.id
|
||||
WHERE
|
||||
a.state = 1
|
||||
AND f.Com_Flag = 1
|
||||
AND a.id in
|
||||
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -67,7 +67,9 @@ public enum EnergyResponseEnum {
|
||||
TASK_HAS_START("508","任务已经执行完毕"),
|
||||
TASK_DEL_ERROR("509","定时任务删除失败,请联系管理员"),
|
||||
TASK_RUNING("510","任务正在执行无法操作,请先停止任务"),
|
||||
TASK_TIME_ERROR("511","两条策略时间差应在5分钟以上")
|
||||
TASK_TIME_ERROR("511","两条策略时间差应在5分钟以上"),
|
||||
TASK_NO_RUN("512","策略不在执行中"),
|
||||
TASK_STOP_ERROR("513","策略停止失败,请联系管理员"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
@@ -31,14 +31,16 @@ public class AirStrategyParam{
|
||||
@NotBlank(message = "名称不可为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(name = "类型",required = true,value = "0.普通策略 1.关机策略 2.开机策略")
|
||||
@NotNull(message = "策略类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(name = "开始时间",required = true)
|
||||
@NotBlank(message = "开始时间不可为空")
|
||||
@DateTimeStrValid(format = "yyyy-MM-dd HH:mm:ss",message = "开始时间格式有误")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(name = "开始时间",required = true)
|
||||
@NotBlank(message = "开始时间不可为空")
|
||||
@DateTimeStrValid(format = "yyyy-MM-dd HH:mm:ss",message = "结束时间格式有误")
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty(name = "空调模式",required = true)
|
||||
@@ -83,6 +85,7 @@ public class AirStrategyParam{
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class AirStrategyQueryParam extends BaseParam {
|
||||
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import lombok.Data;
|
||||
public class AirStrategy extends BaseEntity {
|
||||
private String id;
|
||||
private String name;
|
||||
private Integer type;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String mode;
|
||||
|
||||
@@ -30,6 +30,9 @@ public class AirStrategyVO {
|
||||
@ApiModelProperty(name = "策略名称",required = true)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(name = "策略类型",required = true)
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(name = "开始时间",required = true)
|
||||
private String startTime;
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class EleAirStrategyController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@GetMapping("/delete")
|
||||
@ApiOperation("删除空调策略")
|
||||
@ApiImplicitParam(name = "id", value = "网关设备索引", required = true)
|
||||
@ApiImplicitParam(name = "id", value = "策略索引", required = true)
|
||||
public HttpResult<Object> delete(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
boolean result = eleAirStrategyService.deleteAirStrategy(id);
|
||||
@@ -121,6 +121,24 @@ public class EleAirStrategyController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 停止空调策略
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/stop")
|
||||
@ApiOperation("停止空调策略")
|
||||
@ApiImplicitParam(name = "id", value = "策略索引", required = true)
|
||||
public HttpResult<Object> stopAirStrategy(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("stopAirStrategy");
|
||||
boolean result = eleAirStrategyService.stopAirStrategy(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询空调策略详情
|
||||
* @author cdf
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getEleLineList" resultType="EnergyDeviceTreeVO">
|
||||
select id,pid,name,line_id,3 as level from ele_line
|
||||
select id,pid,name,line_id as lineId,3 as level from ele_line
|
||||
where state = 1
|
||||
order by ele_line.idx
|
||||
</select>
|
||||
@@ -178,7 +178,7 @@ WHERE
|
||||
inner join ele_logic_dev b on a.pid = b.id
|
||||
inner join ele_net_dev c on b.pid = c.id
|
||||
where a.state = 1
|
||||
and a.id in
|
||||
and a.line_id in
|
||||
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
||||
@@ -45,6 +45,14 @@ public interface EleAirStrategyService extends IService<AirStrategy> {
|
||||
*/
|
||||
boolean deleteAirStrategy(String id);
|
||||
|
||||
/**
|
||||
* 停止策略
|
||||
* @param id id
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean stopAirStrategy(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 获取空调策略信息
|
||||
* @param id id
|
||||
|
||||
@@ -39,6 +39,9 @@ import com.njcn.energy.pojo.vo.AirStrategyVO;
|
||||
import com.njcn.energy.pojo.vo.EnergyDeviceTreeVO;
|
||||
import com.njcn.energy.service.EleAirStrategyService;
|
||||
import com.njcn.energy.service.IEleSetService;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.job.api.JobFeignClient;
|
||||
import com.njcn.job.model.XxlJobInfo;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
@@ -48,10 +51,12 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -75,17 +80,19 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
|
||||
private final LogicDeviceLineMapper logicDeviceLineMapper;
|
||||
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final AirStrategyMapper airStrategyMapper;
|
||||
|
||||
private final MqttMessageHandler mqttMessageHandler;
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Value("${mqtt.client-id}")
|
||||
private String clientId;
|
||||
|
||||
private Integer xxlGroup = 5;
|
||||
//徐扬执行器 5 陈道飞执行器6 3 18数据库测试执行器
|
||||
private final Integer xxlGroup = 6;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -98,6 +105,11 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
queryWrapper
|
||||
.and(param -> param.like("ele_air_strategy.name", queryParam.getSearchValue()));
|
||||
}
|
||||
if (queryParam.getType() == 0) {
|
||||
queryWrapper.eq("ele_air_strategy.type", queryParam.getType());
|
||||
} else {
|
||||
queryWrapper.ne("ele_air_strategy.type", 0);
|
||||
}
|
||||
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
@@ -107,6 +119,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
queryWrapper.orderBy(true, true, "ele_air_strategy.sort");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
queryWrapper.eq("ele_air_strategy.state", DataStateEnum.ENABLE.getCode());
|
||||
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
@@ -115,10 +128,16 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addAirStrategy(AirStrategyParam airStrategyParam) {
|
||||
|
||||
|
||||
checkDicTypeName(airStrategyParam, false);
|
||||
|
||||
if (airStrategyParam.getType() == 0) {
|
||||
//默认策略
|
||||
//校验参数
|
||||
LambdaQueryWrapper<AirStrategy> tem = new LambdaQueryWrapper<>();
|
||||
tem.eq(AirStrategy::getState, DataStateEnum.ENABLE.getCode());
|
||||
tem.eq(AirStrategy::getType,0);
|
||||
List<AirStrategy> temList = this.list(tem);
|
||||
if (CollectionUtil.isNotEmpty(temList)) {
|
||||
for (AirStrategy airStrategy : temList) {
|
||||
@@ -129,94 +148,136 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
LocalDateTime endParam = LocalDateTimeUtil.parse(airStrategyParam.getStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
long rangeEnd = LocalDateTimeUtil.between(end, endParam).toMinutes();
|
||||
|
||||
if(rangeStart<=5 ||rangeEnd<=5 ){
|
||||
if (rangeStart <= 5 || rangeEnd <= 5) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_TIME_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
AirStrategy airStrategy = new AirStrategy();
|
||||
BeanUtils.copyProperties(airStrategyParam, airStrategy);
|
||||
airStrategy.setState(DataStateEnum.ENABLE.getCode());
|
||||
airStrategy.setStatus(0);
|
||||
airStrategy.setCreateBy(RequestUtil.getUserIndex());
|
||||
airStrategy.setCreateTime(LocalDateTime.now());
|
||||
airStrategy.setUpdateTime(LocalDateTime.now());
|
||||
this.save(airStrategy);
|
||||
|
||||
|
||||
|
||||
AirStrategy airStrategy = assAirStrategy(airStrategyParam);
|
||||
|
||||
List<AirSet> list = new ArrayList<>();
|
||||
airStrategyParam.getLineIds().forEach((item)->{
|
||||
AirSet airSet = new AirSet(airStrategy.getId(),item);
|
||||
airStrategyParam.getLineIds().forEach((item) -> {
|
||||
AirSet airSet = new AirSet(airStrategy.getId(), item);
|
||||
list.add(airSet);
|
||||
});
|
||||
iEleSetService.saveBatch(list);
|
||||
|
||||
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(airStrategy.getStartTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
String cronOn = "" + startTime.getSecond() + CharUtil.SPACE + startTime.getMinute() + CharUtil.SPACE + startTime.getHour() + CharUtil.SPACE + startTime.getDayOfMonth() + CharUtil.SPACE + startTime.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTime.getYear();
|
||||
String paramOn = "open" + StrUtil.C_COMMA + airStrategy.getId();
|
||||
|
||||
XxlJobInfo xxlJobInfo = assScheduling("测试定时开空调",cronOn,paramOn);
|
||||
HttpResult<String> result = jobFeignClient.addJob(xxlJobInfo);
|
||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTimeEnd = LocalDateTimeUtil.parse(airStrategy.getEndTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
String cronOff = "" + startTimeEnd.getSecond() + CharUtil.SPACE + startTimeEnd.getMinute() + CharUtil.SPACE + startTimeEnd.getHour() + CharUtil.SPACE + startTimeEnd.getDayOfMonth() + CharUtil.SPACE + startTimeEnd.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTimeEnd.getYear();
|
||||
String paramOff = "close" + StrUtil.C_COMMA + airStrategy.getId();
|
||||
XxlJobInfo airStrategyClose = assScheduling("测试定时关空调",cronOff,paramOff);
|
||||
HttpResult<String> result2 = jobFeignClient.addJob(airStrategyClose);
|
||||
if (result2.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
String ids = result.getData() + StrUtil.COMMA + result2.getData();
|
||||
airStrategy.setXxlId(ids);
|
||||
this.updateById(airStrategy);
|
||||
} else if(airStrategyParam.getType() == 1) {
|
||||
|
||||
|
||||
//开关机策略
|
||||
AirStrategy airStrategyOnOff = assAirStrategy(airStrategyParam);
|
||||
|
||||
List<AirSet> list = new ArrayList<>();
|
||||
airStrategyParam.getLineIds().forEach((item) -> {
|
||||
AirSet airSet = new AirSet(airStrategyOnOff.getId(), item);
|
||||
list.add(airSet);
|
||||
});
|
||||
iEleSetService.saveBatch(list);
|
||||
/*
|
||||
* 此处做示例,手动指定
|
||||
* 添加开机调度任务
|
||||
*/
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
String startTime = airStrategyOnOff.getStartTime();
|
||||
String[] temTime = startTime.split(":");
|
||||
String cron = "0" + CharUtil.SPACE + temTime[1] + CharUtil.SPACE + temTime[0] + CharUtil.SPACE + "* * ?";
|
||||
String param = "close" + StrUtil.C_COMMA + airStrategyOnOff.getId();
|
||||
XxlJobInfo xOn = assScheduling("每日定时关空调",cron,param);
|
||||
HttpResult<String> result = jobFeignClient.addJob(xOn);
|
||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
airStrategyOnOff.setXxlId(result.getData());
|
||||
this.updateById(airStrategyOnOff);
|
||||
} else if(airStrategyParam.getType() == 2) {
|
||||
//开机策略
|
||||
AirStrategy airStrategyOnOff = assAirStrategy(airStrategyParam);
|
||||
List<AirSet> list = new ArrayList<>();
|
||||
airStrategyParam.getLineIds().forEach((item) -> {
|
||||
AirSet airSet = new AirSet(airStrategyOnOff.getId(), item);
|
||||
list.add(airSet);
|
||||
});
|
||||
iEleSetService.saveBatch(list);
|
||||
/*
|
||||
* 添加开机调度任务
|
||||
*/
|
||||
String startTime = airStrategyOnOff.getStartTime();
|
||||
String[] temTime = startTime.split(":");
|
||||
String cron = "0" + CharUtil.SPACE + temTime[1] + CharUtil.SPACE + temTime[0] + CharUtil.SPACE + "* * ?";
|
||||
String param = "open" + StrUtil.C_COMMA + airStrategyOnOff.getId();
|
||||
XxlJobInfo xOff = assScheduling("每日定时开空调",cron,param);
|
||||
HttpResult<String> result = jobFeignClient.addJob(xOff);
|
||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
airStrategyOnOff.setXxlId(result.getData());
|
||||
this.updateById(airStrategyOnOff);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*组装数据库数据*/
|
||||
private AirStrategy assAirStrategy(AirStrategyParam airStrategyParam){
|
||||
AirStrategy airStrategyOnOff = new AirStrategy();
|
||||
BeanUtils.copyProperties(airStrategyParam, airStrategyOnOff);
|
||||
airStrategyOnOff.setState(DataStateEnum.ENABLE.getCode());
|
||||
airStrategyOnOff.setStatus(0);
|
||||
airStrategyOnOff.setCreateBy(RequestUtil.getUserIndex());
|
||||
airStrategyOnOff.setCreateTime(LocalDateTime.now());
|
||||
airStrategyOnOff.setUpdateTime(LocalDateTime.now());
|
||||
this.save(airStrategyOnOff);
|
||||
return airStrategyOnOff;
|
||||
}
|
||||
|
||||
/*组装调度任务*/
|
||||
private XxlJobInfo assScheduling(String desc,String confTime,String param){
|
||||
XxlJobInfo xxlJobInfo = new XxlJobInfo();
|
||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||
xxlJobInfo.setJobGroup(xxlGroup);
|
||||
//任务描述
|
||||
xxlJobInfo.setJobDesc("开启空调");
|
||||
xxlJobInfo.setJobDesc(desc);
|
||||
xxlJobInfo.setAuthor("cdf");
|
||||
xxlJobInfo.setScheduleType("CRON");
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(airStrategy.getStartTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
xxlJobInfo.setScheduleConf("" + startTime.getSecond() + CharUtil.SPACE + startTime.getMinute() + CharUtil.SPACE + startTime.getHour() + CharUtil.SPACE + startTime.getDayOfMonth() + CharUtil.SPACE + startTime.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTime.getYear());
|
||||
xxlJobInfo.setScheduleConf(confTime);
|
||||
xxlJobInfo.setMisfireStrategy("DO_NOTHING");
|
||||
xxlJobInfo.setExecutorRouteStrategy("FIRST");
|
||||
xxlJobInfo.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
||||
//指定处理器
|
||||
xxlJobInfo.setExecutorHandler("airStrategyJob");
|
||||
//传递的参数
|
||||
xxlJobInfo.setExecutorParam("open" + StrUtil.C_COMMA + airStrategy.getId());
|
||||
xxlJobInfo.setExecutorParam(param);
|
||||
xxlJobInfo.setGlueType("BEAN");
|
||||
xxlJobInfo.setGlueRemark("GLUE代码初始化");
|
||||
HttpResult result = jobFeignClient.addJob(xxlJobInfo);
|
||||
if (result.getCode().equals(ReturnT.FAIL_CODE)) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* 此处做示例,手动指定
|
||||
*/
|
||||
XxlJobInfo xxlJobInfoEnd = new XxlJobInfo();
|
||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||
xxlJobInfoEnd.setJobGroup(xxlGroup);
|
||||
//任务描述
|
||||
xxlJobInfoEnd.setJobDesc("关闭空调");
|
||||
xxlJobInfoEnd.setAuthor("cdf");
|
||||
xxlJobInfoEnd.setScheduleType("CRON");
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTimeEnd = LocalDateTimeUtil.parse(airStrategy.getEndTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
xxlJobInfoEnd.setScheduleConf("" + startTimeEnd.getSecond() + CharUtil.SPACE + startTimeEnd.getMinute() + CharUtil.SPACE + startTimeEnd.getHour() + CharUtil.SPACE + startTimeEnd.getDayOfMonth() + CharUtil.SPACE + startTimeEnd.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTimeEnd.getYear());
|
||||
xxlJobInfoEnd.setMisfireStrategy("DO_NOTHING");
|
||||
xxlJobInfoEnd.setExecutorRouteStrategy("FIRST");
|
||||
xxlJobInfoEnd.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
||||
//指定处理器
|
||||
xxlJobInfoEnd.setExecutorHandler("airStrategyJob");
|
||||
//传递的参数
|
||||
xxlJobInfoEnd.setExecutorParam("close"+StrUtil.C_COMMA+airStrategy.getId());
|
||||
xxlJobInfoEnd.setGlueType("BEAN");
|
||||
xxlJobInfoEnd.setGlueRemark("GLUE代码初始化");
|
||||
HttpResult result2 = jobFeignClient.addJob(xxlJobInfoEnd);
|
||||
|
||||
if (result2.getCode().equals(ReturnT.FAIL_CODE)) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
|
||||
String ids = result.getData().toString() + StrUtil.COMMA + result2.getData().toString();
|
||||
airStrategy.setXxlId(ids);
|
||||
this.updateById(airStrategy);
|
||||
|
||||
return true;
|
||||
return xxlJobInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,6 +288,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
checkDicTypeName(updateParam, true);
|
||||
|
||||
AirStrategy airStrategy = new AirStrategy();
|
||||
BeanUtils.copyProperties(updateParam, airStrategy);
|
||||
airStrategy.setUpdateBy(RequestUtil.getUserIndex());
|
||||
@@ -235,71 +297,62 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
|
||||
|
||||
iEleSetService.removeById(airStrategy.getId());
|
||||
|
||||
List<AirSet> list = new ArrayList<>();
|
||||
updateParam.getLineIds().forEach((item) -> {
|
||||
AirSet airSet = new AirSet(airStrategy.getId(), item);
|
||||
list.add(airSet);
|
||||
});
|
||||
iEleSetService.saveBatch(list);
|
||||
/*
|
||||
* 此处做示例,手动指定
|
||||
*/
|
||||
|
||||
|
||||
String[] jobIds = airStrategyRes.getXxlId().split(StrUtil.COMMA);
|
||||
XxlJobInfo xxlJobInfo = new XxlJobInfo();
|
||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||
xxlJobInfo.setId(Integer.parseInt(jobIds[0]));
|
||||
xxlJobInfo.setJobGroup(xxlGroup);
|
||||
//任务描述
|
||||
xxlJobInfo.setJobDesc("开启空调");
|
||||
xxlJobInfo.setAuthor("cdf");
|
||||
xxlJobInfo.setScheduleType("CRON");
|
||||
if(updateParam.getType() == 0) {
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(airStrategy.getStartTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
xxlJobInfo.setScheduleConf("" + startTime.getSecond() + CharUtil.SPACE + startTime.getMinute() + CharUtil.SPACE + startTime.getHour() + CharUtil.SPACE + startTime.getDayOfMonth() + CharUtil.SPACE + startTime.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTime.getYear());
|
||||
xxlJobInfo.setMisfireStrategy("DO_NOTHING");
|
||||
xxlJobInfo.setExecutorRouteStrategy("FIRST");
|
||||
xxlJobInfo.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
||||
//指定处理器
|
||||
xxlJobInfo.setExecutorHandler("airStrategyJob");
|
||||
//传递的参数
|
||||
xxlJobInfo.setExecutorParam("open" + StrUtil.C_COMMA + airStrategy.getId());
|
||||
xxlJobInfo.setGlueType("BEAN");
|
||||
xxlJobInfo.setGlueRemark("GLUE代码初始化");
|
||||
HttpResult result = jobFeignClient.updateJob(xxlJobInfo);
|
||||
if (result.getCode().equals(ReturnT.FAIL_CODE)) {
|
||||
String cronOn = "" + startTime.getSecond() + CharUtil.SPACE + startTime.getMinute() + CharUtil.SPACE + startTime.getHour() + CharUtil.SPACE + startTime.getDayOfMonth() + CharUtil.SPACE + startTime.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTime.getYear();
|
||||
String paramOn = "open" + StrUtil.C_COMMA + airStrategy.getId();
|
||||
|
||||
XxlJobInfo xxlJobInfo = assScheduling("测试开空调",cronOn,paramOn);
|
||||
xxlJobInfo.setId(Integer.parseInt(jobIds[0]));
|
||||
HttpResult<String> result = jobFeignClient.updateJob(xxlJobInfo);
|
||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* 此处做示例,手动指定
|
||||
*/
|
||||
XxlJobInfo xxlJobInfoEnd = new XxlJobInfo();
|
||||
xxlJobInfoEnd.setId(Integer.parseInt(jobIds[1]));
|
||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||
xxlJobInfoEnd.setJobGroup(xxlGroup);
|
||||
//任务描述
|
||||
xxlJobInfoEnd.setJobDesc("关闭空调");
|
||||
xxlJobInfoEnd.setAuthor("cdf");
|
||||
xxlJobInfoEnd.setScheduleType("CRON");
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTimeEnd = LocalDateTimeUtil.parse(airStrategy.getEndTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
xxlJobInfoEnd.setScheduleConf("" + startTimeEnd.getSecond() + CharUtil.SPACE + startTimeEnd.getMinute() + CharUtil.SPACE + startTimeEnd.getHour() + CharUtil.SPACE + startTimeEnd.getDayOfMonth() + CharUtil.SPACE + startTimeEnd.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTimeEnd.getYear());
|
||||
xxlJobInfoEnd.setMisfireStrategy("DO_NOTHING");
|
||||
xxlJobInfoEnd.setExecutorRouteStrategy("FIRST");
|
||||
xxlJobInfoEnd.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
||||
//指定处理器
|
||||
xxlJobInfoEnd.setExecutorHandler("airStrategyJob");
|
||||
//传递的参数
|
||||
xxlJobInfoEnd.setExecutorParam("close" + StrUtil.C_COMMA + airStrategy.getId());
|
||||
xxlJobInfoEnd.setGlueType("BEAN");
|
||||
xxlJobInfoEnd.setGlueRemark("GLUE代码初始化");
|
||||
HttpResult result2 = jobFeignClient.updateJob(xxlJobInfoEnd);
|
||||
String cronOff = "" + startTimeEnd.getSecond() + CharUtil.SPACE + startTimeEnd.getMinute() + CharUtil.SPACE + startTimeEnd.getHour() + CharUtil.SPACE + startTimeEnd.getDayOfMonth() + CharUtil.SPACE + startTimeEnd.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTimeEnd.getYear();
|
||||
String paramOff = "close" + StrUtil.C_COMMA + airStrategy.getId();
|
||||
|
||||
if (result2.getCode().equals(ReturnT.FAIL_CODE)) {
|
||||
XxlJobInfo xxlJobInfoOff = assScheduling("测试关空调",cronOff,paramOff);
|
||||
xxlJobInfoOff.setId(Integer.parseInt(jobIds[1]));
|
||||
HttpResult<String> result2 = jobFeignClient.updateJob(xxlJobInfoOff);
|
||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
if (result2.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
}else if(updateParam.getType() == 1){
|
||||
String[] temTime = updateParam.getStartTime().split(":");
|
||||
String cron = "0" + CharUtil.SPACE + temTime[1] + CharUtil.SPACE + temTime[0] + CharUtil.SPACE + "* * ?";
|
||||
String param = "close" + StrUtil.C_COMMA + airStrategy.getId();
|
||||
XxlJobInfo xOff = assScheduling("每日定时关空调",cron,param);
|
||||
xOff.setId(Integer.parseInt(jobIds[0]));
|
||||
HttpResult<String> result = jobFeignClient.updateJob(xOff);
|
||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
}else if(updateParam.getType() == 2){
|
||||
String[] temTime = updateParam.getStartTime().split(":");
|
||||
String cron = "0" + CharUtil.SPACE + temTime[1] + CharUtil.SPACE + temTime[0] + CharUtil.SPACE + "* * ?";
|
||||
String param = "open" + StrUtil.C_COMMA + airStrategy.getId();
|
||||
XxlJobInfo xOff = assScheduling("每日定时开空调",cron,param);
|
||||
xOff.setId(Integer.parseInt(jobIds[0]));
|
||||
HttpResult<String> result = jobFeignClient.updateJob(xOff);
|
||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -337,6 +390,33 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean stopAirStrategy(String id) {
|
||||
AirStrategy airStrategy = this.getById(id);
|
||||
if (Objects.isNull(airStrategy)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
if (airStrategy.getStatus() != 1) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_NO_RUN);
|
||||
}
|
||||
String[] arr = airStrategy.getXxlId().split(StrUtil.COMMA);
|
||||
for (String xxlId : arr) {
|
||||
HttpResult<String> 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)
|
||||
.eq(AirStrategy::getId, id)
|
||||
.update();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AirStrategyVO findById(String id) {
|
||||
AirStrategy airStrategy = this.lambdaQuery().eq(AirStrategy::getId, id).one();
|
||||
@@ -361,20 +441,15 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
String[] ids = airStrategy.getXxlId().split(StrUtil.COMMA);
|
||||
if (airStrategy.getStatus() == 0) {
|
||||
//可以启动
|
||||
|
||||
for (String xxlId : ids) {
|
||||
HttpResult<String> 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) {
|
||||
HttpResult<String> result = jobFeignClient.stopJob(Integer.parseInt(xxlId));
|
||||
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
||||
@@ -386,7 +461,6 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
//已经完成
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_HAS_START);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -398,14 +472,31 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
if (Objects.isNull(airStrategy)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
|
||||
|
||||
LambdaQueryWrapper<AirSet> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(AirSet::getId, id);
|
||||
List<AirSet> list = iEleSetService.list(lambdaQueryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
List<String> lineIds = list.stream().map(AirSet::getLineId).collect(Collectors.toList());
|
||||
//如果是关闭操作
|
||||
if ("close".equals(operation)) {
|
||||
StringBuilder temSql = assToInfluxParam(lineIds);
|
||||
String sql = "select LineId from air_data_Real where " + temSql + " and ACInStat = 'On'";
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
List<QueryResult.Series> listSeries = result.getResults().get(0).getSeries();
|
||||
if (!CollectionUtils.isEmpty(listSeries)) {
|
||||
System.out.println(listSeries);
|
||||
List<String> lineIdTem = new ArrayList<>();
|
||||
listSeries.get(0).getValues().forEach(item -> {
|
||||
lineIdTem.add(item.get(1).toString());
|
||||
});
|
||||
lineIds = lineIdTem;
|
||||
}
|
||||
}
|
||||
System.out.println(lineIds);
|
||||
List<NetAndDevByLineDTO> netDevList = logicDeviceLineMapper.getNetAndDevByLineIds(lineIds);
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(netDevList)) {
|
||||
for (NetAndDevByLineDTO netAndDevByLineDTO : netDevList) {
|
||||
|
||||
@@ -419,11 +510,11 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
power = "On";
|
||||
array = "ACInStat";
|
||||
} else if (i == 1) {
|
||||
power = airStrategy.getTemperature().toString();
|
||||
array = "ACInSetTmp";
|
||||
} else if (i == 2) {
|
||||
power = airStrategy.getMode();
|
||||
array = "ACInMode";
|
||||
} else if (i == 2) {
|
||||
power = airStrategy.getTemperature().toString();
|
||||
array = "ACInSetTmp";
|
||||
} else {
|
||||
power = airStrategy.getWind();
|
||||
array = "ACInSpeed";
|
||||
@@ -452,16 +543,10 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
this.mqttSendTopic = topic;
|
||||
|
||||
flag = true;
|
||||
while(flag){
|
||||
while (flag) {
|
||||
|
||||
}
|
||||
/* try {
|
||||
Thread.sleep(2000);
|
||||
System.out.println("切换命令睡了1s");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
} else {
|
||||
//关闭空调
|
||||
@@ -486,27 +571,13 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
this.mqttJsonMsg = json;
|
||||
this.mqttSendTopic = topic;
|
||||
flag = true;
|
||||
while(flag){
|
||||
while (flag) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*try {
|
||||
Thread.sleep(2000);
|
||||
System.out.println("切换监测点睡了1s");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
System.out.println(operation);
|
||||
if (operation.equals("close")) {
|
||||
if ("close".equals(operation) && airStrategy.getType() == 0) {
|
||||
AirStrategy air = new AirStrategy();
|
||||
air.setId(airStrategy.getId());
|
||||
air.setStatus(2);
|
||||
@@ -514,8 +585,10 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -526,24 +599,25 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
private Integer mqttSendCount = 0;
|
||||
private String mqttJsonMsg;
|
||||
private String mqttSendTopic;
|
||||
@MqttSubscribe(value = "/platform/devack/#",qos = 1)
|
||||
public void airOperation(String topic, MqttMessage message, @Payload String payload){
|
||||
|
||||
@MqttSubscribe(value = "/platform/devack/#", qos = 1)
|
||||
public void airOperation(String topic, MqttMessage message, @Payload String payload) {
|
||||
System.out.println(message.toString());
|
||||
JSONObject jsonObject = new JSONObject(message.toString());
|
||||
String str = jsonObject.getStr("userId");
|
||||
|
||||
if(str.equals(clientId)){
|
||||
if (str.equals(clientId)) {
|
||||
|
||||
if(!jsonObject.getStr("code").equals("200")){
|
||||
if (!jsonObject.getStr("code").equals("200")) {
|
||||
mqttSendCount++;
|
||||
if(mqttSendCount < 3){
|
||||
if (mqttSendCount < 3) {
|
||||
System.out.println("进入错误重发++++++");
|
||||
System.out.println("错误重发详情"+mqttJsonMsg);
|
||||
System.out.println("错误重发详情" + mqttJsonMsg);
|
||||
publisher.send(mqttSendTopic, mqttJsonMsg, 1, false);
|
||||
}else{
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
|
||||
@@ -552,7 +626,6 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的空调策略
|
||||
*/
|
||||
@@ -574,4 +647,16 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
||||
}
|
||||
}
|
||||
|
||||
public static StringBuilder assToInfluxParam(List<String> lineIds) {
|
||||
StringBuilder lineIdsStr = new StringBuilder("(");
|
||||
for (int i = 0; i < lineIds.size(); i++) {
|
||||
if (lineIds.size() - i != 1) {
|
||||
lineIdsStr.append("LineId ='").append(lineIds.get(i)).append("' or ");
|
||||
} else {
|
||||
lineIdsStr.append("LineId ='").append(lineIds.get(i)).append("') ");
|
||||
}
|
||||
}
|
||||
return lineIdsStr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
|
||||
@@ -16,6 +16,7 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
@@ -41,12 +42,12 @@ logging:
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://192.168.1.13:10217/job-admin
|
||||
addresses: http://192.168.1.102:10217/job-admin
|
||||
#执行器通讯TOKEN [选填]:非空时启用;
|
||||
accessToken:
|
||||
executor:
|
||||
#执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
|
||||
appname: executor
|
||||
appname: executorCdf
|
||||
#执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。
|
||||
address:
|
||||
#执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
|
||||
|
||||
Reference in New Issue
Block a user