Browse Source

设备离线记录

develop
lau572 2 months ago
parent
commit
0a0f6c7953
  1. 3
      ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java
  2. 5
      zc-business/src/main/java/com/zc/business/constant/RedisKeyConstants.java
  3. 98
      zc-business/src/main/java/com/zc/business/controller/DcDeviceOfflineRecordController.java
  4. 17
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  5. 255
      zc-business/src/main/java/com/zc/business/domain/DcDeviceOfflineRecord.java
  6. 63
      zc-business/src/main/java/com/zc/business/mapper/DcDeviceOfflineRecordMapper.java
  7. 73
      zc-business/src/main/java/com/zc/business/service/IDcDeviceOfflineRecordService.java
  8. 194
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceOfflineRecordServiceImpl.java
  9. 135
      zc-business/src/main/resources/mapper/business/DcDeviceOfflineRecordMapper.xml

3
ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java

@ -19,4 +19,7 @@ public class WebSocketEvent {
//处置记录
public static final String EVENT_PROCESS = "eventProcess";
//设备离线记录
public static final String DEVICE_OFFLINE_RECORD = "deviceOfflineRecord";
}

5
zc-business/src/main/java/com/zc/business/constant/RedisKeyConstants.java

@ -63,4 +63,9 @@ public class RedisKeyConstants
* 高速云导入事件列表
*/
public static final String SDHS_EVENT_FILE = "sdhsEventFile";
/**
* 设备离线记录
*/
public static final String DC_DEVICE_OFFLINE_RECORD = "dc:deviceOfflineRecord";
}

98
zc-business/src/main/java/com/zc/business/controller/DcDeviceOfflineRecordController.java

