Browse Source

门禁记录

develop
wangsixiang 1 month ago
parent
commit
bf9053468e
  1. 126
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  2. 126
      zc-business/src/main/java/com/zc/business/domain/DcDoor.java
  3. 5
      zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java
  4. 6
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  5. 12
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java
  6. 37
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

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

@ -13,11 +13,13 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
import com.zc.business.constant.DeviceTypeConstants; 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.DcEvent; import com.zc.business.domain.DcEvent;
import com.zc.business.enums.UniversalEnum; import com.zc.business.enums.UniversalEnum;
import com.zc.business.interfaces.OperationLog; import com.zc.business.interfaces.OperationLog;
@ -35,8 +37,10 @@ import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -73,6 +77,8 @@ public class DcDeviceController extends BaseController {
private VideoController videoController; private VideoController videoController;
private static final int THREAD_POOL_SIZE = 100; // 线程池大小 private static final int THREAD_POOL_SIZE = 100; // 线程池大小
private ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE); private ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
private static final String DOORSTATUS = "doorStatus";//redis策略缓存的key
/* /*
@Value("${iot.address}") @Value("${iot.address}")
private String iotAddress; private String iotAddress;
@ -1694,7 +1700,7 @@ private VideoController videoController;
} }
//一体机柜定时调用,采数据 //一体机柜定时调用,采数据
//@PostMapping("/integratedCabinetAir") //@PostMapping("/integratedCabinetAir")
@Scheduled(cron = "0 11/10 * * * ?") @Scheduled(cron = "0 * * * * ?")
public AjaxResult integratedCabinetAirConditioner() throws InterruptedException, IOException, HttpException { public AjaxResult integratedCabinetAirConditioner() throws InterruptedException, IOException, HttpException {
DcDevice dcDevice = new DcDevice(); DcDevice dcDevice = new DcDevice();
dcDevice.setDeviceType(UniversalEnum.SEVENTEEN.getValue()); dcDevice.setDeviceType(UniversalEnum.SEVENTEEN.getValue());
@ -1729,6 +1735,124 @@ private VideoController videoController;
jsonObject.put("functions", functions); jsonObject.put("functions", functions);
return batchInvokedFunction2(jsonObject); return batchInvokedFunction2(jsonObject);
} }
//一体机柜调用机箱门数据
@PostMapping("/integratedCabinetAir")
@Scheduled(cron = "20 * * * * ?")
@Transactional()
public AjaxResult chassisDoor() throws IOException, HttpException {
DcDevice dcDevice = new DcDevice();
dcDevice.setDeviceType(UniversalEnum.SEVENTEEN.getValue());
dcDevice.setDeviceState(UniversalEnum.ONE.getValue());
IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class);
List<DcDevice> dcDeviceList = dcDeviceService.listDevice(dcDevice);//取出全部在线的机柜
for (DcDevice device : dcDeviceList) {
AjaxResult result = getDeviceLatestProperty(device.getIotDeviceId(), "ChassisDoorInspection");
if (!result.get("code").toString().equals("200")){
continue;
}
JSONObject data = (JSONObject) result.get("data");//属性全部值
String value = data.get("value").toString();//属性值
if ("1".equals(value)){//机箱门状态为开
String cacheMapValue = redisCache.getCacheMapValue(DOORSTATUS, device.getIotDeviceId());//查询缓存
if ((cacheMapValue==null||"".equals(cacheMapValue))||"0".equals(cacheMapValue)){//缓存中不存在或者存在但值不同,加入缓存加入记录
DcDoor dcDoor = new DcDoor();
dcDoor.setCreateTime(DateUtils.getNowDate());
dcDoor.setDeviceName(device.getDeviceName());
dcDoor.setDeviceType(device.getDeviceType());
dcDoor.setDirection(device.getDirection());
dcDoor.setStakeMark(device.getStakeMark());
dcDoor.setOperate("箱门状态:开");
dcDoor.setIotDeviceId(device.getIotDeviceId());
dcDeviceService.insertDoorMonitor(dcDoor);
redisCache.setCacheMapValue(DOORSTATUS,device.getIotDeviceId(),value);
}
if ("1".equals(cacheMapValue)){//机箱最新获取的状态与缓存的状态相同,不做处理
continue;
}
}
if ("0".equals(value)){//机箱门状态为关
String cacheMapValue = redisCache.getCacheMapValue(DOORSTATUS, device.getIotDeviceId());//查询缓存
if ("1".equals(cacheMapValue)){//机箱门状态为关,缓存关开,删除缓存,加入记录
DcDoor dcDoor = new DcDoor();
dcDoor.setCreateTime(DateUtils.getNowDate());
dcDoor.setDeviceName(device.getDeviceName());
dcDoor.setDeviceType(device.getDeviceType());
dcDoor.setDirection(device.getDirection());
dcDoor.setStakeMark(device.getStakeMark());
dcDoor.setOperate("箱门状态:关");
dcDoor.setIotDeviceId(device.getIotDeviceId());
dcDeviceService.insertDoorMonitor(dcDoor);
redisCache.delCacheMapValue(DOORSTATUS,device.getIotDeviceId());
}else {
continue;
}
}
}
return AjaxResult.success();
}
//设备箱机箱门状态采集
//@PostMapping("/integratedCabinetAir")
@Scheduled(cron = "40 * * * * ?")
@Transactional()
public AjaxResult equipmentBoxDoor() throws IOException, HttpException {
DcDevice dcDevice = new DcDevice();
dcDevice.setDeviceType(UniversalEnum.THIRTEEN.getValue());
dcDevice.setDeviceState(UniversalEnum.ONE.getValue());
IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class);
List<DcDevice> dcDeviceList = dcDeviceService.listDevice(dcDevice);//取出全部在线的设备箱
for (DcDevice device : dcDeviceList) {
AjaxResult result = getDeviceLatestProperty(device.getIotDeviceId(), "1ac");
if (!result.get("code").toString().equals("200")) {
continue;
}
JSONObject data = (JSONObject) result.get("data");//属性全部值
JSONObject value = (JSONObject) data.get("value");
String doorStatus = value.get("door_status").toString();//属性值
if ("1".equals(doorStatus)){//机箱门状态为开
String cacheMapValue = redisCache.getCacheMapValue(DOORSTATUS, device.getIotDeviceId());//查询缓存
if ((cacheMapValue==null||"".equals(cacheMapValue))||"0".equals(cacheMapValue)){//缓存中不存在或者存在但值不同,加入缓存加入记录
DcDoor dcDoor = new DcDoor();
dcDoor.setCreateTime(DateUtils.getNowDate());
dcDoor.setDeviceName(device.getDeviceName());
dcDoor.setDeviceType(device.getDeviceType());
dcDoor.setDirection(device.getDirection());
dcDoor.setStakeMark(device.getStakeMark());
dcDoor.setOperate("箱门状态:开");
dcDoor.setIotDeviceId(device.getIotDeviceId());
dcDeviceService.insertDoorMonitor(dcDoor);
redisCache.setCacheMapValue(DOORSTATUS,device.getIotDeviceId(),doorStatus);
}
if ("1".equals(cacheMapValue)){//机箱最新获取的状态与缓存的状态相同,不做处理
continue;
}
}
if ("0".equals(doorStatus)){//机箱门状态为关
String cacheMapValue = redisCache.getCacheMapValue(DOORSTATUS, device.getIotDeviceId());//查询缓存
if ("1".equals(cacheMapValue)){//机箱门状态为关,缓存关开,删除缓存,加入记录
DcDoor dcDoor = new DcDoor();
dcDoor.setCreateTime(DateUtils.getNowDate());
dcDoor.setDeviceName(device.getDeviceName());
dcDoor.setDeviceType(device.getDeviceType());
dcDoor.setDirection(device.getDirection());
dcDoor.setStakeMark(device.getStakeMark());
dcDoor.setOperate("箱门状态:关");
dcDoor.setIotDeviceId(device.getIotDeviceId());
dcDeviceService.insertDoorMonitor(dcDoor);
redisCache.delCacheMapValue(DOORSTATUS,device.getIotDeviceId());
}else {
continue;
}
}
}
return null;
}
@GetMapping("/dcDoorList")
public TableDataInfo selectEnergyCircuit( DcDoor dcDoor){
startPage();
List<DcDoor> list = dcDeviceService.selectDcDoorList(dcDoor);
return getDataTable(list);
}
//一体机柜空调定时调用,采数据 //一体机柜空调定时调用,采数据
//@PostMapping("/integratedCabinetAir2") //@PostMapping("/integratedCabinetAir2")
@Scheduled(cron = "0 7 * * * *") @Scheduled(cron = "0 7 * * * *")

126
zc-business/src/main/java/com/zc/business/domain/DcDoor.java

@ -0,0 +1,126 @@
package com.zc.business.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
/**
* @author 王思祥
* @ClassName DcDoor
*/
public class DcDoor 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 operate;
private String iotDeviceId;
private String endStakeMark;
private String startTime;
private String endTime;
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 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 getOperate() {
return operate;
}
public void setOperate(String operate) {
this.operate = operate;
}
public String getIotDeviceId() {
return iotDeviceId;
}
public void setIotDeviceId(String iotDeviceId) {
this.iotDeviceId = iotDeviceId;
}
@Override
public String toString() {
return "DcDoor{" +
"id=" + id +
", stakeMark='" + stakeMark + '\'' +
", direction='" + direction + '\'' +
", deviceName='" + deviceName + '\'' +
", deviceType='" + deviceType + '\'' +
", operate='" + operate + '\'' +
", iotDeviceId='" + iotDeviceId + '\'' +
'}';
}
}

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

