From 3ea3e0a9afe1d59169b7fa6f7408bb6ebf1be4e1 Mon Sep 17 00:00:00 2001 From: Timer <@> Date: Tue, 17 Mar 2026 00:04:44 +0800 Subject: [PATCH] bug fixed --- .../activiti/ActivitiController.java | 2063 +++++++++-------- .../webapp/jsp/business/businessUnitList.jsp | 9 +- .../jsp/safety/EducationBuilderView.jsp | 6 - .../jsp/safety/EducationInsiderView.jsp | 2 +- 4 files changed, 1063 insertions(+), 1017 deletions(-) diff --git a/src/main/java/com/sipai/controller/activiti/ActivitiController.java b/src/main/java/com/sipai/controller/activiti/ActivitiController.java index f061da49..eb23444f 100644 --- a/src/main/java/com/sipai/controller/activiti/ActivitiController.java +++ b/src/main/java/com/sipai/controller/activiti/ActivitiController.java @@ -74,6 +74,7 @@ import org.activiti.engine.task.Task; import org.activiti.image.ProcessDiagramGenerator; import org.activiti.spring.ProcessEngineFactoryBean; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.node.ObjectNode; import org.slf4j.Logger; @@ -114,7 +115,7 @@ import java.util.zip.ZipInputStream; @RequestMapping(value = "/activiti/workflow") public class ActivitiController { - protected Logger logger = LoggerFactory.getLogger(getClass()); + protected Logger logger = LoggerFactory.getLogger(getClass()); protected WorkflowProcessDefinitionService workflowProcessDefinitionService; @@ -125,14 +126,14 @@ public class ActivitiController { protected TaskService taskService; protected WorkflowTraceService traceService; - - @Resource + + @Resource private UnitService unitService; - - @Resource - private JobService jobService; - @Resource - private UserJobService userjobService; + + @Resource + private JobService jobService; + @Resource + private UserJobService userjobService; @Autowired ManagementService managementService; @@ -174,11 +175,11 @@ public class ActivitiController { @Resource private EquipmentTransfersApplyService equipmentTransfersApplyService; @Resource - private EquipmentAcceptanceApplyService equipmentAcceptanceApplyService; - + private EquipmentAcceptanceApplyService equipmentAcceptanceApplyService; + @Resource - private EquipmentStopRecordService equipmentStopRecordService; - + private EquipmentStopRecordService equipmentStopRecordService; + @Resource private EquipmentRepairPlanService equipmentRepairPlanService; @Resource @@ -192,20 +193,20 @@ public class ActivitiController { @Resource private RepairService repairService; @Resource - private OverhaulItemProjectService overhaulItemProjectService; + private OverhaulItemProjectService overhaulItemProjectService; @Resource - private MaintainCarService maintainCarService; - @Resource - private RepairCarService repairCarService; - @Resource - private RoutineWorkService routineWorkService; - @Resource - private WaterTestService waterTestService; - @Resource - private RptCreateService rptCreateService; - @Resource - private OverhaulService overhaulService; - + private MaintainCarService maintainCarService; + @Resource + private RepairCarService repairCarService; + @Resource + private RoutineWorkService routineWorkService; + @Resource + private WaterTestService waterTestService; + @Resource + private RptCreateService rptCreateService; + @Resource + private OverhaulService overhaulService; + @Resource private IndexWorkService indexWorkService; @@ -216,97 +217,96 @@ public class ActivitiController { @Resource private WorkorderDetailService workorderDetailService; @Resource - private AbnormityService abnormityService; + private AbnormityService abnormityService; @Resource private RawMaterialService rawMaterialService; @Resource private ReasonableAdviceService reasonableAdviceService; @Resource - private EquipmentCardService equipmentCardService; - - + private EquipmentCardService equipmentCardService; + @RequestMapping("/showProcessList.do") - public String showProcessList(HttpServletRequest request,Model model) { - System.out.println("basic"); - return "/activiti/processList"; - } + public String showProcessList(HttpServletRequest request, Model model) { + System.out.println("basic"); + return "/activiti/processList"; + } + /** * 流程定义列表 * * @return */ @RequestMapping(value = "/getProcessList.do") - public ModelAndView getProcessList(HttpServletRequest request,Model model, - @RequestParam(value = "page") Integer page, - @RequestParam(value = "rows") Integer rows, - @RequestParam(value = "sort", required=false) String sort, - @RequestParam(value = "order", required=false) String order) { - User cu=(User)request.getSession().getAttribute("cu"); - int startNum=0; - if(rows==null || rows==0){ - rows = 50; - } - if(page!=null && page>0){ - startNum =(page-1)*rows; - } - System.out.println("companyId:"+request.getParameter("search_pid")); - //模糊查询---activiti自带模糊查询无法使用 + public ModelAndView getProcessList(HttpServletRequest request, Model model, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "rows") Integer rows, + @RequestParam(value = "sort", required = false) String sort, + @RequestParam(value = "order", required = false) String order) { + User cu = (User) request.getSession().getAttribute("cu"); + int startNum = 0; + if (rows == null || rows == 0) { + rows = 50; + } + if (page != null && page > 0) { + startNum = (page - 1) * rows; + } + System.out.println("companyId:" + request.getParameter("search_pid")); + //模糊查询---activiti自带模糊查询无法使用 String sql = "select top (100) percent a.*,b.DEPLOY_TIME_ from ACT_RE_PROCDEF a left join ACT_RE_DEPLOYMENT b on a.DEPLOYMENT_ID_ = b.ID_ "; String wherestr = " where 1=1"; - if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){ - wherestr += " and a.NAME_ like '%"+request.getParameter("search_name")+"%' "; - } - if(request.getParameter("search_pid")!=null && !request.getParameter("search_pid").isEmpty()){ - wherestr += " and a.KEY_ like '%"+request.getParameter("search_pid")+"%' "; - }else{ - if(!cu.getId().equals(CommString.ID_Admin)){ - List companies = unitService.getCompaniesByUserId(cu.getId()); - if(companies!=null && companies.size()>0){ - for(int i=0;i companies = unitService.getCompaniesByUserId(cu.getId()); + if (companies != null && companies.size() > 0) { + for (int i = 0; i < companies.size(); i++) { + wherestr += " and KEY_ like '%" + companies.get(0).getId() + "%' "; + } + } + + } + } + String orderstr = " order by b.DEPLOY_TIME_ desc"; + sql = sql + wherestr + orderstr; List list = new ArrayList(); - + // List processDefinitionList = processDefinitionQuery.listPage(startNum, rows); - NativeProcessDefinitionQuery nativeProcessDefinitionQuery= repositoryService.createNativeProcessDefinitionQuery().sql(sql); + NativeProcessDefinitionQuery nativeProcessDefinitionQuery = repositoryService.createNativeProcessDefinitionQuery().sql(sql); List processDefinitionList = nativeProcessDefinitionQuery.listPage(startNum, rows); - long sum=processDefinitionList.size(); + long sum = processDefinitionList.size(); for (ProcessDefinition processDefinition : processDefinitionList) { /*if(!processDefinition.getName().toLowerCase().contains(search_name.toLowerCase()) || !processDefinition.getId().toLowerCase().contains(search_code.toLowerCase()) ){ continue; }*/ String deploymentId = processDefinition.getDeploymentId(); - + //List deployment = repositoryService.createNativeDeploymentQuery().sql("select * from ACT_RE_DEPLOYMENT where ID_ = '"+deploymentId+"'").list(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); - list.add(new Object[]{processDefinition,deployment}); + list.add(new Object[]{processDefinition, deployment}); } - - Collections.sort(list,new Comparator(){ + + Collections.sort(list, new Comparator() { public int compare(Object[] arg0, Object[] arg1) { - return ((Deployment)arg1[1]).getDeploymentTime().compareTo(((Deployment)arg0[1]).getDeploymentTime()); + return ((Deployment) arg1[1]).getDeploymentTime().compareTo(((Deployment) arg0[1]).getDeploymentTime()); } }); - - JSONArray json= listToJsonArray(list); + + JSONArray json = listToJsonArray(list); // getNextPDNode("process:3:97523","cnc","Y"); // getNextPDNode("leave:2:72515","deptLeaderAudit","Y"); - String result="{\"total\":"+sum+",\"rows\":"+json+"}"; + String result = "{\"total\":" + sum + ",\"rows\":" + json + "}"; // System.out.println(result); - model.addAttribute("result",result); + model.addAttribute("result", result); - return new ModelAndView("result"); + return new ModelAndView("result"); - // page.setTotalCount(processDefinitionQuery.count()); // page.setResult(objects); @@ -314,65 +314,65 @@ public class ActivitiController { // // return mav; } + /** * 流程定义列表 * * @return */ @RequestMapping(value = "/getProcessDefinitionListForSelect.do") - public ModelAndView getProcessDefinitionListForSelect(HttpServletRequest request,Model model) { - User cu=(User)request.getSession().getAttribute("cu"); - String wherestr_search_name=""; - if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){ - wherestr_search_name=request.getParameter("search_name"); - } - String wherestr_search_code="asdf"; - if(request.getParameter("search_code")!=null && !request.getParameter("search_code").isEmpty()){ - wherestr_search_code =request.getParameter("search_code"); - - } - try {//解决中文乱码问题 - wherestr_search_name=new String(wherestr_search_name.getBytes("ISO-8859-1"),"UTF-8"); - wherestr_search_code=new String(wherestr_search_code.getBytes("ISO-8859-1"),"UTF-8"); - } catch (UnsupportedEncodingException e) - { - logger.error("Failed to encode search parameters", e); - } + public ModelAndView getProcessDefinitionListForSelect(HttpServletRequest request, Model model) { + User cu = (User) request.getSession().getAttribute("cu"); + String wherestr_search_name = ""; + if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) { + wherestr_search_name = request.getParameter("search_name"); + } + String wherestr_search_code = "asdf"; + if (request.getParameter("search_code") != null && !request.getParameter("search_code").isEmpty()) { + wherestr_search_code = request.getParameter("search_code"); + + } + try {//解决中文乱码问题 + wherestr_search_name = new String(wherestr_search_name.getBytes("ISO-8859-1"), "UTF-8"); + wherestr_search_code = new String(wherestr_search_code.getBytes("ISO-8859-1"), "UTF-8"); + } catch (UnsupportedEncodingException e) { + logger.error("Failed to encode search parameters", e); + } // Page page1 = new Page(PageUtil.PAGE_SIZE); // int[] pageParams = PageUtil.init(page1, request); - Integer page =0; - Integer rows =0; - int startNum=0; - try { - page =Integer.parseInt(request.getParameter("page")); - rows =Integer.parseInt(request.getParameter("rows")); - - } catch (Exception e) { - // TODO: handle exception - } - if(rows==null || rows==0){ - rows = 50; - } - if(page!=null && page>0){ - startNum =(page-1)*rows; - } - - List list = new ArrayList(); - ProcessDefinitionQuery processDefinitionQuery =null; - if(!wherestr_search_name.isEmpty() && !wherestr_search_code.isEmpty()){ - processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionName(wherestr_search_name) - .processDefinitionId(wherestr_search_code).orderByDeploymentId().asc(); - }else if(!wherestr_search_code.isEmpty()){ - //processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionKey(wherestr_search_code).orderByProcessDefinitionVersion().desc(); - List processDefinitionList = (ArrayList)repositoryService.createNativeProcessDefinitionQuery().sql("select * from ACT_RE_PROCDEF where key_ like '%"+wherestr_search_code+"%'").listPage(startNum, rows); - - }else if(!(wherestr_search_name.isEmpty())){ - processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionName(wherestr_search_name).orderByDeploymentId().asc(); - } else{ - processDefinitionQuery = repositoryService.createProcessDefinitionQuery().orderByDeploymentId().desc(); - + Integer page = 0; + Integer rows = 0; + int startNum = 0; + try { + page = Integer.parseInt(request.getParameter("page")); + rows = Integer.parseInt(request.getParameter("rows")); + + } catch (Exception e) { + // TODO: handle exception } - long sum=processDefinitionQuery.count(); + if (rows == null || rows == 0) { + rows = 50; + } + if (page != null && page > 0) { + startNum = (page - 1) * rows; + } + + List list = new ArrayList(); + ProcessDefinitionQuery processDefinitionQuery = null; + if (!wherestr_search_name.isEmpty() && !wherestr_search_code.isEmpty()) { + processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionName(wherestr_search_name) + .processDefinitionId(wherestr_search_code).orderByDeploymentId().asc(); + } else if (!wherestr_search_code.isEmpty()) { + //processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionKey(wherestr_search_code).orderByProcessDefinitionVersion().desc(); + List processDefinitionList = (ArrayList) repositoryService.createNativeProcessDefinitionQuery().sql("select * from ACT_RE_PROCDEF where key_ like '%" + wherestr_search_code + "%'").listPage(startNum, rows); + + } else if (!(wherestr_search_name.isEmpty())) { + processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionName(wherestr_search_name).orderByDeploymentId().asc(); + } else { + processDefinitionQuery = repositoryService.createProcessDefinitionQuery().orderByDeploymentId().desc(); + + } + long sum = processDefinitionQuery.count(); List processDefinitionList = processDefinitionQuery.listPage(startNum, rows); for (ProcessDefinition processDefinition : processDefinitionList) { // if(!processDefinition.getName().toLowerCase().contains(search_name.toLowerCase()) || !processDefinition.getId().toLowerCase().contains(search_code.toLowerCase()) ){ @@ -382,19 +382,18 @@ public class ActivitiController { Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); list.add(new Object[]{processDefinition, deployment}); } - - //页码 + + //页码 PageInfo pi = new PageInfo(list); - JSONArray json= listToJsonArray(list); + JSONArray json = listToJsonArray(list); // getNextPDNode("process:3:97523","cnc","Y"); // getNextPDNode("leave:2:72515","deptLeaderAudit","Y"); - String result="{\"total\":"+sum+",\"rows\":"+json+"}"; + String result = "{\"total\":" + sum + ",\"rows\":" + json + "}"; // System.out.println(result); - model.addAttribute("result",result); + model.addAttribute("result", result); - return new ModelAndView("result"); + return new ModelAndView("result"); - // page.setTotalCount(processDefinitionQuery.count()); // page.setResult(objects); @@ -402,126 +401,131 @@ public class ActivitiController { // // return mav; } + /** * 根据流程定义,获取流程所有工序 - * - *@param //order= desc表示逆序,其它都为顺序 + * + * @param //order= desc表示逆序,其它都为顺序 * @return */ @RequestMapping(value = "/getAllPDNode.do") - public ModelAndView getAllPDNode(HttpServletRequest request,Model model) { - String processDefinitionId=request.getParameter("processDefinitionId"); - String order =request.getParameter("order"); - //processDefinitionId="D121370952B:3:242518"; - List userTasks=workflowProcessDefinitionService.getAllPDTask(processDefinitionId,order); - JSONArray json =JSONArray.fromObject(userTasks); - String result="{\"total\":"+json.size()+",\"rows\":"+json+"}"; + public ModelAndView getAllPDNode(HttpServletRequest request, Model model) { + String processDefinitionId = request.getParameter("processDefinitionId"); + String order = request.getParameter("order"); + //processDefinitionId="D121370952B:3:242518"; + List userTasks = workflowProcessDefinitionService.getAllPDTask(processDefinitionId, order); + JSONArray json = JSONArray.fromObject(userTasks); + String result = "{\"total\":" + json.size() + ",\"rows\":" + json + "}"; // System.out.println(result); - model.addAttribute("result",result); + model.addAttribute("result", result); - return new ModelAndView("result"); + return new ModelAndView("result"); } - public List getLASTPDTask(String processDefinitionId){ - ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processDefinitionId); - //根据流程定义获得所有的节点: - List activitiList = def.getActivities(); + public List getLASTPDTask(String processDefinitionId) { + ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId); + //根据流程定义获得所有的节点: + List activitiList = def.getActivities(); // List outTransitions = activityImpl.getOutgoingTransitions(); - List usertasks=new ArrayList<>(); - for(ActivityImpl activityImpl:activitiList){ - //ActivityBehavior behavior=activityImpl.getActivityBehavior(); - if(activityImpl.getProperty("type").equals("userTask")){ - //System.out.println("任务:"+activityImpl.getProperty("name")); - usertasks.add(activityImpl); - } - } - List workTasks=ActivitiUtil.activitiImplToWorkTask(usertasks); - return workTasks; + List usertasks = new ArrayList<>(); + for (ActivityImpl activityImpl : activitiList) { + //ActivityBehavior behavior=activityImpl.getActivityBehavior(); + if (activityImpl.getProperty("type").equals("userTask")) { + //System.out.println("任务:"+activityImpl.getProperty("name")); + usertasks.add(activityImpl); + } + } + List workTasks = ActivitiUtil.activitiImplToWorkTask(usertasks); + return workTasks; } + /** * 获取流程下一步的所有任务清单 + * * @param request * @param model * @returnq */ @RequestMapping("/getRoutesForSelect.do") - public String getRoutesForSelect(HttpServletRequest request,Model model, - @RequestParam(value = "taskId") String taskId) { - Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult(); - List list=workflowProcessDefinitionService.getNextWorkTasks(task.getProcessDefinitionId(), task.getTaskDefinitionKey()); - String passFlag =request.getParameter("passFlag"); - - if (passFlag!=null && !passFlag.isEmpty()) { - boolean pFlag = Boolean.parseBoolean(passFlag); - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - WorkTask workTask =(WorkTask)iterator.next(); - if (pFlag!=workTask.isPassFlag()) { - iterator.remove(); + public String getRoutesForSelect(HttpServletRequest request, Model model, + @RequestParam(value = "taskId") String taskId) { + Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult(); + List list = workflowProcessDefinitionService.getNextWorkTasks(task.getProcessDefinitionId(), task.getTaskDefinitionKey()); + String passFlag = request.getParameter("passFlag"); + + if (passFlag != null && !passFlag.isEmpty()) { + boolean pFlag = Boolean.parseBoolean(passFlag); + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + WorkTask workTask = (WorkTask) iterator.next(); + if (pFlag != workTask.isPassFlag()) { + iterator.remove(); } - + } } - request.setAttribute("result", JSONArray.fromObject(list)); - return "result"; - } - + request.setAttribute("result", JSONArray.fromObject(list)); + return "result"; + } + /** * 获取流程下一步的所有任务清单,select2选择 + * * @param request * @param model * @returnq */ @RequestMapping("/getRoutesForSelect2.do") - public String getRoutesForSelect2(HttpServletRequest request,Model model, - @RequestParam(value = "taskId") String taskId) { - Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult(); - List list=workflowProcessDefinitionService.getNextWorkTasks(task.getProcessDefinitionId(), task.getTaskDefinitionKey()); - String passFlag =request.getParameter("passFlag"); - if (passFlag!=null && !passFlag.isEmpty()) { - boolean pFlag = Boolean.parseBoolean(passFlag); - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - WorkTask workTask =(WorkTask)iterator.next(); - if (pFlag!=workTask.isPassFlag()) { - iterator.remove(); + public String getRoutesForSelect2(HttpServletRequest request, Model model, + @RequestParam(value = "taskId") String taskId) { + Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult(); + List list = workflowProcessDefinitionService.getNextWorkTasks(task.getProcessDefinitionId(), task.getTaskDefinitionKey()); + String passFlag = request.getParameter("passFlag"); + if (passFlag != null && !passFlag.isEmpty()) { + boolean pFlag = Boolean.parseBoolean(passFlag); + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + WorkTask workTask = (WorkTask) iterator.next(); + if (pFlag != workTask.isPassFlag()) { + iterator.remove(); } - + } - JSONArray jsonArray=new JSONArray(); - if(list!=null && list.size()>0){ - for (WorkTask workTask : list) { - JSONObject jsonObject =new JSONObject(); - jsonObject.put("id", workTask.getRouteNum()); - jsonObject.put("text", workTask.getName()); - jsonObject.put("resourceId", workTask.getId()); - jsonObject.put("modelKEY", workTask.getPd_key()); - jsonArray.add(jsonObject); + JSONArray jsonArray = new JSONArray(); + if (list != null && list.size() > 0) { + for (WorkTask workTask : list) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", workTask.getRouteNum()); + jsonObject.put("text", workTask.getName()); + jsonObject.put("resourceId", workTask.getId()); + jsonObject.put("modelKEY", workTask.getPd_key()); + jsonArray.add(jsonObject); } - - } - model.addAttribute("result", jsonArray.toString()); + + } + model.addAttribute("result", jsonArray.toString()); } - return "result"; - } - + return "result"; + } + @RequestMapping("/getProcessForSelect.do") - public String getProcessForSelect(HttpServletRequest request,Model model) { - if(request.getParameter("id")!=null && !request.getParameter("id").isEmpty()){ - request.setAttribute("id", request.getParameter("id")); - } - return "/activiti/processForSelect"; - } + public String getProcessForSelect(HttpServletRequest request, Model model) { + if (request.getParameter("id") != null && !request.getParameter("id").isEmpty()) { + request.setAttribute("id", request.getParameter("id")); + } + return "/activiti/processForSelect"; + } + /** * 流程定义列表 * * @return */ @RequestMapping(value = "/getProcessListForSelect.do") - public ModelAndView getProcessListForSelect(HttpServletRequest request,Model model) { - Page page1 = new Page(PageUtil.PAGE_SIZE); + public ModelAndView getProcessListForSelect(HttpServletRequest request, Model model) { + Page page1 = new Page(PageUtil.PAGE_SIZE); int[] pageParams = PageUtil.init(page1, request); - + List list = new ArrayList(); ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().active().orderByDeploymentId().desc(); List processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]); @@ -531,15 +535,14 @@ public class ActivitiController { list.add(processDefinition);//(new Object[]{processDefinition, deployment}); } PageInfo pi = new PageInfo(list); - - JSONArray json= listToJsonArray_ProcessDefinition(list); - - - model.addAttribute("result",json); - return new ModelAndView("result"); + JSONArray json = listToJsonArray_ProcessDefinition(list); + + + model.addAttribute("result", json); + + return new ModelAndView("result"); - // page.setTotalCount(processDefinitionQuery.count()); // page.setResult(objects); @@ -547,217 +550,220 @@ public class ActivitiController { // // return mav; } - - @RequestMapping("/taskList.do") - public String taskList(HttpServletRequest request,Model model){ - return "/activiti/taskList"; - } - @RequestMapping("/taskList4main.do") - public String taskList4main(HttpServletRequest request,Model model){ - return "/activiti/taskList4main"; - } - /** - * 获取生产总流程任务列表 - * - * @param //leave - */ - @RequestMapping(value = "getTaskListNew.do") - public ModelAndView getTaskListNew(HttpServletRequest request,Model model, - @RequestParam(value = "page") Integer page, - @RequestParam(value = "rows") Integer rows) { - User cu=(User)request.getSession().getAttribute("cu"); - String userId = cu.getId(); - Map map=null; - String modelKey = request.getParameter("modelKey"); - JSONObject results = workflowService.findTodoTasks(userId,null,map,page,rows,modelKey); - JSONArray json = results.getJSONArray("rows"); - json = jsonArraySort(json,"task",true); - //服务端分页 - String result="{\"total\":"+results.getString("total")+",\"rows\":"+json+"}"; - model.addAttribute("result",result); - //客户端分页 - //String result=json.toString(); - //model.addAttribute("result",result); - return new ModelAndView("result"); - } + @RequestMapping("/taskList.do") + public String taskList(HttpServletRequest request, Model model) { + return "/activiti/taskList"; + } + + @RequestMapping("/taskList4main.do") + public String taskList4main(HttpServletRequest request, Model model) { + return "/activiti/taskList4main"; + } + + /** + * 获取生产总流程任务列表 + * + * @param //leave + */ + @RequestMapping(value = "getTaskListNew.do") + public ModelAndView getTaskListNew(HttpServletRequest request, Model model, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "rows") Integer rows) { + User cu = (User) request.getSession().getAttribute("cu"); + String userId = cu.getId(); + Map map = null; + String modelKey = request.getParameter("modelKey"); + JSONObject results = workflowService.findTodoTasks(userId, null, map, page, rows, modelKey); + JSONArray json = results.getJSONArray("rows"); + json = jsonArraySort(json, "task", true); + //服务端分页 + String result = "{\"total\":" + results.getString("total") + ",\"rows\":" + json + "}"; + model.addAttribute("result", result); + //客户端分页 + //String result=json.toString(); + //model.addAttribute("result",result); + + return new ModelAndView("result"); + } + /** * 获取生产总流程任务列表 * * @param //leave */ @RequestMapping(value = "getTaskList.do") - public ModelAndView getTaskList(HttpServletRequest request,Model model) { - User cu=(User)request.getSession().getAttribute("cu"); - List list= null; - if(cu!=null){ - String userId = cu.getId(); - Map map=null; + public ModelAndView getTaskList(HttpServletRequest request, Model model) { + User cu = (User) request.getSession().getAttribute("cu"); + List list = null; + if (cu != null) { + String userId = cu.getId(); + Map map = null; /* Page page1 = new Page(PageUtil.PAGE_SIZE); int[] pageParams = PageUtil.init(page1, request);*/ - //筛选附件条件,用与variable筛选 - list=workflowService.findTodoTasks(userId,null,map); - for (TodoTask todoTask : list) { - try { - String businessKey = todoTask.getVariables().get("businessKey").toString(); - Maintenance maintenance=null; - if(todoTask.getType().contains(ProcessType.S_Maintenance.getId())){ - //系统默认主流程 - maintenance= this.maintenanceService.selectById(businessKey); - todoTask.setBusiness(maintenance); - }else if (todoTask.getType().contains(ProcessType.Administration_IndexWork.getId())) { - IndexWork indexWork = this.indexWorkService.selectById(businessKey); - if(indexWork!=null){ - maintenance=new Maintenance(); - Company company = unitService.getCompById(indexWork.getUnitId()); + //筛选附件条件,用与variable筛选 + list = workflowService.findTodoTasks(userId, null, map); + for (TodoTask todoTask : list) { + try { + String businessKey = todoTask.getVariables().get("businessKey").toString(); + Maintenance maintenance = null; + if (todoTask.getType().contains(ProcessType.S_Maintenance.getId())) { + //系统默认主流程 + maintenance = this.maintenanceService.selectById(businessKey); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Administration_IndexWork.getId())) { + IndexWork indexWork = this.indexWorkService.selectById(businessKey); + if (indexWork != null) { + maintenance = new Maintenance(); + Company company = unitService.getCompById(indexWork.getUnitId()); + maintenance.setCompany(company); + maintenance.setProblem("指标控制工作"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } + } else if (todoTask.getType().contains(ProcessType.Administration_Organization.getId())) { + Organization organization = this.organizationService.selectById(businessKey); + if (organization != null) { + maintenance = new Maintenance(); + Company company = unitService.getCompById(organization.getUnitId()); + maintenance.setCompany(company); + maintenance.setProblem("组织工作"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } + } else if (todoTask.getType().contains(ProcessType.Administration_Reserve.getId())) { + Organization organization = this.organizationService.selectById(businessKey); + if (organization != null) { + maintenance = new Maintenance(); + Company company = unitService.getCompById(organization.getUnitId()); + maintenance.setCompany(company); + maintenance.setProblem("预案工作"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } + } else if (todoTask.getType().contains(ProcessType.Administration_Temporary.getId())) { + Temporary temporary = this.temporaryService.selectById(businessKey); + if (temporary != null) { + maintenance = new Maintenance(); + Company company = unitService.getCompById(temporary.getUnitId()); + maintenance.setCompany(company); + maintenance.setProblem("行政综合临时任务"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } + } else if (todoTask.getType().contains(ProcessType.B_Purchase.getId())) { + Subscribe subscribe = this.subscribeService.selectById(businessKey); + if (subscribe != null) { + maintenance = new Maintenance(); + Company company = unitService.getCompById(subscribe.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("物资申购审核"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } + } else if (todoTask.getType().contains(ProcessType.B_Contract.getId())) { + Contract contract = this.contractService.selectById(businessKey); + if (contract != null) { + maintenance = new Maintenance(); + Company company = unitService.getCompById(contract.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("采购合同审核"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } + } else if (todoTask.getType().contains(ProcessType.Process_Adjustment.getId())) { + ProcessAdjustment processAdjustment = this.processAdjustmentService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(processAdjustment.getUnitId()); maintenance.setCompany(company); - maintenance.setProblem("指标控制工作"); + //将问题详情内容复制到中间变量 + maintenance.setProblem(processAdjustment.getContents()); maintenance.setStatus(todoTask.getTask().getDescription()); todoTask.setBusiness(maintenance); - } - }else if (todoTask.getType().contains(ProcessType.Administration_Organization.getId())) { - Organization organization = this.organizationService.selectById(businessKey); - if(organization!=null){ - maintenance=new Maintenance(); - Company company = unitService.getCompById(organization.getUnitId()); - maintenance.setCompany(company); - maintenance.setProblem("组织工作"); + } else if (todoTask.getType().contains(ProcessType.B_Maintenance.getId())) { + MaintenanceDetail maintenanceDetail = this.maintenanceDetailService.selectById(businessKey); + if (null != maintenanceDetail.getMaintenanceid() && !maintenanceDetail.getMaintenanceid().isEmpty()) { + maintenance = this.maintenanceService.selectById(maintenanceDetail.getMaintenanceid()); + } else { + maintenance = new Maintenance(); + Company company = unitService.getCompById(maintenanceDetail.getCompanyid()); + maintenance.setCompany(company); + } + //将问题详情内容复制到中间变量 + maintenance.setProblem(maintenanceDetail.getProblemcontent()); maintenance.setStatus(todoTask.getTask().getDescription()); todoTask.setBusiness(maintenance); - } - }else if (todoTask.getType().contains(ProcessType.Administration_Reserve.getId())) { - Organization organization = this.organizationService.selectById(businessKey); - if(organization!=null){ - maintenance=new Maintenance(); - Company company = unitService.getCompById(organization.getUnitId()); + } else if (todoTask.getType().contains(ProcessType.I_Stock.getId())) { + InStockRecord inStockRecord = this.inStockRecordService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(inStockRecord.getBizId()); maintenance.setCompany(company); - maintenance.setProblem("预案工作"); + maintenance.setProblem("物资入库审核"); maintenance.setStatus(todoTask.getTask().getDescription()); todoTask.setBusiness(maintenance); - } - }else if (todoTask.getType().contains(ProcessType.Administration_Temporary.getId())) { - Temporary temporary = this.temporaryService.selectById(businessKey); - if(temporary!=null){ - maintenance=new Maintenance(); - Company company = unitService.getCompById(temporary.getUnitId()); + } else if (todoTask.getType().contains(ProcessType.Raw_Material.getId())) { + RawMaterial rawMaterial = this.rawMaterialService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(rawMaterial.getBizId()); maintenance.setCompany(company); - maintenance.setProblem("行政综合临时任务"); + maintenance.setProblem("药剂检验"); maintenance.setStatus(todoTask.getTask().getDescription()); todoTask.setBusiness(maintenance); - } - }else if (todoTask.getType().contains(ProcessType.B_Purchase.getId())) { - Subscribe subscribe = this.subscribeService.selectById(businessKey); - if(subscribe!=null){ - maintenance=new Maintenance(); - Company company = unitService.getCompById(subscribe.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("物资申购审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - } - }else if (todoTask.getType().contains(ProcessType.B_Contract.getId())) { - Contract contract = this.contractService.selectById(businessKey); - if(contract!=null){ - maintenance=new Maintenance(); - Company company = unitService.getCompById(contract.getBizId()); + } else if (todoTask.getType().contains(ProcessType.Reasonable_Advice.getId())) { + ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(reasonableAdvice.getUnitId()); maintenance.setCompany(company); - maintenance.setProblem("采购合同审核"); + maintenance.setProblem("合理化建议审核"); maintenance.setStatus(todoTask.getTask().getDescription()); todoTask.setBusiness(maintenance); - } - }else if(todoTask.getType().contains(ProcessType.Process_Adjustment.getId())){ - ProcessAdjustment processAdjustment = this.processAdjustmentService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(processAdjustment.getUnitId()); - maintenance.setCompany(company); - //将问题详情内容复制到中间变量 - maintenance.setProblem(processAdjustment.getContents()); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.B_Maintenance.getId())){ - MaintenanceDetail maintenanceDetail = this.maintenanceDetailService.selectById(businessKey); - if (null!=maintenanceDetail.getMaintenanceid() && !maintenanceDetail.getMaintenanceid().isEmpty()) { - maintenance= this.maintenanceService.selectById(maintenanceDetail.getMaintenanceid()); - }else{ - maintenance=new Maintenance(); - Company company = unitService.getCompById(maintenanceDetail.getCompanyid()); - maintenance.setCompany(company); - } - //将问题详情内容复制到中间变量 - maintenance.setProblem(maintenanceDetail.getProblemcontent()); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.I_Stock.getId())){ - InStockRecord inStockRecord = this.inStockRecordService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(inStockRecord.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("物资入库审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Raw_Material.getId())){ - RawMaterial rawMaterial = this.rawMaterialService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(rawMaterial.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("药剂检验"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Reasonable_Advice.getId())){ - ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(reasonableAdvice.getUnitId()); - maintenance.setCompany(company); - maintenance.setProblem("合理化建议审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Maintain_Car.getId())){ - MaintainCar maintainCar = this.maintainCarService.selectById(businessKey); - maintenance=new Maintenance(); - if(maintainCar!=null){ - Company company = unitService.getCompById(maintainCar.getUnitId()); - maintenance.setCompany(company); - } - maintenance.setProblem("车辆维保审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Repair_Car.getId())){ - RepairCar repairCar = this.repairCarService.selectById(businessKey); - maintenance=new Maintenance(); - if(repairCar!=null){ - Company company = unitService.getCompById(repairCar.getUnitId()); - maintenance.setCompany(company); - } - maintenance.setProblem("车辆维修审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.O_Stock.getId())){ - OutStockRecord outStockRecord = this.outStockRecordService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(outStockRecord.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("物资领用审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Scetion_Stock.getId())){ - OutStockRecord outStockRecord = this.outStockRecordService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(outStockRecord.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("处级物资领用审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Stock_Check.getId())){ - StockCheck stockCheck = this.stockCheckService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(stockCheck.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("库存盘点审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Maintain_Plan.getId())){ - //之前老的单条计划 + } else if (todoTask.getType().contains(ProcessType.Maintain_Car.getId())) { + MaintainCar maintainCar = this.maintainCarService.selectById(businessKey); + maintenance = new Maintenance(); + if (maintainCar != null) { + Company company = unitService.getCompById(maintainCar.getUnitId()); + maintenance.setCompany(company); + } + maintenance.setProblem("车辆维保审核"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Repair_Car.getId())) { + RepairCar repairCar = this.repairCarService.selectById(businessKey); + maintenance = new Maintenance(); + if (repairCar != null) { + Company company = unitService.getCompById(repairCar.getUnitId()); + maintenance.setCompany(company); + } + maintenance.setProblem("车辆维修审核"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.O_Stock.getId())) { + OutStockRecord outStockRecord = this.outStockRecordService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(outStockRecord.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("物资领用审核"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Scetion_Stock.getId())) { + OutStockRecord outStockRecord = this.outStockRecordService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(outStockRecord.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("处级物资领用审核"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Stock_Check.getId())) { + StockCheck stockCheck = this.stockCheckService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(stockCheck.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("库存盘点审核"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Maintain_Plan.getId())) { + //之前老的单条计划 /*MaintenancePlan maintenancePlan = this.maintenancePlanService.selectById(businessKey); maintenance=new Maintenance(); Company company = unitService.getCompById(maintenancePlan.getBizId()); @@ -766,24 +772,23 @@ public class ActivitiController { maintenance.setStatus(todoTask.getTask().getDescription()); todoTask.setBusiness(maintenance);*/ - //主附表计划 - EquipmentPlan equipmentPlan = this.equipmentPlanService.selectById(businessKey); - maintenance=new Maintenance(); - if(equipmentPlan!=null){ - if(equipmentPlan.getUnitId()!=null){ - Company company = unitService.getCompById(equipmentPlan.getUnitId()); - maintenance.setCompany(company); - } - if(equipmentPlan.getPlanContents()!=null){ + //主附表计划 + EquipmentPlan equipmentPlan = this.equipmentPlanService.selectById(businessKey); + maintenance = new Maintenance(); + if (equipmentPlan != null) { + if (equipmentPlan.getUnitId() != null) { + Company company = unitService.getCompById(equipmentPlan.getUnitId()); + maintenance.setCompany(company); + } + if (equipmentPlan.getPlanContents() != null) { // equipmentPlan.get - maintenance.setProblem(equipmentPlan.getPlanContents()); + maintenance.setProblem(equipmentPlan.getPlanContents()); + } } - } - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - } - else if(todoTask.getType().contains(ProcessType.Repair_Plan.getId())){ - //之前老的单条计划 + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Repair_Plan.getId())) { + //之前老的单条计划 /*EquipmentRepairPlan maintenancePlan = this.equipmentRepairPlanService.selectById(businessKey); maintenance=new Maintenance(); Company company = unitService.getCompById(maintenancePlan.getBizId()); @@ -792,273 +797,273 @@ public class ActivitiController { maintenance.setStatus(todoTask.getTask().getDescription()); todoTask.setBusiness(maintenance);*/ - //主附表计划 - System.out.println(businessKey); - EquipmentPlan equipmentPlan = this.equipmentPlanService.selectById(businessKey); - maintenance=new Maintenance(); - if(equipmentPlan!=null){ - if(equipmentPlan.getUnitId()!=null){ - Company company = unitService.getCompById(equipmentPlan.getUnitId()); - maintenance.setCompany(company); - } - if(equipmentPlan.getPlanContents()!=null){ - maintenance.setProblem(equipmentPlan.getPlanContents()); + //主附表计划 + System.out.println(businessKey); + EquipmentPlan equipmentPlan = this.equipmentPlanService.selectById(businessKey); + maintenance = new Maintenance(); + if (equipmentPlan != null) { + if (equipmentPlan.getUnitId() != null) { + Company company = unitService.getCompById(equipmentPlan.getUnitId()); + maintenance.setCompany(company); + } + if (equipmentPlan.getPlanContents() != null) { + maintenance.setProblem(equipmentPlan.getPlanContents()); + } } - } - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - } - else if(todoTask.getType().contains(ProcessType.Lose_Apply.getId())){ - EquipmentLoseApply loseApply = this.equipmentLoseApplyService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(loseApply.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("设备丢失申请"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Sale_Apply.getId())){ - EquipmentSaleApply saleApply = this.equipmentSaleApplyService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(saleApply.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("设备出售申请"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Scrap_Apply.getId())){ - EquipmentScrapApply scrapApply = this.equipmentScrapApplyService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(scrapApply.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("设备报废申请"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Transfers_Apply.getId())){ - EquipmentTransfersApply transfersApply = this.equipmentTransfersApplyService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(transfersApply.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("设备调拨申请"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Acceptance_Apply.getId())){ - EquipmentAcceptanceApply eaa = equipmentAcceptanceApplyService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(eaa.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("设备验收申请"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.EquipmentStop_Apply.getId())){ - EquipmentStopRecord esr = equipmentStopRecordService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(esr.getBizId()); - maintenance.setCompany(company); - maintenance.setProblem("设备启用/停用申请"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Maintenance_Repair.getId())){ - Repair esr = repairService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(esr.getUnitId()); - maintenance.setCompany(company); - maintenance.setProblem("维修流程"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Programme_Write.getId())){ - OverhaulItemProject esr = overhaulItemProjectService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(esr.getUnitId()); - maintenance.setCompany(company); - maintenance.setProblem("方案编制"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Bidding_Price.getId())){ - OverhaulItemProject esr = overhaulItemProjectService.selectById(businessKey); - maintenance=new Maintenance(); - Company company = unitService.getCompById(esr.getUnitId()); - maintenance.setCompany(company); - maintenance.setProblem("招标比价"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Install_Debug.getId())){ - OverhaulItemProject esr = overhaulItemProjectService.selectById(businessKey); - maintenance=new Maintenance(); - if (esr != null) { - Company company = unitService.getCompById(esr.getUnitId()); - maintenance.setCompany(company); - } - maintenance.setProblem("安装调试"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Project_Check.getId())){ - OverhaulItemProject esr = overhaulItemProjectService.selectById(businessKey); - maintenance=new Maintenance(); - if (esr != null) { - Company company = unitService.getCompById(esr.getUnitId()); - maintenance.setCompany(company); - } - maintenance.setProblem("项目验收"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Routine_Work.getId())){ - RoutineWork routineWork = routineWorkService.selectById(businessKey); - maintenance=new Maintenance(); - if (routineWork != null) { - Company company = unitService.getCompById(routineWork.getUnitId()); - maintenance.setCompany(company); - } - maintenance.setProblem("周期常规工单"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Water_Test.getId())){ - WaterTest waterTest = waterTestService.selectById(businessKey); - maintenance=new Maintenance(); - if (waterTest != null) { - Company company = unitService.getCompById(waterTest.getUnitId()); - maintenance.setCompany(company); - } - maintenance.setProblem("水质化验工单"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if (todoTask.getType().contains(ProcessType.Overhaul.getId())){ - Overhaul overhaul = this.overhaulService.selectById(businessKey); - maintenance=new Maintenance(); - if (overhaul != null) { - Company company = unitService.getCompById(overhaul.getUnitId()); - maintenance.setCompany(company); - } - maintenance.setProblem(overhaul.getProjectDescribe()); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - } - else if(todoTask.getType().contains(ProcessType.Report_Check.getId())){ - RptCreate rptCreate = rptCreateService.selectById(businessKey); - maintenance=new Maintenance(); - if (rptCreate != null) { - Company company = unitService.getCompById(rptCreate.getUnitId()); - maintenance.setCompany(company); - } - maintenance.setProblem("报表审核"); - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Workorder_Repair.getId())){ - WorkorderDetail entity = this.workorderDetailService.selectById(businessKey); - maintenance=new Maintenance(); - if(entity!=null){ - if(entity.getUnitId()!=null){ - Company company = unitService.getCompById(entity.getUnitId()); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Lose_Apply.getId())) { + EquipmentLoseApply loseApply = this.equipmentLoseApplyService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(loseApply.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("设备丢失申请"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Sale_Apply.getId())) { + EquipmentSaleApply saleApply = this.equipmentSaleApplyService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(saleApply.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("设备出售申请"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Scrap_Apply.getId())) { + EquipmentScrapApply scrapApply = this.equipmentScrapApplyService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(scrapApply.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("设备报废申请"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Transfers_Apply.getId())) { + EquipmentTransfersApply transfersApply = this.equipmentTransfersApplyService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(transfersApply.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("设备调拨申请"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Acceptance_Apply.getId())) { + EquipmentAcceptanceApply eaa = equipmentAcceptanceApplyService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(eaa.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("设备验收申请"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.EquipmentStop_Apply.getId())) { + EquipmentStopRecord esr = equipmentStopRecordService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(esr.getBizId()); + maintenance.setCompany(company); + maintenance.setProblem("设备启用/停用申请"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Maintenance_Repair.getId())) { + Repair esr = repairService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(esr.getUnitId()); + maintenance.setCompany(company); + maintenance.setProblem("维修流程"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Programme_Write.getId())) { + OverhaulItemProject esr = overhaulItemProjectService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(esr.getUnitId()); + maintenance.setCompany(company); + maintenance.setProblem("方案编制"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Bidding_Price.getId())) { + OverhaulItemProject esr = overhaulItemProjectService.selectById(businessKey); + maintenance = new Maintenance(); + Company company = unitService.getCompById(esr.getUnitId()); + maintenance.setCompany(company); + maintenance.setProblem("招标比价"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Install_Debug.getId())) { + OverhaulItemProject esr = overhaulItemProjectService.selectById(businessKey); + maintenance = new Maintenance(); + if (esr != null) { + Company company = unitService.getCompById(esr.getUnitId()); maintenance.setCompany(company); - } - if(entity.getFaultDescription()!=null){ - EquipmentCard equipmentCard = equipmentCardService.selectById(entity.getEquipmentId()); - String name = "(" + equipmentCard.getEquipmentname() + ") "; - maintenance.setProblem(name + entity.getFaultDescription()); } - } - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Workorder_Abnormity_Run.getId())){ - //异常上报(运行) - Abnormity entity = this.abnormityService.selectById(businessKey); - maintenance=new Maintenance(); - if(entity!=null){ - if(entity.getBizId()!=null){ - Company company = unitService.getCompById(entity.getBizId()); - maintenance.setCompany(company); - } - if(entity.getAbnormityDescription()!=null){ - maintenance.setProblem(entity.getAbnormityDescription()); - } - } - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Workorder_Abnormity_Equipment.getId())){ - //异常上报(设备) - Abnormity entity = this.abnormityService.selectById(businessKey); - maintenance=new Maintenance(); - if(entity!=null){ - if(entity.getBizId()!=null){ - Company company = unitService.getCompById(entity.getBizId()); - maintenance.setCompany(company); - } - if(entity.getAbnormityDescription()!=null){ - maintenance.setProblem(entity.getAbnormityDescription()); - } - } - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Workorder_Abnormity_Facilities.getId())){ - //异常上报(设施) - Abnormity entity = this.abnormityService.selectById(businessKey); - maintenance=new Maintenance(); - if(entity!=null){ - if(entity.getBizId()!=null){ - Company company = unitService.getCompById(entity.getBizId()); - maintenance.setCompany(company); - } - if(entity.getAbnormityDescription()!=null){ - maintenance.setProblem(entity.getAbnormityDescription()); - } - } - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else if(todoTask.getType().contains(ProcessType.Workorder_Maintain.getId())){ - //主附表计划 - WorkorderDetail entity = this.workorderDetailService.selectById(businessKey); - maintenance=new Maintenance(); - if(entity!=null){ - if(entity.getUnitId()!=null){ - Company company = unitService.getCompById(entity.getUnitId()); + maintenance.setProblem("安装调试"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Project_Check.getId())) { + OverhaulItemProject esr = overhaulItemProjectService.selectById(businessKey); + maintenance = new Maintenance(); + if (esr != null) { + Company company = unitService.getCompById(esr.getUnitId()); maintenance.setCompany(company); - } - if(entity.getSchemeResume()!=null){ - EquipmentCard equipmentCard = equipmentCardService.selectById(entity.getEquipmentId()); - String name = "(" + equipmentCard.getEquipmentname() + ") "; - maintenance.setProblem(name + entity.getSchemeResume()); } - } - maintenance.setStatus(todoTask.getTask().getDescription()); - todoTask.setBusiness(maintenance); - }else { - //通用 - String str = todoTask.getType(); - //截取-之后字符串 - String str1 = str.substring(0, str.indexOf("-")); - String unitId = str.substring(str1.length()+1, str.length()); - JSONObject obj =new JSONObject(); - Company company = unitService.getCompById(unitId); - obj.put("company", company); - //问题描述,默认为节点名称 - obj.put("problem", todoTask.getTask().getName()); - obj.put("status", todoTask.getTask().getDescription()); - todoTask.setBusiness(obj); - } + maintenance.setProblem("项目验收"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Routine_Work.getId())) { + RoutineWork routineWork = routineWorkService.selectById(businessKey); + maintenance = new Maintenance(); + if (routineWork != null) { + Company company = unitService.getCompById(routineWork.getUnitId()); + maintenance.setCompany(company); + } + maintenance.setProblem("周期常规工单"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Water_Test.getId())) { + WaterTest waterTest = waterTestService.selectById(businessKey); + maintenance = new Maintenance(); + if (waterTest != null) { + Company company = unitService.getCompById(waterTest.getUnitId()); + maintenance.setCompany(company); + } + maintenance.setProblem("水质化验工单"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Overhaul.getId())) { + Overhaul overhaul = this.overhaulService.selectById(businessKey); + maintenance = new Maintenance(); + if (overhaul != null) { + Company company = unitService.getCompById(overhaul.getUnitId()); + maintenance.setCompany(company); + } + maintenance.setProblem(overhaul.getProjectDescribe()); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Report_Check.getId())) { + RptCreate rptCreate = rptCreateService.selectById(businessKey); + maintenance = new Maintenance(); + if (rptCreate != null) { + Company company = unitService.getCompById(rptCreate.getUnitId()); + maintenance.setCompany(company); + } + maintenance.setProblem("报表审核"); + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Workorder_Repair.getId())) { + WorkorderDetail entity = this.workorderDetailService.selectById(businessKey); + maintenance = new Maintenance(); + if (entity != null) { + if (entity.getUnitId() != null) { + Company company = unitService.getCompById(entity.getUnitId()); + maintenance.setCompany(company); + } + if (entity.getFaultDescription() != null) { + EquipmentCard equipmentCard = equipmentCardService.selectById(entity.getEquipmentId()); + String name = "(" + equipmentCard.getEquipmentname() + ") "; + maintenance.setProblem(name + entity.getFaultDescription()); + } + } + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Workorder_Abnormity_Run.getId())) { + //异常上报(运行) + Abnormity entity = this.abnormityService.selectById(businessKey); + maintenance = new Maintenance(); + if (entity != null) { + if (entity.getBizId() != null) { + Company company = unitService.getCompById(entity.getBizId()); + maintenance.setCompany(company); + } + if (entity.getAbnormityDescription() != null) { + maintenance.setProblem(entity.getAbnormityDescription()); + } + } + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Workorder_Abnormity_Equipment.getId())) { + //异常上报(设备) + Abnormity entity = this.abnormityService.selectById(businessKey); + maintenance = new Maintenance(); + if (entity != null) { + if (entity.getBizId() != null) { + Company company = unitService.getCompById(entity.getBizId()); + maintenance.setCompany(company); + } + if (entity.getAbnormityDescription() != null) { + maintenance.setProblem(entity.getAbnormityDescription()); + } + } + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Workorder_Abnormity_Facilities.getId())) { + //异常上报(设施) + Abnormity entity = this.abnormityService.selectById(businessKey); + maintenance = new Maintenance(); + if (entity != null) { + if (entity.getBizId() != null) { + Company company = unitService.getCompById(entity.getBizId()); + maintenance.setCompany(company); + } + if (entity.getAbnormityDescription() != null) { + maintenance.setProblem(entity.getAbnormityDescription()); + } + } + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else if (todoTask.getType().contains(ProcessType.Workorder_Maintain.getId())) { + //主附表计划 + WorkorderDetail entity = this.workorderDetailService.selectById(businessKey); + maintenance = new Maintenance(); + if (entity != null) { + if (entity.getUnitId() != null) { + Company company = unitService.getCompById(entity.getUnitId()); + maintenance.setCompany(company); + } + if (entity.getSchemeResume() != null) { + EquipmentCard equipmentCard = equipmentCardService.selectById(entity.getEquipmentId()); + String name = "(" + equipmentCard.getEquipmentname() + ") "; + maintenance.setProblem(name + entity.getSchemeResume()); + } + } + maintenance.setStatus(todoTask.getTask().getDescription()); + todoTask.setBusiness(maintenance); + } else { + //通用 + String str = todoTask.getType(); + //截取-之后字符串 + String str1 = str.substring(0, str.indexOf("-")); + String unitId = str.substring(str1.length() + 1, str.length()); + JSONObject obj = new JSONObject(); + Company company = unitService.getCompById(unitId); + obj.put("company", company); + //问题描述,默认为节点名称 + obj.put("problem", todoTask.getTask().getName()); + obj.put("status", todoTask.getTask().getDescription()); + todoTask.setBusiness(obj); + } - } catch (Exception e) { - logger.error("Failed to process todo task", e); + } catch (Exception e) { + logger.error("Failed to process todo task", e); + } + } } - - } - JSONArray json= this.workflowService.todoTasklistToJsonArray(list); - json = jsonArraySort(json,"task",true); - String result=json.toString(); + JSONArray json = this.workflowService.todoTasklistToJsonArray(list); + json = jsonArraySort(json, "task", true); + String result = json.toString(); // String result="{\"total\":"+list.size()+",\"rows\":"+json+"}"; // System.out.println(result); - model.addAttribute("result",result); + model.addAttribute("result", result); - return new ModelAndView("result"); + return new ModelAndView("result"); } + /** * 对json数组排序, + * * @param jsonArr * @param sortKey 排序关键字 * @param is_desc is_desc-false升序列 is_desc-true降序 (排序字段为字符串) * @return */ - public JSONArray jsonArraySort(JSONArray jsonArr,final String sortKey,final boolean is_desc) { + public JSONArray jsonArraySort(JSONArray jsonArr, final String sortKey, final boolean is_desc) { //存放排序结果json数组 JSONArray sortedJsonArray = new JSONArray(); //用于排序的list @@ -1070,7 +1075,8 @@ public class ActivitiController { //快速排序,重写compare方法,完成按指定字段比较,完成排序 Collections.sort(jsonValues, new Comparator() { //排序字段 - private final String KEY_NAME = sortKey; + private final String KEY_NAME = sortKey; + //重写compare方法 @Override public int compare(JSONObject a, JSONObject b) { @@ -1083,7 +1089,7 @@ public class ActivitiController { logger.error("Failed to get JSON key: {}", KEY_NAME, e); } //是升序还是降序 - if (is_desc){ + if (is_desc) { return -valA.compareTo(valB); } else { return -valB.compareTo(valA); @@ -1099,19 +1105,20 @@ public class ActivitiController { } @RequestMapping("/donetaskList.do") - public String donetaskList(HttpServletRequest request,Model model){ + public String donetaskList(HttpServletRequest request, Model model) { return "/activiti/donetaskList"; } + /* * 已办事项 */ @RequestMapping("/doneworklist.do") - public ModelAndView doneworklist(HttpServletRequest request,Model model){ + public ModelAndView doneworklist(HttpServletRequest request, Model model) { User cu = (User) request.getSession().getAttribute("cu"); String userid = cu.getId(); - String modelKey = request.getParameter("modelKey"); - List ia = workflowService.queryDoneTasks(userid,modelKey); - JSONArray json = this.workflowService.doneTasklistToJsonArray(ia); + String modelKey = request.getParameter("modelKey"); + List ia = workflowService.queryDoneTasks(userid, modelKey); + JSONArray json = this.workflowService.doneTasklistToJsonArray(ia); //String result="{\"total\":"+ia.size()+",\"rows\":"+json+"}"; model.addAttribute("result", json); return new ModelAndView("result"); @@ -1121,21 +1128,22 @@ public class ActivitiController { * 已完成流程 */ @RequestMapping("/finishWorklist.do") - public ModelAndView finishWorklist(HttpServletRequest request,Model model){ + public ModelAndView finishWorklist(HttpServletRequest request, Model model) { User cu = (User) request.getSession().getAttribute("cu"); String userid = cu.getId(); com.alibaba.fastjson.JSONArray json = workflowService.queryFinishTasks(userid); model.addAttribute("result", json); return new ModelAndView("result"); } + /** * 获取生产总流程任务列表 * * @param //leave */ @RequestMapping(value = "getDoneTaskList.do") - public ModelAndView getDoneTaskList(HttpServletRequest request,Model model) { - User cu=(User)request.getSession().getAttribute("cu"); + public ModelAndView getDoneTaskList(HttpServletRequest request, Model model) { + User cu = (User) request.getSession().getAttribute("cu"); String userId = cu.getId(); // int pages = 0; // if(request.getParameter("page")!=null&&!request.getParameter("page").isEmpty()){ @@ -1150,26 +1158,27 @@ public class ActivitiController { // pagesize = 8; // } // PageHelper.startPage(pages, pagesize); - - List list = this.businessUnitAuditService.selectListByWhere("where insuser='"+userId+"'"); + + List list = this.businessUnitAuditService.selectListByWhere("where insuser='" + userId + "'"); // PageInfo page = new PageInfo(list); - JSONArray json=JSONArray.fromObject(list); - String result="{\"total\":"+list.size()+",\"rows\":"+json+"}"; + JSONArray json = JSONArray.fromObject(list); + String result = "{\"total\":" + list.size() + ",\"rows\":" + json + "}"; System.out.println(result); - model.addAttribute("result",result); + model.addAttribute("result", result); return new ModelAndView("result"); } + /** * 获取生产总流程任务列表 * * @param //leave */ @RequestMapping(value = "getProduceTaskList.do") - public ModelAndView getProduceTaskList(HttpServletRequest request,Model model) { - User cu=(User)request.getSession().getAttribute("cu"); + public ModelAndView getProduceTaskList(HttpServletRequest request, Model model) { + User cu = (User) request.getSession().getAttribute("cu"); String userId = cu.getId(); - Map map=null; + Map map = null; /*if(request.getParameter("processInstanceId")!=null && !request.getParameter("processInstanceId").isEmpty()){ if(map==null){ map=new HashMap<>(); @@ -1184,187 +1193,215 @@ public class ActivitiController { map.put("key", "taskCode"); map.put("value", request.getParameter("procedureno")); }*/ - - Page page1 = new Page(PageUtil.PAGE_SIZE); + + Page page1 = new Page(PageUtil.PAGE_SIZE); int[] pageParams = PageUtil.init(page1, request); //筛选附件条件,用与variable筛选 - - List list=workflowService.findTodoTasks(userId,pageParams,map); - - JSONArray json= todoTasklistToJsonArray(list); - - String result="{\"total\":"+list.size()+",\"rows\":"+json+"}"; -// System.out.println(result); - model.addAttribute("result",result); - return new ModelAndView("result"); - } - @RequestMapping("/processInstaceList.do") - public String processInstaceList(HttpServletRequest request,Model model){ - return "/activiti/processInstanceList"; - } - /**获取所有实例类型*/ - @RequestMapping("/getProcessTypes4Combo.do") - public ModelAndView getProcessTypes4Combo(HttpServletRequest request,Model model) { - JSONArray jsonArray=new JSONArray(); - ProcessType[] types=ProcessType.values(); - for (ProcessType item : types) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", item.getId()); - jsonObject.put("text", item.getName()); - jsonArray.add(jsonObject); - } - model.addAttribute("result",jsonArray.toString()); + List list = workflowService.findTodoTasks(userId, pageParams, map); + + JSONArray json = todoTasklistToJsonArray(list); + + String result = "{\"total\":" + list.size() + ",\"rows\":" + json + "}"; +// System.out.println(result); + model.addAttribute("result", result); + return new ModelAndView("result"); - } + } + + @RequestMapping("/processInstaceList.do") + public String processInstaceList(HttpServletRequest request, Model model) { + return "/activiti/processInstanceList"; + } + + /** + * 获取所有实例类型 + */ + @RequestMapping("/getProcessTypes4Combo.do") + public ModelAndView getProcessTypes4Combo(HttpServletRequest request, Model model) { + JSONArray jsonArray = new JSONArray(); + ProcessType[] types = ProcessType.values(); + // Read search term from request parameter (for Select2 AJAX) or session + String term = request.getParameter("term"); + if (term == null || term.isEmpty()) { + Object sessionTerm = request.getSession().getAttribute("term"); + if (sessionTerm != null) { + term = sessionTerm.toString(); + } + } + if (term != null && !term.isEmpty()) { + for (ProcessType item : types) { + if(item.getName().contains(term)){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", item.getId()); + jsonObject.put("text", item.getName()); + jsonArray.add(jsonObject); + } + } + } else { + for (ProcessType item : types) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", item.getId()); + jsonObject.put("text", item.getName()); + jsonArray.add(jsonObject); + } + } + model.addAttribute("result", jsonArray.toString()); + return new ModelAndView("result"); + } + /** * 获取所有生产流程 * * @param //leave */ @RequestMapping(value = "getAllProcessInstaces.do") - public ModelAndView getAllProcessInstaces(HttpServletRequest request,Model model, - @RequestParam(value = "page") Integer page, - @RequestParam(value = "rows") Integer rows, - @RequestParam(value = "sort", required=false) String sort, - @RequestParam(value = "order", required=false) String order) { + public ModelAndView getAllProcessInstaces(HttpServletRequest request, Model model, + @RequestParam(value = "page") Integer page, + @RequestParam(value = "rows") Integer rows, + @RequestParam(value = "sort", required = false) String sort, + @RequestParam(value = "order", required = false) String order) { // String processDefinitionKey = request.getParameter("key"); // processDefinitionKey="System_Produce"; - User cu=(User)request.getSession().getAttribute("cu"); + User cu = (User) request.getSession().getAttribute("cu"); Page page_activiti = new Page(); - int[] pageParams = {(page-1)*rows,rows};//PageUtil.init(page1, request); - workflowService.findRunningProcessInstaces(page_activiti,pageParams,null); - List list=page_activiti.getResult(); - - JSONArray json= workflowService.todoTasklistToJsonArray(list); - - String result="{\"total\":"+list.size()+",\"rows\":"+json+"}"; -// System.out.println(result); - model.addAttribute("result",result); + int[] pageParams = {(page - 1) * rows, rows};//PageUtil.init(page1, request); + workflowService.findRunningProcessInstaces(page_activiti, pageParams, null); + List list = page_activiti.getResult(); - return new ModelAndView("result"); + JSONArray json = workflowService.todoTasklistToJsonArray(list); + + String result = "{\"total\":" + list.size() + ",\"rows\":" + json + "}"; +// System.out.println(result); + model.addAttribute("result", result); + + return new ModelAndView("result"); } - private JSONArray todoTasklistToJsonArray(List list){ - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - JSONArray json= new JSONArray(); - if (list!=null) { - for(int i=0;i list = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).orderByProcessDefinitionVersion().desc().list(); - //删除部署的流程,级联删除流程实例 - repositoryService.deleteDeployment(deploymentId, true); - result=1; - } catch (Exception e) { - logger.error("Failed to delete deployment: {}", deploymentId, e); - result =0; - } - - model.addAttribute("result", result); - return "result"; + public String delete(HttpServletRequest request, Model model, + @RequestParam("deploymentId") String deploymentId) { + int result = 0; + try { + + //清除processConfig(工序、物料等关系)数据,清除processConfig_em(工序、设备产能等关系)数据 + List list = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).orderByProcessDefinitionVersion().desc().list(); + //删除部署的流程,级联删除流程实例 + repositoryService.deleteDeployment(deploymentId, true); + result = 1; + } catch (Exception e) { + logger.error("Failed to delete deployment: {}", deploymentId, e); + result = 0; + } + + model.addAttribute("result", result); + return "result"; } - /**删除流程*/ + + /** + * 删除流程 + */ @RequestMapping(value = "/process/delProcessInstance") - public String delProcessInstance(HttpServletRequest request,Model model, - @RequestParam("id") String processInstanceId) { - int result =0; - try { - - runtimeService.deleteProcessInstance(processInstanceId,""); - result=1; - } catch (Exception e) { - logger.error("Failed to delete process instance: {}", processInstanceId, e); - result =0; - } - - model.addAttribute("result", result); - return "result"; + public String delProcessInstance(HttpServletRequest request, Model model, + @RequestParam("id") String processInstanceId) { + int result = 0; + try { + + runtimeService.deleteProcessInstance(processInstanceId, ""); + result = 1; + } catch (Exception e) { + logger.error("Failed to delete process instance: {}", processInstanceId, e); + result = 0; + } + + model.addAttribute("result", result); + return "result"; } + /** * 输出跟踪流程信息 * @@ -1482,17 +1523,18 @@ public class ActivitiController { */ @RequestMapping(value = "process/trace") @ResponseBody - public List> traceProcess(HttpServletRequest request,Model model){ - String processInstanceId = request.getParameter("pid"); - String taskId = request.getParameter("taskId"); - List> activityInfos= new ArrayList<>(); - try{ - activityInfos = traceService.traceProcess(processInstanceId,taskId); - }catch(Exception e){ - logger.error("Failed to trace process: {}", processInstanceId, e); + public List> traceProcess(HttpServletRequest request, Model model) { + String processInstanceId = request.getParameter("pid"); + String taskId = request.getParameter("taskId"); + List> activityInfos = new ArrayList<>(); + try { + activityInfos = traceService.traceProcess(processInstanceId, taskId); + } catch (Exception e) { + logger.error("Failed to trace process: {}", processInstanceId, e); } return activityInfos; } + /** * 输出定义流程信息 * @@ -1501,17 +1543,17 @@ public class ActivitiController { * @throws Exception */ @RequestMapping(value = "processDefinition/trace") - public String traceProcessDefinition(HttpServletRequest request,Model model){ - String processDefinitionId = request.getParameter("pdid"); - List> activityInfos= new ArrayList<>(); - try{ - activityInfos = traceService.traceProcessByDefinitionId(processDefinitionId); - }catch(Exception e){ - logger.error("Failed to trace process definition: {}", processDefinitionId, e); + public String traceProcessDefinition(HttpServletRequest request, Model model) { + String processDefinitionId = request.getParameter("pdid"); + List> activityInfos = new ArrayList<>(); + try { + activityInfos = traceService.traceProcessByDefinitionId(processDefinitionId); + } catch (Exception e) { + logger.error("Failed to trace process definition: {}", processDefinitionId, e); } return "/activiti/processDefinitionTrace"; } - + /** * 读取带跟踪的图片 */ @@ -1579,11 +1621,11 @@ public class ActivitiController { */ @RequestMapping(value = "/deployDiagrams.do") public String deployDiagrams(HttpServletRequest request, Model model, - @RequestParam(value = "folderName", required = false) String folderName) { + @RequestParam(value = "folderName", required = false) String folderName) { int successCount = 0; int failCount = 0; JSONArray resultArray = new JSONArray(); - + try { // 获取diagrams目录路径 String diagramsPath = request.getSession().getServletContext() @@ -1592,13 +1634,13 @@ public class ActivitiController { diagramsPath = this.getClass().getClassLoader() .getResource("diagrams").getPath(); } - + File diagramsDir = new File(diagramsPath); if (!diagramsDir.exists() || !diagramsDir.isDirectory()) { model.addAttribute("result", "{\"res\":\"0\",\"msg\":\"diagrams目录不存在\"}"); return "result"; } - + // 获取需要部署的文件夹列表 List targetDirs = new ArrayList(); if (folderName != null && !folderName.isEmpty()) { @@ -1613,28 +1655,28 @@ public class ActivitiController { targetDirs.addAll(java.util.Arrays.asList(subDirs)); } } - + // 遍历部署每个文件夹下的BPMN文件 for (File dir : targetDirs) { - File[] bpmnFiles = dir.listFiles((d, name) -> + File[] bpmnFiles = dir.listFiles((d, name) -> name.endsWith(".bpmn") || name.endsWith(".bpmn20.xml")); - + if (bpmnFiles == null || bpmnFiles.length == 0) { continue; } - + for (File bpmnFile : bpmnFiles) { try { String fileName = bpmnFile.getName(); FileInputStream fis = new FileInputStream(bpmnFile); - + Deployment deployment = repositoryService.createDeployment() .name(fileName.substring(0, fileName.lastIndexOf("."))) .addInputStream(fileName, fis) .deploy(); - + fis.close(); - + JSONObject deployResult = new JSONObject(); deployResult.put("fileName", fileName); deployResult.put("deploymentId", deployment.getId()); @@ -1643,7 +1685,7 @@ public class ActivitiController { .format(deployment.getDeploymentTime())); resultArray.add(deployResult); successCount++; - + logger.info("流程部署成功: {} -> {}", fileName, deployment.getId()); } catch (Exception e) { failCount++; @@ -1651,14 +1693,14 @@ public class ActivitiController { } } } - + } catch (Exception e) { logger.error("部署diagrams文件失败", e); model.addAttribute("result", "{\"res\":\"0\",\"msg\":\"" + e.getMessage() + "\"}"); return "result"; } - - String result = "{\"res\":\"1\",\"success\":" + successCount + ",\"fail\":" + failCount + + String result = "{\"res\":\"1\",\"success\":" + successCount + ",\"fail\":" + failCount + ",\"deployments\":" + resultArray.toString() + "}"; model.addAttribute("result", result); return "result"; @@ -1670,19 +1712,19 @@ public class ActivitiController { @RequestMapping(value = "/getDeployableBpmnFiles.do") public String getDeployableBpmnFiles(HttpServletRequest request, Model model) { JSONArray filesArray = new JSONArray(); - + try { String diagramsPath = this.getClass().getClassLoader() .getResource("diagrams").getPath(); File diagramsDir = new File(diagramsPath); - + if (diagramsDir.exists() && diagramsDir.isDirectory()) { File[] subDirs = diagramsDir.listFiles(File::isDirectory); if (subDirs != null) { for (File dir : subDirs) { - File[] bpmnFiles = dir.listFiles((d, name) -> + File[] bpmnFiles = dir.listFiles((d, name) -> name.endsWith(".bpmn") || name.endsWith(".bpmn20.xml")); - + if (bpmnFiles != null) { for (File bpmnFile : bpmnFiles) { JSONObject fileInfo = new JSONObject(); @@ -1698,7 +1740,7 @@ public class ActivitiController { } catch (Exception e) { logger.error("获取BPMN文件列表失败", e); } - + model.addAttribute("result", filesArray.toString()); return "result"; } @@ -1769,7 +1811,6 @@ public class ActivitiController { return result; }*/ - private Map packageTaskInfo(SimpleDateFormat sdf, Task task, ProcessDefinition processDefinition) { Map singleTask = new HashMap(); singleTask.put("id", task.getId()); @@ -1794,153 +1835,159 @@ public class ActivitiController { * 挂起、激活流程定义 */ @RequestMapping(value = "processdefinition/update.do") - public String updateDefinitionState(HttpServletRequest request,Model model, - @RequestParam(value = "state") String state, - @RequestParam(value = "processDefinitionId") String processDefinitionId) { - int result =0; + public String updateDefinitionState(HttpServletRequest request, Model model, + @RequestParam(value = "state") String state, + @RequestParam(value = "processDefinitionId") String processDefinitionId) { + int result = 0; if (state.equals("active")) { repositoryService.activateProcessDefinitionById(processDefinitionId, true, null); - result=1; + result = 1; } else if (state.equals("suspend")) { repositoryService.suspendProcessDefinitionById(processDefinitionId, true, null); - result=1; + result = 1; } model.addAttribute("result", result); - return "result"; + return "result"; } + /** * 挂起、激活流程实例 */ @RequestMapping(value = "processinstance/update.do") - public String updateInstanceState(HttpServletRequest request,Model model, - @RequestParam(value = "state") String state, - @RequestParam(value = "processInstanceId") String processInstanceId) { - int result =0; + public String updateInstanceState(HttpServletRequest request, Model model, + @RequestParam(value = "state") String state, + @RequestParam(value = "processInstanceId") String processInstanceId) { + int result = 0; if (state.equals("active")) { runtimeService.activateProcessInstanceById(processInstanceId); - result=1; + result = 1; } else if (state.equals("suspend")) { runtimeService.suspendProcessInstanceById(processInstanceId); - result=1; + result = 1; } model.addAttribute("result", result); - return "result"; + return "result"; } - - + + /** * 签收任务 */ @RequestMapping(value = "task/claim.do") - public String claim(HttpServletRequest request,Model model, - @RequestParam(value="taskId") String taskId) { - User cu= (User)request.getSession().getAttribute("cu"); - String userId = cu.getId(); - int result=0; - try{ - identityService.setAuthenticatedUserId(userId); - taskService.claim(taskId, userId); - result=1; - }catch(Exception e){ - logger.error("Failed to claim task: {}", taskId, e); - } - + public String claim(HttpServletRequest request, Model model, + @RequestParam(value = "taskId") String taskId) { + User cu = (User) request.getSession().getAttribute("cu"); + String userId = cu.getId(); + int result = 0; + try { + identityService.setAuthenticatedUserId(userId); + taskService.claim(taskId, userId); + result = 1; + } catch (Exception e) { + logger.error("Failed to claim task: {}", taskId, e); + } + model.addAttribute("result", result); - return "result"; + return "result"; } + /** * 批量签收任务 */ @RequestMapping(value = "task/batchSignIn.do") - public String batchSignIn(HttpServletRequest request,Model model, - @RequestParam(value="taskIds") String taskIds) { - User cu= (User)request.getSession().getAttribute("cu"); + public String batchSignIn(HttpServletRequest request, Model model, + @RequestParam(value = "taskIds") String taskIds) { + User cu = (User) request.getSession().getAttribute("cu"); String userId = cu.getId(); - int result=0; - if(taskIds!=null && !taskIds.isEmpty()){ - String[] taskIdArray = taskIds.split(","); - identityService.setAuthenticatedUserId(userId); - String taskId = ""; - for(int i=0;i list = repositoryService.createNativeModelQuery().sql(sql).list(); - if(list!=null && list.size()>0){ - sqlStr = " and model_id ='"+list.get(0).getId()+"' "; + if (list != null && list.size() > 0) { + sqlStr = " and model_id ='" + list.get(0).getId() + "' "; + } + } + List mnjbList = this.jobService.selectModelNodeJobListByWhere(" where resource_id='" + resourceId + "'" + sqlStr); + List jobIds = new ArrayList(); + for (ModelNodeJob item : mnjbList) { + jobIds.add(item.getJobId()); + } + JSONArray json = new JSONArray(); + List jobList = new ArrayList(); + for (String item : jobIds) { + List jList = this.jobService.selectListByWhere(" where id='" + item + "'"); + if (jList != null && jList.size() > 0) { + for (User u : jList.get(0).getUser()) { + JSONObject obj = new JSONObject(); + obj = obj.fromObject(u); + json.add(obj); + } } } - List mnjbList = this.jobService.selectModelNodeJobListByWhere(" where resource_id='"+resourceId+"'" +sqlStr); - List jobIds = new ArrayList(); - for (ModelNodeJob item:mnjbList){ - jobIds.add(item.getJobId()); - } - JSONArray json = new JSONArray(); - List jobList = new ArrayList(); - for (String item:jobIds){ - List jList = this.jobService.selectListByWhere(" where id='"+item+"'"); - if(jList!= null &&jList.size()>0){ - for(User u:jList.get(0).getUser()){ - JSONObject obj = new JSONObject(); - obj = obj.fromObject(u); - json.add(obj); - } - } - } model.addAttribute("result", json); - return "result"; + return "result"; } - + /** * 获得流程节点关联职位 + * * @param request * @param model * @param resourceId * @return */ @RequestMapping(value = "getTargetJobs4Node.do") - public String getTargetJobs4Node(HttpServletRequest request,Model model, - @RequestParam(value = "resourceId") String resourceId, - @RequestParam(value = "modelKEY") String modelKEY) { + public String getTargetJobs4Node(HttpServletRequest request, Model model, + @RequestParam(value = "resourceId") String resourceId, + @RequestParam(value = "modelKEY") String modelKEY) { String sqlStr = ""; - if(modelKEY!=null && !modelKEY.equals("")){ - String sql = "select * from [ACT_RE_MODEL] where KEY_='"+modelKEY+"' "; + if (modelKEY != null && !modelKEY.equals("")) { + String sql = "select * from [ACT_RE_MODEL] where KEY_='" + modelKEY + "' "; List list = repositoryService.createNativeModelQuery().sql(sql).list(); - if(list!=null && list.size()>0){ - sqlStr = " and model_id ='"+list.get(0).getId()+"' "; + if (list != null && list.size() > 0) { + sqlStr = " and model_id ='" + list.get(0).getId() + "' "; } } - List mnjbList = this.jobService.selectModelNodeJobListByWhere(" where resource_id='"+resourceId+"'" +sqlStr); - - JSONArray json = new JSONArray(); - json = JSONArray.fromObject(mnjbList); + List mnjbList = this.jobService.selectModelNodeJobListByWhere(" where resource_id='" + resourceId + "'" + sqlStr); + + JSONArray json = new JSONArray(); + json = JSONArray.fromObject(mnjbList); model.addAttribute("result", json); - return "result"; + return "result"; } + /** * 导出图片文件到硬盘 * diff --git a/src/main/webapp/jsp/business/businessUnitList.jsp b/src/main/webapp/jsp/business/businessUnitList.jsp index d3c37868..3dd84895 100644 --- a/src/main/webapp/jsp/business/businessUnitList.jsp +++ b/src/main/webapp/jsp/business/businessUnitList.jsp @@ -110,6 +110,11 @@ url: ext.contextPath +"/activiti/workflow/getProcessTypes4Combo.do", dataType: 'json', delay: 250, + data: function (params) { + return { + term: params.term + }; + }, processResults: function (data) { return { results: data @@ -123,8 +128,8 @@ language: "zh-CN", minimumInputLength: 0, minimumResultsForSearch: 10, - formatResult: function formatRepo(repo){return repo.text;}, - formatSelection: function formatRepoSelection(repo){return repo.text;} + templateResult: function formatRepo(repo){return repo.text;}, + templateSelection: function formatRepoSelection(repo){return repo.text;} }); fixSelect2ToTool("search_processType"); $("#table").bootstrapTable({ diff --git a/src/main/webapp/jsp/safety/EducationBuilderView.jsp b/src/main/webapp/jsp/safety/EducationBuilderView.jsp index 23fe5b59..99845b57 100644 --- a/src/main/webapp/jsp/safety/EducationBuilderView.jsp +++ b/src/main/webapp/jsp/safety/EducationBuilderView.jsp @@ -17,17 +17,11 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD display: flex; padding-left: 50px; } - - /*.layout{*/ - / display: flex;*/ - / padding-left: 15px;*/ - /*}*/ .form-horizontal { padding-top: 20px; padding-left: 60px; } - .right { margin-left: 50px; } diff --git a/src/main/webapp/jsp/safety/EducationInsiderView.jsp b/src/main/webapp/jsp/safety/EducationInsiderView.jsp index c3bf235b..e3ce16e8 100644 --- a/src/main/webapp/jsp/safety/EducationInsiderView.jsp +++ b/src/main/webapp/jsp/safety/EducationInsiderView.jsp @@ -50,10 +50,10 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD formatResult: function formatRepo(repo) { return repo.text; }, // 函数用来渲染结果 + formatSelection: function formatRepoSelection(repo) { return repo.text; } // 函数用于呈现当前的选择 }); - }); $(".select2-selection--single").css({'height': '30px', 'paddingTop': '4px'}); select_3.val('${bean.educationType}').trigger("change");