package com.persagy.functions.weather.business.v2020.maintain;

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

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.persagy.core.mvc.service.CoreService;
import com.persagy.core.service.BaseBusinessService;
import com.persagy.core.service.BusinessService;
import com.persagy.framework.util.DateUtils;
import com.persagy.functions.weather.constant.Const;
import com.persagy.functions.weather.thread.HourRepairThread;

/**
 * 修复小时数据 
 */
@Service("HourDataRepair")
@SuppressWarnings({"unchecked","rawtypes" })
public class HourDataRepair extends BaseBusinessService<Map> implements BusinessService {
	@Resource(name="coreService")
	private CoreService coreService;
	
	@Override
	public void handle(Map dto, List content) throws Exception {
		// ALL，所有城市, ALL_12，跳过12个城市从第13个城市开始计算
		String cityId = (String) dto.get("cityId");
		
		// yyyy-MM-dd
		String startDay = (String) dto.get("startDay");
		String endDay = (String) dto.get("endDay");
		
		if(cityId == null || startDay == null || endDay == null) {
			throw new Exception(Const.ErrorTag.paramMis);
		}
		
		Date fromDay = DateUtils.str2Date(startDay, DateUtils.SDF_DAY);
		Date toDay = DateUtils.str2Date(endDay, DateUtils.SDF_DAY);
		
		new Thread(new HourRepairThread(coreService, cityId, fromDay, toDay)).start();
		
		content.add("HourRepairThread task start running...");
	}
	
}
