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.HookLoadWarnLog;

import org.jeecg.modules.newWarning.entity.NewWarnHistory;
import org.jeecg.modules.newWarning.mapper.HookLoadWarnLogMapper;
import org.jeecg.modules.newWarning.params.WarnLogCountParams;
import org.jeecg.modules.newWarning.service.HookLoadWarnLogService;
import org.springframework.stereotype.Service;

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

/**
* @author 费玉泉
* @description 针对表【HOOK_LOAD_WARN_LOG(钩载预警数据表)】的数据库操作Service实现
* @createDate 2024-05-30 09:23:16
*/
@Service
public class HookLoadWarnLogServiceImpl extends ServiceImpl<HookLoadWarnLogMapper, HookLoadWarnLog>
    implements HookLoadWarnLogService {

    @Override
    public NewWarnHistory getOneWarning(String startTime, String endTime, String jh ){
        return baseMapper.getOneWarning( startTime, endTime, jh );
    }
    @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){
        QueryWrapper<HookLoadWarnLog> wrapper=new QueryWrapper<>();
        wrapper.lambda().eq(HookLoadWarnLog::getJh, jh);
        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);
    }

}




