/**
|
# __----~~~~~~~~~~~------___
|
# . . ~~//====...... __--~ ~~
|
# -. \_|// |||\\ ~~~~~~::::... /~
|
# ___-==_ _-~o~ \/ ||| \\ _/~~-
|
# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
|
# _-~~ .=~ | \\-_ '-~7 /- / || \ /
|
# .~ .~ | \\ -_ / /- / || \ /
|
# / ____ / | \\ ~-_/ /|- _/ .|| \ /
|
# |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\
|
# ' ~-| /| |-~\~~ __--~~
|
# |-~~-_/ | | ~\_ _-~ /\
|
# / \ \__ \/~ \__
|
# _--~ _/ | .-~~____--~-/ ~~==.
|
# ((->/~ '.|||' -_| ~~-/ , . _||
|
# -_ ~\ ~~---l__i__i__i--~~_/
|
# _-~-__ ~) \--______________--~~
|
# //.-~~~-~_--~- |-------~~~~~~~~
|
# //.-~~~--\
|
# 神兽保佑
|
# 永无BUG!
|
*/
|
package com.nanjing.water.repository.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.nanjing.water.common.ConstantFactory;
|
import com.nanjing.water.common.PagerResult;
|
import com.nanjing.water.common.enums.EYesOrNo;
|
import com.nanjing.water.common.util.*;
|
import com.nanjing.water.entity.dto.*;
|
import com.nanjing.water.entity.enums.*;
|
import com.nanjing.water.repository.BasicMapperImpl;
|
import org.springframework.stereotype.Repository;
|
|
import java.util.List;
|
import com.nanjing.water.entity.search.SearchMonitorVideoStreaming;
|
import com.nanjing.water.repository.mapper.MonitorVideoStreamingMapper;
|
import com.nanjing.water.repository.po.MonitorVideoStreamingPO;
|
|
/**
|
* 监控视频播放流
|
* @author lin.liu
|
*/
|
@Repository
|
public class MonitorVideoStreamingMapperImpl extends BasicMapperImpl<MonitorVideoStreamingPO, MonitorVideoStreamingMapper> {
|
MonitorVideoStreamingMapperImpl(MonitorVideoStreamingMapper mapper) {
|
super(mapper);
|
}
|
|
@Override
|
public PagerResult<MonitorVideoStreamingPO> search(SearchBasicDTO request) {
|
// 还原查询条件真实类型
|
SearchMonitorVideoStreaming search = (SearchMonitorVideoStreaming)request;
|
// 查询条件
|
LambdaQueryWrapper<MonitorVideoStreamingPO> queryWrapper = this.query();
|
// 非逻辑删除
|
queryWrapper.eq(MonitorVideoStreamingPO::getIsDelete, EYesOrNo.NO.getValue());
|
// 状态
|
//queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, MonitorVideoStreamingPO::getStatus, search.getStatus());
|
// 状态列表
|
//queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), MonitorVideoStreamingPO::getStatus, search.getListStatus());
|
|
// 数据创建时间-起始
|
queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, MonitorVideoStreamingPO::getCreateTime, search.getCreateTimeStart());
|
// 数据创建时间-截止
|
queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, MonitorVideoStreamingPO::getCreateTime, search.getCreateTimeEnd());
|
// 关键字
|
//if (StringUtil.isNotNullOrEmpty(search.getKeywords())) {
|
// queryWrapper.and(q ->
|
// q.like(MonitorVideoStreamingPO::getName, search.getKeywords())
|
// .or().like(MonitorVideoStreamingPO::getPhone, search.getKeywords())
|
// );
|
//}
|
|
// 排序处理
|
if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) {
|
for (OrderByDTO item : search.getOrderBy()) {
|
EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy());
|
// 顺序排序
|
if (item.getIsAsc()) {
|
switch (orderBy) {
|
// 主键
|
case ID:
|
queryWrapper.orderByAsc(MonitorVideoStreamingPO::getId);
|
break;
|
// 数据创建时间
|
case CREATE_TIME:
|
queryWrapper.orderByAsc(MonitorVideoStreamingPO::getCreateTime);
|
break;
|
// 最后更新时间
|
case UPDATE_TIME:
|
queryWrapper.orderByAsc(MonitorVideoStreamingPO::getUpdateTime);
|
break;
|
}
|
} else {
|
// 倒叙排序
|
switch (orderBy) {
|
// 主键
|
case ID:
|
queryWrapper.orderByDesc(MonitorVideoStreamingPO::getId);
|
break;
|
// 数据创建时间
|
case CREATE_TIME:
|
queryWrapper.orderByDesc(MonitorVideoStreamingPO::getCreateTime);
|
break;
|
// 最后更新时间
|
case UPDATE_TIME:
|
queryWrapper.orderByDesc(MonitorVideoStreamingPO::getUpdateTime);
|
break;
|
}
|
}
|
}
|
} else {
|
queryWrapper.orderByDesc(MonitorVideoStreamingPO::getId);
|
}
|
Page<MonitorVideoStreamingPO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper);
|
return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords());
|
}
|
|
public Boolean add(MonitorVideoStreamingPO item) {
|
int rowCount = super.insert(item);
|
return rowCount == 1;
|
}
|
|
public Boolean addNotIncrement(MonitorVideoStreamingPO item) {
|
int rowCount = super.insert(item);
|
return rowCount == 1;
|
}
|
public MonitorVideoStreamingPO getByDeviceId(String deviceId,String channelId) {
|
LambdaQueryWrapper<MonitorVideoStreamingPO> queryWrapper = this.query();
|
queryWrapper.eq(MonitorVideoStreamingPO::getDeviceId,deviceId);
|
queryWrapper.eq(MonitorVideoStreamingPO::getChannelId,channelId);
|
|
return super.selectOne(queryWrapper);
|
}
|
public MonitorVideoStreamingPO getById(Long id) {
|
return super.get(id);
|
}
|
|
public List<MonitorVideoStreamingPO> getListById(List<Long> listId) {
|
return super.getList(listId);
|
}
|
public int updateEndTime(Long id) {
|
MonitorVideoStreamingPO upd = new MonitorVideoStreamingPO();
|
upd.setId(id);
|
upd.setEndTime(LocalDateTimeUtil.nowTimeStamp() + ConstantFactory.TIME_LEN_1MIN * 3L);
|
return super.updateById(upd);
|
}
|
public List<MonitorVideoStreamingPO> getAllByPoint(Long pointId) {
|
LambdaQueryWrapper<MonitorVideoStreamingPO> queryWrapper = this.query();
|
queryWrapper.eq(MonitorVideoStreamingPO::getPointId,pointId);
|
return super.selectList(queryWrapper);
|
}
|
public List<MonitorVideoStreamingPO> list4WaitingStop() {
|
LambdaQueryWrapper<MonitorVideoStreamingPO> queryWrapper = this.query();
|
queryWrapper.eq(MonitorVideoStreamingPO::getState,EYesOrNo.YES.getValue());
|
queryWrapper.le(MonitorVideoStreamingPO::getEndTime,LocalDateTimeUtil.nowTimeStamp());
|
return super.selectList(queryWrapper);
|
}
|
}
|