9f19a6aeab893dd3393243f2611253eead667296.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by FernFlower decompiler)
  4. //
  5. package com.kingdee.bos.workflow.event;
  6. import com.kingdee.bos.BOSException;
  7. import com.kingdee.bos.service.message.Message;
  8. import com.kingdee.bos.workflow.ProcessInstInfo;
  9. import com.kingdee.bos.workflow.WfException;
  10. import com.kingdee.bos.workflow.define.ProcessType;
  11. import com.kingdee.bos.workflow.define.Resource;
  12. import com.kingdee.bos.workflow.enactment.WfEngine;
  13. import com.kingdee.bos.workflow.enactment.message.WfMessage;
  14. import com.kingdee.bos.workflow.util.ApplicationUtil;
  15. import com.kingdee.eas.common.EASBizException;
  16. import com.kingdee.eas.mobile.msg.IMobileAppMsgFacade;
  17. import com.kingdee.eas.mobile.msg.MobileAppMsgFacadeFactory;
  18. import java.util.HashMap;
  19. import java.util.Locale;
  20. import java.util.Map;
  21. import org.apache.log4j.Logger;
  22. public class WfEvent {
  23. private static final Logger logger = Logger.getLogger(WfEvent.class);
  24. public static final String EVENT_MESSAGE_DOMAIN = "kingdee.bos.workflow.event";
  25. public static final String HEADER_NAME_PROCESSDEFID = "processDefId";
  26. public static final String HEADER_NAME_PROCESSDEFVERSION = "processDefVersion";
  27. public static final String HEADER_NAME_ACTDEFID = "actDefId";
  28. public static final String HEADER_NAME_PROCESSID = "processId";
  29. public static final String HEADER_NAME_ACTIVITYID = "activityId";
  30. public static final String HEADER_NAME_EVENTTYPE = "eventType";
  31. private int eventId;
  32. private String processDefId;
  33. private int processDefVersion;
  34. private String actDefId;
  35. private String processId;
  36. private Resource processName;
  37. private String activityId;
  38. private WfEventType eventType;
  39. private HashMap parameters;
  40. private String receiverList;
  41. private String sourceids;
  42. private WfEngine engine;
  43. private ProcessType wfType;
  44. public WfEvent(WfEngine engine) {
  45. this.engine = engine;
  46. }
  47. public int getEventId() {
  48. return this.eventId;
  49. }
  50. public Map getParameters() {
  51. return (Map)this.parameters.clone();
  52. }
  53. public void setParameters(HashMap map) {
  54. this.parameters = map;
  55. }
  56. public Object getParameters(Object key) {
  57. return this.parameters.get(key);
  58. }
  59. public WfEventType getEventType() {
  60. return this.eventType;
  61. }
  62. public void setEventType(WfEventType type) {
  63. this.eventType = type;
  64. }
  65. public String getActDefId() {
  66. return this.actDefId;
  67. }
  68. public void setActDefId(String actDefId) {
  69. this.actDefId = actDefId;
  70. }
  71. public String getActivityId() {
  72. return this.activityId;
  73. }
  74. public void setActivityId(String activityId) {
  75. this.activityId = activityId;
  76. }
  77. public String getProcessDefId() {
  78. return this.processDefId;
  79. }
  80. public void setProcessDefId(String processDefId) {
  81. this.processDefId = processDefId;
  82. }
  83. public int getProcessDefVersion() {
  84. return this.processDefVersion;
  85. }
  86. public void setProcessDefVersion(int processDefVersion) {
  87. this.processDefVersion = processDefVersion;
  88. }
  89. public String getProcessId() {
  90. return this.processId;
  91. }
  92. public void setProcessId(String processId) {
  93. this.processId = processId;
  94. }
  95. public void setWfType(ProcessType wfType) {
  96. this.wfType = wfType;
  97. }
  98. public ProcessType getWfType() {
  99. return this.wfType;
  100. }
  101. private String getEventName(Locale locale) {
  102. if (locale == null) {
  103. return this.eventType.getName();
  104. } else if (!ProcessType.BACKGROUNDJOB.equals(this.wfType)) {
  105. return this.eventType.getName(locale);
  106. } else {
  107. if ("l2".equalsIgnoreCase(locale.toString())) {
  108. if (this.eventType.equals(WfEventType.PROCESS_STARTED)) {
  109. return "后台事务已经启动";
  110. }
  111. if (this.eventType.equals(WfEventType.PROCESS_COMPLETED)) {
  112. return "后台事务已经完成";
  113. }
  114. if (this.eventType.equals(WfEventType.DEADLINE)) {
  115. return "后台事务已经到达期限";
  116. }
  117. if (this.eventType.equals(WfEventType.PROCESS_SUSPENDED)) {
  118. return "后台事务已经挂起";
  119. }
  120. }
  121. if ("l3".equalsIgnoreCase(locale.toString())) {
  122. if (this.eventType.equals(WfEventType.PROCESS_STARTED)) {
  123. return "後臺事務已經啟動";
  124. }
  125. if (this.eventType.equals(WfEventType.PROCESS_COMPLETED)) {
  126. return "後臺事務已經完成";
  127. }
  128. if (this.eventType.equals(WfEventType.DEADLINE)) {
  129. return "後臺事務已經到達期限";
  130. }
  131. if (this.eventType.equals(WfEventType.PROCESS_SUSPENDED)) {
  132. return "後臺事務已經掛起";
  133. }
  134. }
  135. return this.eventType.getName();
  136. }
  137. }
  138. public Message toMessage() {
  139. WfMessage message = null;
  140. message = new WfMessage();
  141. ProcessInstInfo procInfo = null;
  142. String code = "";
  143. String title = "";
  144. String topic = "";
  145. try {
  146. procInfo = this.engine.getProcessInst(this.processId).getData();
  147. code = procInfo.getCode();
  148. } catch (WfException var10) {
  149. logger.error("获取procInfo报错", var10);
  150. }
  151. Locale[] locales = ApplicationUtil.getContextLocales(this.engine.context());
  152. String content;
  153. for(int i = 0; i < locales.length; ++i) {
  154. Locale locale = locales[i];
  155. topic = procInfo.getMeta().getProcInstTopic(locale);
  156. if (topic != null) {
  157. title = topic;
  158. } else {
  159. title = "process name" + this.getProcessName().getValue(locale) + this.getEventName(locale);
  160. }
  161. if ("BACKGROUNDJOB".equals(procInfo.getMeta().getProcdefType())) {
  162. message.addContent("请通过 “ 系统功能 -> 后台事务 -> 后台事务监控” 查看 “编码” 为{ " + code + " }的后台事务的错误日志,了解挂起原因或修复此事务。", locale);
  163. } else {
  164. content = "";
  165. if (this.eventType.equals(WfEventType.PROCESS_SUSPENDED)) {
  166. content = title + " was aborted due to an error. For details, please contact IT (itsupport@gtiit.edu.cn) for help.";
  167. } else {
  168. content = title + " was aborted due to an error. For details, please contact IT (itsupport@gtiit.edu.cn) for help.";
  169. }
  170. message.addContent(content, locale);
  171. }
  172. message.addSubject(title, locale);
  173. message.addInitiatorName(procInfo.getInitiatorName(locale), locale);
  174. }
  175. message.setInitiatorId(procInfo.getInitiatorId());
  176. message.setContext(this.engine.context());
  177. message.setReceiver(this.receiverList);
  178. message.setProcessDefHashValue(procInfo.getProcDefHashValue());
  179. message.setProcessDefId(this.getProcessDefId());
  180. message.setProcessInstId(this.getProcessId());
  181. message.setActivityDefId(this.getActDefId());
  182. message.setActivityInstId(this.getActivityId());
  183. message.setSourceIds(this.getSourceIds());
  184. String suspend = null;
  185. if (this.parameters != null) {
  186. suspend = (String)this.parameters.get("suspendValue");
  187. }
  188. if (suspend != null) {
  189. message.setIsParamSuspend(true);
  190. }
  191. if (WfEventType.PROCESS_SUSPENDED.equals(this.getEventType())) {
  192. String isEmail = String.valueOf(this.getParameters("suspendEmail"));
  193. content = String.valueOf(this.getParameters("suspendSms"));
  194. if ("true".equals(isEmail) && "true".equals(content)) {
  195. message.setContentType(7);
  196. } else if ("true".equals(isEmail)) {
  197. message.setContentType(3);
  198. }
  199. }
  200. message.fillMessage();
  201. return message.getMessage();
  202. }
  203. public void sendEmailWhenSuspend() throws EASBizException, BOSException {
  204. IMobileAppMsgFacade iMsg = MobileAppMsgFacadeFactory.getLocalInstance(this.engine.context());
  205. iMsg.mobileAppListener(this.toMessage());
  206. }
  207. public static WfEvent FromMessage(WfEngine engine, Message message) {
  208. WfEvent event = new WfEvent(engine);
  209. event.processDefId = message.getStringHeader("processDefId");
  210. event.processDefVersion = message.getIntHeader("processDefVersion");
  211. event.actDefId = message.getStringHeader("actDefId");
  212. event.processId = message.getStringHeader("processId");
  213. event.activityId = message.getStringHeader("activityId");
  214. event.eventType = WfEventType.getEnum(message.getStringHeader("eventType"));
  215. return event;
  216. }
  217. public String dump() {
  218. StringBuffer dest = new StringBuffer();
  219. dest.append("eventType = ");
  220. dest.append(this.eventType.getName());
  221. dest.append("\n");
  222. dest.append("processDefId = ");
  223. dest.append(this.processDefId);
  224. dest.append("\n");
  225. dest.append("processDefVersion = ");
  226. dest.append(this.processDefVersion);
  227. dest.append("\n");
  228. dest.append("actDefId = ");
  229. dest.append(this.actDefId);
  230. dest.append("\n");
  231. dest.append("processId = ");
  232. dest.append(this.processId);
  233. dest.append("\n");
  234. dest.append("activityId = ");
  235. dest.append(this.activityId);
  236. dest.append("\n");
  237. return dest.toString();
  238. }
  239. public String getReceiverList() {
  240. return this.receiverList;
  241. }
  242. public void setReceiverList(String string) {
  243. this.receiverList = string;
  244. }
  245. public Resource getProcessName() {
  246. return this.processName;
  247. }
  248. public void setProcessName(Resource resource) {
  249. this.processName = resource;
  250. }
  251. public String getSourceIds() {
  252. return this.sourceids;
  253. }
  254. public void setSourceIds(String sourceids) {
  255. this.sourceids = sourceids;
  256. }
  257. }