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

import com.gyee.wisdom.common.utils.DateUtil;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Service
public class TableNameService {

    public static String FORMAT_ALARMHISTORY  = "alarmhistory_%s_%s";
    public static SimpleDateFormat FORMAT_DATE = new SimpleDateFormat("yyyyMM");
    public static Date DT_BEGIN = new Date(119,06,01);

    public String getAlarmHistoryTableName(String stationId, Date dt) {
        try {
            if (dt.before(DT_BEGIN))
                return "alarmhistory_before201907";

            String[] arr = stationId.split("_");
            return String.format(FORMAT_ALARMHISTORY, arr[0].toLowerCase(), FORMAT_DATE.format(dt));
        }catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

        return "";
    }



}
