若依微服务1.8

1、设备报警规则增删改查和导出
dev 1.8
xins 1 year ago
parent c9314ad1c2
commit 178d5b4de2

@ -106,7 +106,7 @@ public class HwDictConstants {
public static final String CONTROL_COMMAND_PAYLOAD_TYPE_KEY = "type";
public static final String CONTROL_COMMAND_PAYLOAD_PARAM_KEY = "param";
public static final String DEVICEMODE_GPS_FLAG_NO="0";//设备模型,非定位模型
public static final String DEVICEMODE_GPS_FLAG_NO = "0";//设备模型,非定位模型
public static final String TENANT_STATUS_NORMAL = "1";//租户状态:正常
public static final String TENANT_STATUS_DELETED = "9";//租户状态:正常
@ -116,5 +116,35 @@ public class HwDictConstants {
public static final String MONITOR_UNIT_STATUS_NORMAL = "1";//监控单元状态:正常
public static final String MONITORY_UNIT_STATUS_DELETE = "9";//监控单元状态,删除
public static final String TRIGGER_CONDITION_FUNCTION_IDENTIFIER = "identifier";
public static final String TRIGGER_DATA_A = "dataA";
public static final String TRIGGER_DATA_B = "dataB";
public static final String DATA_MORE_THAN_A = "1";
public static final String DATA_LESS_THAN_B = "2";
public static final String DATA_MORE_THAN_A_AND_LESS_THAN_B = "3";
public static final String DATA_LESS_THAN_A_OR_MORE_THAN_B = "4";
public static final String DATA_EQUAL_A = "5";
public static final Map<String, String> triggerConditionMap = new HashMap<String, String>();
static {
triggerConditionMap.put(DATA_MORE_THAN_A, "{" + TRIGGER_CONDITION_FUNCTION_IDENTIFIER + "}" + ">" + TRIGGER_DATA_A);
triggerConditionMap.put(DATA_LESS_THAN_B, "{" + TRIGGER_CONDITION_FUNCTION_IDENTIFIER + "}" + "<" + TRIGGER_DATA_A);
triggerConditionMap.put(DATA_MORE_THAN_A_AND_LESS_THAN_B, "{" + TRIGGER_CONDITION_FUNCTION_IDENTIFIER + "}" + ">" + TRIGGER_DATA_A +
" and " + "{" + TRIGGER_CONDITION_FUNCTION_IDENTIFIER + "}" + "<" + TRIGGER_DATA_B);
triggerConditionMap.put(DATA_LESS_THAN_A_OR_MORE_THAN_B, "{" + TRIGGER_CONDITION_FUNCTION_IDENTIFIER + "}" + "<" + TRIGGER_DATA_A +
" or " + "{" + TRIGGER_CONDITION_FUNCTION_IDENTIFIER + "}" + ">" + TRIGGER_DATA_B);
triggerConditionMap.put(DATA_EQUAL_A, "{" + TRIGGER_CONDITION_FUNCTION_IDENTIFIER + "}" + "=" + TRIGGER_DATA_A);
}
public static final String ALARM_PUSH_FLAG_NO = "0";//报警推送标识:否
public static final String ALARM_PUSH_FLAG_YES = "1";//报警推送标识:是
public static final String ALARM_RULE_LINK_FLAG_NO = "0";//报警联动标识:否
public static final String ALARM_RULE_LINK_FLAG_YES = "1";//报警联动标识:是
public static final String ALARM_RULE_RULE_TYPE_DEVICEMODE="1";//报警规则规则类型:设备模型
public static final String ALARM_RULE_RULE_TYPE_DEVICE="2";//报警规则规则类型:设备
}

@ -0,0 +1,51 @@
package com.ruoyi.common.core.utils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Description:
* @ClassName: RegexUtils
* @Author : xins
* @Date :2023-11-06 11:23
* @Version :1.0
*/
public class RegexUtils {
private static final Pattern P_BRACE = Pattern.compile("\\{(.*?)\\}");
private static final Pattern P_NUMBER = Pattern.compile("[-+]?\\d*\\.?\\d+");
public static final String findContentInBrace(String content){
Matcher matcher = P_BRACE.matcher(content);
while (matcher.find()) {
String match = matcher.group(1);
return match;
}
return "";
}
public static final List<String> findNumberInText(String content){
Matcher matcher = P_NUMBER.matcher(content);
List<String> numbers = new ArrayList<String>();
while (matcher.find()) {
String match = matcher.group();
numbers.add(match);
}
return numbers;
}
public static void main(String[] args) {
System.out.println(findContentInBrace("{ddd}1{ddeeee}"));
String str = "abc-123.0def456.1k888.12";
Pattern pattern =Pattern.compile("[-+]?\\d*\\.?\\d+");
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {
System.out.println(matcher.group());
}
}
}

@ -3,6 +3,10 @@ package com.ruoyi.business.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.business.domain.*;
import com.ruoyi.business.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -15,8 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.HwAlarmRule;
import com.ruoyi.business.service.IHwAlarmRuleService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
@ -24,24 +26,37 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* Controller
*
*
* @author xins
* @date 2023-09-16
* @date 2023-11-02
*/
@RestController
@RequestMapping("/alarmRule")
public class HwAlarmRuleController extends BaseController
{
public class HwAlarmRuleController extends BaseController {
@Autowired
private IHwAlarmRuleService hwAlarmRuleService;
@Autowired
private IHwSceneService hwSceneService;
@Autowired
private IHwAlarmLevelService hwAlarmLevelService;
@Autowired
private IHwAlarmTypeService hwAlarmTypeService;
@Autowired
private IHwDeviceService hwDeviceService;
@Autowired
private IHwDeviceModeService hwDeviceModeService;
/**
*
*/
@RequiresPermissions("business:alarmRule:list")
@GetMapping("/list")
public TableDataInfo list(HwAlarmRule hwAlarmRule)
{
public TableDataInfo list(HwAlarmRule hwAlarmRule) {
startPage();
List<HwAlarmRule> list = hwAlarmRuleService.selectHwAlarmRuleList(hwAlarmRule);
return getDataTable(list);
@ -53,8 +68,7 @@ public class HwAlarmRuleController extends BaseController
@RequiresPermissions("business:alarmRule:export")
@Log(title = "报警规则", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HwAlarmRule hwAlarmRule)
{
public void export(HttpServletResponse response, HwAlarmRule hwAlarmRule) {
List<HwAlarmRule> list = hwAlarmRuleService.selectHwAlarmRuleList(hwAlarmRule);
ExcelUtil<HwAlarmRule> util = new ExcelUtil<HwAlarmRule>(HwAlarmRule.class);
util.exportExcel(response, list, "报警规则数据");
@ -65,8 +79,7 @@ public class HwAlarmRuleController extends BaseController
*/
@RequiresPermissions("business:alarmRule:query")
@GetMapping(value = "/{alarmRuleId}")
public AjaxResult getInfo(@PathVariable("alarmRuleId") Long alarmRuleId)
{
public AjaxResult getInfo(@PathVariable("alarmRuleId") Long alarmRuleId) {
return success(hwAlarmRuleService.selectHwAlarmRuleByAlarmRuleId(alarmRuleId));
}
@ -76,8 +89,7 @@ public class HwAlarmRuleController extends BaseController
@RequiresPermissions("business:alarmRule:add")
@Log(title = "报警规则", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody HwAlarmRule hwAlarmRule)
{
public AjaxResult add(@RequestBody HwAlarmRule hwAlarmRule) {
return toAjax(hwAlarmRuleService.insertHwAlarmRule(hwAlarmRule));
}
@ -87,8 +99,7 @@ public class HwAlarmRuleController extends BaseController
@RequiresPermissions("business:alarmRule:edit")
@Log(title = "报警规则", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody HwAlarmRule hwAlarmRule)
{
public AjaxResult edit(@RequestBody HwAlarmRule hwAlarmRule) {
return toAjax(hwAlarmRuleService.updateHwAlarmRule(hwAlarmRule));
}
@ -97,9 +108,57 @@ public class HwAlarmRuleController extends BaseController
*/
@RequiresPermissions("business:alarmRule:remove")
@Log(title = "报警规则", businessType = BusinessType.DELETE)
@DeleteMapping("/{alarmRuleIds}")
public AjaxResult remove(@PathVariable Long[] alarmRuleIds)
{
@DeleteMapping("/{alarmRuleIds}")
public AjaxResult remove(@PathVariable Long[] alarmRuleIds) {
return toAjax(hwAlarmRuleService.deleteHwAlarmRuleByAlarmRuleIds(alarmRuleIds));
}
@RequiresPermissions("business:alarmRule:list")
@GetMapping("/getScenes")
public AjaxResult getScenes(HwScene scene) {
return success(hwSceneService.selectHwSceneList(scene));
}
@RequiresPermissions("business:alarmRule:list")
@GetMapping("/getEditedScenes")
public AjaxResult getEditedScenes(HwScene scene) {
return success(hwSceneService.selectHwSceneList4Select(scene));
}
@RequiresPermissions("business:alarmRule:list")
@GetMapping("/getSelectListBySceneId/{sceneId}")
public AjaxResult getSelectListBySceneId(@PathVariable("sceneId") Long sceneId) {
HwAlarmType alarmType = new HwAlarmType();
alarmType.setSceneId(sceneId);
List<HwAlarmType> alarmTypes = hwAlarmTypeService.selectHwAlarmTypeList(alarmType);
HwAlarmLevel alarmLevel = new HwAlarmLevel();
alarmLevel.setSceneId(sceneId);
List<HwAlarmLevel> alarmLevels = hwAlarmLevelService.selectHwAlarmLevelList(alarmLevel);
HwDevice device = new HwDevice();
device.setSceneId(sceneId);
List<HwDevice> devices = hwDeviceService.selectHwDeviceListWithDeviceMode(device);
JSONObject result = new JSONObject();
result.put("alarmTypes", alarmTypes);
result.put("alarmLevels",alarmLevels);
result.put("devices",devices);
return success(result);
}
@RequiresPermissions("business:alarmRule:list")
@GetMapping("/getDeviceModeByDeviceId/{deviceId}")
public AjaxResult getDeviceModeByDeviceId(@PathVariable("deviceId") Long deviceId) {
return success(hwDeviceModeService.selectHwDeviceModeByDeviceId(deviceId));
}
@RequiresPermissions("business:alarmRule:list")
@GetMapping("/getModeFunctionParametersByModeFunctionId/{modeFunctionId}")
public AjaxResult getModeFunctionParametersByModeFunctionId(@PathVariable("modeFunctionId") Long modeFunctionId) {
return success(hwDeviceModeService.selectDeviceModeParametersByModeFunctionId(modeFunctionId));
}
}

@ -1,5 +1,6 @@
package com.ruoyi.business.domain;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
@ -9,13 +10,14 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* hw_alarm_rule
*
* @author xins
* @date 2023-09-16
* @date 2023-11-03
*/
public class HwAlarmRule extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 报警规则ID */
/** 报警规则ID主键 */
@Excel(name = "规则ID")
private Long alarmRuleId;
/** 规则名称 */
@ -23,101 +25,89 @@ public class HwAlarmRule extends BaseEntity
private String alarmRuleName;
/** 租户ID关联hw_tenant的tenant_id */
@Excel(name = "租户ID关联hw_tenant的tenant_id")
@Excel(name = "租户ID")
private Long tenantId;
/** 所属场景关联hw_scene表的scene_id字段 */
@Excel(name = "所属场景关联hw_scene表的scene_id字段")
@Excel(name = "场景ID")
private Long sceneId;
/** 语言code,关联表hw_language的language_code字段 */
@Excel(name = "语言code")
private String languageCode;
/** 报警级别关联表hw_alarm_level字段alarm_level_id */
@Excel(name = "报警级别关联表hw_alarm_level字段alarm_level_id")
@Excel(name = "报警级别ID")
private Long alarmLevelId;
/** 报警类型关联表hw_alarm_type字段alarm_type_id */
@Excel(name = "报警类型关联表hw_alarm_type字段alarm_type_id")
@Excel(name = "报警类型ID")
private Long alarmTypeId;
/** 规则类型1、设备模型2、设备 */
@Excel(name = "规则类型", readConverterExp = "1=、设备模型2、设备")
@Excel(name = "规则类型", readConverterExp = "1=设备模型,2=设备")
private String ruleType;
/** 设备关联表hw_device字段device_id */
@Excel(name = "设备关联表hw_device字段device_id")
private Long deviceId;
/** 设备模型关联表hw_device_mode字段device_mode_id */
@Excel(name = "设备模型关联表hw_device_mode字段device_mode_id")
private Long deviceModeId;
/** 设备属性关联表hw_device_mode_function字段mode_function_id */
@Excel(name = "设备属性关联表hw_device_mode_function字段mode_function_id")
private Long modeFunctionId;
/** 触发条件1、数值大于A2、数值小于B3、数值大于A且小于B4、数值小于A或大于B5、数值等于A */
@Excel(name = "触发条件", readConverterExp = "1=、数值大于A2、数值小于B3、数值大于A且小于B4、数值小于A或大于B5、数值等于A")
private String triggerCondition;
/** 触发定义A值 */
@Excel(name = "触发定义A值")
private String triggerDataA;
/** 触发定义B值 */
@Excel(name = "触发定义B值")
private String triggerDataB;
/** 触发死区 */
@Excel(name = "触发死区")
private String triggerDeadzone;
/** 1hw_device_modedevice_mode_id
2hw_devicedevice_id */
@Excel(name = "设备或设备模型ID")
private Long ruleDeviceId;
/** 触发阈值次数 */
@Excel(name = "触发阈值次数")
private Long triggerNumber;
/** 一共有几个属性规则 */
private Long ruleFunctionTotal;
/** 时间范围(单位:分钟) */
@Excel(name = "时间范围", readConverterExp = "单=位:分钟")
private Long triggerTimeFrame;
/** 表达式,例如:{}&gt;60 or {}&lt;-88 */
@Excel(name = "触发规则")
private String triggerExpression;
/** 联动标识1、是0、否 */
@Excel(name = "联动标识", readConverterExp = "1=、是0、否")
@Excel(name = "联动标识", readConverterExp = "1=是,0=否")
private String linkFlag;
/** 联动类型1、控制2、采集 */
@Excel(name = "联动类型", readConverterExp = "1=、控制2、采集")
private String linkType;
/** 联动设备关联表hw_device字段device_id */
@Excel(name = "联动设备关联表hw_device字段device_id")
private Long linkDeviceId;
/** 联动设备功能关联表hw_device_mode_function字段mode_function_id */
@Excel(name = "联动设备功能关联表hw_device_mode_function字段mode_function_id")
private Long linkDeviceFunctionId;
/** 联动设备属性值 */
@Excel(name = "联动设备属性值")
private String linkDeviceFunctionData;
/** 报警启用状态(1、是2、否 */
@Excel(name = "报警启用状态(1、是2、否")
/** 报警启用状态(1、是0、否 */
@Excel(name = "状态", readConverterExp = "1=启用,0=停用")
private String alarmRuleStatus;
/** 报警推送标识(1、是2、否) */
@Excel(name = "报警推送标识(1、是2、否")
/** 报警推送标识(1、是0、否 */
@Excel(name = "报警推送标识", readConverterExp = "1=是,0=否")
private String alarmPushFlag;
/** 报警推送内容 */
@Excel(name = "报警推送内容")
private String alarmPushContent;
/** 恢复正常推送内容 */
@Excel(name = "恢复正常推送内容")
private String alarmRecoverContent;
/** 预留字段 */
@Excel(name = "预留字段")
private String alarmRuleField;
/** 报警规则联动信息信息 */
private List<HwAlarmRuleLink> hwAlarmRuleLinkList;
public String ruleModeFunctionIdentifier;
private String triggerCondition;
private Double triggerDataA;
private Double triggerDataB;
@Excel(name = "所属租户")
private String tenantName;
@Excel(name = "所属场景")
private String sceneName;
@Excel(name = "报警类型")
private String alarmTypeName;
@Excel(name = "报警级别")
private String alarmLevelName;
@Excel(name = "设备")
private String ruleDeviceName;
public void setAlarmRuleId(Long alarmRuleId)
{
this.alarmRuleId = alarmRuleId;
@ -154,6 +144,15 @@ public class HwAlarmRule extends BaseEntity
{
return sceneId;
}
public void setLanguageCode(String languageCode)
{
this.languageCode = languageCode;
}
public String getLanguageCode()
{
return languageCode;
}
public void setAlarmLevelId(Long alarmLevelId)
{
this.alarmLevelId = alarmLevelId;
@ -181,176 +180,168 @@ public class HwAlarmRule extends BaseEntity
{
return ruleType;
}
public void setDeviceId(Long deviceId)
public void setRuleDeviceId(Long ruleDeviceId)
{
this.deviceId = deviceId;
this.ruleDeviceId = ruleDeviceId;
}
public Long getDeviceId()
public Long getRuleDeviceId()
{
return deviceId;
return ruleDeviceId;
}
public void setDeviceModeId(Long deviceModeId)
public void setRuleFunctionTotal(Long ruleFunctionTotal)
{
this.deviceModeId = deviceModeId;
this.ruleFunctionTotal = ruleFunctionTotal;
}
public Long getDeviceModeId()
public Long getRuleFunctionTotal()
{
return deviceModeId;
return ruleFunctionTotal;
}
public void setModeFunctionId(Long modeFunctionId)
public void setTriggerExpression(String triggerExpression)
{
this.modeFunctionId = modeFunctionId;
this.triggerExpression = triggerExpression;
}
public Long getModeFunctionId()
public String getTriggerExpression()
{
return modeFunctionId;
return triggerExpression;
}
public void setTriggerCondition(String triggerCondition)
public void setLinkFlag(String linkFlag)
{
this.triggerCondition = triggerCondition;
this.linkFlag = linkFlag;
}
public String getTriggerCondition()
public String getLinkFlag()
{
return triggerCondition;
return linkFlag;
}
public void setTriggerDataA(String triggerDataA)
public void setAlarmRuleStatus(String alarmRuleStatus)
{
this.triggerDataA = triggerDataA;
this.alarmRuleStatus = alarmRuleStatus;
}
public String getTriggerDataA()
public String getAlarmRuleStatus()
{
return triggerDataA;
return alarmRuleStatus;
}
public void setTriggerDataB(String triggerDataB)
public void setAlarmPushFlag(String alarmPushFlag)
{
this.triggerDataB = triggerDataB;
this.alarmPushFlag = alarmPushFlag;
}
public String getTriggerDataB()
public String getAlarmPushFlag()
{
return triggerDataB;
return alarmPushFlag;
}
public void setTriggerDeadzone(String triggerDeadzone)
public void setAlarmPushContent(String alarmPushContent)
{
this.triggerDeadzone = triggerDeadzone;
this.alarmPushContent = alarmPushContent;
}
public String getTriggerDeadzone()
public String getAlarmPushContent()
{
return triggerDeadzone;
return alarmPushContent;
}
public void setTriggerNumber(Long triggerNumber)
public void setAlarmRecoverContent(String alarmRecoverContent)
{
this.triggerNumber = triggerNumber;
this.alarmRecoverContent = alarmRecoverContent;
}
public Long getTriggerNumber()
public String getAlarmRecoverContent()
{
return triggerNumber;
return alarmRecoverContent;
}
public void setTriggerTimeFrame(Long triggerTimeFrame)
public void setAlarmRuleField(String alarmRuleField)
{
this.triggerTimeFrame = triggerTimeFrame;
this.alarmRuleField = alarmRuleField;
}
public Long getTriggerTimeFrame()
public String getAlarmRuleField()
{
return triggerTimeFrame;
return alarmRuleField;
}
public void setLinkFlag(String linkFlag)
public List<HwAlarmRuleLink> getHwAlarmRuleLinkList()
{
this.linkFlag = linkFlag;
return hwAlarmRuleLinkList;
}
public String getLinkFlag()
public void setHwAlarmRuleLinkList(List<HwAlarmRuleLink> hwAlarmRuleLinkList)
{
return linkFlag;
this.hwAlarmRuleLinkList = hwAlarmRuleLinkList;
}
public void setLinkType(String linkType)
{
this.linkType = linkType;
public String getRuleModeFunctionIdentifier() {
return ruleModeFunctionIdentifier;
}
public String getLinkType()
{
return linkType;
public void setRuleModeFunctionIdentifier(String ruleModeFunctionIdentifier) {
this.ruleModeFunctionIdentifier = ruleModeFunctionIdentifier;
}
public void setLinkDeviceId(Long linkDeviceId)
{
this.linkDeviceId = linkDeviceId;
public String getTriggerCondition() {
return triggerCondition;
}
public Long getLinkDeviceId()
{
return linkDeviceId;
public void setTriggerCondition(String triggerCondition) {
this.triggerCondition = triggerCondition;
}
public void setLinkDeviceFunctionId(Long linkDeviceFunctionId)
{
this.linkDeviceFunctionId = linkDeviceFunctionId;
public Double getTriggerDataA() {
return triggerDataA;
}
public Long getLinkDeviceFunctionId()
{
return linkDeviceFunctionId;
public void setTriggerDataA(Double triggerDataA) {
this.triggerDataA = triggerDataA;
}
public void setLinkDeviceFunctionData(String linkDeviceFunctionData)
{
this.linkDeviceFunctionData = linkDeviceFunctionData;
public Double getTriggerDataB() {
return triggerDataB;
}
public String getLinkDeviceFunctionData()
{
return linkDeviceFunctionData;
public void setTriggerDataB(Double triggerDataB) {
this.triggerDataB = triggerDataB;
}
public void setAlarmRuleStatus(String alarmRuleStatus)
{
this.alarmRuleStatus = alarmRuleStatus;
public String getTenantName() {
return tenantName;
}
public String getAlarmRuleStatus()
{
return alarmRuleStatus;
public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
public void setAlarmPushFlag(String alarmPushFlag)
{
this.alarmPushFlag = alarmPushFlag;
public String getSceneName() {
return sceneName;
}
public String getAlarmPushFlag()
{
return alarmPushFlag;
public void setSceneName(String sceneName) {
this.sceneName = sceneName;
}
public void setAlarmPushContent(String alarmPushContent)
{
this.alarmPushContent = alarmPushContent;
public String getAlarmTypeName() {
return alarmTypeName;
}
public String getAlarmPushContent()
{
return alarmPushContent;
public void setAlarmTypeName(String alarmTypeName) {
this.alarmTypeName = alarmTypeName;
}
public void setAlarmRecoverContent(String alarmRecoverContent)
{
this.alarmRecoverContent = alarmRecoverContent;
public String getAlarmLevelName() {
return alarmLevelName;
}
public String getAlarmRecoverContent()
{
return alarmRecoverContent;
public void setAlarmLevelName(String alarmLevelName) {
this.alarmLevelName = alarmLevelName;
}
public void setAlarmRuleField(String alarmRuleField)
{
this.alarmRuleField = alarmRuleField;
public String getRuleDeviceName() {
return ruleDeviceName;
}
public String getAlarmRuleField()
{
return alarmRuleField;
public void setRuleDeviceName(String ruleDeviceName) {
this.ruleDeviceName = ruleDeviceName;
}
@Override
@ -360,23 +351,14 @@ public class HwAlarmRule extends BaseEntity
.append("alarmRuleName", getAlarmRuleName())
.append("tenantId", getTenantId())
.append("sceneId", getSceneId())
.append("languageCode", getLanguageCode())
.append("alarmLevelId", getAlarmLevelId())
.append("alarmTypeId", getAlarmTypeId())
.append("ruleType", getRuleType())
.append("deviceId", getDeviceId())
.append("deviceModeId", getDeviceModeId())
.append("modeFunctionId", getModeFunctionId())
.append("triggerCondition", getTriggerCondition())
.append("triggerDataA", getTriggerDataA())
.append("triggerDataB", getTriggerDataB())
.append("triggerDeadzone", getTriggerDeadzone())
.append("triggerNumber", getTriggerNumber())
.append("triggerTimeFrame", getTriggerTimeFrame())
.append("ruleDeviceId", getRuleDeviceId())
.append("ruleFunctionTotal", getRuleFunctionTotal())
.append("triggerExpression", getTriggerExpression())
.append("linkFlag", getLinkFlag())
.append("linkType", getLinkType())
.append("linkDeviceId", getLinkDeviceId())
.append("linkDeviceFunctionId", getLinkDeviceFunctionId())
.append("linkDeviceFunctionData", getLinkDeviceFunctionData())
.append("alarmRuleStatus", getAlarmRuleStatus())
.append("alarmPushFlag", getAlarmPushFlag())
.append("alarmPushContent", getAlarmPushContent())
@ -387,6 +369,7 @@ public class HwAlarmRule extends BaseEntity
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("alarmRuleField", getAlarmRuleField())
.append("hwAlarmRuleLinkList", getHwAlarmRuleLinkList())
.toString();
}
}

@ -2,12 +2,13 @@ package com.ruoyi.business.mapper;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmRule;
import com.ruoyi.business.domain.HwAlarmRuleLink;
/**
* Mapper
*
* @author xins
* @date 2023-09-16
* @date 2023-11-03
*/
public interface HwAlarmRuleMapper
{
@ -25,7 +26,7 @@ public interface HwAlarmRuleMapper
* @param hwAlarmRule
* @return
*/
public List<HwAlarmRule> selectHwAlarmRuleList(HwAlarmRule hwAlarmRule);
public List<HwAlarmRule> selectHwAlarmRuleJoinList(HwAlarmRule hwAlarmRule);
/**
*
@ -58,4 +59,29 @@ public interface HwAlarmRuleMapper
* @return
*/
public int deleteHwAlarmRuleByAlarmRuleIds(Long[] alarmRuleIds);
/**
*
*
* @param alarmRuleIds
* @return
*/
public int deleteHwAlarmRuleLinkByAlarmRuleIds(Long[] alarmRuleIds);
/**
*
*
* @param hwAlarmRuleLinkList
* @return
*/
public int batchHwAlarmRuleLink(List<HwAlarmRuleLink> hwAlarmRuleLinkList);
/**
*
*
* @param alarmRuleId ID
* @return
*/
public int deleteHwAlarmRuleLinkByAlarmRuleId(Long alarmRuleId);
}

@ -0,0 +1,61 @@
package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmLevel;
/**
* Service
*
* @author xins
* @date 2023-09-15
*/
public interface IHwAlarmLevelService
{
/**
*
*
* @param alarmLevelId
* @return
*/
public HwAlarmLevel selectHwAlarmLevelByAlarmLevelId(Long alarmLevelId);
/**
*
*
* @param hwAlarmLevel
* @return
*/
public List<HwAlarmLevel> selectHwAlarmLevelList(HwAlarmLevel hwAlarmLevel);
/**
*
*
* @param hwAlarmLevel
* @return
*/
public int insertHwAlarmLevel(HwAlarmLevel hwAlarmLevel);
/**
*
*
* @param hwAlarmLevel
* @return
*/
public int updateHwAlarmLevel(HwAlarmLevel hwAlarmLevel);
/**
*
*
* @param alarmLevelIds
* @return
*/
public int deleteHwAlarmLevelByAlarmLevelIds(Long[] alarmLevelIds);
/**
*
*
* @param alarmLevelId
* @return
*/
public int deleteHwAlarmLevelByAlarmLevelId(Long alarmLevelId);
}

@ -7,7 +7,7 @@ import com.ruoyi.business.domain.HwAlarmRule;
* Service
*
* @author xins
* @date 2023-09-16
* @date 2023-11-03
*/
public interface IHwAlarmRuleService
{

@ -0,0 +1,61 @@
package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmType;
/**
* Service
*
* @author xins
* @date 2023-09-15
*/
public interface IHwAlarmTypeService
{
/**
*
*
* @param alarmTypeId
* @return
*/
public HwAlarmType selectHwAlarmTypeByAlarmTypeId(Long alarmTypeId);
/**
*
*
* @param hwAlarmType
* @return
*/
public List<HwAlarmType> selectHwAlarmTypeList(HwAlarmType hwAlarmType);
/**
*
*
* @param hwAlarmType
* @return
*/
public int insertHwAlarmType(HwAlarmType hwAlarmType);
/**
*
*
* @param hwAlarmType
* @return
*/
public int updateHwAlarmType(HwAlarmType hwAlarmType);
/**
*
*
* @param alarmTypeIds
* @return
*/
public int deleteHwAlarmTypeByAlarmTypeIds(Long[] alarmTypeIds);
/**
*
*
* @param alarmTypeId
* @return
*/
public int deleteHwAlarmTypeByAlarmTypeId(Long alarmTypeId);
}

@ -125,4 +125,13 @@ public interface IHwDeviceModeService
*/
public void rebuildTdSuperTables();
/**
* 使
*
* @param deviceId
* @return
*/
public HwDeviceMode selectHwDeviceModeByDeviceId(Long deviceId);
}

@ -178,4 +178,12 @@ public interface IHwDeviceService
* @return JSONObject
*/
public JSONObject selectDeviceNum(HwDevice device);
/**
* ()
*
* @param hwDevice
* @return
*/
public List<HwDevice> selectHwDeviceListWithDeviceMode(HwDevice hwDevice);
}

@ -0,0 +1,96 @@
package com.ruoyi.business.service.impl;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwAlarmLevelMapper;
import com.ruoyi.business.domain.HwAlarmLevel;
import com.ruoyi.business.service.IHwAlarmLevelService;
/**
* Service
*
* @author xins
* @date 2023-09-15
*/
@Service
public class HwAlarmLevelServiceImpl implements IHwAlarmLevelService
{
@Autowired
private HwAlarmLevelMapper hwAlarmLevelMapper;
/**
*
*
* @param alarmLevelId
* @return
*/
@Override
public HwAlarmLevel selectHwAlarmLevelByAlarmLevelId(Long alarmLevelId)
{
return hwAlarmLevelMapper.selectHwAlarmLevelByAlarmLevelId(alarmLevelId);
}
/**
*
*
* @param hwAlarmLevel
* @return
*/
@Override
public List<HwAlarmLevel> selectHwAlarmLevelList(HwAlarmLevel hwAlarmLevel)
{
return hwAlarmLevelMapper.selectHwAlarmLevelList(hwAlarmLevel);
}
/**
*
*
* @param hwAlarmLevel
* @return
*/
@Override
public int insertHwAlarmLevel(HwAlarmLevel hwAlarmLevel)
{
hwAlarmLevel.setCreateTime(DateUtils.getNowDate());
return hwAlarmLevelMapper.insertHwAlarmLevel(hwAlarmLevel);
}
/**
*
*
* @param hwAlarmLevel
* @return
*/
@Override
public int updateHwAlarmLevel(HwAlarmLevel hwAlarmLevel)
{
hwAlarmLevel.setUpdateTime(DateUtils.getNowDate());
return hwAlarmLevelMapper.updateHwAlarmLevel(hwAlarmLevel);
}
/**
*
*
* @param alarmLevelIds
* @return
*/
@Override
public int deleteHwAlarmLevelByAlarmLevelIds(Long[] alarmLevelIds)
{
return hwAlarmLevelMapper.deleteHwAlarmLevelByAlarmLevelIds(alarmLevelIds);
}
/**
*
*
* @param alarmLevelId
* @return
*/
@Override
public int deleteHwAlarmLevelByAlarmLevelId(Long alarmLevelId)
{
return hwAlarmLevelMapper.deleteHwAlarmLevelByAlarmLevelId(alarmLevelId);
}
}

@ -1,96 +1,196 @@
package com.ruoyi.business.service.impl;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmRule;
import com.ruoyi.business.domain.HwAlarmRuleLink;
import com.ruoyi.business.mapper.HwAlarmRuleMapper;
import com.ruoyi.business.service.IHwAlarmRuleService;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.RegexUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwAlarmRuleMapper;
import com.ruoyi.business.domain.HwAlarmRule;
import com.ruoyi.business.service.IHwAlarmRuleService;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* Service
*
*
* @author xins
* @date 2023-09-16
* @date 2023-11-03
*/
@Service
public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService
{
public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService {
@Autowired
private HwAlarmRuleMapper hwAlarmRuleMapper;
/**
*
*
*
* @param alarmRuleId
* @return
*/
@Override
public HwAlarmRule selectHwAlarmRuleByAlarmRuleId(Long alarmRuleId)
{
return hwAlarmRuleMapper.selectHwAlarmRuleByAlarmRuleId(alarmRuleId);
public HwAlarmRule selectHwAlarmRuleByAlarmRuleId(Long alarmRuleId) {
HwAlarmRule alarmRule = hwAlarmRuleMapper.selectHwAlarmRuleByAlarmRuleId(alarmRuleId);
String triggerExpression = alarmRule.getTriggerExpression();
String triggerCondition = "";
if (triggerExpression.indexOf("and") > 0) {
triggerCondition = HwDictConstants.DATA_MORE_THAN_A_AND_LESS_THAN_B;
} else if (triggerExpression.indexOf("or") > 0) {
triggerCondition = HwDictConstants.DATA_LESS_THAN_A_OR_MORE_THAN_B;
} else if (triggerExpression.indexOf(">") > 0) {
triggerCondition = HwDictConstants.DATA_MORE_THAN_A;
} else if (triggerExpression.indexOf("<") > 0) {
triggerCondition = HwDictConstants.DATA_LESS_THAN_B;
} else if (triggerExpression.indexOf("=") > 0) {
triggerCondition = HwDictConstants.DATA_EQUAL_A;
}
alarmRule.setTriggerCondition(triggerCondition);
String ruleModeFunctionIdentifier = RegexUtils.findContentInBrace(triggerExpression);
alarmRule.setRuleModeFunctionIdentifier(ruleModeFunctionIdentifier);
triggerExpression = triggerExpression.replaceAll(ruleModeFunctionIdentifier, "");
List<String> triggerDataList = RegexUtils.findNumberInText(triggerExpression);
if (triggerDataList.size() == 1) {
alarmRule.setTriggerDataA(Double.valueOf(triggerDataList.get(0)));
} else if (triggerDataList.size() > 1) {
alarmRule.setTriggerDataA(Double.valueOf(triggerDataList.get(0)));
alarmRule.setTriggerDataB(Double.valueOf(triggerDataList.get(1)));
}
return alarmRule;
}
/**
*
*
*
* @param hwAlarmRule
* @return
*/
@Override
public List<HwAlarmRule> selectHwAlarmRuleList(HwAlarmRule hwAlarmRule)
{
return hwAlarmRuleMapper.selectHwAlarmRuleList(hwAlarmRule);
@DataScope(tenantAlias = "har")
public List<HwAlarmRule> selectHwAlarmRuleList(HwAlarmRule hwAlarmRule) {
hwAlarmRule.setRuleType(HwDictConstants.ALARM_RULE_RULE_TYPE_DEVICE);
return hwAlarmRuleMapper.selectHwAlarmRuleJoinList(hwAlarmRule);
}
/**
*
*
*
* @param hwAlarmRule
* @return
*/
@Transactional
@Override
public int insertHwAlarmRule(HwAlarmRule hwAlarmRule)
{
public int insertHwAlarmRule(HwAlarmRule hwAlarmRule) {
String triggerExpression = this.getTriggerExpression(hwAlarmRule);
hwAlarmRule.setTriggerExpression(triggerExpression);
hwAlarmRule.setAlarmPushFlag(HwDictConstants.ALARM_PUSH_FLAG_NO);
hwAlarmRule.setCreateTime(DateUtils.getNowDate());
return hwAlarmRuleMapper.insertHwAlarmRule(hwAlarmRule);
hwAlarmRule.setTenantId(SecurityUtils.getTenantId());
hwAlarmRule.setCreateBy(SecurityUtils.getUsername());
int rows = hwAlarmRuleMapper.insertHwAlarmRule(hwAlarmRule);
insertHwAlarmRuleLink(hwAlarmRule);
return rows;
}
/**
*
*
*
* @param hwAlarmRule
* @return
*/
@Transactional
@Override
public int updateHwAlarmRule(HwAlarmRule hwAlarmRule)
{
public int updateHwAlarmRule(HwAlarmRule hwAlarmRule) {
hwAlarmRule.setUpdateTime(DateUtils.getNowDate());
hwAlarmRule.setUpdateBy(SecurityUtils.getUsername());
String triggerExpression = this.getTriggerExpression(hwAlarmRule);
hwAlarmRule.setTriggerExpression(triggerExpression);
hwAlarmRuleMapper.deleteHwAlarmRuleLinkByAlarmRuleId(hwAlarmRule.getAlarmRuleId());
if (hwAlarmRule.getLinkFlag().equals(HwDictConstants.ALARM_RULE_LINK_FLAG_YES)) {
insertHwAlarmRuleLink(hwAlarmRule);
}
return hwAlarmRuleMapper.updateHwAlarmRule(hwAlarmRule);
}
/**
*
*
*
* @param alarmRuleIds
* @return
*/
@Transactional
@Override
public int deleteHwAlarmRuleByAlarmRuleIds(Long[] alarmRuleIds)
{
public int deleteHwAlarmRuleByAlarmRuleIds(Long[] alarmRuleIds) {
// hwAlarmRuleMapper.deleteHwAlarmRuleLinkByAlarmRuleIds(alarmRuleIds);
return hwAlarmRuleMapper.deleteHwAlarmRuleByAlarmRuleIds(alarmRuleIds);
}
/**
*
*
*
* @param alarmRuleId
* @return
*/
@Transactional
@Override
public int deleteHwAlarmRuleByAlarmRuleId(Long alarmRuleId)
{
public int deleteHwAlarmRuleByAlarmRuleId(Long alarmRuleId) {
hwAlarmRuleMapper.deleteHwAlarmRuleLinkByAlarmRuleId(alarmRuleId);
return hwAlarmRuleMapper.deleteHwAlarmRuleByAlarmRuleId(alarmRuleId);
}
/**
*
*
* @param hwAlarmRule
*/
public void insertHwAlarmRuleLink(HwAlarmRule hwAlarmRule) {
List<HwAlarmRuleLink> hwAlarmRuleLinkList = hwAlarmRule.getHwAlarmRuleLinkList();
Long alarmRuleId = hwAlarmRule.getAlarmRuleId();
if (StringUtils.isNotNull(hwAlarmRuleLinkList)) {
List<HwAlarmRuleLink> list = new ArrayList<HwAlarmRuleLink>();
for (HwAlarmRuleLink hwAlarmRuleLink : hwAlarmRuleLinkList) {
hwAlarmRuleLink.setAlarmRuleId(alarmRuleId);
list.add(hwAlarmRuleLink);
}
if (list.size() > 0) {
hwAlarmRuleMapper.batchHwAlarmRuleLink(list);
}
}
}
/**
* @return String
* @param: alarmRule
* @description
* @author xins
* @date 2023-11-06 10:49
*/
private String getTriggerExpression(HwAlarmRule alarmRule) {
String ruleModeFunctionIdentifier = alarmRule.getRuleModeFunctionIdentifier();
String triggerCondition = alarmRule.getTriggerCondition();
Double triggerDataA = alarmRule.getTriggerDataA();
Double triggerDataB = alarmRule.getTriggerDataB();
String triggerExpression = HwDictConstants.triggerConditionMap.get(triggerCondition);
if (triggerDataA != null) {
triggerExpression = triggerExpression.replaceAll(HwDictConstants.TRIGGER_DATA_A, String.valueOf(triggerDataA));
}
if (triggerDataB != null) {
triggerExpression = triggerExpression.replaceAll(HwDictConstants.TRIGGER_DATA_B, String.valueOf(triggerDataB));
}
triggerExpression = triggerExpression.replaceAll(HwDictConstants.TRIGGER_CONDITION_FUNCTION_IDENTIFIER, ruleModeFunctionIdentifier);
return triggerExpression;
}
}

@ -0,0 +1,96 @@
package com.ruoyi.business.service.impl;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwAlarmTypeMapper;
import com.ruoyi.business.domain.HwAlarmType;
import com.ruoyi.business.service.IHwAlarmTypeService;
/**
* Service
*
* @author xins
* @date 2023-09-15
*/
@Service
public class HwAlarmTypeServiceImpl implements IHwAlarmTypeService
{
@Autowired
private HwAlarmTypeMapper hwAlarmTypeMapper;
/**
*
*
* @param alarmTypeId
* @return
*/
@Override
public HwAlarmType selectHwAlarmTypeByAlarmTypeId(Long alarmTypeId)
{
return hwAlarmTypeMapper.selectHwAlarmTypeByAlarmTypeId(alarmTypeId);
}
/**
*
*
* @param hwAlarmType
* @return
*/
@Override
public List<HwAlarmType> selectHwAlarmTypeList(HwAlarmType hwAlarmType)
{
return hwAlarmTypeMapper.selectHwAlarmTypeList(hwAlarmType);
}
/**
*
*
* @param hwAlarmType
* @return
*/
@Override
public int insertHwAlarmType(HwAlarmType hwAlarmType)
{
hwAlarmType.setCreateTime(DateUtils.getNowDate());
return hwAlarmTypeMapper.insertHwAlarmType(hwAlarmType);
}
/**
*
*
* @param hwAlarmType
* @return
*/
@Override
public int updateHwAlarmType(HwAlarmType hwAlarmType)
{
hwAlarmType.setUpdateTime(DateUtils.getNowDate());
return hwAlarmTypeMapper.updateHwAlarmType(hwAlarmType);
}
/**
*
*
* @param alarmTypeIds
* @return
*/
@Override
public int deleteHwAlarmTypeByAlarmTypeIds(Long[] alarmTypeIds)
{
return hwAlarmTypeMapper.deleteHwAlarmTypeByAlarmTypeIds(alarmTypeIds);
}
/**
*
*
* @param alarmTypeId
* @return
*/
@Override
public int deleteHwAlarmTypeByAlarmTypeId(Long alarmTypeId)
{
return hwAlarmTypeMapper.deleteHwAlarmTypeByAlarmTypeId(alarmTypeId);
}
}

@ -383,6 +383,30 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
});
}
/**
* 使
*
* @param deviceId
* @return
*/
@Override
public HwDeviceMode selectHwDeviceModeByDeviceId(Long deviceId) {
HwDevice device = hwDeviceMapper.selectHwDeviceByDeviceId(deviceId);
HwDeviceMode deviceMode = hwDeviceModeMapper.selectHwDeviceModeByDeviceModeId(device.getDeviceModeId());
List<HwDeviceModeFunction> deviceModeFunctions = deviceMode.getHwDeviceModeFunctionList();
//过滤只有数值的属性才可以定义报警规则.或过滤出服务可以添加关联设备
List<HwDeviceModeFunction> filterDeviceModeFunctions = deviceModeFunctions.stream()
.filter(deviceModeFunction -> (deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) &&
deviceModeFunction.getDataType()!=null && (String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.INT.getDataCode()))
|| String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.FLOAT.getDataCode()))
|| String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.DOUBLE.getDataCode()))))
|| (deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_SERVICE)))
.collect(Collectors.toList());
deviceMode.setHwDeviceModeFunctionList(filterDeviceModeFunctions);
return deviceMode;
}
/**
* @param: hwDeviceModeFunction
* @description

@ -3,7 +3,10 @@ package com.ruoyi.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.business.domain.*;
import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.HwScene;
import com.ruoyi.business.domain.VO.DeviceControlVo;
import com.ruoyi.business.domain.VO.DeviceModeVo;
import com.ruoyi.business.domain.VO.DevicesInfoVo;
@ -31,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -108,9 +110,6 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override
public List<HwDevice> selectLinkDeviceList(Long deviceId) {
List<HwDevice> devices = hwDeviceMapper.selectLinkedDevices(deviceId);
for (HwDevice device : devices) {
device.setDevicePic("http://175.27.215.92:9665/statics/2023/09/23/6793e53d7418643c6ea9abe29be2bdce_20230923183352A001.jpg");
}
return devices;
}
@ -124,7 +123,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override
public int insertHwDevice(HwDevice hwDevice) {
HwDevice duplicateDevice = hwDeviceMapper.selectHwDeviceByDeviceCode(hwDevice.getDeviceCode());
if(duplicateDevice != null){
if (duplicateDevice != null) {
throw new ServiceException("设备编号已经存在,请修改");
}
hwDevice.setCreateTime(DateUtils.getNowDate());
@ -695,11 +694,11 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
/**
* @return JSONObject
* @param: device
* @description
* @author xins
* @date 2023-10-20 10:08
* @return JSONObject
*/
@Override
public JSONObject selectDeviceNum(HwDevice device) {
@ -768,6 +767,18 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
}
/**
* ()
*
* @param hwDevice
* @return
*/
@Override
@DataScope(tenantAlias = "hd")
public List<HwDevice> selectHwDeviceListWithDeviceMode(HwDevice hwDevice) {
return hwDeviceMapper.selectHwDeviceListByMonitor(hwDevice);
}
private Map<Long, Integer> computeDeviceCountPerDay(Long startTime, Long endTime) {
//先增加需要查询的字段名称由于tdengine用last和last_row查询时字段显示有bug所以需要设置要查询的字段
List<TdField> schemaFields = new ArrayList<TdField>();

@ -9,23 +9,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="alarmRuleName" column="alarm_rule_name" />
<result property="tenantId" column="tenant_id" />
<result property="sceneId" column="scene_id" />
<result property="languageCode" column="language_code" />
<result property="alarmLevelId" column="alarm_level_id" />
<result property="alarmTypeId" column="alarm_type_id" />
<result property="ruleType" column="rule_type" />
<result property="deviceId" column="device_id" />
<result property="deviceModeId" column="device_mode_id" />
<result property="modeFunctionId" column="mode_function_id" />
<result property="triggerCondition" column="trigger_condition" />
<result property="triggerDataA" column="trigger_data_a" />
<result property="triggerDataB" column="trigger_data_b" />
<result property="triggerDeadzone" column="trigger_deadzone" />
<result property="triggerNumber" column="trigger_number" />
<result property="triggerTimeFrame" column="trigger_time_frame" />
<result property="ruleDeviceId" column="rule_device_id" />
<result property="ruleFunctionTotal" column="rule_function_total" />
<result property="triggerExpression" column="trigger_expression" />
<result property="linkFlag" column="link_flag" />
<result property="linkType" column="link_type" />
<result property="linkDeviceId" column="link_device_id" />
<result property="linkDeviceFunctionId" column="link_device_function_id" />
<result property="linkDeviceFunctionData" column="link_device_function_data" />
<result property="alarmRuleStatus" column="alarm_rule_status" />
<result property="alarmPushFlag" column="alarm_push_flag" />
<result property="alarmPushContent" column="alarm_push_content" />
@ -36,46 +27,77 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="alarmRuleField" column="alarm_rule_field" />
<result property="tenantName" column="tenant_name" />
<result property="sceneName" column="scene_name" />
<result property="alarmTypeName" column="alarm_type_name" />
<result property="alarmLevelName" column="alarm_level_name" />
<result property="ruleDeviceName" column="device_name" />
</resultMap>
<resultMap id="HwAlarmRuleHwAlarmRuleLinkResult" type="HwAlarmRule" extends="HwAlarmRuleResult">
<collection property="hwAlarmRuleLinkList" notNullColumn="sub_rule_link_id" javaType="java.util.List" resultMap="HwAlarmRuleLinkResult" />
</resultMap>
<resultMap type="HwAlarmRuleLink" id="HwAlarmRuleLinkResult">
<result property="ruleLinkId" column="sub_rule_link_id" />
<result property="alarmRuleId" column="sub_alarm_rule_id" />
<result property="linkType" column="sub_link_type" />
<result property="linkDeviceId" column="sub_link_device_id" />
<result property="linkDeviceFunctionId" column="sub_link_device_function_id" />
<result property="linkDeviceFunctionIdentifier" column="sub_link_device_function_identifier" />
<result property="linkDeviceFunctionData" column="sub_link_device_function_data" />
<result property="linkDeviceName" column="sub_link_device_name" />
<result property="linkDeviceModeFunctionName" column="sub_link_device_mode_function_name" />
</resultMap>
<sql id="selectHwAlarmRuleVo">
select alarm_rule_id, alarm_rule_name, tenant_id, scene_id, alarm_level_id, alarm_type_id, rule_type, device_id, device_mode_id, mode_function_id, trigger_condition, trigger_data_a, trigger_data_b, trigger_deadzone, trigger_number, trigger_time_frame, link_flag, link_type, link_device_id, link_device_function_id, link_device_function_data, alarm_rule_status, alarm_push_flag, alarm_push_content, alarm_recover_content, remark, create_by, create_time, update_by, update_time, alarm_rule_field from hw_alarm_rule
select alarm_rule_id, alarm_rule_name, tenant_id, scene_id, language_code, alarm_level_id, alarm_type_id, rule_type, rule_device_id, rule_function_total, trigger_expression, link_flag, alarm_rule_status, alarm_push_flag, alarm_push_content, alarm_recover_content, remark, create_by, create_time, update_by, update_time, alarm_rule_field from hw_alarm_rule
</sql>
<select id="selectHwAlarmRuleList" parameterType="HwAlarmRule" resultMap="HwAlarmRuleResult">
<include refid="selectHwAlarmRuleVo"/>
<where>
<if test="alarmRuleName != null and alarmRuleName != ''"> and alarm_rule_name like concat('%', #{alarmRuleName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="alarmLevelId != null "> and alarm_level_id = #{alarmLevelId}</if>
<if test="alarmTypeId != null "> and alarm_type_id = #{alarmTypeId}</if>
<if test="ruleType != null and ruleType != ''"> and rule_type = #{ruleType}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="deviceModeId != null "> and device_mode_id = #{deviceModeId}</if>
<if test="modeFunctionId != null "> and mode_function_id = #{modeFunctionId}</if>
<if test="triggerCondition != null and triggerCondition != ''"> and trigger_condition = #{triggerCondition}</if>
<if test="triggerDataA != null and triggerDataA != ''"> and trigger_data_a = #{triggerDataA}</if>
<if test="triggerDataB != null and triggerDataB != ''"> and trigger_data_b = #{triggerDataB}</if>
<if test="triggerDeadzone != null and triggerDeadzone != ''"> and trigger_deadzone = #{triggerDeadzone}</if>
<if test="triggerNumber != null "> and trigger_number = #{triggerNumber}</if>
<if test="triggerTimeFrame != null "> and trigger_time_frame = #{triggerTimeFrame}</if>
<if test="linkFlag != null and linkFlag != ''"> and link_flag = #{linkFlag}</if>
<if test="linkType != null and linkType != ''"> and link_type = #{linkType}</if>
<if test="linkDeviceId != null "> and link_device_id = #{linkDeviceId}</if>
<if test="linkDeviceFunctionId != null "> and link_device_function_id = #{linkDeviceFunctionId}</if>
<if test="linkDeviceFunctionData != null and linkDeviceFunctionData != ''"> and link_device_function_data = #{linkDeviceFunctionData}</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''"> and alarm_rule_status = #{alarmRuleStatus}</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''"> and alarm_push_flag = #{alarmPushFlag}</if>
<if test="alarmPushContent != null and alarmPushContent != ''"> and alarm_push_content = #{alarmPushContent}</if>
<if test="alarmRecoverContent != null and alarmRecoverContent != ''"> and alarm_recover_content = #{alarmRecoverContent}</if>
<if test="alarmRuleField != null and alarmRuleField != ''"> and alarm_rule_field = #{alarmRuleField}</if>
<select id="selectHwAlarmRuleJoinList" parameterType="HwAlarmRule" resultMap="HwAlarmRuleResult">
select har.alarm_rule_id,har.alarm_rule_name, har.alarm_type_id,har.alarm_level_id,har.scene_id,
har.link_flag,har.alarm_rule_status,har.alarm_push_flag,har.tenant_id,har.trigger_expression,har.rule_device_id,har.rule_type,har.language_code,
ht.tenant_name,hs.scene_name,hat.alarm_type_name,hal.alarm_level_name,hd.device_name
from hw_alarm_rule har
left join hw_tenant ht on har.tenant_id=ht.tenant_id
left join hw_scene hs on har.scene_id=hs.scene_id
left join hw_alarm_type hat on har.alarm_type_id= hat.alarm_type_id
left join hw_alarm_level hal on har.alarm_level_id = hal.alarm_level_id
left join hw_device hd on har.rule_device_id=hd.device_id
<where>
har.alarm_rule_status !='9'
<if test="alarmRuleName != null and alarmRuleName != ''"> and har.alarm_rule_name like concat('%', #{alarmRuleName}, '%')</if>
<if test="tenantId != null "> and har.tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and har.scene_id = #{sceneId}</if>
<if test="languageCode != null and languageCode != ''"> and har.language_code = #{languageCode}</if>
<if test="alarmLevelId != null "> and har.alarm_level_id = #{alarmLevelId}</if>
<if test="alarmTypeId != null "> and har.alarm_type_id = #{alarmTypeId}</if>
<if test="ruleType != null and ruleType != ''"> and har.rule_type = #{ruleType}</if>
<if test="ruleDeviceId != null "> and har.rule_device_id = #{ruleDeviceId}</if>
<if test="ruleFunctionTotal != null "> and har.rule_function_total = #{ruleFunctionTotal}</if>
<if test="triggerExpression != null and triggerExpression != ''"> and har.trigger_expression = #{triggerExpression}</if>
<if test="linkFlag != null and linkFlag != ''"> and har.link_flag = #{linkFlag}</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''"> and har.alarm_rule_status = #{alarmRuleStatus}</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''"> and har.alarm_push_flag = #{alarmPushFlag}</if>
<if test="alarmPushContent != null and alarmPushContent != ''"> and har.alarm_push_content = #{alarmPushContent}</if>
<if test="alarmRecoverContent != null and alarmRecoverContent != ''"> and har.alarm_recover_content = #{alarmRecoverContent}</if>
<if test="alarmRuleField != null and alarmRuleField != ''"> and har.alarm_rule_field = #{alarmRuleField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
order by har.alarm_rule_id desc
</select>
<select id="selectHwAlarmRuleByAlarmRuleId" parameterType="Long" resultMap="HwAlarmRuleResult">
<include refid="selectHwAlarmRuleVo"/>
where alarm_rule_id = #{alarmRuleId}
<select id="selectHwAlarmRuleByAlarmRuleId" parameterType="Long" resultMap="HwAlarmRuleHwAlarmRuleLinkResult">
select a.alarm_rule_id, a.alarm_rule_name, a.tenant_id, a.scene_id, a.language_code, a.alarm_level_id, a.alarm_type_id, a.rule_type, a.rule_device_id, a.rule_function_total, a.trigger_expression, a.link_flag, a.alarm_rule_status, a.alarm_push_flag, a.alarm_push_content, a.alarm_recover_content, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.alarm_rule_field,
b.rule_link_id as sub_rule_link_id, b.alarm_rule_id as sub_alarm_rule_id, b.link_type as sub_link_type, b.link_device_id as sub_link_device_id, b.link_device_function_id as sub_link_device_function_id, b.link_device_function_identifier as sub_link_device_function_identifier, b.link_device_function_data as sub_link_device_function_data, hd.device_name as sub_link_device_name,hdmf.function_name as sub_link_device_mode_function_name
from hw_alarm_rule a
left join hw_alarm_rule_link b on b.alarm_rule_id = a.alarm_rule_id
left join hw_device hd on b.link_device_id = hd.device_id
left join hw_device_mode_function hdmf on b.link_device_function_id=hdmf.mode_function_id
where a.alarm_rule_id = #{alarmRuleId}
</select>
<insert id="insertHwAlarmRule" parameterType="HwAlarmRule" useGeneratedKeys="true" keyProperty="alarmRuleId">
@ -84,23 +106,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alarmRuleName != null and alarmRuleName != ''">alarm_rule_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneId != null">scene_id,</if>
<if test="languageCode != null">language_code,</if>
<if test="alarmLevelId != null">alarm_level_id,</if>
<if test="alarmTypeId != null">alarm_type_id,</if>
<if test="ruleType != null and ruleType != ''">rule_type,</if>
<if test="deviceId != null">device_id,</if>
<if test="deviceModeId != null">device_mode_id,</if>
<if test="modeFunctionId != null">mode_function_id,</if>
<if test="triggerCondition != null and triggerCondition != ''">trigger_condition,</if>
<if test="triggerDataA != null and triggerDataA != ''">trigger_data_a,</if>
<if test="triggerDataB != null">trigger_data_b,</if>
<if test="triggerDeadzone != null">trigger_deadzone,</if>
<if test="triggerNumber != null">trigger_number,</if>
<if test="triggerTimeFrame != null">trigger_time_frame,</if>
<if test="ruleDeviceId != null">rule_device_id,</if>
<if test="ruleFunctionTotal != null">rule_function_total,</if>
<if test="triggerExpression != null and triggerExpression != ''">trigger_expression,</if>
<if test="linkFlag != null and linkFlag != ''">link_flag,</if>
<if test="linkType != null">link_type,</if>
<if test="linkDeviceId != null">link_device_id,</if>
<if test="linkDeviceFunctionId != null">link_device_function_id,</if>
<if test="linkDeviceFunctionData != null">link_device_function_data,</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">alarm_rule_status,</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''">alarm_push_flag,</if>
<if test="alarmPushContent != null">alarm_push_content,</if>
@ -116,23 +129,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alarmRuleName != null and alarmRuleName != ''">#{alarmRuleName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="languageCode != null">#{languageCode},</if>
<if test="alarmLevelId != null">#{alarmLevelId},</if>
<if test="alarmTypeId != null">#{alarmTypeId},</if>
<if test="ruleType != null and ruleType != ''">#{ruleType},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="deviceModeId != null">#{deviceModeId},</if>
<if test="modeFunctionId != null">#{modeFunctionId},</if>
<if test="triggerCondition != null and triggerCondition != ''">#{triggerCondition},</if>
<if test="triggerDataA != null and triggerDataA != ''">#{triggerDataA},</if>
<if test="triggerDataB != null">#{triggerDataB},</if>
<if test="triggerDeadzone != null">#{triggerDeadzone},</if>
<if test="triggerNumber != null">#{triggerNumber},</if>
<if test="triggerTimeFrame != null">#{triggerTimeFrame},</if>
<if test="ruleDeviceId != null">#{ruleDeviceId},</if>
<if test="ruleFunctionTotal != null">#{ruleFunctionTotal},</if>
<if test="triggerExpression != null and triggerExpression != ''">#{triggerExpression},</if>
<if test="linkFlag != null and linkFlag != ''">#{linkFlag},</if>
<if test="linkType != null">#{linkType},</if>
<if test="linkDeviceId != null">#{linkDeviceId},</if>
<if test="linkDeviceFunctionId != null">#{linkDeviceFunctionId},</if>
<if test="linkDeviceFunctionData != null">#{linkDeviceFunctionData},</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">#{alarmRuleStatus},</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''">#{alarmPushFlag},</if>
<if test="alarmPushContent != null">#{alarmPushContent},</if>
@ -152,23 +156,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alarmRuleName != null and alarmRuleName != ''">alarm_rule_name = #{alarmRuleName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="languageCode != null">language_code = #{languageCode},</if>
<if test="alarmLevelId != null">alarm_level_id = #{alarmLevelId},</if>
<if test="alarmTypeId != null">alarm_type_id = #{alarmTypeId},</if>
<if test="ruleType != null and ruleType != ''">rule_type = #{ruleType},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deviceModeId != null">device_mode_id = #{deviceModeId},</if>
<if test="modeFunctionId != null">mode_function_id = #{modeFunctionId},</if>
<if test="triggerCondition != null and triggerCondition != ''">trigger_condition = #{triggerCondition},</if>
<if test="triggerDataA != null and triggerDataA != ''">trigger_data_a = #{triggerDataA},</if>
<if test="triggerDataB != null">trigger_data_b = #{triggerDataB},</if>
<if test="triggerDeadzone != null">trigger_deadzone = #{triggerDeadzone},</if>
<if test="triggerNumber != null">trigger_number = #{triggerNumber},</if>
<if test="triggerTimeFrame != null">trigger_time_frame = #{triggerTimeFrame},</if>
<if test="ruleDeviceId != null">rule_device_id = #{ruleDeviceId},</if>
<if test="ruleFunctionTotal != null">rule_function_total = #{ruleFunctionTotal},</if>
<if test="triggerExpression != null and triggerExpression != ''">trigger_expression = #{triggerExpression},</if>
<if test="linkFlag != null and linkFlag != ''">link_flag = #{linkFlag},</if>
<if test="linkType != null">link_type = #{linkType},</if>
<if test="linkDeviceId != null">link_device_id = #{linkDeviceId},</if>
<if test="linkDeviceFunctionId != null">link_device_function_id = #{linkDeviceFunctionId},</if>
<if test="linkDeviceFunctionData != null">link_device_function_data = #{linkDeviceFunctionData},</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">alarm_rule_status = #{alarmRuleStatus},</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''">alarm_push_flag = #{alarmPushFlag},</if>
<if test="alarmPushContent != null">alarm_push_content = #{alarmPushContent},</if>
@ -188,9 +183,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteHwAlarmRuleByAlarmRuleIds" parameterType="String">
delete from hw_alarm_rule where alarm_rule_id in
update hw_alarm_rule set alarm_rule_status='9' where alarm_rule_id in
<foreach item="alarmRuleId" collection="array" open="(" separator="," close=")">
#{alarmRuleId}
</foreach>
</delete>
<delete id="deleteHwAlarmRuleLinkByAlarmRuleIds" parameterType="String">
delete from hw_alarm_rule_link where alarm_rule_id in
<foreach item="alarmRuleId" collection="array" open="(" separator="," close=")">
#{alarmRuleId}
</foreach>
</delete>
<delete id="deleteHwAlarmRuleLinkByAlarmRuleId" parameterType="Long">
delete from hw_alarm_rule_link where alarm_rule_id = #{alarmRuleId}
</delete>
<insert id="batchHwAlarmRuleLink">
insert into hw_alarm_rule_link( rule_link_id, alarm_rule_id, link_type, link_device_id, link_device_function_id, link_device_function_identifier, link_device_function_data) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.ruleLinkId}, #{item.alarmRuleId}, #{item.linkType}, #{item.linkDeviceId}, #{item.linkDeviceFunctionId}, #{item.linkDeviceFunctionIdentifier}, #{item.linkDeviceFunctionData})
</foreach>
</insert>
</mapper>
Loading…
Cancel
Save