Commit 8f993b4c authored by tangwei's avatar tangwei

动态表格

parent 06c8fd9d
...@@ -17,6 +17,7 @@ public class IndexDto { ...@@ -17,6 +17,7 @@ public class IndexDto {
private String address;// 指标地址 private String address;// 指标地址
private String createdTime;// '上报时间', private String createdTime;// '上报时间',
private String equipmentSpecificName;// private String equipmentSpecificName;//
private String equipmentNumber;
private String value; private String value;
private int count; private int count;
private String equipmentsIdx; private String equipmentsIdx;
......
...@@ -2,10 +2,10 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller; ...@@ -2,10 +2,10 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.api.dto.DeviceDto;
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.dto.PersonAccountDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.ColModel;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto; 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.utils.InfluxDButils; import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -20,6 +20,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -20,6 +20,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -40,33 +41,44 @@ public class DeviceController extends BaseController { ...@@ -40,33 +41,44 @@ public class DeviceController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取告警数据") @ApiOperation(value = "获取告警数据")
@GetMapping("/nationwide") @GetMapping("/nationwide")
public ResponseModel<Page<IndexDto>> getNationWideInfo(@RequestParam(value = "current") int current,@RequestParam public ResponseModel<ResultsData> getNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "gateway") String gateway,@RequestParam(value = "equipmentNumber") String equipmentNumber) { (value = "size") int size,@RequestParam(value = "gateway") String gateway,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) {
Page<IndexDto> page = new Page<IndexDto>(); Page<IndexDto> page = new Page<IndexDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
StringBuffer querysql = new StringBuffer("SELECT createdTime ,gatewayId,address,valueLabel,equipmentSpecificName,value FROM "); String table=gateway;
querysql.append("indicators_").append(gateway); StringBuffer querysql = new StringBuffer("SELECT createdTime ,equipmentNumber,gatewayId,address,valueLabel,equipmentSpecificName,value FROM indicators_%s WHERE isAlarm='1' and value!='0.0' and gatewayId= %s ORDER BY time desc LIMIT %d OFFSET %d ");
querysql.append(" WHERE isAlarm='1' and value!='0.0' and gatewayId="); StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM indicators_%s WHERE isAlarm='1' and value!='0.0' and gatewayId= %s ");
querysql.append(gateway); if(StringUtils.isNotEmpty(equipmentNumber)){
StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM "); String date ="'%s' and equipmentNumber = '%s' ";
querysqlcount.append("indicators_").append(gateway); gateway= String.format(date,gateway,equipmentNumber);
querysqlcount.append(" WHERE isAlarm='1' and value!='0.0' and gatewayId="); }else{
querysqlcount.append(gateway); gateway=String.format("'%s'",gateway);
if(StringUtils.isNotEmpty(querysqlcount)){
querysqlcount.append(" and equipmentNumber =").append(equipmentNumber);
querysql.append(" and equipmentNumber =").append(equipmentNumber);
} }
querysql.append(" ORDER BY time desc LIMIT ").append(page.getSize()).append(" OFFSET ").append((page.getCurrent() - 1)*page.getSize()); String querysqln= String.format(querysql.toString(),table,gateway, (int)page.getSize(),(int)(page.getCurrent() - 1)*page.getSize());
String querysqlcountn= String.format(querysqlcount.toString(),table,gateway);
//每个分机的指标数据 //每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysql.toString(),IndexDto.class); List<IndexDto> list = influxDButils.getListData(querysqln,IndexDto.class);
List<IndexDto> list1 = influxDButils.getListData(querysqlcount.toString(),IndexDto.class); List<IndexDto> list1 = influxDButils.getListData(querysqlcountn,IndexDto.class);
page.setRecords(list); page.setRecords(list);
if(list1!=null&&list1.size()>0){
page.setTotal(list1.get(0).getCount());
} //构建平台数据
return ResponseHelper.buildResponse(page); DataGridMock DataGridMock=new DataGridMock(current, list1.get(0).getCount(), false, current, list);
ColModel colModelequipmentNumber=new ColModel("equipmentNumber", "equipmentNumber", "风机号", "风机号", "dataGrid", "equipmentNumber");
ColModel colModelvalueLabel=new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
ColModel colModelcreatedTime=new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
ColModel colModelvalue=new ColModel("value", "value", "告警值", "告警值", "dataGrid", "value");
List<ColModel> listColModel=new ArrayList<>();
listColModel.add(colModelequipmentNumber);
listColModel.add(colModelvalueLabel);
listColModel.add(colModelcreatedTime);
listColModel.add(colModelvalue);
ResultsData resultsData=new ResultsData(DataGridMock,listColModel);
return ResponseHelper.buildResponse(resultsData);
} }
......
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2023/7/6
*/
@Data
public class ColModel {
private String fid;
private String dataIndex;
private String name;
private String title;
private String type;
private String key;
public ColModel(String fid, String dataIndex, String name, String title, String type, String key) {
this.fid = fid;
this.dataIndex = dataIndex;
this.name = name;
this.title = title;
this.type = type;
this.key = key;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/7/6
*/
@Data
public class DataGridMock {
private int current;
private int total;
private boolean pagination;
private int totalPage;
private List dataList;
public DataGridMock(int current, int total, boolean pagination, int totalPage, List dataList) {
this.current = current;
this.total = total;
this.pagination = pagination;
this.totalPage = totalPage;
this.dataList = dataList;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/7/6
*/
@Data
public class ResultsData {
private DataGridMock dataGridMock;
private List<ColModel> colModel;
public ResultsData(DataGridMock dataGridMock, List<ColModel> colModel) {
this.dataGridMock = dataGridMock;
this.colModel = colModel;
}
}
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