ActTaskController.java 33 KB

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