缓存优化
This commit is contained in:
parent
e759bebb84
commit
0af2a8b43b
@ -9,7 +9,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运行状态记录对象 ipc_running_status_record
|
* 产线运行状态记录对象 ipc_running_status_record_dept
|
||||||
*
|
*
|
||||||
* @author inspur
|
* @author inspur
|
||||||
* @date 2024-04-09
|
* @date 2024-04-09
|
||||||
@ -31,8 +31,8 @@ public class IpcRunningStatusRecord extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 开始时间
|
* 开始时间
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
private Long detpId;
|
private Long detpId;
|
||||||
|
|
||||||
|
@ -67,6 +67,11 @@ public interface IIpcMonitorFieldService
|
|||||||
*/
|
*/
|
||||||
public List<IpcMonitorField> selectFieldDataByType(String fieldType);
|
public List<IpcMonitorField> selectFieldDataByType(String fieldType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新缓存
|
||||||
|
*/
|
||||||
|
public List<IpcMonitorField> updateFieldDataByType(String fieldType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取监测设备
|
* 获取监测设备
|
||||||
*/
|
*/
|
||||||
|
@ -101,12 +101,19 @@ public class IpcMonitorFieldServiceImpl implements IIpcMonitorFieldService {
|
|||||||
public List<IpcMonitorField> selectFieldDataByType(String type) {
|
public List<IpcMonitorField> selectFieldDataByType(String type) {
|
||||||
List<IpcMonitorField> list = redisCache.getCacheObject(CacheConstants.IPC_PREFIX + type);
|
List<IpcMonitorField> list = redisCache.getCacheObject(CacheConstants.IPC_PREFIX + type);
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
list = ipcMonitorFieldMapper.selectFieldDataByType(type);
|
list = this.updateFieldDataByType(type);
|
||||||
redisCache.setCacheObject(CacheConstants.IPC_PREFIX + type, list);
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 更新缓存
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<IpcMonitorField> updateFieldDataByType(String fieldType){
|
||||||
|
List<IpcMonitorField> list = ipcMonitorFieldMapper.selectFieldDataByType(fieldType);
|
||||||
|
redisCache.setCacheObject(CacheConstants.IPC_PREFIX + fieldType, list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 获取监测设备
|
* 获取监测设备
|
||||||
*/
|
*/
|
||||||
|
@ -26,10 +26,10 @@ public class IpcRedisCacheConfiguration {
|
|||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void preloadedRedisCache(){
|
public void preloadedRedisCache(){
|
||||||
iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_EQUIP_KEY);
|
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.MONITOR_EQUIP_KEY);
|
||||||
iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.SENSOR_MONITOR_PARAMS_KEY);
|
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.SENSOR_MONITOR_PARAMS_KEY);
|
||||||
iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
|
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
|
||||||
iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_READ_KEY);
|
iIpcMonitorFieldService.updateFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_READ_KEY);
|
||||||
iIpcAlarmRulesConfigService.updateRedisCache();
|
iIpcAlarmRulesConfigService.updateRedisCache();
|
||||||
iIpcRunningStatusRecordService.selectLatestStatus();
|
iIpcRunningStatusRecordService.selectLatestStatus();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectIpcRunningStatusRecordVo">
|
<sql id="selectIpcRunningStatusRecordVo">
|
||||||
select id, running_status, start_time,dept_id from ipc_running_status_record
|
select id, running_status, start_time,dept_id from ipc_running_status_record_dept
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectIpcRunningStatusRecordList" parameterType="com.inspur.ipc.domain.IpcRunningStatusRecord" resultMap="IpcRunningStatusRecordResult">
|
<select id="selectIpcRunningStatusRecordList" parameterType="com.inspur.ipc.domain.IpcRunningStatusRecord" resultMap="IpcRunningStatusRecordResult">
|
||||||
@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertIpcRunningStatusRecord" parameterType="com.inspur.ipc.domain.IpcRunningStatusRecord" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertIpcRunningStatusRecord" parameterType="com.inspur.ipc.domain.IpcRunningStatusRecord" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into ipc_running_status_record
|
insert into ipc_running_status_record_dept
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="runningStatus != null">running_status,</if>
|
<if test="runningStatus != null">running_status,</if>
|
||||||
start_time,
|
start_time,
|
||||||
@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateIpcRunningStatusRecord" parameterType="com.inspur.ipc.domain.IpcRunningStatusRecord">
|
<update id="updateIpcRunningStatusRecord" parameterType="com.inspur.ipc.domain.IpcRunningStatusRecord">
|
||||||
update ipc_running_status_record
|
update ipc_running_status_record_dept
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="runningStatus != null">running_status = #{runningStatus},</if>
|
<if test="runningStatus != null">running_status = #{runningStatus},</if>
|
||||||
<if test="startTime != null">start_time = #{startTime},</if>
|
<if test="startTime != null">start_time = #{startTime},</if>
|
||||||
@ -54,17 +54,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteIpcRunningStatusRecordById" parameterType="Long">
|
<delete id="deleteIpcRunningStatusRecordById" parameterType="Long">
|
||||||
delete from ipc_running_status_record where id = #{id}
|
delete from ipc_running_status_record_dept where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteIpcRunningStatusRecordByIds" parameterType="String">
|
<delete id="deleteIpcRunningStatusRecordByIds" parameterType="String">
|
||||||
delete from ipc_running_status_record where id in
|
delete from ipc_running_status_record_dept where id in
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="selectLatestStatus" resultType="string">
|
<select id="selectLatestStatus" resultType="string">
|
||||||
SELECT running_status FROM `ipc_running_status_record` WHERE dept_id = #{deptId} ORDER BY start_time DESC LIMIT 1
|
SELECT running_status FROM `ipc_running_status_record_dept` WHERE dept_id = #{deptId} ORDER BY start_time DESC LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user