/**
|
# __----~~~~~~~~~~~------___
|
# . . ~~//====...... __--~ ~~
|
# -. \_|// |||\\ ~~~~~~::::... /~
|
# ___-==_ _-~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.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.entity.search.SearchAlarmHistory;
|
import com.nanjing.water.repository.BasicMapperImpl;
|
import com.nanjing.water.repository.mapper.AlarmHistoryMapper;
|
import com.nanjing.water.repository.po.AlarmHistoryPO;
|
import org.springframework.stereotype.Repository;
|
|
import java.util.List;
|
|
/**
|
* 报警信息
|
* @author lin.liu
|
*/
|
@Repository
|
public class AlarmHistoryMapperImpl extends BasicMapperImpl<AlarmHistoryPO, AlarmHistoryMapper> {
|
AlarmHistoryMapperImpl(AlarmHistoryMapper mapper) {
|
super(mapper);
|
}
|
|
@Override
|
public PagerResult<AlarmHistoryPO> search(SearchBasicDTO request) {
|
// 还原查询条件真实类型
|
SearchAlarmHistory search = (SearchAlarmHistory)request;
|
// 查询条件
|
LambdaQueryWrapper<AlarmHistoryPO> queryWrapper = this.query();
|
// 非逻辑删除
|
queryWrapper.eq(AlarmHistoryPO::getIsDelete, EYesOrNo.NO.getValue());
|
// 状态
|
//queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, AlarmHistoryPO::getStatus, search.getStatus());
|
// 状态列表
|
//queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), AlarmHistoryPO::getStatus, search.getListStatus());
|
|
// 数据创建时间-起始
|
queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, AlarmHistoryPO::getCreateTime, search.getCreateTimeStart());
|
// 数据创建时间-截止
|
queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, AlarmHistoryPO::getCreateTime, search.getCreateTimeEnd());
|
// 关键字
|
//if (StringUtil.isNotNullOrEmpty(search.getKeywords())) {
|
// queryWrapper.and(q ->
|
// q.like(AlarmHistoryPO::getName, search.getKeywords())
|
// .or().like(AlarmHistoryPO::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(AlarmHistoryPO::getId);
|
break;
|
// 数据创建时间
|
case CREATE_TIME:
|
queryWrapper.orderByAsc(AlarmHistoryPO::getCreateTime);
|
break;
|
// 最后更新时间
|
case UPDATE_TIME:
|
queryWrapper.orderByAsc(AlarmHistoryPO::getUpdateTime);
|
break;
|
}
|
} else {
|
// 倒叙排序
|
switch (orderBy) {
|
// 主键
|
case ID:
|
queryWrapper.orderByDesc(AlarmHistoryPO::getId);
|
break;
|
// 数据创建时间
|
case CREATE_TIME:
|
queryWrapper.orderByDesc(AlarmHistoryPO::getCreateTime);
|
break;
|
// 最后更新时间
|
case UPDATE_TIME:
|
queryWrapper.orderByDesc(AlarmHistoryPO::getUpdateTime);
|
break;
|
}
|
}
|
}
|
} else {
|
queryWrapper.orderByDesc(AlarmHistoryPO::getId);
|
}
|
Page<AlarmHistoryPO> pageResult = super.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper);
|
return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords());
|
}
|
|
public Boolean add(AlarmHistoryPO item) {
|
int rowCount = super.insert(item);
|
return rowCount == 1;
|
}
|
|
public Boolean addNotIncrement(AlarmHistoryPO item) {
|
int rowCount = super.insert(item);
|
return rowCount == 1;
|
}
|
|
public AlarmHistoryPO getById(Long id) {
|
return super.get(id);
|
}
|
|
public List<AlarmHistoryPO> getListById(List<Long> listId) {
|
return super.getList(listId);
|
}
|
|
|
public List<AlarmHistoryPO> getListByTime(Long beginTime,Long endTime) {
|
LambdaQueryWrapper<AlarmHistoryPO> queryWrapper = this.query();
|
queryWrapper.between(AlarmHistoryPO::getLastTime,beginTime,endTime);
|
return super.selectList(queryWrapper);
|
}
|
public AlarmHistoryPO getListByFacilityId(Long facilityId,Integer code) {
|
LambdaQueryWrapper<AlarmHistoryPO> queryWrapper = this.query();
|
queryWrapper.eq(AlarmHistoryPO::getFacilityId,facilityId);
|
queryWrapper.eq(AlarmHistoryPO::getCode,code);
|
queryWrapper.ne(AlarmHistoryPO::getIsConfirm,30);
|
queryWrapper.ne(AlarmHistoryPO::getIsConfirm,200);
|
return super.selectOne(queryWrapper);
|
}
|
}
|