ActTaskController.java 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  1. /**
  2. * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
  3. */
  4. package com.jeeplus.modules.act.web;
  5. import java.io.InputStream;
  6. import java.io.UnsupportedEncodingException;
  7. import java.net.URLDecoder;
  8. import java.util.ArrayList;
  9. import java.util.HashMap;
  10. import java.util.List;
  11. import java.util.Map;
  12. import javax.servlet.ServletContext;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import com.jeeplus.common.json.AjaxJson;
  16. import com.jeeplus.common.utils.SpringContextHolder;
  17. import com.jeeplus.common.websocket.service.system.SystemInfoSocketHandler;
  18. import com.jeeplus.modules.act.service.ActModelService;
  19. import com.jeeplus.modules.oa.entity.OaNotify;
  20. import com.jeeplus.modules.oa.entity.OaNotifyRecord;
  21. import com.jeeplus.modules.oa.service.OaNotifyService;
  22. import com.jeeplus.modules.sg.managementcenter.activiti.entity.Construction;
  23. import com.jeeplus.modules.sg.managementcenter.activiti.entity.Disclose;
  24. import com.jeeplus.modules.sg.managementcenter.activiti.entity.ProcessPersonnel;
  25. import com.jeeplus.modules.sg.managementcenter.activiti.entity.UploadImages;
  26. import com.jeeplus.modules.sg.managementcenter.activiti.service.ConstructionService;
  27. import com.jeeplus.modules.sg.managementcenter.activiti.service.DiscloseService;
  28. import com.jeeplus.modules.sg.managementcenter.activiti.service.ProcessPersonnelService;
  29. import com.jeeplus.modules.sg.managementcenter.activiti.service.UploadImagesService;
  30. import com.jeeplus.modules.sg.managementcenter.activiti.utils.MyActiviUtils;
  31. import com.jeeplus.modules.sg.managementcenter.project.service.ProjectService;
  32. import org.activiti.engine.HistoryService;
  33. import org.activiti.engine.RepositoryService;
  34. import org.activiti.engine.RuntimeService;
  35. import org.activiti.engine.TaskService;
  36. import org.activiti.engine.history.HistoricTaskInstance;
  37. import org.activiti.engine.impl.RepositoryServiceImpl;
  38. import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
  39. import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
  40. import org.activiti.engine.impl.pvm.PvmActivity;
  41. import org.activiti.engine.impl.pvm.PvmTransition;
  42. import org.activiti.engine.impl.pvm.process.ActivityImpl;
  43. import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
  44. import org.activiti.engine.impl.pvm.process.TransitionImpl;
  45. import org.activiti.engine.impl.task.TaskDefinition;
  46. import org.activiti.engine.runtime.ProcessInstance;
  47. import org.activiti.engine.task.Task;
  48. import org.apache.commons.lang3.StringUtils;
  49. import org.apache.ibatis.annotations.Param;
  50. import org.apache.shiro.authz.annotation.RequiresPermissions;
  51. import org.springframework.beans.factory.annotation.Autowired;
  52. import org.springframework.stereotype.Controller;
  53. import org.springframework.ui.Model;
  54. import org.springframework.web.bind.annotation.PathVariable;
  55. import org.springframework.web.bind.annotation.RequestMapping;
  56. import org.springframework.web.bind.annotation.ResponseBody;
  57. import com.jeeplus.core.persistence.Page;
  58. import com.jeeplus.core.web.BaseController;
  59. import com.jeeplus.modules.act.entity.Act;
  60. import com.jeeplus.modules.act.service.ActTaskService;
  61. import com.jeeplus.modules.act.utils.ActUtils;
  62. import com.jeeplus.modules.sys.utils.UserUtils;
  63. /**
  64. * 流程个人任务相关Controller
  65. * @author jeeplus
  66. * @version 2016-11-03
  67. */
  68. @Controller
  69. @RequestMapping(value = "${adminPath}/act/task")
  70. public class ActTaskController extends BaseController {
  71. @Autowired
  72. private ActTaskService actTaskService;
  73. @Autowired
  74. private HistoryService historyService;
  75. @Autowired
  76. private RuntimeService runtimeService;
  77. @Autowired
  78. private RepositoryService repositoryService;
  79. @Autowired
  80. private TaskService taskService;
  81. @Autowired
  82. private ConstructionService constructionService;
  83. @Autowired
  84. private DiscloseService discloseService;
  85. @Autowired
  86. private UploadImagesService uploadImagesService;
  87. @Autowired
  88. private OaNotifyService oaNotifyService;
  89. @Autowired
  90. private ProcessPersonnelService processPersonnelService;
  91. @Autowired
  92. private ProjectService projectService;
  93. @Autowired
  94. private ActModelService actModelService;
  95. /**
  96. * 获取待办列表
  97. * @return
  98. */
  99. @RequestMapping(value = {"todo", ""})
  100. public String todoList(Act act, HttpServletRequest request,HttpServletResponse response, Model model) throws Exception {
  101. Page<org.activiti.engine.repository.Model> page2 = actModelService.modelList(
  102. new Page<org.activiti.engine.repository.Model>(request, response), "");
  103. List<org.activiti.engine.repository.Model> list2 = page2.getList();
  104. List a = new ArrayList();
  105. a.add("全部流程");
  106. for (org.activiti.engine.repository.Model newList : list2) {
  107. String name = newList.getName();
  108. a.add(name);
  109. }
  110. model.addAttribute("act", a);
  111. return "modules/bpm/task/todo/taskTodoList";
  112. }
  113. @ResponseBody
  114. @RequestMapping(value = "todo/data")
  115. public Map<String, Object> todoListData(Act act, HttpServletRequest request,HttpServletResponse response, Model model) throws Exception {
  116. Page<HashMap<String,String>> page = actTaskService.todoList(new Page<HashMap<String,String>>(request, response),act);
  117. return getBootstrapData(page);
  118. }
  119. /**
  120. * 获取已办任务
  121. * @return
  122. */
  123. @RequestMapping(value = "historic")
  124. public String historicList(Act act, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
  125. return "modules/bpm/task/history/taskHistoricList";
  126. }
  127. @ResponseBody
  128. @RequestMapping(value = "historic/data")
  129. public Map<String, Object> historicListData(Act act, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
  130. Page<HashMap<String,String>> page = actTaskService.historicList(new Page<HashMap<String,String>>(request, response), act);
  131. return getBootstrapData(page);
  132. }
  133. /**
  134. * 获取我的申请列表
  135. * @return
  136. */
  137. @RequestMapping(value = "myApplyed")
  138. public String myApplyedList(Act act, HttpServletResponse response, Model model) throws Exception {
  139. return "modules/bpm/task/apply/taskMyAppledList";
  140. }
  141. @ResponseBody
  142. @RequestMapping(value = "myApplyed/data")
  143. public Map<String, Object> myApplyedListData(Act act, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
  144. Page<HashMap> page = actTaskService.getMyStartedProcIns(UserUtils.getUser(),new Page<HashMap>(request, response));
  145. return getBootstrapData(page);
  146. }
  147. /**
  148. * 获取流转历史列表
  149. * @param startAct 开始活动节点名称
  150. * @param endAct 结束活动节点名称
  151. */
  152. @RequestMapping(value = "histoicFlow")
  153. public String histoicFlow(Act act, String startAct, String endAct, Model model){
  154. if (StringUtils.isNotBlank(act.getProcInsId())){
  155. List<Act> histoicFlowList = actTaskService.histoicFlowList(act.getProcInsId(), startAct, endAct);
  156. model.addAttribute("histoicFlowList", histoicFlowList);
  157. }
  158. return "modules/bpm/task/history/taskHistoricFlow";
  159. }
  160. /**
  161. * 获取流程流向图
  162. * @param startAct 开始活动节点名称
  163. * @param endAct 结束活动节点名称
  164. */
  165. @RequestMapping(value = "flowChart")
  166. public String flowChart(Act act, String startAct, String endAct, Model model){
  167. if (StringUtils.isNotBlank(act.getProcInsId())){
  168. List<Act> histoicFlowList = actTaskService.histoicFlowList(act.getProcInsId(), startAct, endAct);
  169. model.addAttribute("histoicFlowList", histoicFlowList);
  170. }
  171. return "modules/bpm/task/chart/taskFlowChart";
  172. }
  173. /**
  174. * 获取流程列表
  175. * @param category 流程分类
  176. */
  177. @RequestMapping(value = "process")
  178. public String processList(String category, HttpServletRequest request, HttpServletResponse response, Model model) {
  179. Page<Object[]> page = new Page<Object[]>(request, response);
  180. model.addAttribute("category", category);
  181. return "modules/bpm/task/process/taskProcessList";
  182. }
  183. /**
  184. * 获取流程表单
  185. */
  186. @RequestMapping(value = "form")
  187. public String form(Act act, HttpServletRequest request, Model model){
  188. // 获取流程XML上的表单KEY
  189. String formKey = actTaskService.getFormKey(act.getProcDefId(), act.getTaskDefKey());
  190. // 获取流程实例对象
  191. if (act.getProcInsId() != null){
  192. if(actTaskService.getProcIns(act.getProcInsId())!=null){
  193. try {
  194. act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
  195. } catch (Exception e) {
  196. e.printStackTrace();
  197. }
  198. }else{
  199. act.setFinishedProcIns(actTaskService.getFinishedProcIns(act.getProcInsId()));
  200. }
  201. if(actTaskService.isNextGatewaty(act.getProcInsId())){
  202. act.setIsNextGatewaty(true);
  203. }else{
  204. act.setIsNextGatewaty(false);
  205. }
  206. }
  207. return "redirect:" + ActUtils.getFormUrl(formKey, act);
  208. }
  209. /**
  210. * 根据流程实例ID,获取当前节点的流程表单详情
  211. */
  212. @RequestMapping(value = "formDetail")
  213. public String formDetail(Act act, HttpServletRequest request, Model model){
  214. // 获取流程XML上的表单KEY
  215. String taskDefKey = nextTaskDefinition(act.getProcInsId());
  216. String formKey = actTaskService.getFormKey(act.getProcDefId(), taskDefKey);
  217. // 获取流程实例对象
  218. if (act.getProcInsId() != null){
  219. if(actTaskService.getProcIns(act.getProcInsId())!=null){
  220. act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
  221. }else{
  222. act.setFinishedProcIns(actTaskService.getFinishedProcIns(act.getProcInsId()));
  223. }
  224. if(actTaskService.isNextGatewaty(act.getProcInsId())){
  225. act.setIsNextGatewaty(true);
  226. }else{
  227. act.setIsNextGatewaty(false);
  228. }
  229. }
  230. return "redirect:" + ActUtils.getFormUrl(formKey, act);
  231. }
  232. /**
  233. * 启动流程
  234. */
  235. @RequestMapping(value = "start")
  236. @ResponseBody
  237. public String start(Act act, String table, String id, Model model) throws Exception {
  238. actTaskService.startProcess(act.getProcDefKey(), act.getBusinessId(), act.getBusinessTable(), act.getTitle());
  239. return "true";//adminPath + "/act/task";
  240. }
  241. /**
  242. * 签收任务
  243. */
  244. @RequestMapping(value = "claim")
  245. @ResponseBody
  246. public String claim(Act act) {
  247. String userId = UserUtils.getUser().getLoginName();//ObjectUtils.toString(UserUtils.getUser().getId());
  248. actTaskService.claim(act.getTaskId(), userId);
  249. return "true";//adminPath + "/act/task";
  250. }
  251. /**
  252. * 完成任务
  253. * vars.keys=flag,pass
  254. * vars.values=1,true
  255. * vars.types=S,B @see com.jeeplus.jeeplus.modules.act.utils.PropertyType
  256. */
  257. @RequestMapping(value = "complete")
  258. @ResponseBody
  259. public String complete(Act act) {
  260. actTaskService.complete(act.getTaskId(), act.getProcInsId(), act.getComment(), act.getVars().getVariableMap());
  261. return "true";//adminPath + "/act/task";
  262. }
  263. /**
  264. * 读取带跟踪的图片
  265. */
  266. @RequestMapping(value = "trace/photo/{procDefId}/{execId}")
  267. public void tracePhoto(@PathVariable("procDefId") String procDefId, @PathVariable("execId") String execId, HttpServletResponse response) throws Exception {
  268. InputStream imageStream = actTaskService.tracePhoto(procDefId, execId);
  269. // 输出资源内容到相应对象
  270. byte[] b = new byte[1024];
  271. int len;
  272. while ((len = imageStream.read(b, 0, 1024)) != -1) {
  273. response.getOutputStream().write(b, 0, len);
  274. }
  275. }
  276. /**
  277. * 输出跟踪流程信息
  278. *
  279. * @return
  280. * @throws Exception
  281. */
  282. @ResponseBody
  283. @RequestMapping(value = "trace/info/{proInsId}")
  284. public List<Map<String, Object>> traceInfo(@PathVariable("proInsId") String proInsId) throws Exception {
  285. List<Map<String, Object>> activityInfos = actTaskService.traceProcess(proInsId);
  286. return activityInfos;
  287. }
  288. /**
  289. * 显示流程图
  290. @RequestMapping(value = "processPic")
  291. public void processPic(String procDefId, HttpServletResponse response) throws Exception {
  292. ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
  293. String diagramResourceName = procDef.getDiagramResourceName();
  294. InputStream imageStream = repositoryService.getResourceAsStream(procDef.getDeploymentId(), diagramResourceName);
  295. byte[] b = new byte[1024];
  296. int len = -1;
  297. while ((len = imageStream.read(b, 0, 1024)) != -1) {
  298. response.getOutputStream().write(b, 0, len);
  299. }
  300. }*/
  301. /**
  302. * 获取跟踪信息
  303. @RequestMapping(value = "processMap")
  304. public String processMap(String procDefId, String proInstId, Model model)
  305. throws Exception {
  306. List<ActivityImpl> actImpls = new ArrayList<ActivityImpl>();
  307. ProcessDefinition processDefinition = repositoryService
  308. .createProcessDefinitionQuery().processDefinitionId(procDefId)
  309. .singleResult();
  310. ProcessDefinitionImpl pdImpl = (ProcessDefinitionImpl) processDefinition;
  311. String processDefinitionId = pdImpl.getId();// 流程标识
  312. ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
  313. .getDeployedProcessDefinition(processDefinitionId);
  314. List<ActivityImpl> activitiList = def.getActivities();// 获得当前任务的所有节点
  315. List<String> activeActivityIds = runtimeService.getActiveActivityIds(proInstId);
  316. for (String activeId : activeActivityIds) {
  317. for (ActivityImpl activityImpl : activitiList) {
  318. String id = activityImpl.getId();
  319. if (activityImpl.isScope()) {
  320. if (activityImpl.getActivities().size() > 1) {
  321. List<ActivityImpl> subAcList = activityImpl
  322. .getActivities();
  323. for (ActivityImpl subActImpl : subAcList) {
  324. String subid = subActImpl.getId();
  325. System.out.println("subImpl:" + subid);
  326. if (activeId.equals(subid)) {// 获得执行到那个节点
  327. actImpls.add(subActImpl);
  328. break;
  329. }
  330. }
  331. }
  332. }
  333. if (activeId.equals(id)) {// 获得执行到那个节点
  334. actImpls.add(activityImpl);
  335. System.out.println(id);
  336. }
  337. }
  338. }
  339. model.addAttribute("procDefId", procDefId);
  340. model.addAttribute("proInstId", proInstId);
  341. model.addAttribute("actImpls", actImpls);
  342. return "modules/act/actTaskMap";
  343. }*/
  344. /**
  345. * 删除任务
  346. * @param taskId 流程实例ID
  347. * @param reason 删除原因
  348. */
  349. @ResponseBody
  350. @RequiresPermissions("act:process:edit")
  351. @RequestMapping(value = "deleteTask")
  352. public AjaxJson deleteTask(String taskId, String reason) {
  353. AjaxJson j = new AjaxJson();
  354. if (StringUtils.isBlank(reason)){
  355. j.setSuccess(false);
  356. j.setMsg("请填写删除原因");
  357. }else{
  358. actTaskService.deleteTask(taskId, reason);
  359. j.setSuccess(true);
  360. j.setMsg("删除任务成功,任务ID=" + taskId);
  361. }
  362. return j;
  363. }
  364. /**
  365. * 审批
  366. * @param act
  367. */
  368. @ResponseBody
  369. @RequestMapping(value = "audit")
  370. public AjaxJson auditTask(Act act) {
  371. AjaxJson j = new AjaxJson();
  372. actTaskService.auditSave(act);
  373. j.setMsg("审批成功");
  374. return j;
  375. }
  376. /**
  377. * 经研所审批
  378. * @param act
  379. */
  380. @ResponseBody
  381. @RequestMapping(value = "economics")
  382. public AjaxJson economics(Act act,String design) {
  383. AjaxJson j = new AjaxJson();
  384. try {
  385. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  386. act.setComment(comment);
  387. actTaskService.economics(act,design);
  388. } catch (UnsupportedEncodingException e) {
  389. e.printStackTrace();
  390. }
  391. j.setMsg("审批成功");
  392. return j;
  393. }
  394. /**
  395. * 人工选择问题类型审批
  396. * @param act
  397. */
  398. @ResponseBody
  399. @RequestMapping(value = "artificialTask")
  400. public AjaxJson artificialTask(Act act) {
  401. AjaxJson j = new AjaxJson();
  402. try {
  403. ProcessPersonnel processPersonnel = new ProcessPersonnel();
  404. processPersonnel.setProcInsId(act.getProcInsId());
  405. processPersonnel.setProjectManager(UserUtils.getUser().getLoginName());
  406. processPersonnelService.save(processPersonnel);
  407. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  408. act.setComment(comment);
  409. actTaskService.artificialTask(act);
  410. } catch (UnsupportedEncodingException e) {
  411. e.printStackTrace();
  412. }
  413. j.setMsg("审批成功");
  414. return j;
  415. }
  416. /**
  417. * 是否可以政策处理(农场/民事)
  418. * @param act
  419. */
  420. @ResponseBody
  421. @RequestMapping(value = "policiesChange")
  422. public AjaxJson policiesChange(Act act) {
  423. AjaxJson j = new AjaxJson();
  424. try {
  425. ProcessPersonnel processPersonnel = new ProcessPersonnel();
  426. processPersonnel.setProcInsId(act.getProcInsId());
  427. //设置
  428. processPersonnel.setRuralCivil(UserUtils.getUser().getLoginName());
  429. processPersonnelService.newUpdate(processPersonnel);
  430. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  431. act.setComment(comment);
  432. actTaskService.policiesChange(act);
  433. } catch (UnsupportedEncodingException e) {
  434. e.printStackTrace();
  435. }
  436. j.setMsg("审批成功");
  437. return j;
  438. }
  439. /**
  440. * 上传借款单据
  441. * @param act
  442. */
  443. @ResponseBody
  444. @RequestMapping(value = "loanUploadList")
  445. public AjaxJson loanUploadList(Act act) {
  446. AjaxJson j = new AjaxJson();
  447. try {
  448. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  449. act.setComment(comment);
  450. actTaskService.loanUploadList(act);
  451. } catch (UnsupportedEncodingException e) {
  452. e.printStackTrace();
  453. }
  454. j.setMsg("审批成功");
  455. return j;
  456. }
  457. /**
  458. * 项目经理重新审核是否可以政策处理(农场/民事)
  459. * @param act
  460. */
  461. @ResponseBody
  462. @RequestMapping(value = "managerPolicesChange")
  463. public AjaxJson managerPolicesChange(Act act) {
  464. AjaxJson j = new AjaxJson();
  465. try {
  466. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  467. act.setComment(comment);
  468. actTaskService.managerPolicesChange(act);
  469. } catch (UnsupportedEncodingException e) {
  470. e.printStackTrace();
  471. }
  472. j.setMsg("审批成功");
  473. return j;
  474. }
  475. /**
  476. * 上传未签字版政策处理清单
  477. * @param act
  478. */
  479. @ResponseBody
  480. @RequestMapping(value = "notSignUpload")
  481. public AjaxJson notSignUpload(Act act, String pic, UploadImages uploadImages) {
  482. AjaxJson j = new AjaxJson();
  483. try {
  484. if (pic!=null&&pic!="") {
  485. uploadImages.setPath(pic);
  486. uploadImages.setProcInsId(act.getProcInsId());
  487. uploadImages.setuId(UserUtils.getUser().getLoginName());
  488. uploadImagesService.save(uploadImages);
  489. }
  490. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  491. act.setComment(comment);
  492. actTaskService.notSignUpload(act);
  493. } catch (UnsupportedEncodingException e) {
  494. e.printStackTrace();
  495. }
  496. j.setMsg("审批成功");
  497. return j;
  498. }
  499. /**
  500. * 上传签字版政策处理清单
  501. * @param act
  502. */
  503. @ResponseBody
  504. @RequestMapping(value = "signUploadList")
  505. public AjaxJson signUploadList(Act act, String pic, UploadImages uploadImages) {
  506. AjaxJson j = new AjaxJson();
  507. try {
  508. if (pic!=null&&pic!="") {
  509. uploadImages.setPath(pic);
  510. uploadImages.setProcInsId(act.getProcInsId());
  511. uploadImages.setuId(UserUtils.getUser().getLoginName());
  512. uploadImagesService.save(uploadImages);
  513. }
  514. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  515. act.setComment(comment);
  516. actTaskService.signUploadList(act);
  517. } catch (UnsupportedEncodingException e) {
  518. e.printStackTrace();
  519. }
  520. j.setMsg("审批成功");
  521. return j;
  522. }
  523. /**
  524. * 上传签字版合同
  525. * @param act
  526. */
  527. @ResponseBody
  528. @RequestMapping(value = "contractUploadList")
  529. public AjaxJson contractUploadList(Act act, String pic, UploadImages uploadImages) {
  530. AjaxJson j = new AjaxJson();
  531. try {
  532. if (pic!=null&&pic!="") {
  533. uploadImages.setPath(pic);
  534. uploadImages.setProcInsId(act.getProcInsId());
  535. uploadImages.setuId(UserUtils.getUser().getLoginName());
  536. uploadImagesService.save(uploadImages);
  537. }
  538. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  539. act.setComment(comment);
  540. actTaskService.contractUploadList(act);
  541. } catch (UnsupportedEncodingException e) {
  542. e.printStackTrace();
  543. }
  544. j.setMsg("审批成功");
  545. return j;
  546. }
  547. /**
  548. * 配网运行人员判定设计变更
  549. * @param act
  550. */
  551. @ResponseBody
  552. @RequestMapping(value = "operator")
  553. public AjaxJson operator(Act act, String design, String pic, UploadImages uploadImages) {
  554. AjaxJson j = new AjaxJson();
  555. //获取流程id
  556. String procInsId = act.getProcInsId();
  557. //根据流程id获取项目需求提出单位
  558. String demandUnit = constructionService.demandUnit(procInsId);
  559. //根据登陆名查询用户角色
  560. String nameFindOffice = constructionService.nameFindOffice(design);
  561. if ("经研所需求".equals(demandUnit)) {
  562. if (!"经研所".equals(nameFindOffice)) {
  563. j.setSuccess(false);
  564. j.setMsg("请选择对应的人员");
  565. return j;
  566. }
  567. }
  568. try {
  569. if (pic!=null&&pic!="") {
  570. uploadImages.setPath(pic);
  571. uploadImages.setProcInsId(act.getProcInsId());
  572. uploadImages.setuId(UserUtils.getUser().getLoginName());
  573. uploadImagesService.save(uploadImages);
  574. }
  575. ProcessPersonnel processPersonnel = new ProcessPersonnel();
  576. processPersonnel.setProcInsId(act.getProcInsId());
  577. processPersonnel.setOperatingPersonnel(UserUtils.getUser().getLoginName());
  578. processPersonnelService.newUpdate(processPersonnel);
  579. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  580. act.setComment(comment);
  581. actTaskService.operator(act,design);
  582. } catch (UnsupportedEncodingException e) {
  583. e.printStackTrace();
  584. }
  585. j.setMsg("审批成功");
  586. return j;
  587. }
  588. /**
  589. * 项目经理判断是否需要设计变更
  590. * @param act
  591. */
  592. @ResponseBody
  593. @RequestMapping(value = "managerDesign")
  594. public AjaxJson managerDesign(Act act) {
  595. AjaxJson j = new AjaxJson();
  596. try {
  597. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  598. act.setComment(comment);
  599. actTaskService.managerDesign(act);
  600. } catch (UnsupportedEncodingException e) {
  601. e.printStackTrace();
  602. }
  603. j.setMsg("审批成功");
  604. return j;
  605. }
  606. /**
  607. * 设计单位人员提交文件
  608. * @param act
  609. */
  610. @ResponseBody
  611. @RequestMapping(value = "designUpload")
  612. public AjaxJson designUpload(Act act, String design, String pic, UploadImages uploadImages) {
  613. AjaxJson j = new AjaxJson();
  614. try {
  615. if (pic!=null&&pic!="") {
  616. uploadImages.setPath(pic);
  617. uploadImages.setProcInsId(act.getProcInsId());
  618. uploadImages.setuId(UserUtils.getUser().getLoginName());
  619. uploadImagesService.save(uploadImages);
  620. }
  621. ProcessPersonnel processPersonnel = new ProcessPersonnel();
  622. processPersonnel.setProcInsId(act.getProcInsId());
  623. processPersonnel.setTheDesigner(UserUtils.getUser().getLoginName());
  624. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  625. act.setComment(comment);
  626. actTaskService.designUpload(act,design);
  627. } catch (UnsupportedEncodingException e) {
  628. e.printStackTrace();
  629. }
  630. j.setMsg("审批成功");
  631. return j;
  632. }
  633. /**
  634. * 配网运行人员判断变更后材料
  635. * @param act
  636. */
  637. @ResponseBody
  638. @RequestMapping(value = "operatorUpload")
  639. public AjaxJson operatorUpload(Act act, String design) {
  640. AjaxJson j = new AjaxJson();
  641. try {
  642. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  643. act.setComment(comment);
  644. actTaskService.operatorUpload(act,design);
  645. } catch (UnsupportedEncodingException e) {
  646. e.printStackTrace();
  647. }
  648. j.setMsg("审批成功");
  649. return j;
  650. }
  651. /**
  652. * 配网项目经理判断变更后材料
  653. * @param act
  654. */
  655. @ResponseBody
  656. @RequestMapping(value = "managerUpload")
  657. public AjaxJson managerUpload(Act act, String design) {
  658. AjaxJson j = new AjaxJson();
  659. try {
  660. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  661. act.setComment(comment);
  662. actTaskService.managerUpload(act,design);
  663. } catch (UnsupportedEncodingException e) {
  664. e.printStackTrace();
  665. }
  666. j.setMsg("审批成功");
  667. return j;
  668. }
  669. /**
  670. * 施工审批
  671. * @param act
  672. */
  673. @ResponseBody
  674. @RequestMapping(value = "audit2")
  675. public AjaxJson auditTask2(Act act) {
  676. AjaxJson j = new AjaxJson();
  677. String historyActivity = MyActiviUtils.findHistoryActivity(act.getProcInsId(),"施工单位组织交底");
  678. System.out.println(historyActivity);
  679. try {
  680. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  681. act.setComment(comment);
  682. actTaskService.auditSave2(act);
  683. } catch (UnsupportedEncodingException e) {
  684. e.printStackTrace();
  685. }
  686. j.setMsg("审批成功");
  687. return j;
  688. }
  689. /**
  690. * 项目经理组织交底
  691. * @param
  692. */
  693. @ResponseBody
  694. @RequestMapping(value = "audit3")
  695. public AjaxJson auditTask3(Act act) {
  696. AjaxJson j = new AjaxJson();
  697. String s = "";
  698. boolean flag = false;
  699. Disclose dc = new Disclose();
  700. dc.setProcInsId(act.getProcInsId());
  701. Disclose disclose = discloseService.get(dc);
  702. if (null==disclose){
  703. j.setSuccess(false);
  704. j.setMsg("请导入数据");
  705. return j;
  706. }
  707. Boolean flagDesign = actTaskService.isJudgeDesign(disclose);//设计变更
  708. Boolean flagItemCLose =actTaskService.isJudgeItemClose(disclose);//项目关闭
  709. String flagDeal =actTaskService.newJudgeDeal(disclose);
  710. if (null==disclose.getPrecondition()||"".equals(disclose.getPrecondition())){
  711. if (flagItemCLose){
  712. if (null==disclose.getExplanationOfNecessity()||disclose.getExplanationOfNecessity().equals("")){
  713. s="必要性问题说明不能为空!";
  714. flag = true;
  715. }
  716. }
  717. if (flagDesign){
  718. if (null==disclose.getInconsistentDescription()||disclose.getInconsistentDescription().equals("")){
  719. s+="图纸现场不一致说明不能为空!";
  720. flag = true;
  721. }
  722. }
  723. if ("民事农村".equals(flagDeal)||"行政".equals(flagDeal)) {
  724. String policyHandlingInstructions = disclose.getPolicyHandlingInstructions();
  725. if (policyHandlingInstructions == null || "".equals(policyHandlingInstructions)) {
  726. s += "政策处理说明不能为空";
  727. flag = true;
  728. }
  729. }
  730. /* if (flagDeal){
  731. if (null==disclose.getPolicyHandlingInstructions()||disclose.getPolicyHandlingInstructions().equals("")){
  732. s+=" 政策处理说明不能为空!";
  733. flag=true;
  734. }
  735. }*/
  736. if (flag){
  737. j.setSuccess(false);
  738. j.setMsg(s);
  739. return j;
  740. }
  741. }
  742. try {
  743. //记录当前操作的项目经理为
  744. ProcessPersonnel processPersonnel = new ProcessPersonnel();
  745. processPersonnel.setProcInsId(act.getProcInsId());
  746. processPersonnel.setOperatingPersonnel(UserUtils.getUser().getLoginName());
  747. processPersonnelService.newUpdate(processPersonnel);
  748. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  749. act.setComment(comment);
  750. actTaskService.auditSave3(act,disclose,flagDesign,flagItemCLose,flagDeal);
  751. } catch (UnsupportedEncodingException e) {
  752. e.printStackTrace();
  753. }
  754. j.setMsg("审批成功");
  755. return j;
  756. }
  757. /*
  758. 项目关闭:专职
  759. */
  760. @ResponseBody
  761. @RequestMapping(value = "speciallyTask")
  762. public AjaxJson speciallyTask(Act act,String fullName,String tuser,Construction construction) {
  763. AjaxJson j = new AjaxJson();
  764. try {
  765. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  766. act.setComment(comment);
  767. actTaskService.specially(act,fullName);
  768. } catch (UnsupportedEncodingException e) {
  769. e.printStackTrace();
  770. }
  771. if ("yes".equals(act.getFlag())){
  772. j.setMsg("审批成功");
  773. }else {
  774. j.setMsg("驳回成功");
  775. }
  776. return j;
  777. }/*
  778. 项目关闭:项目经理
  779. */
  780. @ResponseBody
  781. @RequestMapping(value = "managerFormTask")
  782. public AjaxJson managerFormTask(Act act,String fullName,String tuser,Construction construction) {
  783. AjaxJson j = new AjaxJson();
  784. try {
  785. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  786. act.setComment(comment);
  787. actTaskService.managerFormTask(act,fullName);
  788. } catch (UnsupportedEncodingException e) {
  789. e.printStackTrace();
  790. }
  791. if ("yes".equals(act.getFlag())){
  792. j.setMsg("审批成功");
  793. }else {
  794. j.setMsg("驳回成功");
  795. }
  796. return j;
  797. }
  798. /*
  799. 项目关闭:运行人员
  800. */
  801. @ResponseBody
  802. @RequestMapping(value = "memberTask")
  803. public AjaxJson memberTask(Act act,String fullTime,String tuser,Construction construction) {
  804. AjaxJson j = new AjaxJson();
  805. try {
  806. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  807. act.setComment(comment);
  808. actTaskService.addMember(act,fullTime);
  809. } catch (UnsupportedEncodingException e) {
  810. e.printStackTrace();
  811. }
  812. if ("yes".equals(act.getFlag())){
  813. j.setMsg("审批成功");
  814. }else {
  815. j.setMsg("驳回成功");
  816. }
  817. return j;
  818. }
  819. /*
  820. 项目关闭:系统专职
  821. */
  822. @ResponseBody
  823. @RequestMapping(value = "departmentTask")
  824. public AjaxJson departmentTask(Act act,String tuser,Construction construction) {
  825. AjaxJson j = new AjaxJson();
  826. try {
  827. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  828. act.setComment(comment);
  829. actTaskService.addDepartment(act);
  830. projectService.updateStatusBy("0",act.getProcInsId());
  831. projectService.updateStatusByClose("1",act.getProcInsId());
  832. } catch (UnsupportedEncodingException e) {
  833. e.printStackTrace();
  834. }
  835. OaNotify oaNotify = new OaNotify();
  836. oaNotify.setType("1");
  837. oaNotify.setTitle("施工交底结束");
  838. oaNotify.setContent("施工交底结束");
  839. oaNotify.setStatus("1");
  840. oaNotify.setOaNotifyRecordIds("9fcadb62979e4ceab459867b37bf04bc");
  841. oaNotifyService.save(oaNotify);
  842. List<OaNotifyRecord> list = oaNotify.getOaNotifyRecordList();
  843. for(OaNotifyRecord o : list){
  844. //发送通知到客户端
  845. ServletContext context = SpringContextHolder
  846. .getBean(ServletContext.class);
  847. new SystemInfoSocketHandler().sendMessageToUser(UserUtils.get(o.getUser().getId()).getLoginName(), "收到一条新通知,请到我的通知查看!");
  848. }
  849. j.setMsg("审批成功;已经通知项目经理,施工单位");
  850. return j;
  851. }
  852. @ResponseBody
  853. @RequestMapping(value = "policiesDealTask")
  854. public AjaxJson policiesDealTask(Act act,String fullName,String tuser,Construction construction) {
  855. AjaxJson j = new AjaxJson();
  856. try {
  857. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  858. act.setComment(comment);
  859. actTaskService.policiesDeal(act,fullName);
  860. } catch (UnsupportedEncodingException e) {
  861. e.printStackTrace();
  862. }
  863. if ("yes".equals(act.getFlag())){
  864. j.setMsg("审批成功");
  865. }else {
  866. j.setMsg("驳回成功");
  867. }
  868. return j;
  869. }
  870. /*
  871. 政策处理:施工单位人员上传未覆盖盖章
  872. */
  873. @ResponseBody
  874. @RequestMapping(value = "coveredTask")
  875. public AjaxJson coveredTask(Act act,String fullName,String pic, UploadImages uploadImages) {
  876. AjaxJson j = new AjaxJson();
  877. try {
  878. if (pic!=null&&pic!="") {
  879. uploadImages.setPath(pic);
  880. uploadImages.setProcInsId(act.getProcInsId());
  881. uploadImages.setuId(UserUtils.getUser().getLoginName());
  882. uploadImagesService.save(uploadImages);
  883. }
  884. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  885. act.setComment(comment);
  886. actTaskService.covered(act,fullName);
  887. } catch (UnsupportedEncodingException e) {
  888. e.printStackTrace();
  889. }
  890. if ("yes".equals(act.getFlag())){
  891. j.setMsg("审批成功");
  892. }else {
  893. j.setMsg("驳回成功");
  894. }
  895. return j;
  896. }
  897. /*
  898. 政策处理:施工单位人员上传覆盖盖章
  899. */
  900. @ResponseBody
  901. @RequestMapping(value = "sealTask")
  902. public AjaxJson sealTask(Act act,String pic, UploadImages uploadImages) {
  903. AjaxJson j = new AjaxJson();
  904. try {
  905. if (pic!=null&&pic!="") {
  906. uploadImages.setPath(pic);
  907. uploadImages.setProcInsId(act.getProcInsId());
  908. uploadImages.setuId(UserUtils.getUser().getLoginName());
  909. uploadImagesService.save(uploadImages);
  910. }
  911. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  912. act.setComment(comment);
  913. actTaskService.seal(act);
  914. } catch (UnsupportedEncodingException e) {
  915. e.printStackTrace();
  916. }
  917. if ("yes".equals(act.getFlag())){
  918. j.setMsg("审批成功");
  919. }else {
  920. j.setMsg("驳回成功");
  921. }
  922. return j;
  923. }
  924. @ResponseBody
  925. @RequestMapping(value = "phaseManagerTask")
  926. public AjaxJson phaseManagerTask(Act act,String fullName) {
  927. AjaxJson j = new AjaxJson();
  928. try {
  929. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  930. act.setComment(comment);
  931. actTaskService.phaseManager(act,fullName);
  932. } catch (UnsupportedEncodingException e) {
  933. e.printStackTrace();
  934. }
  935. if ("yes".equals(act.getFlag())){
  936. j.setMsg("审批成功");
  937. }else {
  938. j.setMsg("驳回成功");
  939. }
  940. return j;
  941. }
  942. /*
  943. 政策处理:配网政策处理专职 : 上传收据
  944. */
  945. @ResponseBody
  946. @RequestMapping(value = "receiptTask")
  947. public AjaxJson receiptTask(Act act,String pic, UploadImages uploadImages) {
  948. AjaxJson j = new AjaxJson();
  949. try {
  950. if (pic!=null&&pic!="") {
  951. uploadImages.setPath(pic);
  952. uploadImages.setProcInsId(act.getProcInsId());
  953. uploadImages.setuId(UserUtils.getUser().getLoginName());
  954. uploadImagesService.save(uploadImages);
  955. }
  956. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  957. act.setComment(comment);
  958. actTaskService.receiptTask(act);
  959. } catch (UnsupportedEncodingException e) {
  960. e.printStackTrace();
  961. }
  962. if ("yes".equals(act.getFlag())){
  963. j.setMsg("审批成功");
  964. }else {
  965. j.setMsg("驳回成功");
  966. }
  967. return j;
  968. }
  969. /*
  970. 政策处理:配网政策处理专职 :上传缴费单
  971. */
  972. @ResponseBody
  973. @RequestMapping(value = "singleTask")
  974. public AjaxJson singleTask(Act act,String pic, UploadImages uploadImages) {
  975. AjaxJson j = new AjaxJson();
  976. try {
  977. if (pic!=null&&pic!="") {
  978. uploadImages.setPath(pic);
  979. uploadImages.setProcInsId(act.getProcInsId());
  980. uploadImages.setuId(UserUtils.getUser().getLoginName());
  981. uploadImagesService.save(uploadImages);
  982. }
  983. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  984. act.setComment(comment);
  985. actTaskService.singleTask(act);
  986. } catch (UnsupportedEncodingException e) {
  987. e.printStackTrace();
  988. }
  989. j.setMsg("审批成功");
  990. return j;
  991. }
  992. /*
  993. 政策处理:配网政策处理专职 :上传借款
  994. */
  995. @ResponseBody
  996. @RequestMapping(value = "policyPay1Task")
  997. public AjaxJson policyPay1Task(Act act,String pic, UploadImages uploadImages) {
  998. AjaxJson j = new AjaxJson();
  999. try {
  1000. if (pic!=null&&pic!="") {
  1001. uploadImages.setPath(pic);
  1002. uploadImages.setProcInsId(act.getProcInsId());
  1003. uploadImages.setuId(UserUtils.getUser().getLoginName());
  1004. uploadImagesService.save(uploadImages);
  1005. }
  1006. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  1007. act.setComment(comment);
  1008. actTaskService.policy1Pay(act);
  1009. } catch (UnsupportedEncodingException e) {
  1010. e.printStackTrace();
  1011. }
  1012. j.setMsg("审批成功");
  1013. return j;
  1014. }
  1015. /**
  1016. * 施工交底审批
  1017. * @param act*/
  1018. @ResponseBody
  1019. @RequestMapping(value = "newAudit")
  1020. public AjaxJson newAuditTask(Act act,String tuser,Construction construction) {
  1021. AjaxJson j = new AjaxJson();
  1022. try {
  1023. String comment = URLDecoder.decode(act.getComment(), "UTF-8");
  1024. act.setComment(comment);
  1025. actTaskService.newAuditSave(act,tuser,construction);
  1026. } catch (UnsupportedEncodingException e) {
  1027. e.printStackTrace();
  1028. }
  1029. j.setMsg("审批成功");
  1030. return j;
  1031. }
  1032. /**
  1033. * 取回流程
  1034. * @param taskId
  1035. */
  1036. @ResponseBody
  1037. @RequestMapping(value = "callback")
  1038. public AjaxJson callback(@Param("taskId") String taskId) {
  1039. AjaxJson j = new AjaxJson();
  1040. try {
  1041. Map<String, Object> variables;
  1042. // 取得当前任务
  1043. HistoricTaskInstance currTask = historyService
  1044. .createHistoricTaskInstanceQuery().taskId(taskId)
  1045. .singleResult();
  1046. // 取得流程实例
  1047. ProcessInstance instance = runtimeService
  1048. .createProcessInstanceQuery()
  1049. .processInstanceId(currTask.getProcessInstanceId())
  1050. .singleResult();
  1051. if (instance == null) {
  1052. j.setSuccess(false);
  1053. j.setMsg("流程已经结束");
  1054. return j;
  1055. }
  1056. variables=instance.getProcessVariables();
  1057. // 取得流程定义
  1058. ProcessDefinitionEntity definition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
  1059. .getDeployedProcessDefinition(currTask
  1060. .getProcessDefinitionId());
  1061. if (definition == null) {
  1062. j.setSuccess(false);
  1063. j.setMsg("流程定义未找到");
  1064. return j;
  1065. }
  1066. // 取得下一步活动
  1067. ActivityImpl currActivity = ((ProcessDefinitionImpl) definition)
  1068. .findActivity(currTask.getTaskDefinitionKey());
  1069. List<PvmTransition> nextTransitionList = currActivity
  1070. .getOutgoingTransitions();
  1071. for (PvmTransition nextTransition : nextTransitionList) {
  1072. PvmActivity nextActivity = nextTransition.getDestination();
  1073. List<HistoricTaskInstance> completeTasks = historyService
  1074. .createHistoricTaskInstanceQuery()
  1075. .processInstanceId(instance.getId())
  1076. .taskDefinitionKey(nextActivity.getId()).finished()
  1077. .list();
  1078. int finished = completeTasks.size();
  1079. if (finished > 0) {
  1080. j.setSuccess(false);
  1081. j.setMsg("存在已经完成的下一步,流程不能取回");
  1082. return j;
  1083. }
  1084. List<Task> nextTasks = taskService.createTaskQuery().processInstanceId(instance.getId())
  1085. .taskDefinitionKey(nextActivity.getId()).list();
  1086. for (Task nextTask : nextTasks) {
  1087. //取活动,清除活动方向
  1088. List<PvmTransition> oriPvmTransitionList = new ArrayList<PvmTransition>();
  1089. List<PvmTransition> pvmTransitionList = nextActivity
  1090. .getOutgoingTransitions();
  1091. for (PvmTransition pvmTransition : pvmTransitionList) {
  1092. oriPvmTransitionList.add(pvmTransition);
  1093. }
  1094. pvmTransitionList.clear();
  1095. //建立新方向
  1096. ActivityImpl nextActivityImpl = ((ProcessDefinitionImpl) definition)
  1097. .findActivity(nextTask.getTaskDefinitionKey());
  1098. TransitionImpl newTransition = nextActivityImpl
  1099. .createOutgoingTransition();
  1100. newTransition.setDestination(currActivity);
  1101. //完成任务
  1102. taskService.complete(nextTask.getId(), variables);
  1103. historyService.deleteHistoricTaskInstance(nextTask.getId());
  1104. //恢复方向
  1105. currActivity.getIncomingTransitions().remove(newTransition);
  1106. List<PvmTransition> pvmTList = nextActivity
  1107. .getOutgoingTransitions();
  1108. pvmTList.clear();
  1109. for (PvmTransition pvmTransition : oriPvmTransitionList) {
  1110. pvmTransitionList.add(pvmTransition);
  1111. }
  1112. }
  1113. }
  1114. historyService.deleteHistoricTaskInstance(currTask.getId());
  1115. j.setSuccess(true);
  1116. j.setMsg("取回成功");
  1117. return j;
  1118. } catch (Exception e) {
  1119. j.setSuccess(false);
  1120. j.setMsg("流程取回失败,未知错误.");
  1121. return j;
  1122. }
  1123. }
  1124. /**
  1125. * 根据实例编号查找下一个任务节点
  1126. * @param procInstId :实例编号
  1127. * @return
  1128. */
  1129. public String nextTaskDefinition(String procInstId){
  1130. //流程标示
  1131. String processDefinitionId = historyService.createHistoricProcessInstanceQuery().processInstanceId(procInstId).singleResult().getProcessDefinitionId();
  1132. ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processDefinitionId);
  1133. //执行实例
  1134. ExecutionEntity execution = (ExecutionEntity) runtimeService.createProcessInstanceQuery().processInstanceId(procInstId).singleResult();
  1135. //当前实例的执行到哪个节点
  1136. if(execution == null){
  1137. TaskDefinition[] taskDefinitions = {};
  1138. taskDefinitions = def.getTaskDefinitions().values().toArray(taskDefinitions);
  1139. return taskDefinitions[taskDefinitions.length -1].getKey();
  1140. }else{
  1141. return execution.getActivityId();
  1142. }
  1143. }
  1144. }