@ -2,6 +2,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 org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -45,4 +46,8 @@ public interface DcDeviceMapper extends BaseMapper<DcDevice> {
//获取设备信息 //获取设备信息
DcDevice getDcDeviceById(@Param("iotDeviceId") String iotDeviceId); DcDevice getDcDeviceById(@Param("iotDeviceId") String iotDeviceId);
//新增电子门锁记录
Integer insertDoorMonitor(DcDoor dcDoor);
//查询电子门锁记录
List<DcDoor> selectDcDoorList(DcDoor dcDoor);
} }

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

@ -4,6 +4,7 @@ package com.zc.business.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.AjaxResult; 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.DcEvent; import com.zc.business.domain.DcEvent;
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;
@ -132,4 +133,9 @@ public interface IDcDeviceService extends IService<DcDevice> {
List<DcDevice> selectTollStationCamPile(String direction, String startMileage, String endMileage); List<DcDevice> selectTollStationCamPile(String direction, String startMileage, String endMileage);
//获取设备信息 //获取设备信息
DcDevice getDcDeviceById(@Param("iotDeviceId") String iotDeviceId); DcDevice getDcDeviceById(@Param("iotDeviceId") String iotDeviceId);
//新增电子门锁记录
Integer insertDoorMonitor(DcDoor dcDoor);
//查询电子门锁记录
List<DcDoor> selectDcDoorList(DcDoor dcDoor);
} }

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

