Merge remote-tracking branch 'origin/IOT' into IOT

IOT
夜笙歌 2 months ago
commit b4e25b1aad

@ -38,7 +38,7 @@ public class EmsBaseMonitorInfoController extends BaseController
/** /**
* *
*/ */
@PreAuthorize("@ss.hasPermi('ems/base:baseMonitorInfo:list')")
@GetMapping("/list") @GetMapping("/list")
public AjaxResult list(EmsBaseMonitorInfo emsBaseMonitorInfo) public AjaxResult list(EmsBaseMonitorInfo emsBaseMonitorInfo)
{ {

@ -6,6 +6,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.TreeEntity; import com.ruoyi.common.core.domain.TreeEntity;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -98,6 +99,11 @@ public class EmsBaseMonitorInfo extends BaseEntity
private List<Long> monitorTypeList; private List<Long> monitorTypeList;
private BigDecimal temperature;
public List<Long> getMonitorTypeList() { public List<Long> getMonitorTypeList() {
return monitorTypeList; return monitorTypeList;
} }
@ -300,6 +306,17 @@ public class EmsBaseMonitorInfo extends BaseEntity
return monitorHierarchy; return monitorHierarchy;
} }
public BigDecimal getTemperature() {
return temperature;
}
public void setTemperature(BigDecimal temperature) {
this.temperature = temperature;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -323,6 +340,7 @@ public class EmsBaseMonitorInfo extends BaseEntity
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("publicShareType", getPublicShareType()) .append("publicShareType", getPublicShareType())
.append("monitorHierarchy", getMonitorHierarchy()) .append("monitorHierarchy", getMonitorHierarchy())
.append("temperature",getTemperature())
.toString(); .toString();
} }
} }

