| | |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iceyyy.workday.WorkUtils; |
| | | import com.squareup.okhttp.OkHttpClient; |
| | | import com.squareup.okhttp.Request; |
| | | import com.squareup.okhttp.Response; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取节假日不含周末 |
| | | * |
| | | * @return |
| | | */ |
| | | public Map getWeather(String code) { |
| | | String url = "https://restapi.amap.com/v3/weather/weatherInfo?key=9e0d819935da8a01de0e476ba8a9019e&city="+code; |
| | | OkHttpClient client = new OkHttpClient(); |
| | | Response response; |
| | | //解密数据 |
| | | String rsa = null; |
| | | Request request = new Request.Builder() |
| | | .url(url) |
| | | .get() |
| | | .addHeader("Content-Type", "application/x-www-form-urlencoded") |
| | | .build(); |
| | | try { |
| | | response = client.newCall(request).execute(); |
| | | rsa = response.body().string(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return JSONObject.parseObject(rsa, Map.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取周末 月从0开始 |
| | | * |
| | | * @param year |
| | |
| | | * @return |
| | | */ |
| | | public DateTime nextWeekDay(DateTime dateTime){ |
| | | TestDate td=new TestDate(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(dateTime); |
| | | while (true){ |
| | | calendar.add(calendar.DATE,1); |
| | | if (td.isWeekday(new DateTime(calendar))){ |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | String dateTimeToday = sdf.format(calendar.getTime()); |
| | | if (!WorkUtils.isWorkendDay(dateTimeToday)){ |
| | | return new DateTime(calendar);//返回日期 |
| | | } |
| | | } |