@ -11,6 +11,7 @@ import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StakeMarkUtils; import com.ruoyi.common.utils.StakeMarkUtils;
import com.zc.business.constant.RedisKeyConstants; import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
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.DcStakeMark; import com.zc.business.domain.DcStakeMark;
@ -670,5 +671,16 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
public DcDevice getDcDeviceById(String iotDeviceId) { public DcDevice getDcDeviceById(String iotDeviceId) {
return dcDeviceMapper.getDcDeviceById(iotDeviceId); return dcDeviceMapper.getDcDeviceById(iotDeviceId);
} }
//新增电子门锁记录
@Override
public Integer insertDoorMonitor(DcDoor dcDoor) {
return dcDeviceMapper.insertDoorMonitor(dcDoor);
}
//新增电子门锁记录
@Override
public List<DcDoor> selectDcDoorList(DcDoor dcDoor) {
return dcDeviceMapper.selectDcDoorList(dcDoor);
}
} }

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

@ -70,7 +70,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
child_type child_type
from dc_device from dc_device
</sql> </sql>
<insert id="insertDoorMonitor">
insert into dc_door_monitor
<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="operate != null and operate != ''">operate,</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="operate != null and operate != ''">#{operate},</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">
@ -202,4 +224,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getDcDeviceById" resultType="com.zc.business.domain.DcDevice"> <select id="getDcDeviceById" resultType="com.zc.business.domain.DcDevice">
select device_state from dc_device where iot_device_id=#{iotDeviceId} select device_state from dc_device where iot_device_id=#{iotDeviceId}
</select> </select>
<select id="selectDcDoorList" resultType="com.zc.business.domain.DcDoor">
select id,device_name,device_type,direction,stake_mark,operate,create_time from dc_door_monitor
<where>
<if test="deviceName != null and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceType != null and deviceType != ''">and device_type = #{deviceType}</if>
<if test="stakeMark != null and stakeMark != ''"> and stake_mark BETWEEN #{stakeMark} and #{endStakeMark} </if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and date_format(create_time,'%Y-%m-%d %H:%i:%s') >= date_format(#{startTime},'%Y-%m-%d %H:%i:%s')
and date_format(create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
</if>
</where>
order by create_time desc
</select>
</mapper> </mapper>

Loading…
Cancel
Save