数据展示优化

This commit is contained in:
zhanghan11 2024-11-18 15:06:32 +08:00
parent ba2e3a0058
commit 2bd3f29992
20 changed files with 561 additions and 27 deletions

View File

@ -49,14 +49,14 @@ public class IpcAlarmRecordController extends BaseController
} }
/** /**
* 查询所有报警记录 * 查询所有报警记录最多1000条
* @param ipcAlarmRecord * @param ipcAlarmRecord
* @return * @return
*/ */
@GetMapping("/listAll") @GetMapping("/listAll")
public AjaxResult listAll(IpcAlarmRecord ipcAlarmRecord) public AjaxResult listAll(IpcAlarmRecord ipcAlarmRecord)
{ {
List<IpcAlarmRecord> list = ipcAlarmRecordService.selectIpcAlarmRecordList(ipcAlarmRecord); List<IpcAlarmRecord> list = ipcAlarmRecordService.selectIpcAlarmRecordListAll(ipcAlarmRecord);
return AjaxResult.success(list); return AjaxResult.success(list);
} }

View File

@ -9,7 +9,7 @@ spring:
# url: jdbc:mysql://117.73.8.43:3306/phm?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://117.73.8.43:3306/phm?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: phm # username: phm
# password: Y123456a # password: Y123456a
url: jdbc:mysql://117.73.2.117:3306/zfipc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://localhost:3306/zfipc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: zfipc username: zfipc
password: Y123456a password: Y123456a
# 从库数据源 # 从库数据源

View File

@ -15,7 +15,9 @@ zfipc:
# 验证码类型 math 数组计算 char 字符验证 # 验证码类型 math 数组计算 char 字符验证
captchaType: math captchaType: math
# 自定义参数,判定是云端还是工控机端,云端-cloud工控机端-client其他-other # 自定义参数,判定是云端还是工控机端,云端-cloud工控机端-client其他-other
model: client1 model: client
# 部门ID
deptId: 100
# 开发环境配置 # 开发环境配置
server: server:
@ -147,7 +149,7 @@ datasyn:
host: 10.124.7.12 host: 10.124.7.12
port: 502 port: 502
influxdb: influxdb:
url: http://117.73.2.117:8086 url: http://localhost:8086
userName: zfipc userName: zfipc
password: Y123456a password: Y123456a
database: zfipc database: zfipc

View File

@ -147,7 +147,7 @@ public class Constants
/** /**
* influxdb表名-超压底缸 * influxdb表名-超压底缸
*/ */
public static final String MEASUREMENT_TOP_SCOLLER="zfipc_industrial_monitor_data1"; public static final String MEASUREMENT_TOP_SCOLLER="zfipc_industrial_monitor_data2";
/** /**
* influxdb表名-超压底缸 * influxdb表名-超压底缸
*/ */
@ -158,11 +158,11 @@ public class Constants
*/ */
public static final String EQUIPID_BOTTOM_CY_LINDER="e2ae4710b516419c84d1d4a819429348"; public static final String EQUIPID_BOTTOM_CY_LINDER="e2ae4710b516419c84d1d4a819429348";
/** /**
* 设备ID-超压底缸 * 设备ID-可控中高辊顶辊
*/ */
public static final String EQUIPID_TOP_SCOLLER="5d6c1a1374ea490a91e1361c1f5400aa"; public static final String EQUIPID_TOP_SCOLLER="5d6c1a1374ea490a91e1361c1f5400aa";
/** /**
* 设备ID-超压底缸 * 设备ID-可控中高辊底辊
*/ */
public static final String EQUIPID_BOTTOM_SCOLLER="8b2d5cb04e254c15ade1e53a4f594f3f"; public static final String EQUIPID_BOTTOM_SCOLLER="8b2d5cb04e254c15ade1e53a4f594f3f";
} }

View File

