Commit e8f662cb authored by caotao's avatar caotao

风机状态图改用消息广播

parent b043aff3
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.netflix.loadbalancer.RetryRule;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region; import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
...@@ -13,11 +14,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto; ...@@ -13,11 +14,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import java.io.File;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -40,7 +43,8 @@ public class MonitoringServiceIMQTTmpl { ...@@ -40,7 +43,8 @@ public class MonitoringServiceIMQTTmpl {
private final String fanStatusListCron = "0/30 * * * * *"; private final String fanStatusListCron = "0/30 * * * * *";
//风机实时数据Cron表达式 //风机实时数据Cron表达式
private final String fanCurrentDataCron = "0 0/1 * * * *"; private final String fanCurrentDataCron = "0 0/1 * * * *";
@Value("${fan.statuts.stattuspath}")
private String fanStatusImagePathPrefix;
/** /**
* 场站mapper * 场站mapper
*/ */
...@@ -287,8 +291,10 @@ public class MonitoringServiceIMQTTmpl { ...@@ -287,8 +291,10 @@ public class MonitoringServiceIMQTTmpl {
.collect(Collectors.toList()); .collect(Collectors.toList());
page.setTotal(fanStatusList.size()); page.setTotal(fanStatusList.size());
page.setRecords(collect); page.setRecords(collect);
IPage<HashMap<String,String>> fanStatusListImages =getFanStatusListImages(collect);
try { try {
emqKeeper.getMqttClient().publish(stationBasic.getSequenceNbr() + "_fanStationFanStatusList_topic", JSON.toJSON(page).toString().getBytes("UTF-8"), 1, true); emqKeeper.getMqttClient().publish(stationBasic.getSequenceNbr() + "_fanStationFanStatusList_topic", JSON.toJSON(page).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(stationBasic.getSequenceNbr() + "_fanStationFanStatusListImages_topic", JSON.toJSON(fanStatusListImages).toString().getBytes("UTF-8"), 1, true);
logger.info("-----------------发送风电站风机列表数据消息=================== 成功!" + JSON.toJSONString(page)); logger.info("-----------------发送风电站风机列表数据消息=================== 成功!" + JSON.toJSONString(page));
} catch (Exception exception) { } catch (Exception exception) {
logger.error("-----------------发送风电站风机列表数据消息=================== 失败!"); logger.error("-----------------发送风电站风机列表数据消息=================== 失败!");
...@@ -377,4 +383,28 @@ public class MonitoringServiceIMQTTmpl { ...@@ -377,4 +383,28 @@ public class MonitoringServiceIMQTTmpl {
}); });
}); });
} }
/**
* @deprecated 根据查询出来的风机状态返回风机的状态图片
* @param collect 根据网关id查询出来的数据
* @return 加工后风机实时运行状态图列表数据
*/
public IPage<HashMap<String, String>> getFanStatusListImages(List<IndexDto> collect) {
IPage<HashMap<String, String>> page = new Page<>();
HashMap<String, String> hashMap = new HashMap<>();
//对于查出来的风机进行排序,便于数据处理
List<IndexDto> indexDtoList = collect.stream().sorted(Comparator.comparing(IndexDto::getEquipmentNumber)).collect(Collectors.toList());
for (int i = 1; i <= indexDtoList.size(); i++) {
IndexDto indexDto = indexDtoList.get(i - 1);
hashMap.put("url" + i, fanStatusImagePathPrefix + File.separator + "风机-" + indexDto.getState() + ".gif");
hashMap.put("name" + i, indexDto.getEquipmentNumber());
}
page.setTotal(10);
page.setSize(100);
page.setCurrent(1);
List<HashMap<String, String>> hashMapList = new ArrayList<>();
hashMapList.add(hashMap);
page.setRecords(hashMapList);
return page;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment