ActTaskController.java 42 KB

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