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.TorqueWarnLog;
import org.jeecg.modules.newWarning.params.WarnLogCountParams;
import org.jeecg.modules.newWarning.service.TorqueWarnLogService;
import org.jeecg.modules.newWarning.mapper.TorqueWarnLogMapper;
import org.springframework.stereotype.Service;

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

/**
* @author 费玉泉
* @description 针对表【TORQUE_WARN_LOG(扭矩预警日志表)】的数据库操作Service实现
* @createDate 2024-06-18 10:01:04
*/
@Service
public class TorqueWarnLogServiceImpl extends ServiceImpl<TorqueWarnLogMapper, TorqueWarnLog>
    implements TorqueWarnLogService{

    @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<TorqueWarnLog> wrapper=new QueryWrapper<>();
        wrapper.lambda().eq(TorqueWarnLog::getJh, jh);
        wrapper.apply("warn_start_time >= to_date({0},'yyyy-mm-dd hh24:mi:ss')", startTime);
        wrapper.apply("warn_start_time <= to_date({0},'yyyy-mm-dd hh24:mi:ss')", endTime);
        return this.count(wrapper);
    }
}




