web端控制中心4
This commit is contained in:
@ -10,6 +10,7 @@ import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
|
||||
import com.fuyuanshen.global.mqtt.base.MqttRuleEngine;
|
||||
import com.fuyuanshen.global.mqtt.base.MqttXinghanCommandType;
|
||||
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
|
||||
import com.fuyuanshen.global.queue.MqttMessageQueueConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.Message;
|
||||
@ -51,6 +52,9 @@ public class ReceiverMessageHandler implements MessageHandler {
|
||||
//在线状态
|
||||
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
||||
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(62));
|
||||
// String queueKey = MqttMessageQueueConstants.MQTT_MESSAGE_QUEUE_KEY;
|
||||
// String dedupKey = MqttMessageQueueConstants.MQTT_MESSAGE_DEDUP_KEY;
|
||||
// RedisUtils.offerDeduplicated(queueKey,dedupKey,deviceImei, Duration.ofHours(24));
|
||||
}
|
||||
|
||||
String state = payloadDict.getStr("state");
|
||||
|
@ -0,0 +1,110 @@
|
||||
package com.fuyuanshen.global.queue;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MqttMessageConsumer {
|
||||
|
||||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
// 创建两个线程池:一个用于消息获取,一个用于业务处理
|
||||
private ExecutorService messageConsumerPool = Executors.newFixedThreadPool(3);
|
||||
private ExecutorService messageProcessorPool = Executors.newFixedThreadPool(10);
|
||||
|
||||
// 初始化方法,启动消息监听
|
||||
// @PostConstruct
|
||||
public void start() {
|
||||
log.info("启动MQTT消息消费者...");
|
||||
// 启动消息获取线程
|
||||
for (int i = 0; i < 3; i++) {
|
||||
messageConsumerPool.submit(this::consumeMessages);
|
||||
}
|
||||
}
|
||||
|
||||
// 销毁方法,关闭线程池
|
||||
@PreDestroy
|
||||
public void stop() {
|
||||
log.info("关闭MQTT消息消费者...");
|
||||
shutdownExecutorService(messageConsumerPool);
|
||||
shutdownExecutorService(messageProcessorPool);
|
||||
}
|
||||
|
||||
private void shutdownExecutorService(ExecutorService executorService) {
|
||||
if (executorService != null && !executorService.isShutdown()) {
|
||||
executorService.shutdown();
|
||||
try {
|
||||
if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
|
||||
executorService.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
executorService.shutdownNow();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 消费者方法 - 专门负责从队列获取消息
|
||||
public void consumeMessages() {
|
||||
String queueKey = MqttMessageQueueConstants.MQTT_MESSAGE_QUEUE_KEY;
|
||||
String threadName = Thread.currentThread().getName();
|
||||
log.info("消息消费者线程 {} 开始监听队列: {}", threadName, queueKey);
|
||||
|
||||
try {
|
||||
while (!Thread.currentThread().isInterrupted() && !messageConsumerPool.isShutdown()) {
|
||||
// 阻塞式获取队列中的消息
|
||||
String message = RedisUtils.pollDeduplicated(
|
||||
queueKey,
|
||||
MqttMessageQueueConstants.MQTT_MESSAGE_DEDUP_KEY,
|
||||
1,
|
||||
TimeUnit.SECONDS
|
||||
);
|
||||
|
||||
if (message != null) {
|
||||
log.info("线程 {} 从队列中获取到消息,提交到处理线程池: {}", threadName, message);
|
||||
// 将消息处理任务提交到处理线程池
|
||||
messageProcessorPool.submit(() -> processMessage(message));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("线程 {} 消费消息时发生错误", threadName, e);
|
||||
}
|
||||
|
||||
log.info("消息消费者线程 {} 停止监听队列", threadName);
|
||||
}
|
||||
|
||||
// 处理具体业务逻辑的方法
|
||||
private void processMessage(String message) {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
try {
|
||||
log.info("业务处理线程 {} 开始处理消息: {}", threadName, message);
|
||||
|
||||
// 实现具体的业务逻辑
|
||||
// 例如更新数据库、发送通知等
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("device_imei", message)
|
||||
.set("online_status", 1);
|
||||
deviceMapper.update(updateWrapper);
|
||||
// 模拟业务处理耗时
|
||||
Thread.sleep(200);
|
||||
|
||||
log.info("业务处理线程 {} 完成消息处理: {}", threadName, message);
|
||||
} catch (Exception e) {
|
||||
log.error("业务处理线程 {} 处理消息时发生错误: {}", threadName, message, e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.fuyuanshen.global.queue;
|
||||
|
||||
public class MqttMessageQueueConstants {
|
||||
public static final String MQTT_MESSAGE_QUEUE_KEY = "mqtt:message:queue";
|
||||
public static final String MQTT_MESSAGE_DEDUP_KEY = "mqtt:message:dedup";
|
||||
}
|
@ -1,19 +1,20 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.*;
|
||||
import com.fuyuanshen.web.service.device.DeviceBizService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -101,4 +102,48 @@ public class DeviceControlCenterController extends BaseController {
|
||||
return appDeviceService.getInstructionRecord(dto,pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public void export(InstructionRecordDto dto, PageQuery pageQuery, HttpServletResponse response) {
|
||||
pageQuery.setPageNum(1);
|
||||
pageQuery.setPageSize(2000);
|
||||
TableDataInfo<InstructionRecordVo> instructionRecord = appDeviceService.getInstructionRecord(dto, pageQuery);
|
||||
if(instructionRecord.getRows() == null){
|
||||
return;
|
||||
}
|
||||
ExcelUtil.exportExcel(instructionRecord.getRows(), "设备操作日志", InstructionRecordVo.class, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 历史轨迹查询
|
||||
*/
|
||||
@GetMapping("/locationHistory")
|
||||
public TableDataInfo<LocationHistoryVo> getLocationHistory(InstructionRecordDto dto, PageQuery pageQuery) {
|
||||
return appDeviceService.getLocationHistory(dto,pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史轨迹导出
|
||||
*/
|
||||
@GetMapping("/locationHistoryExport")
|
||||
public void locationHistoryExport(InstructionRecordDto dto, PageQuery pageQuery, HttpServletResponse response) {
|
||||
pageQuery.setPageNum(1);
|
||||
pageQuery.setPageSize(2000);
|
||||
TableDataInfo<LocationHistoryVo> result = appDeviceService.getLocationHistory(dto, pageQuery);
|
||||
if(result.getRows() == null){
|
||||
return;
|
||||
}
|
||||
ExcelUtil.exportExcel(result.getRows(), "历史轨迹记录", LocationHistoryVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史轨迹导出
|
||||
*/
|
||||
@GetMapping("/getLocationHistoryDetail")
|
||||
public R<List<LocationHistoryDetailVo>> getLocationHistoryDetail(Long id) {
|
||||
return R.ok(appDeviceService.getLocationHistoryDetail(id));
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,7 @@ import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.*;
|
||||
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
||||
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
|
||||
@ -41,9 +39,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.time.*;
|
||||
import java.util.*;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
|
||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
|
||||
@ -336,4 +333,60 @@ public class DeviceBizService {
|
||||
Page<InstructionRecordVo> result = deviceLogMapper.getInstructionRecord(pageQuery.build(), bo);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
public TableDataInfo<LocationHistoryVo> getLocationHistory(InstructionRecordDto bo, PageQuery pageQuery) {
|
||||
Page<LocationHistoryVo> result = deviceMapper.getLocationHistory(pageQuery.build(), bo);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
public List<LocationHistoryDetailVo> getLocationHistoryDetail(Long id) {
|
||||
Device device = deviceMapper.selectById(id);
|
||||
if (device == null) {
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
|
||||
// 计算七天前的凌晨时间戳
|
||||
LocalDateTime sevenDaysAgo = LocalDateTime.of(LocalDate.now().minusDays(7), LocalTime.MIDNIGHT);
|
||||
long startTime = sevenDaysAgo.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
|
||||
// 计算今天的凌晨时间戳
|
||||
LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
|
||||
long endTime = today.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
|
||||
String deviceImei = device.getDeviceImei();
|
||||
String a = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX + ":history";
|
||||
Collection<String> list = RedisUtils.zRangeByScore(a, startTime, endTime);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Map<String, List<JSONObject>> map = new LinkedHashMap<>();
|
||||
for (String obj : list){
|
||||
JSONObject jsonObject = JSONObject.parseObject(obj);
|
||||
Long timestamp = jsonObject.getLong("timestamp");
|
||||
LocalDate date = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()).toLocalDate();
|
||||
if (map.containsKey(date.toString())) {
|
||||
map.get(date.toString()).add(jsonObject);
|
||||
} else {
|
||||
ArrayList<JSONObject> jsonList = new ArrayList<>();
|
||||
jsonList.add(jsonObject);
|
||||
map.put(date.toString(), jsonList);
|
||||
}
|
||||
}
|
||||
|
||||
List<LocationHistoryDetailVo> result = new ArrayList<>();
|
||||
for (Map.Entry<String, List<JSONObject>> entry : map.entrySet()) {
|
||||
LocationHistoryDetailVo detailVo = new LocationHistoryDetailVo();
|
||||
detailVo.setDate(entry.getKey());
|
||||
detailVo.setDeviceName(device.getDeviceName());
|
||||
detailVo.setStartLocation(entry.getValue().get(0).getString("address"));
|
||||
detailVo.setEndLocation(entry.getValue().get(entry.getValue().size()-1).getString("address"));
|
||||
detailVo.setDetailList(entry.getValue());
|
||||
result.add(detailVo);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -373,6 +374,28 @@ public class RedisUtils {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间范围查询Sorted Set中的元素(重载方法,适用于时间戳查询)
|
||||
*
|
||||
* @param key 键
|
||||
* @param startTime 开始时间戳
|
||||
* @param endTime 结束时间戳
|
||||
* @return 指定时间范围内的元素集合
|
||||
*/
|
||||
public static Collection<String> zRangeByScore(String key, Long startTime, Long endTime) {
|
||||
try {
|
||||
RScoredSortedSet<String> sortedSet = CLIENT.getScoredSortedSet(key);
|
||||
return sortedSet.valueRange(startTime, true, endTime, true);
|
||||
} catch (Exception e) {
|
||||
// 记录错误日志(如果项目中有日志工具的话)
|
||||
// log.error("根据时间范围查询Sorted Set中的元素失败: key={}, startTime={}, endTime={}, error={}",
|
||||
// key, startTime, endTime, e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 追加缓存Set数据
|
||||
*
|
||||
@ -614,4 +637,73 @@ public class RedisUtils {
|
||||
RKeys rKeys = CLIENT.getKeys();
|
||||
return rKeys.countExists(key) > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 向去重阻塞队列中添加元素
|
||||
*
|
||||
* @param queueKey 队列键
|
||||
* @param dedupKey 去重集合键
|
||||
* @param value 消息值
|
||||
* @param timeout 过期时间
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
public static boolean offerDeduplicated(String queueKey, String dedupKey, String value, Duration timeout) {
|
||||
// String jsonValue = value instanceof String ? (String) value : JsonUtils.toJsonString(value);
|
||||
|
||||
RLock lock = CLIENT.getLock("lock:" + queueKey);
|
||||
try {
|
||||
lock.lock();
|
||||
|
||||
RSet<String> dedupSet = CLIENT.getSet(dedupKey);
|
||||
if (dedupSet.contains(value)) {
|
||||
return false; // 元素已存在,不重复添加
|
||||
}
|
||||
|
||||
// 添加到去重集合
|
||||
dedupSet.add(value);
|
||||
|
||||
// 添加到阻塞队列
|
||||
RBlockingQueue<String> queue = CLIENT.getBlockingQueue(queueKey);
|
||||
boolean offered = queue.offer(value);
|
||||
|
||||
// 设置过期时间
|
||||
if (timeout != null) {
|
||||
queue.expire(timeout);
|
||||
dedupSet.expire(timeout);
|
||||
}
|
||||
|
||||
return offered;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从去重阻塞队列中消费元素
|
||||
*
|
||||
* @param queueKey 队列键
|
||||
* @param dedupKey 去重集合键
|
||||
* @param timeout 超时时间
|
||||
* @param timeUnit 时间单位
|
||||
* @return 消息值
|
||||
*/
|
||||
public static String pollDeduplicated(String queueKey, String dedupKey, long timeout, TimeUnit timeUnit) {
|
||||
try {
|
||||
RBlockingQueue<String> queue = CLIENT.getBlockingQueue(queueKey);
|
||||
String value = queue.poll(timeout, timeUnit);
|
||||
|
||||
// 从去重集合中移除
|
||||
if (value != null) {
|
||||
RSet<String> dedupSet = CLIENT.getSet(dedupKey);
|
||||
dedupSet.remove(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,4 +29,9 @@ public class InstructionRecordDto {
|
||||
* 操作时间-结束时间
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 分组id
|
||||
*/
|
||||
private Long groupId;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ -8,25 +9,31 @@ public class InstructionRecordVo {
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
|
||||
@ExcelProperty(value = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
@ExcelProperty(value = "设备型号")
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 操作模块
|
||||
*/
|
||||
@ExcelProperty(value = "操作模块")
|
||||
private String deviceAction;
|
||||
|
||||
/**
|
||||
* 操作内容
|
||||
*/
|
||||
@ExcelProperty(value = "操作内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@ExcelProperty(value = "操作时间")
|
||||
private String createTime;
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LocationHistoryDetailVo {
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@ExcelProperty(value = "日期")
|
||||
private String date;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@ExcelProperty(value = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 初始地点
|
||||
*/
|
||||
@ExcelProperty(value = "初始地点")
|
||||
private String startLocation;
|
||||
|
||||
/**
|
||||
* 结束地点
|
||||
*/
|
||||
@ExcelProperty(value = "结束地点")
|
||||
private String endLocation;
|
||||
|
||||
/**
|
||||
* 轨迹详情
|
||||
*/
|
||||
@ExcelProperty(value = "轨迹详情")
|
||||
private List<JSONObject> detailList;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LocationHistoryVo {
|
||||
private Long id;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
|
||||
@ExcelProperty(value = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
@ExcelProperty(value = "设备型号")
|
||||
private String deviceTypeName;
|
||||
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
@ExcelProperty(value = "设备IMEI")
|
||||
private String deviceImei;
|
||||
|
||||
/**
|
||||
* 设备MAC
|
||||
*/
|
||||
@ExcelProperty(value = "设备MAC")
|
||||
private String deviceMac;
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.LocationHistoryVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -71,4 +73,6 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
||||
AppDeviceVo getDeviceInfo(@Param("deviceMac") String deviceMac);
|
||||
|
||||
Page<WebDeviceVo> queryWebDeviceList(Page<Object> build,@Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
Page<LocationHistoryVo> getLocationHistory(Page<Object> build, @Param("bo") InstructionRecordDto criteria);
|
||||
}
|
||||
|
@ -29,10 +29,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND b.device_imei = #{bo.deviceImei}
|
||||
</if>
|
||||
<if test="bo.startTime != null and bo.startTime != ''">
|
||||
AND create_time <![CDATA[>=]]> #{bo.startTime}
|
||||
AND a.create_time <![CDATA[>=]]> #{bo.startTime}
|
||||
</if>
|
||||
<if test="bo.endTime != null and bo.endTime != ''">
|
||||
AND create_time <![CDATA[<=]]> #{bo.startTime}
|
||||
AND a.create_time <![CDATA[<=]]> #{bo.endTime}
|
||||
</if>
|
||||
<if test="bo.groupId != null">
|
||||
and b.group_id = #{bo.groupId}
|
||||
</if>
|
||||
ORDER BY
|
||||
a.create_time DESC
|
||||
|
@ -257,11 +257,8 @@
|
||||
<if test="criteria.deviceName != null and criteria.deviceName != ''">
|
||||
and d.device_name like concat('%', #{criteria.deviceName}, '%')
|
||||
</if>
|
||||
<if test="criteria.deviceMac != null">
|
||||
and d.device_mac = #{criteria.deviceMac}
|
||||
</if>
|
||||
<if test="criteria.deviceImei != null">
|
||||
and d.device_imei = #{criteria.deviceImei}
|
||||
and (d.device_imei = #{criteria.deviceImei} or d.device_mac = #{criteria.deviceImei})
|
||||
</if>
|
||||
<if test="criteria.deviceStatus != null">
|
||||
and d.device_status = #{criteria.deviceStatus}
|
||||
@ -276,5 +273,33 @@
|
||||
and d.group_id = #{criteria.groupId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getLocationHistory" resultType="com.fuyuanshen.equipment.domain.vo.LocationHistoryVo">
|
||||
select a.id,a.device_name,a.device_type,b.type_name deviceTypeName,a.device_imei,a.device_mac from device a
|
||||
inner join device_type b on a.device_type = b.id
|
||||
|
||||
<if test="bo.deviceType != null">
|
||||
AND b.id = #{bo.deviceType}
|
||||
</if>
|
||||
<if test="bo.deviceName != null and bo.deviceName != ''">
|
||||
AND a.device_name like concat('%',#{bo.deviceName},'%')
|
||||
</if>
|
||||
<if test="bo.deviceMac != null and bo.deviceMac != ''">
|
||||
AND a.device_mac = #{bo.deviceMac}
|
||||
</if>
|
||||
<if test="bo.deviceImei != null and bo.deviceImei != ''">
|
||||
AND a.device_imei = #{bo.deviceImei}
|
||||
</if>
|
||||
<if test="bo.startTime != null and bo.startTime != ''">
|
||||
AND a.create_time <![CDATA[>=]]> #{bo.startTime}
|
||||
</if>
|
||||
<if test="bo.endTime != null and bo.endTime != ''">
|
||||
AND a.create_time <![CDATA[<=]]> #{bo.endTime}
|
||||
</if>
|
||||
<if test="bo.groupId != null">
|
||||
and a.group_id = #{bo.groupId}
|
||||
</if>
|
||||
ORDER BY
|
||||
a.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user