|
|
|
|
@ -1,13 +1,15 @@
|
|
|
|
|
package cn.iocoder.yudao.module.iot.dal.mysql.mqttdatarecord;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.mqttdatarecord.vo.MqttDataRecordPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.mqttdatarecord.MqttDataRecordDO;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.mqttdatarecord.vo.*;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设备数据记录 Mapper
|
|
|
|
|
@ -27,4 +29,38 @@ public interface MqttDataRecordMapper extends BaseMapperX<MqttDataRecordDO> {
|
|
|
|
|
.orderByDesc(MqttDataRecordDO::getId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default List<MqttDataRecordDO> select(MqttDataRecordPageReqVO reqVO) {
|
|
|
|
|
return selectList(new LambdaQueryWrapperX<MqttDataRecordDO>()
|
|
|
|
|
.eqIfPresent(MqttDataRecordDO::getDeviceName, reqVO.getDeviceName())
|
|
|
|
|
.eqIfPresent(MqttDataRecordDO::getAttribute, reqVO.getAttribute())
|
|
|
|
|
.eqIfPresent(MqttDataRecordDO::getAttrValue, reqVO.getAttrValue())
|
|
|
|
|
.betweenIfPresent(MqttDataRecordDO::getDeviceTime, reqVO.getDeviceTime())
|
|
|
|
|
.betweenIfPresent(MqttDataRecordDO::getCreateTime, reqVO.getCreateTime())
|
|
|
|
|
.orderByDesc(MqttDataRecordDO::getId));
|
|
|
|
|
}
|
|
|
|
|
default MqttDataRecordDO selectLastOne(MqttDataRecordPageReqVO reqVO) {
|
|
|
|
|
return selectOne(new QueryWrapper<MqttDataRecordDO>()
|
|
|
|
|
.eq(StringUtils.isNotBlank(reqVO.getDeviceName()),"device_name", reqVO.getDeviceName())
|
|
|
|
|
.eq(StringUtils.isNotBlank(reqVO.getAttribute()),"attribute", reqVO.getAttribute())
|
|
|
|
|
.orderByDesc("id")
|
|
|
|
|
.last("limit 1"));
|
|
|
|
|
}
|
|
|
|
|
default Long selectSum(MqttDataRecordPageReqVO reqVO) {
|
|
|
|
|
// SQL sum 查询
|
|
|
|
|
// List<Map<String, Object>> result = selectMaps(new QueryWrapper<MqttDataRecordDO>()
|
|
|
|
|
// .select("SUM(attr_value) AS sumCount")
|
|
|
|
|
// .eq(StringUtils.isNotBlank(reqVO.getDeviceName()),"device_name", reqVO.getDeviceName())
|
|
|
|
|
// .eq(StringUtils.isNotBlank(reqVO.getAttribute()),"attribute", reqVO.getAttribute())
|
|
|
|
|
// );
|
|
|
|
|
// // 获得数量
|
|
|
|
|
// if (CollUtil.isEmpty(result)) {
|
|
|
|
|
// return 0L;
|
|
|
|
|
// }
|
|
|
|
|
// return MapUtil.getLong(result.get(0), "sumCount", 0L);
|
|
|
|
|
List<MqttDataRecordDO> list = select(reqVO);
|
|
|
|
|
if(list!=null && list.size()>0){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
|
}
|
|
|
|
|
}
|