| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- package cn.com.lzt.common.push;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.apache.log4j.Logger;
- import org.jeecgframework.core.constant.Globals;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.core.task.TaskExecutor;
- import org.springframework.scheduling.annotation.Async;
- import org.springframework.stereotype.Component;
- import cn.com.lzt.common.util.CustomerConstant;
- import cn.com.lzt.common.util.HttpRequester;
- import com.alibaba.fastjson.JSON;
- @Component
- public class JPushProcessor {
- private static final Logger log = Logger.getLogger(JPushProcessor.class.getName());
- @Autowired
- @Qualifier("executor")
- private TaskExecutor taskExecutor;
-
- @Async
- public void pushMessage(final PushReq req) {
- this.taskExecutor.execute(new Runnable() {
- @Override
- public void run() {
- log.info("推送消息到:" + JSON.toJSONString(req.getAudiences()));
- System.out.println("推送消息到:" + JSON.toJSONString(req.getAudiences()));
- try {
- System.out.println("Start request hglpush server at TimeMillis:" + System.currentTimeMillis());
- log.info("Start request hglpush server at TimeMillis:" + System.currentTimeMillis());
- log.info(Thread.currentThread().getId() + "开始");
- String gsondata = JSON.toJSONString(req);
- HttpRequester.post(CustomerConstant.JPUSH_URL, gsondata);
- log.info(Thread.currentThread().getId() + "结束");
- } catch (Exception e) {
- log.info("推送异常信息:" + e.getMessage());
- System.out.println("推送异常信息:" + e.getMessage());
- }
- }
- });
- }
-
-
- /**
- * 根据用户userIdList和消息具体类型批量推送
- * @author zbw
- * 2018-1-6
- * @param idList
- * @param msgType
- */
- public void pushCommon(ArrayList<String> idList,String msgType){
- //极光推送
- // PushReq pushreq = new PushReq();
- // Map<String,String> extrasParam = new HashMap<String, String>();
- // if(idList.size()!=0&&msgType!=null&&msgType.length()!=0){
- // if(msgType.equals(Globals.msg_type_0)){//web发布消息
- // extrasParam.put("msgSendType", "sysMsg");
- // pushreq.setAlert(PushMsgContentProcess.PUSH_SysMsg.value());
- // }else if(msgType.equals(Globals.msg_type_1)){//合同到期提醒消息
- // extrasParam.put("msgSendType", "sysMsg");
- // pushreq.setAlert(PushMsgContentProcess.PUSH_ContractMsg.value());
- // }else if(msgType.equals(Globals.msg_type_2)){//证件到期提醒消息
- // extrasParam.put("msgSendType", "sysMsg");
- // pushreq.setAlert(PushMsgContentProcess.PUSH_CertificateMsg.value());
- // }else if(msgType.equals(Globals.msg_type_3)){//考勤预警提醒消息
- // extrasParam.put("msgSendType", "attendanceWarnMsg");
- // pushreq.setAlert(PushMsgContentProcess.PUSH_AttendanceWarnMsg.value());
- // }else if(msgType.equals(Globals.msg_type_4)){//工作流抄送完成消息
- // extrasParam.put("msgSendType", "sysMsg");
- // pushreq.setAlert(PushMsgContentProcess.PUSH_TaskCopyMsg.value());
- // }else if(msgType.equals(Globals.msg_type_5)){//超时的待审批推送消息
- // extrasParam.put("msgSendType", "sysMsg");
- // pushreq.setAlert(PushMsgContentProcess.PUSH_TaskOverTimeMsg.value());
- // }
- //
- // pushreq.setExtras(extrasParam);
- // pushreq.setAudiences(idList);
- // this.pushMessage(pushreq);
- // }
-
-
- // extrasParam.put("msgSendType", "0");//workFlowMsg
-
-
- /*ArrayList<String> ls = new ArrayList<String>();
- for (int i = 0; i < sysMsgDetailEntityList.size(); i++) {
- ls.add(sysMsgDetailEntityList.get(i).getReceivedId());
- }*/
-
- }
-
-
- }
|