@ -193,7 +193,7 @@ public class IpcDataProcess implements Runnable {
i.insert(measurement, tags, fields); i.insert(measurement, tags, fields);
if (!alarmRecordList.isEmpty()) {//运行需放开 if (!alarmRecordList.isEmpty()) {//运行需放开
// alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList); alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
} }
} }
@ -300,9 +300,10 @@ public class IpcDataProcess implements Runnable {
fields.put("ipc_status", results.getValue(102)); fields.put("ipc_status", results.getValue(102));
//报警处理 //报警处理
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(Constant.RUNNING,equipId); List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(Constant.RUNNING,equipId);
System.out.println("rulesList:"+fields);
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则 alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则
if (!alarmRecordList.isEmpty()) {//运行需放开 if (!alarmRecordList.isEmpty()) {//运行需放开
// alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList); alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
} }
i.insert(measurement, tags, fields); i.insert(measurement, tags, fields);
} }
@ -411,7 +412,7 @@ public class IpcDataProcess implements Runnable {
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(Constant.RUNNING,equipId); List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(Constant.RUNNING,equipId);
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则 alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则
if (!alarmRecordList.isEmpty()) {//运行需放开 if (!alarmRecordList.isEmpty()) {//运行需放开
// alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList); alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
} }
i.insert(measurement, tags, fields); i.insert(measurement, tags, fields);
} }

View File

@ -0,0 +1,72 @@
package com.inspur.cache.domain;
import com.inspur.common.annotation.Excel;
import com.inspur.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 缓存同步对象 ipc_cache_sync
*
* @author zhanghan11
* @date 2024-09-29
*/
public class IpcCacheSync extends BaseEntity
{
public IpcCacheSync() {
}
public IpcCacheSync(Long deptId, String type, String model) {
this.deptId = deptId;
this.type = type;
this.model = model;
}
private static final long serialVersionUID = 1L;
/** 部门ID */
@Excel(name = "部门ID")
private Long deptId;
/** 类型 */
@Excel(name = "类型")
private String type;
/** 自定义参数,判定是云端还是工控机端,云端-cloud工控机端-client其他-other */
@Excel(name = "自定义参数,判定是云端还是工控机端,云端-cloud工控机端-client其他-other")
private String model;
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getDeptId()
{
return deptId;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("deptId", getDeptId())
.append("type", getType())
.toString();
}
}

View File

