Browse Source

烟感监测

develop
wangsixiang 1 day ago
parent
commit
2d4c1ec3b0
  1. 62
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  2. 130
      zc-business/src/main/java/com/zc/business/domain/DcSmokeRecord.java
  3. 7
      zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java
  4. 7
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  5. 16
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java
  6. 52
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

62
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -21,6 +21,7 @@ import com.zc.business.constant.DeviceTypeConstants;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcDoor; import com.zc.business.domain.DcDoor;
import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcSmokeRecord;
import com.zc.business.enums.UniversalEnum; import com.zc.business.enums.UniversalEnum;
import com.zc.business.interfaces.OperationLog; import com.zc.business.interfaces.OperationLog;
import com.zc.business.request.DeviceGetPropertiesOperateRequest; import com.zc.business.request.DeviceGetPropertiesOperateRequest;
@ -79,6 +80,7 @@ private VideoController videoController;
private ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE); private ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
private static final String DOORSTATUS = "doorStatus";//redis策略缓存的key private static final String DOORSTATUS = "doorStatus";//redis策略缓存的key
private static final String SOMKEVALUE = "smokeValue";//redis策略缓存的key
/* /*
@Value("${iot.address}") @Value("${iot.address}")
private String iotAddress; private String iotAddress;
@ -1736,7 +1738,7 @@ private VideoController videoController;
return batchInvokedFunction2(jsonObject); return batchInvokedFunction2(jsonObject);
} }
//一体机柜调用机箱门数据 //一体机柜调用机箱门数据
//@PostMapping("/integratedCabinetAir") @PostMapping("/integratedCabinetAir")
@Scheduled(cron = "20 * * * * ?") @Scheduled(cron = "20 * * * * ?")
@Transactional() @Transactional()
public AjaxResult chassisDoor() throws IOException, HttpException { public AjaxResult chassisDoor() throws IOException, HttpException {
@ -1791,6 +1793,50 @@ private VideoController videoController;
} }
} }
} }
for (DcDevice device : dcDeviceList){
AjaxResult result = getDeviceLatestProperty(device.getIotDeviceId(), "SmokeAlarm");
if (!result.get("code").toString().equals("200")){
continue;
}
JSONObject data = (JSONObject) result.get("data");//属性全部值
if (data==null){
continue;
}
String value = data.get("value").toString();//属性值
if (Integer.parseInt(value)>=400){
String cacheMapValue = redisCache.getCacheMapValue(SOMKEVALUE, device.getIotDeviceId());//查询缓存
if (cacheMapValue==null||"".equals(cacheMapValue)){//缓存不存在,加入数据加入缓存
DcSmokeRecord dcSmokeRecord = new DcSmokeRecord();
dcSmokeRecord.setDeviceName(device.getDeviceName());
dcSmokeRecord.setDeviceType(device.getDeviceType());
dcSmokeRecord.setDirection(device.getDirection());
dcSmokeRecord.setStakeMark(device.getStakeMark());
dcSmokeRecord.setSmokeValue(value);
dcSmokeRecord.setCreateTime(DateUtils.getNowDate());
dcSmokeRecord.setIotDeviceId(device.getIotDeviceId());
dcDeviceService.insertSmokeRecord(dcSmokeRecord);
redisCache.setCacheMapValue(SOMKEVALUE,device.getIotDeviceId(),value);
}else {
if (Integer.parseInt(value)==Integer.parseInt(cacheMapValue)){ //最新值与之前的缓存值一样,不予处理
continue;
}
//如果缓存存在,并且与当前值不一样,而且当前值大于400,烟感值缓存替换、数据替换
redisCache.delCacheMapValue(SOMKEVALUE,device.getIotDeviceId());
redisCache.setCacheMapValue(SOMKEVALUE,device.getIotDeviceId(),value);
DcSmokeRecord dcSmokeRecord = new DcSmokeRecord();
dcSmokeRecord.setIotDeviceId(device.getIotDeviceId());
dcSmokeRecord.setSmokeValue(value);
dcSmokeRecord.setUpdateTime(DateUtils.getNowDate());
dcDeviceService.updateSmokeValue(dcSmokeRecord);//修改数据值
}
}else {
String cacheMapValue = redisCache.getCacheMapValue(SOMKEVALUE, device.getIotDeviceId());//查询缓存
if (cacheMapValue==null||"".equals(cacheMapValue)){
continue;
}
redisCache.delCacheMapValue(SOMKEVALUE,device.getIotDeviceId());
}
}
return AjaxResult.success(); return AjaxResult.success();
} }
//设备箱机箱门状态采集 //设备箱机箱门状态采集
@ -1855,7 +1901,19 @@ private VideoController videoController;
} }
return AjaxResult.success(); return AjaxResult.success();
} }
//查询机柜烟感记录
@GetMapping("/dcSmokeRecordList")
public TableDataInfo selectSmokeList( DcSmokeRecord dcSmokeRecord){
startPage();
Map<String, Object> redisCacheCacheMap = redisCache.getCacheMap(SOMKEVALUE);
if (redisCacheCacheMap==null){
return getDataTable(Collections.emptyList());
}
Set<String> strings = redisCacheCacheMap.keySet();
List<DcSmokeRecord> list = dcDeviceService.selectSmokeList(strings);
return getDataTable(list);
}
//查询机柜门锁记录
@GetMapping("/dcDoorList") @GetMapping("/dcDoorList")
public TableDataInfo selectEnergyCircuit( DcDoor dcDoor){ public TableDataInfo selectEnergyCircuit( DcDoor dcDoor){
startPage(); startPage();

130
zc-business/src/main/java/com/zc/business/domain/DcSmokeRecord.java

@ -0,0 +1,130 @@
package com.zc.business.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* @author 王思祥
* @ClassName DcSmokeRecord
*/
public class DcSmokeRecord extends BaseEntity {
/** 预警编号 */
private Long id;
/** 所在桩号 */
@Excel(name = "所在桩号")
private String stakeMark;
/** 方向:1-上行2-中3-下行 */
@Excel(name = "方向",readConverterExp = "1=菏泽方向,3=济南方向,2=双向")
private String direction;
private String deviceName;
private String deviceType;
private String iotDeviceId;
private String endStakeMark;
private String startTime;
private String endTime;
private String smokeValue;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getStakeMark() {
return stakeMark;
}
public void setStakeMark(String stakeMark) {
this.stakeMark = stakeMark;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public String getIotDeviceId() {
return iotDeviceId;
}
public void setIotDeviceId(String iotDeviceId) {
this.iotDeviceId = iotDeviceId;
}
public String getEndStakeMark() {
return endStakeMark;
}
public void setEndStakeMark(String endStakeMark) {
this.endStakeMark = endStakeMark;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getSmokeValue() {
return smokeValue;
}
public void setSmokeValue(String smokeValue) {
this.smokeValue = smokeValue;
}
@Override
public String toString() {
return "DcSmokeRecord{" +
"id=" + id +
", stakeMark='" + stakeMark + '\'' +
", direction='" + direction + '\'' +
", deviceName='" + deviceName + '\'' +
", deviceType='" + deviceType + '\'' +
", iotDeviceId='" + iotDeviceId + '\'' +
", endStakeMark='" + endStakeMark + '\'' +
", startTime='" + startTime + '\'' +
", endTime='" + endTime + '\'' +
", smokeValue='" + smokeValue + '\'' +
'}';
}
}

7
zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java

@ -3,6 +3,7 @@ package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcDoor; import com.zc.business.domain.DcDoor;
import com.zc.business.domain.DcSmokeRecord;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -53,4 +54,10 @@ public interface DcDeviceMapper extends BaseMapper<DcDevice> {
List<DcDoor> selectDcDoorList(DcDoor dcDoor); List<DcDoor> selectDcDoorList(DcDoor dcDoor);
//查询状态为开的设备 //查询状态为开的设备
List<DcDoor> selectDcDoorOpen(@Param("iotIds")Set<String> strings); List<DcDoor> selectDcDoorOpen(@Param("iotIds")Set<String> strings);
//查询机柜烟感异常数据
List<DcSmokeRecord> selectSmokeList(@Param("iotIds")Set<String> strings);
//新增机柜烟感记录
Integer insertSmokeRecord(DcSmokeRecord dcSmokeRecord);
//修改机柜烟感值
Integer updateSmokeValue(DcSmokeRecord dcSmokeRecord);
} }

7
zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java

@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcDoor; import com.zc.business.domain.DcDoor;
import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcSmokeRecord;
import com.zc.business.domain.DcStakeMark; import com.zc.business.domain.DcStakeMark;
import com.zc.common.core.httpclient.exception.HttpException; import com.zc.common.core.httpclient.exception.HttpException;
import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.security.SecurityScheme;
@ -141,4 +142,10 @@ public interface IDcDeviceService extends IService<DcDevice> {
List<DcDoor> selectDcDoorList(DcDoor dcDoor); List<DcDoor> selectDcDoorList(DcDoor dcDoor);
//查询状态为开的设备 //查询状态为开的设备
List<DcDoor> selectDcDoorOpen(Set<String> strings); List<DcDoor> selectDcDoorOpen(Set<String> strings);
//查询机柜烟感异常数据
List<DcSmokeRecord> selectSmokeList(Set<String> strings);
//新增机柜烟感记录
Integer insertSmokeRecord(DcSmokeRecord dcSmokeRecord);
//修改机柜烟感值
Integer updateSmokeValue(DcSmokeRecord dcSmokeRecord);
} }