@ -0,0 +1,98 @@
package com.zc.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.business.domain.DcDeviceOfflineRecord;
import com.zc.business.service.IDcDeviceOfflineRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 设备离线记录Controller
*
* @author ruoyi
* @date 2024-09-18
*/
@RestController
@RequestMapping("/deviceOfflineRecord")
public class DcDeviceOfflineRecordController extends BaseController
{
@Autowired
private IDcDeviceOfflineRecordService dcDeviceOfflineRecordService;
/**
* 查询设备离线记录列表
*/
@GetMapping("/list")
public TableDataInfo list(DcDeviceOfflineRecord dcDeviceOfflineRecord)
{
startPage();
List<DcDeviceOfflineRecord> list = dcDeviceOfflineRecordService.selectDcDeviceOfflineRecordList(dcDeviceOfflineRecord);
return getDataTable(list);
}
/**
* 导出设备离线记录列表
*/
@Log(title = "设备离线记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DcDeviceOfflineRecord dcDeviceOfflineRecord)
{
List<DcDeviceOfflineRecord> list = dcDeviceOfflineRecordService.selectDcDeviceOfflineRecordList(dcDeviceOfflineRecord);
ExcelUtil<DcDeviceOfflineRecord> util = new ExcelUtil<>(DcDeviceOfflineRecord.class);
util.exportExcel(response, list, "设备离线记录数据");
}
/**
* 获取设备离线记录详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(dcDeviceOfflineRecordService.selectDcDeviceOfflineRecordById(id));
}
/**
* 新增设备离线记录
*/
@Log(title = "设备离线记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcDeviceOfflineRecord dcDeviceOfflineRecord)
{
return toAjax(dcDeviceOfflineRecordService.insertDcDeviceOfflineRecord(dcDeviceOfflineRecord));
}
/**
* 修改设备离线记录
*/
@Log(title = "设备离线记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcDeviceOfflineRecord dcDeviceOfflineRecord)
{
return toAjax(dcDeviceOfflineRecordService.updateDcDeviceOfflineRecord(dcDeviceOfflineRecord));
}
/**
* 删除设备离线记录
*/
@Log(title = "设备离线记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(dcDeviceOfflineRecordService.deleteDcDeviceOfflineRecordByIds(ids));
}
}

17
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -14,6 +14,7 @@ import com.zc.business.domain.DcDevice;
import com.zc.business.enums.CameraDirectionEnum;
import com.zc.business.enums.LaneDirectionEnum;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.IDcDeviceOfflineRecordService;
import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IMiddleDatabaseService;
import com.zc.common.core.httpclient.OkHttp;
@ -79,6 +80,9 @@ public class VideoController extends BaseController {
@Resource
private IMiddleDatabaseService middleDatabaseService;
@Resource
private IDcDeviceOfflineRecordService dcDeviceOfflineRecordService;
@Autowired
private ISysConfigService configService;
@ -293,6 +297,9 @@ public class VideoController extends BaseController {
//更新中间库的设备状态
middleDatabaseService.updateMiddleDatabaseDeviceByList(list);
//设备离线记录
dcDeviceOfflineRecordService.batchDeviceOfflineRecord(list);
logger.debug("执行:同步数据平台视频设备的设备状态成功!!");
}
@ -313,6 +320,9 @@ public class VideoController extends BaseController {
//更新中间库的设备状态
middleDatabaseService.updateMiddleDatabaseDeviceByList(dcDevices);
//设备离线记录
dcDeviceOfflineRecordService.batchDeviceOfflineRecord(dcDevices);
logger.debug("执行:同步物联平台设备的设备状态成功!!");
}
@ -331,6 +341,13 @@ public class VideoController extends BaseController {
//更新中间库的设备状态
middleDatabaseService.updateMiddleDatabaseDevice(dcDevice);
//设备离线记录
List<DcDevice> list = new ArrayList<>();
list.add(dcDevice);
dcDeviceOfflineRecordService.batchDeviceOfflineRecord(list);
}
logger.debug("执行:同步广播设备的设备状态成功!!");

255
zc-business/src/main/java/com/zc/business/domain/DcDeviceOfflineRecord.java

@ -0,0 +1,255 @@
package com.zc.business.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 设备离线记录对象 dc_device_offline_record
*
* @author ruoyi
* @date 2024-09-18
*/
public class DcDeviceOfflineRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 设备表id */
@Excel(name = "设备表id")
private Long deviceId;
/** 物联id */
@Excel(name = "物联id")
private String iotDeviceId;
/** 设备名称 */
@Excel(name = "设备名称")
private String deviceName;
/** 设备类型
1 摄像机
2 可变信息标志
3 气象监测器
4 出口诱导灯
5 路段语音广播
6 护栏碰撞
7 毫米波雷达
8 合流区预警
9 智慧锥桶
10 激光疲劳唤醒
11 一类交通量调查站
12 行车诱导
13 智能设备箱
14 光线在线监测
15 太阳能板
16 远端机
*/
@Excel(name = "设备类型")
private String deviceType;
/** 所在桩号 */
@Excel(name = "所在桩号")
private String stakeMark;
/** 方向1-上行,2-中,3-下行 */
@Excel(name = "方向1-上行,2-中,3-下行")
private String direction;
/** 安装位置 */
@Excel(name = "安装位置")
private String installationSite;
/** 设备ip */
@Excel(name = "设备ip")
private String deviceIp;
/** 设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等 */
@Excel(name = "设施归属类型", readConverterExp = "设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等")
private String facilitiesType;
/** 子设备类型
1-1 高清网络枪型固定摄像机
1-2 高清网络球形摄像机
1-3 桥下高清网络球形摄像机
1-4 360°全景摄像机
1-5 180°全景摄像机
2-1 门架式可变信息标志
2-2站前可变信息标志 160*80
2-3 雨棚可变信息标志
2-4 站前悬臂式可变信息标志192*160 */
@Excel(name = "子设备类型")
private String childType;
/** 经度 */
@Excel(name = "经度")
private String longitude;
/** 纬度 */
@Excel(name = "纬度")
private String latitude;
/** 状态(0未处理 1已处理 2自动处理) */
@Excel(name = "状态(0未处理 1已处理 2自动处理)")
private String status;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setDeviceId(Long deviceId)
{
this.deviceId = deviceId;
}
public Long getDeviceId()
{
return deviceId;
}
public String getIotDeviceId() {
return iotDeviceId;
}
public void setIotDeviceId(String iotDeviceId) {
this.iotDeviceId = iotDeviceId;
}
public void setDeviceName(String deviceName)
{
this.deviceName = deviceName;
}
public String getDeviceName()
{
return deviceName;
}
public void setDeviceType(String deviceType)
{
this.deviceType = deviceType;
}
public String getDeviceType()
{
return deviceType;
}
public void setStakeMark(String stakeMark)
{
this.stakeMark = stakeMark;
}
public String getStakeMark()
{
return stakeMark;
}
public void setDirection(String direction)
{
this.direction = direction;
}
public String getDirection()
{
return direction;
}
public void setInstallationSite(String installationSite)
{
this.installationSite = installationSite;
}
public String getInstallationSite()
{
return installationSite;
}
public void setDeviceIp(String deviceIp)
{
this.deviceIp = deviceIp;
}
public String getDeviceIp()
{
return deviceIp;
}
public void setFacilitiesType(String facilitiesType)
{
this.facilitiesType = facilitiesType;
}
public String getFacilitiesType()
{
return facilitiesType;
}
public void setChildType(String childType)
{
this.childType = childType;
}
public String getChildType()
{
return childType;
}
public void setLongitude(String longitude)
{
this.longitude = longitude;
}
public String getLongitude()
{
return longitude;
}
public void setLatitude(String latitude)
{
this.latitude = latitude;
}
public String getLatitude()
{
return latitude;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("deviceId", getDeviceId())
.append("iotDeviceId", getIotDeviceId())
.append("deviceName", getDeviceName())
.append("deviceType", getDeviceType())
.append("stakeMark", getStakeMark())
.append("direction", getDirection())
.append("installationSite", getInstallationSite())
.append("deviceIp", getDeviceIp())
.append("facilitiesType", getFacilitiesType())
.append("childType", getChildType())
.append("longitude", getLongitude())
.append("latitude", getLatitude())
.append("status", getStatus())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.toString();
}
}

63
zc-business/src/main/java/com/zc/business/mapper/DcDeviceOfflineRecordMapper.java

@ -0,0 +1,63 @@
package com.zc.business.mapper;
import java.util.List;
import com.zc.business.domain.DcDeviceOfflineRecord;
/**
* 设备离线记录Mapper接口
*
* @author ruoyi
* @date 2024-09-18
*/
public interface DcDeviceOfflineRecordMapper
{
/**
* 查询设备离线记录
*
* @param id 设备离线记录主键
* @return 设备离线记录
*/
public DcDeviceOfflineRecord selectDcDeviceOfflineRecordById(Long id);
public List<DcDeviceOfflineRecord> selectDcDeviceOfflineRecordByIds(Long[] id);
/**
* 查询设备离线记录列表
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 设备离线记录集合
*/
List<DcDeviceOfflineRecord> selectDcDeviceOfflineRecordList(DcDeviceOfflineRecord dcDeviceOfflineRecord);
/**
* 新增设备离线记录
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 结果
*/
int insertDcDeviceOfflineRecord(DcDeviceOfflineRecord dcDeviceOfflineRecord);
/**
* 修改设备离线记录
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 结果
*/
int updateDcDeviceOfflineRecord(DcDeviceOfflineRecord dcDeviceOfflineRecord);
/**
* 删除设备离线记录
*
* @param id 设备离线记录主键
* @return 结果
*/
int deleteDcDeviceOfflineRecordById(Long id);
/**
* 批量删除设备离线记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteDcDeviceOfflineRecordByIds(Long[] ids);
}

73
zc-business/src/main/java/com/zc/business/service/IDcDeviceOfflineRecordService.java

@ -0,0 +1,73 @@
package com.zc.business.service;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcDeviceOfflineRecord;
/**
* 设备离线记录Service接口
*
* @author ruoyi
* @date 2024-09-18
*/
public interface IDcDeviceOfflineRecordService
{
/**
* 查询设备离线记录
*
* @param id 设备离线记录主键
* @return 设备离线记录
*/
public DcDeviceOfflineRecord selectDcDeviceOfflineRecordById(Long id);
/**
* 查询设备离线记录列表
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 设备离线记录集合
*/
List<DcDeviceOfflineRecord> selectDcDeviceOfflineRecordList(DcDeviceOfflineRecord dcDeviceOfflineRecord);
/**
* 新增设备离线记录
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 结果
*/
int insertDcDeviceOfflineRecord(DcDeviceOfflineRecord dcDeviceOfflineRecord);
/**
* 修改设备离线记录
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 结果
*/
int updateDcDeviceOfflineRecord(DcDeviceOfflineRecord dcDeviceOfflineRecord);
/**
* 批量删除设备离线记录
*
* @param ids 需要删除的设备离线记录主键集合
* @return 结果
*/
int deleteDcDeviceOfflineRecordByIds(Long[] ids);
/**
* 删除设备离线记录信息
*
* @param id 设备离线记录主键
* @return 结果
*/
int deleteDcDeviceOfflineRecordById(Long id);
/**
* 批量处理 设备离线记录
*
* @param deviceList
* @return 结果
*/
AjaxResult batchDeviceOfflineRecord(List<DcDevice> deviceList);
}

194
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceOfflineRecordServiceImpl.java

@ -0,0 +1,194 @@
package com.zc.business.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.DcDevice;
import com.zc.common.core.websocket.WebSocketService;
import com.zc.common.core.websocket.constant.WebSocketEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.business.mapper.DcDeviceOfflineRecordMapper;
import com.zc.business.domain.DcDeviceOfflineRecord;
import com.zc.business.service.IDcDeviceOfflineRecordService;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
/**
* 设备离线记录Service业务层处理
*
* @author ruoyi
* @date 2024-09-18
*/
@Service
public class DcDeviceOfflineRecordServiceImpl implements IDcDeviceOfflineRecordService
{
@Autowired
private DcDeviceOfflineRecordMapper dcDeviceOfflineRecordMapper;
@Autowired
private RedisCache redisCache;
/**
* 查询设备离线记录
*
* @param id 设备离线记录主键
* @return 设备离线记录
*/
@Override
public DcDeviceOfflineRecord selectDcDeviceOfflineRecordById(Long id)
{
return dcDeviceOfflineRecordMapper.selectDcDeviceOfflineRecordById(id);
}
/**
* 查询设备离线记录列表
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 设备离线记录
*/
@Override
public List<DcDeviceOfflineRecord> selectDcDeviceOfflineRecordList(DcDeviceOfflineRecord dcDeviceOfflineRecord)
{
return dcDeviceOfflineRecordMapper.selectDcDeviceOfflineRecordList(dcDeviceOfflineRecord);
}
/**
* 新增设备离线记录
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 结果
*/
@Override
public int insertDcDeviceOfflineRecord(DcDeviceOfflineRecord dcDeviceOfflineRecord)
{
dcDeviceOfflineRecord.setCreateTime(DateUtils.getNowDate());
int i = dcDeviceOfflineRecordMapper.insertDcDeviceOfflineRecord(dcDeviceOfflineRecord);
redisCache.setCacheMapValue(RedisKeyConstants.DC_DEVICE_OFFLINE_RECORD,dcDeviceOfflineRecord.getIotDeviceId(),dcDeviceOfflineRecord);
//websocket推送
Map<String, Object> contentMap = new HashMap<>();
String direction = "";
if (StringUtils.isNotEmpty(dcDeviceOfflineRecord.getDirection())){
if ("1".equals(dcDeviceOfflineRecord.getDirection())){
direction = "菏泽方向";
} else if ("3".equals(dcDeviceOfflineRecord.getDirection())){
direction = "济南方向";
}
}
String content = dcDeviceOfflineRecord.getStakeMark() + direction + dcDeviceOfflineRecord.getDeviceName() + "发生故障";
contentMap.put("content",content);
contentMap.put("deviceOfflineRecord",dcDeviceOfflineRecord);
WebSocketService.broadcast(WebSocketEvent.DEVICE_OFFLINE_RECORD, contentMap);
return i;
}
/**
* 修改设备离线记录
*
* @param dcDeviceOfflineRecord 设备离线记录
* @return 结果
*/
@Override
public int updateDcDeviceOfflineRecord(DcDeviceOfflineRecord dcDeviceOfflineRecord)
{
dcDeviceOfflineRecord.setUpdateTime(DateUtils.getNowDate());
dcDeviceOfflineRecord.setUpdateBy(getUsername());
String status = dcDeviceOfflineRecord.getStatus();
if (StringUtils.isNotEmpty(status) && ("1".equals(status) || "2".equals(status))){
redisCache.delCacheMapValue(RedisKeyConstants.DC_DEVICE_OFFLINE_RECORD,dcDeviceOfflineRecord.getIotDeviceId());
} else {
redisCache.setCacheMapValue(RedisKeyConstants.DC_DEVICE_OFFLINE_RECORD,dcDeviceOfflineRecord.getIotDeviceId(),dcDeviceOfflineRecord);
}
return dcDeviceOfflineRecordMapper.updateDcDeviceOfflineRecord(dcDeviceOfflineRecord);
}
/**
* 批量删除设备离线记录
*
* @param ids 需要删除的设备离线记录主键
* @return 结果
*/
@Override
public int deleteDcDeviceOfflineRecordByIds(Long[] ids)
{
List<DcDeviceOfflineRecord> list = dcDeviceOfflineRecordMapper.selectDcDeviceOfflineRecordByIds(ids);
for (int i = 0; i < list.size(); i++) {
redisCache.delCacheMapValue(RedisKeyConstants.DC_DEVICE_OFFLINE_RECORD,list.get(i).getIotDeviceId());
}
return dcDeviceOfflineRecordMapper.deleteDcDeviceOfflineRecordByIds(ids);
}
/**
* 删除设备离线记录信息
*
* @param id 设备离线记录主键
* @return 结果
*/
@Override
public int deleteDcDeviceOfflineRecordById(Long id)
{
return dcDeviceOfflineRecordMapper.deleteDcDeviceOfflineRecordById(id);
}
/**
* 批量处理 设备离线记录
*
* @param deviceList
* @return 结果
*/
@Override
public AjaxResult batchDeviceOfflineRecord(List<DcDevice> deviceList)
{
for (DcDevice dcDevice : deviceList) {
String iotDeviceId = dcDevice.getIotDeviceId();
String deviceState = dcDevice.getDeviceState();
if (StringUtils.isNotEmpty(iotDeviceId) && StringUtils.isNotEmpty(deviceState)){
DcDeviceOfflineRecord cache = redisCache.getCacheMapValue(RedisKeyConstants.DC_DEVICE_OFFLINE_RECORD,iotDeviceId);
if ("0".equals(deviceState) && cache == null){
//异常状态并且表里有无此纪录, 新增
DcDevice dcDeviceCache = redisCache.getCacheMapValue(RedisKeyConstants.DC_DEVICES, iotDeviceId);
if (dcDeviceCache != null){
DcDeviceOfflineRecord dcDeviceOfflineRecord = new DcDeviceOfflineRecord();
dcDeviceOfflineRecord.setDeviceId(dcDeviceCache.getId());
dcDeviceOfflineRecord.setIotDeviceId(dcDeviceCache.getIotDeviceId());
dcDeviceOfflineRecord.setDeviceName(dcDeviceCache.getDeviceName());
dcDeviceOfflineRecord.setDeviceType(dcDeviceCache.getDeviceType());
dcDeviceOfflineRecord.setStakeMark(dcDeviceCache.getStakeMark());
dcDeviceOfflineRecord.setDirection(dcDeviceCache.getDirection());
dcDeviceOfflineRecord.setInstallationSite(dcDeviceCache.getInstallationSite());
dcDeviceOfflineRecord.setDeviceIp(dcDeviceCache.getDeviceIp());
dcDeviceOfflineRecord.setFacilitiesType(dcDeviceCache.getFacilitiesType());
dcDeviceOfflineRecord.setChildType(dcDeviceCache.getChildType());
dcDeviceOfflineRecord.setLatitude(dcDeviceCache.getLatitude());
dcDeviceOfflineRecord.setLongitude(dcDeviceCache.getLongitude());
dcDeviceOfflineRecord.setStatus("0");
insertDcDeviceOfflineRecord(dcDeviceOfflineRecord);
}
} else if ("1".equals(deviceState) && cache != null){
//正常状态并且表里有离线记录, 修改为自动结束
DcDeviceOfflineRecord dcDeviceOfflineRecord = new DcDeviceOfflineRecord();
dcDeviceOfflineRecord.setId(cache.getId());
dcDeviceOfflineRecord.setStatus("2");
dcDeviceOfflineRecord.setUpdateTime(DateUtils.getNowDate());
dcDeviceOfflineRecordMapper.updateDcDeviceOfflineRecord(dcDeviceOfflineRecord);
redisCache.delCacheMapValue(RedisKeyConstants.DC_DEVICE_OFFLINE_RECORD,iotDeviceId);
}
}
}
return AjaxResult.success("操作成功");
}
}

135
zc-business/src/main/resources/mapper/business/DcDeviceOfflineRecordMapper.xml

@ -0,0 +1,135 @@
<?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">
<mapper namespace="com.zc.business.mapper.DcDeviceOfflineRecordMapper">
<resultMap type="DcDeviceOfflineRecord" id="DcDeviceOfflineRecordResult">
<result property="id" column="id" />
<result property="deviceId" column="device_id" />
<result property="iotDeviceId" column="iot_device_id" />
<result property="deviceName" column="device_name" />
<result property="deviceType" column="device_type" />
<result property="stakeMark" column="stake_mark" />
<result property="direction" column="direction" />
<result property="installationSite" column="installation_site" />
<result property="deviceIp" column="device_ip" />
<result property="facilitiesType" column="facilities_type" />
<result property="childType" column="child_type" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectDcDeviceOfflineRecordVo">
select id, device_id,iot_device_id, device_name, device_type, stake_mark, direction, installation_site, device_ip, facilities_type, child_type, longitude, latitude, status, create_time, update_time, update_by from dc_device_offline_record
</sql>
<select id="selectDcDeviceOfflineRecordList" parameterType="DcDeviceOfflineRecord" resultMap="DcDeviceOfflineRecordResult">
<include refid="selectDcDeviceOfflineRecordVo"/>
<where>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="iotDeviceId != null "> and iot_device_id = #{iotDeviceId}</if>
<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 = #{stakeMark}</if>
<if test="direction != null and direction != ''"> and direction = #{direction}</if>
<if test="installationSite != null and installationSite != ''"> and installation_site = #{installationSite}</if>
<if test="deviceIp != null and deviceIp != ''"> and device_ip = #{deviceIp}</if>
<if test="facilitiesType != null and facilitiesType != ''"> and facilities_type = #{facilitiesType}</if>
<if test="childType != null and childType != ''"> and child_type = #{childType}</if>
<if test="longitude != null and longitude != ''"> and longitude = #{longitude}</if>
<if test="latitude != null and latitude != ''"> and latitude = #{latitude}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectDcDeviceOfflineRecordById" parameterType="Long" resultMap="DcDeviceOfflineRecordResult">
<include refid="selectDcDeviceOfflineRecordVo"/>
where id = #{id}
</select>
<select id="selectDcDeviceOfflineRecordByIds" parameterType="String" resultType="com.zc.business.domain.DcDeviceOfflineRecord">
<include refid="selectDcDeviceOfflineRecordVo"/>
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertDcDeviceOfflineRecord" parameterType="DcDeviceOfflineRecord" useGeneratedKeys="true" keyProperty="id">
insert into dc_device_offline_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="iotDeviceId != null">iot_device_id,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="deviceType != null and deviceType != ''">device_type,</if>
<if test="stakeMark != null and stakeMark != ''">stake_mark,</if>
<if test="direction != null">direction,</if>
<if test="installationSite != null">installation_site,</if>
<if test="deviceIp != null">device_ip,</if>
<if test="facilitiesType != null">facilities_type,</if>
<if test="childType != null">child_type,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="status != null">status,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="iotDeviceId != null">#{iotDeviceId},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="deviceType != null and deviceType != ''">#{deviceType},</if>
<if test="stakeMark != null and stakeMark != ''">#{stakeMark},</if>
<if test="direction != null">#{direction},</if>
<if test="installationSite != null">#{installationSite},</if>
<if test="deviceIp != null">#{deviceIp},</if>
<if test="facilitiesType != null">#{facilitiesType},</if>
<if test="childType != null">#{childType},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="status != null">#{status},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateDcDeviceOfflineRecord" parameterType="DcDeviceOfflineRecord">
update dc_device_offline_record
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="iotDeviceId != null">iot_device_id = #{iotDeviceId},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="deviceType != null and deviceType != ''">device_type = #{deviceType},</if>
<if test="stakeMark != null and stakeMark != ''">stake_mark = #{stakeMark},</if>
<if test="direction != null">direction = #{direction},</if>
<if test="installationSite != null">installation_site = #{installationSite},</if>
<if test="deviceIp != null">device_ip = #{deviceIp},</if>
<if test="facilitiesType != null">facilities_type = #{facilitiesType},</if>
<if test="childType != null">child_type = #{childType},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="status != null">status = #{status},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDcDeviceOfflineRecordById" parameterType="Long">
delete from dc_device_offline_record where id = #{id}
</delete>
<delete id="deleteDcDeviceOfflineRecordByIds" parameterType="String">
delete from dc_device_offline_record where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save