规则优化

This commit is contained in:
zhanghan11 2024-11-15 08:48:25 +08:00
parent 9238822f22
commit 7c10a7274d
3 changed files with 46 additions and 36 deletions

View File

@ -93,11 +93,13 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService {
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int insertIpcAlarmRules(IpcAlarmRules ipcAlarmRules) { public int insertIpcAlarmRules(IpcAlarmRules ipcAlarmRules) {
int num = ipcAlarmRulesMapper.insertIpcAlarmRules(ipcAlarmRules); int num = ipcAlarmRulesMapper.insertIpcAlarmRules(ipcAlarmRules);
List<IpcAlarmRules> rulesList = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId()); if (num > 0) {
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + ipcAlarmRules.getEquipId()), rulesList); List<IpcAlarmRules> rulesList = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId());
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.RUNNING + CacheConstants.SEPARATOR + ipcAlarmRules.getEquipId()), rulesList.stream().filter(rules -> Constant.RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.TRY_RUNNING + CacheConstants.SEPARATOR + ipcAlarmRules.getEquipId()), rulesList.stream().filter(rules -> Constant.TRY_RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
}
return num; return num;
} }
@ -111,8 +113,9 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService {
public int updateIpcAlarmRules(IpcAlarmRules ipcAlarmRules) { public int updateIpcAlarmRules(IpcAlarmRules ipcAlarmRules) {
int num = ipcAlarmRulesMapper.updateIpcAlarmRules(ipcAlarmRules); int num = ipcAlarmRulesMapper.updateIpcAlarmRules(ipcAlarmRules);
if (num > 0) { if (num > 0) {
List<IpcAlarmRules> rules = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId()); List<IpcAlarmRules> rulesList = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId());
redisCache.setCacheObject(CacheConstants.IPC_RULES_KEY + ipcAlarmRules.getEquipId(), rules); redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.RUNNING + CacheConstants.SEPARATOR + ipcAlarmRules.getEquipId()), rulesList.stream().filter(rules -> Constant.RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.TRY_RUNNING + CacheConstants.SEPARATOR + ipcAlarmRules.getEquipId()), rulesList.stream().filter(rules -> Constant.TRY_RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
} }
return num; return num;
} }
@ -126,9 +129,12 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService {
@Override @Override
public int deleteIpcAlarmRulesByIds(String[] ids) { public int deleteIpcAlarmRulesByIds(String[] ids) {
int num = ipcAlarmRulesMapper.deleteIpcAlarmRulesByIds(ids); int num = ipcAlarmRulesMapper.deleteIpcAlarmRulesByIds(ids);
IpcAlarmRules ipcAlarmRules = selectIpcAlarmRulesById(ids[0]); if (num > 0) {
List<IpcAlarmRules> rules = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId()); IpcAlarmRules ipcAlarmRules = selectIpcAlarmRulesById(ids[0]);
redisCache.setCacheObject(CacheConstants.IPC_RULES_KEY + ipcAlarmRules.getEquipId(), rules); List<IpcAlarmRules> rulesList = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId());
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.RUNNING + CacheConstants.SEPARATOR + ipcAlarmRules.getEquipId()), rulesList.stream().filter(rules -> Constant.RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.TRY_RUNNING + CacheConstants.SEPARATOR + ipcAlarmRules.getEquipId()), rulesList.stream().filter(rules -> Constant.TRY_RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
}
return num; return num;
} }
@ -141,9 +147,12 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService {
@Override @Override
public int deleteIpcAlarmRulesById(String id) { public int deleteIpcAlarmRulesById(String id) {
int num = ipcAlarmRulesMapper.deleteIpcAlarmRulesById(id); int num = ipcAlarmRulesMapper.deleteIpcAlarmRulesById(id);
IpcAlarmRules ipcAlarmRules = selectIpcAlarmRulesById(id); if (num > 0) {
List<IpcAlarmRules> rules = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId()); IpcAlarmRules ipcAlarmRules = selectIpcAlarmRulesById(id);
redisCache.setCacheObject(CacheConstants.IPC_RULES_KEY + ipcAlarmRules.getEquipId(), rules); List<IpcAlarmRules> rulesList = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId());
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.RUNNING + CacheConstants.SEPARATOR + ipcAlarmRules.getEquipId()), rulesList.stream().filter(rules -> Constant.RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.TRY_RUNNING + CacheConstants.SEPARATOR + ipcAlarmRules.getEquipId()), rulesList.stream().filter(rules -> Constant.TRY_RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
}
return num; return num;
} }

View File

@ -38,9 +38,9 @@ public class Constant {
public static final String OUTSIDE_INTERVAL = "区间外"; public static final String OUTSIDE_INTERVAL = "区间外";
/** /**
* 区间外根据基准值确定上下限 * 区间外根据基准值上下波动
*/ */
public static final String BASE_VALUE = "区间外(根据基准值确定上下限"; public static final String BASE_VALUE = "区间外(根据基准值上下波动";
/** /**
* 区间外根据基准值范围精确设置 * 区间外根据基准值范围精确设置

View File

@ -703,21 +703,6 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12">
<el-form-item
label="报警上限值"
prop="alertUpperBound"
>
<el-input-number
v-model="form.alertUpperBound"
placeholder="请输入报警上限值"
:precision="2"
:step="0.1"
:max="1000000"
:min="-1000000"
></el-input-number>
</el-form-item>
</el-col>
<el-col <el-col
:span="12" :span="12"
v-if="form.referenceCon && form.referenceCon.startsWith('区间')" v-if="form.referenceCon && form.referenceCon.startsWith('区间')"
@ -750,6 +735,22 @@
></el-input-number> ></el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item prop="alertUpperBound">
<template slot="label">
<span v-if="form.referenceCon && form.referenceCon.startsWith('区间')">报警上限值</span>
<span v-else>报警值</span>
</template>
<el-input-number
v-model="form.alertUpperBound"
placeholder="请输入报警上限值"
:precision="2"
:step="0.1"
:max="1000000"
:min="-1000000"
></el-input-number>
</el-form-item>
</el-col>
</el-row> </el-row>
<el-row v-if="form.referenceCon && form.referenceCon.startsWith('区间外(')"> <el-row v-if="form.referenceCon && form.referenceCon.startsWith('区间外(')">
<el-col :span="12"> <el-col :span="12">
@ -776,12 +777,12 @@
<el-row v-if="form.referenceCon=='区间外(根据基准值范围精确设置)'"> <el-row v-if="form.referenceCon=='区间外(根据基准值范围精确设置)'">
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="基准值范围限值" label="基准值范围限值"
prop="baseValueUpperBound" prop="baseValueLowerBound"
> >
<el-input-number <el-input-number
v-model="form.baseValueUpperBound" v-model="form.baseValueLowerBound"
placeholder="请输入基准值范围限值" placeholder="请输入基准值范围限值"
:precision="2" :precision="2"
:step="0.1" :step="0.1"
:max="1000000" :max="1000000"
@ -791,12 +792,12 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="基准值范围限值" label="基准值范围限值"
prop="baseValueLowerBound" prop="baseValueUpperBound"
> >
<el-input-number <el-input-number
v-model="form.baseValueLowerBound" v-model="form.baseValueUpperBound"
placeholder="请输入基准值范围限值" placeholder="请输入基准值范围限值"
:precision="2" :precision="2"
:step="0.1" :step="0.1"
:max="1000000" :max="1000000"