diff --git a/src/main/java/com/sipai/controller/activiti/ModelController.java b/src/main/java/com/sipai/controller/activiti/ModelController.java index feaa7066..f6ca5cf2 100644 --- a/src/main/java/com/sipai/controller/activiti/ModelController.java +++ b/src/main/java/com/sipai/controller/activiti/ModelController.java @@ -63,6 +63,7 @@ import java.util.Locale; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; + /** * 流程模型控制器 * @@ -87,177 +88,180 @@ public class ModelController { @Resource private UnitService unitService; @Resource - private JobService jobService; - @Resource - protected TaskService taskService; - + private JobService jobService; + @Resource + protected TaskService taskService; + @RequestMapping("/showModelList.do") - public String showModelList(HttpServletRequest request,Model model) { - return "/activiti/modelList"; - } + public String showModelList(HttpServletRequest request, Model model) { + return "/activiti/modelList"; + } + @RequestMapping("/showProcessTechnicsList.do") - public String showProcessTechnicsList(HttpServletRequest request,Model model) { - return "/activiti/processTechnicsList"; - } + public String showProcessTechnicsList(HttpServletRequest request, Model model) { + return "/activiti/processTechnicsList"; + } + /* * 模型副本 * */ @RequestMapping(value = "copycreat.do") - public ModelAndView copycreat(HttpServletRequest request, - HttpServletResponse response,Model model - ) throws IOException { - int result =0; - User cu = (User)request.getSession().getAttribute("cu"); - String modelid = request.getParameter("id"); - org.activiti.engine.repository.Model modelData = repositoryService.getModel(modelid); + public ModelAndView copycreat(HttpServletRequest request, + HttpServletResponse response, Model model + ) throws IOException { + int result = 0; + User cu = (User) request.getSession().getAttribute("cu"); + String modelid = request.getParameter("id"); + org.activiti.engine.repository.Model modelData = repositoryService.getModel(modelid); ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId())); byte[] bpmnBytes = null; try { - - bpmnBytes=modelNode.toString().getBytes("utf-8"); + + bpmnBytes = modelNode.toString().getBytes("utf-8"); } catch (Exception e) { } - + org.activiti.engine.repository.Model modelData_new = repositoryService.newModel(); ObjectMapper objectMapper = new ObjectMapper(); ObjectNode modelObjectNode = objectMapper.createObjectNode(); - modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME,modelData.getName()+"(副本)" ); + modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, modelData.getName() + "(副本)"); modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); - modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, modelData.getName()+"(副本)"); + modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, modelData.getName() + "(副本)"); modelData_new.setMetaInfo(modelObjectNode.toString()); - modelData_new.setName(modelData.getName()+"(副本)"); + modelData_new.setName(modelData.getName() + "(副本)"); modelData_new.setKey(modelData.getKey()); - - repositoryService.saveModel(modelData_new); - repositoryService.addModelEditorSource(modelData_new.getId(),bpmnBytes ); - - result =1; - model.addAttribute("result",result); - return new ModelAndView("result"); - } - @RequestMapping("/doimportExcel.do") - public String doimportTechnics(HttpServletRequest request,Model model){ - return "/activiti/importExcel4Model"; - } - - @RequestMapping(value = "saveImportModel.do") - public ModelAndView saveImportActiviti(@RequestParam MultipartFile[] file, HttpServletRequest request, - HttpServletResponse response,Model model) throws IOException { - int result=0; - User cu = (User)request.getSession().getAttribute("cu"); - //要存入的实际地址 - String realPath = request.getSession().getServletContext().getRealPath("/"); - String pjName = request.getContextPath().substring(1, request.getContextPath().length()); - realPath = realPath.replace(pjName,"Temp"); - //String technicsname=""; - List taskModels= new ArrayList<>();//(technicsname,ptList); - - String modelid =processModelService.autoImport(taskModels); - - List unmainProcedure =new ArrayList<>();//存储未匹配预设工序的工序名 - if(modelid!=null && !modelid.isEmpty()){ - try{ - SimpleDateFormat dateFormat = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss.SSS", Locale.SIMPLIFIED_CHINESE); - result=1; - }catch(Exception e){ - e.printStackTrace(); - repositoryService.deleteModel(modelid);//管控信息保存失败时,删除模型 - } - - } - String res_str=""; - for (String str : unmainProcedure) { - if(!res_str.isEmpty()){ - res_str+=","; - } - str=str.replace(" ", "").replace("\n", ""); - res_str+=str; - } - model.addAttribute("result","{\"res\":\""+result+"\",\"unmatch\":\""+res_str+"\"}"); - return new ModelAndView("result"); - } - -/* //导入文档最后一个sheet - public String importByExcel(String realPath, MultipartFile[] file,List ptList) throws IOException { - String technicsname=""; - //上传文件的原名(即上传前的文件名字) - String originalFilename = null; - //服务器路径 - String serverPath = null; - for(MultipartFile myfile:file){ - if(myfile.isEmpty()){ - return null; - }else{ - originalFilename = myfile.getOriginalFilename(); - //兼容linux路径 - serverPath = realPath+System.getProperty("file.separator")+CommUtil.getUUID()+originalFilename; - FileUtil.saveFile(myfile.getInputStream(), serverPath); - System.out.println("-->>临时文件上传完成!"); - - FileInputStream is = new FileInputStream(serverPath); - try { - POIFSFileSystem fs = new POIFSFileSystem(is); - HSSFWorkbook wb = new HSSFWorkbook(fs); - HSSFSheet sheet = wb.getSheetAt(wb.getNumberOfSheets()-1); //根据最后一个sheet获取工艺信息 - // 得到总行数 - int rowNum = sheet.getPhysicalNumberOfRows(); - HSSFRow row = sheet.getRow(0); - //以导入时列名长度为需要导入数据的长度,超过部分程序将忽略 - int colNum = row.getPhysicalNumberOfCells(); - // 正文内容应该从第3行开始,第一行为表头的标题 - boolean startflag=false; - - for (int i = 1; i < rowNum; i++) { - //Excel行数据 - row = sheet.getRow(i); - if(!startflag && row.getCell(0)!=null && row.getCell(0).toString().equals(CommString.Flag_Technics_Name)){ - technicsname =getTechnicsName(sheet,i); - } - if(!startflag && row.getCell(0)!=null && row.getCell(0).toString().equals("")){ - startflag=true; - continue; - } - - if(startflag){ - ProcessTechnics newtemp=getTechnicesFromCell(sheet,i); - ptList.add(newtemp); - } - - - } - //导入动作完成后,删除导入文件的临时文件 - FileUtil.deleteFile(serverPath); - System.out.println("<<--临时文件已删除!"); - //关闭流文件 - is.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + repositoryService.saveModel(modelData_new); + repositoryService.addModelEditorSource(modelData_new.getId(), bpmnBytes); + + result = 1; + model.addAttribute("result", result); + return new ModelAndView("result"); + } + + @RequestMapping("/doimportExcel.do") + public String doimportTechnics(HttpServletRequest request, Model model) { + return "/activiti/importExcel4Model"; + } + + + @RequestMapping(value = "saveImportModel.do") + public ModelAndView saveImportActiviti(@RequestParam MultipartFile[] file, HttpServletRequest request, + HttpServletResponse response, Model model) throws IOException { + int result = 0; + User cu = (User) request.getSession().getAttribute("cu"); + //要存入的实际地址 + String realPath = request.getSession().getServletContext().getRealPath("/"); + String pjName = request.getContextPath().substring(1, request.getContextPath().length()); + realPath = realPath.replace(pjName, "Temp"); + //String technicsname=""; + List taskModels = new ArrayList<>();//(technicsname,ptList); + + String modelid = processModelService.autoImport(taskModels); + + List unmainProcedure = new ArrayList<>();//存储未匹配预设工序的工序名 + if (modelid != null && !modelid.isEmpty()) { + try { + SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss.SSS", Locale.SIMPLIFIED_CHINESE); + result = 1; + } catch (Exception e) { + e.printStackTrace(); + repositoryService.deleteModel(modelid);//管控信息保存失败时,删除模型 + } + } - - return technicsname; - } -*/ //根据导入excel获取工艺名称,即产品编号 - private String getTechnicsName(Sheet sheet ,int row_NO){ - String res=""; - Row row = sheet.getRow(row_NO); - for(int i=0;i ptList) throws IOException { + String technicsname=""; + //上传文件的原名(即上传前的文件名字) + String originalFilename = null; + //服务器路径 + String serverPath = null; + for(MultipartFile myfile:file){ + if(myfile.isEmpty()){ + return null; + }else{ + originalFilename = myfile.getOriginalFilename(); + //兼容linux路径 + serverPath = realPath+System.getProperty("file.separator")+CommUtil.getUUID()+originalFilename; + FileUtil.saveFile(myfile.getInputStream(), serverPath); + System.out.println("-->>临时文件上传完成!"); + + FileInputStream is = new FileInputStream(serverPath); + try { + POIFSFileSystem fs = new POIFSFileSystem(is); + HSSFWorkbook wb = new HSSFWorkbook(fs); + HSSFSheet sheet = wb.getSheetAt(wb.getNumberOfSheets()-1); //根据最后一个sheet获取工艺信息 + // 得到总行数 + int rowNum = sheet.getPhysicalNumberOfRows(); + HSSFRow row = sheet.getRow(0); + //以导入时列名长度为需要导入数据的长度,超过部分程序将忽略 + int colNum = row.getPhysicalNumberOfCells(); + // 正文内容应该从第3行开始,第一行为表头的标题 + boolean startflag=false; + + for (int i = 1; i < rowNum; i++) { + //Excel行数据 + row = sheet.getRow(i); + if(!startflag && row.getCell(0)!=null && row.getCell(0).toString().equals(CommString.Flag_Technics_Name)){ + technicsname =getTechnicsName(sheet,i); + } + if(!startflag && row.getCell(0)!=null && row.getCell(0).toString().equals("")){ + startflag=true; + continue; + } + + if(startflag){ + ProcessTechnics newtemp=getTechnicesFromCell(sheet,i); + ptList.add(newtemp); + } + + + } + //导入动作完成后,删除导入文件的临时文件 + FileUtil.deleteFile(serverPath); + System.out.println("<<--临时文件已删除!"); + //关闭流文件 + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + return technicsname; + } + */ //根据导入excel获取工艺名称,即产品编号 + private String getTechnicsName(Sheet sheet, int row_NO) { + String res = ""; + Row row = sheet.getRow(row_NO); + for (int i = 0; i < row.getLastCellNum(); i++) { + String cellcontent = getMergedRegionValue(sheet, row_NO, i); + if (cellcontent != null && cellcontent.equals(CommString.Flag_Technics_Name)) { + continue; + } else { + res = cellcontent; + break; + + } + } + return res; + } + /** + * excel导入的工序转为taskmodel*/ /*private List getTaskModels(String technicsname,List processTechnics){ //查询主工序。去重 List pt4TaskModel =new ArrayList<>(); @@ -415,74 +419,79 @@ public class ModelController { return processTechnics; }*/ - /* - * 获取主工序code - * */ - /** - * 获取合并单元格的值 - * @param sheet - * @param row - * @param column - * @return - */ - public String getMergedRegionValue(Sheet sheet ,int row , int column){ - int sheetMergeCount = sheet.getNumMergedRegions(); - - for(int i = 0 ; i < sheetMergeCount ; i++){ - CellRangeAddress ca = sheet.getMergedRegion(i); - int firstColumn = ca.getFirstColumn(); - int lastColumn = ca.getLastColumn(); - int firstRow = ca.getFirstRow(); - int lastRow = ca.getLastRow(); - - if(row >= firstRow && row <= lastRow){ - - if(column >= firstColumn && column <= lastColumn){ - Row fRow = sheet.getRow(firstRow); - Cell fCell = fRow.getCell(firstColumn); - - return getCellValue(fCell) ; - } - } - } - - return null ; - } - /** - * 获取单元格的值 - * @param cell - * @return - */ - public String getCellValue(Cell cell){ - - if(cell == null) { - return ""; - } - - if(cell.getCellType() == CellType.STRING){ - - return cell.getStringCellValue(); - - }else if(cell.getCellType() == CellType.BOOLEAN){ - - return String.valueOf(cell.getBooleanCellValue()); - - }else if(cell.getCellType() == CellType.FORMULA){ - - return cell.getCellFormula() ; - - }else if(cell.getCellType() == CellType.NUMERIC){ - - return String.valueOf(cell.getNumericCellValue()); - - } - - return ""; - } - /* - * 将存在的值赋给目标变量 - * */ - public static void replace(Object source, Object dest) throws Exception { + /* + * 获取主工序code + * */ + + /** + * 获取合并单元格的值 + * + * @param sheet + * @param row + * @param column + * @return + */ + public String getMergedRegionValue(Sheet sheet, int row, int column) { + int sheetMergeCount = sheet.getNumMergedRegions(); + + for (int i = 0; i < sheetMergeCount; i++) { + CellRangeAddress ca = sheet.getMergedRegion(i); + int firstColumn = ca.getFirstColumn(); + int lastColumn = ca.getLastColumn(); + int firstRow = ca.getFirstRow(); + int lastRow = ca.getLastRow(); + + if (row >= firstRow && row <= lastRow) { + + if (column >= firstColumn && column <= lastColumn) { + Row fRow = sheet.getRow(firstRow); + Cell fCell = fRow.getCell(firstColumn); + + return getCellValue(fCell); + } + } + } + + return null; + } + + /** + * 获取单元格的值 + * + * @param cell + * @return + */ + public String getCellValue(Cell cell) { + + if (cell == null) { + return ""; + } + + if (cell.getCellType() == CellType.STRING) { + + return cell.getStringCellValue(); + + } else if (cell.getCellType() == CellType.BOOLEAN) { + + return String.valueOf(cell.getBooleanCellValue()); + + } else if (cell.getCellType() == CellType.FORMULA) { + + return cell.getCellFormula(); + + } else if (cell.getCellType() == CellType.NUMERIC) { + + return String.valueOf(cell.getNumericCellValue()); + + } + + return ""; + } + + /* + * 将存在的值赋给目标变量 + * */ + public static void replace(Object source, Object dest) throws Exception { // 获取属性 BeanInfo sourceBean = Introspector.getBeanInfo(source.getClass(), java.lang.Object.class); PropertyDescriptor[] sourceProperty = sourceBean.getPropertyDescriptors(); @@ -504,47 +513,48 @@ public class ModelController { throw new Exception("属性复制失败:" + e.getMessage()); } } + /** * 流程定义列表 * * @return */ @RequestMapping(value = "/getModelList.do") - public ModelAndView getModelList(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; - } - String wherestr = " where 1=1 "; - if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){ - wherestr += " and NAME_ like '%"+request.getParameter("search_name")+"%' "; - } - if(request.getParameter("search_code")!=null && !request.getParameter("search_code").isEmpty()){ - wherestr += " and KEY_ like '%"+request.getParameter("search_code")+"%' "; - }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 0) { + startNum = (page - 1) * rows; + } + String wherestr = " where 1=1 "; + if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) { + wherestr += " and NAME_ like '%" + request.getParameter("search_name") + "%' "; + } + if (request.getParameter("search_code") != null && !request.getParameter("search_code").isEmpty()) { + wherestr += " and KEY_ like '%" + request.getParameter("search_code") + "%' "; + } 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.size(); i++) { + wherestr += " and KEY_ like '%" + companies.get(0).getId() + "%' "; + } + } + + } + } + String sql = "select * from [ACT_RE_MODEL]" + wherestr; + //page = 2; // List list = repositoryService.createModelQuery().orderByCreateTime().desc().listPage(startNum, rows); - List list = repositoryService.createNativeModelQuery().sql(sql).list(); + List list = repositoryService.createNativeModelQuery().sql(sql).list(); /*Iterator it = list.iterator(); if(!search_name.isEmpty()){ it = list.iterator(); @@ -565,13 +575,12 @@ public class ModelController { } }*/ PageInfo pi = new PageInfo(list); - JSONArray json=JSONArray.fromObject(list); - String result="{\"total\":"+list.size()+",\"rows\":"+json+"}"; - model.addAttribute("result",result); + JSONArray json = JSONArray.fromObject(list); + String result = "{\"total\":" + list.size() + ",\"rows\":" + json + "}"; + model.addAttribute("result", result); - return new ModelAndView("result"); + return new ModelAndView("result"); - // page.setTotalCount(processDefinitionQuery.count()); // page.setResult(objects); @@ -579,327 +588,342 @@ public class ModelController { // // return mav; } - /** - * 流程定义列表 - * - * @return - */ - @RequestMapping(value = "/getModelAll.do") - public ModelAndView getModelAll(HttpServletRequest request,Model model) { - User cu=(User)request.getSession().getAttribute("cu"); - String userId = cu.getId(); - String wherestr = " where 1=1 "; - if(request.getParameter("bizid")!=null && !request.getParameter("bizid").isEmpty()){ - wherestr += " and KEY_ like '%"+request.getParameter("bizid")+"%' "; - } - String sql = "select * from [ACT_RE_MODEL]"+wherestr; - List list = repositoryService.createNativeModelQuery().sql(sql).list(); - JSONArray json=JSONArray.fromObject(list); - JSONArray rows = new JSONArray(); - if(json!=null && json.size()>0){ - for(int i=0;i taskList = taskQuery.list(); - int taskNum = taskList.size(); - job.put("taskNum",taskNum); - rows.add(job); - } - } - String result="{\"total\":"+list.size()+",\"rows\":"+rows+"}"; - model.addAttribute("result",result); - return new ModelAndView("result"); - } - @RequestMapping("/addModel.do") - public String addModel(HttpServletRequest request,Model model) { - Company company = this.unitService.getCompById(request.getParameter("companyId")); - request.setAttribute("company", company); - return "/activiti/modelAdd"; - } - @RequestMapping("/editModel.do") - public String editModel(HttpServletRequest request,Model model) { - String modelId = request.getParameter("modelid"); - org.activiti.engine.repository.Model modelData = repositoryService.getModel(modelId); - model.addAttribute("model", modelData); - String metainfo = modelData.getMetaInfo(); - JSONObject modelObjectNode = JSONObject.fromObject(metainfo) ; - String description = modelObjectNode.getString(ModelDataJsonConstants.MODEL_DESCRIPTION); - String[] str =modelData.getKey().split("-"); - model.addAttribute("processTypeId", str[0]); - String companyId = str[1]; - Company company = this.unitService.getCompById(companyId); - request.setAttribute("company", company); - model.addAttribute("description", description); - if (str.length>2) { - String maintenanceType = str[2]; - model.addAttribute("maintenanceType", maintenanceType); + /** + * 流程定义列表 + * + * @return + */ + @RequestMapping(value = "/getModelAll.do") + public ModelAndView getModelAll(HttpServletRequest request, Model model) { + User cu = (User) request.getSession().getAttribute("cu"); + String userId = cu.getId(); + String wherestr = " where 1=1 "; + if (request.getParameter("bizid") != null && !request.getParameter("bizid").isEmpty()) { + wherestr += " and KEY_ like '%" + request.getParameter("bizid") + "%' "; } - return "/activiti/modelEdit"; - } - /** - * 编辑流程图 - * @author wuping - * @return - */ - @RequestMapping("/editFlow.do") - public String editFlow(HttpServletRequest request,Model model) { - return "/activiti/modelFlowEdit"; - } + String sql = "select * from [ACT_RE_MODEL]" + wherestr; + List list = repositoryService.createNativeModelQuery().sql(sql).list(); + JSONArray json = JSONArray.fromObject(list); + JSONArray rows = new JSONArray(); + if (json != null && json.size() > 0) { + for (int i = 0; i < json.size(); i++) { + JSONObject job = json.getJSONObject(i); + TaskQuery taskQuery = taskService.createTaskQuery().taskCandidateOrAssigned(userId).processDefinitionKey(job.get("key").toString()); + List taskList = taskQuery.list(); + int taskNum = taskList.size(); + job.put("taskNum", taskNum); + rows.add(job); + } + } + String result = "{\"total\":" + list.size() + ",\"rows\":" + rows + "}"; + model.addAttribute("result", result); - /** - * 编辑流程节点添加业务 - * @author wuping - * @return - */ - @RequestMapping("/editNode.do") - public String editNode(HttpServletRequest request,Model model) { - //String prString= request.getParameter("processTypeId"); - String modelid = request.getParameter("modelid"); - int index=0; - String resourceId = request.getParameter("resourceId"); - String bizId = request.getParameter("bizId"); - Company company = this.unitService.getCompById(bizId); - request.setAttribute("company", company); - ObjectNode modelNode; - Object name = ""; - Object nodetype = ""; - Object businessid = ""; - try { - modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelid)); - for(int i=0;i 2) { + String maintenanceType = str[2]; + model.addAttribute("maintenanceType", maintenanceType); + } + return "/activiti/modelEdit"; + } + + /** + * 编辑流程图 + * + * @return + * @author wuping + */ + @RequestMapping("/editFlow.do") + public String editFlow(HttpServletRequest request, Model model) { + return "/activiti/modelFlowEdit"; + } + + /** + * 编辑流程节点添加业务 + * + * @return + * @author wuping + */ + @RequestMapping("/editNode.do") + public String editNode(HttpServletRequest request, Model model) { + //String prString= request.getParameter("processTypeId"); + String modelid = request.getParameter("modelid"); + int index = 0; + String resourceId = request.getParameter("resourceId"); + String bizId = request.getParameter("bizId"); + Company company = this.unitService.getCompById(bizId); + request.setAttribute("company", company); + ObjectNode modelNode; + Object name = ""; + Object nodetype = ""; + Object businessid = ""; + try { + modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelid)); + for (int i = 0; i < modelNode.get("childShapes").size(); i++) { + if (modelNode.get("childShapes").path(i).get("resourceId").asText().equals(resourceId)) { + index = i; + break; + } + } + JsonNode json = modelNode.get("childShapes").path(index); + JsonNode properties = json.get("properties"); + System.out.println(properties); + name = properties.get("name").asText(); + JsonNode stencil = json.get("stencil"); + nodetype = stencil.get("id").asText(); + businessid = properties.get("documentation"); + if (businessid != null) { + businessid = properties.get("documentation").asText(); + } else { + businessid = ""; + } + + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + model.addAttribute("businessid", businessid); + model.addAttribute("nodename", name); + model.addAttribute("modelid", modelid);//模型id + model.addAttribute("resourceId", resourceId);//流程节点id + model.addAttribute("index", index); /*if(nodetype.equals("UserTask")){ return "/activiti/modelNodeEdit"; }else{ return "/activiti/modelNodeEditOther"; }*/ - return "/activiti/modelNodeEdit"; - } + return "/activiti/modelNodeEdit"; + } - /** - * 流程节点列表 - * @author wuping - * @return - */ - @RequestMapping("modelNode.do") - public ModelAndView modelNode(HttpServletRequest request,Model model) { - String modelId = request.getParameter("modelid"); - org.activiti.engine.repository.Model modelData = repositoryService.getModel(modelId); - model.addAttribute("model", modelData); - JSONArray jsonArray =new JSONArray(); - - Map map; - try { - ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId())); - JsonNode childShapes =modelNode.get("childShapes"); - if(childShapes!= null && childShapes.size()>0){ - for(int i=0;i list = this.jobService.selectModelNodeJobListByWhere(" where resource_id='"+resourceId+"' and model_id ='"+modelData.getId()+"' "); - StringBuilder jobNames= new StringBuilder(); - StringBuilder jobIds= new StringBuilder(); - if(list != null && !list.isEmpty()){ - for(int j=0;j 0) { + for (int i = 0; i < childShapes.size(); i++) { + JsonNode stencil = childShapes.path(i).get("stencil"); + if (stencil.get("id").asText().toString().equals("UserTask")) { + JSONObject json = JSONObject.fromObject(childShapes.path(i).toString()); + JSONObject properties = JSONObject.fromObject(json.get("properties").toString()); + String documentation = ""; + Object documentation1 = properties.get("documentation"); + if (documentation1 != null) { + documentation = documentation1.toString(); + json.put("businessunit", businessUnitService.selectById(documentation)); + } + // 获取节点名称 + String nodeName = ""; + if (properties.has("name") && properties.get("name") != null) { + nodeName = properties.get("name").toString(); + }else if(properties.has("namename") && properties.get("namename") != null) { + nodeName = properties.get("namename").toString(); + } + // 添加节点名称字段,方便前端显示 + json.put("nodeName", nodeName); + String resourceId = json.get("resourceId").toString(); + List list = this.jobService.selectModelNodeJobListByWhere(" where resource_id='" + resourceId + "' and model_id ='" + modelData.getId() + "' "); + StringBuilder jobNames = new StringBuilder(); + StringBuilder jobIds = new StringBuilder(); + if (list != null && !list.isEmpty()) { + for (int j = 0; j < list.size(); j++) { + if (list.get(j) != null) { + if (list.get(j).getName() != null && list.get(j).getName() != "" && list.get(j).getName() != "null") { + jobNames.append(list.get(j).getName()).append(","); + jobIds.append(list.get(j).getJobId()).append(","); + } + + } + + } + } + if (!jobNames.toString().isEmpty()) { + json.put("jobNames", jobNames.toString()); + json.put("jobIds", jobIds.toString()); + + } + + jsonArray.add(json); + + } + } + } String result = "{\"total\":" + jsonArray.size() + ",\"rows\":" + jsonArray + "}"; - model.addAttribute("result",result); + model.addAttribute("result", result); } catch (JsonProcessingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return new ModelAndView("result"); - - } - /** - * 更新模型 - */ - @RequestMapping(value = "update", method = RequestMethod.POST) - public String update(HttpServletRequest request,Model model, - @RequestParam(value ="id") String id, - @RequestParam(value ="name") String name, - @RequestParam(value ="description", required=false) String description, - @RequestParam(value ="companyid") String companyid, - @RequestParam(value ="processType") String processType,HttpServletResponse response){ - User cu= (User)request.getSession().getAttribute("cu"); - - String result=""; - try { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } - org.activiti.engine.repository.Model modelData = repositoryService.getModel(id); - modelData.setName(name); - String modelKey=processType+"-"+companyid; - String maintenanceType=request.getParameter("maintenanceType"); - if (ProcessType.B_Maintenance.getId().equals(processType)) { - modelKey+="-"+maintenanceType; - } - modelData.setKey(modelKey);//模型key - description = StringUtils.defaultString(description); - String metainfo = modelData.getMetaInfo(); - JSONObject modelObjectNode = JSONObject.fromObject(metainfo) ; - modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description); - modelData.setMetaInfo(modelObjectNode.toString()); - repositoryService.saveModel(modelData); - /*修改流程唯一标识、名称*/ - ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId())); - ObjectMapper objectMapper = new ObjectMapper(); - ObjectNode propertiesNode = objectMapper.createObjectNode(); - propertiesNode.put("process_id", modelData.getKey()); - propertiesNode.put("name", modelData.getName()); - modelNode.put("properties", propertiesNode); - repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8")); - result=modelData.getId(); - } catch (Exception e) { - logger.error("创建模型失败:", e); - } - //String resstr="{\"res\":\""+result+"\",\"id\":\""+modelData.getId()+"\"}"; - model.addAttribute("result", result); - return "result"; - } - /** - * 创建模型 - */ - @RequestMapping(value = "create", method = RequestMethod.POST) - public String create(HttpServletRequest request,Model model, - @RequestParam(value ="name") String name, - @RequestParam(value ="description", required=false) String description, - @RequestParam(value ="companyid") String companyid, - @RequestParam(value ="processType") String processType, - HttpServletResponse response) { - String result=""; - try { - ObjectMapper objectMapper = new ObjectMapper(); - ObjectNode editorNode = objectMapper.createObjectNode(); - editorNode.put("id", "canvas"); - editorNode.put("resourceId", "canvas"); - ObjectNode stencilSetNode = objectMapper.createObjectNode(); - stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); - editorNode.put("stencilset", stencilSetNode); - org.activiti.engine.repository.Model modelData = repositoryService.newModel(); - ObjectNode modelObjectNode = objectMapper.createObjectNode(); - modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name); - modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); - description = StringUtils.defaultString(description); - modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description); - modelData.setMetaInfo(modelObjectNode.toString()); - modelData.setName(name); - String maintenanceType=request.getParameter("maintenanceType"); - String modelKey=processType+"-"+companyid; - if (ProcessType.B_Maintenance.getId().equals(processType)) { - modelKey+="-"+maintenanceType; - } - modelData.setKey(modelKey);//模型key - - /*自动写入流程唯一标识、名称*/ - ObjectNode propertiesNode = objectMapper.createObjectNode(); - propertiesNode.put("process_id", modelData.getKey()); - propertiesNode.put("name", modelData.getName()); - editorNode.put("properties", propertiesNode); + return new ModelAndView("result"); + + } + + /** + * 更新模型 + */ + @RequestMapping(value = "update", method = RequestMethod.POST) + public String update(HttpServletRequest request, Model model, + @RequestParam(value = "id") String id, + @RequestParam(value = "name") String name, + @RequestParam(value = "description", required = false) String description, + @RequestParam(value = "companyid") String companyid, + @RequestParam(value = "processType") String processType, HttpServletResponse response) { + User cu = (User) request.getSession().getAttribute("cu"); + + String result = ""; + try { + + org.activiti.engine.repository.Model modelData = repositoryService.getModel(id); + modelData.setName(name); + String modelKey = processType + "-" + companyid; + String maintenanceType = request.getParameter("maintenanceType"); + if (ProcessType.B_Maintenance.getId().equals(processType)) { + modelKey += "-" + maintenanceType; + } + modelData.setKey(modelKey);//模型key + description = StringUtils.defaultString(description); + String metainfo = modelData.getMetaInfo(); + JSONObject modelObjectNode = JSONObject.fromObject(metainfo); + modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description); + modelData.setMetaInfo(modelObjectNode.toString()); + repositoryService.saveModel(modelData); + /*修改流程唯一标识、名称*/ + ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId())); + ObjectMapper objectMapper = new ObjectMapper(); + ObjectNode propertiesNode = objectMapper.createObjectNode(); + propertiesNode.put("process_id", modelData.getKey()); + propertiesNode.put("name", modelData.getName()); + modelNode.put("properties", propertiesNode); + repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8")); + result = modelData.getId(); + } catch (Exception e) { + logger.error("创建模型失败:", e); + } + //String resstr="{\"res\":\""+result+"\",\"id\":\""+modelData.getId()+"\"}"; + model.addAttribute("result", result); + return "result"; + } + + /** + * 创建模型 + */ + @RequestMapping(value = "create", method = RequestMethod.POST) + public String create(HttpServletRequest request, Model model, + @RequestParam(value = "name") String name, + @RequestParam(value = "description", required = false) String description, + @RequestParam(value = "companyid") String companyid, + @RequestParam(value = "processType") String processType, + HttpServletResponse response) { + String result = ""; + try { + ObjectMapper objectMapper = new ObjectMapper(); + ObjectNode editorNode = objectMapper.createObjectNode(); + editorNode.put("id", "canvas"); + editorNode.put("resourceId", "canvas"); + ObjectNode stencilSetNode = objectMapper.createObjectNode(); + stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); + editorNode.put("stencilset", stencilSetNode); + org.activiti.engine.repository.Model modelData = repositoryService.newModel(); + ObjectNode modelObjectNode = objectMapper.createObjectNode(); + modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name); + modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); + description = StringUtils.defaultString(description); + modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description); + modelData.setMetaInfo(modelObjectNode.toString()); + modelData.setName(name); + String maintenanceType = request.getParameter("maintenanceType"); + String modelKey = processType + "-" + companyid; + if (ProcessType.B_Maintenance.getId().equals(processType)) { + modelKey += "-" + maintenanceType; + } + modelData.setKey(modelKey);//模型key + + /*自动写入流程唯一标识、名称*/ + ObjectNode propertiesNode = objectMapper.createObjectNode(); + propertiesNode.put("process_id", modelData.getKey()); + propertiesNode.put("name", modelData.getName()); + editorNode.put("properties", propertiesNode); + + repositoryService.saveModel(modelData); + repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8")); + result = modelData.getId(); + } catch (Exception e) { + logger.error("创建模型失败:", e); + } + model.addAttribute("result", result); + return "result"; + } - repositoryService.saveModel(modelData); - repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8")); - result=modelData.getId(); - } catch (Exception e) { - logger.error("创建模型失败:", e); - } - model.addAttribute("result",result ); - return "result"; - } /** * 更新业务流程节点 - * @author wuping + * * @return + * @author wuping */ @RequestMapping("/saveNode.do") - public String saveNode(HttpServletRequest request,Model model, - @RequestParam(value ="businessid") String businessid, - @RequestParam(value ="nodename") String nodename, - @RequestParam(value ="modelid") String modelid, - @RequestParam(value ="index") String index, - @RequestParam(value = "countersign",required = false,defaultValue = "false") boolean countersign, + public String saveNode(HttpServletRequest request, Model model, + @RequestParam(value = "businessid") String businessid, + @RequestParam(value = "nodename") String nodename, + @RequestParam(value = "modelid") String modelid, + @RequestParam(value = "index") String index, + @RequestParam(value = "countersign", required = false, defaultValue = "false") boolean countersign, HttpServletResponse response) { - String result=""; + String result = ""; JsonNode modelNode; JSONObject modelobject; - BpmnModel bpmnModel ; + BpmnModel bpmnModel; BpmnJsonConverter bpmnJsonConverter; try { int i = Integer.valueOf(index); - modelNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelid)); + modelNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelid)); modelobject = JSONObject.fromObject(new ObjectMapper().writeValueAsString(modelNode)); - JSONObject json= modelobject.getJSONArray("childShapes").getJSONObject(i); - JSONObject properties =json.getJSONObject("properties"); + JSONObject json = modelobject.getJSONArray("childShapes").getJSONObject(i); + JSONObject properties = json.getJSONObject("properties"); properties.put("documentation", businessid); properties.put("name", nodename); properties.put("nodename", nodename); @@ -944,90 +968,90 @@ public class ModelController { } catch (Exception e) { logger.error("创建模型失败:", e); } - model.addAttribute("result",result ); + model.addAttribute("result", result); return "result"; } - /** - * 根据Model部署流程 - */ - @RequestMapping(value = "deploy", method = RequestMethod.POST) - public String deploy(HttpServletRequest request,Model model, - @RequestParam(value ="modelId") String modelId) { + /** + * 根据Model部署流程 + */ + @RequestMapping(value = "deploy", method = RequestMethod.POST) + public String deploy(HttpServletRequest request, Model model, + @RequestParam(value = "modelId") String modelId) { /*String result=processModelService.deploy(modelId); model.addAttribute("result",result); return "result";*/ - - - String result=""; - JsonNode modelNode; - JSONObject modelobject; - JSONArray childShapes; - try { - modelNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelId)); - modelobject = JSONObject.fromObject(new ObjectMapper().writeValueAsString(modelNode)); - if(modelobject.get("childShapes")!=null){ - childShapes= modelobject.getJSONArray("childShapes"); - for(int i=0;i0){ - properties.put("conditionsequenceflow", "${pass && route=="+num+"}"); - }else{ - properties.put("conditionsequenceflow", "${pass}"); - } - } - if(properties.get("name").toString().startsWith("不通过")){ - if(num>0){ - properties.put("conditionsequenceflow", "${!pass && route=="+num+"}"); - }else{ - properties.put("conditionsequenceflow", "${!pass}"); - } - } - } - } - }else{ - model.addAttribute("result","{\"res\":\"0\",\"restr\":\"部署失败,请编辑流程图!\"}" ); - return "result"; - } - - - ObjectMapper mapper = new ObjectMapper(); - //JSON ----> JsonNode - JsonNode editorNode = mapper.readTree(modelobject.toString()); - repositoryService.addModelEditorSource(modelId, editorNode.toString().getBytes("utf-8")); - result=processModelService.deploy(modelId); - model.addAttribute("result",result ); - return "result"; - } catch (Exception e) { - logger.error("创建模型失败:", e); - model.addAttribute("result","{\"res\":\"0\",\"restr\":\"部署失败!\"}" ); - return "result"; - } - - } + + + String result = ""; + JsonNode modelNode; + JSONObject modelobject; + JSONArray childShapes; + try { + modelNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelId)); + modelobject = JSONObject.fromObject(new ObjectMapper().writeValueAsString(modelNode)); + if (modelobject.get("childShapes") != null) { + childShapes = modelobject.getJSONArray("childShapes"); + for (int i = 0; i < childShapes.size(); i++) { + JSONObject json = childShapes.getJSONObject(i); + JSONObject properties = json.getJSONObject("properties"); + JSONObject stencil = json.getJSONObject("stencil"); + if (!stencil.get("id").toString().equals("StartNoneEvent") && !stencil.get("id").toString().equals("UserTask") && !stencil.get("id").toString().equals("SequenceFlow") && !stencil.get("id").toString().equals("EndNoneEvent") + && !stencil.get("id").toString().equals("ExclusiveGateway")) { + model.addAttribute("result", "{\"res\":\"0\",\"restr\":\"部署失败,请勿添加除任务、单一选择的网关、开始、结束以外的流程图元素!\"}"); + return "result"; + } + if (stencil.get("id").toString().equals("UserTask")) { + if (properties.get("documentation").toString().equals("") || properties.get("documentation").toString() == null) { + model.addAttribute("result", "{\"res\":\"0\",\"restr\":\"部署失败,请为节点添加业务!\"}"); + return "result"; + } + } + //properties.put("documentation", businessid); + //properties.put("usertaskassignment", "{\"assignment\":{\"candidateUsers\":[{\"value\":\"#{userIds}\",\"$$hashKey\":\"0BQ\"}],\"assignee\":\"${applicantId}\"}}"); + if (stencil.get("id").toString().indexOf("SequenceFlow") != -1) { + String regEx = "[^0-9]"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(properties.get("name").toString()); + String numstr = m.replaceAll("").trim(); + numstr = numstr.isEmpty() ? "0" : numstr; + int num = Integer.valueOf(numstr); + if (properties.get("name").toString().startsWith("通过")) { + if (num > 0) { + properties.put("conditionsequenceflow", "${pass && route==" + num + "}"); + } else { + properties.put("conditionsequenceflow", "${pass}"); + } + } + if (properties.get("name").toString().startsWith("不通过")) { + if (num > 0) { + properties.put("conditionsequenceflow", "${!pass && route==" + num + "}"); + } else { + properties.put("conditionsequenceflow", "${!pass}"); + } + } + } + } + } else { + model.addAttribute("result", "{\"res\":\"0\",\"restr\":\"部署失败,请编辑流程图!\"}"); + return "result"; + } + + + ObjectMapper mapper = new ObjectMapper(); + //JSON ----> JsonNode + JsonNode editorNode = mapper.readTree(modelobject.toString()); + repositoryService.addModelEditorSource(modelId, editorNode.toString().getBytes("utf-8")); + result = processModelService.deploy(modelId); + model.addAttribute("result", result); + return "result"; + } catch (Exception e) { + logger.error("创建模型失败:", e); + model.addAttribute("result", "{\"res\":\"0\",\"restr\":\"部署失败!\"}"); + return "result"; + } + + } /** * 导出model的xml文件 @@ -1035,7 +1059,7 @@ public class ModelController { @RequestMapping(value = "export/{modelId}") public void export(@PathVariable("modelId") String modelId, HttpServletResponse response) { try { - org.activiti.engine.repository.Model modelData = repositoryService.getModel(modelId); + org.activiti.engine.repository.Model modelData = repositoryService.getModel(modelId); BpmnJsonConverter jsonConverter = new BpmnJsonConverter(); JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId())); BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode); @@ -1053,15 +1077,15 @@ public class ModelController { } @RequestMapping("/delete.do") - public String dodel(HttpServletRequest request,Model model, - @RequestParam(value="id") String id){ - repositoryService.deleteModel(id); - model.addAttribute("result", 1); - return "result"; - } - + public String dodel(HttpServletRequest request, Model model, + @RequestParam(value = "id") String id) { + repositoryService.deleteModel(id); + model.addAttribute("result", 1); + return "result"; + } + // ==================== BPMN文件管理功能 ==================== - + /** * 显示BPMN文件列表页面 */ @@ -1069,7 +1093,7 @@ public class ModelController { public String showBpmnFileList(HttpServletRequest request, Model model) { return "/activiti/bpmnFileList"; } - + /** * 获取BPMN文件列表 */ @@ -1081,20 +1105,20 @@ public class ModelController { model.addAttribute("result", result); return new ModelAndView("result"); } - + /** * 导入BPMN文件到模型编辑器 */ @RequestMapping(value = "/importBpmnFile.do", method = RequestMethod.POST) public String importBpmnFile(HttpServletRequest request, Model model, - @RequestParam(value = "bpmnFilePath") String bpmnFilePath, - @RequestParam(value = "modelName", required = false) String modelName, - @RequestParam(value = "description", required = false) String description, - @RequestParam(value = "companyId", required = false) String companyId) { - + @RequestParam(value = "bpmnFilePath") String bpmnFilePath, + @RequestParam(value = "modelName", required = false) String modelName, + @RequestParam(value = "description", required = false) String description, + @RequestParam(value = "companyId", required = false) String companyId) { + // 构建模型Key String modelKey = null; - User cu = (User)request.getSession().getAttribute("cu"); + User cu = (User) request.getSession().getAttribute("cu"); if (companyId != null && !companyId.isEmpty()) { modelKey = "imported-" + companyId; } else if (cu != null && !cu.getId().equals(CommString.ID_Admin)) { @@ -1103,53 +1127,53 @@ public class ModelController { modelKey = "imported-" + companies.get(0).getId(); } } - + String modelId = bpmnImportService.importBpmnFile(bpmnFilePath, modelName, description, modelKey); int result = modelId != null ? 1 : 0; - + JSONObject resObj = new JSONObject(); resObj.put("res", result); resObj.put("modelId", modelId); - + model.addAttribute("result", resObj.toString()); return "result"; } - + /** * 直接部署BPMN文件 */ @RequestMapping(value = "/deployBpmnFile.do", method = RequestMethod.POST) public String deployBpmnFile(HttpServletRequest request, Model model, - @RequestParam(value = "bpmnFilePath") String bpmnFilePath, - @RequestParam(value = "deploymentName", required = false) String deploymentName) { - + @RequestParam(value = "bpmnFilePath") String bpmnFilePath, + @RequestParam(value = "deploymentName", required = false) String deploymentName) { + String deploymentId = bpmnImportService.deployBpmnFile(bpmnFilePath, deploymentName); int result = deploymentId != null ? 1 : 0; - + JSONObject resObj = new JSONObject(); resObj.put("res", result); resObj.put("deploymentId", deploymentId); - + model.addAttribute("result", resObj.toString()); return "result"; } - + /** * 上传BPMN文件并导入 */ @RequestMapping(value = "/uploadBpmnFile.do", method = RequestMethod.POST) - public String uploadBpmnFile(@RequestParam MultipartFile[] file, HttpServletRequest request, - Model model) { + public String uploadBpmnFile(@RequestParam MultipartFile[] file, HttpServletRequest request, + Model model) { int result = 0; String modelId = null; - + try { // 获取当前用户和公司信息 - User cu = (User)request.getSession().getAttribute("cu"); + User cu = (User) request.getSession().getAttribute("cu"); String processTypeId = request.getParameter("processTypeId"); String companyId = request.getParameter("companyId"); String maintenanceType = request.getParameter("maintenanceType"); - + for (MultipartFile myfile : file) { if (!myfile.isEmpty()) { String originalFilename = myfile.getOriginalFilename(); @@ -1157,7 +1181,7 @@ public class ModelController { if (originalFilename != null && originalFilename.contains(".")) { modelName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); } - + // 构建模型Key(格式:processTypeId-companyId-maintenanceType) String modelKey = null; if (companyId != null && !companyId.isEmpty()) { @@ -1179,10 +1203,10 @@ public class ModelController { modelKey = "imported-" + companies.get(0).getId(); } } - + modelId = bpmnImportService.importBpmnFromInputStream( - myfile.getInputStream(), modelName, "Uploaded from " + originalFilename, modelKey); - + myfile.getInputStream(), modelName, "Uploaded from " + originalFilename, modelKey); + if (modelId != null) { result = 1; } @@ -1191,21 +1215,21 @@ public class ModelController { } catch (Exception e) { logger.error("Error uploading BPMN file", e); } - + JSONObject resObj = new JSONObject(); resObj.put("res", result); resObj.put("modelId", modelId); - + model.addAttribute("result", resObj.toString()); return "result"; } - + /** * 获取BPMN文件内容 */ @RequestMapping("/getBpmnFileContent.do") public void getBpmnFileContent(HttpServletRequest request, HttpServletResponse response, - @RequestParam(value = "bpmnFilePath") String bpmnFilePath) { + @RequestParam(value = "bpmnFilePath") String bpmnFilePath) { try { String content = bpmnImportService.getBpmnFileContent(bpmnFilePath); if (content != null) { @@ -1217,7 +1241,7 @@ public class ModelController { logger.error("Error getting BPMN file content", e); } } - + /** * 批量导入所有BPMN文件到模型 */ @@ -1227,21 +1251,21 @@ public class ModelController { int successCount = 0; int failCount = 0; List importedModels = new ArrayList<>(); - + for (Map fileInfo : bpmnFiles) { String path = (String) fileInfo.get("path"); String processName = (String) fileInfo.get("processName"); String processId = (String) fileInfo.get("processId"); - + // 提取相对路径 String relativePath = path; if (path != null && path.contains("diagrams/")) { relativePath = path.substring(path.indexOf("diagrams/") + 9); } - + String modelName = processName != null ? processName : fileInfo.get("filename").toString(); String modelId = bpmnImportService.importBpmnFile(relativePath, modelName, ""); - + if (modelId != null) { successCount++; importedModels.add(modelName + ":" + modelId); @@ -1249,13 +1273,13 @@ public class ModelController { failCount++; } } - + JSONObject resObj = new JSONObject(); resObj.put("res", 1); resObj.put("successCount", successCount); resObj.put("failCount", failCount); resObj.put("importedModels", importedModels); - + model.addAttribute("result", resObj.toString()); return "result"; }