@ -0,0 +1,70 @@
package com.inspur.cache.mapper;
import com.inspur.cache.domain.IpcCacheSync;
import java.util.List;
/**
* 缓存同步Mapper接口
*
* @author zhanghan11
* @date 2024-09-29
*/
public interface IpcCacheSyncMapper
{
/**
* 查询缓存同步
*
* @param deptId 缓存同步主键
* @return 缓存同步
*/
public IpcCacheSync selectIpcCacheSyncByDeptId(Long deptId);
/**
* 去重查询缓存同步列表
*
* @param ipcCacheSync 缓存同步
* @return 缓存同步集合
*/
public List<IpcCacheSync> selectIpcCacheSyncList(IpcCacheSync ipcCacheSync);
/**
* 新增缓存同步
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
public int insertIpcCacheSync(IpcCacheSync ipcCacheSync);
/**
* 修改缓存同步
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
public int updateIpcCacheSync(IpcCacheSync ipcCacheSync);
/**
* 删除缓存同步
*
* @param deptId 缓存同步主键
* @return 结果
*/
public int deleteIpcCacheSyncByDeptId(Long deptId);
/**
* 批量删除缓存同步
*
* @param deptIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteIpcCacheSyncByDeptIds(Long[] deptIds);
/**
* 删除缓存同步信息
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
public int deleteIpcCacheSync(IpcCacheSync ipcCacheSync);
}

View File

@ -0,0 +1,70 @@
package com.inspur.cache.service;
import com.inspur.cache.domain.IpcCacheSync;
import java.util.List;
/**
* 缓存同步Service接口
*
* @author zhanghan11
* @date 2024-09-29
*/
public interface IIpcCacheSyncService
{
/**
* 查询缓存同步
*
* @param deptId 缓存同步主键
* @return 缓存同步
*/
public IpcCacheSync selectIpcCacheSyncByDeptId(Long deptId);
/**
* 去重查询缓存同步列表
*
* @param ipcCacheSync 缓存同步
* @return 缓存同步集合
*/
public List<IpcCacheSync> selectIpcCacheSyncList(IpcCacheSync ipcCacheSync);
/**
* 新增缓存同步
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
public int insertIpcCacheSync(IpcCacheSync ipcCacheSync);
/**
* 修改缓存同步
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
public int updateIpcCacheSync(IpcCacheSync ipcCacheSync);
/**
* 批量删除缓存同步
*
* @param deptIds 需要删除的缓存同步主键集合
* @return 结果
*/
public int deleteIpcCacheSyncByDeptIds(Long[] deptIds);
/**
* 删除缓存同步信息
*
* @param deptId 缓存同步主键
* @return 结果
*/
public int deleteIpcCacheSyncByDeptId(Long deptId);
/**
* 删除缓存同步信息
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
public int deleteIpcCacheSync(IpcCacheSync ipcCacheSync);
}

View File

@ -0,0 +1,104 @@
package com.inspur.cache.service.impl;
import com.inspur.cache.domain.IpcCacheSync;
import com.inspur.cache.mapper.IpcCacheSyncMapper;
import com.inspur.cache.service.IIpcCacheSyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 缓存同步Service业务层处理
*
* @author zhanghan11
* @date 2024-09-29
*/
@Service
public class IpcCacheSyncServiceImpl implements IIpcCacheSyncService
{
@Autowired
private IpcCacheSyncMapper ipcCacheSyncMapper;
/**
* 查询缓存同步
*
* @param deptId 缓存同步主键
* @return 缓存同步
*/
@Override
public IpcCacheSync selectIpcCacheSyncByDeptId(Long deptId)
{
return ipcCacheSyncMapper.selectIpcCacheSyncByDeptId(deptId);
}
/**
* 去重查询缓存同步列表
*
* @param ipcCacheSync 缓存同步
* @return 缓存同步
*/
@Override
public List<IpcCacheSync> selectIpcCacheSyncList(IpcCacheSync ipcCacheSync)
{
return ipcCacheSyncMapper.selectIpcCacheSyncList(ipcCacheSync);
}
/**
* 新增缓存同步
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
@Override
public int insertIpcCacheSync(IpcCacheSync ipcCacheSync)
{
return ipcCacheSyncMapper.insertIpcCacheSync(ipcCacheSync);
}
/**
* 修改缓存同步
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
@Override
public int updateIpcCacheSync(IpcCacheSync ipcCacheSync)
{
return ipcCacheSyncMapper.updateIpcCacheSync(ipcCacheSync);
}
/**
* 批量删除缓存同步
*
* @param deptIds 需要删除的缓存同步主键
* @return 结果
*/
@Override
public int deleteIpcCacheSyncByDeptIds(Long[] deptIds)
{
return ipcCacheSyncMapper.deleteIpcCacheSyncByDeptIds(deptIds);
}
/**
* 删除缓存同步信息
*
* @param deptId 缓存同步主键
* @return 结果
*/
@Override
public int deleteIpcCacheSyncByDeptId(Long deptId)
{
return ipcCacheSyncMapper.deleteIpcCacheSyncByDeptId(deptId);
}
/**
* 删除缓存同步信息
*
* @param ipcCacheSync 缓存同步
* @return 结果
*/
@Override
public int deleteIpcCacheSync(IpcCacheSync ipcCacheSync){
return ipcCacheSyncMapper.deleteIpcCacheSync(ipcCacheSync);
}
}

View File

@ -48,8 +48,8 @@ public class IpcAlarmRecord extends BaseEntity
private BigDecimal alarmValue; private BigDecimal alarmValue;
/** 报警时间 */ /** 报警时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:SS") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "报警时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:SS") @Excel(name = "报警时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date alarmTime; private Date alarmTime;
/** 处理结果 */ /** 处理结果 */

View File

@ -28,6 +28,14 @@ public interface IpcAlarmRecordMapper
*/ */
public List<IpcAlarmRecord> selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord); public List<IpcAlarmRecord> selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord);
/**
* 查询报警记录列表
*
* @param ipcAlarmRecord 报警记录
* @return 报警记录集合
*/
public List<IpcAlarmRecord> selectIpcAlarmRecordListAll(IpcAlarmRecord ipcAlarmRecord);
/** /**
* 新增报警记录 * 新增报警记录
* *

View File

@ -27,6 +27,14 @@ public interface IIpcAlarmRecordService
*/ */
public List<IpcAlarmRecord> selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord); public List<IpcAlarmRecord> selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord);
/**
* 查询报警记录列表
*
* @param ipcAlarmRecord 报警记录
* @return 报警记录集合
*/
public List<IpcAlarmRecord> selectIpcAlarmRecordListAll(IpcAlarmRecord ipcAlarmRecord);
/** /**
* 新增报警记录 * 新增报警记录
* *

View File

@ -11,6 +11,7 @@ import com.inspur.industrial.domain.IpcAlarmRules;
*/ */
public interface IIpcAlarmRulesService public interface IIpcAlarmRulesService
{ {
public void updateRedisCache();
/** /**
* 查询设备报警规则 * 查询设备报警规则
* *

View File

@ -47,6 +47,16 @@ public class IpcAlarmRecordServiceImpl implements IIpcAlarmRecordService
return ipcAlarmRecordMapper.selectIpcAlarmRecordList(ipcAlarmRecord); return ipcAlarmRecordMapper.selectIpcAlarmRecordList(ipcAlarmRecord);
} }
/**
* 查询报警记录列表
*
* @param ipcAlarmRecord 报警记录
* @return 报警记录集合
*/
@Override
public List<IpcAlarmRecord> selectIpcAlarmRecordListAll(IpcAlarmRecord ipcAlarmRecord){
return ipcAlarmRecordMapper.selectIpcAlarmRecordListAll(ipcAlarmRecord);
}
/** /**
* 新增报警记录 * 新增报警记录
* *

View File

@ -1,6 +1,7 @@
package com.inspur.industrial.service.impl; package com.inspur.industrial.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -43,16 +44,13 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService {
@Resource @Resource
private IIpcEquipInfoService ipcEquipInfoService; private IIpcEquipInfoService ipcEquipInfoService;
//加载规则到缓存 @Override
@PostConstruct public void updateRedisCache() {
public void init() {
List<IpcEquipInfo> equips = ipcEquipInfoService.selectIpcEquipInfoList(null); List<IpcEquipInfo> equips = ipcEquipInfoService.selectIpcEquipInfoList(null);
for (IpcEquipInfo equip : equips) { for (IpcEquipInfo equip : equips) {
if (!redisCache.hasKey((CacheConstants.IPC_RULES_KEY + equip.getId()))) { List<IpcAlarmRules> rulesList = selectIpcAlarmRulesByEquipId(equip.getId());
List<IpcAlarmRules> rulesList = selectIpcAlarmRulesByEquipId(equip.getId()); redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.RUNNING + CacheConstants.SEPARATOR + equip.getId()), rulesList.stream().filter(ipcAlarmRules -> Constant.RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.RUNNING + CacheConstants.SEPARATOR + equip.getId()), rulesList.stream().filter(ipcAlarmRules -> Constant.RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList())); redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.TRY_RUNNING + CacheConstants.SEPARATOR + equip.getId()), rulesList.stream().filter(ipcAlarmRules -> Constant.TRY_RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
redisCache.setCacheObject((CacheConstants.IPC_RULES_KEY + Constant.TRY_RUNNING + CacheConstants.SEPARATOR + equip.getId()), rulesList.stream().filter(ipcAlarmRules -> Constant.TRY_RUNNING.equals(ipcAlarmRules.getType())).collect(Collectors.toList()));
}
} }
} }

View File

@ -56,4 +56,27 @@ public class Constant {
* 试运行 * 试运行
*/ */
public static final Integer TRY_RUNNING = 1; public static final Integer TRY_RUNNING = 1;
/**
* 缓存类型-参数
*/
public static final String CACHE_TYPE_PARAMS = "params";
/**
* 缓存类型-规则
*/
public static final String CACHE_TYPE_RULES = "rules";
/**
* 云端
*/
public static final String MODEL_CLOUD = "cloud";
/**
* 工控机端
*/
public static final String MODEL_CLIENT = "client";
/**
* 其他端
*/
public static final String MODEL_OTHER = "other";
} }

