change - 设备曲线

main
wenjy 3 years ago
parent ef06745bd7
commit 4389555a91

@ -31,8 +31,7 @@ public class RecordSensorDataController {
@Autowired private IRecordSensorDataService iRecordSensorDataService;
@Autowired
private IBaseSensorInfoService baseSensorInfoService;
@Autowired private IBaseSensorInfoService baseSensorInfoService;
private String prefix = "record/recordSensorData";
@ -45,11 +44,19 @@ public class RecordSensorDataController {
}
@GetMapping("/getTemperatureTrend")
public String getTemperatureTrend(@RequestParam("id") String id, ModelMap mmap){
public String getTemperatureTrend(@RequestParam("id") String id, ModelMap mmap) {
mmap.put("sensorId", id);
return prefix + "/temperatureTrend";
}
/**
*
*
* @author WenJY
* @date 2022/4/11 13:18
* @param baseSensorInfoDto
* @return java.lang.String
*/
@PostMapping("/list")
@ResponseBody
public String _getList(BaseSensorInfoDto baseSensorInfoDto) {
@ -82,9 +89,17 @@ public class RecordSensorDataController {
return JSONArray.toJSONString(maps);
}
/**
* 线
*
* @author WenJY
* @date 2022/4/11 13:17
* @param baseSensorInfoDto
* @return java.lang.String
*/
@PostMapping("/getTemperatureTrendJson")
@ResponseBody
public String getTemperatureTrendJson(BaseSensorInfoDto baseSensorInfoDto){
public String getTemperatureTrendJson(BaseSensorInfoDto baseSensorInfoDto) {
baseSensorInfoDto.setTableName("record_" + baseSensorInfoDto.getSensorType());
@ -110,18 +125,23 @@ public class RecordSensorDataController {
baseSensorInfoDto.setParams(paramMap);
List<BaseSensorInfoDto> baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(baseSensorInfoDto.getSensorId()));
List<BaseSensorInfoDto> baseSensorInfoDtos =
baseSensorInfoService.selectBaseSensorInfoList(
new BaseSensorInfo(baseSensorInfoDto.getSensorId()));
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null,null,null,baseSensorInfoDtos.get(0).getMonitorunitId()));
List<BaseSensorInfoDto> baseSensorInfoDtos1 =
baseSensorInfoService.selectBaseSensorInfoList(
new BaseSensorInfo(null, null, null, baseSensorInfoDtos.get(0).getMonitorunitId()));
List<Map<String, Object>> maps = new ArrayList<>();
for (BaseSensorInfoDto sensorInfoDto : baseSensorInfoDtos1) {
baseSensorInfoDto.setSensorId(sensorInfoDto.getSensorId());
maps.addAll(maps.size(),iRecordSensorDataService.selectTemperatureList(baseSensorInfoDto));
maps.addAll(maps.size(), iRecordSensorDataService.selectTemperatureList(baseSensorInfoDto));
}
Map<String, List<Map<String, Object>>> sensorId = maps.stream().collect(Collectors.groupingBy(m -> (m.get("sensorName").toString())));
Map<String, List<Map<String, Object>>> sensorId =
maps.stream().collect(Collectors.groupingBy(m -> (m.get("sensorName").toString())));
List<String> legend = new ArrayList<>();
List<String> xAxis = new ArrayList<>();
@ -137,25 +157,21 @@ public class RecordSensorDataController {
xAxis.add(map.get("collectTime").toString());
data.add(Convert.toBigDecimal(map.get("value")));
}
series.add(new Series(entry.getKey(),"line","Total",data));
series.add(new Series(entry.getKey(), "line", "Total", data));
}
List<String> collect = xAxis.stream().distinct().collect(Collectors.toList());
String s = JSONArray.toJSONString(new Root(legend, collect, series));
System.out.println("曲线趋势数据格式打印:"+s);
return s;
}
}
@Data
class Root{
class Root {
public Root() {
}
public Root() {}
public Root(List<String> legend, List<String> xAxis, List<Series> series) {
this.legend = legend;
@ -171,10 +187,9 @@ class Root{
}
@Data
class Series{
class Series {
public Series() {
}
public Series() {}
public Series(String name, String type, String stack, List<BigDecimal> data) {
this.name = name;
@ -190,4 +205,4 @@ class Series{
private String stack;
private List<BigDecimal> data;
}
}

@ -60,10 +60,10 @@
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<!--表格导出-->
<th:block th:include="include :: bootstrap-table-export-js" />
<th:block th:include="include :: FileSaver-xlsx-Base64-js" />
<th:block th:include="include :: bootstrap-table-export-js"/>
<th:block th:include="include :: FileSaver-xlsx-Base64-js"/>
<th:block th:include="include :: echarts-js" />
<th:block th:include="include :: echarts-js"/>
<script th:inline="javascript">
@ -72,24 +72,24 @@
$(() => {
$("#historyTable").hide();
window.onload = function () {
document.getElementById('optionStatus').addEventListener('change',function(){
document.getElementById('optionStatus').addEventListener('change', function () {
$("#temperatureTrend").hide();
$("#historyTable").hide();
$("#"+this.value).show();
},false);
$("#" + this.value).show();
}, false);
}
tableRefresh();
temperatureTrend();
})
const searchOnclick = function(){
const searchOnclick = function () {
tableRefresh();
temperatureTrend();
}
/*曲线趋势*/
const temperatureTrend = function (){
const temperatureTrend = function () {
let sensorId = [[${sensorId}]].split(",");
let formData = new FormData();
formData.append("sensorId", sensorId[0]);
@ -107,7 +107,7 @@
processData: false,
contentType: false,
success: function (json) {
lineCharts(json,document.getElementById("trendEcharts"));
lineCharts(json, document.getElementById("trendEcharts"));
},
error: function () {
alert("错误");
@ -193,8 +193,8 @@
colspan: 1,
rowspan: 1,
align: "center",
formatter: function(value, row, index) {
return value.replace("T"," ");
formatter: function (value, row, index) {
return value.replace("T", " ");
}
});
}
@ -248,7 +248,7 @@
}
//echarts折线图
const lineCharts =function (res, id) {
const lineCharts = function (res, id) {
let charts = echarts.init(id);
let options = {
@ -256,7 +256,7 @@
trigger: 'axis'
},
legend: {
data:res.legend
data: res.legend
},
grid: {
left: '3%',
@ -272,7 +272,7 @@
xAxis: {
type: 'category',
boundaryGap: false,
data:res.xAxis
data: res.xAxis
},
yAxis: {
type: 'value'
@ -285,7 +285,7 @@
}
// 自定义按钮导出数据
function exportData(){
function exportData() {
$('#bootstrap-table').tableExport({
type: 'excel',
exportDataType: "basic",

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.RecordSensorDataMapper">
<resultMap type="BaseSensorInfoDto" id="BaseSensorInfoDtoResult">
@ -30,19 +30,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from ${tableName}
<where>
<if test="sensorId != null and sensorId != ''">and sensorId = #{sensorId}</if>
<if test="params.beginCollectTime != null and params.endCollectTime != null ">and collectTime between #{params.beginCollectTime} and #{params.endCollectTime}
<if test="params.beginCollectTime != null and params.endCollectTime != null ">and collectTime between
#{params.beginCollectTime} and #{params.endCollectTime}
</if>
</where>
order by collectTime desc
</select>
<select id="selectTemperatureList" fetchSize="50000" parameterType="BaseSensorInfoDto" resultType="map">
select t1.sensorId,t2.Sensor_Name as sensorName,t1.value,DATE_FORMAT(t1.collectTime,'%Y-%m-%d %H:%i') as collectTime
select t1.sensorId,t2.Sensor_Name as sensorName,t1.value,DATE_FORMAT(t1.collectTime,'%Y-%m-%d %H:%i') as
collectTime
from record_temperature t1
left join base_sensor_info t2 on t1.sensorId = t2.Sensor_Id
<where>
<if test="sensorId != null and sensorId != ''">and t1.sensorId = #{sensorId}</if>
<if test="params.beginCollectTime != null and params.endCollectTime != null ">and t1.collectTime between #{params.beginCollectTime} and #{params.endCollectTime}
<if test="params.beginCollectTime != null and params.endCollectTime != null ">and t1.collectTime between
#{params.beginCollectTime} and #{params.endCollectTime}
</if>
</where>
group by DATE_FORMAT(t1.collectTime,'%Y-%m-%d %H:%i')

Loading…
Cancel
Save