diff --git a/tzipc-server/tzipc-common/src/main/java/com/inspur/common/constant/CacheConstants.java b/tzipc-server/tzipc-common/src/main/java/com/inspur/common/constant/CacheConstants.java index 742f466..ac96952 100644 --- a/tzipc-server/tzipc-common/src/main/java/com/inspur/common/constant/CacheConstants.java +++ b/tzipc-server/tzipc-common/src/main/java/com/inspur/common/constant/CacheConstants.java @@ -85,7 +85,7 @@ public class CacheConstants /** * ipc前缀 */ - public static final String IPC_PREFIX = "ipc:"; + public static final String IPC_PREFIX = "tzipc:"; /** diff --git a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java index 0d6ea7c..3d9ca48 100644 --- a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java +++ b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java @@ -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 diff --git a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/timer/IPCDataTimer.java b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/timer/IPCDataTimer.java index f65c620..4736b1a 100644 --- a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/timer/IPCDataTimer.java +++ b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/timer/IPCDataTimer.java @@ -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() { diff --git a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/mqtt/MqttAutoStart.java b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/mqtt/MqttAutoStart.java index 932c3f6..d5b1dba 100644 --- a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/mqtt/MqttAutoStart.java +++ b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/mqtt/MqttAutoStart.java @@ -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 客户端创建完成##############"); diff --git a/tzipc-server/tzipc-quartz/src/main/java/com/inspur/quartz/service/impl/SysJobServiceImpl.java b/tzipc-server/tzipc-quartz/src/main/java/com/inspur/quartz/service/impl/SysJobServiceImpl.java index 2aed072..c36841b 100644 --- a/tzipc-server/tzipc-quartz/src/main/java/com/inspur/quartz/service/impl/SysJobServiceImpl.java +++ b/tzipc-server/tzipc-quartz/src/main/java/com/inspur/quartz/service/impl/SysJobServiceImpl.java @@ -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); } } diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/domain/IpcCacheSync.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/domain/IpcCacheSync.java new file mode 100644 index 0000000..002bf7d --- /dev/null +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/domain/IpcCacheSync.java @@ -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(); + } +} diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/mapper/IpcCacheSyncMapper.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/mapper/IpcCacheSyncMapper.java new file mode 100644 index 0000000..e83de82 --- /dev/null +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/mapper/IpcCacheSyncMapper.java @@ -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 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); +} diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/service/IIpcCacheSyncService.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/service/IIpcCacheSyncService.java new file mode 100644 index 0000000..fa44638 --- /dev/null +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/service/IIpcCacheSyncService.java @@ -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 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); +} diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/service/impl/IpcCacheSyncServiceImpl.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/service/impl/IpcCacheSyncServiceImpl.java new file mode 100644 index 0000000..9f83465 --- /dev/null +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/cache/service/impl/IpcCacheSyncServiceImpl.java @@ -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 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); + } +} diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/domain/IpcAlarmRecord.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/domain/IpcAlarmRecord.java index 1a34f9f..c634256 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/domain/IpcAlarmRecord.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/domain/IpcAlarmRecord.java @@ -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; diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcDataShowServiceImpl.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcDataShowServiceImpl.java index 59005b0..ca045dd 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcDataShowServiceImpl.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcDataShowServiceImpl.java @@ -244,11 +244,11 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService { ipcAlarmRecord.setDeptId(deptId); List 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 fieldList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_EQUIP_KEY); Map map = new HashMap<>(); diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcConstant.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcConstant.java index 280af0e..e531ec9 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcConstant.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcConstant.java @@ -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"; + } diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcRedisCacheConfiguration.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcRedisCacheConfiguration.java index 66631c7..65b87b9 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcRedisCacheConfiguration.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcRedisCacheConfiguration.java @@ -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 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()); } } diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/RuleUtils.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/RuleUtils.java index 3d714ce..df005cc 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/RuleUtils.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/RuleUtils.java @@ -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(); } diff --git a/tzipc-server/tzipc-system/src/main/resources/mapper/cache/IpcCacheSyncMapper.xml b/tzipc-server/tzipc-system/src/main/resources/mapper/cache/IpcCacheSyncMapper.xml new file mode 100644 index 0000000..46d13a5 --- /dev/null +++ b/tzipc-server/tzipc-system/src/main/resources/mapper/cache/IpcCacheSyncMapper.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + select dept_id, type, model from ipc_cache_sync + + + + + + + + insert into ipc_cache_sync + + dept_id, + type, + model, + + + #{deptId}, + #{type}, + #{model}, + + + + + update ipc_cache_sync + + type = #{type}, + model = #{model}, + + where dept_id = #{deptId} + + + + delete from ipc_cache_sync where dept_id = #{deptId} + + + + delete from ipc_cache_sync where dept_id in + + #{deptId} + + + + delete from ipc_cache_sync where dept_id = #{deptId} and model = #{model} + + diff --git a/tzipc-server/tzipc-system/src/main/resources/mapper/ipc/IpcAlarmRecordMapper.xml b/tzipc-server/tzipc-system/src/main/resources/mapper/ipc/IpcAlarmRecordMapper.xml index 0938f8c..18b36d2 100644 --- a/tzipc-server/tzipc-system/src/main/resources/mapper/ipc/IpcAlarmRecordMapper.xml +++ b/tzipc-server/tzipc-system/src/main/resources/mapper/ipc/IpcAlarmRecordMapper.xml @@ -18,6 +18,7 @@ + @@ -38,14 +39,18 @@