package org.jeecg.modules.newWarning.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.newWarning.dto.WarnLogComprehensiveDto;
import org.jeecg.modules.newWarning.dto.WarnLogStatisticsDto;
import org.jeecg.modules.newWarning.entity.TotalPoolVolumeWarnLog;
import org.jeecg.modules.newWarning.mapper.TotalPoolVolumeWarnLogMapper;
import org.jeecg.modules.newWarning.params.WarnLogCountParams;
import org.jeecg.modules.newWarning.service.TotalPoolVolumeWarnLogService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
* @author 费玉泉
* @description 针对表【TOTAL_POOL_VOLUME_WARN_LOG(总池体积预警数据日志表)】的数据库操作Service实现
* @createDate 2024-06-06 09:08:33
*/
@Service
public class TotalPoolVolumeWarnLogServiceImpl extends ServiceImpl<TotalPoolVolumeWarnLogMapper, TotalPoolVolumeWarnLog>
    implements TotalPoolVolumeWarnLogService {

    @Override
    public List<WarnLogComprehensiveDto> getWarnLogList(HashMap<String, Object> params){
        return baseMapper.getWarnLogList(params);
    }

    @Override
    public List<WarnLogStatisticsDto> getWarnLogCount(WarnLogCountParams params){
        QueryWrapper<WarnLogCountParams> wrapper=new QueryWrapper<>();
        return baseMapper.getWarnLogCount(wrapper);
    }

    @Override
    public Integer getWarnCountByJhAndDate(String jh, String startTime, String endTime,String type){
        QueryWrapper<TotalPoolVolumeWarnLog> wrapper=new QueryWrapper<>();
        wrapper.lambda().eq(TotalPoolVolumeWarnLog::getJh, jh);
        wrapper.lambda().eq(TotalPoolVolumeWarnLog::getTotalWarnType, type);
        wrapper.apply("warn_time >= to_date({0},'yyyy-mm-dd hh24:mi:ss')", startTime);
        wrapper.apply("warn_time <= to_date({0},'yyyy-mm-dd hh24:mi:ss')", endTime);
        return this.count(wrapper);
    }
}