View File

@ -0,0 +1,81 @@
package com.inspur.industrial.utils;
import com.inspur.cache.domain.IpcCacheSync;
import com.inspur.cache.service.IIpcCacheSyncService;
import com.inspur.common.constant.Constants;
import com.inspur.common.utils.spring.SpringUtils;
import com.inspur.industrial.service.IIpcAlarmRulesService;
import com.inspur.system.service.influx.InfluxDBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.time.LocalDate;
import java.util.List;
@Configuration
@Component("ipcRedisCacheConfiguration")
public class IpcRedisCacheConfiguration {
@Autowired
private IIpcAlarmRulesService ipcAlarmRulesService;
@Autowired
private IIpcCacheSyncService iIpcCacheSyncService;
@Value("${zfipc.model}")
private String model;
@Value("${zfipc.deptId}")
private Long deptId;
/**
* 预加载缓存
*/
@PostConstruct
public void preloadedRedisCache() {
// 工控机端更新规则和设备状态
if (Constant.MODEL_CLIENT.equals(model)) {
ipcAlarmRulesService.updateRedisCache();
}
}
public void updateCache() {
// 查询是否需要更新
IpcCacheSync ipcCacheSync = new IpcCacheSync(deptId, null, model);
List<IpcCacheSync> list = iIpcCacheSyncService.selectIpcCacheSyncList(ipcCacheSync);
System.out.println("缓存更新:"+deptId);
if(!list.isEmpty()){
for(IpcCacheSync cacheSync:list){
switch(cacheSync.getType()){
case Constant.CACHE_TYPE_RULES:
ipcAlarmRulesService.updateRedisCache();
break;
case Constant.CACHE_TYPE_PARAMS:
break;
default:
break;
}
}
// 删除更新标识
iIpcCacheSyncService.deleteIpcCacheSync(ipcCacheSync);
}
}
public void deleteExpDataByDate(Integer params)
{
System.out.println("执行有参方法删除过期数据:" + params);
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
StringBuffer sql1 = new StringBuffer("");
StringBuffer sql2 = new StringBuffer("");
StringBuffer sql3 = new StringBuffer("");
sql1.append("SELECT * FROM ").append(Constants.MEASUREMENT_BOTTOM_CY_LINDER).append(" where isAlarm = '0' and time < '").append(LocalDate.now().toString()).append("T00:00:00Z' -8h -").append(params.toString()).append("d");
sql2.append("SELECT * FROM ").append(Constants.MEASUREMENT_TOP_SCOLLER).append(" where isAlarm = '0' and time < '").append(LocalDate.now().toString()).append("T00:00:00Z' -8h -").append(params.toString()).append("d");
sql3.append("SELECT * FROM ").append(Constants.MEASUREMENT_BOTTOM_SCOLLER).append(" where isAlarm = '0' and time < '").append(LocalDate.now().toString()).append("T00:00:00Z' -8h -").append(params.toString()).append("d");
i.query(sql1.toString());
i.query(sql2.toString());
i.query(sql3.toString());
}
}

