ActTaskController.java 51 KB

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