feat(rfid): 新增RFID设备、位置和读取记录模块及首页监控功能
- 新增RfidDevice、RfidLocation、RfidReadRecord三个子系统的Service接口及实现 - 实现设备信息增删改查及分页查询功能,支持导出Excel操作 - 完善设备唯一性校验及删除前关联读取记录校验,防止孤儿数据产生 - 新增设备相关的数据传输对象(BO,VO)及MyBatis Mapper和XML映射文件支持自定义复杂SQL查询 - 新增RfidDashboardController提供首页设备状态统计接口,统计在线、离线、告警设备数量 - 设备信息支持在线状态、告警状态和标识状态的字典数据转换及导出显示 - 提供设备下拉列表接口,方便前端获取设备简要信息 - 采用注解实现接口权限控制、日志记录、请求有效性校验及防重提交 - 全面符合代码规范及分层设计,提升RFID模块整体功能与稳定性main
parent
883d0e54c4
commit
746a361625
@ -0,0 +1,65 @@
|
||||
package org.dromara.rfid.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.rfid.domain.RfidDevice;
|
||||
import org.dromara.rfid.domain.vo.RfidDashboardStatsVo;
|
||||
import org.dromara.rfid.service.IRfidDeviceService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* RFID 首页监控 Controller
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/rfid/dashboard")
|
||||
public class RfidDashboardController {
|
||||
|
||||
private final IRfidDeviceService rfidDeviceService;
|
||||
|
||||
/** 在线状态:在线 */
|
||||
private static final String ONLINE_STATUS_ONLINE = "1";
|
||||
|
||||
/** 在线状态:离线 */
|
||||
private static final String ONLINE_STATUS_OFFLINE = "0";
|
||||
|
||||
/** 告警状态:告警 */
|
||||
private static final String ALARM_STATUS_ALARM = "1";
|
||||
|
||||
/**
|
||||
* 获取首页统计数据
|
||||
*/
|
||||
@GetMapping("/stats")
|
||||
public R<RfidDashboardStatsVo> getStats() {
|
||||
RfidDashboardStatsVo stats = new RfidDashboardStatsVo();
|
||||
|
||||
// 设备总数
|
||||
stats.setTotalDevices(rfidDeviceService.count());
|
||||
|
||||
// 在线数量 (online_status = 1)
|
||||
stats.setOnlineDevices(rfidDeviceService.count(
|
||||
Wrappers.<RfidDevice>lambdaQuery().eq(RfidDevice::getOnlineStatus, ONLINE_STATUS_ONLINE)//在线状态(0-离线;1-在线)
|
||||
));
|
||||
|
||||
// 离线数量 (online_status = 0)
|
||||
stats.setOfflineDevices(rfidDeviceService.count(
|
||||
Wrappers.<RfidDevice>lambdaQuery().eq(RfidDevice::getOnlineStatus, ONLINE_STATUS_OFFLINE)//在线状态(0-离线;1-在线)
|
||||
));
|
||||
|
||||
// 告警数量 (alarm_status = 1)
|
||||
stats.setAlarmDevices(rfidDeviceService.count(
|
||||
Wrappers.<RfidDevice>lambdaQuery().eq(RfidDevice::getAlarmStatus, ALARM_STATUS_ALARM)//告警状态(0-正常;1-告警)
|
||||
));
|
||||
|
||||
return R.ok(stats);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
package org.dromara.rfid.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.rfid.domain.vo.RfidDeviceVo;
|
||||
import org.dromara.rfid.domain.bo.RfidDeviceBo;
|
||||
import org.dromara.rfid.service.IRfidDeviceService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 设备信息
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/rfid/rfidDevice")
|
||||
public class RfidDeviceController extends BaseController {
|
||||
|
||||
private final IRfidDeviceService rfidDeviceService;
|
||||
|
||||
/**
|
||||
* 查询设备信息列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidDevice:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<RfidDeviceVo> list(RfidDeviceBo bo, PageQuery pageQuery) {
|
||||
return rfidDeviceService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出设备信息列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidDevice:export")
|
||||
@Log(title = "设备信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(RfidDeviceBo bo, HttpServletResponse response) {
|
||||
List<RfidDeviceVo> list = rfidDeviceService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "设备信息", RfidDeviceVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备信息详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidDevice:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<RfidDeviceVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(rfidDeviceService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备信息
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidDevice:add")
|
||||
@Log(title = "设备信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody RfidDeviceBo bo) {
|
||||
return toAjax(rfidDeviceService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备信息
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidDevice:edit")
|
||||
@Log(title = "设备信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody RfidDeviceBo bo) {
|
||||
return toAjax(rfidDeviceService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备信息
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidDevice:remove")
|
||||
@Log(title = "设备信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(rfidDeviceService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框查询设备信息列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidDevice:list")
|
||||
@GetMapping("/getRfidDeviceList")
|
||||
public R<List<RfidDeviceVo>> getRfidDeviceList(RfidDeviceBo bo) {
|
||||
List<RfidDeviceVo> list = rfidDeviceService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
package org.dromara.rfid.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.rfid.domain.bo.RfidLocationBo;
|
||||
import org.dromara.rfid.domain.vo.RfidLocationVo;
|
||||
import org.dromara.rfid.service.IRfidLocationService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 位置信息
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/rfid/rfidLocation")
|
||||
public class RfidLocationController extends BaseController {
|
||||
|
||||
private final IRfidLocationService rfidLocationService;
|
||||
|
||||
/**
|
||||
* 查询位置信息列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidLocation:list")
|
||||
@GetMapping("/list")
|
||||
public R<List<RfidLocationVo>> list(RfidLocationBo bo) {
|
||||
List<RfidLocationVo> list = rfidLocationService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出位置信息列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidLocation:export")
|
||||
@Log(title = "位置信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(RfidLocationBo bo, HttpServletResponse response) {
|
||||
List<RfidLocationVo> list = rfidLocationService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "位置信息", RfidLocationVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取位置信息详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidLocation:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<RfidLocationVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(rfidLocationService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增位置信息
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidLocation:add")
|
||||
@Log(title = "位置信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody RfidLocationBo bo) {
|
||||
return toAjax(rfidLocationService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改位置信息
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidLocation:edit")
|
||||
@Log(title = "位置信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody RfidLocationBo bo) {
|
||||
return toAjax(rfidLocationService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除位置信息
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidLocation:remove")
|
||||
@Log(title = "位置信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(rfidLocationService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框查询位置信息列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidLocation:list")
|
||||
@GetMapping("/getRfidLocationList")
|
||||
public R<List<RfidLocationVo>> getRfidLocationList(RfidLocationBo bo) {
|
||||
List<RfidLocationVo> list = rfidLocationService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
package org.dromara.rfid.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.rfid.domain.vo.RfidReadRecordVo;
|
||||
import org.dromara.rfid.domain.bo.RfidReadRecordBo;
|
||||
import org.dromara.rfid.service.IRfidReadRecordService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 读取记录
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/rfid/rfidReadRecord")
|
||||
public class RfidReadRecordController extends BaseController {
|
||||
|
||||
private final IRfidReadRecordService rfidReadRecordService;
|
||||
|
||||
/**
|
||||
* 查询读取记录列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidReadRecord:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<RfidReadRecordVo> list(RfidReadRecordBo bo, PageQuery pageQuery) {
|
||||
return rfidReadRecordService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出读取记录列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidReadRecord:export")
|
||||
@Log(title = "读取记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(RfidReadRecordBo bo, HttpServletResponse response) {
|
||||
List<RfidReadRecordVo> list = rfidReadRecordService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "读取记录", RfidReadRecordVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取读取记录详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidReadRecord:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<RfidReadRecordVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(rfidReadRecordService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增读取记录
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidReadRecord:add")
|
||||
@Log(title = "读取记录", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody RfidReadRecordBo bo) {
|
||||
return toAjax(rfidReadRecordService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改读取记录
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidReadRecord:edit")
|
||||
@Log(title = "读取记录", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody RfidReadRecordBo bo) {
|
||||
return toAjax(rfidReadRecordService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除读取记录
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidReadRecord:remove")
|
||||
@Log(title = "读取记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(rfidReadRecordService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框查询读取记录列表
|
||||
*/
|
||||
@SaCheckPermission("rfid:rfidReadRecord:list")
|
||||
@GetMapping("/getRfidReadRecordList")
|
||||
public R<List<RfidReadRecordVo>> getRfidReadRecordList(RfidReadRecordBo bo) {
|
||||
List<RfidReadRecordVo> list = rfidReadRecordService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package org.dromara.rfid.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 首页统计 VO
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
@Data
|
||||
public class RfidDashboardStatsVo {
|
||||
/**
|
||||
* 设备总数
|
||||
*/
|
||||
private Long totalDevices;
|
||||
|
||||
/**
|
||||
* 在线数量
|
||||
*/
|
||||
private Long onlineDevices;
|
||||
|
||||
/**
|
||||
* 离线数量
|
||||
*/
|
||||
private Long offlineDevices;
|
||||
|
||||
/**
|
||||
* 告警数量
|
||||
*/
|
||||
private Long alarmDevices;
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package org.dromara.rfid.service;
|
||||
|
||||
import org.dromara.rfid.domain.bo.RfidLocationBo;
|
||||
import org.dromara.rfid.domain.vo.RfidLocationVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 位置信息Service接口
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
public interface IRfidLocationService {
|
||||
|
||||
/**
|
||||
* 查询位置信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 位置信息
|
||||
*/
|
||||
RfidLocationVo queryById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 查询符合条件的位置信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 位置信息列表
|
||||
*/
|
||||
List<RfidLocationVo> queryList(RfidLocationBo bo);
|
||||
|
||||
/**
|
||||
* 新增位置信息
|
||||
*
|
||||
* @param bo 位置信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(RfidLocationBo bo);
|
||||
|
||||
/**
|
||||
* 修改位置信息
|
||||
*
|
||||
* @param bo 位置信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(RfidLocationBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除位置信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package org.dromara.rfid.service;
|
||||
|
||||
import org.dromara.rfid.domain.vo.RfidReadRecordVo;
|
||||
import org.dromara.rfid.domain.bo.RfidReadRecordBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 读取记录Service接口
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
public interface IRfidReadRecordService {
|
||||
|
||||
/**
|
||||
* 查询读取记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 读取记录
|
||||
*/
|
||||
RfidReadRecordVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询读取记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 读取记录分页列表
|
||||
*/
|
||||
TableDataInfo<RfidReadRecordVo> queryPageList(RfidReadRecordBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的读取记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 读取记录列表
|
||||
*/
|
||||
List<RfidReadRecordVo> queryList(RfidReadRecordBo bo);
|
||||
|
||||
/**
|
||||
* 新增读取记录
|
||||
*
|
||||
* @param bo 读取记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(RfidReadRecordBo bo);
|
||||
|
||||
/**
|
||||
* 修改读取记录
|
||||
*
|
||||
* @param bo 读取记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(RfidReadRecordBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除读取记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,186 @@
|
||||
package org.dromara.rfid.service.impl;
|
||||
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.rfid.domain.bo.RfidDeviceBo;
|
||||
import org.dromara.rfid.domain.vo.RfidDeviceVo;
|
||||
import org.dromara.rfid.domain.RfidDevice;
|
||||
import org.dromara.rfid.domain.RfidReadRecord;
|
||||
import org.dromara.rfid.mapper.RfidDeviceMapper;
|
||||
import org.dromara.rfid.mapper.RfidReadRecordMapper;
|
||||
import org.dromara.rfid.service.IRfidDeviceService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备信息Service业务层处理
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class RfidDeviceServiceImpl implements IRfidDeviceService {
|
||||
|
||||
private final RfidDeviceMapper baseMapper;
|
||||
|
||||
private final RfidReadRecordMapper rfidReadRecordMapper;
|
||||
|
||||
/**
|
||||
* 查询设备信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 设备信息
|
||||
*/
|
||||
@Override
|
||||
public RfidDeviceVo queryById(Long id){
|
||||
return baseMapper.selectCustomRfidDeviceVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<RfidDeviceVo> queryPageList(RfidDeviceBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<RfidDevice> lqw = buildQueryWrapper(bo);
|
||||
// 使用自定义 Mapper XML + MyBatis-Plus Wrapper 进行分页查询
|
||||
Page<RfidDeviceVo> result = baseMapper.selectCustomRfidDeviceVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<RfidDeviceVo> queryList(RfidDeviceBo bo) {
|
||||
LambdaQueryWrapper<RfidDevice> lqw = buildQueryWrapper(bo);
|
||||
// 使用自定义 Mapper XML + MyBatis-Plus Wrapper 查询列表
|
||||
return baseMapper.selectCustomRfidDeviceVoList(lqw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return baseMapper.countCustomRfidDevice(Wrappers.<RfidDevice>lambdaQuery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count(LambdaQueryWrapper<RfidDevice> queryWrapper) {
|
||||
LambdaQueryWrapper<RfidDevice> wrapper = queryWrapper;
|
||||
if (wrapper == null) {
|
||||
wrapper = Wrappers.lambdaQuery();
|
||||
}
|
||||
return baseMapper.countCustomRfidDevice(wrapper);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<RfidDevice> buildQueryWrapper(RfidDeviceBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<RfidDevice> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(RfidDevice::getId);
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDeviceCode()), RfidDevice::getDeviceCode, bo.getDeviceCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), RfidDevice::getDeviceName, bo.getDeviceName());
|
||||
lqw.eq(bo.getLocationId() != null, RfidDevice::getLocationId, bo.getLocationId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDeviceAddress()), RfidDevice::getDeviceAddress, bo.getDeviceAddress());
|
||||
lqw.eq(bo.getDevicePort() != null, RfidDevice::getDevicePort, bo.getDevicePort());
|
||||
lqw.eq(bo.getReadFrequency() != null, RfidDevice::getReadFrequency, bo.getReadFrequency());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOnlineStatus()), RfidDevice::getOnlineStatus, bo.getOnlineStatus());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAlarmStatus()), RfidDevice::getAlarmStatus, bo.getAlarmStatus());
|
||||
if (StringUtils.isNotBlank(bo.getIsMarked())) {
|
||||
lqw.apply("t.is_marked = {0}", bo.getIsMarked());
|
||||
}
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCreatedBy()), RfidDevice::getCreatedBy, bo.getCreatedBy());
|
||||
lqw.eq(bo.getCreatedAt() != null, RfidDevice::getCreatedAt, bo.getCreatedAt());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUpdatedBy()), RfidDevice::getUpdatedBy, bo.getUpdatedBy());
|
||||
lqw.eq(bo.getUpdatedAt() != null, RfidDevice::getUpdatedAt, bo.getUpdatedAt());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备信息
|
||||
*
|
||||
* @param bo 设备信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(RfidDeviceBo bo) {
|
||||
RfidDevice add = MapstructUtils.convert(bo, RfidDevice.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备信息
|
||||
*
|
||||
* @param bo 设备信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(RfidDeviceBo bo) {
|
||||
RfidDevice update = MapstructUtils.convert(bo, RfidDevice.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(RfidDevice entity){
|
||||
// 业务编号 deviceCode 唯一校验
|
||||
if (StringUtils.isNotBlank(entity.getDeviceCode())) {
|
||||
boolean exists = baseMapper.existsRfidDevice(Wrappers.<RfidDevice>lambdaQuery()
|
||||
.eq(RfidDevice::getDeviceCode, entity.getDeviceCode())
|
||||
.ne(entity.getId() != null, RfidDevice::getId, entity.getId()));
|
||||
if (exists) {
|
||||
throw new ServiceException("设备编号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
// isMarked 默认值处理
|
||||
if (StringUtils.isBlank(entity.getIsMarked())) {
|
||||
entity.setIsMarked("1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid && ids != null && !ids.isEmpty()) {
|
||||
// 校验是否存在关联的读取记录,防止产生孤儿记录
|
||||
boolean existsRecord = rfidReadRecordMapper.existsRfidReadRecord(
|
||||
Wrappers.<RfidReadRecord>lambdaQuery().in(RfidReadRecord::getDeviceId, ids)
|
||||
);
|
||||
if (existsRecord) {
|
||||
throw new ServiceException("存在关联读取记录的设备,无法删除");
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
package org.dromara.rfid.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.rfid.domain.bo.RfidReadRecordBo;
|
||||
import org.dromara.rfid.domain.vo.RfidReadRecordVo;
|
||||
import org.dromara.rfid.domain.RfidReadRecord;
|
||||
import org.dromara.rfid.mapper.RfidReadRecordMapper;
|
||||
import org.dromara.rfid.service.IRfidReadRecordService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 读取记录Service业务层处理
|
||||
*
|
||||
* @author zch
|
||||
* @date 2025-11-25
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class RfidReadRecordServiceImpl implements IRfidReadRecordService {
|
||||
|
||||
private final RfidReadRecordMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询读取记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 读取记录
|
||||
*/
|
||||
@Override
|
||||
public RfidReadRecordVo queryById(Long id){
|
||||
return baseMapper.selectCustomRfidReadRecordVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询读取记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 读取记录分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<RfidReadRecordVo> queryPageList(RfidReadRecordBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<RfidReadRecord> lqw = buildQueryWrapper(bo);
|
||||
// 使用自定义 Mapper XML + MyBatis-Plus Wrapper 进行分页查询
|
||||
Page<RfidReadRecordVo> result = baseMapper.selectCustomRfidReadRecordVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的读取记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 读取记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<RfidReadRecordVo> queryList(RfidReadRecordBo bo) {
|
||||
LambdaQueryWrapper<RfidReadRecord> lqw = buildQueryWrapper(bo);
|
||||
// 使用自定义 Mapper XML + MyBatis-Plus Wrapper 查询列表
|
||||
return baseMapper.selectCustomRfidReadRecordVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<RfidReadRecord> buildQueryWrapper(RfidReadRecordBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<RfidReadRecord> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(RfidReadRecord::getId);
|
||||
lqw.eq(bo.getDeviceId() != null, RfidReadRecord::getDeviceId, bo.getDeviceId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getReadStatus()), RfidReadRecord::getReadStatus, bo.getReadStatus());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBarcode()), RfidReadRecord::getBarcode, bo.getBarcode());
|
||||
lqw.eq(bo.getRecordTime() != null, RfidReadRecord::getRecordTime, bo.getRecordTime());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAlarmFlag()), RfidReadRecord::getAlarmFlag, bo.getAlarmFlag());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAlarmLevel()), RfidReadRecord::getAlarmLevel, bo.getAlarmLevel());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAlarmType()), RfidReadRecord::getAlarmType, bo.getAlarmType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAlarmAction()), RfidReadRecord::getAlarmAction, bo.getAlarmAction());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增读取记录
|
||||
*
|
||||
* @param bo 读取记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(RfidReadRecordBo bo) {
|
||||
RfidReadRecord add = MapstructUtils.convert(bo, RfidReadRecord.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改读取记录
|
||||
*
|
||||
* @param bo 读取记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(RfidReadRecordBo bo) {
|
||||
RfidReadRecord update = MapstructUtils.convert(bo, RfidReadRecord.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(RfidReadRecord entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除读取记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,261 @@
|
||||
<?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="org.dromara.rfid.mapper.RfidDeviceMapper">
|
||||
|
||||
<resultMap type="org.dromara.rfid.domain.vo.RfidDeviceVo" id="RfidDeviceResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectCustomRfidDeviceVoList" resultMap="RfidDeviceResult">
|
||||
select t.id,
|
||||
t.device_code,
|
||||
t.device_name,
|
||||
t.location_id,
|
||||
l.location_alias as locationAlias,
|
||||
t.device_address,
|
||||
t.device_port,
|
||||
t.read_frequency,
|
||||
t.online_status,
|
||||
t.alarm_status,
|
||||
t.is_marked,
|
||||
t.remark,
|
||||
t.created_by,
|
||||
t.created_at,
|
||||
t.updated_by,
|
||||
t.updated_at
|
||||
from rfid_device t
|
||||
left join rfid_location l on t.location_id = l.id
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询详情 -->
|
||||
<select id="selectCustomRfidDeviceVoById" resultMap="RfidDeviceResult">
|
||||
select t.id,
|
||||
t.device_code,
|
||||
t.device_name,
|
||||
t.location_id,
|
||||
l.location_alias as locationAlias,
|
||||
t.device_address,
|
||||
t.device_port,
|
||||
t.read_frequency,
|
||||
t.online_status,
|
||||
t.alarm_status,
|
||||
t.is_marked,
|
||||
t.remark,
|
||||
t.created_by,
|
||||
t.created_at,
|
||||
t.updated_by,
|
||||
t.updated_at
|
||||
from rfid_device t
|
||||
left join rfid_location l on t.location_id = l.id
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 批量查询 - 根据ID列表 -->
|
||||
<select id="selectCustomRfidDeviceVoByIds" resultMap="RfidDeviceResult">
|
||||
select t.id,
|
||||
t.device_code,
|
||||
t.device_name,
|
||||
t.location_id,
|
||||
l.location_alias as locationAlias,
|
||||
t.device_address,
|
||||
t.device_port,
|
||||
t.read_frequency,
|
||||
t.online_status,
|
||||
t.alarm_status,
|
||||
t.is_marked,
|
||||
t.remark,
|
||||
t.created_by,
|
||||
t.created_at,
|
||||
t.updated_by,
|
||||
t.updated_at
|
||||
from rfid_device t
|
||||
left join rfid_location l on t.location_id = l.id
|
||||
where t.id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 统计查询 -->
|
||||
<select id="countCustomRfidDevice" resultType="java.lang.Long">
|
||||
select count(1) from rfid_device t
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 分页查询(带自定义条件) -->
|
||||
<select id="selectCustomRfidDeviceVoPage" resultMap="RfidDeviceResult">
|
||||
select t.id,
|
||||
t.device_code,
|
||||
t.device_name,
|
||||
t.location_id,
|
||||
l.location_alias as locationAlias,
|
||||
t.device_address,
|
||||
t.device_port,
|
||||
t.read_frequency,
|
||||
t.online_status,
|
||||
t.alarm_status,
|
||||
t.is_marked,
|
||||
t.remark,
|
||||
t.created_by,
|
||||
t.created_at,
|
||||
t.updated_by,
|
||||
t.updated_at
|
||||
from rfid_device t
|
||||
left join rfid_location l on t.location_id = l.id
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量插入 -->
|
||||
<insert id="batchInsertRfidDevice">
|
||||
insert into rfid_device(
|
||||
device_code,
|
||||
|
||||
device_name,
|
||||
|
||||
location_id,
|
||||
|
||||
device_address,
|
||||
|
||||
device_port,
|
||||
|
||||
read_frequency,
|
||||
|
||||
online_status,
|
||||
|
||||
alarm_status,
|
||||
|
||||
is_marked,
|
||||
|
||||
remark,
|
||||
|
||||
created_by,
|
||||
|
||||
created_at,
|
||||
|
||||
updated_by,
|
||||
|
||||
updated_at
|
||||
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.deviceCode},
|
||||
|
||||
#{item.deviceName},
|
||||
|
||||
#{item.locationId},
|
||||
|
||||
#{item.deviceAddress},
|
||||
|
||||
#{item.devicePort},
|
||||
|
||||
#{item.readFrequency},
|
||||
|
||||
#{item.onlineStatus},
|
||||
|
||||
#{item.alarmStatus},
|
||||
|
||||
#{item.isMarked},
|
||||
|
||||
#{item.remark},
|
||||
|
||||
#{item.createdBy},
|
||||
|
||||
#{item.createdAt},
|
||||
|
||||
#{item.updatedBy},
|
||||
|
||||
#{item.updatedAt}
|
||||
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量更新 -->
|
||||
<update id="batchUpdateRfidDevice">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
update rfid_device
|
||||
<set>
|
||||
<if test="item.deviceCode != null and item.deviceCode != ''">
|
||||
device_code = #{item.deviceCode},
|
||||
</if>
|
||||
<if test="item.deviceName != null and item.deviceName != ''">
|
||||
device_name = #{item.deviceName},
|
||||
</if>
|
||||
<if test="item.locationId != null">
|
||||
location_id = #{item.locationId},
|
||||
</if>
|
||||
<if test="item.deviceAddress != null and item.deviceAddress != ''">
|
||||
device_address = #{item.deviceAddress},
|
||||
</if>
|
||||
<if test="item.devicePort != null">
|
||||
device_port = #{item.devicePort},
|
||||
</if>
|
||||
<if test="item.readFrequency != null">
|
||||
read_frequency = #{item.readFrequency},
|
||||
</if>
|
||||
<if test="item.onlineStatus != null and item.onlineStatus != ''">
|
||||
online_status = #{item.onlineStatus},
|
||||
</if>
|
||||
<if test="item.alarmStatus != null and item.alarmStatus != ''">
|
||||
alarm_status = #{item.alarmStatus},
|
||||
</if>
|
||||
<if test="item.isMarked != null and item.isMarked != ''">
|
||||
is_marked = #{item.isMarked},
|
||||
</if>
|
||||
<if test="item.remark != null and item.remark != ''">
|
||||
remark = #{item.remark},
|
||||
</if>
|
||||
<if test="item.createdBy != null and item.createdBy != ''">
|
||||
created_by = #{item.createdBy},
|
||||
</if>
|
||||
<if test="item.createdAt != null">
|
||||
created_at = #{item.createdAt},
|
||||
</if>
|
||||
<if test="item.updatedBy != null and item.updatedBy != ''">
|
||||
updated_by = #{item.updatedBy},
|
||||
</if>
|
||||
<if test="item.updatedAt != null">
|
||||
updated_at = #{item.updatedAt}
|
||||
</if>
|
||||
</set>
|
||||
where id = #{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 根据自定义条件删除 -->
|
||||
<delete id="deleteCustomRfidDevice">
|
||||
delete from rfid_device
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<!-- 根据ID列表批量删除 -->
|
||||
<delete id="deleteCustomRfidDeviceByIds">
|
||||
delete from rfid_device
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 检查是否存在 -->
|
||||
<select id="existsRfidDevice" resultType="java.lang.Boolean">
|
||||
select count(1) > 0 from rfid_device t
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,169 @@
|
||||
<?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="org.dromara.rfid.mapper.RfidLocationMapper">
|
||||
|
||||
<resultMap type="org.dromara.rfid.domain.vo.RfidLocationVo" id="RfidLocationResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectCustomRfidLocationVoList" resultMap="RfidLocationResult">
|
||||
select t.id, t.location_code, t.location_alias, t.location_type, t.parent_id, t.is_marked, t.remark, t.created_by, t.created_at, t.updated_by, t.updated_at
|
||||
from rfid_location t
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询详情 -->
|
||||
<select id="selectCustomRfidLocationVoById" resultMap="RfidLocationResult">
|
||||
select t.id, t.location_code, t.location_alias, t.location_type, t.parent_id, t.is_marked, t.remark, t.created_by, t.created_at, t.updated_by, t.updated_at
|
||||
from rfid_location t
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 批量查询 - 根据ID列表 -->
|
||||
<select id="selectCustomRfidLocationVoByIds" resultMap="RfidLocationResult">
|
||||
select t.id, t.location_code, t.location_alias, t.location_type, t.parent_id, t.is_marked, t.remark, t.created_by, t.created_at, t.updated_by, t.updated_at
|
||||
from rfid_location t
|
||||
where t.id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 统计查询 -->
|
||||
<select id="countCustomRfidLocation" resultType="java.lang.Long">
|
||||
select count(1) from rfid_location t
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 分页查询(带自定义条件) -->
|
||||
<select id="selectCustomRfidLocationVoPage" resultMap="RfidLocationResult">
|
||||
select t.id, t.location_code, t.location_alias, t.location_type, t.parent_id, t.is_marked, t.remark, t.created_by, t.created_at, t.updated_by, t.updated_at
|
||||
from rfid_location t
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量插入 -->
|
||||
<insert id="batchInsertRfidLocation">
|
||||
insert into rfid_location(
|
||||
location_code,
|
||||
|
||||
location_alias,
|
||||
|
||||
location_type,
|
||||
|
||||
parent_id,
|
||||
|
||||
is_marked,
|
||||
|
||||
remark,
|
||||
|
||||
created_by,
|
||||
|
||||
created_at,
|
||||
|
||||
updated_by,
|
||||
|
||||
updated_at
|
||||
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.locationCode},
|
||||
|
||||
#{item.locationAlias},
|
||||
|
||||
#{item.locationType},
|
||||
|
||||
#{item.parentId},
|
||||
|
||||
#{item.isMarked},
|
||||
|
||||
#{item.remark},
|
||||
|
||||
#{item.createdBy},
|
||||
|
||||
#{item.createdAt},
|
||||
|
||||
#{item.updatedBy},
|
||||
|
||||
#{item.updatedAt}
|
||||
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量更新 -->
|
||||
<update id="batchUpdateRfidLocation">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
update rfid_location
|
||||
<set>
|
||||
<if test="item.locationCode != null and item.locationCode != ''">
|
||||
location_code = #{item.locationCode},
|
||||
</if>
|
||||
<if test="item.locationAlias != null and item.locationAlias != ''">
|
||||
location_alias = #{item.locationAlias},
|
||||
</if>
|
||||
<if test="item.locationType != null and item.locationType != ''">
|
||||
location_type = #{item.locationType},
|
||||
</if>
|
||||
<if test="item.parentId != null">
|
||||
parent_id = #{item.parentId},
|
||||
</if>
|
||||
<if test="item.isMarked != null and item.isMarked != ''">
|
||||
is_marked = #{item.isMarked},
|
||||
</if>
|
||||
<if test="item.remark != null and item.remark != ''">
|
||||
remark = #{item.remark},
|
||||
</if>
|
||||
<if test="item.createdBy != null and item.createdBy != ''">
|
||||
created_by = #{item.createdBy},
|
||||
</if>
|
||||
<if test="item.createdAt != null">
|
||||
created_at = #{item.createdAt},
|
||||
</if>
|
||||
<if test="item.updatedBy != null and item.updatedBy != ''">
|
||||
updated_by = #{item.updatedBy},
|
||||
</if>
|
||||
<if test="item.updatedAt != null">
|
||||
updated_at = #{item.updatedAt}
|
||||
</if>
|
||||
</set>
|
||||
where id = #{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 根据自定义条件删除 -->
|
||||
<delete id="deleteCustomRfidLocation">
|
||||
delete from rfid_location
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<!-- 根据ID列表批量删除 -->
|
||||
<delete id="deleteCustomRfidLocationByIds">
|
||||
delete from rfid_location
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 检查是否存在 -->
|
||||
<select id="existsRfidLocation" resultType="java.lang.Boolean">
|
||||
select count(1) > 0 from rfid_location t
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,199 @@
|
||||
<?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="org.dromara.rfid.mapper.RfidReadRecordMapper">
|
||||
|
||||
<resultMap type="org.dromara.rfid.domain.vo.RfidReadRecordVo" id="RfidReadRecordResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectCustomRfidReadRecordVoList" resultMap="RfidReadRecordResult">
|
||||
select t.id,
|
||||
t.device_id,
|
||||
d.device_code as deviceCode,
|
||||
d.device_name as deviceName,
|
||||
t.read_status,
|
||||
t.barcode,
|
||||
t.record_time,
|
||||
t.alarm_flag,
|
||||
t.alarm_level,
|
||||
t.alarm_type,
|
||||
t.alarm_action
|
||||
from rfid_read_record t
|
||||
left join rfid_device d on t.device_id = d.id
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询详情 -->
|
||||
<select id="selectCustomRfidReadRecordVoById" resultMap="RfidReadRecordResult">
|
||||
select t.id,
|
||||
t.device_id,
|
||||
d.device_code as deviceCode,
|
||||
d.device_name as deviceName,
|
||||
t.read_status,
|
||||
t.barcode,
|
||||
t.record_time,
|
||||
t.alarm_flag,
|
||||
t.alarm_level,
|
||||
t.alarm_type,
|
||||
t.alarm_action
|
||||
from rfid_read_record t
|
||||
left join rfid_device d on t.device_id = d.id
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 批量查询 - 根据ID列表 -->
|
||||
<select id="selectCustomRfidReadRecordVoByIds" resultMap="RfidReadRecordResult">
|
||||
select t.id,
|
||||
t.device_id,
|
||||
d.device_code as deviceCode,
|
||||
d.device_name as deviceName,
|
||||
t.read_status,
|
||||
t.barcode,
|
||||
t.record_time,
|
||||
t.alarm_flag,
|
||||
t.alarm_level,
|
||||
t.alarm_type,
|
||||
t.alarm_action
|
||||
from rfid_read_record t
|
||||
left join rfid_device d on t.device_id = d.id
|
||||
where t.id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 统计查询 -->
|
||||
<select id="countCustomRfidReadRecord" resultType="java.lang.Long">
|
||||
select count(1) from rfid_read_record t
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 分页查询(带自定义条件) -->
|
||||
<select id="selectCustomRfidReadRecordVoPage" resultMap="RfidReadRecordResult">
|
||||
select t.id,
|
||||
t.device_id,
|
||||
d.device_code as deviceCode,
|
||||
d.device_name as deviceName,
|
||||
t.read_status,
|
||||
t.barcode,
|
||||
t.record_time,
|
||||
t.alarm_flag,
|
||||
t.alarm_level,
|
||||
t.alarm_type,
|
||||
t.alarm_action
|
||||
from rfid_read_record t
|
||||
left join rfid_device d on t.device_id = d.id
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量插入 -->
|
||||
<insert id="batchInsertRfidReadRecord">
|
||||
insert into rfid_read_record(
|
||||
device_id,
|
||||
|
||||
read_status,
|
||||
|
||||
barcode,
|
||||
|
||||
record_time,
|
||||
|
||||
alarm_flag,
|
||||
|
||||
alarm_level,
|
||||
|
||||
alarm_type,
|
||||
|
||||
alarm_action
|
||||
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.deviceId},
|
||||
|
||||
#{item.readStatus},
|
||||
|
||||
#{item.barcode},
|
||||
|
||||
#{item.recordTime},
|
||||
|
||||
#{item.alarmFlag},
|
||||
|
||||
#{item.alarmLevel},
|
||||
|
||||
#{item.alarmType},
|
||||
|
||||
#{item.alarmAction}
|
||||
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量更新 -->
|
||||
<update id="batchUpdateRfidReadRecord">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
update rfid_read_record
|
||||
<set>
|
||||
<if test="item.deviceId != null">
|
||||
device_id = #{item.deviceId},
|
||||
</if>
|
||||
<if test="item.readStatus != null and item.readStatus != ''">
|
||||
read_status = #{item.readStatus},
|
||||
</if>
|
||||
<if test="item.barcode != null and item.barcode != ''">
|
||||
barcode = #{item.barcode},
|
||||
</if>
|
||||
<if test="item.recordTime != null">
|
||||
record_time = #{item.recordTime},
|
||||
</if>
|
||||
<if test="item.alarmFlag != null and item.alarmFlag != ''">
|
||||
alarm_flag = #{item.alarmFlag},
|
||||
</if>
|
||||
<if test="item.alarmLevel != null and item.alarmLevel != ''">
|
||||
alarm_level = #{item.alarmLevel},
|
||||
</if>
|
||||
<if test="item.alarmType != null and item.alarmType != ''">
|
||||
alarm_type = #{item.alarmType},
|
||||
</if>
|
||||
<if test="item.alarmAction != null and item.alarmAction != ''">
|
||||
alarm_action = #{item.alarmAction}
|
||||
</if>
|
||||
</set>
|
||||
where id = #{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 根据自定义条件删除 -->
|
||||
<delete id="deleteCustomRfidReadRecord">
|
||||
delete from rfid_read_record
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<!-- 根据ID列表批量删除 -->
|
||||
<delete id="deleteCustomRfidReadRecordByIds">
|
||||
delete from rfid_read_record
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 检查是否存在 -->
|
||||
<select id="existsRfidReadRecord" resultType="java.lang.Boolean">
|
||||
select count(1) > 0 from rfid_read_record t
|
||||
<if test="ew != null">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue