From 85c7ded162879f9adb40b3ac3ebd4409ce135579 Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Wed, 3 Dec 2025 17:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E6=82=A3=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HazardRuleController.java | 105 ++++++++++++++ .../org/dromara/safety/domain/HazardRule.java | 77 ++++++++++ .../safety/domain/HazardRuleNotifyObject.java | 37 +++++ .../safety/domain/bo/HazardRuleBo.java | 83 +++++++++++ .../domain/bo/HazardRuleNotifyObjectBo.java | 42 ++++++ .../domain/vo/HazardRuleNotifyObjectVo.java | 46 ++++++ .../safety/domain/vo/HazardRuleVo.java | 93 ++++++++++++ .../safety/mapper/HazardRuleMapper.java | 15 ++ .../mapper/HazardRuleNotifyObjectMapper.java | 15 ++ .../IHazardRuleNotifyObjectService.java | 70 +++++++++ .../safety/service/IHazardRuleService.java | 70 +++++++++ .../HazardRuleNotifyObjectServiceImpl.java | 131 +++++++++++++++++ .../service/impl/HazardRuleServiceImpl.java | 137 ++++++++++++++++++ .../mapper/safety/HazardRuleMapper.xml | 7 + .../safety/HazardRuleNotifyObjectMapper.xml | 7 + xinnengyuan/script/sql/xinnengyuan.sql | 50 +++++++ 16 files changed, 985 insertions(+) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/controller/HazardRuleController.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HazardRule.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HazardRuleNotifyObject.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/bo/HazardRuleBo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/bo/HazardRuleNotifyObjectBo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/HazardRuleNotifyObjectVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/HazardRuleVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HazardRuleMapper.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HazardRuleNotifyObjectMapper.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHazardRuleNotifyObjectService.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHazardRuleService.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HazardRuleNotifyObjectServiceImpl.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HazardRuleServiceImpl.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HazardRuleMapper.xml create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HazardRuleNotifyObjectMapper.xml diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/controller/HazardRuleController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/controller/HazardRuleController.java new file mode 100644 index 00000000..906b41a1 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/controller/HazardRuleController.java @@ -0,0 +1,105 @@ +package org.dromara.safety.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.safety.domain.vo.HazardRuleVo; +import org.dromara.safety.domain.bo.HazardRuleBo; +import org.dromara.safety.service.IHazardRuleService; +import org.dromara.common.mybatis.core.page.TableDataInfo; + +/** + * 隐患分级通知规则 + * + * @author lilemy + * @date 2025-12-03 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/safety/rule") +public class HazardRuleController extends BaseController { + + private final IHazardRuleService hazardRuleService; + + /** + * 查询隐患分级通知规则列表 + */ + @SaCheckPermission("safety:rule:list") + @GetMapping("/list") + public TableDataInfo list(HazardRuleBo bo, PageQuery pageQuery) { + return hazardRuleService.queryPageList(bo, pageQuery); + } + + /** + * 导出隐患分级通知规则列表 + */ + @SaCheckPermission("safety:rule:export") + @Log(title = "隐患分级通知规则", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HazardRuleBo bo, HttpServletResponse response) { + List list = hazardRuleService.queryList(bo); + ExcelUtil.exportExcel(list, "隐患分级通知规则", HazardRuleVo.class, response); + } + + /** + * 获取隐患分级通知规则详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("safety:rule:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(hazardRuleService.queryById(id)); + } + + /** + * 新增隐患分级通知规则 + */ + @SaCheckPermission("safety:rule:add") + @Log(title = "隐患分级通知规则", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody HazardRuleBo bo) { + return toAjax(hazardRuleService.insertByBo(bo)); + } + + /** + * 修改隐患分级通知规则 + */ + @SaCheckPermission("safety:rule:edit") + @Log(title = "隐患分级通知规则", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody HazardRuleBo bo) { + return toAjax(hazardRuleService.updateByBo(bo)); + } + + /** + * 删除隐患分级通知规则 + * + * @param ids 主键串 + */ + @SaCheckPermission("safety:rule:remove") + @Log(title = "隐患分级通知规则", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(hazardRuleService.deleteWithValidByIds(List.of(ids), true)); + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HazardRule.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HazardRule.java new file mode 100644 index 00000000..ca376f35 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HazardRule.java @@ -0,0 +1,77 @@ +package org.dromara.safety.domain; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.dromara.common.mybatis.core.domain.BaseEntity; + +import java.io.Serial; + +/** + * 隐患分级通知规则对象 hazard_rule + * + * @author lilemy + * @date 2025-12-03 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hazard_rule") +public class HazardRule extends BaseEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id") + private Long id; + + /** + * 项目id + */ + private Long projectId; + + /** + * 隐患级别 + */ + private String hazardLevel; + + /** + * 隐患权重 + */ + private Integer hazardWeight; + + /** + * 响应时限数值 + */ + private Integer responseTime; + + /** + * 响应时效单位 + */ + private String responseUnit; + + /** + * 通知方式 + */ + private String notifyMethod; + + /** + * 超时处理方式 + */ + private String timeoutAction; + + /** + * 额外设置 + */ + private String extraSetting; + + /** + * 备注 + */ + private String remark; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HazardRuleNotifyObject.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HazardRuleNotifyObject.java new file mode 100644 index 00000000..7b8120a8 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HazardRuleNotifyObject.java @@ -0,0 +1,37 @@ +package org.dromara.safety.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 隐患规则通知对象对象 hazard_rule_notify_object + * + * @author lilemy + * @date 2025-12-03 + */ +@Data +@TableName("hazard_rule_notify_object") +public class HazardRuleNotifyObject implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 规则ID + */ + private Long ruleId; + + /** + * 通知ID + */ + private Long notifyId; + + /** + * 通知类型 + */ + private String notifyType; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/bo/HazardRuleBo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/bo/HazardRuleBo.java new file mode 100644 index 00000000..fd13e90c --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/bo/HazardRuleBo.java @@ -0,0 +1,83 @@ +package org.dromara.safety.domain.bo; + +import io.github.linpeilie.annotations.AutoMapper; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.safety.domain.HazardRule; + +/** + * 隐患分级通知规则业务对象 hazard_rule + * + * @author lilemy + * @date 2025-12-03 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = HazardRule.class, reverseConvertGenerate = false) +public class HazardRuleBo extends BaseEntity { + + /** + * 主键 + */ + @NotNull(message = "主键不能为空", groups = {EditGroup.class}) + private Long id; + + /** + * 项目id + */ + @NotNull(message = "项目id不能为空", groups = {AddGroup.class, EditGroup.class}) + private Long projectId; + + /** + * 隐患级别 + */ + @NotBlank(message = "隐患级别不能为空", groups = {AddGroup.class, EditGroup.class}) + private String hazardLevel; + + /** + * 隐患权重 + */ + @NotNull(message = "隐患权重不能为空", groups = {AddGroup.class, EditGroup.class}) + private Integer hazardWeight; + + /** + * 响应时限数值 + */ + @NotNull(message = "响应时限数值不能为空", groups = {AddGroup.class, EditGroup.class}) + private Integer responseTime; + + /** + * 响应时效单位 + */ + @NotBlank(message = "响应时效单位不能为空", groups = {AddGroup.class, EditGroup.class}) + private String responseUnit; + + /** + * 通知方式 + */ + @NotBlank(message = "通知方式不能为空", groups = {AddGroup.class, EditGroup.class}) + private String notifyMethod; + + /** + * 超时处理方式 + */ + @NotBlank(message = "超时处理方式不能为空", groups = {AddGroup.class, EditGroup.class}) + private String timeoutAction; + + /** + * 额外设置 + */ + @NotBlank(message = "额外设置不能为空", groups = {AddGroup.class, EditGroup.class}) + private String extraSetting; + + /** + * 备注 + */ + private String remark; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/bo/HazardRuleNotifyObjectBo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/bo/HazardRuleNotifyObjectBo.java new file mode 100644 index 00000000..1815b4c9 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/bo/HazardRuleNotifyObjectBo.java @@ -0,0 +1,42 @@ +package org.dromara.safety.domain.bo; + +import org.dromara.safety.domain.HazardRuleNotifyObject; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; +import jakarta.validation.constraints.*; + +/** + * 隐患规则通知对象业务对象 hazard_rule_notify_object + * + * @author lilemy + * @date 2025-12-03 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = HazardRuleNotifyObject.class, reverseConvertGenerate = false) +public class HazardRuleNotifyObjectBo extends BaseEntity { + + /** + * 规则ID + */ + @NotNull(message = "规则ID不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long ruleId; + + /** + * 通知ID + */ + @NotNull(message = "通知ID不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long notifyId; + + /** + * 通知类型 + */ + @NotBlank(message = "通知类型不能为空", groups = { AddGroup.class, EditGroup.class }) + private String notifyType; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/HazardRuleNotifyObjectVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/HazardRuleNotifyObjectVo.java new file mode 100644 index 00000000..285767d5 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/HazardRuleNotifyObjectVo.java @@ -0,0 +1,46 @@ +package org.dromara.safety.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import org.dromara.safety.domain.HazardRuleNotifyObject; + +import java.io.Serial; +import java.io.Serializable; + + +/** + * 隐患规则通知对象视图对象 hazard_rule_notify_object + * + * @author lilemy + * @date 2025-12-03 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = HazardRuleNotifyObject.class) +public class HazardRuleNotifyObjectVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 规则ID + */ + @ExcelProperty(value = "规则ID") + private Long ruleId; + + /** + * 通知ID + */ + @ExcelProperty(value = "通知ID") + private Long notifyId; + + /** + * 通知类型 + */ + @ExcelProperty(value = "通知类型") + private String notifyType; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/HazardRuleVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/HazardRuleVo.java new file mode 100644 index 00000000..54c23bc0 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/HazardRuleVo.java @@ -0,0 +1,93 @@ +package org.dromara.safety.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; +import org.dromara.safety.domain.HazardRule; + +import java.io.Serial; +import java.io.Serializable; + + +/** + * 隐患分级通知规则视图对象 hazard_rule + * + * @author lilemy + * @date 2025-12-03 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = HazardRule.class) +public class HazardRuleVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @ExcelProperty(value = "主键") + private Long id; + + /** + * 项目id + */ + @ExcelProperty(value = "项目id") + private Long projectId; + + /** + * 隐患级别 + */ + @ExcelProperty(value = "隐患级别") + private String hazardLevel; + + /** + * 隐患权重 + */ + @ExcelProperty(value = "隐患权重") + private Integer hazardWeight; + + /** + * 响应时限数值 + */ + @ExcelProperty(value = "响应时限数值") + private Integer responseTime; + + /** + * 响应时效单位 + */ + @ExcelProperty(value = "响应时效单位", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "time_unit") + private String responseUnit; + + /** + * 通知方式 + */ + @ExcelProperty(value = "通知方式", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "notify_method") + private String notifyMethod; + + /** + * 超时处理方式 + */ + @ExcelProperty(value = "超时处理方式", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "hazard_timeout_action") + private String timeoutAction; + + /** + * 额外设置 + */ + @ExcelProperty(value = "额外设置") + private String extraSetting; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + private String remark; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HazardRuleMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HazardRuleMapper.java new file mode 100644 index 00000000..a87e87c0 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HazardRuleMapper.java @@ -0,0 +1,15 @@ +package org.dromara.safety.mapper; + +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.dromara.safety.domain.HazardRule; +import org.dromara.safety.domain.vo.HazardRuleVo; + +/** + * 隐患分级通知规则Mapper接口 + * + * @author lilemy + * @date 2025-12-03 + */ +public interface HazardRuleMapper extends BaseMapperPlus { + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HazardRuleNotifyObjectMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HazardRuleNotifyObjectMapper.java new file mode 100644 index 00000000..8442da31 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HazardRuleNotifyObjectMapper.java @@ -0,0 +1,15 @@ +package org.dromara.safety.mapper; + +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.dromara.safety.domain.HazardRuleNotifyObject; +import org.dromara.safety.domain.vo.HazardRuleNotifyObjectVo; + +/** + * 隐患规则通知对象Mapper接口 + * + * @author lilemy + * @date 2025-12-03 + */ +public interface HazardRuleNotifyObjectMapper extends BaseMapperPlus { + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHazardRuleNotifyObjectService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHazardRuleNotifyObjectService.java new file mode 100644 index 00000000..e54a0b74 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHazardRuleNotifyObjectService.java @@ -0,0 +1,70 @@ +package org.dromara.safety.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.safety.domain.HazardRuleNotifyObject; +import org.dromara.safety.domain.bo.HazardRuleNotifyObjectBo; +import org.dromara.safety.domain.vo.HazardRuleNotifyObjectVo; + +import java.util.Collection; +import java.util.List; + +/** + * 隐患规则通知对象Service接口 + * + * @author lilemy + * @date 2025-12-03 + */ +public interface IHazardRuleNotifyObjectService extends IService { + + /** + * 查询隐患规则通知对象 + * + * @param ruleId 主键 + * @return 隐患规则通知对象 + */ + HazardRuleNotifyObjectVo queryById(Long ruleId); + + /** + * 分页查询隐患规则通知对象列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 隐患规则通知对象分页列表 + */ + TableDataInfo queryPageList(HazardRuleNotifyObjectBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的隐患规则通知对象列表 + * + * @param bo 查询条件 + * @return 隐患规则通知对象列表 + */ + List queryList(HazardRuleNotifyObjectBo bo); + + /** + * 新增隐患规则通知对象 + * + * @param bo 隐患规则通知对象 + * @return 是否新增成功 + */ + Boolean insertByBo(HazardRuleNotifyObjectBo bo); + + /** + * 修改隐患规则通知对象 + * + * @param bo 隐患规则通知对象 + * @return 是否修改成功 + */ + Boolean updateByBo(HazardRuleNotifyObjectBo bo); + + /** + * 校验并批量删除隐患规则通知对象信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHazardRuleService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHazardRuleService.java new file mode 100644 index 00000000..6ead1996 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHazardRuleService.java @@ -0,0 +1,70 @@ +package org.dromara.safety.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.safety.domain.HazardRule; +import org.dromara.safety.domain.bo.HazardRuleBo; +import org.dromara.safety.domain.vo.HazardRuleVo; + +import java.util.Collection; +import java.util.List; + +/** + * 隐患分级通知规则Service接口 + * + * @author lilemy + * @date 2025-12-03 + */ +public interface IHazardRuleService extends IService { + + /** + * 查询隐患分级通知规则 + * + * @param id 主键 + * @return 隐患分级通知规则 + */ + HazardRuleVo queryById(Long id); + + /** + * 分页查询隐患分级通知规则列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 隐患分级通知规则分页列表 + */ + TableDataInfo queryPageList(HazardRuleBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的隐患分级通知规则列表 + * + * @param bo 查询条件 + * @return 隐患分级通知规则列表 + */ + List queryList(HazardRuleBo bo); + + /** + * 新增隐患分级通知规则 + * + * @param bo 隐患分级通知规则 + * @return 是否新增成功 + */ + Boolean insertByBo(HazardRuleBo bo); + + /** + * 修改隐患分级通知规则 + * + * @param bo 隐患分级通知规则 + * @return 是否修改成功 + */ + Boolean updateByBo(HazardRuleBo bo); + + /** + * 校验并批量删除隐患分级通知规则信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HazardRuleNotifyObjectServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HazardRuleNotifyObjectServiceImpl.java new file mode 100644 index 00000000..3ce043b7 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HazardRuleNotifyObjectServiceImpl.java @@ -0,0 +1,131 @@ +package org.dromara.safety.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.safety.domain.HazardRuleNotifyObject; +import org.dromara.safety.domain.bo.HazardRuleNotifyObjectBo; +import org.dromara.safety.domain.vo.HazardRuleNotifyObjectVo; +import org.dromara.safety.mapper.HazardRuleNotifyObjectMapper; +import org.dromara.safety.service.IHazardRuleNotifyObjectService; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 隐患规则通知对象Service业务层处理 + * + * @author lilemy + * @date 2025-12-03 + */ +@RequiredArgsConstructor +@Service +public class HazardRuleNotifyObjectServiceImpl extends ServiceImpl + implements IHazardRuleNotifyObjectService { + + /** + * 查询隐患规则通知对象 + * + * @param ruleId 主键 + * @return 隐患规则通知对象 + */ + @Override + public HazardRuleNotifyObjectVo queryById(Long ruleId) { + return baseMapper.selectVoById(ruleId); + } + + /** + * 分页查询隐患规则通知对象列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 隐患规则通知对象分页列表 + */ + @Override + public TableDataInfo queryPageList(HazardRuleNotifyObjectBo 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(HazardRuleNotifyObjectBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(HazardRuleNotifyObjectBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.eq(bo.getRuleId() != null, HazardRuleNotifyObject::getRuleId, bo.getRuleId()); + lqw.eq(bo.getNotifyId() != null, HazardRuleNotifyObject::getNotifyId, bo.getNotifyId()); + lqw.eq(StringUtils.isNotBlank(bo.getNotifyType()), HazardRuleNotifyObject::getNotifyType, bo.getNotifyType()); + return lqw; + } + + /** + * 新增隐患规则通知对象 + * + * @param bo 隐患规则通知对象 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(HazardRuleNotifyObjectBo bo) { + HazardRuleNotifyObject add = MapstructUtils.convert(bo, HazardRuleNotifyObject.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setRuleId(add.getRuleId()); + } + return flag; + } + + /** + * 修改隐患规则通知对象 + * + * @param bo 隐患规则通知对象 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(HazardRuleNotifyObjectBo bo) { + HazardRuleNotifyObject update = MapstructUtils.convert(bo, HazardRuleNotifyObject.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(HazardRuleNotifyObject 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/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HazardRuleServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HazardRuleServiceImpl.java new file mode 100644 index 00000000..768babfc --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HazardRuleServiceImpl.java @@ -0,0 +1,137 @@ +package org.dromara.safety.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.safety.domain.HazardRule; +import org.dromara.safety.domain.bo.HazardRuleBo; +import org.dromara.safety.domain.vo.HazardRuleVo; +import org.dromara.safety.mapper.HazardRuleMapper; +import org.dromara.safety.service.IHazardRuleService; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 隐患分级通知规则Service业务层处理 + * + * @author lilemy + * @date 2025-12-03 + */ +@RequiredArgsConstructor +@Service +public class HazardRuleServiceImpl extends ServiceImpl + implements IHazardRuleService { + + /** + * 查询隐患分级通知规则 + * + * @param id 主键 + * @return 隐患分级通知规则 + */ + @Override + public HazardRuleVo queryById(Long id) { + return baseMapper.selectVoById(id); + } + + /** + * 分页查询隐患分级通知规则列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 隐患分级通知规则分页列表 + */ + @Override + public TableDataInfo queryPageList(HazardRuleBo 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(HazardRuleBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(HazardRuleBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByDesc(HazardRule::getId); + lqw.eq(bo.getProjectId() != null, HazardRule::getProjectId, bo.getProjectId()); + lqw.eq(StringUtils.isNotBlank(bo.getHazardLevel()), HazardRule::getHazardLevel, bo.getHazardLevel()); + lqw.eq(bo.getHazardWeight() != null, HazardRule::getHazardWeight, bo.getHazardWeight()); + lqw.eq(bo.getResponseTime() != null, HazardRule::getResponseTime, bo.getResponseTime()); + lqw.eq(StringUtils.isNotBlank(bo.getResponseUnit()), HazardRule::getResponseUnit, bo.getResponseUnit()); + lqw.eq(StringUtils.isNotBlank(bo.getNotifyMethod()), HazardRule::getNotifyMethod, bo.getNotifyMethod()); + lqw.eq(StringUtils.isNotBlank(bo.getTimeoutAction()), HazardRule::getTimeoutAction, bo.getTimeoutAction()); + lqw.eq(StringUtils.isNotBlank(bo.getExtraSetting()), HazardRule::getExtraSetting, bo.getExtraSetting()); + return lqw; + } + + /** + * 新增隐患分级通知规则 + * + * @param bo 隐患分级通知规则 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(HazardRuleBo bo) { + HazardRule add = MapstructUtils.convert(bo, HazardRule.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + /** + * 修改隐患分级通知规则 + * + * @param bo 隐患分级通知规则 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(HazardRuleBo bo) { + HazardRule update = MapstructUtils.convert(bo, HazardRule.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(HazardRule 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/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HazardRuleMapper.xml b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HazardRuleMapper.xml new file mode 100644 index 00000000..fc02f467 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HazardRuleMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HazardRuleNotifyObjectMapper.xml b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HazardRuleNotifyObjectMapper.xml new file mode 100644 index 00000000..b3fa5193 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HazardRuleNotifyObjectMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/xinnengyuan/script/sql/xinnengyuan.sql b/xinnengyuan/script/sql/xinnengyuan.sql index 0d6c75df..54a6fe2a 100644 --- a/xinnengyuan/script/sql/xinnengyuan.sql +++ b/xinnengyuan/script/sql/xinnengyuan.sql @@ -1974,3 +1974,53 @@ CREATE TABLE `gps_safety_user_record` PRIMARY KEY (`id`) USING BTREE, INDEX `idx_user_id` (`user_id` ASC) USING BTREE comment '用户id' ) comment '安全员轨迹信息'; + + +CREATE TABLE hazard_rule +( + `id` bigint not null auto_increment comment '主键', + `project_id` bigint not null comment '项目id', + `hazard_level` varchar(64) not null comment '隐患级别', + `hazard_weight` int not null comment '隐患权重', + `response_time` int not null comment '响应时限数值', + `response_unit` varchar(20) not null comment '响应时效单位', + `notify_method` varchar(20) not null comment '通知方式', + `timeout_action` varchar(50) not null comment '超时处理方式', + `extra_setting` varchar(20) not null comment '额外设置', + `remark` varchar(512) null comment '备注', + `create_by` bigint null comment '创建者', + `update_by` bigint null comment '更新者', + `create_dept` bigint null comment '创建部门', + `create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间', + `update_time` datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间', + PRIMARY KEY (`id`) USING BTREE, + index `idx_project_id` (`project_id` asc) using btree comment '项目ID' +) comment '隐患分级通知规则'; + +CREATE TABLE hazard_rule_notify_object +( + rule_id BIGINT NOT NULL COMMENT '规则ID', + notify_id BIGINT NOT NULL COMMENT '通知ID', + notify_type VARCHAR(20) NOT NULL COMMENT '通知类型', + index `idx_rule_id` (`rule_id` asc) using btree comment '规则ID' +) comment '隐患规则通知对象'; + +-- 菜单 SQL +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1996139632219136001, '隐患分级通知规则', '1996118434672001025', '1', 'rule', 'safety/rule/index', 1, 0, 'C', '0', '0', 'safety:rule:list', '#', 103, 1, sysdate(), null, null, '隐患分级通知规则菜单'); + +-- 按钮 SQL +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1996139632219136002, '隐患分级通知规则查询', 1996139632219136001, '1', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:query', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1996139632219136003, '隐患分级通知规则新增', 1996139632219136001, '2', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:add', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1996139632219136004, '隐患分级通知规则修改', 1996139632219136001, '3', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:edit', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1996139632219136005, '隐患分级通知规则删除', 1996139632219136001, '4', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:remove', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1996139632219136006, '隐患分级通知规则导出', 1996139632219136001, '5', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:export', '#', 103, 1, sysdate(), null, null, '');