16
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

@ -14,6 +14,7 @@ import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcDoor; import com.zc.business.domain.DcDoor;
import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcProduct; import com.zc.business.domain.DcProduct;
import com.zc.business.domain.DcSmokeRecord;
import com.zc.business.domain.DcStakeMark; import com.zc.business.domain.DcStakeMark;
import com.zc.business.domain.MdDevice; import com.zc.business.domain.MdDevice;
import com.zc.business.enums.UniversalEnum; import com.zc.business.enums.UniversalEnum;
@ -686,6 +687,21 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
public List<DcDoor> selectDcDoorOpen(Set<String> strings) { public List<DcDoor> selectDcDoorOpen(Set<String> strings) {
return dcDeviceMapper.selectDcDoorOpen(strings); return dcDeviceMapper.selectDcDoorOpen(strings);
} }
//查询机柜烟感异常数据
@Override
public List<DcSmokeRecord> selectSmokeList(Set<String> strings) {
return dcDeviceMapper.selectSmokeList(strings);
}
//新增机柜烟感记录
@Override
public Integer insertSmokeRecord(DcSmokeRecord dcSmokeRecord) {
return dcDeviceMapper.insertSmokeRecord(dcSmokeRecord);
}
@Override
public Integer updateSmokeValue(DcSmokeRecord dcSmokeRecord) {
return dcDeviceMapper.updateSmokeValue(dcSmokeRecord);
}
} }

