|
直接上代码
- public class ProcessPushEngine implements Interceptor{
- public static Logger logger = Logger.getLogger(ProcessPushEngine.class);
- public static final List<String> NAMES = new ArrayList<String>();
- static{
- NAMES.add("advanceProcessAction");
- NAMES.add("backProcessAction");
- NAMES.add("transferTaskAction");
- NAMES.add("withdrawTaskAction");
- };
-
- public void execute() {
- ActionContext ac = ContextHelper.getActionContext();
- Action action = ac.getAction();
- if (NAMES.contains(action.getName())){
- try{
- Set<Task> tasks = new HashSet<Task>();
- ProcessContext pc = ProcessUtils.getProcessContext();
- tasks.addAll(pc.getNewNotices());
- tasks.addAll(pc.getNewTasks());
-
- for (Task t : tasks){
- String status = t.getStatus();
- if (TaskStatus.READY.equals(status) || TaskStatus.EXECUTING.equals(status)){
- String name = t.getName();
- String url = t.getEURL();
- if (SystemUtils.isNotEmptyString(url)){
- url += (url.contains("?") ? "&" : "?");
- url = url + "task=" + t.getId() + "&process=" + t.getProcess() + "&activity=" + t.getActivity();
-
- if (url.startsWith("/")){
- url = JustepConfig.getUIServer() + url;
- }
- logger.info("message: " + name + ", url: " + url + ", person: " + t.getExecutorFID() + ", " + t.getExecutorFName());
- Message msg = new Message(name, url, null);
- Set<String> personIDs = new HashSet<String>();
- personIDs.add(t.getExecutorFID());
- MessageDispatcherFactory.createMessageDispatcher(JustepConfig.getMqttServer()).sendMessage(msg, personIDs);
- }
- }
- }
- }catch (Exception e){
- e.printStackTrace();
- logger.error(e.getMessage()+"", e);
- }
- }
- }
- }
复制代码
|
|