ActTaskController.java 39 KB

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