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

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.stereotype.Service;

import com.persagy.core.service.BaseBusinessService;
import com.persagy.core.service.BusinessService;
import com.persagy.framework.util.ConfigUtil;

@Service("QueryTypicalWeatherCity")
@SuppressWarnings({ "unchecked", "rawtypes" })
public class QueryTypicalWeatherCity extends BaseBusinessService<Map> implements BusinessService {

	@Override
	public void handle(Map dto, List content) throws Exception {
		Map<String, String> dicCode2CityId = ConfigUtil.getDicCode2CityId();
		Set<String> hourCitySet = ConfigUtil.getHourCitySet();

		Set<String> cityCodeSet = new HashSet();
		if ((!dicCode2CityId.isEmpty()) && (!hourCitySet.isEmpty())) {
			for (String code : dicCode2CityId.keySet()) {
				if (hourCitySet.contains(dicCode2CityId.get(code))) {
					cityCodeSet.add(code);
				}
			}
		}
		content.add(cityCodeSet);
	}
}
