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 idList,String msgType){ //极光推送 // PushReq pushreq = new PushReq(); // Map extrasParam = new HashMap(); // 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 ls = new ArrayList(); for (int i = 0; i < sysMsgDetailEntityList.size(); i++) { ls.add(sysMsgDetailEntityList.get(i).getReceivedId()); }*/ } }