JPushProcessor.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package cn.com.lzt.common.push;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import org.apache.log4j.Logger;
  7. import org.jeecgframework.core.constant.Globals;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.beans.factory.annotation.Qualifier;
  10. import org.springframework.core.task.TaskExecutor;
  11. import org.springframework.scheduling.annotation.Async;
  12. import org.springframework.stereotype.Component;
  13. import cn.com.lzt.common.util.CustomerConstant;
  14. import cn.com.lzt.common.util.HttpRequester;
  15. import com.alibaba.fastjson.JSON;
  16. @Component
  17. public class JPushProcessor {
  18. private static final Logger log = Logger.getLogger(JPushProcessor.class.getName());
  19. @Autowired
  20. @Qualifier("executor")
  21. private TaskExecutor taskExecutor;
  22. @Async
  23. public void pushMessage(final PushReq req) {
  24. this.taskExecutor.execute(new Runnable() {
  25. @Override
  26. public void run() {
  27. log.info("推送消息到:" + JSON.toJSONString(req.getAudiences()));
  28. System.out.println("推送消息到:" + JSON.toJSONString(req.getAudiences()));
  29. try {
  30. System.out.println("Start request hglpush server at TimeMillis:" + System.currentTimeMillis());
  31. log.info("Start request hglpush server at TimeMillis:" + System.currentTimeMillis());
  32. log.info(Thread.currentThread().getId() + "开始");
  33. String gsondata = JSON.toJSONString(req);
  34. HttpRequester.post(CustomerConstant.JPUSH_URL, gsondata);
  35. log.info(Thread.currentThread().getId() + "结束");
  36. } catch (Exception e) {
  37. log.info("推送异常信息:" + e.getMessage());
  38. System.out.println("推送异常信息:" + e.getMessage());
  39. }
  40. }
  41. });
  42. }
  43. /**
  44. * 根据用户userIdList和消息具体类型批量推送
  45. * @author zbw
  46. * 2018-1-6
  47. * @param idList
  48. * @param msgType
  49. */
  50. public void pushCommon(ArrayList<String> idList,String msgType){
  51. //极光推送
  52. // PushReq pushreq = new PushReq();
  53. // Map<String,String> extrasParam = new HashMap<String, String>();
  54. // if(idList.size()!=0&&msgType!=null&&msgType.length()!=0){
  55. // if(msgType.equals(Globals.msg_type_0)){//web发布消息
  56. // extrasParam.put("msgSendType", "sysMsg");
  57. // pushreq.setAlert(PushMsgContentProcess.PUSH_SysMsg.value());
  58. // }else if(msgType.equals(Globals.msg_type_1)){//合同到期提醒消息
  59. // extrasParam.put("msgSendType", "sysMsg");
  60. // pushreq.setAlert(PushMsgContentProcess.PUSH_ContractMsg.value());
  61. // }else if(msgType.equals(Globals.msg_type_2)){//证件到期提醒消息
  62. // extrasParam.put("msgSendType", "sysMsg");
  63. // pushreq.setAlert(PushMsgContentProcess.PUSH_CertificateMsg.value());
  64. // }else if(msgType.equals(Globals.msg_type_3)){//考勤预警提醒消息
  65. // extrasParam.put("msgSendType", "attendanceWarnMsg");
  66. // pushreq.setAlert(PushMsgContentProcess.PUSH_AttendanceWarnMsg.value());
  67. // }else if(msgType.equals(Globals.msg_type_4)){//工作流抄送完成消息
  68. // extrasParam.put("msgSendType", "sysMsg");
  69. // pushreq.setAlert(PushMsgContentProcess.PUSH_TaskCopyMsg.value());
  70. // }else if(msgType.equals(Globals.msg_type_5)){//超时的待审批推送消息
  71. // extrasParam.put("msgSendType", "sysMsg");
  72. // pushreq.setAlert(PushMsgContentProcess.PUSH_TaskOverTimeMsg.value());
  73. // }
  74. //
  75. // pushreq.setExtras(extrasParam);
  76. // pushreq.setAudiences(idList);
  77. // this.pushMessage(pushreq);
  78. // }
  79. // extrasParam.put("msgSendType", "0");//workFlowMsg
  80. /*ArrayList<String> ls = new ArrayList<String>();
  81. for (int i = 0; i < sysMsgDetailEntityList.size(); i++) {
  82. ls.add(sysMsgDetailEntityList.get(i).getReceivedId());
  83. }*/
  84. }
  85. }