elkers
7 天以前 3ca43c0f02fd9974eb087c79f411a3d55f806613
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/**
#                                                    __----~~~~~~~~~~~------___
#                                   .  .   ~~//====......          __--~ ~~
#                   -.            \_|//     |||\\  ~~~~~~::::... /~
#                ___-==_       _-~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);
    }
}