| | |
| | | package com.dsh.guns.modular.system.util.task.jobs; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.entity.TNotices; |
| | | import com.dsh.guns.core.util.SinataUtil; |
| | | import com.dsh.guns.modular.system.model.TDriver; |
| | | import com.dsh.guns.modular.system.model.TSystemNotice; |
| | | import com.dsh.guns.modular.system.model.TUser; |
| | | import com.dsh.guns.modular.system.util.task.base.AbstractJob; |
| | | import lombok.NoArgsConstructor; |
| | | import org.quartz.JobDataMap; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 添加公告记录 |
| | |
| | | |
| | | @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.getById(noticeId); |
| | | if (SinataUtil.isNotEmpty(tNotices)){ |
| | | if (tNotices.getIsUser() == 2){ |
| | | List<TUser> tUsers = tUserService.getBaseMapper().selectList(new QueryWrapper<TUser>().eq("state",1)); |
| | | //发送公告给用户 |
| | | 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.save(notice); |
| | | |
| | | /*Map<String,Object> map = new HashMap<String,Object>(); |
| | | 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<TDriver> tDrivers = tDriverService.getBaseMapper().selectList(new QueryWrapper<TDriver>().eq("authState",2)); |
| | | //发送公告给用户 |
| | | 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.save(notice); |
| | | |
| | | /*Map<String,Object> map = new HashMap<String,Object>(); |
| | | 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(); |
| | | } |
| | | } |
| | | } |