Compare commits

2 Commits

Author SHA1 Message Date
8597dc5a9f 导出围栏进出记录列表 2025-09-12 14:50:42 +08:00
01a1a6e25b 查询围栏进出记录 2025-09-12 11:48:39 +08:00
5 changed files with 75 additions and 19 deletions

View File

@ -55,13 +55,13 @@ public class DeviceFenceAccessRecordBo extends BaseEntity {
* 纬度
*/
@NotNull(message = "纬度不能为空", groups = { AddGroup.class, EditGroup.class })
private Long latitude;
private Double latitude;
/**
* 经度
*/
@NotNull(message = "经度不能为空", groups = { AddGroup.class, EditGroup.class })
private Long longitude;
private Double longitude;
/**
* 定位精度

View File

@ -1,6 +1,7 @@
package com.fuyuanshen.equipment.domain.vo;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
@ -15,7 +16,6 @@ import java.io.Serializable;
import java.util.Date;
/**
* 围栏进出记录视图对象 device_fence_access_record
*
@ -33,31 +33,44 @@ public class DeviceFenceAccessRecordVo implements Serializable {
/**
* 记录ID
*/
@ExcelProperty(value = "记录ID")
// @ExcelProperty(value = "记录ID")
private Long id;
/**
* 围栏ID
*/
@ExcelProperty(value = "围栏ID")
// @ExcelProperty(value = "围栏ID")
private Long fenceId;
/**
* 围栏名称
*/
@ExcelProperty(value = "围栏名称")
private String fenceName;
/**
* 设备标识
*/
@ExcelProperty(value = "设备标识")
private String deviceId;
// @ExcelProperty(value = "设备标识")
private Long deviceId;
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 用户ID
*/
@ExcelProperty(value = "用户ID")
// @ExcelProperty(value = "用户ID")
private Long userId;
/**
* 事件类型
*/
@ExcelProperty(value = "事件类型")
@ExcelProperty(value = "事件类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "1=进入围栏,2=离开围栏")
private Long eventType;
/**

View File

@ -1,8 +1,14 @@
package com.fuyuanshen.equipment.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
import com.fuyuanshen.equipment.domain.DeviceFenceAccessRecord;
import com.fuyuanshen.equipment.domain.vo.DeviceFenceAccessRecordVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 围栏进出记录Mapper接口
@ -12,4 +18,16 @@ import com.fuyuanshen.equipment.domain.vo.DeviceFenceAccessRecordVo;
*/
public interface DeviceFenceAccessRecordMapper extends BaseMapperPlus<DeviceFenceAccessRecord, DeviceFenceAccessRecordVo> {
/**
* 分页查询围栏进出记录列表(包含围栏名称和设备名称)
*
* @param page 分页参数
* @param wrapper 查询条件
* @return 围栏进出记录分页列表
*/
Page<DeviceFenceAccessRecordVo> selectVoPageWithFenceAndDeviceName(Page<DeviceFenceAccessRecord> page, @Param(Constants.WRAPPER) Wrapper<DeviceFenceAccessRecord> wrapper);
List<DeviceFenceAccessRecordVo> selectVoPageWithFenceAndDeviceName(@Param(Constants.WRAPPER) Wrapper<DeviceFenceAccessRecord> wrapper);
}

View File

@ -54,7 +54,7 @@ public class DeviceFenceAccessRecordServiceImpl implements IDeviceFenceAccessRec
@Override
public TableDataInfo<DeviceFenceAccessRecordVo> queryPageList(DeviceFenceAccessRecordBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<DeviceFenceAccessRecord> lqw = buildQueryWrapper(bo);
Page<DeviceFenceAccessRecordVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
Page<DeviceFenceAccessRecordVo> result = baseMapper.selectVoPageWithFenceAndDeviceName(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
@ -67,13 +67,13 @@ public class DeviceFenceAccessRecordServiceImpl implements IDeviceFenceAccessRec
@Override
public List<DeviceFenceAccessRecordVo> queryList(DeviceFenceAccessRecordBo bo) {
LambdaQueryWrapper<DeviceFenceAccessRecord> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
return baseMapper.selectVoPageWithFenceAndDeviceName(lqw);
}
private LambdaQueryWrapper<DeviceFenceAccessRecord> buildQueryWrapper(DeviceFenceAccessRecordBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<DeviceFenceAccessRecord> lqw = Wrappers.lambdaQuery();
lqw.orderByAsc(DeviceFenceAccessRecord::getId);
// lqw.orderByAsc(DeviceFenceAccessRecord::getId);
lqw.eq(bo.getFenceId() != null, DeviceFenceAccessRecord::getFenceId, bo.getFenceId());
lqw.eq(StringUtils.isNotBlank(bo.getDeviceId()), DeviceFenceAccessRecord::getDeviceId, bo.getDeviceId());
lqw.eq(bo.getUserId() != null, DeviceFenceAccessRecord::getUserId, bo.getUserId());

View File

@ -4,4 +4,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceFenceAccessRecordMapper">
<!-- 分页查询围栏进出记录列表 -->
<select id="selectVoPageWithFenceAndDeviceName"
resultType="com.fuyuanshen.equipment.domain.vo.DeviceFenceAccessRecordVo">
SELECT
r.id,
r.fence_id,
f.name AS fence_name,
r.device_id,
d.device_name,
r.user_id,
r.event_type,
r.latitude,
r.longitude,
r.accuracy,
r.event_time,
r.create_time
FROM device_fence_access_record r
LEFT JOIN device_geo_fence f ON r.fence_id = f.id
LEFT JOIN device d ON r.device_id = d.id
<where>
${ew.customSqlSegment}
</where>
ORDER BY r.id ASC
</select>
</mapper>