定时推送优化!
This commit is contained in:
parent
cbfa434a27
commit
25058a6be9
|
|
@ -56,7 +56,7 @@ public class RemindJobImpl implements RemindJob {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITblDeviceService deviceService;
|
private ITblDeviceService deviceService;
|
||||||
|
|
||||||
private final String pushContent = "【换水提醒】您的水族箱需要换水啦~您可以在水箱设置中更改提醒设置";
|
private final String pushContent = "【换水提醒】您的水族箱\"%s\"需要换水啦~您可以在水箱设置中更改提醒设置";
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 10 * * ?")
|
@Scheduled(cron = "0 0 10 * * ?")
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -67,20 +67,19 @@ public class RemindJobImpl implements RemindJob {
|
||||||
.eq(TblTmpPushRemind::getRemindDate, LocalDate.now()));
|
.eq(TblTmpPushRemind::getRemindDate, LocalDate.now()));
|
||||||
final PushList pushList = new PushList();
|
final PushList pushList = new PushList();
|
||||||
list.forEach(tblTmpPushRemind -> {
|
list.forEach(tblTmpPushRemind -> {
|
||||||
pushList.setUserId(tblTmpPushRemind.getUserId());
|
//查询出设备对应的名称
|
||||||
pushList.setDeviceId(tblTmpPushRemind.getDeviceId());
|
TblDeviceUser deviceUser = deviceUserService.getOne(new QueryWrapper<TblDeviceUser>().lambda()
|
||||||
pushList.setPhoneType("ALL");
|
.eq(TblDeviceUser::getDeviceId, tblTmpPushRemind.getDeviceId())
|
||||||
pushList.setShowName(tblTmpPushRemind.getShowName());
|
.eq(TblDeviceUser::getUserId, tblTmpPushRemind.getUserId()));
|
||||||
pushList.setPushType(PushTypeEnum.remind_water.getKey());
|
if (deviceUser != null) {
|
||||||
pushList.setPushTitle(PushTypeEnum.remind_water.getValue());
|
setPushList(pushList, deviceUser);
|
||||||
pushList.setPushContext(pushContent);
|
//更新换水提醒下次时间
|
||||||
sendPushQueueMessage(pushList);
|
Date nextRemindDate = nextRemindDate(tblTmpPushRemind.getRemindCycle());
|
||||||
//更新换水提醒下次时间
|
Instant instant = nextRemindDate.toInstant();
|
||||||
Date nextRemindDate = nextRemindDate(tblTmpPushRemind.getRemindCycle());
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
Instant instant = nextRemindDate.toInstant();
|
tblTmpPushRemind.setRemindDate(instant.atZone(zoneId).toLocalDate());
|
||||||
ZoneId zoneId = ZoneId.systemDefault();
|
tmpPushRemindService.saveOrUpdate(tblTmpPushRemind);
|
||||||
tblTmpPushRemind.setRemindDate(instant.atZone(zoneId).toLocalDate());
|
}
|
||||||
tmpPushRemindService.saveOrUpdate(tblTmpPushRemind);
|
|
||||||
});
|
});
|
||||||
log.info("RemindJobImpl - commDeviceChangeWater --> end");
|
log.info("RemindJobImpl - commDeviceChangeWater --> end");
|
||||||
}
|
}
|
||||||
|
|
@ -102,14 +101,7 @@ public class RemindJobImpl implements RemindJob {
|
||||||
List<TblDeviceUser> deviceUsers = deviceUserService.list(new QueryWrapper<TblDeviceUser>().lambda()
|
List<TblDeviceUser> deviceUsers = deviceUserService.list(new QueryWrapper<TblDeviceUser>().lambda()
|
||||||
.eq(TblDeviceUser::getDeviceId, device.getDeviceId()));
|
.eq(TblDeviceUser::getDeviceId, device.getDeviceId()));
|
||||||
deviceUsers.forEach(deviceUser -> {
|
deviceUsers.forEach(deviceUser -> {
|
||||||
pushList.setUserId(deviceUser.getUserId());
|
setPushList(pushList, deviceUser);
|
||||||
pushList.setDeviceId(deviceUser.getDeviceId());
|
|
||||||
pushList.setPhoneType("ALL");
|
|
||||||
pushList.setShowName(deviceUser.getShowName());
|
|
||||||
pushList.setPushType(PushTypeEnum.remind_water.getKey());
|
|
||||||
pushList.setPushTitle(PushTypeEnum.remind_water.getValue());
|
|
||||||
pushList.setPushContext(pushContent);
|
|
||||||
sendPushQueueMessage(pushList);
|
|
||||||
});
|
});
|
||||||
Date date = nextRemindDate(Integer.parseInt(tblDeviceHeaterDetail.getHeaterCycle()));
|
Date date = nextRemindDate(Integer.parseInt(tblDeviceHeaterDetail.getHeaterCycle()));
|
||||||
String nextRemindDate = IfishTaskUtil.format(date);
|
String nextRemindDate = IfishTaskUtil.format(date);
|
||||||
|
|
@ -117,10 +109,25 @@ public class RemindJobImpl implements RemindJob {
|
||||||
tblDeviceHeaterDetail.setHerterRemindDate(nextRemindDate);
|
tblDeviceHeaterDetail.setHerterRemindDate(nextRemindDate);
|
||||||
deviceHeaterDetailService.updateById(tblDeviceHeaterDetail);
|
deviceHeaterDetailService.updateById(tblDeviceHeaterDetail);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("RemindJobImpl - heaterDeviceChangeWater --> end");
|
log.info("RemindJobImpl - heaterDeviceChangeWater --> end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置pushList 推送对象
|
||||||
|
* @param pushList
|
||||||
|
* @param deviceUser
|
||||||
|
*/
|
||||||
|
private void setPushList(PushList pushList, TblDeviceUser deviceUser) {
|
||||||
|
pushList.setUserId(deviceUser.getUserId());
|
||||||
|
pushList.setDeviceId(deviceUser.getDeviceId());
|
||||||
|
pushList.setPhoneType("ALL");
|
||||||
|
pushList.setShowName(deviceUser.getShowName());
|
||||||
|
pushList.setPushType(PushTypeEnum.remind_water.getKey());
|
||||||
|
pushList.setPushTitle(PushTypeEnum.remind_water.getValue());
|
||||||
|
pushList.setPushContext(String.format(pushContent, deviceUser.getShowName()));
|
||||||
|
sendPushQueueMessage(pushList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置下次提醒日期
|
* 设置下次提醒日期
|
||||||
* @param remindCycle
|
* @param remindCycle
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue