宠物笼杀菌提醒

This commit is contained in:
易焱 2020-03-28 21:21:25 +08:00
parent 27f360947d
commit 84b9222837
2 changed files with 12 additions and 6 deletions

View File

@ -43,5 +43,5 @@ public class TblTmpPushRemind {
private String isPush; private String isPush;
private int notifyType;
} }

View File

@ -58,6 +58,7 @@ public class RemindJobImpl implements RemindJob {
private ITblDeviceService deviceService; private ITblDeviceService deviceService;
private final String pushContent = "【换水提醒】您的水族箱\"%s\"需要换水啦~您可以在水箱设置中更改提醒设置"; private final String pushContent = "【换水提醒】您的水族箱\"%s\"需要换水啦~您可以在水箱设置中更改提醒设置";
private final String pushContent1 = "【杀菌提醒】您的宠物笼\"%s\"需要杀菌啦~您可以在宠物笼设置中更改提醒设置";
@Scheduled(cron = "0 0 10 * * ?") @Scheduled(cron = "0 0 10 * * ?")
@ -76,8 +77,13 @@ public class RemindJobImpl implements RemindJob {
//查询出设备对应的名称 //查询出设备对应的名称
TblDeviceUser deviceUser = deviceUsers.get(0); TblDeviceUser deviceUser = deviceUsers.get(0);
if (deviceUser != null) { if (deviceUser != null) {
setPushList(pushList, deviceUser); //0 水族箱 1 宠物笼
//更新换水提醒下次时间 if (tblTmpPushRemind.getNotifyType() == 0) {
setPushList(pushList, deviceUser, pushContent);
} else {
setPushList(pushList, deviceUser, pushContent1);
}
//更新下次时间换水提醒
Date nextRemindDate = nextRemindDate(tblTmpPushRemind.getRemindCycle()); Date nextRemindDate = nextRemindDate(tblTmpPushRemind.getRemindCycle());
Instant instant = nextRemindDate.toInstant(); Instant instant = nextRemindDate.toInstant();
ZoneId zoneId = ZoneId.systemDefault(); ZoneId zoneId = ZoneId.systemDefault();
@ -110,7 +116,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 -> {
setPushList(pushList, deviceUser); setPushList(pushList, deviceUser, pushContent);
}); });
Date date = nextRemindDate(Integer.parseInt(tblDeviceHeaterDetail.getHeaterCycle())); Date date = nextRemindDate(Integer.parseInt(tblDeviceHeaterDetail.getHeaterCycle()));
String nextRemindDate = IfishTaskUtil.format(date); String nextRemindDate = IfishTaskUtil.format(date);
@ -126,14 +132,14 @@ public class RemindJobImpl implements RemindJob {
* @param pushList * @param pushList
* @param deviceUser * @param deviceUser
*/ */
private void setPushList(PushList pushList, TblDeviceUser deviceUser) { private void setPushList(PushList pushList, TblDeviceUser deviceUser, String content) {
pushList.setUserId(deviceUser.getUserId()); pushList.setUserId(deviceUser.getUserId());
pushList.setDeviceId(deviceUser.getDeviceId()); pushList.setDeviceId(deviceUser.getDeviceId());
pushList.setPhoneType("ALL"); pushList.setPhoneType("ALL");
pushList.setShowName(deviceUser.getShowName()); pushList.setShowName(deviceUser.getShowName());
pushList.setPushType(PushTypeEnum.remind_water.getKey()); pushList.setPushType(PushTypeEnum.remind_water.getKey());
pushList.setPushTitle(PushTypeEnum.remind_water.getValue()); pushList.setPushTitle(PushTypeEnum.remind_water.getValue());
pushList.setPushContext(String.format(pushContent, deviceUser.getShowName())); pushList.setPushContext(String.format(content, deviceUser.getShowName()));
sendPushQueueMessage(pushList); sendPushQueueMessage(pushList);
} }