change - 传感器汇总页面接口初步实现

main
wenjy 3 years ago
parent 8e99db156c
commit 32eb628144

@ -5,6 +5,12 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.BaseSensorType;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import com.ruoyi.system.service.IBaseSensorInfoService;
import com.ruoyi.system.service.IBaseSensorTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
@ -28,7 +34,11 @@ import java.util.UUID;
@RequestMapping("/iot/sensorSummary")
public class SensorSummaryController extends BaseController {
@Autowired
private IBaseSensorTypeService baseSensorTypeService;
@Autowired
private IBaseSensorInfoService baseSensorInfoService;
@GetMapping()
public String sensorSummary()
@ -36,24 +46,38 @@ public class SensorSummaryController extends BaseController {
return "iot-ui/sensorSummary";
}
@GetMapping("/getSensorType")
@ResponseBody
public String getSensorType(){
List<BaseSensorType> baseSensorTypeList = baseSensorTypeService.selectBaseSensorTypeList(new BaseSensorType(null,null,0L));
return JSONArray.toJSONString(baseSensorTypeList);
}
@GetMapping("/getSensorInfo")
@ResponseBody
public String getSensorInfo(){
public String getSensorInfo(String sensorTypeId){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<BaseSensorInfoDto> baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L));
List<sensorTableModel> sensorTableModelList = new ArrayList<>();
for (int i =1;i<24;i++){
for (int i =1;i<baseSensorInfoDtos.size();i++){
sensorTableModel sensor = new sensorTableModel();
sensor.setId(i);
sensor.setEdgeId(UUID.randomUUID().toString().substring(0,8));
sensor.setSensorId(UUID.randomUUID().toString().substring(0,8));
sensor.setEdgeId(baseSensorInfoDtos.get(i).getEdgeId());
sensor.setSensorId(baseSensorInfoDtos.get(i).getSensorId());
//生成随机数,带两位小数
double a=Math.random()*10;
DecimalFormat df = new DecimalFormat( "0.00" );
String str=df.format( a );
sensor.setSensorData(new BigDecimal(str));
sensor.setRssi(new BigDecimal(str));
sensor.setCollectTime(simpleDateFormat.format(new Date()));
sensor.setMonitorLocation(i+"#监控点");
sensor.setMonitorLocation(baseSensorInfoDtos.get(i).getSensorLocation());
sensorTableModelList.add(sensor);
}

@ -1,30 +1,4 @@
$(()=>{
// alert("成功")
const sensorInfo = [
{
sensorCode:"E001",
sensorName:"温度传感器"
},{
sensorCode:"E002",
sensorName:"湿度传感器"
},{
sensorCode:"E003",
sensorName:"振动传感器"
},{
sensorCode:"E004",
sensorName:"水浸传感器"
},{
sensorCode:"E005",
sensorName:"烟雾传感器"
},{
sensorCode:"E006",
sensorName:"门磁传感器"
},{
sensorCode:"E007",
sensorName:"AI识别"
}
];
document.getElementById("sensorType").contentWindow.document.designMode = "on";
document.getElementById("sensorType").contentWindow.document.contentEditable = true;
@ -34,16 +8,29 @@ $(()=>{
cssLink.type = "text/css";
document.getElementById("sensorType").contentWindow.document.body.appendChild(cssLink);
for(let i=0;i<sensorInfo.length;i++){
var div = document.getElementById("sensorType").contentWindow.document.createElement("button");
div.id = sensorInfo[i].sensorCode;
div.innerText = sensorInfo[i].sensorName;
div.onclick = btnBaby1_onclick;
div.setAttribute("class","sensorTypeItem");
document.getElementById("sensorType").contentWindow.document.body.appendChild(div);
}
$.ajax({
url: "/iot/sensorSummary/getSensorType",
type: "get",
dataType: 'JSON',
success: (res) => {
$("#sensorType").html("");
res.map(x=>{
var div = document.getElementById("sensorType").contentWindow.document.createElement("button");
div.id = x.sensortypeId;
div.innerText = x.sensortypeName;
div.onclick = btnBaby1_onclick;
div.setAttribute("class","sensorTypeItem");
document.getElementById("sensorType").contentWindow.document.body.appendChild(div);
})
sensorInfoList(res[0].sensortypeId);
},
error: () => {
console.log("失败");
}
})
})
function btnBaby1_onclick(){
alert("切换传感器")
sensorInfoList(this.id);
}

@ -1,6 +1,7 @@
$(()=>{
const sensorInfoList = function(sensorTypeId) {
$('#table').bootstrapTable('destroy');
$('#table').bootstrapTable({
url: '/iot/sensorSummary/getSensorInfo', // 表格数据来源
url: '/iot/sensorSummary/getSensorInfo?sensorTypeId='+sensorTypeId, // 表格数据来源
pageNumber: 1,
pagination: true,
sidePagination: 'client',
@ -42,7 +43,7 @@ $(()=>{
align: 'center',
}]
});
})
}
const onSearchByMonitorLocation = function (obj) {
setTimeout(function(){

@ -23,6 +23,7 @@
<!-- 搜索框 -->
<div class="sensorHistoryData searchBox" style="height:6%;top: 3%">
<form action="#" class="search-form">
<input id="sensorTypeId" type="hidden" name="sensorTypeId">
<div style="width: 90%;height: 100%;border: 0px solid red;">
<label class="search-label" style="padding-left: 0%;">监测位置:</label>
<input type="text" class="form-control" onkeydown="onSearchByMonitorLocation(this)" id="monitorLocation" name="monitorLocation" placeholder="请输入监测位置">
@ -36,12 +37,6 @@
</form>
</div>
<!-- 表格 -->
<!-- <div class="sensorHistoryData sensorDataTable">-->
<!-- <iframe id="sensorDataTable" name="b_iframe" width="100%" height="100%" frameborder="0" align="middle"-->
<!-- scrolling="auto" src="about:blank">-->
<!-- </iframe>-->
<!-- </div>-->
<div class="sensorHistoryData sensorDataTable">
<table id="table"></table>
</div>

@ -22,6 +22,12 @@ public class BaseSensorType extends BaseEntity
this.sensortypeId = sensortypeId;
}
public BaseSensorType(String sensortypeId, String sensortypeName, Long enableFlag) {
this.sensortypeId = sensortypeId;
this.sensortypeName = sensortypeName;
this.enableFlag = enableFlag;
}
/** 主键标识 */
private Long ObjId;

Loading…
Cancel
Save