diff --git a/os-admin/src/main/resources/MySQL测试数据源.txt b/os-admin/src/main/resources/MySQL测试数据源.txt new file mode 100644 index 0000000..929c8a8 --- /dev/null +++ b/os-admin/src/main/resources/MySQL测试数据源.txt @@ -0,0 +1,70 @@ +# 数据源配置 +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 +# master: +# url: jdbc:mysql://10.42.0.1:4000/tao_iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true +# username: root +# password: haiwei@123 + # 主库数据源 + master: + url: jdbc:mysql://1.13.177.47:3306/tao_iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: Haiwei123456 + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 10 + # 最小连接池数量 + minIdle: 20 + # 最大连接池数量 + maxActive: 200 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: true + testOnReturn: false + # 缓存游标,默认false + poolPreparedStatements: true + # 缓存游标最大数量,默认-1(不缓存) + max-open-prepared-statements: 50 + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 2000 + merge-sql: true + wall: + config: + multi-statement-allow: true \ No newline at end of file diff --git a/os-ems/src/main/java/com/os/ems/base/controller/EmsAlarmActionStepController.java b/os-ems/src/main/java/com/os/ems/base/controller/EmsAlarmActionStepController.java new file mode 100644 index 0000000..2c239fb --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/controller/EmsAlarmActionStepController.java @@ -0,0 +1,139 @@ +package com.os.ems.base.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.os.common.annotation.Log; +import com.os.common.core.controller.BaseController; +import com.os.common.core.domain.AjaxResult; +import com.os.common.enums.BusinessType; +import com.os.ems.base.domain.EmsAlarmActionStep; +import com.os.ems.base.service.IEmsAlarmActionStepService; +import com.os.common.utils.poi.ExcelUtil; +import com.os.common.core.page.TableDataInfo; + +/** + * 报警规则具体措施步骤Controller + * + * @author zch + * @date 2025-05-29 + */ +@RestController +@RequestMapping("/ems/base/emsAlarmActionStep") +public class EmsAlarmActionStepController extends BaseController +{ + @Autowired + private IEmsAlarmActionStepService emsAlarmActionStepService; + + /** + * 查询报警规则具体措施步骤列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:list')") + @GetMapping("/list") + public TableDataInfo list(EmsAlarmActionStep emsAlarmActionStep) + { + startPage(); + List list = emsAlarmActionStepService.selectEmsAlarmActionStepList(emsAlarmActionStep); + return getDataTable(list); + } + + /** + * 导出报警规则具体措施步骤列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:export')") + @Log(title = "报警规则具体措施步骤", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsAlarmActionStep emsAlarmActionStep) + { + List list = emsAlarmActionStepService.selectEmsAlarmActionStepList(emsAlarmActionStep); + ExcelUtil util = new ExcelUtil(EmsAlarmActionStep.class); + util.exportExcel(response, list, "报警规则具体措施步骤数据"); + } + + /** + * 获取报警规则具体措施步骤详细信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:query')") + @GetMapping(value = "/{objId}") + public AjaxResult getInfo(@PathVariable("objId") String objId) + { + return success(emsAlarmActionStepService.selectEmsAlarmActionStepByObjId(objId)); + } + + /** + * 根据报警规则ID查询措施步骤列表(包含图片) + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:query')") + @GetMapping(value = "/rule/{ruleObjId}") + public AjaxResult getStepsByRuleId(@PathVariable("ruleObjId") String ruleObjId) + { + List steps = emsAlarmActionStepService.selectEmsAlarmActionStepByRuleObjId(ruleObjId); + return success(steps); + } + + /** + * 新增报警规则具体措施步骤 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:add')") + @Log(title = "报警规则具体措施步骤", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsAlarmActionStep emsAlarmActionStep) + { + emsAlarmActionStep.setCreateBy(getUsername()); + return toAjax(emsAlarmActionStepService.insertEmsAlarmActionStep(emsAlarmActionStep)); + } + + /** + * 修改报警规则具体措施步骤 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:edit')") + @Log(title = "报警规则具体措施步骤", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsAlarmActionStep emsAlarmActionStep) + { + emsAlarmActionStep.setUpdateBy(getUsername()); + return toAjax(emsAlarmActionStepService.updateEmsAlarmActionStep(emsAlarmActionStep)); + } + + /** + * 删除报警规则具体措施步骤 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:remove')") + @Log(title = "报警规则具体措施步骤", businessType = BusinessType.DELETE) + @DeleteMapping("/{objIds}") + public AjaxResult remove(@PathVariable String[] objIds) + { + return toAjax(emsAlarmActionStepService.deleteEmsAlarmActionStepByObjIds(objIds)); + } + + /** + * 根据报警数据信息查询对应的措施步骤列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:query')") + @GetMapping(value = "/alarm/{monitorId}/{cause}") + public AjaxResult getStepsByAlarmInfo(@PathVariable("monitorId") String monitorId, @PathVariable("cause") String cause) + { + List steps = emsAlarmActionStepService.selectActionStepsByAlarmInfo(monitorId, cause); + return success(steps); + } + + /** + * 批量保存措施步骤(包含图片信息) + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStep:edit')") + @Log(title = "批量保存措施步骤", businessType = BusinessType.UPDATE) + @PostMapping(value = "/batchSave/{ruleObjId}") + public AjaxResult batchSaveActionSteps(@PathVariable("ruleObjId") String ruleObjId, @RequestBody List stepList) + { + return toAjax(emsAlarmActionStepService.batchSaveActionSteps(ruleObjId, stepList)); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/controller/EmsAlarmActionStepImageController.java b/os-ems/src/main/java/com/os/ems/base/controller/EmsAlarmActionStepImageController.java new file mode 100644 index 0000000..80a24c8 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/controller/EmsAlarmActionStepImageController.java @@ -0,0 +1,106 @@ +package com.os.ems.base.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.os.common.annotation.Log; +import com.os.common.core.controller.BaseController; +import com.os.common.core.domain.AjaxResult; +import com.os.common.enums.BusinessType; +import com.os.ems.base.domain.EmsAlarmActionStepImage; +import com.os.ems.base.service.IEmsAlarmActionStepImageService; +import com.os.common.utils.poi.ExcelUtil; +import com.os.common.core.page.TableDataInfo; + +/** + * 报警措施步骤图片Controller + * + * @author zch + * @date 2025-05-29 + */ +@RestController +@RequestMapping("/ems/base/emsAlarmActionStepImage") +public class EmsAlarmActionStepImageController extends BaseController +{ + @Autowired + private IEmsAlarmActionStepImageService emsAlarmActionStepImageService; + + /** + * 查询报警措施步骤图片列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStepImage:list')") + @GetMapping("/list") + public TableDataInfo list(EmsAlarmActionStepImage emsAlarmActionStepImage) + { + startPage(); + List list = emsAlarmActionStepImageService.selectEmsAlarmActionStepImageList(emsAlarmActionStepImage); + return getDataTable(list); + } + + /** + * 导出报警措施步骤图片列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStepImage:export')") + @Log(title = "报警措施步骤图片", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsAlarmActionStepImage emsAlarmActionStepImage) + { + List list = emsAlarmActionStepImageService.selectEmsAlarmActionStepImageList(emsAlarmActionStepImage); + ExcelUtil util = new ExcelUtil(EmsAlarmActionStepImage.class); + util.exportExcel(response, list, "报警措施步骤图片数据"); + } + + /** + * 获取报警措施步骤图片详细信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStepImage:query')") + @GetMapping(value = "/{objId}") + public AjaxResult getInfo(@PathVariable("objId") String objId) + { + return success(emsAlarmActionStepImageService.selectEmsAlarmActionStepImageByObjId(objId)); + } + + /** + * 新增报警措施步骤图片 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStepImage:add')") + @Log(title = "报警措施步骤图片", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsAlarmActionStepImage emsAlarmActionStepImage) + { + emsAlarmActionStepImage.setCreateBy(getUsername()); + return toAjax(emsAlarmActionStepImageService.insertEmsAlarmActionStepImage(emsAlarmActionStepImage)); + } + + /** + * 修改报警措施步骤图片 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStepImage:edit')") + @Log(title = "报警措施步骤图片", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsAlarmActionStepImage emsAlarmActionStepImage) + { + emsAlarmActionStepImage.setUpdateBy(getUsername()); + return toAjax(emsAlarmActionStepImageService.updateEmsAlarmActionStepImage(emsAlarmActionStepImage)); + } + + /** + * 删除报警措施步骤图片 + */ + @PreAuthorize("@ss.hasPermi('ems/base:emsAlarmActionStepImage:remove')") + @Log(title = "报警措施步骤图片", businessType = BusinessType.DELETE) + @DeleteMapping("/{objIds}") + public AjaxResult remove(@PathVariable String[] objIds) + { + return toAjax(emsAlarmActionStepImageService.deleteEmsAlarmActionStepImageByObjIds(objIds)); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/domain/EmsAlarmActionStep.java b/os-ems/src/main/java/com/os/ems/base/domain/EmsAlarmActionStep.java new file mode 100644 index 0000000..ada4f07 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/domain/EmsAlarmActionStep.java @@ -0,0 +1,98 @@ +package com.os.ems.base.domain; + +import java.util.List; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.os.common.annotation.Excel; +import com.os.common.core.domain.BaseEntity; + +/** + * 报警规则具体措施步骤对象 ems_alarm_action_step + * + * @author zch + * @date 2025-05-29 + */ +public class EmsAlarmActionStep extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private String objId; + + /** 关联的报警规则ID (逻辑关联 ems_record_alarm_rule.obj_id) */ + @Excel(name = "关联的报警规则ID (逻辑关联 ems_record_alarm_rule.obj_id)") + private String ruleObjId; + + /** 步骤顺序,从1开始 */ + @Excel(name = "步骤顺序,从1开始") + private Long stepSequence; + + /** 步骤文字描述 */ + @Excel(name = "步骤文字描述") + private String description; + + /** 步骤关联的图片列表 */ + private List stepImages; + + public void setObjId(String objId) + { + this.objId = objId; + } + + public String getObjId() + { + return objId; + } + public void setRuleObjId(String ruleObjId) + { + this.ruleObjId = ruleObjId; + } + + public String getRuleObjId() + { + return ruleObjId; + } + public void setStepSequence(Long stepSequence) + { + this.stepSequence = stepSequence; + } + + public Long getStepSequence() + { + return stepSequence; + } + public void setDescription(String description) + { + this.description = description; + } + + public String getDescription() + { + return description; + } + + public void setStepImages(List stepImages) + { + this.stepImages = stepImages; + } + + public List getStepImages() + { + return stepImages; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("objId", getObjId()) + .append("ruleObjId", getRuleObjId()) + .append("stepSequence", getStepSequence()) + .append("description", getDescription()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/domain/EmsAlarmActionStepImage.java b/os-ems/src/main/java/com/os/ems/base/domain/EmsAlarmActionStepImage.java new file mode 100644 index 0000000..1bb34b7 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/domain/EmsAlarmActionStepImage.java @@ -0,0 +1,102 @@ +package com.os.ems.base.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.os.common.annotation.Excel; +import com.os.common.core.domain.BaseEntity; + +/** + * 报警规则措施步骤图片对象 ems_alarm_action_step_image + * + * @author zch + * @date 2025-05-29 + */ +public class EmsAlarmActionStepImage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private String objId; + + /** 关联的措施步骤ID */ + @Excel(name = "关联的措施步骤ID") + private String actionStepObjId; + + /** 图片URL */ + @Excel(name = "图片URL") + private String imageUrl; + + /** 图片顺序 */ + @Excel(name = "图片顺序") + private Long imageSequence; + + /** 图片描述 */ + @Excel(name = "图片描述") + private String description; + + public void setObjId(String objId) + { + this.objId = objId; + } + + public String getObjId() + { + return objId; + } + + public void setActionStepObjId(String actionStepObjId) + { + this.actionStepObjId = actionStepObjId; + } + + public String getActionStepObjId() + { + return actionStepObjId; + } + + public void setImageUrl(String imageUrl) + { + this.imageUrl = imageUrl; + } + + public String getImageUrl() + { + return imageUrl; + } + + public void setImageSequence(Long imageSequence) + { + this.imageSequence = imageSequence; + } + + public Long getImageSequence() + { + return imageSequence; + } + + public void setDescription(String description) + { + this.description = description; + } + + public String getDescription() + { + return description; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("objId", getObjId()) + .append("actionStepObjId", getActionStepObjId()) + .append("imageUrl", getImageUrl()) + .append("imageSequence", getImageSequence()) + .append("description", getDescription()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/mapper/EmsAlarmActionStepImageMapper.java b/os-ems/src/main/java/com/os/ems/base/mapper/EmsAlarmActionStepImageMapper.java new file mode 100644 index 0000000..65480d8 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/mapper/EmsAlarmActionStepImageMapper.java @@ -0,0 +1,61 @@ +package com.os.ems.base.mapper; + +import java.util.List; +import com.os.ems.base.domain.EmsAlarmActionStepImage; + +/** + * 报警措施步骤图片Mapper接口 + * + * @author zch + * @date 2025-05-29 + */ +public interface EmsAlarmActionStepImageMapper +{ + /** + * 查询报警措施步骤图片 + * + * @param objId 报警措施步骤图片主键 + * @return 报警措施步骤图片 + */ + public EmsAlarmActionStepImage selectEmsAlarmActionStepImageByObjId(String objId); + + /** + * 查询报警措施步骤图片列表 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 报警措施步骤图片集合 + */ + public List selectEmsAlarmActionStepImageList(EmsAlarmActionStepImage emsAlarmActionStepImage); + + /** + * 新增报警措施步骤图片 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 结果 + */ + public int insertEmsAlarmActionStepImage(EmsAlarmActionStepImage emsAlarmActionStepImage); + + /** + * 修改报警措施步骤图片 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 结果 + */ + public int updateEmsAlarmActionStepImage(EmsAlarmActionStepImage emsAlarmActionStepImage); + + /** + * 删除报警措施步骤图片 + * + * @param objId 报警措施步骤图片主键 + * @return 结果 + */ + public int deleteEmsAlarmActionStepImageByObjId(String objId); + + /** + * 批量删除报警措施步骤图片 + * + * @param objIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsAlarmActionStepImageByObjIds(String[] objIds); +} diff --git a/os-ems/src/main/java/com/os/ems/base/mapper/EmsAlarmActionStepMapper.java b/os-ems/src/main/java/com/os/ems/base/mapper/EmsAlarmActionStepMapper.java new file mode 100644 index 0000000..1c3faab --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/mapper/EmsAlarmActionStepMapper.java @@ -0,0 +1,79 @@ +package com.os.ems.base.mapper; + +import java.util.List; +import com.os.ems.base.domain.EmsAlarmActionStep; +import org.apache.ibatis.annotations.Param; + +/** + * 报警规则具体措施步骤Mapper接口 + * + * @author zch + * @date 2025-05-29 + */ +public interface EmsAlarmActionStepMapper +{ + /** + * 查询报警规则具体措施步骤 + * + * @param objId 报警规则具体措施步骤主键 + * @return 报警规则具体措施步骤 + */ + public EmsAlarmActionStep selectEmsAlarmActionStepByObjId(String objId); + + /** + * 查询报警规则具体措施步骤列表 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 报警规则具体措施步骤集合 + */ + public List selectEmsAlarmActionStepList(EmsAlarmActionStep emsAlarmActionStep); + + /** + * 新增报警规则具体措施步骤 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 结果 + */ + public int insertEmsAlarmActionStep(EmsAlarmActionStep emsAlarmActionStep); + + /** + * 修改报警规则具体措施步骤 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 结果 + */ + public int updateEmsAlarmActionStep(EmsAlarmActionStep emsAlarmActionStep); + + /** + * 删除报警规则具体措施步骤 + * + * @param objId 报警规则具体措施步骤主键 + * @return 结果 + */ + public int deleteEmsAlarmActionStepByObjId(String objId); + + /** + * 批量删除报警规则具体措施步骤 + * + * @param objIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsAlarmActionStepByObjIds(String[] objIds); + + /** + * 根据报警规则ID查询措施步骤列表 + * + * @param ruleObjId 报警规则ID + * @return 措施步骤列表 + */ + public List selectEmsAlarmActionStepByRuleObjId(String ruleObjId); + + /** + * 根据报警数据信息查询对应的措施步骤列表 + * + * @param monitorId 设备编号 + * @param cause 异常原因 + * @return 措施步骤列表 + */ + public List selectActionStepsByAlarmInfo(@Param("monitorId") String monitorId, @Param("cause") String cause); +} diff --git a/os-ems/src/main/java/com/os/ems/base/service/IEmsAlarmActionStepImageService.java b/os-ems/src/main/java/com/os/ems/base/service/IEmsAlarmActionStepImageService.java new file mode 100644 index 0000000..471d31f --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/service/IEmsAlarmActionStepImageService.java @@ -0,0 +1,61 @@ +package com.os.ems.base.service; + +import java.util.List; +import com.os.ems.base.domain.EmsAlarmActionStepImage; + +/** + * 报警措施步骤图片Service接口 + * + * @author zch + * @date 2025-05-29 + */ +public interface IEmsAlarmActionStepImageService +{ + /** + * 查询报警措施步骤图片 + * + * @param objId 报警措施步骤图片主键 + * @return 报警措施步骤图片 + */ + public EmsAlarmActionStepImage selectEmsAlarmActionStepImageByObjId(String objId); + + /** + * 查询报警措施步骤图片列表 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 报警措施步骤图片集合 + */ + public List selectEmsAlarmActionStepImageList(EmsAlarmActionStepImage emsAlarmActionStepImage); + + /** + * 新增报警措施步骤图片 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 结果 + */ + public int insertEmsAlarmActionStepImage(EmsAlarmActionStepImage emsAlarmActionStepImage); + + /** + * 修改报警措施步骤图片 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 结果 + */ + public int updateEmsAlarmActionStepImage(EmsAlarmActionStepImage emsAlarmActionStepImage); + + /** + * 批量删除报警措施步骤图片 + * + * @param objIds 需要删除的报警措施步骤图片主键集合 + * @return 结果 + */ + public int deleteEmsAlarmActionStepImageByObjIds(String[] objIds); + + /** + * 删除报警措施步骤图片信息 + * + * @param objId 报警措施步骤图片主键 + * @return 结果 + */ + public int deleteEmsAlarmActionStepImageByObjId(String objId); +} diff --git a/os-ems/src/main/java/com/os/ems/base/service/IEmsAlarmActionStepService.java b/os-ems/src/main/java/com/os/ems/base/service/IEmsAlarmActionStepService.java new file mode 100644 index 0000000..d07fa5e --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/service/IEmsAlarmActionStepService.java @@ -0,0 +1,87 @@ +package com.os.ems.base.service; + +import java.util.List; +import com.os.ems.base.domain.EmsAlarmActionStep; + +/** + * 报警规则具体措施步骤Service接口 + * + * @author zch + * @date 2025-05-29 + */ +public interface IEmsAlarmActionStepService +{ + /** + * 查询报警规则具体措施步骤 + * + * @param objId 报警规则具体措施步骤主键 + * @return 报警规则具体措施步骤 + */ + public EmsAlarmActionStep selectEmsAlarmActionStepByObjId(String objId); + + /** + * 查询报警规则具体措施步骤列表 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 报警规则具体措施步骤集合 + */ + public List selectEmsAlarmActionStepList(EmsAlarmActionStep emsAlarmActionStep); + + /** + * 新增报警规则具体措施步骤 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 结果 + */ + public int insertEmsAlarmActionStep(EmsAlarmActionStep emsAlarmActionStep); + + /** + * 修改报警规则具体措施步骤 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 结果 + */ + public int updateEmsAlarmActionStep(EmsAlarmActionStep emsAlarmActionStep); + + /** + * 批量删除报警规则具体措施步骤 + * + * @param objIds 需要删除的报警规则具体措施步骤主键集合 + * @return 结果 + */ + public int deleteEmsAlarmActionStepByObjIds(String[] objIds); + + /** + * 删除报警规则具体措施步骤信息 + * + * @param objId 报警规则具体措施步骤主键 + * @return 结果 + */ + public int deleteEmsAlarmActionStepByObjId(String objId); + + /** + * 根据报警规则ID查询措施步骤列表(包含图片信息) + * + * @param ruleObjId 报警规则ID + * @return 措施步骤列表 + */ + List selectEmsAlarmActionStepByRuleObjId(String ruleObjId); + + /** + * 根据报警数据信息查询对应的措施步骤列表 + * + * @param monitorId 设备编号 + * @param cause 异常原因 + * @return 措施步骤列表 + */ + List selectActionStepsByAlarmInfo(String monitorId, String cause); + + /** + * 批量保存措施步骤(包含图片信息) + * + * @param ruleObjId 报警规则ID + * @param stepList 措施步骤列表 + * @return 结果 + */ + int batchSaveActionSteps(String ruleObjId, List stepList); +} diff --git a/os-ems/src/main/java/com/os/ems/base/service/impl/EmsAlarmActionStepImageServiceImpl.java b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsAlarmActionStepImageServiceImpl.java new file mode 100644 index 0000000..827d51f --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsAlarmActionStepImageServiceImpl.java @@ -0,0 +1,96 @@ +package com.os.ems.base.service.impl; + +import java.util.List; +import com.os.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.os.ems.base.mapper.EmsAlarmActionStepImageMapper; +import com.os.ems.base.domain.EmsAlarmActionStepImage; +import com.os.ems.base.service.IEmsAlarmActionStepImageService; + +/** + * 报警措施步骤图片Service业务层处理 + * + * @author zch + * @date 2025-05-29 + */ +@Service +public class EmsAlarmActionStepImageServiceImpl implements IEmsAlarmActionStepImageService +{ + @Autowired + private EmsAlarmActionStepImageMapper emsAlarmActionStepImageMapper; + + /** + * 查询报警措施步骤图片 + * + * @param objId 报警措施步骤图片主键 + * @return 报警措施步骤图片 + */ + @Override + public EmsAlarmActionStepImage selectEmsAlarmActionStepImageByObjId(String objId) + { + return emsAlarmActionStepImageMapper.selectEmsAlarmActionStepImageByObjId(objId); + } + + /** + * 查询报警措施步骤图片列表 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 报警措施步骤图片 + */ + @Override + public List selectEmsAlarmActionStepImageList(EmsAlarmActionStepImage emsAlarmActionStepImage) + { + return emsAlarmActionStepImageMapper.selectEmsAlarmActionStepImageList(emsAlarmActionStepImage); + } + + /** + * 新增报警措施步骤图片 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 结果 + */ + @Override + public int insertEmsAlarmActionStepImage(EmsAlarmActionStepImage emsAlarmActionStepImage) + { + emsAlarmActionStepImage.setCreateTime(DateUtils.getNowDate()); + return emsAlarmActionStepImageMapper.insertEmsAlarmActionStepImage(emsAlarmActionStepImage); + } + + /** + * 修改报警措施步骤图片 + * + * @param emsAlarmActionStepImage 报警措施步骤图片 + * @return 结果 + */ + @Override + public int updateEmsAlarmActionStepImage(EmsAlarmActionStepImage emsAlarmActionStepImage) + { + emsAlarmActionStepImage.setUpdateTime(DateUtils.getNowDate()); + return emsAlarmActionStepImageMapper.updateEmsAlarmActionStepImage(emsAlarmActionStepImage); + } + + /** + * 批量删除报警措施步骤图片 + * + * @param objIds 需要删除的报警措施步骤图片主键 + * @return 结果 + */ + @Override + public int deleteEmsAlarmActionStepImageByObjIds(String[] objIds) + { + return emsAlarmActionStepImageMapper.deleteEmsAlarmActionStepImageByObjIds(objIds); + } + + /** + * 删除报警措施步骤图片信息 + * + * @param objId 报警措施步骤图片主键 + * @return 结果 + */ + @Override + public int deleteEmsAlarmActionStepImageByObjId(String objId) + { + return emsAlarmActionStepImageMapper.deleteEmsAlarmActionStepImageByObjId(objId); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/service/impl/EmsAlarmActionStepServiceImpl.java b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsAlarmActionStepServiceImpl.java new file mode 100644 index 0000000..5319dba --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsAlarmActionStepServiceImpl.java @@ -0,0 +1,191 @@ +package com.os.ems.base.service.impl; + +import java.util.List; +import com.os.common.utils.DateUtils; +import com.os.common.utils.StringUtils; +import com.os.common.utils.uuid.IdUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.os.ems.base.mapper.EmsAlarmActionStepMapper; +import com.os.ems.base.mapper.EmsAlarmActionStepImageMapper; +import com.os.ems.base.domain.EmsAlarmActionStep; +import com.os.ems.base.domain.EmsAlarmActionStepImage; +import com.os.ems.base.service.IEmsAlarmActionStepService; + +/** + * 报警规则具体措施步骤Service业务层处理 + * + * @author zch + * @date 2025-05-29 + */ +@Service +public class EmsAlarmActionStepServiceImpl implements IEmsAlarmActionStepService +{ + @Autowired + private EmsAlarmActionStepMapper emsAlarmActionStepMapper; + + @Autowired + private EmsAlarmActionStepImageMapper emsAlarmActionStepImageMapper; + + /** + * 查询报警规则具体措施步骤 + * + * @param objId 报警规则具体措施步骤主键 + * @return 报警规则具体措施步骤 + */ + @Override + public EmsAlarmActionStep selectEmsAlarmActionStepByObjId(String objId) + { + return emsAlarmActionStepMapper.selectEmsAlarmActionStepByObjId(objId); + } + + /** + * 查询报警规则具体措施步骤列表 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 报警规则具体措施步骤 + */ + @Override + public List selectEmsAlarmActionStepList(EmsAlarmActionStep emsAlarmActionStep) + { + return emsAlarmActionStepMapper.selectEmsAlarmActionStepList(emsAlarmActionStep); + } + + /** + * 新增报警规则具体措施步骤 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 结果 + */ + @Override + public int insertEmsAlarmActionStep(EmsAlarmActionStep emsAlarmActionStep) + { + emsAlarmActionStep.setCreateTime(DateUtils.getNowDate()); + return emsAlarmActionStepMapper.insertEmsAlarmActionStep(emsAlarmActionStep); + } + + /** + * 修改报警规则具体措施步骤 + * + * @param emsAlarmActionStep 报警规则具体措施步骤 + * @return 结果 + */ + @Override + public int updateEmsAlarmActionStep(EmsAlarmActionStep emsAlarmActionStep) + { + emsAlarmActionStep.setUpdateTime(DateUtils.getNowDate()); + return emsAlarmActionStepMapper.updateEmsAlarmActionStep(emsAlarmActionStep); + } + + /** + * 批量删除报警规则具体措施步骤 + * + * @param objIds 需要删除的报警规则具体措施步骤主键 + * @return 结果 + */ + @Override + public int deleteEmsAlarmActionStepByObjIds(String[] objIds) + { + return emsAlarmActionStepMapper.deleteEmsAlarmActionStepByObjIds(objIds); + } + + /** + * 删除报警规则具体措施步骤信息 + * + * @param objId 报警规则具体措施步骤主键 + * @return 结果 + */ + @Override + public int deleteEmsAlarmActionStepByObjId(String objId) + { + return emsAlarmActionStepMapper.deleteEmsAlarmActionStepByObjId(objId); + } + + /** + * 根据报警规则ID查询措施步骤列表(包含图片信息) + * + * @param ruleObjId 报警规则ID + * @return 措施步骤列表 + */ + @Override + public List selectEmsAlarmActionStepByRuleObjId(String ruleObjId) + { + return emsAlarmActionStepMapper.selectEmsAlarmActionStepByRuleObjId(ruleObjId); + } + + /** + * 根据报警数据信息查询对应的措施步骤列表 + * + * @param monitorId 设备编号 + * @param cause 异常原因 + * @return 措施步骤列表 + */ + @Override + public List selectActionStepsByAlarmInfo(String monitorId, String cause) + { + return emsAlarmActionStepMapper.selectActionStepsByAlarmInfo(monitorId, cause); + } + + /** + * 批量保存措施步骤(包含图片信息) + * + * @param ruleObjId 报警规则ID + * @param stepList 措施步骤列表 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int batchSaveActionSteps(String ruleObjId, List stepList) + { + if (StringUtils.isEmpty(ruleObjId) || stepList == null || stepList.isEmpty()) { + return 0; + } + + try { + // 1. 先删除该规则下的所有现有步骤和图片 + List existingSteps = emsAlarmActionStepMapper.selectEmsAlarmActionStepByRuleObjId(ruleObjId); + for (EmsAlarmActionStep existingStep : existingSteps) { + // 删除步骤关联的图片 + EmsAlarmActionStepImage imageQuery = new EmsAlarmActionStepImage(); + imageQuery.setActionStepObjId(existingStep.getObjId()); + List existingImages = emsAlarmActionStepImageMapper.selectEmsAlarmActionStepImageList(imageQuery); + for (EmsAlarmActionStepImage image : existingImages) { + emsAlarmActionStepImageMapper.deleteEmsAlarmActionStepImageByObjId(image.getObjId()); + } + // 删除步骤 + emsAlarmActionStepMapper.deleteEmsAlarmActionStepByObjId(existingStep.getObjId()); + } + + // 2. 保存新的步骤和图片 + int result = 0; + for (EmsAlarmActionStep step : stepList) { + // 生成步骤ID + if (StringUtils.isEmpty(step.getObjId())) { + step.setObjId(IdUtils.fastUUID()); + } + step.setRuleObjId(ruleObjId); + step.setCreateTime(DateUtils.getNowDate()); + + // 保存步骤 + result += emsAlarmActionStepMapper.insertEmsAlarmActionStep(step); + + // 保存步骤关联的图片 + if (step.getStepImages() != null && !step.getStepImages().isEmpty()) { + for (EmsAlarmActionStepImage image : step.getStepImages()) { + if (StringUtils.isEmpty(image.getObjId())) { + image.setObjId(IdUtils.fastUUID()); + } + image.setActionStepObjId(step.getObjId()); + image.setCreateTime(DateUtils.getNowDate()); + emsAlarmActionStepImageMapper.insertEmsAlarmActionStepImage(image); + } + } + } + + return result; + } catch (Exception e) { + throw new RuntimeException("批量保存措施步骤失败: " + e.getMessage(), e); + } + } +} diff --git a/os-ems/src/main/resources/mapper/ems/base/EmsAlarmActionStepImageMapper.xml b/os-ems/src/main/resources/mapper/ems/base/EmsAlarmActionStepImageMapper.xml new file mode 100644 index 0000000..c77ca2b --- /dev/null +++ b/os-ems/src/main/resources/mapper/ems/base/EmsAlarmActionStepImageMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + select obj_id, action_step_obj_id, image_url, image_sequence, description, create_by, create_time, update_by, update_time, remark from ems_alarm_action_step_image + + + + + + + + insert into ems_alarm_action_step_image + + action_step_obj_id, + image_url, + image_sequence, + description, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{actionStepObjId}, + #{imageUrl}, + #{imageSequence}, + #{description}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_alarm_action_step_image + + action_step_obj_id = #{actionStepObjId}, + image_url = #{imageUrl}, + image_sequence = #{imageSequence}, + description = #{description}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where obj_id = #{objId} + + + + delete from ems_alarm_action_step_image where obj_id = #{objId} + + + + delete from ems_alarm_action_step_image where obj_id in + + #{objId} + + + \ No newline at end of file diff --git a/os-ems/src/main/resources/mapper/ems/base/EmsAlarmActionStepMapper.xml b/os-ems/src/main/resources/mapper/ems/base/EmsAlarmActionStepMapper.xml new file mode 100644 index 0000000..7537747 --- /dev/null +++ b/os-ems/src/main/resources/mapper/ems/base/EmsAlarmActionStepMapper.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select obj_id, rule_obj_id, step_sequence, description, create_by, create_time, update_by, update_time, remark from ems_alarm_action_step + + + + + + + + + + + + insert into ems_alarm_action_step + + rule_obj_id, + step_sequence, + description, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{ruleObjId}, + #{stepSequence}, + #{description}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_alarm_action_step + + rule_obj_id = #{ruleObjId}, + step_sequence = #{stepSequence}, + description = #{description}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where obj_id = #{objId} + + + + delete from ems_alarm_action_step where obj_id = #{objId} + + + + delete from ems_alarm_action_step where obj_id in + + #{objId} + + + \ No newline at end of file