| | |
| | | package com.fzzy.gateway; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.data.GatewayDeviceProtocol; |
| | | import com.fzzy.api.entity.ApiConfs; |
| | | import com.fzzy.api.service.*; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.api.utils.RedisUtil; |
| | | import com.fzzy.data.ConfigData; |
| | | import com.fzzy.gateway.api.GatewayRemoteManager; |
| | | import com.fzzy.gateway.data.BaseReqData; |
| | | import com.fzzy.gateway.data.WeatherWebDto; |
| | |
| | | import com.fzzy.gateway.util.GatewayHttpUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang.time.DateUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Component(GatewayTimerScheduled.BEAN_ID) |
| | | public class GatewayTimerScheduled { |
| | | |
| | | public static String DEFAULT_URL = "https://v1.yiketianqi.com/api?unescape=1&version=v61&appid={appId}&appsecret={appsecret}&cityid={cityid}"; |
| | | public static String DEFAULT_URL = "https://v1.yiketianqi.com/api?unescape=1&version=v61&appid={appId}&appsecret={appsecret}&cityid={cityid}"; |
| | | public static String DEFAULT_APP_ID = "49421971"; |
| | | public static String DEFAULT_APP_SECRET = "JmJE48Fv"; |
| | | public static String DEFAULT_CITYID = "101270101";//成都 |
| | |
| | | private GatewayConfService confService; |
| | | @Resource |
| | | private GatewayRemoteManager gatewayRemoteManager; |
| | | @Resource |
| | | private ConfigData configData; |
| | | |
| | | |
| | | /** |
| | |
| | | public void doWeatherExe() { |
| | | |
| | | try { |
| | | String url = DEFAULT_URL; |
| | | url = url.replace("{appId}", DEFAULT_APP_ID).replace("{appsecret}", DEFAULT_APP_SECRET).replace("{cityid}", DEFAULT_CITYID); |
| | | String url = configData.getWeatherPath(); |
| | | |
| | | if (null == url) { |
| | | url = DEFAULT_URL; |
| | | } |
| | | |
| | | log.debug("------气象URL---{}", url); |
| | | String result = GatewayHttpUtil.doGet(url, null); |
| | | url = url.replace("{appId}", DEFAULT_APP_ID).replace("{appsecret}", DEFAULT_APP_SECRET); |
| | | |
| | | if (StringUtils.isNotEmpty(configData.getCityId())) { |
| | | url = url.replace("{cityid}", configData.getCityId()); |
| | | } else { |
| | | url = url.replace("{cityid}", DEFAULT_CITYID); |
| | | } |
| | | |
| | | log.debug("------气象请求信息URL---{}", url); |
| | | String result = GatewayHttpUtil.doGet(url); |
| | | |
| | | if (null == result) { |
| | | log.error("当前外网获取气象信息失败……"); |