View File

@ -8,9 +8,7 @@ import com.inspur.industrial.domain.IpcAlarmRules;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
@Component @Component
public class IpcUtil { public class IpcUtil {
@ -96,7 +94,7 @@ public class IpcUtil {
// 默认正常数据 // 默认正常数据
String isAlarm = "0"; String isAlarm = "0";
for (IpcAlarmRules rule : rulesList) { for (IpcAlarmRules rule : rulesList) {
// 判断是否当前参数类型 0:开机 // 判断是否当前参数类型 0:运行中1:试运行
if (type == rule.getType()) { if (type == rule.getType()) {
if (judgeAlarm(map.get(rule.getAlarmNameKey()), rule.getAlertLowerBound(), rule.getAlertUpperBound(), rule.getReferenceCon(), map.get(rule.getBaseValue()), rule.getBaseValueLowerBound(), rule.getBaseValueUpperBound())) { if (judgeAlarm(map.get(rule.getAlarmNameKey()), rule.getAlertLowerBound(), rule.getAlertUpperBound(), rule.getReferenceCon(), map.get(rule.getBaseValue()), rule.getBaseValueLowerBound(), rule.getBaseValueUpperBound())) {
// 报警数据 // 报警数据
@ -109,7 +107,7 @@ public class IpcUtil {
String name = rule.getAlarmNameKey(); String name = rule.getAlarmNameKey();
ipcAlarmRecord.setAlarmValue(BigDecimal.valueOf((Float) map.get(name))); ipcAlarmRecord.setAlarmValue(BigDecimal.valueOf((Float) map.get(name)));
ipcAlarmRecord.setNameKey(name); ipcAlarmRecord.setNameKey(name);
ipcAlarmRecord.setContent(type == 0 ? "(开机监测)" + rule.getReferenceName() : rule.getReferenceName()); ipcAlarmRecord.setContent(rule.getReferenceName());
ipcAlarmRecord.setStatus(0); ipcAlarmRecord.setStatus(0);
ipcAlarmRecord.setOperator(1L); ipcAlarmRecord.setOperator(1L);
ipcAlarmRecord.setAlarmLevel(rule.getAlarmLevel()); ipcAlarmRecord.setAlarmLevel(rule.getAlarmLevel());

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.inspur.cache.mapper.IpcCacheSyncMapper">
<resultMap type="com.inspur.cache.domain.IpcCacheSync" id="IpcCacheSyncResult">
<result property="deptId" column="dept_id" />
<result property="type" column="type" />
<result property="model" column="model" />
</resultMap>
<sql id="selectIpcCacheSyncVo">
select dept_id, type, model from ipc_cache_sync
</sql>
<select id="selectIpcCacheSyncList" parameterType="com.inspur.cache.domain.IpcCacheSync" resultMap="IpcCacheSyncResult">
select distinct type from ipc_cache_sync
<where>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="model != null and model != ''"> and model = #{model}</if>
</where>
</select>
<select id="selectIpcCacheSyncByDeptId" parameterType="Long" resultMap="IpcCacheSyncResult">
<include refid="selectIpcCacheSyncVo"/>
where dept_id = #{deptId}
</select>
<insert id="insertIpcCacheSync" parameterType="com.inspur.cache.domain.IpcCacheSync">
insert into ipc_cache_sync
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptId != null">dept_id,</if>
<if test="type != null and type != ''">type,</if>
<if test="model != null and model != ''">model,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptId != null">#{deptId},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="model != null and model != ''">#{model},</if>
</trim>
</insert>
<update id="updateIpcCacheSync" parameterType="com.inspur.cache.domain.IpcCacheSync">
update ipc_cache_sync
<trim prefix="SET" suffixOverrides=",">
<if test="type != null and type != ''">type = #{type},</if>
<if test="model != null and model != ''">model = #{model},</if>
</trim>
where dept_id = #{deptId}
</update>
<delete id="deleteIpcCacheSyncByDeptId" parameterType="Long">
delete from ipc_cache_sync where dept_id = #{deptId}
</delete>
<delete id="deleteIpcCacheSyncByDeptIds" parameterType="String">
delete from ipc_cache_sync where dept_id in
<foreach item="deptId" collection="array" open="(" separator="," close=")">
#{deptId}
</foreach>
</delete>
<delete id="deleteIpcCacheSync" parameterType="com.inspur.cache.domain.IpcCacheSync">
delete from ipc_cache_sync where dept_id = #{deptId} and model = #{model}
</delete>
</mapper>

View File

@ -77,6 +77,27 @@
order by a.alarm_time desc order by a.alarm_time desc
</select> </select>
<select id="selectIpcAlarmRecordListAll" parameterType="IpcAlarmRecord" resultMap="IpcAlarmRecordResult">
<include refid="selectIpcAlarmRecordVo"/>
<where>
<if test="alarmRulesId != null and alarmRulesId != ''"> and a.alarm_rules_id = #{alarmRulesId}</if>
<if test="equipId != null and equipId != ''"> and a.equip_id = #{equipId}</if>
<if test="sensorId != null and sensorId != ''"> and a.sensor_id = #{sensorId}</if>
<if test="nameKey != null and nameKey != ''"> and a.name_key = #{nameKey}</if>
<if test="content != null and content != ''"> and a.content = #{content}</if>
<if test="alarmValue != null "> and a.alarm_value = #{alarmValue}</if>
<if test="result != null and result != ''"> and a.result = #{result}</if>
<if test="status != null "> and a.status = #{status}</if>
<if test="operator != null "> and a.operator = #{operator}</if>
<if test="alarmLevel != null "> and a.alarm_level = #{alarmLevel}</if>
<if test="params.startTime != null and params.endTime != null">and a.alarm_time between #{params.startTime}
and #{params.endTime}
</if>
</where>
order by a.alarm_time desc
limit 1000
</select>
<select id="selectIpcAlarmRecordById" parameterType="Long" resultMap="IpcAlarmRecordResult"> <select id="selectIpcAlarmRecordById" parameterType="Long" resultMap="IpcAlarmRecordResult">
<include refid="selectIpcAlarmRecordVo"/> <include refid="selectIpcAlarmRecordVo"/>
where a.id = #{id} where a.id = #{id}