数据接收功能修改

This commit is contained in:
zhangjunwen 2024-10-09 18:01:26 +08:00
parent 00193a7252
commit cacf21776c
4 changed files with 95 additions and 89 deletions

View File

@ -244,7 +244,7 @@ public class MyMqttCallback implements MqttCallback {
fields.put(v,(Double.parseDouble(msg.get(k).toString()) - 400) * 1.25); fields.put(v,(Double.parseDouble(msg.get(k).toString()) - 400) * 1.25);
break; break;
case "temp": case "temp":
fields.put(v,Double.parseDouble(msg.get(k).toString()) * 0.1); fields.put(v,Double.parseDouble(msg.get(k).toString()) / 10.0);
break; break;
default: default:
fields.put(v,msg.get(k)); fields.put(v,msg.get(k));

View File

@ -32,7 +32,7 @@ public class DataQueryService implements IDataQueryService{
public Map<String, Object> selectDataListByPages(String equipId, String tableName, String startTime, String endTime, Integer pageSize, Integer pageNum) { public Map<String, Object> selectDataListByPages(String equipId, String tableName, String startTime, String endTime, Integer pageSize, Integer pageNum) {
Map<String, Object> resMap = new HashMap<>(); Map<String, Object> resMap = new HashMap<>();
//TODO 分页查找条数根据设备id表名时间范围页码每页条数 //TODO 分页查找条数根据设备id表名时间范围页码每页条数
List<Map<String, Object>> dataList = queryDataByTime(tableName, null, startTime, endTime, pageNum, pageSize); List<Map<String, Object>> dataList = queryDataByTime(tableName, equipId, startTime, endTime, pageNum, pageSize);
dataList.forEach(map -> { dataList.forEach(map -> {
try { try {
String time = map.get("time").toString(); String time = map.get("time").toString();
@ -44,7 +44,11 @@ public class DataQueryService implements IDataQueryService{
//TODO 时间需要将查询到的UTC时间转为系统时间北京时间 //TODO 时间需要将查询到的UTC时间转为系统时间北京时间
// DateUtils.tranUTC2LocalDateTime("2024-08-28T08:00:00Z"); // DateUtils.tranUTC2LocalDateTime("2024-08-28T08:00:00Z");
//TODO 查询数据总条数 //TODO 查询数据总条数
long total = countDataList(tableName, "x_push_temp", null, startTime, endTime); long total = 0L;
if (dataList.size() != 0) {
List<String> keys = new ArrayList<>(dataList.get(0).keySet());
total = countDataList(tableName, keys.get(0), null, startTime, endTime);
}
resMap.put("list", dataList); resMap.put("list", dataList);
resMap.put("total", total); resMap.put("total", total);
return resMap; return resMap;
@ -191,8 +195,7 @@ public class DataQueryService implements IDataQueryService{
/** /**
* 按照策略分段查询数据列表 * 按照策略分段查询数据列表
*/ */
private List<Map<String, Object>> selectDataByColumnNameandDateSegmentation(String equipId, String tableName, String columnName, String startTime, String endTime,long intervalHours) private List<Map<String, Object>> selectDataByColumnNameandDateSegmentation(String equipId, String tableName, String columnName, String startTime, String endTime, long intervalHours) {
{
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
if (intervalHours <= 6) {//6小时内全查 if (intervalHours <= 6) {//6小时内全查
list = selectDataByColumnNameandDate(null, tableName, columnName, startTime, endTime); list = selectDataByColumnNameandDate(null, tableName, columnName, startTime, endTime);
@ -266,6 +269,7 @@ public class DataQueryService implements IDataQueryService{
/** /**
* 根据字段名称和起止时间查询数据 * 根据字段名称和起止时间查询数据
*
* @param tableName 表名 * @param tableName 表名
* @param columnName 字段名称 * @param columnName 字段名称
* @param beginTime 起始时间 * @param beginTime 起始时间

View File

@ -104,6 +104,8 @@ public class NoticeController {
Assert.notNull(notice, "公告不能为空"); Assert.notNull(notice, "公告不能为空");
// 直接插入站内信表 // 直接插入站内信表
notice.setId(null); notice.setId(null);
notice.setCreateTime(null);
notice.setUpdateTime(null);
NotifyMessageDO notifyMessage = BeanUtils.toBean(notice, NotifyMessageDO.class); NotifyMessageDO notifyMessage = BeanUtils.toBean(notice, NotifyMessageDO.class);
notifyMessage.setTemplateNickname(SecurityFrameworkUtils.getLoginUserNickname()); notifyMessage.setTemplateNickname(SecurityFrameworkUtils.getLoginUserNickname());
notifyMessage.setTemplateType(notice.getType()); notifyMessage.setTemplateType(notice.getType());

View File

@ -55,17 +55,17 @@ public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> {
default List<NotifyMessageDO> selectUnreadListByUserIdAndUserType(Long userId, Integer userType, Integer size) { default List<NotifyMessageDO> selectUnreadListByUserIdAndUserType(Long userId, Integer userType, Integer size) {
return selectList(new QueryWrapperX<NotifyMessageDO>() // 由于要使用 limitN 语句所以只能用 QueryWrapperX return selectList(new QueryWrapperX<NotifyMessageDO>() // 由于要使用 limitN 语句所以只能用 QueryWrapperX
.eq("user_id", userId) // .eq("user_id", userId)
.eq("user_type", userType) // .eq("user_type", userType)
.eq("read_status", false) .eq("read_status", false)
.orderByDesc("id").limitN(size)); .orderByDesc("id").limitN(size));
} }
default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) { default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) {
return selectCount(new LambdaQueryWrapperX<NotifyMessageDO>() return selectCount(new LambdaQueryWrapperX<NotifyMessageDO>()
.eq(NotifyMessageDO::getReadStatus, false) .eq(NotifyMessageDO::getReadStatus, false));
.eq(NotifyMessageDO::getUserId, userId) // .eq(NotifyMessageDO::getUserId, userId)
.eq(NotifyMessageDO::getUserType, userType)); // .eq(NotifyMessageDO::getUserType, userType));
} }
} }