ActTaskController.java 38 KB

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