缓存更新功能

This commit is contained in:
zhanghan11 2024-09-29 16:06:05 +08:00
parent 81e9f643f5
commit 144e2d334e
16 changed files with 491 additions and 23 deletions

View File

@ -85,7 +85,7 @@ public class CacheConstants
/**
* ipc前缀
*/
public static final String IPC_PREFIX = "ipc:";
public static final String IPC_PREFIX = "tzipc:";
/**

View File

@ -1,6 +1,7 @@
package com.inspur.datasyn.modbus;
import com.inspur.ipc.service.IIpcMonitorFieldService;
import com.inspur.ipc.utils.IpcConstant;
import com.inspur.system.service.influx.InfluxDBService;
import com.serotonin.modbus4j.ModbusFactory;
import com.serotonin.modbus4j.ModbusMaster;
@ -81,7 +82,7 @@ public class IPCDataSyncTask implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
// 工控机取plc数据
if ("client".equals(model)) {
if (IpcConstant.MODEL_CLIENT.equals(model)) {
final Timer timer1 = new Timer();
// 取数plc
IpParameters params = new IpParameters();
@ -118,7 +119,7 @@ public class IPCDataSyncTask implements ApplicationRunner {
}, 1000, 1000);
}
// 云端mqtt上传数据
if ("cloud".equals(model)) {
if (IpcConstant.MODEL_CLOUD.equals(model)) {
final Timer timer3 = new Timer();
timer3.schedule(new TimerTask() {
@Override
@ -128,7 +129,7 @@ public class IPCDataSyncTask implements ApplicationRunner {
}, 1000, 1000 * 60);
}
if ("other".equals(model)) {
if (IpcConstant.MODEL_OTHER.equals(model)) {
// final Timer timer2 = new Timer();
// timer2.schedule(new TimerTask() {
// @Override

View File

@ -33,7 +33,7 @@ public class IPCDataTimer implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
/*if("client".equals(model)){
/*if(IpcConstant.MODEL_CLIENT.equals(model)){
redisCache.setCacheObject("lightStatus",-1);
final Timer timer = new Timer();
timer.schedule(new TimerTask() {

View File

@ -1,5 +1,6 @@
package com.inspur.datasyn.mqtt;
import com.inspur.ipc.utils.IpcConstant;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,7 +44,7 @@ public class MqttAutoStart implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws MqttException {
if("cloud".equals(model)){
if(IpcConstant.MODEL_CLOUD.equals(model)){
// 创建MQTT客户端
MyMqttClient myMqttClient = new MyMqttClient(host, userName, password, clientId, timeOut, keepAlive);
logger.info("############## 1、mqtt 客户端创建完成##############");

View File

@ -42,7 +42,7 @@ public class SysJobServiceImpl implements ISysJobService
for (SysJob job : jobList)
{
// 定时任务优化子系统仅执行子系统分组指定任务
if ("CHILD_SYSTEM".equals(job.getJobGroup()) && "".equals(job.getInvokeTarget())) {
if ("CHILD_SYSTEM".equals(job.getJobGroup())) {
ScheduleUtils.createScheduleJob(scheduler, job);
}
}

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

@ -63,6 +63,7 @@ public class IpcAlarmRecord extends BaseEntity {
@Excel(name = "处理人")
private Long operator;
private String alarmNameKey;
/**
* 报警等级
*/
@ -87,6 +88,14 @@ public class IpcAlarmRecord extends BaseEntity {
public IpcAlarmRecord() {
}
public String getAlarmNameKey() {
return alarmNameKey;
}
public void setAlarmNameKey(String alarmNameKey) {
this.alarmNameKey = alarmNameKey;
}
public void setId(Long id)
{
this.id = id;

View File

@ -244,11 +244,11 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
ipcAlarmRecord.setDeptId(deptId);
List<IpcAlarmRecord> list = ipcAlarmRecordService.selectIpcAlarmRecordList(ipcAlarmRecord);
// 颗粒度报警
dataMap.put("pzOperationAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getEquipId().endsWith("o") && ipcAlarmRecord1.getNameKey().startsWith("pz")).limit(IpcConstant.BIGSCREEN_ALARM_RECORD_NUM_5).map(IpcAlarmRecord::getContent).collect(Collectors.toList())));
dataMap.put("pzDriveAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getEquipId().endsWith("d") && ipcAlarmRecord1.getNameKey().startsWith("pz")).limit(IpcConstant.BIGSCREEN_ALARM_RECORD_NUM_5).map(IpcAlarmRecord::getContent).collect(Collectors.toList())));
dataMap.put("pzOperationAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getEquipId().endsWith("o") && ipcAlarmRecord1.getAlarmNameKey().startsWith("pz")).limit(IpcConstant.BIGSCREEN_ALARM_RECORD_NUM_5).map(IpcAlarmRecord::getContent).collect(Collectors.toList())));
dataMap.put("pzDriveAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getEquipId().endsWith("d") && ipcAlarmRecord1.getAlarmNameKey().startsWith("pz")).limit(IpcConstant.BIGSCREEN_ALARM_RECORD_NUM_5).map(IpcAlarmRecord::getContent).collect(Collectors.toList())));
// 其他报警
dataMap.put("otherOperationAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getEquipId().endsWith("o") && !ipcAlarmRecord1.getNameKey().startsWith("pz")).limit(IpcConstant.BIGSCREEN_ALARM_RECORD_NUM_10).map(IpcAlarmRecord::getContent).collect(Collectors.toList())));
dataMap.put("otherDriveAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getEquipId().endsWith("d") && !ipcAlarmRecord1.getNameKey().startsWith("pz")).limit(IpcConstant.BIGSCREEN_ALARM_RECORD_NUM_10).map(IpcAlarmRecord::getContent).collect(Collectors.toList())));
dataMap.put("otherOperationAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getEquipId().endsWith("o") && !ipcAlarmRecord1.getAlarmNameKey().startsWith("pz")).limit(IpcConstant.BIGSCREEN_ALARM_RECORD_NUM_10).map(IpcAlarmRecord::getContent).collect(Collectors.toList())));
dataMap.put("otherDriveAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getEquipId().endsWith("d") && !ipcAlarmRecord1.getAlarmNameKey().startsWith("pz")).limit(IpcConstant.BIGSCREEN_ALARM_RECORD_NUM_10).map(IpcAlarmRecord::getContent).collect(Collectors.toList())));
// 根据部位区分报警数量
List<IpcMonitorField> fieldList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_EQUIP_KEY);
Map<String, Object> map = new HashMap<>();

View File

@ -68,9 +68,9 @@ public class IpcConstant {
/**
* 工控机端
*/
public static final String MODEL_CLIENT = "clinet";
public static final String MODEL_CLIENT = "client";
/**
* 其他
* 其他
*/
public static final String MODEL_OTHER = "other";
@ -178,4 +178,15 @@ public class IpcConstant {
*/
public static final String FILED_OIP = "oip";
/**
* 缓存类型-参数
*/
public static final String CACHE_TYPE_PARAMS = "params";
/**
* 缓存类型-规则
*/
public static final String CACHE_TYPE_RULES = "rules";
}

View File

@ -1,5 +1,7 @@
package com.inspur.ipc.utils;
import com.inspur.cache.domain.IpcCacheSync;
import com.inspur.cache.service.IIpcCacheSyncService;
import com.inspur.common.constant.CacheConstants;
import com.inspur.common.utils.spring.SpringUtils;
import com.inspur.ipc.service.IIpcAlarmRecordService;
@ -8,29 +10,85 @@ import com.inspur.ipc.service.IIpcMonitorFieldService;
import com.inspur.ipc.service.IIpcRunningStatusRecordService;
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
IIpcMonitorFieldService iIpcMonitorFieldService;
private IIpcMonitorFieldService iIpcMonitorFieldService;
@Autowired
IIpcAlarmRulesConfigService iIpcAlarmRulesConfigService;
private IIpcAlarmRulesConfigService iIpcAlarmRulesConfigService;
@Autowired
IIpcRunningStatusRecordService iIpcRunningStatusRecordService;
private IIpcRunningStatusRecordService iIpcRunningStatusRecordService;
@Autowired
private IIpcCacheSyncService iIpcCacheSyncService;
@Value("${tzipc.model}")
private String model;
@Value("${tzipc.deptId}")
private Long deptId;
/**
* 预加载缓存
*/
@PostConstruct
public void preloadedRedisCache(){
public void preloadedRedisCache() {
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.MONITOR_EQUIP_KEY);
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.SENSOR_MONITOR_PARAMS_KEY);
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_READ_KEY);
iIpcAlarmRulesConfigService.updateRedisCache();
iIpcRunningStatusRecordService.selectLatestStatus();
// 工控机端更新规则和设备状态云端只更新参数
if (IpcConstant.MODEL_CLIENT.equals(model)) {
iIpcRunningStatusRecordService.selectLatestStatus();
iIpcAlarmRulesConfigService.updateRedisCache();
}
}
public void updateCache() {
// 查询是否需要更新
IpcCacheSync ipcCacheSync = new IpcCacheSync(deptId, null, model);
List<IpcCacheSync> list = iIpcCacheSyncService.selectIpcCacheSyncList(ipcCacheSync);
System.out.println("缓存更新"+list.size()+"---"+list.toString());
if(!list.isEmpty()){
for(IpcCacheSync cacheSync:list){
switch(cacheSync.getType()){
case IpcConstant.CACHE_TYPE_RULES:
iIpcAlarmRulesConfigService.updateRedisCache();
break;
case IpcConstant.CACHE_TYPE_PARAMS:
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.MONITOR_EQUIP_KEY);
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.SENSOR_MONITOR_PARAMS_KEY);
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_READ_KEY);
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("");
sql1.append("SELECT * FROM ").append(IpcConstant.PLC_MEASUREMENT).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(IpcConstant.SENSOR_MEASUREMENT).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());
}
}

View File

@ -75,7 +75,7 @@ public class RuleUtils {
if (result) {
// 报警数据
map.put("isAlarm", 1);
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(), rulesConfig.getEquipId(), rulesConfig.getEquipName(), rulesConfig.getAlarmNameKey(), rulesConfig.getAlarmName(), String.valueOf(map.get(rulesConfig.getAlarmNameKey())), rulesConfig.getAlarmInfoUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getDescription(), rulesConfig.getId());
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(rulesConfig.getId(), rulesConfig.getEquipId(), rulesConfig.getSensorId(), rulesConfig.getDescription(), new BigDecimal(String.valueOf(map.get(rulesConfig.getAlarmNameKey()) == null ? 0 : map.get(rulesConfig.getAlarmNameKey()))), rulesConfig.getAlarmLevel(), rulesConfig.getDeptId());
returnList.add(ipcAlarmRecord);
} else {
// 正常数据
@ -126,7 +126,7 @@ public class RuleUtils {
// 报警数据
map.put("isAlarm", 1);
// 记录报警日志
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(), rulesConfig.getEquipId(), rulesConfig.getEquipName(), rulesConfig.getAlarmNameKey(), rulesConfig.getAlarmName(), String.valueOf(map.get(rulesConfig.getAlarmNameKey())), rulesConfig.getAlarmInfoUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getDescription(), rulesConfig.getId());
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(rulesConfig.getId(), rulesConfig.getEquipId(), rulesConfig.getSensorId(), rulesConfig.getDescription(), new BigDecimal(String.valueOf(map.get(rulesConfig.getAlarmNameKey()) == null ? 0 : map.get(rulesConfig.getAlarmNameKey()))), rulesConfig.getAlarmLevel(), rulesConfig.getDeptId());
returnList.add(ipcAlarmRecord);
} else {
// 正常数据
@ -137,7 +137,7 @@ public class RuleUtils {
// 报警数据
map.put("isAlarm", 1);
// 记录报警日志
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(), rulesConfig.getEquipId(), rulesConfig.getEquipName(), rulesConfig.getAlarmNameKey(), rulesConfig.getAlarmName(), String.valueOf(map.get(rulesConfig.getAlarmNameKey())), rulesConfig.getAlarmInfoUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getDescription(), rulesConfig.getId());
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(rulesConfig.getId(), rulesConfig.getEquipId(), rulesConfig.getSensorId(), rulesConfig.getDescription(), new BigDecimal(String.valueOf(map.get(rulesConfig.getAlarmNameKey()) == null ? 0 : map.get(rulesConfig.getAlarmNameKey()))), rulesConfig.getAlarmLevel(), rulesConfig.getDeptId());
returnList.add(ipcAlarmRecord);
e.printStackTrace();
}

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

@ -18,6 +18,7 @@
<result property="operator" column="operator"/>
<result property="alarmLevel" column="alarm_level"/>
<result property="deptId" column="dept_id"/>
<result property="alarmNameKey" column="alarm_name_key"/>
</resultMap>
<sql id="selectIpcAlarmRecordVo">
@ -38,14 +39,18 @@
<select id="selectIpcAlarmRecordList" parameterType="com.inspur.ipc.domain.IpcAlarmRecord"
resultMap="IpcAlarmRecordResult">
SELECT a.*,b.alarm_name_key FROM
(
<include refid="selectIpcAlarmRecordVo"/>
<where>
<if test="equipId != null and equipId != ''">and equip_id = #{equipId}</if>
<if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
<if test="params.startTime != null and params.endTime != null">and alarm_time between #{params.startTime}
<if test="params.startTime != null and params.endTime != null">and alarm_time between #{params.startTime}
and #{params.endTime}
</if>
</where>
) a
left join ipc_alarm_rules b on a.alarm_rules_id = b.id
order by alarm_time desc
</select>