package com.shanghaichengdi.ghjgitem.vo.request;

import com.shanghaichengdi.ghjgitem.vo.PageVo;
import com.shanghaigeography.Util.DateUtils;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class PollutantBoatWaterReq extends PageVo {

  String boatName;
  String mmsi;
  String pollutantType;
  String source;
  String startTime;
  String endTime;

  public static List<String> getDatesBetween(String startDateStr, String endDateStr)
      throws ParseException {
    Date startDate = DateUtils.stringToDate(startDateStr, DateUtils.DATE_FORMAT_10);
    Date endDate = DateUtils.stringToDate(endDateStr, DateUtils.DATE_FORMAT_10);
    List<String> dates = new ArrayList<>();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(startDate);

    while (calendar.getTime().before(endDate)) {
      dates.add(DateUtils.dateToString(calendar.getTime(), DateUtils.DATE_FORMAT_11));
      calendar.add(Calendar.DATE, 1);
    }
    dates.add(DateUtils.dateToString(endDate, DateUtils.DATE_FORMAT_11));
    return dates;
  }

//  public static void main(String[] args) throws ParseException {
////    Date startDate = DateUtils.stringToDate("2024-06-01", DateUtils.DATE_FORMAT_11);
////    Date endDate = DateUtils.stringToDate("2024-06-08", DateUtils.DATE_FORMAT_11);
//    String startDate = "2024-06-01";
//    String endDate = "2024-06-08";
//    List<String> tableNameList = new ArrayList<>();
//    List<String> datesBetween = PollutantBoatWaterReq.getDatesBetween(startDate, endDate);
//    String partitionPrefix = "POLLUTANT_ACCEPT_F";
//    datesBetween.forEach(
//        x -> tableNameList.add("ghjg_bussiness.boat_water_pollutant_accept_f " + "partition(" +
//            partitionPrefix + x + ")" + " a"));
//    System.out.println("查询的表名为:" + JSONObject.toJSONString(tableNameList));
//  }
}
