Browse Source

天气相关

LAPTOP-KB9HII50\70708 2 years ago
parent
commit
9fb50b32a8

+ 3 - 0
common/common-entity/sql记录

@ -2041,6 +2041,7 @@ CREATE TABLE `base_weather_week` (
  `city` varchar(10) DEFAULT NULL COMMENT '城市名称',
  `update_time` varchar(30) DEFAULT NULL COMMENT '更新时间',
  `date` varchar(10) DEFAULT NULL COMMENT '预报日期',
  `week` varchar(10) DEFAULT NULL COMMENT '星期',
  `wea` varchar(10) DEFAULT NULL COMMENT '天气情况',
  `wea_img` varchar(10) DEFAULT NULL COMMENT '天气情况xue、lei、shachen、wu、bingbao、yun、yu、yin、qing',
  `tem_day` varchar(10) DEFAULT NULL COMMENT '白天温度(高温)',
@ -2052,3 +2053,5 @@ CREATE TABLE `base_weather_week` (
  UNIQUE KEY `index_1` (`update_date`,`date`,`cityid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='7天天气记录表';

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/weather/BaseWeatherWeekDO.java

@ -19,6 +19,7 @@ public class BaseWeatherWeekDO extends UuidIdentityEntityWithCreateTime {
    private String updateDate;//更新日期
    private String updateTime;//更新时间
    private String date;//预报日期
    private String week;//星期
    private String wea;//天气情况
    private String weaImg;//天气标识(xue、lei、shachen、wu、bingbao、yun、yu、yin、qing)
    private String temDay;//白天温度(高温)
@ -134,4 +135,12 @@ public class BaseWeatherWeekDO extends UuidIdentityEntityWithCreateTime {
        this.winSpeed = winSpeed;
    }
    @Column(name = "week")
    public String getWeek() {
        return week;
    }
    public void setWeek(String week) {
        this.week = week;
    }
}

+ 20 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -1586,4 +1586,24 @@ public class DateUtil {
        Date currentDate = DateUtil.getNowDate();
        return (startDate.getTime() - currentDate.getTime()) / 1000;
    }
    public static int getWeekByString(String date){
        Calendar cal = Calendar.getInstance(); // 获得一个日历
        Date datet = null;
        try {
            datet = simpleDateParse(date);
            cal.setTime(datet);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1; // 指示一个星期中的某天。
        if (w < 0)
            w = 0;
        return w;
    }
    public static String dateToWeek(String date) {
        String[] weekDays = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
        return weekDays[getWeekByString(date)];
    }
}

+ 14 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/WeatherUtil.java

@ -132,7 +132,7 @@ public class WeatherUtil {
                weekDO.setUpdateDate(date);
                weekDO.setUpdateTime(updateTime);
                weekDO.setNums(nums);
                weekDO.setWeek(dateToWeek(json.getString("date"),i));
                weekDO.setDate(json.getString("date"));
                weekDO.setWea(json.getString("wea"));
                weekDO.setWeaImg(json.getString("wea_img"));
@ -152,4 +152,17 @@ public class WeatherUtil {
        }
    }
    /**
     * 日期转星期
     */
    private String dateToWeek(String date,int i){
        if(i==0){
            return "今天";
        }else if(i==1){
            return "明天";
        }else {
            return DateUtil.dateToWeek(date);
        }
    }
}

+ 14 - 1
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/WeatherUtil.java

@ -132,7 +132,7 @@ public class WeatherUtil {
                weekDO.setUpdateDate(date);
                weekDO.setUpdateTime(updateTime);
                weekDO.setNums(nums);
                weekDO.setWeek(dateToWeek(json.getString("date"),i));
                weekDO.setDate(json.getString("date"));
                weekDO.setWea(json.getString("wea"));
                weekDO.setWeaImg(json.getString("wea_img"));
@ -152,4 +152,17 @@ public class WeatherUtil {
        }
    }
    /**
     * 日期转星期
     */
    private String dateToWeek(String date,int i){
        if(i==0){
            return "今天";
        }else if(i==1){
            return "明天";
        }else {
            return DateUtil.dateToWeek(date);
        }
    }
}