ActTaskController.java 40 KB

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