运行状态新需求
This commit is contained in:
parent
7e8fc56cd7
commit
d66484f149
@ -70,4 +70,15 @@ public class CacheConstants
|
|||||||
* ipc缓存过期时间
|
* ipc缓存过期时间
|
||||||
*/
|
*/
|
||||||
public static final Integer IPC_EXPIRATION_TIME = 1;
|
public static final Integer IPC_EXPIRATION_TIME = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行状态
|
||||||
|
*/
|
||||||
|
public static final String RUNNING_STATUS = "running_status:";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ipc前缀
|
||||||
|
*/
|
||||||
|
public static final String IPC_PREFIX = "ipc:";
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package com.inspur.datasyn.modbus;
|
package com.inspur.datasyn.modbus;
|
||||||
|
|
||||||
import com.inspur.common.constant.CacheConstants;
|
import com.inspur.common.constant.CacheConstants;
|
||||||
|
import com.inspur.common.utils.StringUtils;
|
||||||
import com.inspur.common.utils.spring.SpringUtils;
|
import com.inspur.common.utils.spring.SpringUtils;
|
||||||
import com.inspur.ipc.domain.IpcAlarmRecord;
|
import com.inspur.ipc.domain.IpcAlarmRecord;
|
||||||
import com.inspur.ipc.domain.IpcAlarmRulesConfig;
|
import com.inspur.ipc.domain.IpcAlarmRulesConfig;
|
||||||
import com.inspur.ipc.domain.IpcMonitorField;
|
import com.inspur.ipc.domain.IpcMonitorField;
|
||||||
|
import com.inspur.ipc.domain.IpcRunningStatusRecord;
|
||||||
import com.inspur.ipc.service.IIpcAlarmRecordService;
|
import com.inspur.ipc.service.IIpcAlarmRecordService;
|
||||||
import com.inspur.ipc.service.IIpcAlarmRulesConfigService;
|
import com.inspur.ipc.service.IIpcAlarmRulesConfigService;
|
||||||
import com.inspur.ipc.service.IIpcMonitorFieldService;
|
import com.inspur.ipc.service.IIpcMonitorFieldService;
|
||||||
|
import com.inspur.ipc.service.IIpcRunningStatusRecordService;
|
||||||
import com.inspur.ipc.utils.IpcConstant;
|
import com.inspur.ipc.utils.IpcConstant;
|
||||||
import com.inspur.ipc.utils.IpcUtil;
|
import com.inspur.ipc.utils.IpcUtil;
|
||||||
import com.inspur.system.service.influx.InfluxDBService;
|
import com.inspur.system.service.influx.InfluxDBService;
|
||||||
@ -42,6 +45,7 @@ public class IPCPlcDataSyncThread implements Runnable {
|
|||||||
IpcUtil ipcUtil = SpringUtils.getBean(IpcUtil.class);
|
IpcUtil ipcUtil = SpringUtils.getBean(IpcUtil.class);
|
||||||
IIpcAlarmRulesConfigService iIpcAlarmRulesConfigService = SpringUtils.getBean(IIpcAlarmRulesConfigService.class);
|
IIpcAlarmRulesConfigService iIpcAlarmRulesConfigService = SpringUtils.getBean(IIpcAlarmRulesConfigService.class);
|
||||||
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
|
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
|
||||||
|
IIpcRunningStatusRecordService iIpcRunningStatusRecordService = SpringUtils.getBean(IIpcRunningStatusRecordService.class);
|
||||||
|
|
||||||
/* BatchRead<Integer> batch = new BatchRead<Integer>();
|
/* BatchRead<Integer> batch = new BatchRead<Integer>();
|
||||||
batch.addLocator(0, BaseLocator.holdingRegister(1, 0, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油压力,float
|
batch.addLocator(0, BaseLocator.holdingRegister(1, 0, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油压力,float
|
||||||
@ -63,11 +67,15 @@ public class IPCPlcDataSyncThread implements Runnable {
|
|||||||
batch.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int
|
batch.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int
|
||||||
batch.setContiguousRequests(false);
|
batch.setContiguousRequests(false);
|
||||||
BatchResults<Integer> results = master.send(batch);*/
|
BatchResults<Integer> results = master.send(batch);*/
|
||||||
// TODO 获取运行状态
|
// 获取运行状态,不一致则新增运行状态
|
||||||
// 不一致则更新运行状态
|
String status = iIpcRunningStatusRecordService.selectLatestStatus();
|
||||||
/**
|
if(StringUtils.isNull(status) || !status.equals("4")){
|
||||||
* 温压数据
|
status="4";
|
||||||
*/
|
iIpcRunningStatusRecordService.insertIpcRunningStatusRecord(new IpcRunningStatusRecord(status));
|
||||||
|
}
|
||||||
|
// 如果不是停机数据,进行处理
|
||||||
|
if(!IpcConstant.RUNNING_STATUS_SHUTDOWN.equals(status)) {
|
||||||
|
// 温压数据
|
||||||
List<IpcMonitorField> partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
|
List<IpcMonitorField> partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
|
||||||
List<IpcMonitorField> plcList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
|
List<IpcMonitorField> plcList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
|
||||||
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
|
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
|
||||||
@ -110,10 +118,14 @@ public class IPCPlcDataSyncThread implements Runnable {
|
|||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||||
String format = simpleDateFormat.format(new Date());
|
String format = simpleDateFormat.format(new Date());
|
||||||
fields.put("insertTime", format);
|
fields.put("insertTime", format);
|
||||||
// TODO 根据报警规则校验
|
|
||||||
// 根据运行状态获取规则
|
// 根据运行状态获取规则
|
||||||
List<IpcAlarmRulesConfig> rulesConfigList = iIpcAlarmRulesConfigService.selectIpcAlarmRulesConfigList(tags.get("part"));
|
List<IpcAlarmRulesConfig> rulesConfigList = iIpcAlarmRulesConfigService.selectIpcAlarmRulesConfigList(tags.get("part"));
|
||||||
|
if(IpcConstant.RUNNING_STATUS_RUNNING.equals(status)){
|
||||||
rulesConfigList = rulesConfigList.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getType().equals(IpcConstant.RULE_TYPE_IN_RUNNING)).collect(Collectors.toList());
|
rulesConfigList = rulesConfigList.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getType().equals(IpcConstant.RULE_TYPE_IN_RUNNING)).collect(Collectors.toList());
|
||||||
|
}else{
|
||||||
|
rulesConfigList = rulesConfigList.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getType().equals(IpcConstant.RULE_TYPE_TRIAL_RUN)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
// 根据报警规则校验
|
||||||
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, CacheConstants.PLC_MONITOR_PARAMS_KEY, rulesConfigList));
|
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, CacheConstants.PLC_MONITOR_PARAMS_KEY, rulesConfigList));
|
||||||
i.insert(IpcConstant.PLC_MEASUREMENT, tags, fields);
|
i.insert(IpcConstant.PLC_MEASUREMENT, tags, fields);
|
||||||
}
|
}
|
||||||
@ -121,6 +133,7 @@ public class IPCPlcDataSyncThread implements Runnable {
|
|||||||
if (!alarmRecordList.isEmpty()) {
|
if (!alarmRecordList.isEmpty()) {
|
||||||
iIpcAlarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
|
iIpcAlarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("数据处理失败,时间{},{}", new Date(), e.getMessage());
|
logger.info("数据处理失败,时间{},{}", new Date(), e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
package com.inspur.ipc.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
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_running_status_record
|
||||||
|
*
|
||||||
|
* @author inspur
|
||||||
|
* @date 2024-04-09
|
||||||
|
*/
|
||||||
|
public class IpcRunningStatusRecord extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 运行状态 */
|
||||||
|
@Excel(name = "运行状态")
|
||||||
|
private String runningStatus;
|
||||||
|
|
||||||
|
/** 开始时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
public void setId(Long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setRunningStatus(String runningStatus)
|
||||||
|
{
|
||||||
|
this.runningStatus = runningStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRunningStatus()
|
||||||
|
{
|
||||||
|
return runningStatus;
|
||||||
|
}
|
||||||
|
public void setStartTime(Date startTime)
|
||||||
|
{
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getStartTime()
|
||||||
|
{
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IpcRunningStatusRecord() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public IpcRunningStatusRecord(String runningStatus) {
|
||||||
|
this.runningStatus = runningStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("runningStatus", getRunningStatus())
|
||||||
|
.append("startTime", getStartTime())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.inspur.ipc.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.inspur.ipc.domain.IpcRunningStatusRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行状态记录Mapper接口
|
||||||
|
*
|
||||||
|
* @author inspur
|
||||||
|
* @date 2024-04-09
|
||||||
|
*/
|
||||||
|
public interface IpcRunningStatusRecordMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询运行状态记录
|
||||||
|
*
|
||||||
|
* @param id 运行状态记录主键
|
||||||
|
* @return 运行状态记录
|
||||||
|
*/
|
||||||
|
public IpcRunningStatusRecord selectIpcRunningStatusRecordById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运行状态记录列表
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 运行状态记录集合
|
||||||
|
*/
|
||||||
|
public List<IpcRunningStatusRecord> selectIpcRunningStatusRecordList(IpcRunningStatusRecord ipcRunningStatusRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运行状态记录
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运行状态记录
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除运行状态记录
|
||||||
|
*
|
||||||
|
* @param id 运行状态记录主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteIpcRunningStatusRecordById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除运行状态记录
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteIpcRunningStatusRecordByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询最新状态
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
String selectLatestStatus();
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.inspur.ipc.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.inspur.ipc.domain.IpcRunningStatusRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行状态记录Service接口
|
||||||
|
*
|
||||||
|
* @author inspur
|
||||||
|
* @date 2024-04-09
|
||||||
|
*/
|
||||||
|
public interface IIpcRunningStatusRecordService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询运行状态记录
|
||||||
|
*
|
||||||
|
* @param id 运行状态记录主键
|
||||||
|
* @return 运行状态记录
|
||||||
|
*/
|
||||||
|
public IpcRunningStatusRecord selectIpcRunningStatusRecordById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运行状态记录列表
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 运行状态记录集合
|
||||||
|
*/
|
||||||
|
public List<IpcRunningStatusRecord> selectIpcRunningStatusRecordList(IpcRunningStatusRecord ipcRunningStatusRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运行状态记录
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运行状态记录
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除运行状态记录
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的运行状态记录主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteIpcRunningStatusRecordByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除运行状态记录信息
|
||||||
|
*
|
||||||
|
* @param id 运行状态记录主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteIpcRunningStatusRecordById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询最新状态
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
String selectLatestStatus();
|
||||||
|
}
|
@ -106,7 +106,7 @@ public class IpcAlarmRulesConfigServiceImpl implements IIpcAlarmRulesConfigServi
|
|||||||
List<IpcAlarmRulesConfig> list = ipcAlarmRulesConfigMapper.selectIpcAlarmRulesConfigList(new IpcAlarmRulesConfig());
|
List<IpcAlarmRulesConfig> list = ipcAlarmRulesConfigMapper.selectIpcAlarmRulesConfigList(new IpcAlarmRulesConfig());
|
||||||
for (IpcMonitorField field : partList) {
|
for (IpcMonitorField field : partList) {
|
||||||
List<IpcAlarmRulesConfig> redisList = list.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getPartKey().equals(field.getFieldValue())).collect(Collectors.toList());
|
List<IpcAlarmRulesConfig> redisList = list.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getPartKey().equals(field.getFieldValue())).collect(Collectors.toList());
|
||||||
redisCache.setCacheObject(CacheConstants.RULE_CONFIG + field.getFieldValue(), redisList,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
|
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RULE_CONFIG + field.getFieldValue(), redisList,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,11 +118,11 @@ public class IpcAlarmRulesConfigServiceImpl implements IIpcAlarmRulesConfigServi
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<IpcAlarmRulesConfig> selectIpcAlarmRulesConfigList(String part) {
|
public List<IpcAlarmRulesConfig> selectIpcAlarmRulesConfigList(String part) {
|
||||||
List<IpcAlarmRulesConfig> list = redisCache.getCacheObject(CacheConstants.RULE_CONFIG + part);
|
List<IpcAlarmRulesConfig> list = redisCache.getCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RULE_CONFIG + part);
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
this.updateRedisCache();
|
this.updateRedisCache();
|
||||||
}
|
}
|
||||||
list = redisCache.getCacheObject(CacheConstants.RULE_CONFIG + part);
|
list = redisCache.getCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RULE_CONFIG + part);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,10 +99,10 @@ public class IpcMonitorFieldServiceImpl implements IIpcMonitorFieldService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<IpcMonitorField> selectFieldDataByType(String type) {
|
public List<IpcMonitorField> selectFieldDataByType(String type) {
|
||||||
List<IpcMonitorField> list = redisCache.getCacheObject(type + CacheConstants.REDIS_KEY_SEPARATOR);
|
List<IpcMonitorField> list = redisCache.getCacheObject(CacheConstants.IPC_PREFIX+type + CacheConstants.REDIS_KEY_SEPARATOR);
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
list = ipcMonitorFieldMapper.selectFieldDataByType(type);
|
list = ipcMonitorFieldMapper.selectFieldDataByType(type);
|
||||||
redisCache.setCacheObject(type + CacheConstants.REDIS_KEY_SEPARATOR, list,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
|
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+type + CacheConstants.REDIS_KEY_SEPARATOR, list,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,115 @@
|
|||||||
|
package com.inspur.ipc.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.inspur.common.constant.CacheConstants;
|
||||||
|
import com.inspur.common.core.redis.RedisCache;
|
||||||
|
import com.inspur.common.utils.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.inspur.ipc.mapper.IpcRunningStatusRecordMapper;
|
||||||
|
import com.inspur.ipc.domain.IpcRunningStatusRecord;
|
||||||
|
import com.inspur.ipc.service.IIpcRunningStatusRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行状态记录Service业务层处理
|
||||||
|
*
|
||||||
|
* @author inspur
|
||||||
|
* @date 2024-04-09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class IpcRunningStatusRecordServiceImpl implements IIpcRunningStatusRecordService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IpcRunningStatusRecordMapper ipcRunningStatusRecordMapper;
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
/**
|
||||||
|
* 查询运行状态记录
|
||||||
|
*
|
||||||
|
* @param id 运行状态记录主键
|
||||||
|
* @return 运行状态记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IpcRunningStatusRecord selectIpcRunningStatusRecordById(Long id)
|
||||||
|
{
|
||||||
|
return ipcRunningStatusRecordMapper.selectIpcRunningStatusRecordById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运行状态记录列表
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 运行状态记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<IpcRunningStatusRecord> selectIpcRunningStatusRecordList(IpcRunningStatusRecord ipcRunningStatusRecord)
|
||||||
|
{
|
||||||
|
return ipcRunningStatusRecordMapper.selectIpcRunningStatusRecordList(ipcRunningStatusRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运行状态记录
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord)
|
||||||
|
{
|
||||||
|
int num = ipcRunningStatusRecordMapper.insertIpcRunningStatusRecord(ipcRunningStatusRecord);
|
||||||
|
selectLatestStatus();
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运行状态记录
|
||||||
|
*
|
||||||
|
* @param ipcRunningStatusRecord 运行状态记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord)
|
||||||
|
{
|
||||||
|
return ipcRunningStatusRecordMapper.updateIpcRunningStatusRecord(ipcRunningStatusRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除运行状态记录
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的运行状态记录主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteIpcRunningStatusRecordByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return ipcRunningStatusRecordMapper.deleteIpcRunningStatusRecordByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除运行状态记录信息
|
||||||
|
*
|
||||||
|
* @param id 运行状态记录主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteIpcRunningStatusRecordById(Long id)
|
||||||
|
{
|
||||||
|
return ipcRunningStatusRecordMapper.deleteIpcRunningStatusRecordById(id);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查询最新状态
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String selectLatestStatus(){
|
||||||
|
String status = redisCache.getCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RUNNING_STATUS);
|
||||||
|
if(StringUtils.isNull(status) || StringUtils.isEmpty(status)){
|
||||||
|
status = ipcRunningStatusRecordMapper.selectLatestStatus();
|
||||||
|
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RUNNING_STATUS,status,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
<?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.ipc.mapper.IpcRunningStatusRecordMapper">
|
||||||
|
|
||||||
|
<resultMap type="IpcRunningStatusRecord" id="IpcRunningStatusRecordResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="runningStatus" column="running_status" />
|
||||||
|
<result property="startTime" column="start_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectIpcRunningStatusRecordVo">
|
||||||
|
select id, running_status, start_time from ipc_running_status_record
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectIpcRunningStatusRecordList" parameterType="IpcRunningStatusRecord" resultMap="IpcRunningStatusRecordResult">
|
||||||
|
<include refid="selectIpcRunningStatusRecordVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="runningStatus != null and runningStatus != ''"> and running_status = #{runningStatus}</if>
|
||||||
|
<if test="startTime != null "> and start_time = #{startTime}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectIpcRunningStatusRecordById" parameterType="Long" resultMap="IpcRunningStatusRecordResult">
|
||||||
|
<include refid="selectIpcRunningStatusRecordVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertIpcRunningStatusRecord" parameterType="IpcRunningStatusRecord" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into ipc_running_status_record
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="runningStatus != null">running_status,</if>
|
||||||
|
start_time
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="runningStatus != null">#{runningStatus},</if>
|
||||||
|
SYSDATE()
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateIpcRunningStatusRecord" parameterType="IpcRunningStatusRecord">
|
||||||
|
update ipc_running_status_record
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="runningStatus != null">running_status = #{runningStatus},</if>
|
||||||
|
<if test="startTime != null">start_time = #{startTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteIpcRunningStatusRecordById" parameterType="Long">
|
||||||
|
delete from ipc_running_status_record where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteIpcRunningStatusRecordByIds" parameterType="String">
|
||||||
|
delete from ipc_running_status_record where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectLatestStatus" resultType="string">
|
||||||
|
SELECT running_status FROM `ipc_running_status_record` ORDER BY start_time DESC LIMIT 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue
Block a user