0.0.4:
修改为早安推送和晚安推送 增加了农历日期的和节日节气的显示 更改了推送的文字 增加了空气质量 删除了英文每日一句 增加了生活小贴士 修改了字体颜色 优化了代码逻辑
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.bamanker</groupId>
|
<groupId>com.bamanker</groupId>
|
||||||
<artifactId>dailyLove</artifactId>
|
<artifactId>dailyLove</artifactId>
|
||||||
<version>0.0.3</version>
|
<version>0.0.4</version>
|
||||||
<name>dailyLove</name>
|
<name>dailyLove</name>
|
||||||
<description>dailyLove</description>
|
<description>dailyLove</description>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -5,80 +5,118 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DailyLoveConfigure {
|
public class DailyLoveConfigure {
|
||||||
|
public static String Color_quality;
|
||||||
|
public static String Color_morning;
|
||||||
|
public static String Color_chineseDate;
|
||||||
|
public static String Color_festival;
|
||||||
|
public static String Color_night;
|
||||||
|
|
||||||
|
public static String Color_tomorrow;
|
||||||
|
|
||||||
|
@Value("${wechat.color.tomorrow:null}")
|
||||||
|
public void setColor_tomorrow(String color_tomorrow) {
|
||||||
|
Color_tomorrow = color_tomorrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${wechat.color.quality:null}")
|
||||||
|
public void setColor_quality(String color_quality) {
|
||||||
|
Color_quality = color_quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${wechat.color.morning:null}")
|
||||||
|
public void setColor_morning(String color_morning) {
|
||||||
|
Color_morning = color_morning;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${wechat.color.chineseDate:null}")
|
||||||
|
public void setColor_chineseDate(String color_chineseDate) {
|
||||||
|
Color_chineseDate = color_chineseDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${wechat.color.festival:null}")
|
||||||
|
public void setColor_festival(String color_festival) {
|
||||||
|
Color_festival = color_festival;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${wechat.color.night:null}")
|
||||||
|
public void setColor_night(String color_night) {
|
||||||
|
Color_night = color_night;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// public static String Access_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";
|
// public static String Access_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";
|
||||||
// public static String Send_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
|
// public static String Send_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
|
||||||
|
|
||||||
|
|
||||||
@Value("${wechat.color.city}")
|
@Value("${wechat.color.city:null}")
|
||||||
public void setColor_city(String color_city) {
|
public void setColor_city(String color_city) {
|
||||||
Color_city = color_city;
|
Color_city = color_city;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String Color_Now = null;
|
public static String Color_Now;
|
||||||
public static String Color_city = null;
|
public static String Color_city;
|
||||||
public static String Color_weather = null;
|
public static String Color_weather;
|
||||||
public static String Color_minTem = null;
|
public static String Color_minTem;
|
||||||
public static String Color_maxTem = null;
|
public static String Color_maxTem;
|
||||||
public static String Color_tips = null;
|
public static String Color_tips;
|
||||||
public static String Color_dailyCn = null;
|
public static String Color_dailyCn;
|
||||||
public static String Color_dailyEn = null;
|
public static String Color_dailyEn;
|
||||||
public static String Color_gbir = null;
|
public static String Color_gbir;
|
||||||
public static String Color_bbir = null;
|
public static String Color_bbir;
|
||||||
public static String Color_loveDay = null;
|
public static String Color_loveDay;
|
||||||
public static String Color_remark = null;
|
public static String Color_remark;
|
||||||
|
|
||||||
@Value("${wechat.color.weather}")
|
@Value("${wechat.color.weather:null}")
|
||||||
public void setColor_weather(String color_weather) {
|
public void setColor_weather(String color_weather) {
|
||||||
Color_weather = color_weather;
|
Color_weather = color_weather;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.minTem}")
|
@Value("${wechat.color.minTem:null}")
|
||||||
public void setColor_minTem(String color_minTem) {
|
public void setColor_minTem(String color_minTem) {
|
||||||
Color_minTem = color_minTem;
|
Color_minTem = color_minTem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.maxTem}")
|
@Value("${wechat.color.maxTem:null}")
|
||||||
public void setColor_maxTem(String color_maxTem) {
|
public void setColor_maxTem(String color_maxTem) {
|
||||||
Color_maxTem = color_maxTem;
|
Color_maxTem = color_maxTem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.tips}")
|
@Value("${wechat.color.tips:null}")
|
||||||
public void setColor_tips(String color_tips) {
|
public void setColor_tips(String color_tips) {
|
||||||
Color_tips = color_tips;
|
Color_tips = color_tips;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.dailyCn}")
|
@Value("${wechat.color.dailyCn:null}")
|
||||||
public void setColor_dailyCn(String color_dailyCn) {
|
public void setColor_dailyCn(String color_dailyCn) {
|
||||||
Color_dailyCn = color_dailyCn;
|
Color_dailyCn = color_dailyCn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.dailyEn}")
|
@Value("${wechat.color.dailyEn:null}")
|
||||||
public void setColor_dailyEn(String color_dailyEn) {
|
public void setColor_dailyEn(String color_dailyEn) {
|
||||||
Color_dailyEn = color_dailyEn;
|
Color_dailyEn = color_dailyEn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.gbir}")
|
@Value("${wechat.color.gbir:null}")
|
||||||
public void setColor_gbir(String color_gbir) {
|
public void setColor_gbir(String color_gbir) {
|
||||||
Color_gbir = color_gbir;
|
Color_gbir = color_gbir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.bbir}")
|
@Value("${wechat.color.bbir:null}")
|
||||||
public void setColor_bbir(String color_bbir) {
|
public void setColor_bbir(String color_bbir) {
|
||||||
Color_bbir = color_bbir;
|
Color_bbir = color_bbir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.loveDay}")
|
@Value("${wechat.color.loveDay:null}")
|
||||||
public void setColor_loveDay(String color_loveDay) {
|
public void setColor_loveDay(String color_loveDay) {
|
||||||
Color_loveDay = color_loveDay;
|
Color_loveDay = color_loveDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.remark}")
|
@Value("${wechat.color.remark:null}")
|
||||||
public void setColor_remark(String color_remark) {
|
public void setColor_remark(String color_remark) {
|
||||||
Color_remark = color_remark;
|
Color_remark = color_remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${wechat.color.now}")
|
@Value("${wechat.color.now:null}")
|
||||||
public void setColor_Now(String color_Now) {
|
public void setColor_Now(String color_Now) {
|
||||||
Color_Now = color_Now;
|
Color_Now = color_Now;
|
||||||
}
|
}
|
||||||
@@ -104,13 +142,21 @@ public class DailyLoveConfigure {
|
|||||||
Open_ID = OpenID;
|
Open_ID = OpenID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String Template_ID;
|
public static String Template_ID_Morning;
|
||||||
|
|
||||||
@Value("${wechat.template-id}")
|
@Value("${wechat.template-id-morning}")
|
||||||
public void setTemplateID(String TemplateID) {
|
public void setTemplateIDMorning(String templateIDMorning) {
|
||||||
Template_ID = TemplateID;
|
Template_ID_Morning = templateIDMorning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String Template_ID_Night;
|
||||||
|
|
||||||
|
@Value("${wechat.template-id-night}")
|
||||||
|
public void setTemplateIDNight(String templateIDNight) {
|
||||||
|
Template_ID_Night = templateIDNight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String City_ID;
|
public static String City_ID;
|
||||||
|
|
||||||
@Value("${DL.city-id}")
|
@Value("${DL.city-id}")
|
||||||
|
|||||||
@@ -12,8 +12,13 @@ public class PushTask {
|
|||||||
PushDailyController pushDailyController;
|
PushDailyController pushDailyController;
|
||||||
|
|
||||||
//每日 早上8,12,22点 定时推送
|
//每日 早上8,12,22点 定时推送
|
||||||
@Scheduled(cron = "0 0 8 * * ?")
|
@Scheduled(cron = "0 30 7 * * ?")
|
||||||
public void scheduledPush(){
|
public void scheduledPushMorning(){
|
||||||
pushDailyController.push();
|
pushDailyController.pushMorning();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 22 * * ?")
|
||||||
|
public void scheduledPushNight(){
|
||||||
|
pushDailyController.pushNight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.bamanker.dailylove.controller;
|
package com.bamanker.dailylove.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.ChineseDate;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.bamanker.dailylove.config.DailyLoveConfigure;
|
import com.bamanker.dailylove.config.DailyLoveConfigure;
|
||||||
@@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -29,30 +32,115 @@ public class PushDailyController {
|
|||||||
String remark = "❤";
|
String remark = "❤";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送
|
* 推送晚安
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/push")
|
@GetMapping("/pushNight")
|
||||||
public String push() {
|
public String pushNight() {
|
||||||
|
|
||||||
|
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
|
||||||
|
DailyLoveConfigure.Template_ID_Night,
|
||||||
|
DailyLoveConfigure.Color_Top);
|
||||||
|
|
||||||
|
TianXinReqParam param1 = new TianXinReqParam();
|
||||||
|
param1.setKey(DailyLoveConfigure.TianXin_Key);
|
||||||
|
param1.setCity(DailyLoveConfigure.City_ID);
|
||||||
|
param1.setType("7");
|
||||||
|
String weatherResp = dataRemoteClient.getWeather(param1);
|
||||||
|
JSONObject weatherJson = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(1);
|
||||||
|
String city = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getString("area");
|
||||||
|
Weather weather = weatherJson.toJavaObject(Weather.class);
|
||||||
|
|
||||||
|
resultVo.setAttribute("tomorrow", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_tomorrow));
|
||||||
|
resultVo.setAttribute("city", new DataItem(city, DailyLoveConfigure.Color_city));
|
||||||
|
resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather));
|
||||||
|
resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem));
|
||||||
|
resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem));
|
||||||
|
resultVo.setAttribute("quality", new DataItem(weather.getVis(), DailyLoveConfigure.Color_quality));
|
||||||
|
|
||||||
|
|
||||||
|
TianXinReqParam param2 = new TianXinReqParam();
|
||||||
|
param2.setKey(DailyLoveConfigure.TianXin_Key);
|
||||||
|
|
||||||
|
String tipsResp = dataRemoteClient.getTips(param2);
|
||||||
|
String tips = JSONObject.parseObject(tipsResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
|
resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
|
||||||
|
|
||||||
|
String nightResp = dataRemoteClient.getNight(param2);
|
||||||
|
String night = JSONObject.parseObject(nightResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
|
resultVo.setAttribute("night", new DataItem(night, DailyLoveConfigure.Color_night));
|
||||||
|
|
||||||
|
String rainbowResp = dataRemoteClient.getRainbow(param2);
|
||||||
|
String rainbow = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
|
resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
|
||||||
|
|
||||||
|
String englishResp = dataRemoteClient.getDailyEnglish(param2);
|
||||||
|
String english = JSONObject.parseObject(englishResp).getJSONArray("result").getJSONObject(0).getString("en");
|
||||||
|
resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn));
|
||||||
|
|
||||||
|
|
||||||
|
ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(weather.getDate()));
|
||||||
|
String festival = chineseDate.getFestivals();
|
||||||
|
String term = chineseDate.getTerm();
|
||||||
|
resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate));
|
||||||
|
resultVo.setAttribute("festival", new DataItem(festival + " " + term, DailyLoveConfigure.Color_festival));
|
||||||
|
|
||||||
|
|
||||||
|
int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
|
||||||
|
log.debug("gbir_day:{}", girlBirthdays);
|
||||||
|
resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays - 1 + "", DailyLoveConfigure.Color_gbir));
|
||||||
|
|
||||||
|
int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday);
|
||||||
|
log.debug("bbir_day:{}", boyBirthdays);
|
||||||
|
resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays - 1 + "", DailyLoveConfigure.Color_bbir));
|
||||||
|
|
||||||
|
if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 1) {
|
||||||
|
remark = "明天是恋爱周年纪念日!永远爱你~mua";
|
||||||
|
} else if ((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day)) % 100 == 1) {
|
||||||
|
remark = "明天是恋爱百日纪念日!提前庆祝哦~";
|
||||||
|
} else if (girlBirthdays == 1) {
|
||||||
|
remark = "明天是lili大宝贝的生日啦";
|
||||||
|
} else if (boyBirthdays == 1) {
|
||||||
|
remark = "明天是songsong的生日!别忘了哦~";
|
||||||
|
}
|
||||||
|
|
||||||
|
resultVo.setAttribute("remark", new DataItem(remark, DailyLoveConfigure.Color_remark));
|
||||||
|
|
||||||
|
int loveDays = DataUtils.getLoveDays(DailyLoveConfigure.Love_Day);
|
||||||
|
log.debug("love_day:{}", loveDays);
|
||||||
|
resultVo.setAttribute("love_day", new DataItem(loveDays + 1 + "", DailyLoveConfigure.Color_loveDay));
|
||||||
|
|
||||||
|
log.debug("resultVo:{}", resultVo);
|
||||||
|
WechatTokenParam wechatTokenParam = new WechatTokenParam();
|
||||||
|
wechatTokenParam.setAppid(DailyLoveConfigure.App_ID);
|
||||||
|
wechatTokenParam.setSecret(DailyLoveConfigure.App_Secret);
|
||||||
|
|
||||||
|
String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam);
|
||||||
|
log.debug("accessTokenJson:{}", accessTokenResp);
|
||||||
|
String token = JSONObject.parseObject(accessTokenResp).getString("access_token");
|
||||||
|
String responseStr = wechatRequestClient.sendMsg(resultVo, token);
|
||||||
|
return responseStr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送早安
|
||||||
|
*/
|
||||||
|
@GetMapping("/pushMorning")
|
||||||
|
public String pushMorning() {
|
||||||
|
|
||||||
TianXinReqParam param1 = new TianXinReqParam();
|
TianXinReqParam param1 = new TianXinReqParam();
|
||||||
param1.setKey(DailyLoveConfigure.TianXin_Key);
|
param1.setKey(DailyLoveConfigure.TianXin_Key);
|
||||||
param1.setCity(DailyLoveConfigure.City_ID);
|
param1.setCity(DailyLoveConfigure.City_ID);
|
||||||
param1.setType("1");
|
param1.setType("1");
|
||||||
String weatherJson = dataRemoteClient.getWeather(param1);
|
String weatherResp = dataRemoteClient.getWeather(param1);
|
||||||
|
|
||||||
log.debug("weather:{}", weatherJson);
|
|
||||||
JSONObject responseWeather = JSONObject.parseObject(weatherJson);
|
|
||||||
log.debug("weatherJson:{}", responseWeather);
|
|
||||||
JSONObject resultWeather = responseWeather.getJSONArray("result").getJSONObject(0);
|
|
||||||
JSONArray result1 = responseWeather.getJSONArray("result");
|
|
||||||
log.debug("-----------------{}", result1);
|
|
||||||
log.debug("weatherJsonNewList:{}", resultWeather);
|
|
||||||
Weather weather = resultWeather.toJavaObject(Weather.class);
|
|
||||||
log.debug("weatherJsonNewList:{}", weather.toString());
|
|
||||||
|
|
||||||
|
Weather weather = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).toJavaObject(Weather.class);
|
||||||
|
;
|
||||||
|
|
||||||
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
|
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
|
||||||
DailyLoveConfigure.Template_ID,
|
DailyLoveConfigure.Template_ID_Morning,
|
||||||
DailyLoveConfigure.Color_Top);
|
DailyLoveConfigure.Color_Top);
|
||||||
|
|
||||||
resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_Now));
|
resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_Now));
|
||||||
@@ -60,41 +148,53 @@ public class PushDailyController {
|
|||||||
resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather));
|
resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather));
|
||||||
resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem));
|
resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem));
|
||||||
resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem));
|
resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem));
|
||||||
resultVo.setAttribute("tips", new DataItem(weather.getTips(), DailyLoveConfigure.Color_tips));
|
resultVo.setAttribute("quality", new DataItem(weather.getQuality(), DailyLoveConfigure.Color_quality));
|
||||||
|
|
||||||
|
|
||||||
TianXinReqParam param2 = new TianXinReqParam();
|
TianXinReqParam param2 = new TianXinReqParam();
|
||||||
param2.setKey(DailyLoveConfigure.TianXin_Key);
|
param2.setKey(DailyLoveConfigure.TianXin_Key);
|
||||||
String rainbowJson = dataRemoteClient.getRainbow(param2);
|
|
||||||
log.debug("rainbowJson:{}", rainbowJson);
|
String tipsResp = dataRemoteClient.getTips(param2);
|
||||||
JSONObject responseRainbow = JSONObject.parseObject(rainbowJson);
|
String tips = JSONObject.parseObject(tipsResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
String rainbow = responseRainbow.getJSONArray("result").getJSONObject(0).getString("content");
|
resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
|
||||||
log.debug("rainbow:{}", rainbow);
|
|
||||||
|
String morningResp = dataRemoteClient.getMorning(param2);
|
||||||
|
String morning = JSONObject.parseObject(morningResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
|
resultVo.setAttribute("morning", new DataItem(morning, DailyLoveConfigure.Color_morning));
|
||||||
|
|
||||||
|
String rainbowResp = dataRemoteClient.getRainbow(param2);
|
||||||
|
String rainbow = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
|
resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
|
||||||
|
|
||||||
|
String englishResp = dataRemoteClient.getDailyEnglish(param2);
|
||||||
|
String english = JSONObject.parseObject(englishResp).getJSONArray("result").getJSONObject(0).getString("en");
|
||||||
String englishJson = dataRemoteClient.getDailyEnglish(param2);
|
|
||||||
log.debug("englishJson:{}", englishJson);
|
|
||||||
JSONObject responseEnglist = JSONObject.parseObject(englishJson);
|
|
||||||
String english = responseEnglist.getJSONArray("result").getJSONObject(0).getString("en");
|
|
||||||
log.debug("english:{}", english);
|
|
||||||
resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn));
|
resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn));
|
||||||
|
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date date = new Date();
|
||||||
|
String currentTime = dateFormat.format(date);
|
||||||
|
ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(currentTime));
|
||||||
|
String festival = chineseDate.getFestivals();
|
||||||
|
String term = chineseDate.getTerm();
|
||||||
|
resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate));
|
||||||
|
resultVo.setAttribute("festival", new DataItem(festival + " " + term, DailyLoveConfigure.Color_festival));
|
||||||
|
|
||||||
|
|
||||||
int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
|
int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
|
||||||
log.debug("gbir_day:{}", girlBirthdays);
|
log.debug("gbir_day:{}", girlBirthdays);
|
||||||
resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays + "", DailyLoveConfigure.Color_gbir));
|
resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays + "", DailyLoveConfigure.Color_gbir));
|
||||||
int boyBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Boy_Birthday);
|
|
||||||
|
int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday);
|
||||||
log.debug("bbir_day:{}", boyBirthdays);
|
log.debug("bbir_day:{}", boyBirthdays);
|
||||||
resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays + "", DailyLoveConfigure.Color_bbir));
|
resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays + "", DailyLoveConfigure.Color_bbir));
|
||||||
|
|
||||||
if(DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 0){
|
if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 0) {
|
||||||
remark = "今天是恋爱周年纪念日!永远爱你~mua";
|
remark = "今天是恋爱周年纪念日!永远爱你~mua";
|
||||||
}else if((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day))%100 == 0){
|
} else if ((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day)) % 100 == 0) {
|
||||||
remark = "今天是恋爱百日纪念日!永远爱你~";
|
remark = "今天是恋爱百日纪念日!永远爱你~";
|
||||||
}else if(girlBirthdays == 0){
|
} else if (girlBirthdays == 0) {
|
||||||
remark = "今天是lili大宝贝的生日!生日快乐哟~";
|
remark = "今天是lili大宝贝的生日!生日快乐哟~";
|
||||||
}else if(boyBirthdays == 0){
|
} else if (boyBirthdays == 0) {
|
||||||
remark = "今天是songsong的生日!别忘了好好爱他~";
|
remark = "今天是songsong的生日!别忘了好好爱他~";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,12 +209,10 @@ public class PushDailyController {
|
|||||||
wechatTokenParam.setAppid(DailyLoveConfigure.App_ID);
|
wechatTokenParam.setAppid(DailyLoveConfigure.App_ID);
|
||||||
wechatTokenParam.setSecret(DailyLoveConfigure.App_Secret);
|
wechatTokenParam.setSecret(DailyLoveConfigure.App_Secret);
|
||||||
|
|
||||||
String accessTokenJson = wechatRequestClient.getAccessToken(wechatTokenParam);
|
String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam);
|
||||||
log.debug("accessTokenJson:{}", accessTokenJson);
|
log.debug("accessTokenJson:{}", accessTokenResp);
|
||||||
JSONObject responseToken = JSONObject.parseObject(accessTokenJson);
|
String token = JSONObject.parseObject(accessTokenResp).getString("access_token");
|
||||||
String token = responseToken.getString("access_token");
|
|
||||||
String responseStr = wechatRequestClient.sendMsg(resultVo, token);
|
String responseStr = wechatRequestClient.sendMsg(resultVo, token);
|
||||||
log.info("{}",responseStr);
|
|
||||||
return responseStr;
|
return responseStr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ public class Weather {
|
|||||||
private String area;
|
private String area;
|
||||||
private String weather;
|
private String weather;
|
||||||
private String lowest;
|
private String lowest;
|
||||||
|
|
||||||
|
private String vis;
|
||||||
private String highest;
|
private String highest;
|
||||||
private String tips;
|
private String quality;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,5 +28,17 @@ public interface DataRemoteClient {
|
|||||||
consumes = {MediaType.APPLICATION_JSON_VALUE},
|
consumes = {MediaType.APPLICATION_JSON_VALUE},
|
||||||
produces = {MediaType.APPLICATION_JSON_VALUE})
|
produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||||
String getDailyEnglish(@SpringQueryMap TianXinReqParam param);
|
String getDailyEnglish(@SpringQueryMap TianXinReqParam param);
|
||||||
|
@GetMapping(value = "/qiaomen/index",
|
||||||
|
consumes = {MediaType.APPLICATION_JSON_VALUE},
|
||||||
|
produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||||
|
String getTips(@SpringQueryMap TianXinReqParam param);
|
||||||
|
@GetMapping(value = "/zaoan/index",
|
||||||
|
consumes = {MediaType.APPLICATION_JSON_VALUE},
|
||||||
|
produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||||
|
String getMorning(@SpringQueryMap TianXinReqParam param);
|
||||||
|
@GetMapping(value = "/wanan/index",
|
||||||
|
consumes = {MediaType.APPLICATION_JSON_VALUE},
|
||||||
|
produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||||
|
String getNight(@SpringQueryMap TianXinReqParam param);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,22 +32,29 @@ wechat:
|
|||||||
#ME: oo5bL6bK_4TC0tb-Wa5oiugTPVeQ
|
#ME: oo5bL6bK_4TC0tb-Wa5oiugTPVeQ
|
||||||
#LILI: oo5bL6QafHJa9zQNYKS0fIhFC0zM
|
#LILI: oo5bL6QafHJa9zQNYKS0fIhFC0zM
|
||||||
open-id: oo5bL6QafHJa9zQNYKS0fIhFC0zM
|
open-id: oo5bL6QafHJa9zQNYKS0fIhFC0zM
|
||||||
template-id: QAEWkGL9HfDGxHQDilIBaux8HylTTsEn_3MjI6bTFhc
|
template-id-morning: 0qVcDob-3INv8Jh_Odd5nl9gfgA0LYpvBMYcqqP03rA
|
||||||
|
template-id-night: TUL17fAJ4g69_7PjpgvrQwKxr8KC4fYQxMIAl0e3L9s
|
||||||
|
|
||||||
color:
|
color:
|
||||||
now: '#00BFFF'
|
now: '#99CCCC'
|
||||||
|
tomorrow: '#99CCCC'
|
||||||
|
chineseDate: '#99CC66'
|
||||||
top: '#FF0000'
|
top: '#FF0000'
|
||||||
weather: '#1f95c5'
|
weather: '#66CCCC'
|
||||||
minTem: '#0ace3c'
|
minTem: '#0066CC'
|
||||||
maxTem: '#dc1010'
|
maxTem: '#FF0033'
|
||||||
dailyCn: '#FF69B4'
|
dailyCn: '#993366'
|
||||||
dailyEn: '#800080'
|
dailyEn: '#CC99CC'
|
||||||
gbir: '#FFA500'
|
gbir: '#FF3399'
|
||||||
bbir: '#FFA500'
|
bbir: '#FF3399'
|
||||||
loveDay: '#FF1493'
|
loveDay: '#FF3399'
|
||||||
remark: '#FF1493'
|
remark: '#FF6666'
|
||||||
city: ""
|
city: ""
|
||||||
tips: ""
|
tips: ""
|
||||||
|
quality: '#99CC66'
|
||||||
|
festival: '#FF6666'
|
||||||
|
morning: '#FFFF99'
|
||||||
|
night: '#006699'
|
||||||
|
|
||||||
tianxin:
|
tianxin:
|
||||||
server: https://apis.tianapi.com
|
server: https://apis.tianapi.com
|
||||||
|
|||||||
@@ -145,60 +145,60 @@ class DailyLoveApplicationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void contextLoads() {
|
||||||
TianXinReqParam param1 = new TianXinReqParam();
|
// TianXinReqParam param1 = new TianXinReqParam();
|
||||||
param1.setKey(DailyLoveConfigure.TianXin_Key);
|
// param1.setKey(DailyLoveConfigure.TianXin_Key);
|
||||||
param1.setCity(DailyLoveConfigure.City_ID);
|
// param1.setCity(DailyLoveConfigure.City_ID);
|
||||||
param1.setType("1");
|
// param1.setType("1");
|
||||||
String weatherJson = dataRemoteClient.getWeather(param1);
|
// String weatherJson = dataRemoteClient.getWeather(param1);
|
||||||
log.info("weather:{}", weatherJson);
|
// log.info("weather:{}", weatherJson);
|
||||||
JSONObject responseWeather = JSONObject.parseObject(weatherJson);
|
// JSONObject responseWeather = JSONObject.parseObject(weatherJson);
|
||||||
log.info("weatherJson:{}", responseWeather);
|
// log.info("weatherJson:{}", responseWeather);
|
||||||
JSONObject resultWeather = responseWeather.getJSONArray("result").getJSONObject(0);
|
// JSONObject resultWeather = responseWeather.getJSONArray("result").getJSONObject(0);
|
||||||
JSONArray result1 = responseWeather.getJSONArray("result");
|
// JSONArray result1 = responseWeather.getJSONArray("result");
|
||||||
log.info("-----------------{}", result1);
|
// log.info("-----------------{}", result1);
|
||||||
log.info("weatherJsonNewList:{}", resultWeather);
|
// log.info("weatherJsonNewList:{}", resultWeather);
|
||||||
Weather weather = resultWeather.toJavaObject(Weather.class);
|
// Weather weather = resultWeather.toJavaObject(Weather.class);
|
||||||
log.info("weatherJsonNewList:{}", weather.toString());
|
// log.info("weatherJsonNewList:{}", weather.toString());
|
||||||
|
//
|
||||||
|
//
|
||||||
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
|
// ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
|
||||||
DailyLoveConfigure.Template_ID,
|
// DailyLoveConfigure.Template_ID,
|
||||||
DailyLoveConfigure.Color_Top);
|
// DailyLoveConfigure.Color_Top);
|
||||||
resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), "#00BFFF"));
|
// resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), "#00BFFF"));
|
||||||
resultVo.setAttribute("city", new DataItem(weather.getArea(), null));
|
// resultVo.setAttribute("city", new DataItem(weather.getArea(), null));
|
||||||
resultVo.setAttribute("weather", new DataItem(weather.getWeather(), "#1f95c5"));
|
// resultVo.setAttribute("weather", new DataItem(weather.getWeather(), "#1f95c5"));
|
||||||
resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), "#0ace3c"));
|
// resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), "#0ace3c"));
|
||||||
resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), "#dc1010"));
|
// resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), "#dc1010"));
|
||||||
resultVo.setAttribute("tips", new DataItem(weather.getTips(), null));
|
// resultVo.setAttribute("tips", new DataItem(weather.getTips(), null));
|
||||||
|
//
|
||||||
|
//
|
||||||
TianXinReqParam param2 = new TianXinReqParam();
|
// TianXinReqParam param2 = new TianXinReqParam();
|
||||||
param2.setKey(DailyLoveConfigure.TianXin_Key);
|
// param2.setKey(DailyLoveConfigure.TianXin_Key);
|
||||||
String rainbowJson = dataRemoteClient.getRainbow(param2);
|
// String rainbowJson = dataRemoteClient.getRainbow(param2);
|
||||||
log.info("rainbowJson:{}", rainbowJson);
|
// log.info("rainbowJson:{}", rainbowJson);
|
||||||
JSONObject responseRainbow = JSONObject.parseObject(rainbowJson);
|
// JSONObject responseRainbow = JSONObject.parseObject(rainbowJson);
|
||||||
String rainbow = responseRainbow.getJSONArray("result").getJSONObject(0).getString("content");
|
// String rainbow = responseRainbow.getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
log.info("rainbow:{}", rainbow);
|
// log.info("rainbow:{}", rainbow);
|
||||||
resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, "#FF69B4"));
|
// resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, "#FF69B4"));
|
||||||
resultVo.setAttribute("remark", new DataItem(remark, "#FF1493"));
|
// resultVo.setAttribute("remark", new DataItem(remark, "#FF1493"));
|
||||||
|
//
|
||||||
|
//
|
||||||
String englishJson = dataRemoteClient.getDailyEnglish(param2);
|
// String englishJson = dataRemoteClient.getDailyEnglish(param2);
|
||||||
log.info("englishJson:{}", englishJson);
|
// log.info("englishJson:{}", englishJson);
|
||||||
JSONObject responseEnglist = JSONObject.parseObject(englishJson);
|
// JSONObject responseEnglist = JSONObject.parseObject(englishJson);
|
||||||
String englist = responseEnglist.getJSONArray("result").getJSONObject(0).getString("en");
|
// String englist = responseEnglist.getJSONArray("result").getJSONObject(0).getString("en");
|
||||||
log.info("english:{}", englist);
|
// log.info("english:{}", englist);
|
||||||
resultVo.setAttribute("daily_english_en", new DataItem(rainbow, "#800080"));
|
// resultVo.setAttribute("daily_english_en", new DataItem(rainbow, "#800080"));
|
||||||
|
//
|
||||||
int birthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
|
// int birthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
|
||||||
log.info("bir_day:{}", birthdays);
|
// log.info("bir_day:{}", birthdays);
|
||||||
resultVo.setAttribute("bir_day", new DataItem(birthdays + "", "#FFA500"));
|
// resultVo.setAttribute("bir_day", new DataItem(birthdays + "", "#FFA500"));
|
||||||
|
//
|
||||||
int loveDays = DataUtils.getLoveDays(DailyLoveConfigure.Love_Day);
|
// int loveDays = DataUtils.getLoveDays(DailyLoveConfigure.Love_Day);
|
||||||
log.info("love_day:{}", loveDays);
|
// log.info("love_day:{}", loveDays);
|
||||||
resultVo.setAttribute("love_day", new DataItem(loveDays + "", "#FFA500"));
|
// resultVo.setAttribute("love_day", new DataItem(loveDays + "", "#FFA500"));
|
||||||
|
//
|
||||||
log.info("resultVo:{}", resultVo);
|
// log.info("resultVo:{}", resultVo);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user