|
|
|
|
@@ -68,11 +68,11 @@ public class PushDailyController {
|
|
|
|
|
String term = chineseDate.getTerm();
|
|
|
|
|
|
|
|
|
|
// 计算各种日期
|
|
|
|
|
int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
|
|
|
|
|
int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday);
|
|
|
|
|
int catBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Cat_Birthday);
|
|
|
|
|
int loveDays = DataUtils.getDayDiff(DailyLoveConfigure.Love_Day);
|
|
|
|
|
int weddingDays = DataUtils.getDayDiff(DailyLoveConfigure.Wedding_Day);
|
|
|
|
|
int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday) - 1;
|
|
|
|
|
int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday) - 1;
|
|
|
|
|
int catBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Cat_Birthday) - 1;
|
|
|
|
|
int loveDays = DataUtils.getDayDiff(DailyLoveConfigure.Love_Day) + 1;
|
|
|
|
|
int weddingDays = DataUtils.getDayDiff(DailyLoveConfigure.Wedding_Day) + 1;
|
|
|
|
|
|
|
|
|
|
log.info("gbir_days:{}, bbir_days:{}, cbir_days:{}, love_days:{}, wedding_days:{}",
|
|
|
|
|
girlBirthdays, boyBirthdays, catBirthdays, loveDays, weddingDays);
|
|
|
|
|
@@ -138,12 +138,14 @@ public class PushDailyController {
|
|
|
|
|
resultVo.setAttribute("rainbow", new DataItem(rainbowContent, DailyLoveConfigure.Color_dailyCn));
|
|
|
|
|
resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate));
|
|
|
|
|
resultVo.setAttribute("festival", new DataItem(festival + " " + term, DailyLoveConfigure.Color_festival));
|
|
|
|
|
resultVo.setAttribute("gbir_day", new DataItem((girlBirthdays - 1) + "", DailyLoveConfigure.Color_gbir));
|
|
|
|
|
resultVo.setAttribute("bbir_day", new DataItem((boyBirthdays - 1) + "", DailyLoveConfigure.Color_bbir));
|
|
|
|
|
resultVo.setAttribute("cbir_day", new DataItem((catBirthdays - 1) + "", DailyLoveConfigure.Color_cbir));
|
|
|
|
|
resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays + "", DailyLoveConfigure.Color_gbir));
|
|
|
|
|
resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays + "", DailyLoveConfigure.Color_bbir));
|
|
|
|
|
resultVo.setAttribute("cbir_day", new DataItem(catBirthdays + "", DailyLoveConfigure.Color_cbir));
|
|
|
|
|
resultVo.setAttribute("words", new DataItem(words, DailyLoveConfigure.Color_remark));
|
|
|
|
|
resultVo.setAttribute("love_day", new DataItem((loveDays + 1) + "", DailyLoveConfigure.Color_loveDay));
|
|
|
|
|
resultVo.setAttribute("wedding_day", new DataItem((weddingDays + 1) + "", DailyLoveConfigure.Color_weddingDay));
|
|
|
|
|
resultVo.setAttribute("love_day", new DataItem(loveDays + "", DailyLoveConfigure.Color_loveDay));
|
|
|
|
|
resultVo.setAttribute("wedding_day", new DataItem(weddingDays + "", DailyLoveConfigure.Color_weddingDay));
|
|
|
|
|
|
|
|
|
|
log.info("推送消息: {}", resultVo);
|
|
|
|
|
|
|
|
|
|
// 获取微信访问令牌并发送消息
|
|
|
|
|
return wechatRequestService.getAccessToken("client_credential", DailyLoveConfigure.App_ID, DailyLoveConfigure.App_Secret)
|
|
|
|
|
@@ -152,7 +154,7 @@ public class PushDailyController {
|
|
|
|
|
.flatMap(accessToken -> wechatRequestService.sendMsg(accessToken, resultVo)
|
|
|
|
|
.doOnNext(this::printPushLog)
|
|
|
|
|
.onErrorMap(throwable -> new PushException("发送微信消息失败: " + throwable.getMessage(), throwable)))
|
|
|
|
|
.log();
|
|
|
|
|
.doOnSuccess(response -> log.info("推送结果: {}", response));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("处理晚安推送数据时发生错误", e);
|
|
|
|
|
return Mono.error(new PushException("处理晚安推送数据时发生错误", e));
|
|
|
|
|
@@ -255,6 +257,7 @@ public class PushDailyController {
|
|
|
|
|
resultVo.setAttribute("love_day", new DataItem(loveDays + "", DailyLoveConfigure.Color_loveDay));
|
|
|
|
|
resultVo.setAttribute("wedding_day", new DataItem(weddingDays + "", DailyLoveConfigure.Color_weddingDay));
|
|
|
|
|
|
|
|
|
|
log.info("推送消息: {}", resultVo);
|
|
|
|
|
// 获取微信访问令牌并发送消息
|
|
|
|
|
return wechatRequestService.getAccessToken("client_credential", DailyLoveConfigure.App_ID, DailyLoveConfigure.App_Secret)
|
|
|
|
|
.onErrorMap(throwable -> new PushException("获取微信访问令牌失败: " + throwable.getMessage(), throwable))
|
|
|
|
|
@@ -262,7 +265,7 @@ public class PushDailyController {
|
|
|
|
|
.flatMap(accessToken -> wechatRequestService.sendMsg(accessToken, resultVo)
|
|
|
|
|
.doOnNext(PushDailyController.this::printPushLog)
|
|
|
|
|
.onErrorMap(throwable -> new PushException("发送微信消息失败: " + throwable.getMessage(), throwable)))
|
|
|
|
|
.log();
|
|
|
|
|
.doOnSuccess(response -> log.info("推送结果: {}", response));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("处理早安推送数据时发生错误", e);
|
|
|
|
|
return Mono.error(new PushException("处理早安推送数据时发生错误", e));
|
|
|
|
|
|