package com.stylefeng.guns.modular.system.util.task.jobs; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.stylefeng.guns.core.util.SinataUtil; import com.stylefeng.guns.modular.system.model.TDriver; import com.stylefeng.guns.modular.system.model.TNotices; import com.stylefeng.guns.modular.system.model.TSystemNotice; import com.stylefeng.guns.modular.system.model.TUser; import com.stylefeng.guns.modular.system.util.task.base.AbstractJob; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import java.util.Date; import java.util.List; /** * 添加公告记录 */ public class AddNotice extends AbstractJob { public static final String name = "addNoticeJob"; @Override public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap maps = context.getMergedJobDataMap(); Integer noticeId = maps.getIntValue("noticeId"); try { System.out.println("----定时1秒后生成公告记录-----"); TNotices tNotices = tNoticesService.selectById(noticeId); if (SinataUtil.isNotEmpty(tNotices)){ if (tNotices.getIsUser() == 2){ List tUsers = tUserService.selectList(new EntityWrapper().eq("state", 1).ne("flag", 3)); //发送公告给用户 for (TUser user : tUsers){ TSystemNotice notice = new TSystemNotice(); notice.setType(1); notice.setUserType(1); notice.setNoticesId(noticeId); notice.setContent(tNotices.getContent()); notice.setUserId(user.getId()); notice.setInsertTime(new Date()); notice.setRead(1); tSystemNoticeService.insert(notice); /*Map map = new HashMap(); map.put("sound", userInfo.getIsVoice()); //是否有声音 1=否 2=是 map.put("vibrate", userInfo.getIsShake()); //是否有震动 1=否 2=是 map.put("type", 2); //消息类型 1=互动 2=公告 map.put("id", record.getId()); //对象ID JpushUtil.SendPushWithCustomForTransmission(String.valueOf(userInfo.getId()),"【超级过客】提醒您,您有一条新的公告消息。","通知消息",map);*/ } } if (tNotices.getIsDriver() == 2){ List tDrivers = tDriverService.selectList(new EntityWrapper().eq("authState", 2).ne("flag", 3)); //发送公告给用户 for (TDriver driver : tDrivers){ TSystemNotice notice = new TSystemNotice(); notice.setType(1); notice.setUserType(2); notice.setNoticesId(noticeId); notice.setContent(tNotices.getContent()); notice.setUserId(driver.getId()); notice.setInsertTime(new Date()); notice.setRead(1); tSystemNoticeService.insert(notice); /*Map map = new HashMap(); map.put("sound", userInfo.getIsVoice()); //是否有声音 1=否 2=是 map.put("vibrate", userInfo.getIsShake()); //是否有震动 1=否 2=是 map.put("type", 2); //消息类型 1=互动 2=公告 map.put("id", record.getId()); //对象ID JpushUtil.SendPushWithCustomForTransmission(String.valueOf(userInfo.getId()),"【超级过客】提醒您,您有一条新的公告消息。","通知消息",map);*/ // if (tNotices.getIsBroadcast() == 1){ // //增加极光推送 // JpushUtil.SendPushWithCustomForSh("DRIVER"+driver.getId().toString(),tNotices.getTitle(),"通知消息",null); // } } } } } catch (Exception e) { e.printStackTrace(); } } }