@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.core.domain.entity.SysMenu;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -28,6 +29,10 @@ public class TreeSelects implements Serializable
private Long monitorType; private Long monitorType;
private BigDecimal tempreture;
/** 子节点 */ /** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelects> children; private List<TreeSelects> children;
@ -50,6 +55,7 @@ public class TreeSelects implements Serializable
this.code = baseMonitorInfo.getMonitorCode(); this.code = baseMonitorInfo.getMonitorCode();
this.children = baseMonitorInfo.getChildren().stream().map(TreeSelects::new).collect(Collectors.toList()); this.children = baseMonitorInfo.getChildren().stream().map(TreeSelects::new).collect(Collectors.toList());
this.monitorType = baseMonitorInfo.getMonitorType(); this.monitorType = baseMonitorInfo.getMonitorType();
this.tempreture = baseMonitorInfo.getTemperature();
} }
public TreeSelects(EmsBaseWorkUnit baseWorkUnit){ public TreeSelects(EmsBaseWorkUnit baseWorkUnit){
@ -111,4 +117,13 @@ public class TreeSelects implements Serializable
public void setMonitorType(Long monitorType) { public void setMonitorType(Long monitorType) {
this.monitorType = monitorType; this.monitorType = monitorType;
} }
public BigDecimal getTempreture() {
return tempreture;
}
public void setTempreture(BigDecimal tempreture) {
this.tempreture = tempreture;
}
} }

@ -1,13 +1,20 @@
package com.ruoyi.ems.base.service.impl; package com.ruoyi.ems.base.service.impl;
import java.util.ArrayList; import java.math.BigDecimal;
import java.util.Iterator; import java.util.*;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.ems.base.domain.TreeSelects; import com.ruoyi.ems.base.domain.TreeSelects;
import com.ruoyi.ems.record.domain.TWTempertureData;
import com.ruoyi.ems.record.mapper.TWTempertureDataMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.ems.base.mapper.EmsBaseMonitorInfoMapper; import com.ruoyi.ems.base.mapper.EmsBaseMonitorInfoMapper;
@ -26,6 +33,8 @@ public class EmsBaseMonitorInfoServiceImpl implements IEmsBaseMonitorInfoService
@Autowired @Autowired
private EmsBaseMonitorInfoMapper emsBaseMonitorInfoMapper; private EmsBaseMonitorInfoMapper emsBaseMonitorInfoMapper;
@Autowired
private TWTempertureDataMapper tWTempertureDataMapper;
/** /**
* *
* *
@ -139,9 +148,50 @@ public class EmsBaseMonitorInfoServiceImpl implements IEmsBaseMonitorInfoService
* @return * @return
*/ */
@Override @Override
public List<EmsBaseMonitorInfo> buildMonitorInfoTree(List<EmsBaseMonitorInfo> baseMonitorInfos) public List<EmsBaseMonitorInfo> buildMonitorInfoTree(List<EmsBaseMonitorInfo> baseMonitorInfos) {
{
List<EmsBaseMonitorInfo> returnList = new ArrayList<EmsBaseMonitorInfo>(); // 创建一个Map来存储温度数据键为监控ID值为TWTempertureData对象
Map<String, TWTempertureData> tempDataMap = new HashMap<>();
// 创建一个List来存储设备编号
List<String> monitorCodes = new ArrayList<>();
// 遍历设备列表
for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos) {
// 如果设备不为空且监控类型为1L
if (!ObjectUtils.isEmpty(baseMonitorInfo) && baseMonitorInfo.getMonitorType() == 1L) {
// 获取设备编号并添加到设备编号列表中
String monitorCode = baseMonitorInfo.getMonitorCode();
monitorCodes.add(monitorCode);
}
}
// 如果设备编号列表不为空
if (CollectionUtils.isNotEmpty(monitorCodes)) {
// 根据设备编号列表查询最新的温度数据
List<TWTempertureData> tempDatas = tWTempertureDataMapper.selectLastTWTempertureDataByMonitorCodes(monitorCodes);
// 遍历查询到的温度数据
for (TWTempertureData tempData : tempDatas) {
// 如果温度数据和温度值不为空
if (!ObjectUtils.isEmpty(tempData) && tempData.getTempreture() != null) {
// 将温度数据存入Map中键为监控ID值为温度数据对象
tempDataMap.put(tempData.getMonitorId(), tempData);
}
}
// 再次遍历设备列表
for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos) {
// 如果设备不为空且监控类型为1L
if (!ObjectUtils.isEmpty(baseMonitorInfo) && baseMonitorInfo.getMonitorType() == 1L) {
// 根据设备ID从Map中获取对应的温度数据
TWTempertureData tempData = tempDataMap.get(baseMonitorInfo.getMonitorCode());
// 如果温度数据不为空
if (!ObjectUtils.isEmpty(tempData)) {
// 设置设备的温度值
baseMonitorInfo.setTemperature(tempData.getTempreture());
}
}
}
}
List<EmsBaseMonitorInfo> returnList = new ArrayList<>();
List<Long> tempList = baseMonitorInfos.stream().map(EmsBaseMonitorInfo::getObjId).collect(Collectors.toList()); List<Long> tempList = baseMonitorInfos.stream().map(EmsBaseMonitorInfo::getObjId).collect(Collectors.toList());
for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos) for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos)
{ {

@ -221,15 +221,15 @@ public class TWTempertureDataController extends BaseController
return tWTempertureDataService.selectLastTWTempertureData(tWTempertureData); return tWTempertureDataService.selectLastTWTempertureData(tWTempertureData);
} }
/** /* *//**
* *
*/ *//*
@PreAuthorize("@ss.hasPermi('ems/record:recordIOTInstant:list')") @PreAuthorize("@ss.hasPermi('ems/record:recordIOTInstant:list')")
@PostMapping("/boardTWTempertureDataList") @PostMapping("/boardTWTempertureDataList")
public AjaxResult boardTWTempertureDataList(TWTempertureData tWTempertureData) public AjaxResult boardTWTempertureDataList(TWTempertureData tWTempertureData)
{ {
List<TWTempertureData> list = tWTempertureDataService.selectTWTempertureDataList(tWTempertureData); List<TreeSelects> list = tWTempertureDataService.selectBoardTWTempertureDataList(tWTempertureData);
return success(list); return success(list);
} }*/
} }

@ -79,4 +79,10 @@ public interface TWTempertureDataMapper
* @return * @return
*/ */
public List<TWTempertureData> selectLastTWTempertureDataList(TWTempertureData tWTempertureData); public List<TWTempertureData> selectLastTWTempertureDataList(TWTempertureData tWTempertureData);
public TWTempertureData selectLastTWTempertureDataByMonitorCode(String monitorId);
public List<TWTempertureData> selectLastTWTempertureDataByMonitorCodes(List<String> monitorCodes);
public List<TWTempertureData> selectLastTWTempertureData(TWTempertureData tWTempertureData);
} }

