package com.gyee.wisdom.alarm.schedule.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gyee.wisdom.alarm.schedule.entity.AlarmSnap;
import com.gyee.wisdom.alarm.schedule.mapper.AlarmSnapMapper;
import com.gyee.wisdom.common.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @description:
 * @auther: Wanghs
 * @date: 2022-03-16
 */

@Service
public class AlarmSnapService extends ServiceImpl<AlarmSnapMapper, AlarmSnap> {
    @Autowired
    private AlarmSnapMapper alarmSnapMapper;


    public List<AlarmSnap> queryAll(String stationId,
                                    String windturbineId,
                                    String category1,
                                    String category2,
                                    String rank,
                                    String modelid,
                                    Integer isopened,
                                    String keyword,
                                    String startTime,
                                    String endTime) throws Exception {
        if (keyword != null && keyword.trim() != "")
            keyword = "%" + keyword.trim() + "%";
        Date dtStart = null;
        Date dtEnd = null;
        if (startTime != null && startTime.trim() != "")
            dtStart = DateUtil.parseDate1(startTime);
        if (endTime != null && endTime.trim() != "")
            dtEnd = DateUtil.parseDate1(endTime);

        return alarmSnapMapper.queryAll(stationId, windturbineId, category1, category2, rank,
                modelid, isopened, keyword, dtStart, dtEnd);
    }
}
