package com.jiayue.ipp.idp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiayue.ipp.common.data.entity.FileAnalysisRecord;
import com.jiayue.ipp.idp.mapper.FileAnalysisRecordMapper;
import com.jiayue.ipp.idp.service.FileAnalysisRecordService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * idp_file_analysis_record
 *
 * @author whc
 * @date 2022-03-18 15:48:51
 */
@Service
public class FileAnalysisRecordServiceImpl extends ServiceImpl<FileAnalysisRecordMapper, FileAnalysisRecord> implements FileAnalysisRecordService {
    @Override
    public QueryWrapper<FileAnalysisRecord> findByStationCodeAndCreateDateAndFileStatus(String stationCode, Date startDate, Date endDate, String fileStatus) {
        QueryWrapper<FileAnalysisRecord> wrapper = new QueryWrapper<>();
        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("station_code", stationCode);
        }
        if (startDate != null && !startDate.equals("") && endDate != null && !endDate.equals("")) {
            wrapper.between("create_time", startDate, endDate);
        }
        if (fileStatus != null && !fileStatus.equals("")) {
            wrapper.eq("file_status", fileStatus);
        }
        return wrapper;
    }
}
