Commit 46083d01 authored by chenzhao's avatar chenzhao

增加接口

parent 5d998a47
......@@ -41,4 +41,7 @@ public interface MonitorFanIndicatorMapper extends BaseMapper<MonitorFanIndicato
List<Map<String, String>> getMajorBoosterStationInfo(@Param("gatewayId") String gatewayId,
@Param("sortType") String sortType,
@Param("size") Integer size);
Map<String, String> getMajorBoosterStationInfoBySort(@Param("gatewayId") String gatewayId,
@Param("sort") String sort);
}
......@@ -129,4 +129,22 @@
ORDER BY major_sort ${sortType}
limit #{size}
</select>
<select id="getMajorBoosterStationInfoBySort" resultType="java.util.Map">
select
`sequence_nbr` as id,
`gateway_id` as gatewayId,
`booster_name` as text,
booster_name as boosterName,
`booster_code` as boosterCode,
`sort` as value
from booster_station_info
where
sort = #{sort}
AND gateway_id = #{gatewayId}
limit 1
</select>
</mapper>
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.elasticsearch.index.Index;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
......@@ -61,6 +58,12 @@ public class MonitorFanIdxController extends BaseController {
@Value("${fan.statuts.stattuspath}")
private String fanStatusImagePathPrefix;
@Autowired
MonitorFanIndicatorMapper monitorFanIndicatorMapper;
@Autowired
EmqKeeper emqKeeper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据设备编号、场站id、前段展示模块、系统类型查询表数据")
@GetMapping("/getFanIdxInfoByPage")
......@@ -76,7 +79,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "左侧树API")
@GetMapping("/getTreeInfo")
public ResponseModel<TreeDto> getTreeInfo(@RequestParam(value = "sequenceNbr", required = true) String sequenceNbr) {
public ResponseModel<TreeDto> getTreeInfo(@RequestParam(value = "sequenceNbr") String sequenceNbr) {
return ResponseHelper.buildResponse(monitorFanIndicator.getTreeInfo(sequenceNbr));
}
......@@ -182,18 +185,15 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图-总概览")
@GetMapping("/overview")
public ResponseModel<IPage<Map<String, Object>>> getData(@RequestParam(value = "stationId", required = true)String stationId) {
public ResponseModel<IPage<Map<String, Object>>> getData(@RequestParam(value = "stationId")String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
String [] sumColumns = new String[]{"日发电量","月发电量","年发电量"};
String [] avgColumns = new String[]{"有功功率","瞬时风速"};
List<String> columnList = Arrays.asList(sumColumns);
List<String> columnLists = Arrays.asList(avgColumns);
String [] columnList = new String[]{"日发电量","月发电量","年发电量"};
String [] columnLists = new String[]{"有功功率","瞬时风速"};
Map<String, Object> columnMap = new HashMap<>();
for (String column : columnList) {
Double result = commonService.getTotalByIndicatior(gatewayId, column);
columnMap.put(column, result);
......@@ -260,7 +260,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机详情-风速功率曲线")
@GetMapping("/detailsWindSpeed")
public ResponseModel<Map<String, Object>> getDetailsWindSpeed(@RequestParam(value = "stationId", required = true)String stationId,String name) {
public ResponseModel<Map<String, Object>> getDetailsWindSpeed(@RequestParam(value = "stationId")String stationId,String name) {
name = name + "风机";
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
......@@ -272,7 +272,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "状态监控")
@GetMapping("/statusMonitoring")
public ResponseModel<IPage<Map<String, Object>>> getStatusMonitoring(@RequestParam(value = "stationId", required = true)String stationId,String equipNum,String systemType) {
public ResponseModel<IPage<Map<String, Object>>> getStatusMonitoring(@RequestParam(value = "stationId")String stationId,String equipNum,String systemType) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusMonitoring(gatewayId, equipNum, systemType);
......@@ -287,9 +287,10 @@ public class MonitorFanIdxController extends BaseController {
@ApiOperation(value = "升压站光字牌/开关-通用")
@GetMapping("/getStatusGzp")
public ResponseModel<IPage<Map<String, Object>>> getStatusGzp(@RequestParam(value = "stationId", required = true)String stationId,String frontModule,String systemType) {
public ResponseModel<IPage<Map<String, Object>>> getStatusGzp(@RequestParam(value = "stationId")String stationId,String frontModule,String systemType) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId ,systemType,frontModule);
IPage<Map<String,Object>> result = new Page<>();
result.setRecords(statusMonitoring);
......@@ -303,7 +304,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "集电线路图左侧 集电线列表")
@GetMapping("/jdTree")
public ResponseModel<IPage<Map<String, Object>>> getStatusJDX(@RequestParam(value = "stationId", required = true)String stationId) {
public ResponseModel<IPage<Map<String, Object>>> getStatusJDX(@RequestParam(value = "stationId")String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
String werks = stationBasic.getStationNumber();
......@@ -433,11 +434,44 @@ public class MonitorFanIdxController extends BaseController {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getBoosterGatewayId();
monitorFanIndicatorImpl.getSwitchUrlAll(gatewayId);
monitorFanIndicatorImpl.getSwitchUrlAll(stationBasic);
}
return CommonResponseUtil.success();
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "动态面板页面消息")
@GetMapping("/pageTopic")
public ResponseModel<Map<String,Object>> sendPageTopic(
@RequestParam(value = "stationId") String stationId, @RequestParam(value = "equipName") String equipName
) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
Map<String, String> map = monitorFanIndicatorMapper.getMajorBoosterStationInfoBySort(stationId, equipName);
equipName = map.get("text").contains("主变")?map.get("text").substring(0,3):map.get("text");
Map<String, Object> switchUrl = monitorFanIndicatorImpl.getSwitchUrl(stationId, equipName);
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId ,"光字牌",equipName);
IPage<Map<String, Object>> result = new Page<>();
switchUrl.put("records",statusMonitoring);
switchUrl.put("current",1);
switchUrl.put("total",100);
List<Map<String, Object>> data = new ArrayList<>();
data.add(switchUrl);
result.setRecords(data);
result.setCurrent(1);
result.setTotal(100);
try {
emqKeeper.getMqttClient().publish("", JSON.toJSONString(result).getBytes(),0,false);
} catch (MqttException e) {
e.printStackTrace();
}
return CommonResponseUtil.success();
}
}
......@@ -27,6 +27,7 @@ public class IndicatorsDto {
private String time;
private String displayName;
private String title;
private String pictureName;
public String getTime() {
......
......@@ -28,19 +28,26 @@ import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IMonitorFanIndicator;
import com.yeejoin.amos.component.robot.BadRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.parseArray;
/**
* @description:
* @author: tw
......@@ -90,6 +97,13 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Autowired
EmqKeeper emqKeeper;
@Value("${pictureUrl}")
String pictureUrl;
@Value("classpath:/json/topic.json")
private Resource topic;
private List<Map> list;
@Override
public void UpdateMonitorFanIndicator(List<IndexDto> list) {
......@@ -974,7 +988,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
}
public void getSwitchUrlAll(String gatewayId){
public void getSwitchUrlAll(StationBasic stationBasic){
String gatewayId = stationBasic.getBoosterGatewayId();
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType = '开关' and displayName =~/合位$/";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
Set<String> names = new HashSet<>();
......@@ -990,27 +1006,40 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
public void getSwitchUrl(String gatewayId,String equipName){
public Map<String, Object> getSwitchUrl(String gatewayId,String equipName ){
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType = '开关' and frontModule =~ /"+equipName+"/ and displayName =~/合位$/";
String sql1 = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType = '开关' and frontModule =~ /"+equipName+"/ and displayName =~/远方就地开关$/";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
List<IndicatorsDto> listDatas = influxDButils.getListData(sql1, IndicatorsDto.class);
Map<String, Object> photoUrls = new HashMap<>();
for (IndicatorsDto data : listDatas) {
String url = "";
String[] urls = data.getPictureName().split(",");
if (data.getValue().equals("true")){
url =pictureUrl+urls[0];
}else {
url =pictureUrl+ urls[1];;
}
photoUrls.put(data.getDisplayName().split("_")[0]+"yfjdkgurl",url);
}
for (IndicatorsDto listDatum : listData) {
String url = "";
SwitchPicture switchUrl = switchPictureMapper.getSwitchUrl(gatewayId, listDatum.getDisplayName().split("_")[0]);
if (listDatum.getValue().equals("true")){
url = switchUrl.getOnUrl();
url =pictureUrl+ listDatum.getPictureName();
}else {
url = switchUrl.getOffUrl();
url =pictureUrl+ listDatum.getPictureName().replace("red", "green");
}
photoUrls.put(listDatum.getDisplayName().split("_")[0]+"url",url);
}
return photoUrls;
try {
emqKeeper.getMqttClient().publish(gatewayId+"/switch",JSON.toJSONString(photoUrls).getBytes(),0,false);
/* try {
emqKeeper.getMqttClient().publish(stationId+"/switch/",JSON.toJSONString(photoUrls).getBytes(),0,false);
} catch (MqttException e) {
e.printStackTrace();
log.error("开关消息发送失败");
}
}*/
}
}
......
......@@ -102,3 +102,5 @@ myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness
# ?????????
fan.statuts.stattuspath=upload/jxiop/device_status
pictureUrl=
[
{
"code": "iot",
"emqTopic": "emq.iot.created",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "patrol",
"emqTopic": "emq.patrol.created",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "sign",
"emqTopic": "emq.sign.created",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "bussSign",
"emqTopic": "emq.bussSign.created",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "user",
"emqTopic": "emq.user.created",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "xf",
"emqTopic": "emq.xf.created",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "risk",
"emqTopic": "emq.risk.created",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "patrol",
"emqTopic": "emq.patrol.created",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "equipQrcode",
"emqTopic": "emq.mcb.zxj",
"akkaTopic": "JKXT2BP-XFYY-Topic"
},
{
"code": "mcbsubmit",
"emqTopic": "risk.submit",
"akkaTopic": "JKXT2BP-XFZX-Topic"
},
{
"code": "question",
"emqTopic": "warning.issue.question.zd",
"akkaTopic": "JKXT2BP-XFZX-Topic"
},
{
"code": "syncExecute",
"emqTopic": "sync.execute",
"akkaTopic": "JKXT2BP-XFZX-Topic"
},
{
"code": "ccsLoginInfo",
"emqTopic": "ccs-user-login-info",
"akkaTopic": "JKXT2BP-XFZX-Topic"
}
]
\ No newline at end of file
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