6 changed files with 122 additions and 4 deletions
@ -0,0 +1,64 @@
|
||||
package com.mh.quartz.task; |
||||
|
||||
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||
import com.mh.common.core.redis.RedisCache; |
||||
import com.mh.framework.dealdata.DataProcessService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.time.Duration; |
||||
import java.time.LocalDateTime; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 处理上来的数据报文 |
||||
* @date 2025-02-10 14:19:36 |
||||
*/ |
||||
@Slf4j |
||||
@Component("dealDataTask") |
||||
public class DealDataTask { |
||||
|
||||
private final RedisCache redisCache; |
||||
|
||||
private final DataProcessService dataProcessService; |
||||
|
||||
@Autowired |
||||
public DealDataTask(RedisCache redisCache, DataProcessService dataProcessService) { |
||||
this.redisCache = redisCache; |
||||
this.dataProcessService = dataProcessService; |
||||
} |
||||
|
||||
|
||||
public void dealDeviceData() { |
||||
List<CollectionParamsManage> cacheList = redisCache.getCacheList("CHILLERS", CollectionParamsManage.class); |
||||
if (null == cacheList || cacheList.isEmpty()) { |
||||
return; |
||||
} |
||||
//清空redis
|
||||
redisCache.deleteObject("CHILLERS"); |
||||
//处理chillers数据
|
||||
try { |
||||
//todo 处理没有对象curValue和curTime的异常
|
||||
dealChillersCollect(cacheList); |
||||
} catch (Exception e) { |
||||
log.error("处理主机参数异常:{}", e); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 处理主机秒级数据,再计算主机运行时间 |
||||
* |
||||
* @param cacheList |
||||
*/ |
||||
private void dealChillersCollect(List<CollectionParamsManage> cacheList) throws Exception { |
||||
//插入报表,将历史数据插入chillers_data_min
|
||||
//1.插入register_id,当前值,当前时间,名字
|
||||
dataProcessService.insertChillerReport(cacheList); |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.mh.system.mapper.device; |
||||
|
||||
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||
import org.apache.ibatis.annotations.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author : ljf |
||||
* @date : 2025-02-10 |
||||
*/ |
||||
@Mapper |
||||
public interface DataProcessMapper { |
||||
|
||||
/** |
||||
* 批量插入冷水机组分钟记录保存表 |
||||
* |
||||
* @param batchList |
||||
* @param tableName |
||||
*/ |
||||
@Select("<script>" + |
||||
"insert into ${tableName}(device_num, device_code, register_address,register_name, cur_value,cur_time,grade,register_id)" + |
||||
"values " + |
||||
"<foreach collection='batchList' item='item' index='index' separator=','>" + |
||||
"(#{item.mtNum},#{item.mtCode},#{item.registerAddr},#{item.otherName},#{item.curValue},#{item.curTime},#{item.grade},#{item.id})" + |
||||
"</foreach>" + |
||||
"</script>") |
||||
void batchInsertChiller(@Param("batchList") List<CollectionParamsManage> batchList, @Param("tableName") String tableName); |
||||
|
||||
} |
Loading…
Reference in new issue