|  | @@ -3,9 +3,11 @@ package com.xunmei.core.weather.service.impl;
 | 
	
		
			
				|  |  |  import cn.hutool.core.date.DateTime;
 | 
	
		
			
				|  |  |  import cn.hutool.core.date.DateUtil;
 | 
	
		
			
				|  |  |  import cn.hutool.core.util.ObjectUtil;
 | 
	
		
			
				|  |  | +import cn.hutool.http.HttpUtil;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.TypeReference;
 | 
	
		
			
				|  |  |  import com.alibaba.nacos.common.utils.CollectionUtils;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
	
		
			
				|  | @@ -13,6 +15,7 @@ import com.xunmei.common.core.constant.ErrorMsgConstants;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.constant.SecurityConstants;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.constant.SystemParameterConstant;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.domain.weather.domain.WeatherWarning;
 | 
	
		
			
				|  |  | +import com.xunmei.common.core.domain.weather.dto.WeatherParaDto;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.domain.weather.dto.WeatherWarningDto;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.domain.weather.vo.CityInfoVo;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.domain.weather.vo.SelectCityInfoVo;
 | 
	
	
		
			
				|  | @@ -71,12 +74,18 @@ public class WeatherWarningServiceImpl extends ServiceImpl<WeatherWarningMapper,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void getDataFromApi() {
 | 
	
		
			
				|  |  | -        SysConfig sysConfig =  RemoteCallHandlerExecutor.executeRemoteCall(() -> systemParameService.findSysConfigByCode("WEATHER_APP_CODE", SecurityConstants.INNER),ErrorMsgConstants.QUERY_SYS_CONFIG_ERROR);
 | 
	
		
			
				|  |  | -        String appCode = sysConfig.getConfigValue();
 | 
	
		
			
				|  |  | -        if(StringUtils.isEmpty(appCode)){
 | 
	
		
			
				|  |  | +        SysConfig sysConfig =  RemoteCallHandlerExecutor.executeRemoteCall(() -> systemParameService.findSysConfigByCode(SystemParameterConstant.WEATHER_URL, SecurityConstants.INNER),ErrorMsgConstants.QUERY_SYS_CONFIG_ERROR);
 | 
	
		
			
				|  |  | +        String weather_url = sysConfig.getConfigValue();
 | 
	
		
			
				|  |  | +        if(StringUtils.isEmpty(weather_url)){
 | 
	
		
			
				|  |  |              log.error("尚未开通天气预警服务");
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        String weather_para_str = systemParameService.findSysConfigByCode(SystemParameterConstant.WEATHER_PAPA, SecurityConstants.INNER).getConfigValue();
 | 
	
		
			
				|  |  | +        if(StringUtils.isEmpty(weather_para_str)){
 | 
	
		
			
				|  |  | +            log.error("访问获取天气预警接口参数未配置");
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        WeatherParaDto weatherPara = JSON.parseObject(weather_para_str,new TypeReference<WeatherParaDto>(){});
 | 
	
		
			
				|  |  |          //获取区域id
 | 
	
		
			
				|  |  |      List<String> areaIds =baseMapper.findAreaList();
 | 
	
		
			
				|  |  |          /*List<String> areaIds = new ArrayList<>();
 | 
	
	
		
			
				|  | @@ -87,7 +96,7 @@ public class WeatherWarningServiceImpl extends ServiceImpl<WeatherWarningMapper,
 | 
	
		
			
				|  |  |          DateTime time = DateUtil.beginOfDay(new Date());
 | 
	
		
			
				|  |  |          List<WeatherWarning> listAll =baseMapper.findListAllByDate(time);
 | 
	
		
			
				|  |  |          for(String areaId:areaIds){
 | 
	
		
			
				|  |  | -            String str = this.getWeathDatafromApi(areaId,appCode);
 | 
	
		
			
				|  |  | +            String str = this.getWeathDatafromApi(areaId,weather_url,weatherPara);
 | 
	
		
			
				|  |  |              if(StringUtils.isNotEmpty(str)){
 | 
	
		
			
				|  |  |                  List<WeatherWarning> list =this.buildWeatherWarningList(str);
 | 
	
		
			
				|  |  |                  if(CollectionUtils.isNotEmpty(list)){
 | 
	
	
		
			
				|  | @@ -150,31 +159,34 @@ public class WeatherWarningServiceImpl extends ServiceImpl<WeatherWarningMapper,
 | 
	
		
			
				|  |  |           return cityInfoVoList;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private  String getWeathDatafromApi(String areaId,String appCode){
 | 
	
		
			
				|  |  | +    private  String getWeathDatafromApi(String areaId,String weather_url,WeatherParaDto para){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        String host = systemParameService.findSysConfigByCode(SystemParameterConstant.WEATHER_URL, SecurityConstants.INNER).getConfigValue();
 | 
	
		
			
				|  |  | -        String path = "/area-to-weather";
 | 
	
		
			
				|  |  | -        String method = "GET";
 | 
	
		
			
				|  |  | -        //String appcode = "6d7d4fa382234e36893f4226f9dd3379";
 | 
	
		
			
				|  |  | -        Map<String, String> headers = new HashMap<String, String>();
 | 
	
		
			
				|  |  | -        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
 | 
	
		
			
				|  |  | -        headers.put("Authorization", "APPCODE " + appCode);
 | 
	
		
			
				|  |  | -        Map<String, String> querys = new HashMap<String, String>();
 | 
	
		
			
				|  |  | -        querys.put("areaid", areaId);
 | 
	
		
			
				|  |  | -        querys.put("need3HourForcast", "0");
 | 
	
		
			
				|  |  | -        querys.put("needAlarm", "1");
 | 
	
		
			
				|  |  | -        querys.put("needHourData", "0");
 | 
	
		
			
				|  |  | -        querys.put("needIndex", "0");
 | 
	
		
			
				|  |  | -        querys.put("needMoreDay", "0");
 | 
	
		
			
				|  |  | +//        String host = systemParameService.findSysConfigByCode(SystemParameterConstant.WEATHER_URL, SecurityConstants.INNER).getConfigValue();
 | 
	
		
			
				|  |  | +//        String path = "/area-to-weather";
 | 
	
		
			
				|  |  | +//        String method = "GET";
 | 
	
		
			
				|  |  | +//        //String appcode = "6d7d4fa382234e36893f4226f9dd3379";
 | 
	
		
			
				|  |  | +//        Map<String, String> headers = new HashMap<String, String>();
 | 
	
		
			
				|  |  | +//        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
 | 
	
		
			
				|  |  | +//        headers.put("Authorization", "APPCODE " + appCode);
 | 
	
		
			
				|  |  | +//        Map<String, String> querys = new HashMap<String, String>();
 | 
	
		
			
				|  |  | +//        querys.put("areaid", areaId);
 | 
	
		
			
				|  |  | +//        querys.put("need3HourForcast", "0");
 | 
	
		
			
				|  |  | +//        querys.put("needAlarm", "1");
 | 
	
		
			
				|  |  | +//        querys.put("needHourData", "0");
 | 
	
		
			
				|  |  | +//        querys.put("needIndex", "0");
 | 
	
		
			
				|  |  | +//        querys.put("needMoreDay", "0");
 | 
	
		
			
				|  |  | +        para.setAreaid(areaId);
 | 
	
		
			
				|  |  |          String str=null;
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              // HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
 | 
	
		
			
				|  |  |               //str = EntityUtils.toString(response.getEntity());
 | 
	
		
			
				|  |  | -            str =HttpUtils.doGetNew(host, path, method, headers, querys);
 | 
	
		
			
				|  |  | +//            str =HttpUtils.doGetNew(host, path, method, headers, querys);
 | 
	
		
			
				|  |  | +            String paraStr = JSON.toJSONString(para);
 | 
	
		
			
				|  |  | +            str= HttpUtil.post(weather_url,paraStr);
 | 
	
		
			
				|  |  |               //稳定过后取消,前期留着,一遍分析数据
 | 
	
		
			
				|  |  |               log.info("时间:【{}】区域【{}】的天气数据【{}】", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"),areaId,str);
 | 
	
		
			
				|  |  |          }catch (Exception e) {
 | 
	
		
			
				|  |  | -             log.info("时间:【{}】,调用万维易源天气接口失败原因【{}】,接口地址【{}】", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"),e.getMessage(),"https://ali-weather.showapi.com/area-to-weather");
 | 
	
		
			
				|  |  | +             log.info("时间:【{}】,调用万维易源天气接口失败原因【{}】,接口地址【{}】", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"),e.getMessage(),weather_url);
 | 
	
		
			
				|  |  |              e.printStackTrace();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return str;
 |