From 984081ac98057ed4cc30e4ceae17999c70c21925 Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Tue, 29 Jul 2025 11:10:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DeviceLogController.java | 105 ++++++++++++++ .../equipment/domain/bo/DeviceLogBo.java | 49 +++++++ .../equipment/domain/vo/DeviceLogVo.java | 62 ++++++++ .../equipment/mapper/DeviceLogMapper.java | 15 ++ .../equipment/service/IDeviceLogService.java | 68 +++++++++ .../service/impl/DeviceLogServiceImpl.java | 135 ++++++++++++++++++ .../mapper/equipment/DeviceLogMapper.xml | 7 + 7 files changed, 441 insertions(+) create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceLogController.java create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/bo/DeviceLogBo.java create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/DeviceLogVo.java create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceLogMapper.java create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/IDeviceLogService.java create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceLogServiceImpl.java create mode 100644 fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceLogMapper.xml diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceLogController.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceLogController.java new file mode 100644 index 0000000..caa8ff7 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceLogController.java @@ -0,0 +1,105 @@ +package com.fuyuanshen.equipment.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 com.fuyuanshen.common.idempotent.annotation.RepeatSubmit; +import com.fuyuanshen.common.log.annotation.Log; +import com.fuyuanshen.common.web.core.BaseController; +import com.fuyuanshen.common.mybatis.core.page.PageQuery; +import com.fuyuanshen.common.core.domain.R; +import com.fuyuanshen.common.core.validate.AddGroup; +import com.fuyuanshen.common.core.validate.EditGroup; +import com.fuyuanshen.common.log.enums.BusinessType; +import com.fuyuanshen.common.excel.utils.ExcelUtil; +import com.fuyuanshen.equipment.domain.vo.DeviceLogVo; +import com.fuyuanshen.equipment.domain.bo.DeviceLogBo; +import com.fuyuanshen.equipment.service.IDeviceLogService; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; + +/** + * 设备日志 + * + * @author Lion Li + * @date 2025-07-29 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/equipment/log") +public class DeviceLogController extends BaseController { + + private final IDeviceLogService deviceLogService; + + /** + * 查询设备日志列表 + */ + @SaCheckPermission("equipment:log:list") + @GetMapping("/list") + public TableDataInfo list(DeviceLogBo bo, PageQuery pageQuery) { + return deviceLogService.queryPageList(bo, pageQuery); + } + + /** + * 导出设备日志列表 + */ + @SaCheckPermission("equipment:log:export") + @Log(title = "设备日志", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(DeviceLogBo bo, HttpServletResponse response) { + List list = deviceLogService.queryList(bo); + ExcelUtil.exportExcel(list, "设备日志", DeviceLogVo.class, response); + } + + /** + * 获取设备日志详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("equipment:log:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(deviceLogService.queryById(id)); + } + + /** + * 新增设备日志 + */ + @SaCheckPermission("equipment:log:add") + @Log(title = "设备日志", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody DeviceLogBo bo) { + return toAjax(deviceLogService.insertByBo(bo)); + } + + /** + * 修改设备日志 + */ + @SaCheckPermission("equipment:log:edit") + @Log(title = "设备日志", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody DeviceLogBo bo) { + return toAjax(deviceLogService.updateByBo(bo)); + } + + /** + * 删除设备日志 + * + * @param ids 主键串 + */ + @SaCheckPermission("equipment:log:remove") + @Log(title = "设备日志", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(deviceLogService.deleteWithValidByIds(List.of(ids), true)); + } +} diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/bo/DeviceLogBo.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/bo/DeviceLogBo.java new file mode 100644 index 0000000..71900d5 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/bo/DeviceLogBo.java @@ -0,0 +1,49 @@ +package com.fuyuanshen.equipment.domain.bo; + +import com.fuyuanshen.common.core.validate.EditGroup; +import com.fuyuanshen.equipment.domain.DeviceLog; +import com.fuyuanshen.common.mybatis.core.domain.BaseEntity; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; +import jakarta.validation.constraints.*; + +/** + * 设备日志业务对象 device_log + * + * @author Lion Li + * @date 2025-07-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = DeviceLog.class, reverseConvertGenerate = false) +public class DeviceLogBo extends BaseEntity { + + /** + * ID + */ + @NotNull(message = "ID不能为空", groups = { EditGroup.class }) + private Long id; + + /** + * 设备行为 + */ + private String deviceAction; + + /** + * 设备名称 + */ + private String deviceName; + + /** + * 数据来源 + */ + private String dataSource; + + /** + * 内容 + */ + private String content; + + +} diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/DeviceLogVo.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/DeviceLogVo.java new file mode 100644 index 0000000..cbfbc6a --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/DeviceLogVo.java @@ -0,0 +1,62 @@ +package com.fuyuanshen.equipment.domain.vo; + +import com.fuyuanshen.equipment.domain.DeviceLog; +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; +import cn.idev.excel.annotation.ExcelProperty; +import com.fuyuanshen.common.excel.annotation.ExcelDictFormat; +import com.fuyuanshen.common.excel.convert.ExcelDictConvert; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + + +/** + * 设备日志视图对象 device_log + * + * @author Lion Li + * @date 2025-07-29 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = DeviceLog.class) +public class DeviceLogVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @ExcelProperty(value = "ID") + private Long id; + + /** + * 设备行为 + */ + @ExcelProperty(value = "设备行为") + private String deviceAction; + + /** + * 设备名称 + */ + @ExcelProperty(value = "设备名称") + private String deviceName; + + /** + * 数据来源 + */ + @ExcelProperty(value = "数据来源") + private String dataSource; + + /** + * 内容 + */ + @ExcelProperty(value = "内容") + private String content; + + +} diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceLogMapper.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceLogMapper.java new file mode 100644 index 0000000..adff5de --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceLogMapper.java @@ -0,0 +1,15 @@ +package com.fuyuanshen.equipment.mapper; + +import com.fuyuanshen.equipment.domain.DeviceLog; +import com.fuyuanshen.equipment.domain.vo.DeviceLogVo; +import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus; + +/** + * 设备日志Mapper接口 + * + * @author Lion Li + * @date 2025-07-29 + */ +public interface DeviceLogMapper extends BaseMapperPlus { + +} diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/IDeviceLogService.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/IDeviceLogService.java new file mode 100644 index 0000000..5605d20 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/IDeviceLogService.java @@ -0,0 +1,68 @@ +package com.fuyuanshen.equipment.service; + +import com.fuyuanshen.equipment.domain.vo.DeviceLogVo; +import com.fuyuanshen.equipment.domain.bo.DeviceLogBo; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +import com.fuyuanshen.common.mybatis.core.page.PageQuery; + +import java.util.Collection; +import java.util.List; + +/** + * 设备日志Service接口 + * + * @author Lion Li + * @date 2025-07-29 + */ +public interface IDeviceLogService { + + /** + * 查询设备日志 + * + * @param id 主键 + * @return 设备日志 + */ + DeviceLogVo queryById(Long id); + + /** + * 分页查询设备日志列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 设备日志分页列表 + */ + TableDataInfo queryPageList(DeviceLogBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的设备日志列表 + * + * @param bo 查询条件 + * @return 设备日志列表 + */ + List queryList(DeviceLogBo bo); + + /** + * 新增设备日志 + * + * @param bo 设备日志 + * @return 是否新增成功 + */ + Boolean insertByBo(DeviceLogBo bo); + + /** + * 修改设备日志 + * + * @param bo 设备日志 + * @return 是否修改成功 + */ + Boolean updateByBo(DeviceLogBo bo); + + /** + * 校验并批量删除设备日志信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceLogServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceLogServiceImpl.java new file mode 100644 index 0000000..60d46df --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceLogServiceImpl.java @@ -0,0 +1,135 @@ +package com.fuyuanshen.equipment.service.impl; + +import com.fuyuanshen.common.core.utils.MapstructUtils; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +import com.fuyuanshen.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.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import com.fuyuanshen.equipment.domain.bo.DeviceLogBo; +import com.fuyuanshen.equipment.domain.vo.DeviceLogVo; +import com.fuyuanshen.equipment.domain.DeviceLog; +import com.fuyuanshen.equipment.mapper.DeviceLogMapper; +import com.fuyuanshen.equipment.service.IDeviceLogService; + +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 设备日志Service业务层处理 + * + * @author Lion Li + * @date 2025-07-29 + */ +@Slf4j +@RequiredArgsConstructor +@Service +public class DeviceLogServiceImpl implements IDeviceLogService { + + private final DeviceLogMapper baseMapper; + + /** + * 查询设备日志 + * + * @param id 主键 + * @return 设备日志 + */ + @Override + public DeviceLogVo queryById(Long id){ + return baseMapper.selectVoById(id); + } + + /** + * 分页查询设备日志列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 设备日志分页列表 + */ + @Override + public TableDataInfo queryPageList(DeviceLogBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的设备日志列表 + * + * @param bo 查询条件 + * @return 设备日志列表 + */ + @Override + public List queryList(DeviceLogBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(DeviceLogBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByAsc(DeviceLog::getId); + lqw.eq(StringUtils.isNotBlank(bo.getDeviceAction()), DeviceLog::getDeviceAction, bo.getDeviceAction()); + lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), DeviceLog::getDeviceName, bo.getDeviceName()); + lqw.eq(StringUtils.isNotBlank(bo.getDataSource()), DeviceLog::getDataSource, bo.getDataSource()); + lqw.eq(StringUtils.isNotBlank(bo.getContent()), DeviceLog::getContent, bo.getContent()); + return lqw; + } + + /** + * 新增设备日志 + * + * @param bo 设备日志 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(DeviceLogBo bo) { + DeviceLog add = MapstructUtils.convert(bo, DeviceLog.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + /** + * 修改设备日志 + * + * @param bo 设备日志 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(DeviceLogBo bo) { + DeviceLog update = MapstructUtils.convert(bo, DeviceLog.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(DeviceLog entity){ + //TODO 做一些数据校验,如唯一约束 + } + + /** + * 校验并批量删除设备日志信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } +} diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceLogMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceLogMapper.xml new file mode 100644 index 0000000..d4c99d6 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceLogMapper.xml @@ -0,0 +1,7 @@ + + + + +