@ -134,8 +134,8 @@ public class TWTempertureDataServiceImpl implements ITWTempertureDataService
@Override @Override
public List<TWTempertureData> selectLastTWTempertureData(TWTempertureData tWTempertureData) { public List<TWTempertureData> selectLastTWTempertureData(TWTempertureData tWTempertureData) {
try { try {
// 从数据库中查询温度数据列表 // 从数据库中查询数据列表
List<TWTempertureData> twlist = tWTempertureDataMapper.selectTWTempertureDataList(tWTempertureData); List<TWTempertureData> twlist = tWTempertureDataMapper.selectLastTWTempertureData(tWTempertureData);
if (twlist == null || twlist.isEmpty()) { if (twlist == null || twlist.isEmpty()) {
// 如果查询结果为空或列表为空,返回一个空列表 // 如果查询结果为空或列表为空,返回一个空列表
return Collections.emptyList(); return Collections.emptyList();

@ -79,7 +79,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="pm10 != null "> and twtd.pm10 = #{pm10}</if> <if test="pm10 != null "> and twtd.pm10 = #{pm10}</if>
<if test="standby != null "> and twtd.standby = #{standby}</if> <if test="standby != null "> and twtd.standby = #{standby}</if>
</where> </where>
order by twtd.recodeTime desc
</select> </select>
<select id="selectTWTempertureDataByObjid" parameterType="Long" resultMap="TWTempertureDataResult"> <select id="selectTWTempertureDataByObjid" parameterType="Long" resultMap="TWTempertureDataResult">
@ -103,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="monitorId != null and monitorId != ''"> and twtd.monitorId = #{monitorId}</if> <if test="monitorId != null and monitorId != ''"> and twtd.monitorId = #{monitorId}</if>
</where> </where>
order by twtd.recordTime desc order by twtd.recodeTime desc
</select> </select>
<insert id="insertTWTempertureData" parameterType="TWTempertureData" useGeneratedKeys="true" keyProperty="objid"> <insert id="insertTWTempertureData" parameterType="TWTempertureData" useGeneratedKeys="true" keyProperty="objid">
@ -184,14 +183,72 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectLastTWTempertureDataList" parameterType="TWTempertureData" resultMap="TWTempertureDataResult"> <select id="selectLastTWTempertureDataList" parameterType="TWTempertureData" resultMap="TWTempertureDataResult">
SELECT twtd.*,ebmi.monitor_name SELECT twtd.objid,
twtd.monitorId,
twtd.collectTime,
twtd.tempreture,
twtd.humidity,
twtd.illuminance,
twtd.noise,
twtd.concentration,
twtd.recodeTime,
twtd.alarmType,
twtd.pm1,
twtd.pm2,
twtd.pm10,
twtd.standby,
ebmi.monitor_name
FROM ( FROM (
select *, select objid,
row_number() over(partition by monitorId order by recodeTime desc) as rownum monitorId,
collectTime,
tempreture,
humidity,
illuminance,
noise,
concentration,
recodeTime,
alarmType,
pm1,
pm2,
pm10,
standby
row_number() over(partition by monitorId order by objid desc) as rownum
from T_W_TempertureData from T_W_TempertureData
) twtd ) twtd
left join ems_base_monitor_info ebmi on twtd.monitorId = ebmi.monitor_code left join ems_base_monitor_info ebmi on twtd.monitorId = ebmi.monitor_code
where twtd.rownum = 1; where twtd.rownum = 1;
</select> </select>
<select id="selectLastTWTempertureDataByMonitorCode" parameterType="TWTempertureData" resultMap="TWTempertureDataResult">
SELECT twtd.tempreture
FROM T_W_TempertureData twtd
WHERE twtd.monitorId = #{monitorId}
ORDER BY twtd.objid DESC
LIMIT 1
</select>
<select id="selectLastTWTempertureDataByMonitorCodes" parameterType="list" resultMap="TWTempertureDataResult">
SELECT twtd.*
FROM (
SELECT *,
ROW_NUMBER() OVER(PARTITION BY monitorId ORDER BY recodeTime DESC) as rownum
FROM T_W_TempertureData
WHERE monitorId IN
<foreach item="monitorCode" collection="list" open="(" separator="," close=")">
#{monitorCode}
</foreach>
) twtd
LEFT JOIN ems_base_monitor_info ebmi ON twtd.monitorId = ebmi.monitor_code
WHERE twtd.rownum = 1;
</select>
<select id="selectLastTWTempertureData" parameterType="TWTempertureData" resultMap="TWTempertureDataResult">
select *
from T_W_TempertureData
ORDER BY objid DESC
LIMIT 1000
</select>
</mapper> </mapper>

@ -123,8 +123,20 @@ public class SecurityConfig
.antMatchers("/record/recordBusbarAlarm/recordBusbarAlarmCount").permitAll() .antMatchers("/record/recordBusbarAlarm/recordBusbarAlarmCount").permitAll()
.antMatchers("/ems/record/recordIOTInstant/selectLastTWTempertureData").permitAll() .antMatchers("/ems/record/recordIOTInstant/selectLastTWTempertureData").permitAll()
.antMatchers("/record/recordBusbarTemp/boardTempList").permitAll() .antMatchers("/record/recordBusbarTemp/boardTempList").permitAll()
.antMatchers("/ems/base/baseMonitorInfo/list").permitAll()
.antMatchers("/ems/base/baseMonitorInfo/monitorInfoTree").permitAll()
.antMatchers("/ems/base/baseMonitorInfo/monitorInfo").permitAll()
.antMatchers("/ems/base/baseMonitorInfo/**").permitAll()
.antMatchers("/ems/record/recordIOTInstant/selectLastTWTempertureData").permitAll()
.antMatchers("/ems/base/baseMonitorInfo/list").permitAll()
.antMatchers("/ems/base/baseMonitorInfo/monitorInfo/**").permitAll()
.antMatchers("/record/recordBusbarAlarm/recordBusbarAlarmList").permitAll()
// 允许匿名访问 看板 下所有页面 // 允许匿名访问 看板 下所有页面
.antMatchers("/board/**").permitAll() .antMatchers("/board/**").permitAll()
.antMatchers("/board/index2").permitAll()
.antMatchers("/board/index1").permitAll()
.antMatchers("/board/index").permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated(); .anyRequest().authenticated();

@ -110,7 +110,6 @@ public class RecordBusbarAlarmController extends BaseController
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@PreAuthorize("@ss.hasPermi('record:recordBusbarAlarm:list')")
@PostMapping("/recordBusbarAlarmList") @PostMapping("/recordBusbarAlarmList")
public AjaxResult recordBusbarAlarmList(RecordBusbarAlarm recordBusbarAlarm) public AjaxResult recordBusbarAlarmList(RecordBusbarAlarm recordBusbarAlarm)
{ {

@ -35,14 +35,14 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="报警阈值" prop="alarmValue"> <!-- <el-form-item label="报警阈值" prop="alarmValue">
<el-input <el-input
v-model="queryParams.alarmValue" v-model="queryParams.alarmValue"
placeholder="请输入报警阈值" placeholder="请输入报警阈值"
clearable clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>-->
<el-form-item label="判断方式" prop="judgMethod"> <el-form-item label="判断方式" prop="judgMethod">
<el-select v-model="queryParams.judgMethod" placeholder="请选择判断方式" clearable> <el-select v-model="queryParams.judgMethod" placeholder="请选择判断方式" clearable>
<el-option <el-option
@ -63,7 +63,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="创建人" prop="createdBy"> <!-- <el-form-item label="创建人" prop="createdBy">
<el-input <el-input
v-model="queryParams.createdBy" v-model="queryParams.createdBy"
placeholder="请输入创建人" placeholder="请输入创建人"
@ -100,7 +100,7 @@
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>-->
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>

@ -178,10 +178,10 @@ export default {
}) })
selectLastTWTempertureData().then(e=>{ selectLastTWTempertureData().then(e=>{
this.data2 = { this.data2 = {
num1:e?.tempreture || 0, num1:e[0]?.tempreture || 0,
num2:e?.humidity || 0, num2:e[0]?.humidity || 0,
num3:e?.illuminance || 0, num3:e[0]?.illuminance || 0,
num4:e?.noise || 0, num4:e[0]?.noise || 0,
} }
}) })
boardTempList().then(e=>{ boardTempList().then(e=>{

Loading…
Cancel
Save