| | |
| | | package com.ycl.service.smoke.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.entity.smoke.OdsAlarmMsg; |
| | | import com.ycl.entity.smoke.OdsInTime; |
| | | import com.ycl.mapper.smoke.OdsAlarmMsgMapper; |
| | | import com.ycl.service.smoke.IOdsAlarmMsgService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class OdsAlarmMsgServiceImpl extends ServiceImpl<OdsAlarmMsgMapper, OdsAlarmMsg> implements IOdsAlarmMsgService { |
| | | |
| | | @Override |
| | | public Page<OdsAlarmMsg> findList(String type, String startTime, String endTime, Integer pageSize, Integer pageNum) { |
| | | Page<OdsAlarmMsg> page = new Page<>(pageNum, pageSize); |
| | | QueryWrapper<OdsAlarmMsg> wrapper = new QueryWrapper<>(); |
| | | LambdaQueryWrapper<OdsAlarmMsg> lambda = wrapper.lambda(); |
| | | |
| | | if (StrUtil.isNotEmpty(startTime)) { |
| | | try { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date startdate = format.parse(startTime); |
| | | Long startTimestamp = startdate.getTime() / 1000; |
| | | |
| | | Date enddate = format.parse(endTime); |
| | | Long endTimestamp = enddate.getTime() / 1000; |
| | | |
| | | lambda.between(OdsAlarmMsg::getAcquitAt, startTimestamp, endTimestamp); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | if (StrUtil.isNotEmpty(type)) { |
| | | lambda.eq(OdsAlarmMsg::getMsgType, type); |
| | | } |
| | | wrapper.orderByDesc("id"); |
| | | return this.page(page, wrapper); |
| | | } |
| | | } |