52
zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

@ -93,6 +93,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="iotDeviceId != null and iotDeviceId != ''">#{iotDeviceId},</if> <if test="iotDeviceId != null and iotDeviceId != ''">#{iotDeviceId},</if>
</trim> </trim>
</insert> </insert>
<insert id="insertSmokeRecord" useGeneratedKeys="true" keyProperty="id">
insert into dc_smoke_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="stakeMark != null and stakeMark != ''">stake_mark,</if>
<if test="direction != null and direction != ''">direction,</if>
<if test="deviceType != null and deviceType != ''">device_type,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="smokeValue != null and smokeValue != ''">smoke_value,</if>
<if test="createTime != null ">create_time,</if>
<if test="iotDeviceId != null and iotDeviceId != ''">iot_device_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="stakeMark != null and stakeMark != ''">#{stakeMark},</if>
<if test="direction != null and direction != ''">#{direction},</if>
<if test="deviceType != null and deviceType != ''">#{deviceType},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="smokeValue != null and smokeValue != ''">#{smokeValue},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="iotDeviceId != null and iotDeviceId != ''">#{iotDeviceId},</if>
</trim>
</insert>
<select id="selectDcDeviceList" parameterType="dcDevice" resultMap="DcDevice"> <select id="selectDcDeviceList" parameterType="dcDevice" resultMap="DcDevice">
@ -211,6 +234,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateTollStationCameraStatus"> <update id="updateTollStationCameraStatus">
update dc_device set device_state=#{deviceState} where id=#{id} update dc_device set device_state=#{deviceState} where id=#{id}
</update> </update>
<select id="selectTollStationCamPile" resultType="com.zc.business.domain.DcDevice"> <select id="selectTollStationCamPile" resultType="com.zc.business.domain.DcDevice">
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name, select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name,
t1.device_code, t1.device_type,t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site, t1.device_code, t1.device_type,t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,
@ -252,4 +276,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) b ON a.iot_device_id = b.iot_device_id AND a.create_time = b.latest_time ) b ON a.iot_device_id = b.iot_device_id AND a.create_time = b.latest_time
ORDER BY a.create_time DESC ORDER BY a.create_time DESC
</select> </select>
<select id="selectSmokeList" resultType="com.zc.business.domain.DcSmokeRecord">
select id,device_name,device_type,direction,stake_mark,smoke_value,create_time,update_time from dc_smoke_record as a
INNER JOIN (
SELECT
iot_device_id,
MAX(create_time) AS latest_time
FROM dc_smoke_record
WHERE iot_device_id IN
<foreach item="item" collection="iotIds" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY iot_device_id
) b ON a.iot_device_id = b.iot_device_id AND a.create_time = b.latest_time
ORDER BY a.create_time DESC
</select>
<update id="updateSmokeValue">
UPDATE dc_smoke_record
SET smoke_value =#{smokeValue},update_time=#{updateTime}
WHERE id = (
SELECT id FROM (
SELECT id
FROM dc_smoke_record
WHERE iot_device_id = #{iotDeviceId}
ORDER BY create_time DESC
LIMIT 1
) AS latest_record
);
</update>
</mapper> </mapper>

Loading…
Cancel
Save