diff --git a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar index 7bb2d31e..34038f1a 100644 Binary files a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar and b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar differ diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/OutputAPIManager.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/OutputAPIManager.java index 5f6a1b97..f131d677 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/OutputAPIManager.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/OutputAPIManager.java @@ -1,21 +1,13 @@ package com.actionsoft.apps.coe.pal.pal.output; -import java.io.FileInputStream; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; - import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; import com.actionsoft.apps.coe.pal.log.CoEOpLogConst; +import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; import com.actionsoft.bpms.commons.mvc.view.ResponseObject; import com.actionsoft.bpms.server.UserContext; @@ -25,14 +17,16 @@ import com.actionsoft.bpms.util.ClassReflect; import com.actionsoft.bpms.util.UUIDGener; import com.actionsoft.bpms.util.UtilFile; import com.actionsoft.bpms.util.UtilString; -import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; -import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; -import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; -import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; -import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; import com.actionsoft.exception.AWSException; import com.actionsoft.sdk.local.SDK; -import com.alibaba.fastjson.JSONObject; + +import java.io.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; /** * 报告生成器内部API封装 @@ -66,11 +60,9 @@ public class OutputAPIManager { throw new AWSException("Not Find OutputAppProfile! profileId=" + profileId); // --------dc context----------- DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - System.out.println("这是一个什么东西>>>>>>"+dcProfile); if (dcProfile == null) throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), wsId, id, OutputConst.FILE_WIZARD_CONFIG); - System.out.println("dc里边的是什么东西>>>>>>>>>>>>"+dcContext); InputStream in = null; try { in = new ByteArrayInputStream(jsonData.getBytes("UTF-8")); @@ -157,7 +149,7 @@ public class OutputAPIManager { * @param id 任务Id * @param profileId 报告生成器扩展App的配置Id */ - public String getWizardJsonData(String wsId, String id, String profileId) throws AWSException { + public String getWizardJsonData(String wsId, String id, String profileId) throws AWSException { // --------app appProfile---------- OutputAppProfile appProfile = OutputAppManager.getProfile(profileId); if (appProfile == null) diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java index 382b8336..c80bd0e9 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java @@ -1,26 +1,46 @@ package com.actionsoft.apps.coe.pal.pal.output.util; +import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; import com.actionsoft.bpms.org.model.DepartmentModel; import com.actionsoft.bpms.org.model.RoleModel; import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.DispatcherRequest; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.server.fs.dc.DCProfileManager; import com.actionsoft.bpms.util.UtilFile; import com.actionsoft.bpms.util.UtilString; import com.actionsoft.sdk.local.SDK; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.sini.com.spire.doc.*; +import com.sini.com.spire.doc.collections.SectionCollection; +import com.sini.com.spire.doc.documents.*; +import com.sini.com.spire.doc.fields.DocPicture; +import com.sini.com.spire.doc.fields.TextRange; +import com.sini.com.spire.doc.formatting.CharacterFormat; +import com.sini.com.spire.doc.formatting.ParagraphFormat; import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateException; +import java.awt.*; import java.io.*; +import java.util.List; import java.util.*; public class OutputWordUtil { @@ -186,6 +206,719 @@ public class OutputWordUtil { } } + + /** + * 生成word文件 + * + * @param dataMap + * @param tempPath + * @param tempName + * @param docName + */ + public static void createZdDoc2(JSONObject dataMap, String tempPath, String tempName, String docName, JSONObject wizardJsonData, String repositoryId, String docPath) throws FileNotFoundException { + Configuration configuration = new Configuration(); + configuration.setDefaultEncoding("UTF-8"); + + // 设置模本装置方法和路径 + try { + UtilFile temps = new UtilFile(tempPath); + configuration.setDirectoryForTemplateLoading(temps); + } catch (IOException e2) { + e2.printStackTrace(); + } + Template t = null; + try { + t = configuration.getTemplate(tempName, "UTF-8"); + } catch (IOException e) { + e.printStackTrace(); + } + // 输出文档路径及名称 + File outFile = new File(docName); + Writer out = null; + try { + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8")); + } catch (Exception e1) { + e1.printStackTrace(); + } + + + try { + if (t != null && out != null) { + t.process(dataMap, out); + out.flush(); + out.close(); + } + } catch (TemplateException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + + //***********************************************************使用spire 生成模板后复制文件****************************************************/ + List> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson4(repositoryId); //流程文件内容 + if (wizardJsonData.getBoolean("orderNuberFirst")) { // 根据页面选择进行排序 + OutputWordUtil.orderByNumber(repositoryFileElements); + } + + String controlShapeId = ""; + if (repositoryFileElements != null) { + int index = 1;// 流程步骤序号 + int dangerIndex = 1;// 风险序号 + int regulateIndex = 1;// 控制序号 + for (Map shape : repositoryFileElements) { + String type = shape.get("type").toString(); + if ("regulation".equals(type)) { + controlShapeId = shape.get("id").toString(); + } else if ("I/O_L4".equals(type)) { + controlShapeId = shape.get("id").toString(); + } + } + } + + + UserContext userContext = DispatcherRequest.getUserContext(); + + Map result = new HashMap<>(); + result.put("listDef", ""); + result.put("content", ""); + if (UtilString.isEmpty(controlShapeId)) { + + } + PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId); + if (repositoryModel == null) { + + } + String content = ""; + StringBuilder listStr = new StringBuilder(); + // 读取附件 + // 流程附件列表 + UpFileDao upFileDao = new UpFileDao(); + List search = upFileDao.search(repositoryModel.getId(), controlShapeId, null); + + DCContext dcContextpdf = null; + File file = null; + + + if (search != null && search.size() > 0) { + long b1 = System.currentTimeMillis(); + // 复制附件 + for (UpfileModel upfileModel : search) { + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + + if (dcProfile != null) { + dcContextpdf = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), upfileModel.getFileName()); + String path = dcContextpdf.getPath(); + String fileName = dcContextpdf.getFileName(); + + //创建 Document 类的对象并从磁盘加载 Word 文档 + Document document = new Document(outFile.getPath()); + + /*//获取最后一节 + Section section = document.getLastSection(); + Paragraph paragraph = section.addParagraph(); + + paragraph.appendBreak(BreakType.Page_Break);*/ + + + String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + + if (suffix.equals("xml")) { + // 输出文档路径及名称 + File sourceFile = new UtilFile(path + fileName); + File targetFile = new UtilFile(docPath + fileName); + try { + UtilFile.copyFile(sourceFile, targetFile); + } catch (Exception e) { + System.out.println(e); + e.printStackTrace(); + } + + //创建实例,加载xml测试文档 + com.sini.com.spire.doc.Document doc = new com.sini.com.spire.doc.Document(); + doc.loadFromFile(docPath + fileName); + + //保存为xml格式 + String substring = fileName.substring(0, fileName.lastIndexOf(".xml")); + //保存为Word + doc.saveToFile(docPath + substring + ".docx", FileFormat.Docx);//支持.doc + + } + + + if (suffix.equals("xml")) { + //保存为xml格式 + String substring = fileName.substring(0, fileName.lastIndexOf(".xml")); + //保存为Word + document.insertTextFromFile(docPath + substring + ".docx", FileFormat.Docx_2013); + } else { + document.insertTextFromFile(path + fileName, FileFormat.Docx_2013); + } + // document.insertTextFromFile("/Users/sunlh/Downloads/手册格式问题测试文档(3)new.docx", FileFormat.Docx_2013); + //保存结果文档 + document.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + + + //加载文档1 + com.sini.com.spire.doc.Document doc1 = new com.sini.com.spire.doc.Document(); + doc1.loadFromFile(tempPath + "制度-手册5.doc"); + + + //获取section + Section section1 = doc1.getSections().get(0); + + //获取文档1的页眉页脚 + HeaderFooter headerword = section1.getHeadersFooters().getHeader(); + HeaderFooter footerword = section1.getHeadersFooters().getFooter(); + + //加载文档2 + com.sini.com.spire.doc.Document doc2 = new com.sini.com.spire.doc.Document(); + + + doc2.loadFromFile(outFile.getPath()); + + + SectionCollection sections = doc2.getSections(); + + + // 获取源文档的页眉页脚 + Section sourceSection = doc1.getSections().get(0); + HeaderFooter sourceHeader = sourceSection.getHeadersFooters().getHeader(); + HeaderFooter sourceFooter = sourceSection.getHeadersFooters().getFooter(); + + // 将页眉复制到目标文档的第三节以及后续节 + for (int i = 2; i < doc2.getSections().getCount(); i++) { + Section targetSection = doc2.getSections().get(i); + HeaderFooter targetHeader = targetSection.getHeadersFooters().getHeader(); + targetHeader.getChildObjects().clear(); + for (int j = 0; j < sourceHeader.getChildObjects().getCount(); j++) { + DocumentObject obj = sourceHeader.getChildObjects().get(j).deepClone(); + targetHeader.getChildObjects().add(obj); + } + } + + // 将页脚复制到目标文档的第三节以及后续节 + for (int i = 2; i < doc2.getSections().getCount(); i++) { + Section targetSection = doc2.getSections().get(i); + HeaderFooter targetFooter = targetSection.getHeadersFooters().getFooter(); + targetFooter.getChildObjects().clear(); + for (int j = 0; j < sourceFooter.getChildObjects().getCount(); j++) { + DocumentObject obj = sourceFooter.getChildObjects().get(j).deepClone(); + targetFooter.getChildObjects().add(obj); + } + } + + doc2.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + + } + } + long b2 = System.currentTimeMillis(); + + System.err.println("复制附件用时:" + + (b2 - b1) / 1000 + "秒"); + } + + + /****************************插入支持文件、相关文件、附则等信息********************************************************/ + Document doc = new Document(outFile.getPath()); + //获取最后一节 + Section section = doc.getLastSection(); + + //添加段落,设置一级序列 + Paragraph paragraph = section.addParagraph(); + + + //paragraph.appendBreak(BreakType.Page_Break); + //Section section2 = doc.addSection(); + + //相关文件 R_relevant_flies + JSONArray relevant_flies = new JSONArray(); //组织职责Table + List relationList2 = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "related_files"); + int count = 0; + if (relationList2.size() > 0) { + for (DesignerShapeRelationModel relation : relationList2) { + String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID + PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId); + if (model != null) { + count++; + String name = model.getName(); + JSONObject tmp = new JSONObject(); + tmp.put("name", name); + tmp.put("desc", count); + + relevant_flies.add(tmp); + } + } + + CharacterFormat format = new CharacterFormat(); + //创建字体格式 + format.setFontName("宋体"); + //添加段落,设置一级序列 + Paragraph paragraph1 = section.addParagraph(); + + + //paragraph1.appendBreak(BreakType.Page_Break); + + + ParagraphFormat paragraphFormat1 = paragraph1.getFormat(); + paragraphFormat1.setHorizontalAlignment(HorizontalAlignment.Left); + + TextRange tr = paragraph1.appendText("相关文件"); + tr.getCharacterFormat().setBold(true); + tr.getCharacterFormat().setFontName("宋体"); + tr.getCharacterFormat().setFontSize(12); + //tr.applyCharacterFormat(format); //应用字体格式 + paragraph1.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式 + + + //定义表格数据 + String[] header = {"序号", "文件名称"}; + + String[][] strArray2 = new String[relevant_flies.size()][]; + List list = new LinkedList<>(); + for (int i = 0; i < relevant_flies.size(); i++) { + JSONObject jsonObject = relevant_flies.getJSONObject(i); + String[] strArray = new String[2]; + strArray[0] = jsonObject.getString("desc").toString(); + strArray[1] = jsonObject.getString("name").toString(); + list.add(strArray); + strArray2[i] = strArray; + } + + String[][] data = strArray2; + + //添加表格 + Table table = section.addTable(true); + table.resetCells(data.length + 1, header.length); + + TableRow row = table.getRows().get(0); + row.isHeader(true); + row.setHeight(20); + row.setHeightType(TableRowHeightType.Exactly); + for (int i = 0; i < header.length; i++) { + row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + Paragraph p = row.getCells().get(i).addParagraph(); + p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center); + TextRange txtRange = p.appendText(header[i]); + txtRange.getCharacterFormat().setBold(true); + } + + //将数据添加到其余行 + for (int r = 0; r < data.length; r++) { + TableRow dataRow = table.getRows().get(r + 1); + dataRow.setHeight(25); + dataRow.setHeightType(TableRowHeightType.Exactly); + dataRow.getRowFormat().setBackColor(Color.white); + for (int c = 0; c < data[r].length; c++) { + dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); + } + } + + + } + + + //支持文件 + JSONArray supportfiles = new JSONArray(); //组织职责Table + List relationList = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "support_files"); + int index = 0; + if (relationList.size() > 0) { + for (DesignerShapeRelationModel relation : relationList) { + String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID + PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId); + if (model != null) { + index++; + String name = model.getName(); + JSONObject tmp = new JSONObject(); + tmp.put("name", name); + tmp.put("desc", index); + supportfiles.add(tmp); + } + } + + + CharacterFormat format2 = new CharacterFormat(); + //创建字体格式 + format2.setFontName("宋体"); + //添加段落,设置一级序列 + Paragraph paragraph2 = section.addParagraph(); + ParagraphFormat paragraphFormat2 = paragraph2.getFormat(); + paragraphFormat2.setHorizontalAlignment(HorizontalAlignment.Left); + TextRange tr2 = paragraph2.appendText("支持文件"); + tr2.getCharacterFormat().setBold(true); + tr2.getCharacterFormat().setFontName("宋体"); + tr2.getCharacterFormat().setFontSize(12); + paragraph2.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式 + + + //定义表格数据 + String[] header = {"序号", "文件名称"}; + String[][] strArray2 = new String[supportfiles.size()][]; + List list = new LinkedList<>(); + for (int i = 0; i < supportfiles.size(); i++) { + JSONObject jsonObject = supportfiles.getJSONObject(i); + String[] strArray = new String[2]; + strArray[0] = jsonObject.getString("desc").toString(); + strArray[1] = jsonObject.getString("name").toString(); + list.add(strArray); + strArray2[i] = strArray; + } + + String[][] data = strArray2; + + //添加表格 + Table table = section.addTable(true); + table.resetCells(data.length + 1, header.length); + + TableRow row = table.getRows().get(0); + row.isHeader(true); + row.setHeight(20); + row.setHeightType(TableRowHeightType.Exactly); + for (int i = 0; i < header.length; i++) { + row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + Paragraph p = row.getCells().get(i).addParagraph(); + p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center); + TextRange txtRange = p.appendText(header[i]); + txtRange.getCharacterFormat().setBold(true); + } + + //将数据添加到其余行 + for (int r = 0; r < data.length; r++) { + TableRow dataRow = table.getRows().get(r + 1); + dataRow.setHeight(25); + dataRow.setHeightType(TableRowHeightType.Exactly); + dataRow.getRowFormat().setBackColor(Color.white); + for (int c = 0; c < data[r].length; c++) { + dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); + } + } + + + } + + /*CharacterFormat format3=new CharacterFormat(); + //创建字体格式 + format3.setFontName("宋体"); + //添加段落,设置一级序列 + Paragraph paragraph3 = section.addParagraph(); + TextRange tr3 = paragraph3.appendText("7.附则"); + tr3.getCharacterFormat().setBold(true); + tr3.getCharacterFormat().setFontName("宋体"); + paragraph3.applyStyle(BuiltinStyle.Heading_7); //应用标题1样式 + + //添加段落 + Paragraph paragraph5 = section.addParagraph(); + + // 附则处理 + List T_supplementary_articles_table = new ArrayList<>(); + String [] tmp = dataMap.getString("pl_T_supplementary_articles").split("\n"); + for (int i = 0; i < tmp.length; i++) { + if (UtilString.isNotEmpty(tmp[i])) { + T_supplementary_articles_table.add(tmp[i]); + } + } + + TextRange tr5 = paragraph5.appendText(T_supplementary_articles_table.toString()); + tr5.getCharacterFormat().setFontName("宋体");*/ + + + //查询模型文件属性上传附件信息 + List search2 = upFileDao.searchByRepositoryId(repositoryModel.getId(), "f"); + + DCContext dcContextModel = null; + + + // 排序 + Collections.sort(search2, new Comparator() { + @Override + public int compare(UpfileModel o1, UpfileModel o2) { + String p1 = o1.getFileName(); + String p2 = o2.getFileName(); + if (p1.substring(0, 2).equals("附件") && p2.substring(0, 2).equals("附件") && p1.contains(":") && p2.contains(":")) { + return Integer.parseInt(p1.substring(2, p1.indexOf(":"))) - Integer.parseInt(p2.substring(2, p2.indexOf(":"))); + + } else { + return 0; + } + + + } + }); + + //读取模型附件插入手册中文档对象 + if (search2 != null && search2.size() > 0) { + + + //附件如果为空,不插入附件标题 + CharacterFormat format4 = new CharacterFormat(); + //创建字体格式 + format4.setFontName("宋体"); + //添加段落 + Paragraph paragraph4 = section.addParagraph(); + + ParagraphFormat paragraphFormat4 = paragraph4.getFormat(); + paragraphFormat4.setHorizontalAlignment(HorizontalAlignment.Left); + + TextRange tr4 = paragraph4.appendText("附件"); + + + tr4.getCharacterFormat().setBold(true); + tr4.getCharacterFormat().setFontName("宋体"); + tr4.getCharacterFormat().setFontSize(12); + paragraph4.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式 + + + long b1 = System.currentTimeMillis(); + + for (UpfileModel upfileModel : search2) { + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile != null) { + + // 处理DocCenter + dcContextModel = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, "file", upfileModel.getPl_uuid(), upfileModel.getFileName()); + //添加段落 + Paragraph paragraph5 = section.addParagraph(); + + //加载一个图片,它将作为外部文件的符号显示在Word文档中 + //获取最后一个.的位置 + int lastIndexOf = dcContextModel.getFileName().lastIndexOf("."); + //获取文件的后缀名 .jpg + String suffix = dcContextModel.getFileName().substring(lastIndexOf); + + DocPicture pdfIcon = new DocPicture(doc); + + InputStream stream1 = new FileInputStream(dcContextModel.getFilePath()); + DocPicture pic1 = new DocPicture(doc); + + if (suffix.equals(".doc") || suffix.equals(".docx")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/word.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".doc")) { + paragraph5.appendOleObject(stream1, pic1, "doc"); + } else if (suffix.equals(".docx")) { + paragraph5.appendOleObject(stream1, pic1, "docx"); + } + } else if (suffix.equals(".pdf")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/pdf.png"); + paragraph5.appendText(dcContextModel.getFileName()); + paragraph5.appendOleObject(stream1, pic1, "pdf"); + } else if (suffix.equals(".xls") || suffix.equals(".xlsx")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/xls.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".xls")) { + paragraph5.appendOleObject(stream1, pic1, "xls"); + } else if (suffix.equals(".xlsx")) { + paragraph5.appendOleObject(stream1, pic1, "xlsx"); + } + } else if (suffix.equals(".png") || suffix.equals(".jgp")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/png.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".png")) { + paragraph5.appendOleObject(stream1, pic1, "png"); + } else if (suffix.equals(".jpg")) { + paragraph5.appendOleObject(stream1, pic1, "jpg"); + } + } else if (suffix.equals(".zip") || suffix.equals(".rar")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/zip.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".zip")) { + paragraph5.appendOleObject(stream1, pic1, "zip"); + } else if (suffix.equals(".rar")) { + paragraph5.appendOleObject(stream1, pic1, "rar"); + } + } else if (suffix.equals(".mp3") || suffix.equals(".mp4")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/mp3.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".mp3")) { + paragraph5.appendOleObject(stream1, pic1, "mp3"); + } else if (suffix.equals(".mp4")) { + paragraph5.appendOleObject(stream1, pic1, "mp4"); + } + } else if (suffix.equals(".txt")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/txt.png"); + paragraph5.appendText(dcContextModel.getFileName()); + paragraph5.appendOleObject(stream1, pic1, "txt"); + } + + + } + + } + long b2 = System.currentTimeMillis(); + System.err.println("插入附件用时:" + + (b2 - b1) / 1000 + "秒"); + } + doc.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + } + + + /** + * 生成word文件 + * + * @param dataMap + * @param tempPath + * @param tempName + * @param docName + */ + public static void createBdDoc2(JSONObject dataMap, String tempPath, String tempName, String docName, String repositoryId) throws FileNotFoundException { + Configuration configuration = new Configuration(); + configuration.setDefaultEncoding("UTF-8"); + + // 设置模本装置方法和路径 + try { + UtilFile temps = new UtilFile(tempPath); + configuration.setDirectoryForTemplateLoading(temps); + } catch (IOException e2) { + e2.printStackTrace(); + } + Template t = null; + try { + t = configuration.getTemplate(tempName, "UTF-8"); + } catch (IOException e) { + e.printStackTrace(); + } + // 输出文档路径及名称 + File outFile = new File(docName); + Writer out = null; + try { + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8")); + } catch (Exception e1) { + e1.printStackTrace(); + } + + try { + if (t != null && out != null) { + t.process(dataMap, out); + out.flush(); + out.close(); + } + } catch (TemplateException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + /**************************************************插入文件对象**********************************************************************/ + Document doc = new Document(outFile.getPath()); + //获取最后一节 + Section section = doc.getLastSection(); + + + CharacterFormat format4 = new CharacterFormat(); + //创建字体格式 + format4.setFontName("宋体"); + //添加段落 + Paragraph paragraph = section.addParagraph(); + + + ParagraphFormat paragraphFormat4 = paragraph.getFormat(); + paragraphFormat4.setHorizontalAlignment(HorizontalAlignment.Left); + + TextRange tr4 = paragraph.appendText("表单/模板"); + + tr4.getCharacterFormat().setBold(true); + tr4.getCharacterFormat().setFontName("宋体"); + paragraph.applyStyle(BuiltinStyle.Heading_1); //应用标题1样式 + + //doc.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + + + PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId); + + UpFileDao upFileDao = new UpFileDao(); + //查询模型文件属性上传附件信息 + List search = upFileDao.searchByRepositoryId(repositoryModel.getId(), "s"); + + + DCContext dcContextModel = null; + UserContext userContext = DispatcherRequest.getUserContext(); + if (search != null && search.size() > 0) { + // 复制附件 + for (UpfileModel upfileModel : search) { + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + + if (dcProfile != null) { + dcContextModel = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), upfileModel.getFileName()); + String path = dcContextModel.getPath(); + String fileName = dcContextModel.getFileName(); + + + //添加段落 + Paragraph paragraph5 = section.addParagraph(); + + //加载一个图片,它将作为外部文件的符号显示在Word文档中 + //获取最后一个.的位置 + int lastIndexOf = dcContextModel.getFileName().lastIndexOf("."); + //获取文件的后缀名 .jpg + String suffix = dcContextModel.getFileName().substring(lastIndexOf); + + DocPicture pdfIcon = new DocPicture(doc); + + InputStream stream1 = new FileInputStream(dcContextModel.getFilePath()); + DocPicture pic1 = new DocPicture(doc); + + if (suffix.equals(".doc") || suffix.equals(".docx")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/word.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".doc")) { + paragraph5.appendOleObject(stream1, pic1, "doc"); + } else if (suffix.equals(".docx")) { + paragraph5.appendOleObject(stream1, pic1, "docx"); + } + } else if (suffix.equals(".pdf")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/pdf.png"); + paragraph5.appendText(dcContextModel.getFileName()); + paragraph5.appendOleObject(stream1, pic1, "pdf"); + } else if (suffix.equals(".xls") || suffix.equals(".xlsx")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/xls.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".xls")) { + paragraph5.appendOleObject(stream1, pic1, "xls"); + } else if (suffix.equals(".xlsx")) { + paragraph5.appendOleObject(stream1, pic1, "xlsx"); + } + } else if (suffix.equals(".png") || suffix.equals(".jgp")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/png.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".png")) { + paragraph5.appendOleObject(stream1, pic1, "png"); + } else if (suffix.equals(".jpg")) { + paragraph5.appendOleObject(stream1, pic1, "jpg"); + } + } else if (suffix.equals(".zip") || suffix.equals(".rar")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/zip.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".zip")) { + paragraph5.appendOleObject(stream1, pic1, "zip"); + } else if (suffix.equals(".rar")) { + paragraph5.appendOleObject(stream1, pic1, "rar"); + } + } else if (suffix.equals(".mp3") || suffix.equals(".mp4")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/mp3.png"); + paragraph5.appendText(dcContextModel.getFileName()); + if (suffix.equals(".mp3")) { + paragraph5.appendOleObject(stream1, pic1, "mp3"); + } else if (suffix.equals(".mp4")) { + paragraph5.appendOleObject(stream1, pic1, "mp4"); + } + } else if (suffix.equals(".txt")) { + pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/txt.png"); + paragraph5.appendText(dcContextModel.getFileName()); + paragraph5.appendOleObject(stream1, pic1, "txt"); + } + + + } + } + + } + + doc.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + } + + /** * 将文件的扩展属性设置默认值为空字符串(防止没有设置扩展属性而使得导出文件出错) * diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/PALRepositoryQueryAPIManager.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/PALRepositoryQueryAPIManager.java index 33337b77..af471045 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/PALRepositoryQueryAPIManager.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/PALRepositoryQueryAPIManager.java @@ -1,65 +1,26 @@ package com.actionsoft.apps.coe.pal.pal.repository; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Field; -import java.nio.charset.StandardCharsets; -import java.util.*; - -import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; +import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.cooperation.cache.CooperationCache; import com.actionsoft.apps.coe.pal.cooperation.cache.model.TeamInfo; import com.actionsoft.apps.coe.pal.cooperation.cache.model.UserInfo; import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; import com.actionsoft.apps.coe.pal.log.CoEOpLogConst; -import com.actionsoft.apps.coe.pal.pal.method.PALMethodManager; -import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; -import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; -import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant; -import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb; -import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; -import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; -import com.actionsoft.bpms.bo.engine.BO; -import com.actionsoft.bpms.bpmn.engine.cache.ProcessDefCache; -import com.actionsoft.bpms.bpmn.modeler.constant.BPMNConstant; -import com.actionsoft.bpms.bpmn.modeler.constant.BPMNFileConstant; -import com.actionsoft.bpms.bpmn.modeler.io.BPMNIO; -import com.actionsoft.bpms.bpmn.modeler.util.BPMNFileUtil; -import com.actionsoft.bpms.commons.cache.Cache; -import com.actionsoft.bpms.commons.database.RowMap; -import com.actionsoft.bpms.commons.htmlframework.AlertWindow; -import com.actionsoft.bpms.commons.login.constant.LoginConst; -import com.actionsoft.bpms.commons.mvc.view.ResponseObject; -import com.actionsoft.bpms.commons.security.high.HighSecurity; -import com.actionsoft.bpms.org.cache.DepartmentCache; -import com.actionsoft.bpms.org.cache.UserMapCache; -import com.actionsoft.bpms.org.model.DepartmentModel; -import com.actionsoft.bpms.org.model.RoleModel; -import com.actionsoft.bpms.org.model.UserMapModel; -import com.actionsoft.bpms.org.model.UserModel; -import com.actionsoft.bpms.server.DispatcherRequest; -import com.actionsoft.bpms.server.SSOUtil; -import com.actionsoft.bpms.server.UserContext; -import com.actionsoft.bpms.server.fs.DCContext; -import com.actionsoft.bpms.server.fs.dc.DCProfileManager; -import com.actionsoft.bpms.server.fs.dc.DCUtil; -import com.actionsoft.bpms.util.*; -import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishFrequencyDao; import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishListHistory; import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishFrequencyModel; +import com.actionsoft.apps.coe.pal.pal.method.PALMethodManager; import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; import com.actionsoft.apps.coe.pal.pal.output.OutPutReportWeb; import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager; +import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; import com.actionsoft.apps.coe.pal.pal.repository.cache.CoeProcessLevelCorrelateCache; -import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryAttributeCache; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryShapeAttributeCache; @@ -78,1000 +39,1032 @@ import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil; import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil; import com.actionsoft.apps.coe.pal.pal.repository.designer.web.CoeDesignerWeb; import com.actionsoft.apps.coe.pal.pal.repository.model.CoeProcessLevelCorrelateModel; -import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryAttributeModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryShapeAttributeModel; import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant; import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao; import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb; import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; +import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb; import com.actionsoft.apps.coe.pal.pal.ws.dao.CoeWorkSpace; import com.actionsoft.apps.coe.pal.pal.ws.web.VersionUtil; +import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; import com.actionsoft.apps.coe.pal.util.StringHandleUtil; +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.cache.ProcessDefCache; +import com.actionsoft.bpms.bpmn.modeler.constant.BPMNConstant; +import com.actionsoft.bpms.bpmn.modeler.constant.BPMNFileConstant; +import com.actionsoft.bpms.bpmn.modeler.io.BPMNIO; +import com.actionsoft.bpms.bpmn.modeler.util.BPMNFileUtil; +import com.actionsoft.bpms.commons.cache.Cache; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.htmlframework.AlertWindow; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.commons.security.high.HighSecurity; +import com.actionsoft.bpms.org.cache.DepartmentCache; +import com.actionsoft.bpms.org.cache.UserMapCache; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.RoleModel; +import com.actionsoft.bpms.org.model.UserMapModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.DispatcherRequest; +import com.actionsoft.bpms.server.SSOUtil; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.server.fs.dc.DCProfileManager; +import com.actionsoft.bpms.server.fs.dc.DCUtil; import com.actionsoft.bpms.util.Base64; +import com.actionsoft.bpms.util.*; import com.actionsoft.exception.AWSException; import com.actionsoft.i18n.I18nRes; import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.api.AppAPI; -import com.actionsoft.sdk.local.api.BOAPI; -import com.actionsoft.sdk.local.api.BOQueryAPI; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.IteratorUtils; import org.apache.commons.lang.StringUtils; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; +import java.util.*; + /** * 资产库文件查询接口API封装 * * @author wangyh */ public class PALRepositoryQueryAPIManager { - private PALRepositoryQueryAPIManager() { - } - - public static PALRepositoryQueryAPIManager getInstance() { - return PALRepositoryQueryAPIManager.Inner.instance; - } - - /** - * 得到缓存中所有的流程文件 - * - * @return 一个查询结果集 - */ - public List getPALRepositoryModelList() { - List list = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - while (it.hasNext()) { - list.add(it.next()); - } - return list; - } - - /** - * 得到缓存中指定流程库的流程文件 - * - * @return 一个查询结果集 - */ - public List getPALRepositoryModelList(String wsId) { - List list = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (model.getWsId().equals(wsId)) - list.add(model); - } - if (wsId != null) { - List list1 = new ArrayList(); - for (PALRepositoryModel model : list) { - if (wsId.equals(model.getWsId())) { - list1.add(model); - } - } - return list1; - } - return list; - } - - /** - * 执行查询,返回结果集 - * - * @param sortType - * @param orderByField - * @param wsId - * @param map - * @return 一个查询结果集 - */ - public List list(boolean sortType, String orderByField, String wsId, Map map) { - Iterator it = PALRepositoryCache.getCache().iterator(); - List list = new ArrayList(); - if (map.size() > 0) { - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (isExistModel(model, map)) { - list.add(model); - } - } - if (wsId != null) { - List list1 = new ArrayList(); - for (PALRepositoryModel model : list) { - if (wsId.equals(model.getWsId())) { - list1.add(model); - } - } - return list1; - } - return list; - } else { - list = getPALRepositoryModelList(wsId); - } - return list; - } - - /** - * 对查询结果进行排序 - * - * @param list - * @param sortType - * @param orderByField - */ - private void orderByFieldName(List list, String sortType, String orderByField) { - - } - - private boolean isExistModel(PALRepositoryModel model, Map map) { - Map map1 = new HashMap(); - map1.put("parentId", model.getParentId()); - map1.put("fileId", model.getId()); - map1.put("fileNo", model.getNo()); - map1.put("fileName", model.getName()); - map1.put("version", model.getVersion()); - map1.put("fileLevel", model.getLevel()); - map1.put("fileDesc", model.getDesc()); - map1.put("fileInput", model.getInput()); - map1.put("fileOutput", model.getOutput()); - map1.put("fileOwnerUser", model.getOwnerUser()); - map1.put("fileOwnerDept", model.getOwnerDept()); - map1.put("fileExecType", model.getExecType()); - map1.put("fileSystemName", model.getSystemName()); - map1.put("fileColor", model.getColor()); - map1.put("fileMethodCategory", model.getMethodCategory()); - map1.put("fileMethodId", model.getMethodId()); - map1.put("fileIsUse", model.isUse()); - map1.put("fileIsPublish", model.isPublish()); - map1.put("fileIsSystem", model.isSystemFile()); - map1.put("wsId", model.getWsId()); - Iterator it = map.keySet().iterator(); - Set set = new HashSet(2); - while (it.hasNext()) { - String key = it.next(); - Object obj = map.get(key); - if (obj == null) { - continue; - } - String className = obj.getClass().getName(); - className = className.substring(className.lastIndexOf(".") + 1); - queryResult(map1, set, key, obj, className); - } - if (set.size() > 1) { - return false; - } else return set.size() == 1 && set.contains(true); - } - - private void queryResult(Map map1, Set set, String key, Object obj, String className) { - if ("Integer".equals(className)) { - int i = (Integer) obj; - set.add(i == (Integer) map1.get(key)); - } else if ("Boolean".equals(className)) { - boolean b = (Boolean) obj; - set.add(b == (Boolean) map1.get(key)); - } else if ("String".equals(className)) { - String str = (String) map1.get(key); - if (str != null) { - set.add(str.contains((String) obj)); - } - } else if (className.toLowerCase().contains("list")) { - List list = (List) obj; - Object obj1 = map1.get(key); - if (list.size() > 0) { - set.add(list.contains(obj1)); - } - } - } - - /** - * 根据wsId过滤流程 - * - * @param wsId - * @return - */ - public List getRepositoryModelToList(String wsId) { - List list = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (model.getWsId().equals(wsId)) { - list.add((PALRepositoryModelImpl) model); - } - } - return list; - } - - public List getJsonToList(String pid, String wsId, String language, String methodType) { - List listJsonArr = new ArrayList(); - List list = getRepositoryModelToList(wsId); - for (PALRepositoryModelImpl model : list) { - if (model.getParentId() != null && !"".equals(model.getParentId()) && model.getParentId().equals(pid) && (model.getMethodId().contains(methodType) || methodType.contains(model.getMethodId()))) { - listJsonArr.add(getJSon(model, language, isParent(model.getId(), list))); - } - } - return listJsonArr; - } - - /** - * 根据wsId过滤流程并生成json - * - * @param wsId - * @return - */ - public JSONArray getRepositoryModelToJson(String wsId, String language) { - List list = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - JSONArray jsonArray = new JSONArray(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (model.getWsId().equals(wsId)) { - list.add((PALRepositoryModelImpl) model); - } - } - for (PALRepositoryModelImpl models : list) { - putAllNodeJsonToJsonArr(models.getId(), jsonArray, language, list); - } - return jsonArray; - } - - /** - * 根据wsId过滤流程并生成json - * - * @param wsId - * @return - */ - public List getRepositoryModelToJson(String wsId, String language, String methodId) { - List list = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - List listJsonArr = new ArrayList(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (model.getWsId().equals(wsId) && model.getMethodId().contains(methodId)) { - list.add((PALRepositoryModelImpl) model); - } - } - for (PALRepositoryModelImpl models : list) { - putAllNodeJson(models.getId(), listJsonArr, language, list); - } - return listJsonArr; - } - - private void putAllNodeJsonToJsonArr(String id, JSONArray jsonArray, String language, List models) { - for (int i = 0, size = models.size(); i < size; i++) { - PALRepositoryModel model = models.get(i); - String parentId = model.getParentId(); - if (parentId != null && !"".equals(parentId) && parentId.equals(id)) { - JSONObject json = getJSon(model, language, isParent(id, models)); - jsonArray.add(json); - } - } - } - - private void putAllNodeJson(String id, List jsonArray, String language, List models) { - for (int i = 0, size = models.size(); i < size; i++) { - PALRepositoryModel model = models.get(i); - String parentId = model.getParentId(); - if (parentId != null && !"".equals(parentId) && parentId.equals(id)) { - JSONObject json = getJSon(model, language, isParent(id, models)); - jsonArray.add(json); - } - } - } - - private boolean isParent(String id, List models) { - for (PALRepositoryModelImpl model : models) { - String parentId = model.getParentId(); - if (parentId != null && !"".equals(parentId) && parentId.equals(id)) { - return true; - } - } - return false; - } - - /** - * 获取tree json - * - * @param model - * @param language - * @param flag - * @return - */ - private JSONObject getJSon(PALRepositoryModel model, String language, boolean flag) { - JSONObject rootJson = new JSONObject(); - rootJson.put("id", model.getId().trim()); - rootJson.put("pid", model.getParentId().trim()); - rootJson.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - rootJson.put("name", I18nRes.findValue(CoEConstant.APP_ID, language, model.getName()).trim()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - rootJson.put("title", rootJson.get("name")); - } else { - rootJson.put("title", rootJson.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - rootJson.put("drop", false); - rootJson.put("isSystemFile", model.isSystemFile()); - rootJson.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) { - rootJson.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/default/16.png"); - } else { - rootJson.put("icon", "../apps/" + PALMethodCache.getPALMethodModelById(model.getMethodId()).getApp().getId() + "/img/method/" + model.getMethodId() + "/16.png"); - } - if (flag) { - rootJson.put("isParent", true); - rootJson.put("open", false); - } - rootJson.put("plLevel", model.getLevel()); - rootJson.put("plOrdexIndex", model.getOrderIndex()); - rootJson.put("plCategory", model.getMethodCategory()); - return rootJson; - } - - /** - * 得到给定范围内的流程文件 - * - * @param str 格式 id,id,id,id - * @return - */ - public List getFileList(String str) { - List newList = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (str.contains(model.getId())) { - newList.add(model); - } - } - return newList; - } - - /** - * 根据父id得到子节点 - * - * @param pid - * @return - */ - public List getSubList(String pid) { - List newList = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (pid.equals(model.getParentId())) { - newList.add(model); - } - } - return newList; - - } - - /** - * 获得小组可访问的使用中的资产库文件 - * - * @param teamId 小组Id - * @param wsId 资产库Id - * @return 库文件集合 - */ - public List getHavingRepositoryAccessList(String wsId, String teamId, String userId) { - return CoeProcessLevelUtil.getPermRepositoryList(wsId, teamId, userId, null, null, true, false); - } - - /** - * 得到可以访问的流程节点 - * - * @param wsid 流程库ID - * @param teamId 小组id - * @param category 建模方法 如process  - */ - public List getAccessPalModel(String wsid, String teamId, String userId, String category) { - return CoeProcessLevelUtil.getPermRepositoryList(wsid, teamId, userId, category, null, true, false); - } - - /** - * 得到当前工作空间下的流程节点 - * - * @param wsId - * @return - */ - public List getRepositoryModelByWsid(String wsId) { - List list = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (model.getWsId().equals(wsId) && model.isUse()) { - list.add(model); - } - } - return list; - } - - /** - * 得到当前工作空间下的流程节点 - * - * @param wsId - * @return - */ - public List getRepositoryModelByWsid(String wsId, String category) { - List list = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (model.getWsId().equals(wsId) && model.getMethodCategory().equals(category)) { - list.add(model); - } - } - return list; - } - - /** - * 得到当前工作空间下的流程节点 - * - * @param wsId - * @return - */ - public List getRepositoryModelByWsid1(String wsId, String category, boolean isUse, boolean isPublish) { - List list = new ArrayList(); - Iterator it = PALRepositoryCache.getCache().iterator(); - while (it.hasNext()) { - PALRepositoryModel model = it.next(); - if (model.getWsId().equals(wsId) && category.contains(model.getMethodId())) { - boolean flag = !isUse || model.isUse(); - if (isPublish && !model.isPublish()) { - flag = false; - } - if (flag) { - list.add(model); - } - } - } - return list; - } - - /** - * 得到指定权限的树节点并重新生成树节点 - * - * @param wsId 流程库ID - * @param teamId 小组id - * @param category 建模方法 如process  - * @return list - */ - public List getAccessPALFile(String wsId, String teamId, String userId, String category) { - List modelList = getAccessPalModel(wsId, teamId, userId, category); - List> list = new ArrayList>(); - for (int i = 0, size = modelList.size(); i < size; i++) { - forEachList(wsId, teamId, userId, modelList, list, i); // 得到有权限的节点 - } - return createResult(list); - } - - /** - * 得到指定权限的树节点并重新生成树节点 - * - * @param wsid 流程库ID - * @param category 建模方法 如process  - * @return list - */ - public List getAccessPALFile(String wsid, String category) { - List modelList = null; - List> list = new ArrayList>(); - modelList = getAccessPALFileByWsid(wsid, category); - Map tempMap = new HashMap(); - for (int i = 0, size = modelList.size(); i < size; i++) { - PALRepositoryModel m = modelList.get(i); - tempMap.put(m.getId(), m); - } - for (int i = 0, size = modelList.size(); i < size; i++) { - eachList(wsid, tempMap, modelList, list, i); // 得到有权限的节点 - } - return createResult(list); - } - - /** - * 得到指定权限的树节点并重新生成树节点 - * - * @param wsid 流程库ID - * @param category 建模方法 如process  - * @return list - */ - public List getAccessPALFile1(String wsid, String category, boolean isUse, boolean isPublish) { - List modelList = null; - List> list = new ArrayList>(); - modelList = getRepositoryModelByWsid1(wsid, category, isUse, isPublish); - Map tempMap = new HashMap(); - for (int i = 0, size = modelList.size(); i < size; i++) { - PALRepositoryModel m = modelList.get(i); - tempMap.put(m.getVersionId(), m); - } - for (int i = 0, size = modelList.size(); i < size; i++) { - eachList(wsid, tempMap, modelList, list, i); // 得到有权限的节点 - } - return createResult(list); - } - - private List createResult(List> list) { - List> softList = new ArrayList>(); - Map map = new HashMap(); - Set parentIds = getSoftList(list, softList, map);// 得到是父级的节点 - Set keys = map.keySet(); - List result = new ArrayList(); - for (String key : keys) { - resultModel(map, parentIds, result, key);// 汇总结果 - } - Collections.sort(result, new Comparator1()); - return result; - } - - private void resultModel(Map map, Set parentIds, List result, String key) { - PALRepositoryModelImpl m = map.get(key); - if (parentIds.contains(key)) { - m.setPublish(true); - } - if (m.getId().length() < 16) { - m.setLevel(-1); - } - result.add(m); - } - - private String addModelToList(ArrayList models, List modelList, int i) { - PALRepositoryModel coeProcessLevelModel = modelList.get(i); - models.add(coeProcessLevelModel); - return coeProcessLevelModel.getParentId(); - } - - private void forEachList(String wsid, String teamId, String userId, List modelList, List> list, int i) { - ArrayList models = new ArrayList(); - String ruuid = addModelToList(models, modelList, i); - Set permVerIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsid, teamId, userId, null, null); - PALRepositoryModel model; - while (true) { - model = PALRepositoryCache.getCache().get(ruuid); - if (model != null) { - if (permVerIds.contains(model.getVersionId())) { - models.add(model); - } - ruuid = model.getParentId(); - } else { - if (ruuid.length() < 36) { - createModelValue(models, ruuid); - } - break; - } - } - list.add(models); - } - - private void createModelValue(ArrayList models, String ruuid) { - PALRepositoryModelImpl cplm = new PALRepositoryModelImpl(); - cplm.setId(ruuid); - cplm.setName(ruuid); - models.add(cplm); - } - - private void eachList(String wsid, Map tempMap, List modelList, List> list, int i) { - ArrayList models = new ArrayList(); - String ruuid = addModelToList(models, modelList, i); - PALRepositoryModel model; - while (true) { - model = PALRepositoryCache.getCache().get(ruuid); - if (model != null) { - if (tempMap.get(model.getVersionId()) != null && model.isUse()) { - models.add(model); - } - ruuid = model.getParentId(); - } else { - if (ruuid.length() < 36) { - createModelValue(models, ruuid); - } - break; - } - } - list.add(models); - } - - private Set getSoftList(List> list, List> softList, Map map) { - for (ArrayList arrayList : list) { - ArrayList subList = new ArrayList(); - for (PALRepositoryModel palRepositoryModel : arrayList) { - addSubList(subList, palRepositoryModel); - } - softList.add(subList); - } - Set parentIds = new HashSet(); - for (ArrayList arrayList : softList) { - Collections.sort(arrayList, new ComparatorLevel()); - for (PALRepositoryModelImpl palRepositoryModel : arrayList) { - parentIds.add(palRepositoryModel.getParentId()); - map.put(palRepositoryModel.getId(), palRepositoryModel); - } - } - return parentIds; - } - - /** - * 创建新的节点对象 - * - * @param subList - * @param palRepositoryModel - */ - private void addSubList(ArrayList subList, PALRepositoryModel palRepositoryModel) { - PALRepositoryModelImpl model = new PALRepositoryModelImpl(); - model.setId(palRepositoryModel.getId()); - model.setParentId(palRepositoryModel.getParentId()); - model.setName(palRepositoryModel.getName()); - model.setLevel(palRepositoryModel.getLevel()); - model.setMethodCategory(palRepositoryModel.getMethodCategory()); - model.setMethodId(palRepositoryModel.getMethodId()); - model.setVersion(palRepositoryModel.getVersion()); - subList.add(model); - } - - /** - * 生成后的树模型组建 - * - * @param methodType 建模方法大类 - * @param wsid 流程库id - * @param jsonArray  jsonArray数组 - * @param teamId 小组id - */ - public void createTreeModel(String methodType, String wsid, JSONArray jsonArray, String teamId, String userId) { - List list = getAccessPALFile(wsid, teamId, methodType, userId); - createTreeModelForEach(methodType, jsonArray, list); - } - - /** - * 生成后的树模型组建 - * - * @param methodType 建模方法大类 - * @param wsid 流程库id - * @param jsonArray  jsonArray数组 - */ - public void createTreeModel1(String methodType, String wsid, JSONArray jsonArray, boolean isUse, boolean isPublish) { - List list = getAccessPALFile1(wsid, methodType, isUse, isPublish); - createTreeModelForEach(methodType, jsonArray, list); - } - - /** - * 生成后的树模型组建 - * - * @param methodType 建模方法大类 - * @param wsid 流程库id - * @param jsonArray  jsonArray数组 - * @param versionType 工作版本或发布版本 - */ - public void createTreeModelByVersionType(String methodType, String wsid, JSONArray jsonArray, String versionType) { - List list = getAccessPALFile(wsid, methodType); - if (list != null) { - if (versionType != null && !"".equals(versionType)) { - for (PALRepositoryModel model : list) { - if ("isUsed".equals(versionType) && !model.isUse()) { - list.remove(model); - break; - } - if ("isPublish".equals(versionType) && !model.isPublish()) { - list.remove(model); - break; - } - } - } - } - createTreeModelForEach(methodType, jsonArray, list); - } - - public void createTreeModelForEach(String methodType, JSONArray jsonArray, List list) { - for (PALRepositoryModel model : list) { - JSONObject json = new JSONObject(); - json.put("id", model.getId()); - json.put("name", I18nRes.findValue(CoEConstant.APP_ID, model.getName())); - if (model.getId().length() < 16) { - if ("process.bpmn2,process.epc,process.flowchart".equals(methodType)) { - json.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + model.getMethodId() + "/process.png"); - - } else - json.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + model.getMethodId() + "/" + methodType + ".png"); - } else { - json.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + model.getMethodId() + "/16.png"); - json.put("fileType", I18nRes.findValue(CoEConstant.APP_ID, model.getMethodId())); - json.put("fileVersion", VersionUtil.getVersionStrV(model.getVersion())); - } - if (model.getMethodId().contains("epc")) { - json.put("icon", "../apps/com.actionsoft.apps.coe.method.process.epc/img/method/" + model.getMethodId() + "/16.png"); - } - if (model.getMethodId().contains("flowchart")) { - json.put("icon", "../apps/com.actionsoft.apps.coe.method.process.flowchart/img/method/process.flowchart/16.png"); - } - if (model.isPublish()) { - json.put("open", false); - if (model.getId().length() < 16) { - json.put("open", true); - } - } - if (model.getParentId() != null) { - json.put("pid", model.getParentId()); - } - jsonArray.add(json); // 加载根 - } - } - - /** - * 得到指定权限范围内的树节点 - * - * @param jsonArray - * @param methodType  建模方法大类 - * @param wsId  流程库id - * @param versionType 版本类型 - * @param teamId 小组id - * @return - */ - public JSONArray getLimitPALTree(JSONArray jsonArray, String methodType, String wsId, String versionType, String teamId, String userId) { - if ("process.bpmn2,process.epc,process.flowchart".equals(methodType) || "process".equals(methodType)) { - createTreeModel("process", wsId, jsonArray, teamId, userId); - } else { - createTreeModel(methodType, wsId, jsonArray, teamId, userId); - } - return jsonArray; - } - - /** - * 得到指定权限范围内的树节点 - * - * @param jsonArray  - * @param methodType 建模方法大类 - * @param wsid 流程库Id - * @param versionType 版本类型 - * @return - */ - public JSONArray getLimitPALTree(JSONArray jsonArray, String methodType, String wsid, String versionType) { - if ("process.bpmn2,process.epc,process.flowchart".equals(methodType) || "process".equals(methodType)) { - boolean isUsed = false; - boolean isPublish = false; - if ("isUsed".equals(versionType)) { - isUsed = true; - } else if ("isPublish".equals(versionType)) { - isPublish = true; - } - createTreeModel1("process.bpmn2,process.epc,process.flowchart", wsid, jsonArray, isUsed, isPublish); - } else { - createTreeModelByVersionType(methodType, wsid, jsonArray, versionType); - } - return jsonArray; - } - - /** - * 得到当前流程库能访问到的授权节点如果没有授权则得到所有的 - * - * @param wsid 流程库Id - * @param category 建模方法大 - * @return - */ - public List getAccessPALFileByWsid(String wsid, String category) { - /* List list = new ArrayList(); - * Iterator it = TeamPermCache.getTeamListByWsId(wsid); - * while (it.hasNext()) { TeamPermModel perModel = it.next(); - * PALRepositoryModelImpl model = (PALRepositoryModelImpl) - * PALRepositoryCache.getCache().get(perModel.getResourceId()); if - * (model.getMethodCategory().equals(category)) list.add(model); } */ - // if (list.isEmpty()) { - return getRepositoryModelByWsid(wsid, category); - // } else { - // return getResultByWsid(list); - // } - } - - private List getResultByWsid(List list) { - List result = new ArrayList(); - Map map = new HashMap(); - for (PALRepositoryModel m : list) { - map.put(m.getId(), m); - } - Set set = map.keySet(); - for (String key : set) { - result.add(map.get(key)); - } - return result; - } - - /** - * 判断资产库是否暂停 - * - * @return - */ - public boolean isActiveWorkSpace(String wsid) { - return new CoeWorkSpace().isActiveWorkSpace(wsid); - } - - /** - * 获取流程资产库下所有流程 - * - * @param wsId 流程库id - * @return - */ - public List getPalRepositoryModelsByWsId(String wsId) { - List list = new ArrayList(); - Iterator pals = PALRepositoryCache.getByWsId(wsId); - while (pals.hasNext()) { - PALRepositoryModel model = pals.next(); - list.add(model); - } - return list; - } - - /** - * 获取某个流程的所有子流程 - * - * @param wsId - * @param pid - * @return - */ - public List getPalRepositoryModelsByPid(String wsId, String pid) { - List list = new ArrayList(); - - List repositoryModelList = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); - if (repositoryModelList != null) { - for (PALRepositoryModel model : repositoryModelList) { - try { - PALRepositoryModelImpl newModel = ((PALRepositoryModelImpl) model).clone(); - newModel.setNewParentId(pid); - list.add(newModel); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - } - } - return list; - } - - public List getPalRepositoryModelsByPidRole(String wsId, String pid,String ruuid) { - List list = new ArrayList(); - - List repositoryModelList = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); - if (repositoryModelList != null) { - for (PALRepositoryModel model : repositoryModelList) { - try { - PALRepositoryModelImpl newModel = ((PALRepositoryModelImpl) model).clone(); - newModel.setNewParentId(pid); - list.add(newModel); - - - - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - } - } - - List data = new ArrayList(); - data.add(0, "org.role"); - data.add(1, ruuid); - RowMap rowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", data.toString()); - if (rowMap != null) { - PALRepositoryModel roleModel = PALRepositoryCache.getCache().get(rowMap.getString("ID")); - list.add(roleModel); - } - return list; - } - - - public void getAllPalRepositoryModelsByPid(String wsId, String pid, List list) { - List children = getPalRepositoryModelsByPid(wsId, pid); - if (children != null && children.size() > 0) { - list.addAll(children); - } - for (PALRepositoryModel model : children) { - getAllPalRepositoryModelsByPid(wsId, model.getId(), list); - } - } - - /**************************************************** 获取所有流程 *****************************************************/ - - /** - * 获取某个小组的成员有权限的流程 - * @param wsId - * @param userId - * @param teamId - * @param isUsed - * @param isPublished - * @return - */ - public List getPalRepositoryModelsByTeamId(String wsId, String userId, String teamId, boolean isUsed, boolean isPublished) { - List list = CoeProcessLevelUtil.getPermRepositoryList(wsId, teamId, userId, null, null, isUsed, isPublished); - return list; - } - - /** - * 获取流程资产库下所有使用中的流程 - * - * @param wsId 流程库id - * @return - */ - public List getUsedPalRepositoryModelsByWsId(String wsId, String methodId) { - List list = new ArrayList(); - - Iterator pals = PALRepositoryCache.getByWsId(wsId); - while (pals.hasNext()) { - PALRepositoryModel model = pals.next(); - if (model.isUse()) { - if (methodId != null && !"".equals(methodId)) { - if (methodId.indexOf(".") != -1) { - if (model.getMethodId().equals(methodId)) { - list.add(model); - } - } else { - if (model.getMethodCategory().equals(methodId)) { - list.add(model); - } - } - } else { - list.add(model); - } - } - } - return list; - } - - /** - * 获取资产库下的流程 - * @param wsId - * @param methodId - * @return - */ - public List getPalRepositoryModelsByWsIdAndMethodId(String wsId, String methodId) { - List list = new ArrayList(); - Iterator pals = PALRepositoryCache.getByWsId(wsId); - while (pals.hasNext()) { - PALRepositoryModel model = pals.next(); - if (methodId != null && !UtilString.isEmpty(methodId)) { - if (methodId.indexOf(".") != -1) { - if (model.getMethodId().equals(methodId)) { - list.add(model); - } - } else { - if (model.getMethodCategory().equals(methodId)) { - list.add(model); - } - } - } else { - list.add(model); - } - } - return list; - } - - /** - * 获取某个流程的使用中的子流程 - * - * @param wsId - * @param pid - * @return - */ - public List getUsedPalRepositoryModelsByPid(String wsId, String pid) { - List list = getPalRepositoryModelsByPid(wsId, pid); - List removeList = new ArrayList(); - if (list != null) { - for (PALRepositoryModel model : list) { - if (!model.isUse()) { - removeList.add(model); - } - } - } - list.removeAll(removeList); - Collections.sort(list, new Comparator1()); - return list; - } - - - - public List getUsedPalRepositoryModelsByPidRole(String wsId, String pid,String ruuid) { - List list = getPalRepositoryModelsByPidRole(wsId, pid,ruuid); - List removeList = new ArrayList(); - if (list != null) { - for (PALRepositoryModel model : list) { - if (!model.isUse()) { - removeList.add(model); - } - if(model.getName().equals("岗位模型")){ - removeList.add(model); - } - - } - } - list.removeAll(removeList); - //Collections.sort(list, new Comparator1()); + private PALRepositoryQueryAPIManager() { + } + + public static PALRepositoryQueryAPIManager getInstance() { + return PALRepositoryQueryAPIManager.Inner.instance; + } + + /** + * 得到缓存中所有的流程文件 + * + * @return 一个查询结果集 + */ + public List getPALRepositoryModelList() { + List list = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + while (it.hasNext()) { + list.add(it.next()); + } + return list; + } + + /** + * 得到缓存中指定流程库的流程文件 + * + * @return 一个查询结果集 + */ + public List getPALRepositoryModelList(String wsId) { + List list = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (model.getWsId().equals(wsId)) + list.add(model); + } + if (wsId != null) { + List list1 = new ArrayList(); + for (PALRepositoryModel model : list) { + if (wsId.equals(model.getWsId())) { + list1.add(model); + } + } + return list1; + } + return list; + } + + /** + * 执行查询,返回结果集 + * + * @param sortType + * @param orderByField + * @param wsId + * @param map + * @return 一个查询结果集 + */ + public List list(boolean sortType, String orderByField, String wsId, Map map) { + Iterator it = PALRepositoryCache.getCache().iterator(); + List list = new ArrayList(); + if (map.size() > 0) { + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (isExistModel(model, map)) { + list.add(model); + } + } + if (wsId != null) { + List list1 = new ArrayList(); + for (PALRepositoryModel model : list) { + if (wsId.equals(model.getWsId())) { + list1.add(model); + } + } + return list1; + } + return list; + } else { + list = getPALRepositoryModelList(wsId); + } + return list; + } + + /** + * 对查询结果进行排序 + * + * @param list + * @param sortType + * @param orderByField + */ + private void orderByFieldName(List list, String sortType, String orderByField) { + + } + + private boolean isExistModel(PALRepositoryModel model, Map map) { + Map map1 = new HashMap(); + map1.put("parentId", model.getParentId()); + map1.put("fileId", model.getId()); + map1.put("fileNo", model.getNo()); + map1.put("fileName", model.getName()); + map1.put("version", model.getVersion()); + map1.put("fileLevel", model.getLevel()); + map1.put("fileDesc", model.getDesc()); + map1.put("fileInput", model.getInput()); + map1.put("fileOutput", model.getOutput()); + map1.put("fileOwnerUser", model.getOwnerUser()); + map1.put("fileOwnerDept", model.getOwnerDept()); + map1.put("fileExecType", model.getExecType()); + map1.put("fileSystemName", model.getSystemName()); + map1.put("fileColor", model.getColor()); + map1.put("fileMethodCategory", model.getMethodCategory()); + map1.put("fileMethodId", model.getMethodId()); + map1.put("fileIsUse", model.isUse()); + map1.put("fileIsPublish", model.isPublish()); + map1.put("fileIsSystem", model.isSystemFile()); + map1.put("wsId", model.getWsId()); + Iterator it = map.keySet().iterator(); + Set set = new HashSet(2); + while (it.hasNext()) { + String key = it.next(); + Object obj = map.get(key); + if (obj == null) { + continue; + } + String className = obj.getClass().getName(); + className = className.substring(className.lastIndexOf(".") + 1); + queryResult(map1, set, key, obj, className); + } + if (set.size() > 1) { + return false; + } else return set.size() == 1 && set.contains(true); + } + + private void queryResult(Map map1, Set set, String key, Object obj, String className) { + if ("Integer".equals(className)) { + int i = (Integer) obj; + set.add(i == (Integer) map1.get(key)); + } else if ("Boolean".equals(className)) { + boolean b = (Boolean) obj; + set.add(b == (Boolean) map1.get(key)); + } else if ("String".equals(className)) { + String str = (String) map1.get(key); + if (str != null) { + set.add(str.contains((String) obj)); + } + } else if (className.toLowerCase().contains("list")) { + List list = (List) obj; + Object obj1 = map1.get(key); + if (list.size() > 0) { + set.add(list.contains(obj1)); + } + } + } + + /** + * 根据wsId过滤流程 + * + * @param wsId + * @return + */ + public List getRepositoryModelToList(String wsId) { + List list = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (model.getWsId().equals(wsId)) { + list.add((PALRepositoryModelImpl) model); + } + } + return list; + } + + public List getJsonToList(String pid, String wsId, String language, String methodType) { + List listJsonArr = new ArrayList(); + List list = getRepositoryModelToList(wsId); + for (PALRepositoryModelImpl model : list) { + if (model.getParentId() != null && !"".equals(model.getParentId()) && model.getParentId().equals(pid) && (model.getMethodId().contains(methodType) || methodType.contains(model.getMethodId()))) { + listJsonArr.add(getJSon(model, language, isParent(model.getId(), list))); + } + } + return listJsonArr; + } + + /** + * 根据wsId过滤流程并生成json + * + * @param wsId + * @return + */ + public JSONArray getRepositoryModelToJson(String wsId, String language) { + List list = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + JSONArray jsonArray = new JSONArray(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (model.getWsId().equals(wsId)) { + list.add((PALRepositoryModelImpl) model); + } + } + for (PALRepositoryModelImpl models : list) { + putAllNodeJsonToJsonArr(models.getId(), jsonArray, language, list); + } + return jsonArray; + } + + /** + * 根据wsId过滤流程并生成json + * + * @param wsId + * @return + */ + public List getRepositoryModelToJson(String wsId, String language, String methodId) { + List list = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + List listJsonArr = new ArrayList(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (model.getWsId().equals(wsId) && model.getMethodId().contains(methodId)) { + list.add((PALRepositoryModelImpl) model); + } + } + for (PALRepositoryModelImpl models : list) { + putAllNodeJson(models.getId(), listJsonArr, language, list); + } + return listJsonArr; + } + + private void putAllNodeJsonToJsonArr(String id, JSONArray jsonArray, String language, List models) { + for (int i = 0, size = models.size(); i < size; i++) { + PALRepositoryModel model = models.get(i); + String parentId = model.getParentId(); + if (parentId != null && !"".equals(parentId) && parentId.equals(id)) { + JSONObject json = getJSon(model, language, isParent(id, models)); + jsonArray.add(json); + } + } + } + + private void putAllNodeJson(String id, List jsonArray, String language, List models) { + for (int i = 0, size = models.size(); i < size; i++) { + PALRepositoryModel model = models.get(i); + String parentId = model.getParentId(); + if (parentId != null && !"".equals(parentId) && parentId.equals(id)) { + JSONObject json = getJSon(model, language, isParent(id, models)); + jsonArray.add(json); + } + } + } + + private boolean isParent(String id, List models) { + for (PALRepositoryModelImpl model : models) { + String parentId = model.getParentId(); + if (parentId != null && !"".equals(parentId) && parentId.equals(id)) { + return true; + } + } + return false; + } + + /** + * 获取tree json + * + * @param model + * @param language + * @param flag + * @return + */ + private JSONObject getJSon(PALRepositoryModel model, String language, boolean flag) { + JSONObject rootJson = new JSONObject(); + rootJson.put("id", model.getId().trim()); + rootJson.put("pid", model.getParentId().trim()); + rootJson.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + rootJson.put("name", I18nRes.findValue(CoEConstant.APP_ID, language, model.getName()).trim()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + rootJson.put("title", rootJson.get("name")); + } else { + rootJson.put("title", rootJson.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + rootJson.put("drop", false); + rootJson.put("isSystemFile", model.isSystemFile()); + rootJson.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) { + rootJson.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/default/16.png"); + } else { + rootJson.put("icon", "../apps/" + PALMethodCache.getPALMethodModelById(model.getMethodId()).getApp().getId() + "/img/method/" + model.getMethodId() + "/16.png"); + } + if (flag) { + rootJson.put("isParent", true); + rootJson.put("open", false); + } + rootJson.put("plLevel", model.getLevel()); + rootJson.put("plOrdexIndex", model.getOrderIndex()); + rootJson.put("plCategory", model.getMethodCategory()); + return rootJson; + } + + /** + * 得到给定范围内的流程文件 + * + * @param str 格式 id,id,id,id + * @return + */ + public List getFileList(String str) { + List newList = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (str.contains(model.getId())) { + newList.add(model); + } + } + return newList; + } + + /** + * 根据父id得到子节点 + * + * @param pid + * @return + */ + public List getSubList(String pid) { + List newList = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (pid.equals(model.getParentId())) { + newList.add(model); + } + } + return newList; + + } + + /** + * 获得小组可访问的使用中的资产库文件 + * + * @param teamId 小组Id + * @param wsId 资产库Id + * @return 库文件集合 + */ + public List getHavingRepositoryAccessList(String wsId, String teamId, String userId) { + return CoeProcessLevelUtil.getPermRepositoryList(wsId, teamId, userId, null, null, true, false); + } + + /** + * 得到可以访问的流程节点 + * + * @param wsid  流程库ID + * @param teamId 小组id + * @param category 建模方法 如process + */ + public List getAccessPalModel(String wsid, String teamId, String userId, String category) { + return CoeProcessLevelUtil.getPermRepositoryList(wsid, teamId, userId, category, null, true, false); + } + + /** + * 得到当前工作空间下的流程节点 + * + * @param wsId + * @return + */ + public List getRepositoryModelByWsid(String wsId) { + List list = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (model.getWsId().equals(wsId) && model.isUse()) { + list.add(model); + } + } + return list; + } + + /** + * 得到当前工作空间下的流程节点 + * + * @param wsId + * @return + */ + public List getRepositoryModelByWsid(String wsId, String category) { + List list = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (model.getWsId().equals(wsId) && model.getMethodCategory().equals(category)) { + list.add(model); + } + } + return list; + } + + /** + * 得到当前工作空间下的流程节点 + * + * @param wsId + * @return + */ + public List getRepositoryModelByWsid1(String wsId, String category, boolean isUse, boolean isPublish) { + List list = new ArrayList(); + Iterator it = PALRepositoryCache.getCache().iterator(); + while (it.hasNext()) { + PALRepositoryModel model = it.next(); + if (model.getWsId().equals(wsId) && category.contains(model.getMethodId())) { + boolean flag = !isUse || model.isUse(); + if (isPublish && !model.isPublish()) { + flag = false; + } + if (flag) { + list.add(model); + } + } + } + return list; + } + + /** + * 得到指定权限的树节点并重新生成树节点 + * + * @param wsId  流程库ID + * @param teamId 小组id + * @param category 建模方法 如process + * @return list + */ + public List getAccessPALFile(String wsId, String teamId, String userId, String category) { + List modelList = getAccessPalModel(wsId, teamId, userId, category); + List> list = new ArrayList>(); + for (int i = 0, size = modelList.size(); i < size; i++) { + forEachList(wsId, teamId, userId, modelList, list, i); // 得到有权限的节点 + } + return createResult(list); + } + + /** + * 得到指定权限的树节点并重新生成树节点 + * + * @param wsid  流程库ID + * @param category 建模方法 如process + * @return list + */ + public List getAccessPALFile(String wsid, String category) { + List modelList = null; + List> list = new ArrayList>(); + modelList = getAccessPALFileByWsid(wsid, category); + Map tempMap = new HashMap(); + for (int i = 0, size = modelList.size(); i < size; i++) { + PALRepositoryModel m = modelList.get(i); + tempMap.put(m.getId(), m); + } + for (int i = 0, size = modelList.size(); i < size; i++) { + eachList(wsid, tempMap, modelList, list, i); // 得到有权限的节点 + } + return createResult(list); + } + + /** + * 得到指定权限的树节点并重新生成树节点 + * + * @param wsid  流程库ID + * @param category 建模方法 如process + * @return list + */ + public List getAccessPALFile1(String wsid, String category, boolean isUse, boolean isPublish) { + List modelList = null; + List> list = new ArrayList>(); + modelList = getRepositoryModelByWsid1(wsid, category, isUse, isPublish); + Map tempMap = new HashMap(); + for (int i = 0, size = modelList.size(); i < size; i++) { + PALRepositoryModel m = modelList.get(i); + tempMap.put(m.getVersionId(), m); + } + for (int i = 0, size = modelList.size(); i < size; i++) { + eachList(wsid, tempMap, modelList, list, i); // 得到有权限的节点 + } + return createResult(list); + } + + private List createResult(List> list) { + List> softList = new ArrayList>(); + Map map = new HashMap(); + Set parentIds = getSoftList(list, softList, map);// 得到是父级的节点 + Set keys = map.keySet(); + List result = new ArrayList(); + for (String key : keys) { + resultModel(map, parentIds, result, key);// 汇总结果 + } + Collections.sort(result, new Comparator1()); + return result; + } + + private void resultModel(Map map, Set parentIds, List result, String key) { + PALRepositoryModelImpl m = map.get(key); + if (parentIds.contains(key)) { + m.setPublish(true); + } + if (m.getId().length() < 16) { + m.setLevel(-1); + } + result.add(m); + } + + private String addModelToList(ArrayList models, List modelList, int i) { + PALRepositoryModel coeProcessLevelModel = modelList.get(i); + models.add(coeProcessLevelModel); + return coeProcessLevelModel.getParentId(); + } + + private void forEachList(String wsid, String teamId, String userId, List modelList, List> list, int i) { + ArrayList models = new ArrayList(); + String ruuid = addModelToList(models, modelList, i); + Set permVerIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsid, teamId, userId, null, null); + PALRepositoryModel model; + while (true) { + model = PALRepositoryCache.getCache().get(ruuid); + if (model != null) { + if (permVerIds.contains(model.getVersionId())) { + models.add(model); + } + ruuid = model.getParentId(); + } else { + if (ruuid.length() < 36) { + createModelValue(models, ruuid); + } + break; + } + } + list.add(models); + } + + private void createModelValue(ArrayList models, String ruuid) { + PALRepositoryModelImpl cplm = new PALRepositoryModelImpl(); + cplm.setId(ruuid); + cplm.setName(ruuid); + models.add(cplm); + } + + private void eachList(String wsid, Map tempMap, List modelList, List> list, int i) { + ArrayList models = new ArrayList(); + String ruuid = addModelToList(models, modelList, i); + PALRepositoryModel model; + while (true) { + model = PALRepositoryCache.getCache().get(ruuid); + if (model != null) { + if (tempMap.get(model.getVersionId()) != null && model.isUse()) { + models.add(model); + } + ruuid = model.getParentId(); + } else { + if (ruuid.length() < 36) { + createModelValue(models, ruuid); + } + break; + } + } + list.add(models); + } + + private Set getSoftList(List> list, List> softList, Map map) { + for (ArrayList arrayList : list) { + ArrayList subList = new ArrayList(); + for (PALRepositoryModel palRepositoryModel : arrayList) { + addSubList(subList, palRepositoryModel); + } + softList.add(subList); + } + Set parentIds = new HashSet(); + for (ArrayList arrayList : softList) { + Collections.sort(arrayList, new ComparatorLevel()); + for (PALRepositoryModelImpl palRepositoryModel : arrayList) { + parentIds.add(palRepositoryModel.getParentId()); + map.put(palRepositoryModel.getId(), palRepositoryModel); + } + } + return parentIds; + } + + /** + * 创建新的节点对象 + * + * @param subList + * @param palRepositoryModel + */ + private void addSubList(ArrayList subList, PALRepositoryModel palRepositoryModel) { + PALRepositoryModelImpl model = new PALRepositoryModelImpl(); + model.setId(palRepositoryModel.getId()); + model.setParentId(palRepositoryModel.getParentId()); + model.setName(palRepositoryModel.getName()); + model.setLevel(palRepositoryModel.getLevel()); + model.setMethodCategory(palRepositoryModel.getMethodCategory()); + model.setMethodId(palRepositoryModel.getMethodId()); + model.setVersion(palRepositoryModel.getVersion()); + subList.add(model); + } + + /** + * 生成后的树模型组建 + * + * @param methodType  建模方法大类 + * @param wsid  流程库id + * @param jsonArray   jsonArray数组 + * @param teamId  小组id + */ + public void createTreeModel(String methodType, String wsid, JSONArray jsonArray, String teamId, String userId) { + List list = getAccessPALFile(wsid, teamId, methodType, userId); + createTreeModelForEach(methodType, jsonArray, list); + } + + /** + * 生成后的树模型组建 + * + * @param methodType  建模方法大类 + * @param wsid  流程库id + * @param jsonArray   jsonArray数组 + */ + public void createTreeModel1(String methodType, String wsid, JSONArray jsonArray, boolean isUse, boolean isPublish) { + List list = getAccessPALFile1(wsid, methodType, isUse, isPublish); + createTreeModelForEach(methodType, jsonArray, list); + } + + /** + * 生成后的树模型组建 + * + * @param methodType  建模方法大类 + * @param wsid  流程库id + * @param jsonArray   jsonArray数组 + * @param versionType  工作版本或发布版本 + */ + public void createTreeModelByVersionType(String methodType, String wsid, JSONArray jsonArray, String versionType) { + List list = getAccessPALFile(wsid, methodType); + if (list != null) { + if (versionType != null && !"".equals(versionType)) { + for (PALRepositoryModel model : list) { + if ("isUsed".equals(versionType) && !model.isUse()) { + list.remove(model); + break; + } + if ("isPublish".equals(versionType) && !model.isPublish()) { + list.remove(model); + break; + } + } + } + } + createTreeModelForEach(methodType, jsonArray, list); + } + + public void createTreeModelForEach(String methodType, JSONArray jsonArray, List list) { + for (PALRepositoryModel model : list) { + JSONObject json = new JSONObject(); + json.put("id", model.getId()); + json.put("name", I18nRes.findValue(CoEConstant.APP_ID, model.getName())); + if (model.getId().length() < 16) { + if ("process.bpmn2,process.epc,process.flowchart".equals(methodType)) { + json.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + model.getMethodId() + "/process.png"); + + } else + json.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + model.getMethodId() + "/" + methodType + ".png"); + } else { + json.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + model.getMethodId() + "/16.png"); + json.put("fileType", I18nRes.findValue(CoEConstant.APP_ID, model.getMethodId())); + json.put("fileVersion", VersionUtil.getVersionStrV(model.getVersion())); + } + if (model.getMethodId().contains("epc")) { + json.put("icon", "../apps/com.actionsoft.apps.coe.method.process.epc/img/method/" + model.getMethodId() + "/16.png"); + } + if (model.getMethodId().contains("flowchart")) { + json.put("icon", "../apps/com.actionsoft.apps.coe.method.process.flowchart/img/method/process.flowchart/16.png"); + } + if (model.isPublish()) { + json.put("open", false); + if (model.getId().length() < 16) { + json.put("open", true); + } + } + if (model.getParentId() != null) { + json.put("pid", model.getParentId()); + } + jsonArray.add(json); // 加载根 + } + } + + /** + * 得到指定权限范围内的树节点 + * + * @param jsonArray + * @param methodType  建模方法大类 + * @param wsId  流程库id + * @param versionType 版本类型 + * @param teamId 小组id + * @return + */ + public JSONArray getLimitPALTree(JSONArray jsonArray, String methodType, String wsId, String versionType, String teamId, String userId) { + if ("process.bpmn2,process.epc,process.flowchart".equals(methodType) || "process".equals(methodType)) { + createTreeModel("process", wsId, jsonArray, teamId, userId); + } else { + createTreeModel(methodType, wsId, jsonArray, teamId, userId); + } + return jsonArray; + } + + /** + * 得到指定权限范围内的树节点 + * + * @param jsonArray + * @param methodType  建模方法大类 + * @param wsid  流程库Id + * @param versionType 版本类型 + * @return + */ + public JSONArray getLimitPALTree(JSONArray jsonArray, String methodType, String wsid, String versionType) { + if ("process.bpmn2,process.epc,process.flowchart".equals(methodType) || "process".equals(methodType)) { + boolean isUsed = false; + boolean isPublish = false; + if ("isUsed".equals(versionType)) { + isUsed = true; + } else if ("isPublish".equals(versionType)) { + isPublish = true; + } + createTreeModel1("process.bpmn2,process.epc,process.flowchart", wsid, jsonArray, isUsed, isPublish); + } else { + createTreeModelByVersionType(methodType, wsid, jsonArray, versionType); + } + return jsonArray; + } + + /** + * 得到当前流程库能访问到的授权节点如果没有授权则得到所有的 + * + * @param wsid  流程库Id + * @param category 建模方法大 + * @return + */ + public List getAccessPALFileByWsid(String wsid, String category) { + /* List list = new ArrayList(); + * Iterator it = TeamPermCache.getTeamListByWsId(wsid); + * while (it.hasNext()) { TeamPermModel perModel = it.next(); + * PALRepositoryModelImpl model = (PALRepositoryModelImpl) + * PALRepositoryCache.getCache().get(perModel.getResourceId()); if + * (model.getMethodCategory().equals(category)) list.add(model); } */ + // if (list.isEmpty()) { + return getRepositoryModelByWsid(wsid, category); + // } else { + // return getResultByWsid(list); + // } + } + + private List getResultByWsid(List list) { + List result = new ArrayList(); + Map map = new HashMap(); + for (PALRepositoryModel m : list) { + map.put(m.getId(), m); + } + Set set = map.keySet(); + for (String key : set) { + result.add(map.get(key)); + } + return result; + } + + /** + * 判断资产库是否暂停 + * + * @return + */ + public boolean isActiveWorkSpace(String wsid) { + return new CoeWorkSpace().isActiveWorkSpace(wsid); + } + + /** + * 获取流程资产库下所有流程 + * + * @param wsId 流程库id + * @return + */ + public List getPalRepositoryModelsByWsId(String wsId) { + List list = new ArrayList(); + Iterator pals = PALRepositoryCache.getByWsId(wsId); + while (pals.hasNext()) { + PALRepositoryModel model = pals.next(); + list.add(model); + } + return list; + } + + /** + * 获取某个流程的所有子流程 + * + * @param wsId + * @param pid + * @return + */ + public List getPalRepositoryModelsByPid(String wsId, String pid) { + List list = new ArrayList(); + + List repositoryModelList = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); + if (repositoryModelList != null) { + for (PALRepositoryModel model : repositoryModelList) { + try { + PALRepositoryModelImpl newModel = ((PALRepositoryModelImpl) model).clone(); + newModel.setNewParentId(pid); + list.add(newModel); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + } + } + return list; + } + + public List getPalRepositoryModelsByPidRole(String wsId, String pid, String ruuid) { + List list = new ArrayList(); + + List repositoryModelList = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); + if (repositoryModelList != null) { + for (PALRepositoryModel model : repositoryModelList) { + try { + PALRepositoryModelImpl newModel = ((PALRepositoryModelImpl) model).clone(); + newModel.setNewParentId(pid); + list.add(newModel); + + + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + } + } + + List data = new ArrayList(); + data.add(0, "org.role"); + data.add(1, ruuid); + RowMap rowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", data.toString()); + if (rowMap != null) { + PALRepositoryModel roleModel = PALRepositoryCache.getCache().get(rowMap.getString("ID")); + list.add(roleModel); + } + return list; + } + + + public void getAllPalRepositoryModelsByPid(String wsId, String pid, List list) { + List children = getPalRepositoryModelsByPid(wsId, pid); + if (children != null && children.size() > 0) { + list.addAll(children); + } + for (PALRepositoryModel model : children) { + getAllPalRepositoryModelsByPid(wsId, model.getId(), list); + } + } + + /**************************************************** 获取所有流程 *****************************************************/ + + /** + * 获取某个小组的成员有权限的流程 + * + * @param wsId + * @param userId + * @param teamId + * @param isUsed + * @param isPublished + * @return + */ + public List getPalRepositoryModelsByTeamId(String wsId, String userId, String teamId, boolean isUsed, boolean isPublished) { + List list = CoeProcessLevelUtil.getPermRepositoryList(wsId, teamId, userId, null, null, isUsed, isPublished); + return list; + } + + /** + * 获取流程资产库下所有使用中的流程 + * + * @param wsId 流程库id + * @return + */ + public List getUsedPalRepositoryModelsByWsId(String wsId, String methodId) { + List list = new ArrayList(); + + Iterator pals = PALRepositoryCache.getByWsId(wsId); + while (pals.hasNext()) { + PALRepositoryModel model = pals.next(); + if (model.isUse()) { + if (methodId != null && !"".equals(methodId)) { + if (methodId.indexOf(".") != -1) { + if (model.getMethodId().equals(methodId)) { + list.add(model); + } + } else { + if (model.getMethodCategory().equals(methodId)) { + list.add(model); + } + } + } else { + list.add(model); + } + } + } + return list; + } + + /** + * 获取资产库下的流程 + * + * @param wsId + * @param methodId + * @return + */ + public List getPalRepositoryModelsByWsIdAndMethodId(String wsId, String methodId) { + List list = new ArrayList(); + Iterator pals = PALRepositoryCache.getByWsId(wsId); + while (pals.hasNext()) { + PALRepositoryModel model = pals.next(); + if (methodId != null && !UtilString.isEmpty(methodId)) { + if (methodId.indexOf(".") != -1) { + if (model.getMethodId().equals(methodId)) { + list.add(model); + } + } else { + if (model.getMethodCategory().equals(methodId)) { + list.add(model); + } + } + } else { + list.add(model); + } + } + return list; + } + + /** + * 获取某个流程的使用中的子流程 + * + * @param wsId + * @param pid + * @return + */ + public List getUsedPalRepositoryModelsByPid(String wsId, String pid) { + List list = getPalRepositoryModelsByPid(wsId, pid); + List removeList = new ArrayList(); + if (list != null) { + for (PALRepositoryModel model : list) { + if (!model.isUse()) { + removeList.add(model); + } + } + } + list.removeAll(removeList); + Collections.sort(list, new Comparator1()); + return list; + } + + + public List getUsedPalRepositoryModelsByPidRole(String wsId, String pid, String ruuid) { + List list = getPalRepositoryModelsByPidRole(wsId, pid, ruuid); + List removeList = new ArrayList(); + if (list != null) { + for (PALRepositoryModel model : list) { + if (!model.isUse()) { + removeList.add(model); + } + if (model.getName().equals("岗位模型")) { + removeList.add(model); + } + + } + } + list.removeAll(removeList); + //Collections.sort(list, new Comparator1()); /*List data = new ArrayList(); data.add(0, "org.role"); @@ -1082,962 +1075,964 @@ public class PALRepositoryQueryAPIManager { list.add(roleModel); }*/ - return list; - } - - public List getUsedPalRepositoryModelsByPidRoleCorrelation(String wsId, String pid,String ruuid) { - List list = getPalRepositoryModelsByPid(wsId, pid); - List removeList = new ArrayList(); - if (list != null) { - for (PALRepositoryModel model : list) { - if (!model.isUse()) { - removeList.add(model); - } - List data = new ArrayList(); - data.add(0, "org.role"); - data.add(1, ruuid); - RowMap rowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=? AND ID=?", data.toString(),model.getId()); - if (rowMap == null) { - removeList.add(model); - } - - - } - } - list.removeAll(removeList); - Collections.sort(list, new Comparator1()); - return list; - } - - - - /**************************************************** 获取使用中的流程 *****************************************************/ - - /** - * 获取某个流程的所有使用中的子流程 - * - * @param wsId - * @param pid - * @param list - */ - public void getAllUsedPalRepositoryModelsByPid(String wsId, String pid, List list) { - List children = getUsedPalRepositoryModelsByPid(wsId, pid); - if (children != null && children.size() > 0) { - list.addAll(children); - for (PALRepositoryModel model : children) { - getAllUsedPalRepositoryModelsByPid(wsId, model.getId(), list); - } - } - } - - /** - * 通过pid获取子流程集合 - * - * @param wsId - * @param pid - * @param list - */ - public void getUsedListPalRepositoryModelsByPid(String wsId, String pid, List list) { - List children = getUsedPalRepositoryModelsByPid(wsId, pid); - if (children != null && children.size() > 0) { - list.addAll(children); - } - } - - /** - * 获取流程资产库下所有发布的流程 - * - * @param wsId 流程库id - * @return - */ - public List getPublishedPalRepositoryModelsByWsId(String wsId, String methodId) { - List list = new ArrayList(); - - Iterator pals = PALRepositoryCache.getByWsId(wsId); - while (pals.hasNext()) { - PALRepositoryModel model = pals.next(); - if (model.isPublish()) { - if (methodId != null && !"".equals(methodId)) { - if (methodId.indexOf(".") != -1) { - if (model.getMethodId().equals(methodId)) { - list.add(model); - } - } else { - if (model.getMethodCategory().equals(methodId)) { - list.add(model); - } - } - } else { - list.add(model); - } - } - } - return list; - } - - /** - * 获取某个流程的发布的子流程 - * - * @param wsId - * @param pid - * @return - */ - public List getPublishedPalRepositoryModelsByPid(String wsId, String pid) { - List list = getPalRepositoryModelsByPid(wsId, pid); - if (list != null) { - List removeList = new ArrayList(); - for (PALRepositoryModel model : list) { - if (!model.isPublish()) { - removeList.add(model); - } - } - list.removeAll(removeList); - } - - return list; - } - - /** - * 获取某个流程的所有发布的子流程 - * - * @param wsId - * @param pid - * @param list - */ - public void getAllPublishedPalRepositoryModelsByPid(String wsId, String pid, List list) { - List publishedChildren = getPublishedPalRepositoryModelsByPid(wsId, pid); - if (publishedChildren != null && publishedChildren.size() > 0) { - list.addAll(publishedChildren); - } - List children = Cache.iteratorToList(PALRepositoryCache.getByPid(wsId, pid)); - for (PALRepositoryModel model : children) { - getAllPublishedPalRepositoryModelsByPid(wsId, model.getId(), list); - } - } - - /**************************************************** 获取发布的流程 *****************************************************/ - - /** - * 获取完整流程树 - * - * @param context - * @param wsId - * @param methods - * @param type isUsed/isPublished/designer 使用中/已发布/使用中但是未发布 - * @return - */ - public JSONArray getPalRepositoryTreeData(UserContext context, String wsId, String methods, String type) { - JSONArray result = new JSONArray(); - - String[] methodArray; - if (methods == null || "".equals(methods)) { - methodArray = new String[] { "process", "org", "data", "itsystem", "control" }; - } else { - methodArray = methods.split(","); - } - - int i = 1; - Set methodSet = new HashSet(); - for (String method : methodArray) { - String category = ""; - if (method.indexOf(".") != -1) { - category = method.substring(0, method.indexOf(".")); - } else { - category = method; - } - if (methodSet.contains(category)) { - continue; - } else { - methodSet.add(category); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", category); - String name = I18nRes.findValue(CoEConstant.APP_ID, category); - jsonObject.put("name", name); - jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); - jsonObject.put("menu", false); - jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + category + "&type=0&wsid=" + wsId); - jsonObject.put("open", i == 1); - jsonObject.put("nocheck", true); - - result.add(jsonObject); - } - - List modelList = new ArrayList(); - boolean isUsed = false; - boolean isPublished = false; - if ("isUsed".equals(type) || "designer".equals(type)) { - modelList = getUsedPalRepositoryModelsByWsId(wsId, category); - isUsed = true; - } else if ("isPublished".equals(type)) { - modelList = getPublishedPalRepositoryModelsByWsId(wsId, category); - isPublished = true; - - } - StringBuilder removeIds = new StringBuilder(); - if (modelList.size() > 0) { - if (methods != null && !"".equals(methods)) { - List removeList = new ArrayList(); - for (PALRepositoryModel model : modelList) { - // 如果限制的方法是小类,需判断模型方法Id;如果限制的方法是大类,需判断模型的category - if ((method.indexOf(".") != -1 && methods.indexOf(model.getMethodId()) == -1) || (method.indexOf(".") == -1 && !method.equals(model.getMethodCategory()))) { - removeList.add(model); - removeIds.append(model.getId()).append(","); - } - } - // modelList.removeAll(removeList); - } - } - - // 若type为designer并且有数据,则过滤掉已发布的 - if("designer".equals(type) && modelList.size() > 0) { - List tempList = new ArrayList(); - for (PALRepositoryModel model : modelList) { - if (!model.isPublish()) { - tempList.add(model); - } - } - modelList = tempList; - } - - List newList = setNewPid(modelList); - Collections.sort(newList, new Comparator1()); - - result.addAll(list2Json(context, newList, isUsed, isPublished, removeIds.toString(), type)); - i++; - } - return result; - } - - /** - * 获取使用中的流程树根节点及第一级子节点 - * - * @param context - * @param wsId - * @param methods - * @param type isUsed/isPublished - * @return - */ - public JSONArray getPalRepositoryTreeRootData(UserContext context, String wsId, String methods, String type) { - JSONArray result = new JSONArray(); - - String[] methodArray; - if (methods == null || "".equals(methods)) { - methodArray = new String[] { "process", "org", "data", "itsystem", "control" }; - } else { - methodArray = methods.split(","); - } - - int i = 1; - for (String method : methodArray) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", method); - String name = I18nRes.findValue(CoEConstant.APP_ID, method); - jsonObject.put("name", name); - - jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + method + ".png"); - jsonObject.put("menu", false); - jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + method + "&type=0&wsid=" + wsId); - jsonObject.put("open", i == 1); - jsonObject.put("plCategory", method); - - - result.add(jsonObject); - if ("isUsed".equals(type)) { - result.addAll(getUsedPalRepositoryTreeDataByPid(context, wsId, method)); - } else if ("isPublished".equals(type)) { - result.addAll(getPublishedPalRepositoryTreeDataByPid(context, wsId, method)); - } - - i++; - } - - return result; - } - - /** - * 获取使用中的流程树根节点 - * - * @param uc - * @param wsId - * @param categorys - * @param teamId 小组Id - * @return - */ - public JSONArray getPalRepositoryTreeRoot(UserContext uc, String wsId, String categorys, String teamId) { - JSONArray result = new JSONArray(); - List palMethodList; - String[] categoryArray; - if (UtilString.isEmpty(categorys)) {// 不指定分类 - palMethodList = PALMethodCache.getPALMethodList(true); - if (!UtilString.isEmpty(teamId)) { - palMethodList = PALMethodCache.getPALMethodList(true); - List list = new ArrayList<>(); - List list1 = CoeProcessLevelUtil.getPermRepositoryList(wsId, teamId, uc.getUID(), null, null, true, false); - for (String str: palMethodList) { - for (PALRepositoryModel model : list1) { - if (model.getMethodCategory().equals(str)) { - list.add(str); - break; - } - } - } - palMethodList = list; - } - categoryArray = new String[palMethodList.size()]; - palMethodList.toArray(categoryArray); - } else {// 指定分类 - categoryArray = categorys.split(","); - } - for (String category : categoryArray) { - //隐藏数据字段 by zhaolei - if(category.equals("data")){ - continue; - } - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", category); - jsonObject.put("currId", category); - jsonObject.put("versionId", category); - String name = I18nRes.findValue(CoEConstant.APP_ID, category); - jsonObject.put("name", name); - JSONObject icon = new JSONObject(); - icon.put("icon", ""); - icon.put("color", "red"); - jsonObject.put("icon", icon); - jsonObject.put("plCategory", category); - jsonObject.put("plMethodId", ""); - List list = CoeProcessLevelUtil.getPermRepositoryList(wsId, teamId, uc.getUID(), category, null, true, false); - if (list != null && list.size() > 0) { - jsonObject.put("leaf", false); - } else { - jsonObject.put("leaf", true); - } - result.add(jsonObject); - } - return result; - } - - /** - * 根据pid获取使用中的流程树 - * - * @param wsId 流程库Id - * @param pid 父节点Id - * @return - */ - public JSONArray getUsedPalRepositoryTreeDataByPid(UserContext context, String wsId, String pid) { - List list = getUsedPalRepositoryModelsByPid(wsId, pid); // 根据父节点Id获取使用中的子节点 - Collections.sort(list, new Comparator1()); // 按级别排序 - JSONArray result = list2Json(context, list, true, false); - return result; - } - - /** - * 根据pid获取使用中的流程树 - * @param context - * @param wsId - * @param pid - * @param teamId - * @return - */ - public JSONArray getUsedPalRepositoryTreeDataByPid(UserContext context, String wsId, String pid,String teamId) { - List list = getUsedPalRepositoryModelsByPid(wsId, pid); // 根据父节点Id获取使用中的子节点 - Set versionIds = new HashSet<>(); - if (UtilString.isNotEmpty(teamId)){ - UserInfo userInfo = CooperationCache.getUserInfo(teamId, context.getUID()); - if (userInfo != null){ - if (userInfo.getIsAllDataPermission()) { - TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); - versionIds = teamInfo.getVersionIds(); - }else { - versionIds = userInfo.getDataPermission().keySet(); - } - } - } - if (versionIds.size() > 0){ - List modelList = new ArrayList<>(); - for (PALRepositoryModel model : list) { - if (versionIds.contains(model.getId())){ - modelList.add(model); - } - } - list = modelList; - } - Collections.sort(list, new Comparator1()); // 按级别排序 - JSONArray result = list2Json(context, list, true, false); - return result; - } - - /** - * 根据pid获取使用中的流程树(角色模型) - * - * @param wsId 流程库Id - * @param pid 父节点Id - * @return - */ - public JSONArray getUsedPalRepositoryTreeDataByPidRole(UserContext context, String wsId, String pid,String ruuid) { - List list = getUsedPalRepositoryModelsByPidRole(wsId, pid,ruuid); // 根据父节点Id获取使用中的子节点 - //Collections.sort(list, new Comparator1()); // 按级别排序 - JSONArray result = list2JsonRole(context, list, true, false,ruuid); - return result; - } - - /** - * 根据pid获取使用中的流程树(角色模型) - * @param context - * @param wsId - * @param pid - * @param ruuid - * @param teamId - * @return - */ - public JSONArray getUsedPalRepositoryTreeDataByPidRole(UserContext context, String wsId, String pid,String ruuid,String teamId) { - List list = getUsedPalRepositoryModelsByPidRole(wsId, pid,ruuid); // 根据父节点Id获取使用中的子节点 - Set versionIds = new HashSet<>(); - if (UtilString.isNotEmpty(teamId)){ - UserInfo userInfo = CooperationCache.getUserInfo(teamId, context.getUID()); - if (userInfo != null){ - if (userInfo.getIsAllDataPermission()) { - TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); - versionIds = teamInfo.getVersionIds(); - }else { - versionIds = userInfo.getDataPermission().keySet(); - } - } - } - if (versionIds.size() > 0){ - List modelList = new ArrayList<>(); - for (PALRepositoryModel model : list) { - if (versionIds.contains(model.getId())){ - modelList.add(model); - } - } - list = modelList; - } - //Collections.sort(list, new Comparator1()); // 按级别排序 - JSONArray result = list2JsonRole(context, list, true, false,ruuid); - return result; - } - /** - * - * @param context - * @param wsId - * @param pid - * @param uuid - * @return - */ - public JSONArray getUsedPalRepositoryTreeDataByPidAnduuid(UserContext context, String wsId, String pid,String attrId,String uuid,String teamId) { - Set versionIds = new HashSet<>(); - if (UtilString.isNotEmpty(teamId)){ - UserInfo userInfo = CooperationCache.getUserInfo(teamId, context.getUID()); - if (userInfo != null){ - if (userInfo.getIsAllDataPermission()) { - TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); - versionIds = teamInfo.getVersionIds(); - }else { - versionIds = userInfo.getDataPermission().keySet(); - } - } - } - List list = getUsedPalRepositoryModelsByPid(wsId, pid); // 根据父节点Id获取使用中的子节点 - if (versionIds.size() > 0){ - List modelList = new ArrayList<>(); - for (PALRepositoryModel model : list) { - if (versionIds.contains(model.getVersionId())){ - modelList.add(model); - } - } - list = modelList; - } - Collections.sort(list, new Comparator1()); // 按级别排序 - JSONArray result = list2JsonByuuid(context, list, true, false,attrId,uuid); - return result; - } - - - - /**************************************************** 获取流程树 **********************************************************/ - - /** - * 根据pid获取发布的流程树 - * - * @param wsId 流程库Id - * @param pid 父节点Id - * @return - */ - public JSONArray getPublishedPalRepositoryTreeDataByPid(UserContext context, String wsId, String pid) { - List list = getUsedPalRepositoryModelsByPid(wsId, pid); // 根据父节点Id获取使用中的子节点 - Collections.sort(list, new Comparator1()); // 按级别排序 - JSONArray result = list2Json(context, list, false, true); - - return result; - } - - /** 父节点下的所有子节点 */ - private static void recurPermChild(List repidList, List newList, String newParentId) { - if(repidList!=null) { - for( int i=0; i list = null; - boolean isUsed = false; - boolean isPublished = false; - if ("isUsed".equals(type)) { - isUsed = true; - } else if ("isPublished".equals(type)) { - isPublished = true; - } - list = getPalRepositoryModelsByTeamId(wsId, context.getUID(), teamId, isUsed, isPublished); - Collections.sort(list, new Comparator1()); // 按级别排序 - List newList = setNewPid(list); - - List categorys = PALMethodCache.getPalMehtodList(teamId, context.getUID(), isUsed, isPublished, true); - int i = 1; - for (String category : categorys) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", category); - String name = I18nRes.findValue(CoEConstant.APP_ID, category); - jsonObject.put("name", name); - jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); - jsonObject.put("menu", false); - jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + category + "&type=0&wsid=" + wsId); - jsonObject.put("open", i == 1); - result.add(jsonObject); - i++; - } - - result.addAll(list2Json(context, newList, isUsed, isPublished)); - - return result; - } - - /** - * 根据流程小组获取有权限的完整流程树 - * - * @param context - * @param wsId - * @param teamId - * @param type - * @return - */ - public JSONArray getPermPalRepositoryTreeDataByUser(UserContext context, String wsId, String teamId, String type,String uuid) { - JSONArray result = new JSONArray(); - - List list = null; - boolean isUsed = false; - boolean isPublished = false; - if ("isUsed".equals(type)) { - isUsed = true; - } else if ("isPublished".equals(type)) { - isPublished = true; - } - list = getPalRepositoryModelsByTeamId(wsId, context.getUID(), teamId, isUsed, isPublished); - Collections.sort(list, new Comparator1()); // 按级别排序 - List newList = setNewPid(list); - - List categorys = PALMethodCache.getPalMehtodList(teamId, context.getUID(), isUsed, isPublished, true); - int i = 1; - for (String category : categorys) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", category); - String name = I18nRes.findValue(CoEConstant.APP_ID, category); - jsonObject.put("name", name); - jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); - jsonObject.put("menu", false); - jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + category + "&type=0&wsid=" + wsId); - jsonObject.put("open", i == 1); - result.add(jsonObject); - i++; - } - result.addAll(list2Json(context, newList, isUsed, isPublished)); - - return result; - } - - /** - * 获取有权限以及Methods限制的完整流程树 - * - * @param context - * @param wsId - * @param teamId - * @param type - * @return - */ - public JSONArray getPermPalRepositoryTreeDataByMethods(UserContext context, String wsId, String teamId, String type, String methods) { - JSONArray result = new JSONArray(); - - List list = null; - boolean isUsed = false; - boolean isPublished = false; - if ("isUsed".equals(type) || "designer".equals(type)) { - isUsed = true; - } else if ("isPublished".equals(type)) { - isPublished = true; - } - list = getPalRepositoryModelsByTeamId(wsId, context.getUID(), teamId, isUsed, isPublished); - if (list == null) { - list = new ArrayList(); - } - List removeList = new ArrayList(); - StringBuilder removeIds = new StringBuilder(); - // 若type为designer并且有数据,则过滤掉已发布的 - if("designer".equals(type) && list != null && list.size() > 0) { - List tempList = new ArrayList(); - for (PALRepositoryModel model : list) { - if (!model.isPublish()) { - tempList.add(model); - } - } - list = tempList; - } - Collections.sort(list, new Comparator1()); // 按级别排序 - List newList = setNewPid(list); - - List categorys = PALMethodCache.getPalMehtodList(teamId, context.getUID(), isUsed, isPublished, true); - int i = 1; - for (String category : categorys) { - if (methods != null && !"".equals(methods) ) { - if (methods.indexOf(category) == -1 ) { - //制度图与表单图特殊处理 - if ("data.form".equals(methods)){ - if (!category.equals("process")){ - continue; - } - } else if ("control.policy".equals(methods)){ - if (!category.equals("process")){ - continue; - } - } else { - continue; - } - } - } - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", category); - jsonObject.put("nocheck", true); - String name = I18nRes.findValue(CoEConstant.APP_ID, category); - jsonObject.put("name", name); - jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); - jsonObject.put("menu", false); - jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + category + "&type=0&wsid=" + wsId); - jsonObject.put("open", i == 1); - result.add(jsonObject); - i++; - } - - // 过滤掉method以外的 - for (PALRepositoryModel model : list) { - if (!methods.contains(model.getMethodId())) { - removeIds.append(model.getId()).append(","); - } - } - result.addAll(list2Json(context, newList, isUsed, isPublished, removeIds.toString(), type)); - - return result; - } - - /**************************************************异步获取流程子节点start**************************************************************************/ - - /** - * 获取当前节点的第一级子节点 - * - * @param context 用户 - * @param categorys 流程大类,多个则逗号分隔 - * @param wsId - * @param teamId 若teamId不为空,则获取该用户的小组权限之内的流程 - * @param pid 父节点,为空则以cagegorys中每个元素作为父节点返回结果 - * @return - */ - public JSONArray getSubRepositoryListByPid(UserContext context, String categorys, String wsId, String teamId, String pid) { - JSONArray result = new JSONArray(); - String[] categoryArr = categorys.split(","); - if (UtilString.isEmpty(pid)) {// 父节点为空,直接返回categorys拼接结果 - for (String category : categoryArr) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", category); - jsonObject.put("nocheck", true); - String name = I18nRes.findValue(CoEConstant.APP_ID, category); - jsonObject.put("name", name); - jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); - jsonObject.put("open", false); - result.add(jsonObject); - } - return result; - } - List tmpList = new ArrayList<>(); - Set resourcePermList = new HashSet(); - if (!UtilString.isEmpty(teamId)) { - resourcePermList = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, context.getUID(), null, null); - } - // 获取子节点集合 - Set ids = new HashSet<>(); - getSubPalListByPidAndTeamId(wsId, teamId, resourcePermList, pid, tmpList, ids); - Collections.sort(tmpList, new Comparator1()); - // 转换json - list2Json(context, tmpList, result, pid); - return result; - } - - /** - * 简易版list转换树结构json - * - * @param list - * @param result - */ - public void list2Json(UserContext context, List list, JSONArray result, String pid) { - for (PALRepositoryModel model : list) { - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", pid); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - object.put("methodId", model.getMethodId().trim()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("iconFont", ""); - } else { - object.put("iconFont", ""); - } - object.put("open", false); - object.put("versionId", model.getVersionId()); - object.put("version", model.getVersion()); - object.put("isUse", model.isUse()); - object.put("level", model.getLevel()); - object.put("ordexIndex", model.getOrderIndex()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("category", model.getMethodCategory()); - result.add(object); - } - } - - /** - * 获取流程的子节点 - * - * @param wsId 资产库ID - * @param teamId 流程团队小组Id - * @param resourcePermList 权限Set结合 - * @param pid 父节点 - * @param result 存放结果集的空List - * @param ids 空的set集合,防止数据原因造成死循环 - */ - public void getSubPalListByPidAndTeamId(String wsId, String teamId, Set resourcePermList, String pid, List result, Set ids) { - List list = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); - if (list != null) { - if (UtilString.isEmpty(teamId)) { - for (PALRepositoryModel subModel : list) { - if (subModel.isUse()) { - result.add(subModel); - } - } - } else { - List tmpList = new ArrayList<>(); - for (PALRepositoryModel subModel : list) { - if (subModel.isUse()) { - tmpList.add(subModel); - } - } - for (PALRepositoryModel tmp : tmpList) { - if (resourcePermList.contains(tmp.getVersionId())) { - result.add(tmp); - } else { - if (!ids.contains(tmp.getVersionId())) {// 防止数据错误造成的死循环 - ids.add(tmp.getVersionId()); - getSubPalListByPidAndTeamId(wsId, teamId, resourcePermList, tmp.getId(), result, ids); - } - } - } - } - } - } - /**************************************************异步获取流程子节点end**************************************************************************/ - - /** - * 通过流程model列表,获取流程树的json数组 - * - * @param context - * @param list - * @return - */ - public JSONArray list2Json(UserContext context, List list, boolean isUsed, boolean isPublished) { - return list2Json(context, list, isUsed, isPublished, null, null); - } - - private JSONArray list2Json(UserContext context, List list, boolean isUsed, boolean isPublished, String removeIds, String param) { - JSONArray jsonArray = new JSONArray(); - for (PALRepositoryModel model : list) { - - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", model.getNewParentId().trim()); - if (removeIds != null && removeIds.contains(model.getId().trim())) { - object.put("nocheck", true); - } else { - object.put("nocheck", false); - } - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("title", object.get("name")); - } else { - object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - //三员管理文件密级校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); - if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())){ - object.put("nocheck", true); - } - } - object.put("drop", false); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("iconFont", ""); - } else { - object.put("iconFont", ""); - } - List children = null; - if (isUsed) { - children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 - List tempChildren = new ArrayList<>(); - for (PALRepositoryModel model2 : children) { - if (!model2.isPublish()) { - tempChildren.add(model2); - } - } - children = tempChildren; - } - } else if (isPublished) { - children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - } - if (children == null || children.size() == 0) { - object.put("isParent", false); - //String icon = object.getString("icon"); - object.put("leaf", true);// 叶子节点 - // object.put("icon", icon.replace("16.png", "16.leaf.png")); - } else { - object.put("isParent", true); - object.put("open", false); - } - - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - String dutyDeptId = model.getDutyDept(); - object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); - String plDutyDeptName = dutyDeptId; - if (!UtilString.isEmpty(dutyDeptId)) { - if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { - plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); - } - } - object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); - String plDutyPerson = model.getDutyUser(); - object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); - object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); - jsonArray.add(object); - } - return jsonArray; - } - - /**********************************************************筛选角色模型***************************************************/ - - /** - * 通过流程model列表,获取流程树的json数组 - * - * @param context - * @param list - * @return - */ - public JSONArray list2JsonRole(UserContext context, List list, boolean isUsed, boolean isPublished,String ruuid) { - return list2JsonRole(context, list, isUsed, isPublished, null, null,ruuid); - } - - private JSONArray list2JsonRole(UserContext context, List list, boolean isUsed, boolean isPublished, String removeIds, String param,String ruuid) { - JSONArray jsonArray = new JSONArray(); - for (PALRepositoryModel model : list) { - - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", model.getNewParentId().trim()); - if (removeIds != null && removeIds.contains(model.getId().trim())) { - object.put("nocheck", true); - } else { - object.put("nocheck", false); - } - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("title", object.get("name")); - } else { - object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - //三员管理文件密级校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); - if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())){ - object.put("nocheck", true); - } - } - object.put("drop", false); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("iconFont", ""); - } else { - object.put("iconFont", ""); - } - - if(model.getName().equals("角色模型")){ - object.put("isParent", true); - object.put("open", true); - }else{ - object.put("isParent", false); - object.remove("open"); - } + return list; + } + + public List getUsedPalRepositoryModelsByPidRoleCorrelation(String wsId, String pid, String ruuid) { + List list = getPalRepositoryModelsByPid(wsId, pid); + List removeList = new ArrayList(); + if (list != null) { + for (PALRepositoryModel model : list) { + if (!model.isUse()) { + removeList.add(model); + } + List data = new ArrayList(); + data.add(0, "org.role"); + data.add(1, ruuid); + RowMap rowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=? AND ID=?", data.toString(), model.getId()); + if (rowMap == null) { + removeList.add(model); + } + + + } + } + list.removeAll(removeList); + Collections.sort(list, new Comparator1()); + return list; + } + + + /**************************************************** 获取使用中的流程 *****************************************************/ + + /** + * 获取某个流程的所有使用中的子流程 + * + * @param wsId + * @param pid + * @param list + */ + public void getAllUsedPalRepositoryModelsByPid(String wsId, String pid, List list) { + List children = getUsedPalRepositoryModelsByPid(wsId, pid); + if (children != null && children.size() > 0) { + list.addAll(children); + for (PALRepositoryModel model : children) { + getAllUsedPalRepositoryModelsByPid(wsId, model.getId(), list); + } + } + } + + /** + * 通过pid获取子流程集合 + * + * @param wsId + * @param pid + * @param list + */ + public void getUsedListPalRepositoryModelsByPid(String wsId, String pid, List list) { + List children = getUsedPalRepositoryModelsByPid(wsId, pid); + if (children != null && children.size() > 0) { + list.addAll(children); + } + } + + /** + * 获取流程资产库下所有发布的流程 + * + * @param wsId 流程库id + * @return + */ + public List getPublishedPalRepositoryModelsByWsId(String wsId, String methodId) { + List list = new ArrayList(); + + Iterator pals = PALRepositoryCache.getByWsId(wsId); + while (pals.hasNext()) { + PALRepositoryModel model = pals.next(); + if (model.isPublish()) { + if (methodId != null && !"".equals(methodId)) { + if (methodId.indexOf(".") != -1) { + if (model.getMethodId().equals(methodId)) { + list.add(model); + } + } else { + if (model.getMethodCategory().equals(methodId)) { + list.add(model); + } + } + } else { + list.add(model); + } + } + } + return list; + } + + /** + * 获取某个流程的发布的子流程 + * + * @param wsId + * @param pid + * @return + */ + public List getPublishedPalRepositoryModelsByPid(String wsId, String pid) { + List list = getPalRepositoryModelsByPid(wsId, pid); + if (list != null) { + List removeList = new ArrayList(); + for (PALRepositoryModel model : list) { + if (!model.isPublish()) { + removeList.add(model); + } + } + list.removeAll(removeList); + } + + return list; + } + + /** + * 获取某个流程的所有发布的子流程 + * + * @param wsId + * @param pid + * @param list + */ + public void getAllPublishedPalRepositoryModelsByPid(String wsId, String pid, List list) { + List publishedChildren = getPublishedPalRepositoryModelsByPid(wsId, pid); + if (publishedChildren != null && publishedChildren.size() > 0) { + list.addAll(publishedChildren); + } + List children = Cache.iteratorToList(PALRepositoryCache.getByPid(wsId, pid)); + for (PALRepositoryModel model : children) { + getAllPublishedPalRepositoryModelsByPid(wsId, model.getId(), list); + } + } + + /**************************************************** 获取发布的流程 *****************************************************/ + + /** + * 获取完整流程树 + * + * @param context + * @param wsId + * @param methods + * @param type isUsed/isPublished/designer 使用中/已发布/使用中但是未发布 + * @return + */ + public JSONArray getPalRepositoryTreeData(UserContext context, String wsId, String methods, String type) { + JSONArray result = new JSONArray(); + + String[] methodArray; + if (methods == null || "".equals(methods)) { + methodArray = new String[]{"process", "org", "data", "itsystem", "control"}; + } else { + methodArray = methods.split(","); + } + + int i = 1; + Set methodSet = new HashSet(); + for (String method : methodArray) { + String category = ""; + if (method.indexOf(".") != -1) { + category = method.substring(0, method.indexOf(".")); + } else { + category = method; + } + if (methodSet.contains(category)) { + continue; + } else { + methodSet.add(category); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", category); + String name = I18nRes.findValue(CoEConstant.APP_ID, category); + jsonObject.put("name", name); + jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); + jsonObject.put("menu", false); + jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + category + "&type=0&wsid=" + wsId); + jsonObject.put("open", i == 1); + jsonObject.put("nocheck", true); + + result.add(jsonObject); + } + + List modelList = new ArrayList(); + boolean isUsed = false; + boolean isPublished = false; + if ("isUsed".equals(type) || "designer".equals(type)) { + modelList = getUsedPalRepositoryModelsByWsId(wsId, category); + isUsed = true; + } else if ("isPublished".equals(type)) { + modelList = getPublishedPalRepositoryModelsByWsId(wsId, category); + isPublished = true; + + } + StringBuilder removeIds = new StringBuilder(); + if (modelList.size() > 0) { + if (methods != null && !"".equals(methods)) { + List removeList = new ArrayList(); + for (PALRepositoryModel model : modelList) { + // 如果限制的方法是小类,需判断模型方法Id;如果限制的方法是大类,需判断模型的category + if ((method.indexOf(".") != -1 && methods.indexOf(model.getMethodId()) == -1) || (method.indexOf(".") == -1 && !method.equals(model.getMethodCategory()))) { + removeList.add(model); + removeIds.append(model.getId()).append(","); + } + } + // modelList.removeAll(removeList); + } + } + + // 若type为designer并且有数据,则过滤掉已发布的 + if ("designer".equals(type) && modelList.size() > 0) { + List tempList = new ArrayList(); + for (PALRepositoryModel model : modelList) { + if (!model.isPublish()) { + tempList.add(model); + } + } + modelList = tempList; + } + + List newList = setNewPid(modelList); + Collections.sort(newList, new Comparator1()); + + result.addAll(list2Json(context, newList, isUsed, isPublished, removeIds.toString(), type)); + i++; + } + return result; + } + + /** + * 获取使用中的流程树根节点及第一级子节点 + * + * @param context + * @param wsId + * @param methods + * @param type isUsed/isPublished + * @return + */ + public JSONArray getPalRepositoryTreeRootData(UserContext context, String wsId, String methods, String type) { + JSONArray result = new JSONArray(); + + String[] methodArray; + if (methods == null || "".equals(methods)) { + methodArray = new String[]{"process", "org", "data", "itsystem", "control"}; + } else { + methodArray = methods.split(","); + } + + int i = 1; + for (String method : methodArray) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", method); + String name = I18nRes.findValue(CoEConstant.APP_ID, method); + jsonObject.put("name", name); + + jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + method + ".png"); + jsonObject.put("menu", false); + jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + method + "&type=0&wsid=" + wsId); + jsonObject.put("open", i == 1); + jsonObject.put("plCategory", method); + + + result.add(jsonObject); + if ("isUsed".equals(type)) { + result.addAll(getUsedPalRepositoryTreeDataByPid(context, wsId, method)); + } else if ("isPublished".equals(type)) { + result.addAll(getPublishedPalRepositoryTreeDataByPid(context, wsId, method)); + } + + i++; + } + + return result; + } + + /** + * 获取使用中的流程树根节点 + * + * @param uc + * @param wsId + * @param categorys + * @param teamId 小组Id + * @return + */ + public JSONArray getPalRepositoryTreeRoot(UserContext uc, String wsId, String categorys, String teamId) { + JSONArray result = new JSONArray(); + List palMethodList; + String[] categoryArray; + if (UtilString.isEmpty(categorys)) {// 不指定分类 + palMethodList = PALMethodCache.getPALMethodList(true); + if (!UtilString.isEmpty(teamId)) { + palMethodList = PALMethodCache.getPALMethodList(true); + List list = new ArrayList<>(); + List list1 = CoeProcessLevelUtil.getPermRepositoryList(wsId, teamId, uc.getUID(), null, null, true, false); + for (String str : palMethodList) { + for (PALRepositoryModel model : list1) { + if (model.getMethodCategory().equals(str)) { + list.add(str); + break; + } + } + } + palMethodList = list; + } + categoryArray = new String[palMethodList.size()]; + palMethodList.toArray(categoryArray); + } else {// 指定分类 + categoryArray = categorys.split(","); + } + for (String category : categoryArray) { + //隐藏数据字段 by zhaolei + if (category.equals("data")) { + continue; + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", category); + jsonObject.put("currId", category); + jsonObject.put("versionId", category); + String name = I18nRes.findValue(CoEConstant.APP_ID, category); + jsonObject.put("name", name); + JSONObject icon = new JSONObject(); + icon.put("icon", ""); + icon.put("color", "red"); + jsonObject.put("icon", icon); + jsonObject.put("plCategory", category); + jsonObject.put("plMethodId", ""); + List list = CoeProcessLevelUtil.getPermRepositoryList(wsId, teamId, uc.getUID(), category, null, true, false); + if (list != null && list.size() > 0) { + jsonObject.put("leaf", false); + } else { + jsonObject.put("leaf", true); + } + result.add(jsonObject); + } + return result; + } + + /** + * 根据pid获取使用中的流程树 + * + * @param wsId 流程库Id + * @param pid 父节点Id + * @return + */ + public JSONArray getUsedPalRepositoryTreeDataByPid(UserContext context, String wsId, String pid) { + List list = getUsedPalRepositoryModelsByPid(wsId, pid); // 根据父节点Id获取使用中的子节点 + Collections.sort(list, new Comparator1()); // 按级别排序 + JSONArray result = list2Json(context, list, true, false); + return result; + } + + /** + * 根据pid获取使用中的流程树 + * + * @param context + * @param wsId + * @param pid + * @param teamId + * @return + */ + public JSONArray getUsedPalRepositoryTreeDataByPid(UserContext context, String wsId, String pid, String teamId) { + List list = getUsedPalRepositoryModelsByPid(wsId, pid); // 根据父节点Id获取使用中的子节点 + Set versionIds = new HashSet<>(); + if (UtilString.isNotEmpty(teamId)) { + UserInfo userInfo = CooperationCache.getUserInfo(teamId, context.getUID()); + if (userInfo != null) { + if (userInfo.getIsAllDataPermission()) { + TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); + versionIds = teamInfo.getVersionIds(); + } else { + versionIds = userInfo.getDataPermission().keySet(); + } + } + } + if (versionIds.size() > 0) { + List modelList = new ArrayList<>(); + for (PALRepositoryModel model : list) { + if (versionIds.contains(model.getId())) { + modelList.add(model); + } + } + list = modelList; + } + Collections.sort(list, new Comparator1()); // 按级别排序 + JSONArray result = list2Json(context, list, true, false); + return result; + } + + /** + * 根据pid获取使用中的流程树(角色模型) + * + * @param wsId 流程库Id + * @param pid 父节点Id + * @return + */ + public JSONArray getUsedPalRepositoryTreeDataByPidRole(UserContext context, String wsId, String pid, String ruuid) { + List list = getUsedPalRepositoryModelsByPidRole(wsId, pid, ruuid); // 根据父节点Id获取使用中的子节点 + //Collections.sort(list, new Comparator1()); // 按级别排序 + JSONArray result = list2JsonRole(context, list, true, false, ruuid); + return result; + } + + /** + * 根据pid获取使用中的流程树(角色模型) + * + * @param context + * @param wsId + * @param pid + * @param ruuid + * @param teamId + * @return + */ + public JSONArray getUsedPalRepositoryTreeDataByPidRole(UserContext context, String wsId, String pid, String ruuid, String teamId) { + List list = getUsedPalRepositoryModelsByPidRole(wsId, pid, ruuid); // 根据父节点Id获取使用中的子节点 + Set versionIds = new HashSet<>(); + if (UtilString.isNotEmpty(teamId)) { + UserInfo userInfo = CooperationCache.getUserInfo(teamId, context.getUID()); + if (userInfo != null) { + if (userInfo.getIsAllDataPermission()) { + TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); + versionIds = teamInfo.getVersionIds(); + } else { + versionIds = userInfo.getDataPermission().keySet(); + } + } + } + if (versionIds.size() > 0) { + List modelList = new ArrayList<>(); + for (PALRepositoryModel model : list) { + if (versionIds.contains(model.getId())) { + modelList.add(model); + } + } + list = modelList; + } + //Collections.sort(list, new Comparator1()); // 按级别排序 + JSONArray result = list2JsonRole(context, list, true, false, ruuid); + return result; + } + + /** + * @param context + * @param wsId + * @param pid + * @param uuid + * @return + */ + public JSONArray getUsedPalRepositoryTreeDataByPidAnduuid(UserContext context, String wsId, String pid, String attrId, String uuid, String teamId) { + Set versionIds = new HashSet<>(); + if (UtilString.isNotEmpty(teamId)) { + UserInfo userInfo = CooperationCache.getUserInfo(teamId, context.getUID()); + if (userInfo != null) { + if (userInfo.getIsAllDataPermission()) { + TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); + versionIds = teamInfo.getVersionIds(); + } else { + versionIds = userInfo.getDataPermission().keySet(); + } + } + } + List list = getUsedPalRepositoryModelsByPid(wsId, pid); // 根据父节点Id获取使用中的子节点 + if (versionIds.size() > 0) { + List modelList = new ArrayList<>(); + for (PALRepositoryModel model : list) { + if (versionIds.contains(model.getVersionId())) { + modelList.add(model); + } + } + list = modelList; + } + Collections.sort(list, new Comparator1()); // 按级别排序 + JSONArray result = list2JsonByuuid(context, list, true, false, attrId, uuid); + return result; + } + + + /**************************************************** 获取流程树 **********************************************************/ + + /** + * 根据pid获取发布的流程树 + * + * @param wsId 流程库Id + * @param pid 父节点Id + * @return + */ + public JSONArray getPublishedPalRepositoryTreeDataByPid(UserContext context, String wsId, String pid) { + List list = getUsedPalRepositoryModelsByPid(wsId, pid); // 根据父节点Id获取使用中的子节点 + Collections.sort(list, new Comparator1()); // 按级别排序 + JSONArray result = list2Json(context, list, false, true); + + return result; + } + + /** + * 父节点下的所有子节点 + */ + private static void recurPermChild(List repidList, List newList, String newParentId) { + if (repidList != null) { + for (int i = 0; i < repidList.size(); i++) { + PALRepositoryModel model = repidList.get(i); + if (model.getNewParentId() != null && !model.getNewParentId().equals("") && model.getNewParentId().equals(newParentId)) { + newList.add(model); + recurPermChild(repidList, newList, model.getId()); + } + } + } + } + + /** + * 获取有权限的完整流程树 + * + * @param context + * @param wsId + * @param teamId + * @param type + * @return + */ + public JSONArray getPermPalRepositoryTreeData(UserContext context, String wsId, String teamId, String type) { + JSONArray result = new JSONArray(); + + List list = null; + boolean isUsed = false; + boolean isPublished = false; + if ("isUsed".equals(type)) { + isUsed = true; + } else if ("isPublished".equals(type)) { + isPublished = true; + } + list = getPalRepositoryModelsByTeamId(wsId, context.getUID(), teamId, isUsed, isPublished); + Collections.sort(list, new Comparator1()); // 按级别排序 + List newList = setNewPid(list); + + List categorys = PALMethodCache.getPalMehtodList(teamId, context.getUID(), isUsed, isPublished, true); + int i = 1; + for (String category : categorys) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", category); + String name = I18nRes.findValue(CoEConstant.APP_ID, category); + jsonObject.put("name", name); + jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); + jsonObject.put("menu", false); + jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + category + "&type=0&wsid=" + wsId); + jsonObject.put("open", i == 1); + result.add(jsonObject); + i++; + } + + result.addAll(list2Json(context, newList, isUsed, isPublished)); + + return result; + } + + /** + * 根据流程小组获取有权限的完整流程树 + * + * @param context + * @param wsId + * @param teamId + * @param type + * @return + */ + public JSONArray getPermPalRepositoryTreeDataByUser(UserContext context, String wsId, String teamId, String type, String uuid) { + JSONArray result = new JSONArray(); + + List list = null; + boolean isUsed = false; + boolean isPublished = false; + if ("isUsed".equals(type)) { + isUsed = true; + } else if ("isPublished".equals(type)) { + isPublished = true; + } + list = getPalRepositoryModelsByTeamId(wsId, context.getUID(), teamId, isUsed, isPublished); + Collections.sort(list, new Comparator1()); // 按级别排序 + List newList = setNewPid(list); + + List categorys = PALMethodCache.getPalMehtodList(teamId, context.getUID(), isUsed, isPublished, true); + int i = 1; + for (String category : categorys) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", category); + String name = I18nRes.findValue(CoEConstant.APP_ID, category); + jsonObject.put("name", name); + jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); + jsonObject.put("menu", false); + jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + category + "&type=0&wsid=" + wsId); + jsonObject.put("open", i == 1); + result.add(jsonObject); + i++; + } + result.addAll(list2Json(context, newList, isUsed, isPublished)); + + return result; + } + + /** + * 获取有权限以及Methods限制的完整流程树 + * + * @param context + * @param wsId + * @param teamId + * @param type + * @return + */ + public JSONArray getPermPalRepositoryTreeDataByMethods(UserContext context, String wsId, String teamId, String type, String methods) { + JSONArray result = new JSONArray(); + + List list = null; + boolean isUsed = false; + boolean isPublished = false; + if ("isUsed".equals(type) || "designer".equals(type)) { + isUsed = true; + } else if ("isPublished".equals(type)) { + isPublished = true; + } + list = getPalRepositoryModelsByTeamId(wsId, context.getUID(), teamId, isUsed, isPublished); + if (list == null) { + list = new ArrayList(); + } + List removeList = new ArrayList(); + StringBuilder removeIds = new StringBuilder(); + // 若type为designer并且有数据,则过滤掉已发布的 + if ("designer".equals(type) && list != null && list.size() > 0) { + List tempList = new ArrayList(); + for (PALRepositoryModel model : list) { + if (!model.isPublish()) { + tempList.add(model); + } + } + list = tempList; + } + Collections.sort(list, new Comparator1()); // 按级别排序 + List newList = setNewPid(list); + + List categorys = PALMethodCache.getPalMehtodList(teamId, context.getUID(), isUsed, isPublished, true); + int i = 1; + for (String category : categorys) { + if (methods != null && !"".equals(methods)) { + if (methods.indexOf(category) == -1) { + //制度图与表单图特殊处理 + if ("data.form".equals(methods)) { + if (!category.equals("process")) { + continue; + } + } else if ("control.policy".equals(methods)) { + if (!category.equals("process")) { + continue; + } + } else { + continue; + } + } + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", category); + jsonObject.put("nocheck", true); + String name = I18nRes.findValue(CoEConstant.APP_ID, category); + jsonObject.put("name", name); + jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); + jsonObject.put("menu", false); + jsonObject.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + category + "&type=0&wsid=" + wsId); + jsonObject.put("open", i == 1); + result.add(jsonObject); + i++; + } + + // 过滤掉method以外的 + for (PALRepositoryModel model : list) { + if (!methods.contains(model.getMethodId())) { + removeIds.append(model.getId()).append(","); + } + } + result.addAll(list2Json(context, newList, isUsed, isPublished, removeIds.toString(), type)); + + return result; + } + + /**************************************************异步获取流程子节点start**************************************************************************/ + + /** + * 获取当前节点的第一级子节点 + * + * @param context 用户 + * @param categorys 流程大类,多个则逗号分隔 + * @param wsId + * @param teamId 若teamId不为空,则获取该用户的小组权限之内的流程 + * @param pid 父节点,为空则以cagegorys中每个元素作为父节点返回结果 + * @return + */ + public JSONArray getSubRepositoryListByPid(UserContext context, String categorys, String wsId, String teamId, String pid) { + JSONArray result = new JSONArray(); + String[] categoryArr = categorys.split(","); + if (UtilString.isEmpty(pid)) {// 父节点为空,直接返回categorys拼接结果 + for (String category : categoryArr) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", category); + jsonObject.put("nocheck", true); + String name = I18nRes.findValue(CoEConstant.APP_ID, category); + jsonObject.put("name", name); + jsonObject.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/" + category + ".png"); + jsonObject.put("open", false); + result.add(jsonObject); + } + return result; + } + List tmpList = new ArrayList<>(); + Set resourcePermList = new HashSet(); + if (!UtilString.isEmpty(teamId)) { + resourcePermList = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, context.getUID(), null, null); + } + // 获取子节点集合 + Set ids = new HashSet<>(); + getSubPalListByPidAndTeamId(wsId, teamId, resourcePermList, pid, tmpList, ids); + Collections.sort(tmpList, new Comparator1()); + // 转换json + list2Json(context, tmpList, result, pid); + return result; + } + + /** + * 简易版list转换树结构json + * + * @param list + * @param result + */ + public void list2Json(UserContext context, List list, JSONArray result, String pid) { + for (PALRepositoryModel model : list) { + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", pid); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + object.put("methodId", model.getMethodId().trim()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("iconFont", ""); + } else { + object.put("iconFont", ""); + } + object.put("open", false); + object.put("versionId", model.getVersionId()); + object.put("version", model.getVersion()); + object.put("isUse", model.isUse()); + object.put("level", model.getLevel()); + object.put("ordexIndex", model.getOrderIndex()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("category", model.getMethodCategory()); + result.add(object); + } + } + + /** + * 获取流程的子节点 + * + * @param wsId 资产库ID + * @param teamId 流程团队小组Id + * @param resourcePermList 权限Set结合 + * @param pid 父节点 + * @param result 存放结果集的空List + * @param ids 空的set集合,防止数据原因造成死循环 + */ + public void getSubPalListByPidAndTeamId(String wsId, String teamId, Set resourcePermList, String pid, List result, Set ids) { + List list = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); + if (list != null) { + if (UtilString.isEmpty(teamId)) { + for (PALRepositoryModel subModel : list) { + if (subModel.isUse()) { + result.add(subModel); + } + } + } else { + List tmpList = new ArrayList<>(); + for (PALRepositoryModel subModel : list) { + if (subModel.isUse()) { + tmpList.add(subModel); + } + } + for (PALRepositoryModel tmp : tmpList) { + if (resourcePermList.contains(tmp.getVersionId())) { + result.add(tmp); + } else { + if (!ids.contains(tmp.getVersionId())) {// 防止数据错误造成的死循环 + ids.add(tmp.getVersionId()); + getSubPalListByPidAndTeamId(wsId, teamId, resourcePermList, tmp.getId(), result, ids); + } + } + } + } + } + } + /**************************************************异步获取流程子节点end**************************************************************************/ + + /** + * 通过流程model列表,获取流程树的json数组 + * + * @param context + * @param list + * @return + */ + public JSONArray list2Json(UserContext context, List list, boolean isUsed, boolean isPublished) { + return list2Json(context, list, isUsed, isPublished, null, null); + } + + private JSONArray list2Json(UserContext context, List list, boolean isUsed, boolean isPublished, String removeIds, String param) { + JSONArray jsonArray = new JSONArray(); + for (PALRepositoryModel model : list) { + + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", model.getNewParentId().trim()); + if (removeIds != null && removeIds.contains(model.getId().trim())) { + object.put("nocheck", true); + } else { + object.put("nocheck", false); + } + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("title", object.get("name")); + } else { + object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + //三员管理文件密级校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); + if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) { + object.put("nocheck", true); + } + } + object.put("drop", false); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("iconFont", ""); + } else { + object.put("iconFont", ""); + } + List children = null; + if (isUsed) { + children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 + List tempChildren = new ArrayList<>(); + for (PALRepositoryModel model2 : children) { + if (!model2.isPublish()) { + tempChildren.add(model2); + } + } + children = tempChildren; + } + } else if (isPublished) { + children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + } + if (children == null || children.size() == 0) { + object.put("isParent", false); + //String icon = object.getString("icon"); + object.put("leaf", true);// 叶子节点 + // object.put("icon", icon.replace("16.png", "16.leaf.png")); + } else { + object.put("isParent", true); + object.put("open", false); + } + + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + String dutyDeptId = model.getDutyDept(); + object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); + String plDutyDeptName = dutyDeptId; + if (!UtilString.isEmpty(dutyDeptId)) { + if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { + plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); + } + } + object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); + String plDutyPerson = model.getDutyUser(); + object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); + object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); + jsonArray.add(object); + } + return jsonArray; + } + + /**********************************************************筛选角色模型***************************************************/ + + /** + * 通过流程model列表,获取流程树的json数组 + * + * @param context + * @param list + * @return + */ + public JSONArray list2JsonRole(UserContext context, List list, boolean isUsed, boolean isPublished, String ruuid) { + return list2JsonRole(context, list, isUsed, isPublished, null, null, ruuid); + } + + private JSONArray list2JsonRole(UserContext context, List list, boolean isUsed, boolean isPublished, String removeIds, String param, String ruuid) { + JSONArray jsonArray = new JSONArray(); + for (PALRepositoryModel model : list) { + + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", model.getNewParentId().trim()); + if (removeIds != null && removeIds.contains(model.getId().trim())) { + object.put("nocheck", true); + } else { + object.put("nocheck", false); + } + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("title", object.get("name")); + } else { + object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + //三员管理文件密级校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); + if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) { + object.put("nocheck", true); + } + } + object.put("drop", false); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("iconFont", ""); + } else { + object.put("iconFont", ""); + } + + if (model.getName().equals("角色模型")) { + object.put("isParent", true); + object.put("open", true); + } else { + object.put("isParent", false); + object.remove("open"); + } /*List children = null; if (isUsed) { children = getUsedPalRepositoryModelsByPidRoleCorrelation(model.getWsId(), model.getId(),ruuid); @@ -2063,1483 +2058,1500 @@ public class PALRepositoryQueryAPIManager { object.put("open", false); }*/ - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - String dutyDeptId = model.getDutyDept(); - object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); - String plDutyDeptName = dutyDeptId; - if (!UtilString.isEmpty(dutyDeptId)) { - if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { - plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); - } - } - object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); - String plDutyPerson = model.getDutyUser(); - object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); - object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); - jsonArray.add(object); - } - return jsonArray; - } + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + String dutyDeptId = model.getDutyDept(); + object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); + String plDutyDeptName = dutyDeptId; + if (!UtilString.isEmpty(dutyDeptId)) { + if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { + plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); + } + } + object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); + String plDutyPerson = model.getDutyUser(); + object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); + object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); + jsonArray.add(object); + } + return jsonArray; + } - /*********************************************************************重写通过流程model列表,获取流程树的json数组***by zhaolei*****************************************************/ + /*********************************************************************重写通过流程model列表,获取流程树的json数组***by zhaolei*****************************************************/ - /** - * 通过流程model列表,获取流程树的json数组 - * - * @param context - * @param list - * @return - */ - public JSONArray list2JsonByuuid(UserContext context, List list, boolean isUsed, boolean isPublished,String attrId,String uuid) { - return list2JsonByuuid(context, list, isUsed, isPublished, null, null,attrId,uuid); - } + /** + * 通过流程model列表,获取流程树的json数组 + * + * @param context + * @param list + * @return + */ + public JSONArray list2JsonByuuid(UserContext context, List list, boolean isUsed, boolean isPublished, String attrId, String uuid) { + return list2JsonByuuid(context, list, isUsed, isPublished, null, null, attrId, uuid); + } - private JSONArray list2JsonByuuid(UserContext context, List list, boolean isUsed, boolean isPublished, String removeIds, String param,String attrId,String uuid) { - JSONArray jsonArray = new JSONArray(); - for (PALRepositoryModel model : list) { + private JSONArray list2JsonByuuid(UserContext context, List list, boolean isUsed, boolean isPublished, String removeIds, String param, String attrId, String uuid) { + JSONArray jsonArray = new JSONArray(); + for (PALRepositoryModel model : list) { - if(attrId.equals("role")){ - List data=new ArrayList(); - data.add(0,model.getMethodId()); - data.add(1,uuid); + if (attrId.equals("role")) { + List data = new ArrayList(); + data.add(0, model.getMethodId()); + data.add(1, uuid); - RowMap rowMap = DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=? AND EXT2=?",model.getId(),data.toString()); - if (rowMap != null || model.getName().equals("角色模型")) { - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", model.getNewParentId().trim()); - if (removeIds != null && removeIds.contains(model.getId().trim())) { - object.put("nocheck", true); - } else { - object.put("nocheck", false); - } - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("title", object.get("name")); - } else { - object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - //三员管理文件密级校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); - if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())){ - object.put("nocheck", true); - } - } - object.put("drop", false); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("iconFont", ""); - } else { - object.put("iconFont", ""); - } - List children = null; - if (isUsed) { - children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 - List tempChildren = new ArrayList<>(); - for (PALRepositoryModel model2 : children) { - if (!model2.isPublish()) { - tempChildren.add(model2); - } - } - children = tempChildren; - } - } else if (isPublished) { - children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - } - if (children == null || children.size() == 0) { - object.put("isParent", false); - //String icon = object.getString("icon"); - object.put("leaf", true);// 叶子节点 - // object.put("icon", icon.replace("16.png", "16.leaf.png")); - } else { - object.put("isParent", true); - object.put("open", false); - } + RowMap rowMap = DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=? AND EXT2=?", model.getId(), data.toString()); + if (rowMap != null || model.getName().equals("角色模型")) { + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", model.getNewParentId().trim()); + if (removeIds != null && removeIds.contains(model.getId().trim())) { + object.put("nocheck", true); + } else { + object.put("nocheck", false); + } + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("title", object.get("name")); + } else { + object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + //三员管理文件密级校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); + if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) { + object.put("nocheck", true); + } + } + object.put("drop", false); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("iconFont", ""); + } else { + object.put("iconFont", ""); + } + List children = null; + if (isUsed) { + children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 + List tempChildren = new ArrayList<>(); + for (PALRepositoryModel model2 : children) { + if (!model2.isPublish()) { + tempChildren.add(model2); + } + } + children = tempChildren; + } + } else if (isPublished) { + children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + } + if (children == null || children.size() == 0) { + object.put("isParent", false); + //String icon = object.getString("icon"); + object.put("leaf", true);// 叶子节点 + // object.put("icon", icon.replace("16.png", "16.leaf.png")); + } else { + object.put("isParent", true); + object.put("open", false); + } - object.put("open",true); - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - String dutyDeptId = model.getDutyDept(); - object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); - String plDutyDeptName = dutyDeptId; - if (!UtilString.isEmpty(dutyDeptId)) { - if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { - plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); - } - } - object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); - String plDutyPerson = model.getDutyUser(); - object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); - object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); - jsonArray.add(object); - } - }else if(attrId.equals("R_relevant_flies") || attrId.equals("related_files")){ + object.put("open", true); + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + String dutyDeptId = model.getDutyDept(); + object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); + String plDutyDeptName = dutyDeptId; + if (!UtilString.isEmpty(dutyDeptId)) { + if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { + plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); + } + } + object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); + String plDutyPerson = model.getDutyUser(); + object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); + object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); + jsonArray.add(object); + } + } else if (attrId.equals("R_relevant_flies") || attrId.equals("related_files")) { - if(!model.isPublish()){ - continue; - } + if (!model.isPublish()) { + continue; + } - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", model.getNewParentId().trim()); - if (removeIds != null && removeIds.contains(model.getId().trim())) { - object.put("nocheck", true); - } else { - object.put("nocheck", false); - } - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("title", object.get("name")); - } else { - object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - //三员管理文件密级校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); - if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())){ - object.put("nocheck", true); - } - } - object.put("drop", false); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("iconFont", ""); - } else { - object.put("iconFont", ""); - } - List children = null; - if (isUsed) { - children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 - List tempChildren = new ArrayList<>(); - for (PALRepositoryModel model2 : children) { - if (!model2.isPublish()) { - tempChildren.add(model2); - } - } - children = tempChildren; - } - } else if (isPublished) { - children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - } - if (children == null || children.size() == 0) { - object.put("isParent", false); - //String icon = object.getString("icon"); - object.put("leaf", true);// 叶子节点 - // object.put("icon", icon.replace("16.png", "16.leaf.png")); - } else { - object.put("isParent", true); - object.put("open", false); - } + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", model.getNewParentId().trim()); + if (removeIds != null && removeIds.contains(model.getId().trim())) { + object.put("nocheck", true); + } else { + object.put("nocheck", false); + } + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("title", object.get("name")); + } else { + object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + //三员管理文件密级校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); + if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) { + object.put("nocheck", true); + } + } + object.put("drop", false); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("iconFont", ""); + } else { + object.put("iconFont", ""); + } + List children = null; + if (isUsed) { + children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 + List tempChildren = new ArrayList<>(); + for (PALRepositoryModel model2 : children) { + if (!model2.isPublish()) { + tempChildren.add(model2); + } + } + children = tempChildren; + } + } else if (isPublished) { + children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + } + if (children == null || children.size() == 0) { + object.put("isParent", false); + //String icon = object.getString("icon"); + object.put("leaf", true);// 叶子节点 + // object.put("icon", icon.replace("16.png", "16.leaf.png")); + } else { + object.put("isParent", true); + object.put("open", false); + } - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - String dutyDeptId = model.getDutyDept(); - object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); - String plDutyDeptName = dutyDeptId; - if (!UtilString.isEmpty(dutyDeptId)) { - if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { - plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); - } - } - object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); - String plDutyPerson = model.getDutyUser(); - object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); - object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); - jsonArray.add(object); - }else if(attrId.equals("Process_performance_metrics")){ - List data=new ArrayList(); - data.add(0,model.getMethodId()); - data.add(1,uuid); + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + String dutyDeptId = model.getDutyDept(); + object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); + String plDutyDeptName = dutyDeptId; + if (!UtilString.isEmpty(dutyDeptId)) { + if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { + plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); + } + } + object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); + String plDutyPerson = model.getDutyUser(); + object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); + object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); + jsonArray.add(object); + } else if (attrId.equals("Process_performance_metrics")) { + List data = new ArrayList(); + data.add(0, model.getMethodId()); + data.add(1, uuid); - RowMap rowMap = DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=? AND EXT2=?",model.getId(),data.toString()); - if (rowMap != null ||model.getName().equals("末级流程绩效")) { - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", model.getNewParentId().trim()); - if (removeIds != null && removeIds.contains(model.getId().trim())) { - object.put("nocheck", true); - } else { - object.put("nocheck", false); - } - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("title", object.get("name")); - } else { - object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - //三员管理文件密级校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); - if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())){ - object.put("nocheck", true); - } - } - object.put("drop", false); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("iconFont", ""); - } else { - object.put("iconFont", ""); - } - List children = null; - if (isUsed) { - children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 - List tempChildren = new ArrayList<>(); - for (PALRepositoryModel model2 : children) { - if (!model2.isPublish()) { - tempChildren.add(model2); - } - } - children = tempChildren; - } - } else if (isPublished) { - children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - } - if (children == null || children.size() == 0) { - object.put("isParent", false); - //String icon = object.getString("icon"); - object.put("leaf", true);// 叶子节点 - // object.put("icon", icon.replace("16.png", "16.leaf.png")); - } else { - object.put("isParent", true); - object.put("open", false); - } + RowMap rowMap = DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=? AND EXT2=?", model.getId(), data.toString()); + if (rowMap != null || model.getName().equals("末级流程绩效")) { + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", model.getNewParentId().trim()); + if (removeIds != null && removeIds.contains(model.getId().trim())) { + object.put("nocheck", true); + } else { + object.put("nocheck", false); + } + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("title", object.get("name")); + } else { + object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + //三员管理文件密级校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); + if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) { + object.put("nocheck", true); + } + } + object.put("drop", false); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("iconFont", ""); + } else { + object.put("iconFont", ""); + } + List children = null; + if (isUsed) { + children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 + List tempChildren = new ArrayList<>(); + for (PALRepositoryModel model2 : children) { + if (!model2.isPublish()) { + tempChildren.add(model2); + } + } + children = tempChildren; + } + } else if (isPublished) { + children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + } + if (children == null || children.size() == 0) { + object.put("isParent", false); + //String icon = object.getString("icon"); + object.put("leaf", true);// 叶子节点 + // object.put("icon", icon.replace("16.png", "16.leaf.png")); + } else { + object.put("isParent", true); + object.put("open", false); + } - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - String dutyDeptId = model.getDutyDept(); - object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); - String plDutyDeptName = dutyDeptId; - if (!UtilString.isEmpty(dutyDeptId)) { - if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { - plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); - } - } - object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); - String plDutyPerson = model.getDutyUser(); - object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); - object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); - jsonArray.add(object); - } - }else if(attrId.equals("L1L3_Performance")){ + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + String dutyDeptId = model.getDutyDept(); + object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); + String plDutyDeptName = dutyDeptId; + if (!UtilString.isEmpty(dutyDeptId)) { + if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { + plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); + } + } + object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); + String plDutyPerson = model.getDutyUser(); + object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); + object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); + jsonArray.add(object); + } + } else if (attrId.equals("L1L3_Performance")) { - if (model.getName().equals("L1-L3流程绩效") || model.getMethodId().equals("control.ma")) { - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", model.getNewParentId().trim()); - if (removeIds != null && removeIds.contains(model.getId().trim())) { - object.put("nocheck", true); - } else { - object.put("nocheck", false); - } - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("title", object.get("name")); - } else { - object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - //三员管理文件密级校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); - if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())){ - object.put("nocheck", true); - } - } - object.put("drop", false); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("iconFont", ""); - } else { - object.put("iconFont", ""); - } - List children = null; - if (isUsed) { - children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 - List tempChildren = new ArrayList<>(); - for (PALRepositoryModel model2 : children) { - if (!model2.isPublish()) { - tempChildren.add(model2); - } - } - children = tempChildren; - } - } else if (isPublished) { - children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - } - if (children == null || children.size() == 0) { - object.put("isParent", false); - //String icon = object.getString("icon"); - object.put("leaf", true);// 叶子节点 - // object.put("icon", icon.replace("16.png", "16.leaf.png")); - } else { - object.put("isParent", true); - object.put("open", false); - } + if (model.getName().equals("L1-L3流程绩效") || model.getMethodId().equals("control.ma")) { + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", model.getNewParentId().trim()); + if (removeIds != null && removeIds.contains(model.getId().trim())) { + object.put("nocheck", true); + } else { + object.put("nocheck", false); + } + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("title", object.get("name")); + } else { + object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + //三员管理文件密级校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); + if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) { + object.put("nocheck", true); + } + } + object.put("drop", false); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("iconFont", ""); + } else { + object.put("iconFont", ""); + } + List children = null; + if (isUsed) { + children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 + List tempChildren = new ArrayList<>(); + for (PALRepositoryModel model2 : children) { + if (!model2.isPublish()) { + tempChildren.add(model2); + } + } + children = tempChildren; + } + } else if (isPublished) { + children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + } + if (children == null || children.size() == 0) { + object.put("isParent", false); + //String icon = object.getString("icon"); + object.put("leaf", true);// 叶子节点 + // object.put("icon", icon.replace("16.png", "16.leaf.png")); + } else { + object.put("isParent", true); + object.put("open", false); + } - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - String dutyDeptId = model.getDutyDept(); - object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); - String plDutyDeptName = dutyDeptId; - if (!UtilString.isEmpty(dutyDeptId)) { - if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { - plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); - } - } - object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); - String plDutyPerson = model.getDutyUser(); - object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); - object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); - jsonArray.add(object); - } - }else if(attrId.equals("post")){ - if (model.getName().equals("岗位模型") || model.getMethodId().equals("org.normal")) { + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + String dutyDeptId = model.getDutyDept(); + object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); + String plDutyDeptName = dutyDeptId; + if (!UtilString.isEmpty(dutyDeptId)) { + if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { + plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); + } + } + object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); + String plDutyPerson = model.getDutyUser(); + object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); + object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); + jsonArray.add(object); + } + } else if (attrId.equals("post")) { + if (model.getName().equals("岗位模型") || model.getMethodId().equals("org.normal")) { - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", model.getNewParentId().trim()); - if (removeIds != null && removeIds.contains(model.getId().trim())) { - object.put("nocheck", true); - } else { - object.put("nocheck", false); - } + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", model.getNewParentId().trim()); + if (removeIds != null && removeIds.contains(model.getId().trim())) { + object.put("nocheck", true); + } else { + object.put("nocheck", false); + } - //判断如果当前模型为岗位模型,不允许选择 - if(model.getName().equals("岗位模型")){ - object.put("nocheck",true); - } - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("title", object.get("name")); - } else { - object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - //三员管理文件密级校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); - if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())){ - object.put("nocheck", true); - } - } - object.put("drop", false); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("iconFont", ""); - } else { - object.put("iconFont", ""); - } - List children = null; - if (isUsed) { - children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 - List tempChildren = new ArrayList<>(); - for (PALRepositoryModel model2 : children) { - if (!model2.isPublish()) { - tempChildren.add(model2); - } - } - children = tempChildren; - } - } else if (isPublished) { - children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - } - if (children == null || children.size() == 0) { - object.put("isParent", false); - //String icon = object.getString("icon"); - object.put("leaf", true);// 叶子节点 - // object.put("icon", icon.replace("16.png", "16.leaf.png")); - } else { - object.put("isParent", true); - object.put("open", false); - } + //判断如果当前模型为岗位模型,不允许选择 + if (model.getName().equals("岗位模型")) { + object.put("nocheck", true); + } + object.put("nocheck", false); + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("title", object.get("name")); + } else { + object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + //三员管理文件密级校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId()); + if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) { + object.put("nocheck", true); + } + } + object.put("drop", false); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("iconFont", ""); + } else { + object.put("iconFont", ""); + } + List children = null; + if (isUsed) { + children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + if (param != null && "designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本 + List tempChildren = new ArrayList<>(); + for (PALRepositoryModel model2 : children) { + if (!model2.isPublish()) { + tempChildren.add(model2); + } + } + children = tempChildren; + } + } else if (isPublished) { + children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + } + if (children == null || children.size() == 0) { + object.put("isParent", false); + //String icon = object.getString("icon"); + object.put("leaf", true);// 叶子节点 + // object.put("icon", icon.replace("16.png", "16.leaf.png")); + } else { + object.put("isParent", true); + object.put("open", false); + } - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - String dutyDeptId = model.getDutyDept(); - object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); - String plDutyDeptName = dutyDeptId; - if (!UtilString.isEmpty(dutyDeptId)) { - if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { - plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); - } - } - object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); - String plDutyPerson = model.getDutyUser(); - object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); - object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); - jsonArray.add(object); - } - } + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + String dutyDeptId = model.getDutyDept(); + object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); + String plDutyDeptName = dutyDeptId; + if (!UtilString.isEmpty(dutyDeptId)) { + if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { + plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); + } + } + object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); + String plDutyPerson = model.getDutyUser(); + object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); + object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); + jsonArray.add(object); + } + } - } - return jsonArray; - } + } + return jsonArray; + } + /*******************************************************************************************************************************************/ - /*******************************************************************************************************************************************/ + /** + * 对于不完整的流程树(有权限限制等),重新设置父节点Id + * + * @param list + */ + public List setNewPid(List list) { + List newList = new ArrayList(); + Map versionIdMap = new HashMap(); + if (list != null && list.size() > 0) { + for (PALRepositoryModel model : list) { + versionIdMap.put(model.getVersionId(), model); + } - /** - * 对于不完整的流程树(有权限限制等),重新设置父节点Id - * - * @param list - */ - public List setNewPid(List list) { - List newList = new ArrayList(); - Map versionIdMap = new HashMap(); - if (list != null && list.size() > 0) { - for (PALRepositoryModel model : list) { - versionIdMap.put(model.getVersionId(), model); - } + for (PALRepositoryModel model : list) { + try { + PALRepositoryModelImpl modelImpl = ((PALRepositoryModelImpl) model).clone(); + String pid = model.getParentId(); + modelImpl.setNewParentId(pid); + if (pid.length() < 36) { + newList.add(modelImpl); + continue; + } + boolean flag = false; + while (!flag) { + if (pid.length() < 36) { + modelImpl.setNewParentId(pid); + flag = true; + newList.add(modelImpl); + break; + } + PALRepositoryModel pModel = PALRepositoryCache.getCache().get(pid); + if (pModel != null) { + if (versionIdMap.containsKey(pModel.getVersionId())) { + modelImpl.setNewParentId(versionIdMap.get(pModel.getVersionId()).getId()); + newList.add(modelImpl); + flag = true; + break; + } else { + pid = pModel.getParentId(); + } + } else { + break; + } + } + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + } + } + return newList; + } - for (PALRepositoryModel model : list) { - try { - PALRepositoryModelImpl modelImpl = ((PALRepositoryModelImpl) model).clone(); - String pid = model.getParentId(); - modelImpl.setNewParentId(pid); - if (pid.length() < 36) { - newList.add(modelImpl); - continue; - } - boolean flag = false; - while (!flag) { - if (pid.length() < 36) { - modelImpl.setNewParentId(pid); - flag = true; - newList.add(modelImpl); - break; - } - PALRepositoryModel pModel = PALRepositoryCache.getCache().get(pid); - if (pModel != null) { - if (versionIdMap.containsKey(pModel.getVersionId())) { - modelImpl.setNewParentId(versionIdMap.get(pModel.getVersionId()).getId()); - newList.add(modelImpl); - flag = true; - break; - } else { - pid = pModel.getParentId(); - } - } else { - break; - } - } - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - } - } - return newList; - } + /**************************************************** 流程树相关方法 *******************************************************/ - /**************************************************** 流程树相关方法 *******************************************************/ + /** + * 根据name获取流程文件 + * + * @param name + * @return + */ + public List getCoeProcessLevelByName(String name, String wsId, String methodId) { + PALRepository dao = new PALRepository(); + return dao.getCoeProcessLevelByName(name, wsId, methodId); - /** - * 根据name获取流程文件 - * - * @param name - * @return - */ - public List getCoeProcessLevelByName(String name, String wsId, String methodId) { - PALRepository dao = new PALRepository(); - return dao.getCoeProcessLevelByName(name, wsId, methodId); + } - } + public List sortListByLevel(List list) { + Collections.sort(list, new Comparator1()); // 按级别排序 + return list; + } - public List sortListByLevel(List list) { - Collections.sort(list, new Comparator1()); // 按级别排序 - return list; - } + /** + * 获取部门下的流程根节点(仅适用于责任部门选择org) + * + * @param uid 用户ID + * @param wsId 资产库Id,为空则查询默认资产库 + * @param methodId + * @param category + * @param isUsed + * @param isPublish + * @return + */ + public List getRootPALRepositoryModelsByDeptId(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { + String deptIds = getDeptIdsInSql(uid); + List list = new PALRepository().getRootPALRepositoryModelsByDeptId(deptIds, wsId, methodId, category, isUsed, isPublish); + List rootList = new ArrayList(); - /** - * 获取部门下的流程根节点(仅适用于责任部门选择org) - * @param uid 用户ID - * @param wsId 资产库Id,为空则查询默认资产库 - * @param methodId - * @param category - * @param isUsed - * @param isPublish - * @return - */ - public List getRootPALRepositoryModelsByDeptId(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { - String deptIds = getDeptIdsInSql(uid); - List list = new PALRepository().getRootPALRepositoryModelsByDeptId(deptIds, wsId, methodId, category, isUsed, isPublish); - List rootList = new ArrayList(); + if (list != null && list.size() > 0) { + Set versionIds = new HashSet(); + for (PALRepositoryModel model : list) { + versionIds.add(model.getVersionId()); + } - if (list != null && list.size() > 0) { - Set versionIds = new HashSet(); - for (PALRepositoryModel model : list) { - versionIds.add(model.getVersionId()); - } + /* + * 如果流程的父节点也在列表中,则只保留根节点 + */ + for (PALRepositoryModel model : list) { + boolean flag = true; + String pid = model.getParentId(); + while (pid.length() == 36) { + if (versionIds.contains(pid)) { + flag = false; + break; + } + List pList = PALRepositoryCache.getByVersionId(model.getWsId(), pid); + if (pList == null || pList.size() == 0) { + // 如果父节点已经不在资产库中,则不显示该节点。 + flag = false; + break; + } + pid = pList.get(0).getParentId(); - /* - * 如果流程的父节点也在列表中,则只保留根节点 - */ - for (PALRepositoryModel model : list) { - boolean flag = true; - String pid = model.getParentId(); - while (pid.length() == 36) { - if (versionIds.contains(pid)) { - flag = false; - break; - } - List pList = PALRepositoryCache.getByVersionId(model.getWsId(), pid); - if (pList == null || pList.size() == 0) { - // 如果父节点已经不在资产库中,则不显示该节点。 - flag = false; - break; - } - pid = pList.get(0).getParentId(); + } + if (flag) { + rootList.add(model); + } + } + } - } - if (flag) { - rootList.add(model); - } - } - } + return rootList; + } - return rootList; - } + /** + * 获取部门下的所有流程(仅适用于责任部门选择org) + * + * @param uid 用户ID + * @param wsId 资产库Id,为空则查询默认资产库 + * @param methodId + * @param category + * @param isUsed + * @param isPublish + * @return + */ + public List getAllPALRepositoryModelsByDeptId(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { + String deptIds = getDeptIdsInSql(uid); + return new PALRepository().getAllPALRepositoryModelsByDeptId(deptIds, wsId, methodId, category, isUsed, isPublish); + } - /** - * 获取部门下的所有流程(仅适用于责任部门选择org) - * @param uid 用户ID - * @param wsId 资产库Id,为空则查询默认资产库 - * @param methodId - * @param category - * @param isUsed - * @param isPublish - * @return - */ - public List getAllPALRepositoryModelsByDeptId(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { - String deptIds = getDeptIdsInSql(uid); - return new PALRepository().getAllPALRepositoryModelsByDeptId(deptIds, wsId, methodId, category, isUsed, isPublish); - } + /** + * 根据uid,获取可以查看的流程的责任部门Id + * + * @param uid + * @return + */ + public String getDeptIdsInSql(String uid) { + String plDeptLayerS = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_PLDEPT_LAYER); + int plDeptLayer = Integer.parseInt(plDeptLayerS); + String deptId = ""; // 要查找的顶级部门 + String deptIds = ""; + DepartmentModel dept = SDK.getORGAPI().getDepartmentByUser(uid); + // 如果属性设置的流程责任部门组织级别为-1,则查询责任部门为当前部门及子部门的流程 + if ("-1".equals(plDeptLayerS)) { + deptId = dept.getId(); + } else { + int deptLayer = dept.getLayer(); + if (deptLayer == plDeptLayer) { + deptIds = "'" + dept.getId() + "'"; + } else if (deptLayer > plDeptLayer) { + // 当前用户的级别小于流程责任部门组织级别,则向上查找上级部门 + while (deptLayer > plDeptLayer) { + String pDeptId = dept.getParentDepartmentId(); + dept = SDK.getORGAPI().getDepartmentById(pDeptId); + if (dept == null) { + break; + } + deptLayer = dept.getLayer(); + } + if (deptLayer == plDeptLayer) { + deptId = dept.getId(); + } + } else if (deptLayer < plDeptLayer) { + // 当前用户的级别大于流程责任部门组织级别,则从当前部门向下查找所有子部门 + deptId = dept.getId(); + } + } + // 查询所有子部门 + List departmentList = new ArrayList(); + DepartmentCache.getAllDepartmentList(deptId, departmentList); + StringBuilder ids = new StringBuilder("'" + deptId + "'"); + for (DepartmentModel model : departmentList) { + ids.append(",'").append(model.getId()).append("'"); + } + deptIds = ids.toString(); + return deptIds; + } - /** - * 根据uid,获取可以查看的流程的责任部门Id - * @param uid - * @return - */ - public String getDeptIdsInSql(String uid) { - String plDeptLayerS = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_PLDEPT_LAYER); - int plDeptLayer = Integer.parseInt(plDeptLayerS); - String deptId = ""; // 要查找的顶级部门 - String deptIds = ""; - DepartmentModel dept = SDK.getORGAPI().getDepartmentByUser(uid); - // 如果属性设置的流程责任部门组织级别为-1,则查询责任部门为当前部门及子部门的流程 - if ("-1".equals(plDeptLayerS)) { - deptId = dept.getId(); - } else { - int deptLayer = dept.getLayer(); - if (deptLayer == plDeptLayer) { - deptIds = "'" + dept.getId() + "'"; - } else if (deptLayer > plDeptLayer) { - // 当前用户的级别小于流程责任部门组织级别,则向上查找上级部门 - while (deptLayer > plDeptLayer) { - String pDeptId = dept.getParentDepartmentId(); - dept = SDK.getORGAPI().getDepartmentById(pDeptId); - if (dept == null) { - break; - } - deptLayer = dept.getLayer(); - } - if (deptLayer == plDeptLayer) { - deptId = dept.getId(); - } - } else if (deptLayer < plDeptLayer) { - // 当前用户的级别大于流程责任部门组织级别,则从当前部门向下查找所有子部门 - deptId = dept.getId(); - } - } - // 查询所有子部门 - List departmentList = new ArrayList(); - DepartmentCache.getAllDepartmentList(deptId, departmentList); - StringBuilder ids = new StringBuilder("'" + deptId + "'"); - for (DepartmentModel model : departmentList) { - ids.append(",'").append(model.getId()).append("'"); - } - deptIds = ids.toString(); - return deptIds; - } + /** + * @param uid + * @param searchList + * @return + */ + public List getDutyDeptRepository(String uid, List searchList) { + List list = new ArrayList(); + String deptIds = getDeptIdsInSql(uid); + if (searchList != null && searchList.size() > 0) { + for (PALRepositoryModel model : searchList) { + String dutyDept = model.getDutyDept(); + if (!UtilString.isEmpty(dutyDept) && deptIds.indexOf(dutyDept) > -1) { + list.add(model); + continue; + } else if (!UtilString.isEmpty(dutyDept) && deptIds.indexOf(dutyDept) == -1) { + continue; + } else { + String pid = model.getParentId(); + while (true) { + if (pid.length() < 36) { + break; + } else { + PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(pid); + if (!UtilString.isEmpty(parentModel.getDutyDept()) && deptIds.indexOf(parentModel.getDutyDept()) > -1) { + list.add(model); + break; + } else { + pid = parentModel.getParentId(); + } + } + } - /** - * - * @param uid - * @param searchList - * @return - */ - public List getDutyDeptRepository(String uid, List searchList) { - List list = new ArrayList(); - String deptIds = getDeptIdsInSql(uid); - if (searchList != null && searchList.size() > 0) { - for (PALRepositoryModel model : searchList) { - String dutyDept = model.getDutyDept(); - if (!UtilString.isEmpty(dutyDept) && deptIds.indexOf(dutyDept) > -1) { - list.add(model); - continue; - } else if (!UtilString.isEmpty(dutyDept) && deptIds.indexOf(dutyDept) == -1) { - continue; - } else { - String pid = model.getParentId(); - while (true) { - if (pid.length() < 36) { - break; - } else { - PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(pid); - if (!UtilString.isEmpty(parentModel.getDutyDept()) && deptIds.indexOf(parentModel.getDutyDept()) > -1) { - list.add(model); - break; - } else { - pid = parentModel.getParentId(); - } - } - } + } + } + } + return list; + } - } - } - } - return list; - } + /** + * 流程,发布版本下,未发布流程可见 + * + * @param context + * @param wsId + * @param pid + * @return + */ + public String getPublishProcessIsVisibleModelList(UserContext context, String wsId, String pid, String uuid) { + List subPublishList = getPublishedPalRepositoryModelsByPid(wsId, pid);// 发布的子流程 + List subUseList = getUsedPalRepositoryModelsByPid(wsId, pid);// 使用中的子流程 + List list = new ArrayList(); // 获取所有子流程 + Map map = new HashMap(); + for (int i = 0; i < subPublishList.size(); i++) { + PALRepositoryModel model = subPublishList.get(i); + map.put(model.getVersionId(), model); + } + List removeList = new ArrayList(); + if (subUseList != null && subUseList.size() > 0) { + for (int j = subUseList.size() - 1; j >= 0; j--) { + PALRepositoryModel model = subUseList.get(j); + if (map.containsKey(model.getVersionId())) { + list.add(map.get(model.getVersionId())); + removeList.add(model); + } + } + subUseList.removeAll(removeList); + } + list.addAll(subUseList); + Collections.sort(list, new Comparator1()); // 按级别排序 + JSONArray result = list2Json(context, list, true, false); + return result.toString(); + } - /** - * 流程,发布版本下,未发布流程可见 - * @param context - * @param wsId - * @param pid - * @return - */ - public String getPublishProcessIsVisibleModelList(UserContext context, String wsId, String pid,String uuid) { - List subPublishList = getPublishedPalRepositoryModelsByPid(wsId, pid);// 发布的子流程 - List subUseList = getUsedPalRepositoryModelsByPid(wsId, pid);// 使用中的子流程 - List list = new ArrayList(); // 获取所有子流程 - Map map = new HashMap(); - for (int i = 0; i < subPublishList.size(); i++) { - PALRepositoryModel model = subPublishList.get(i); - map.put(model.getVersionId(), model); - } - List removeList = new ArrayList(); - if (subUseList != null && subUseList.size() > 0) { - for (int j = subUseList.size() - 1; j >= 0; j--) { - PALRepositoryModel model = subUseList.get(j); - if (map.containsKey(model.getVersionId())) { - list.add(map.get(model.getVersionId())); - removeList.add(model); - } - } - subUseList.removeAll(removeList); - } - list.addAll(subUseList); - Collections.sort(list, new Comparator1()); // 按级别排序 - JSONArray result = list2Json(context, list, true, false); - return result.toString(); - } + /** + * 部门流程,获取根节点 + * + * @param uid + * @param wsId + * @param methodId + * @param category + * @param isUse + * @param isPublish + * @return + */ + public List getRootRepositoryModelListByDept(String uid, String wsId, String methodId, String category, boolean isUse, boolean isPublish) { + List rootUseList = new ArrayList(); + PALRepository dao = new PALRepository(); + String deptIds = getDeptIdsInSql(uid); + List deptList = dao.searchRepositoryListForProcessTree(wsId, methodId, category, isUse, isPublish, deptIds, null); + Map map = new HashMap(); + if (deptList != null && deptList.size() > 0) { + for (PALRepositoryModel model : deptList) { + map.put(model.getVersionId(), model); + } + } + if (deptList != null && deptList.size() > 0) { + for (PALRepositoryModel model : deptList) { + String pid = model.getParentId(); + while (true) { + if (pid.length() < 36) { + rootUseList.add(model); + break; + } else if (map.containsKey(pid)) { + break; + } else { + PALRepositoryModel tempModel = PALRepositoryCache.getCache().get(pid); + if (tempModel != null) { + pid = tempModel.getParentId(); + } else { + break; + } + } + } + } + } + return rootUseList; + } - /** - * 部门流程,获取根节点 - * @param uid - * @param wsId - * @param methodId - * @param category - * @param isUse - * @param isPublish - * @return - */ - public List getRootRepositoryModelListByDept(String uid, String wsId, String methodId, String category, boolean isUse, boolean isPublish) { - List rootUseList = new ArrayList(); - PALRepository dao = new PALRepository(); - String deptIds = getDeptIdsInSql(uid); - List deptList = dao.searchRepositoryListForProcessTree(wsId, methodId, category, isUse, isPublish, deptIds, null); - Map map = new HashMap(); - if (deptList != null && deptList.size() > 0) { - for (PALRepositoryModel model : deptList) { - map.put(model.getVersionId(), model); - } - } - if (deptList != null && deptList.size() > 0) { - for (PALRepositoryModel model : deptList) { - String pid = model.getParentId(); - while (true) { - if (pid.length() < 36) { - rootUseList.add(model); - break; - } else if (map.containsKey(pid)) { - break; - } else { - PALRepositoryModel tempModel = PALRepositoryCache.getCache().get(pid); - if (tempModel != null) { - pid = tempModel.getParentId(); - } else { - break; - } - } - } - } - } - return rootUseList; - } + /** + * 获取有发布版本的部门流程根节点,没有发布版本,取该节点的使用版本 + * + * @param uid + * @param wsId + * @param methodId + * @param category + * @param isUsed + * @param isPublish + * @return + */ + public List getPublishProcessIsVisibleModelListByDept(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { + List list = new ArrayList(); + List rootUseList = getRootRepositoryModelListByDept(uid, wsId, methodId, category, isUsed, isPublish); + List removeList = new ArrayList(); + if (rootUseList != null && rootUseList.size() > 0) { + for (int i = rootUseList.size() - 1; i >= 0; i--) { + PALRepositoryModel model = rootUseList.get(i); + List curModelList = PALRepositoryCache.getByVersionId(model.getWsId(), model.getVersionId()); + for (int j = 0; j < curModelList.size(); j++) { + PALRepositoryModel curModel = curModelList.get(j); + if (curModel.isPublish()) { + list.add(curModel); + removeList.add(model); + break; + } + } + } + rootUseList.removeAll(removeList); + } + list.addAll(rootUseList); + return list; + } - /** - * 获取有发布版本的部门流程根节点,没有发布版本,取该节点的使用版本 - * @param uid - * @param wsId - * @param methodId - * @param category - * @param isUsed - * @param isPublish - * @return - */ - public List getPublishProcessIsVisibleModelListByDept(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { - List list = new ArrayList(); - List rootUseList = getRootRepositoryModelListByDept(uid, wsId, methodId, category, isUsed, isPublish); - List removeList = new ArrayList(); - if (rootUseList != null && rootUseList.size() > 0) { - for (int i = rootUseList.size() - 1; i >= 0; i--) { - PALRepositoryModel model = rootUseList.get(i); - List curModelList = PALRepositoryCache.getByVersionId(model.getWsId(), model.getVersionId()); - for (int j = 0; j < curModelList.size(); j++) { - PALRepositoryModel curModel = curModelList.get(j); - if (curModel.isPublish()) { - list.add(curModel); - removeList.add(model); - break; - } - } - } - rootUseList.removeAll(removeList); - } - list.addAll(rootUseList); - return list; - } + /** + * 获取有发布版本的部门流程,没有发布版本,取该节点的使用版本 + * + * @param uid + * @param wsId + * @param methodId + * @param category + * @param isUsed + * @param isPublish + * @return + */ + public List getAllPublishProcessIsVisibleModelListByDept(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { + List list = new ArrayList(); + List allDeptList = getAllPALRepositoryModelsByDeptId(uid, wsId, methodId, category, isUsed, isPublish); + if (allDeptList == null) { + return list; + } + List removeList = new ArrayList(); + if (allDeptList.size() > 0) { + for (int i = 0; i < allDeptList.size(); i++) { + PALRepositoryModel model = allDeptList.get(i); + List curModelList = PALRepositoryCache.getByVersionId(model.getWsId(), model.getVersionId()); + for (int j = 0; j < curModelList.size(); j++) { + PALRepositoryModel curModel = curModelList.get(j); + if (curModel.isPublish()) { + list.add(curModel); + removeList.add(model); + break; + } + } + } + allDeptList.removeAll(removeList); + } + list.addAll(allDeptList); + return list; + } - /** - * 获取有发布版本的部门流程,没有发布版本,取该节点的使用版本 - * @param uid - * @param wsId - * @param methodId - * @param category - * @param isUsed - * @param isPublish - * @return - */ - public List getAllPublishProcessIsVisibleModelListByDept(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { - List list = new ArrayList(); - List allDeptList = getAllPALRepositoryModelsByDeptId(uid, wsId, methodId, category, isUsed, isPublish); - if (allDeptList == null) { - return list; - } - List removeList = new ArrayList(); - if (allDeptList.size() > 0) { - for (int i = 0; i < allDeptList.size(); i++) { - PALRepositoryModel model = allDeptList.get(i); - List curModelList = PALRepositoryCache.getByVersionId(model.getWsId(), model.getVersionId()); - for (int j = 0; j < curModelList.size(); j++) { - PALRepositoryModel curModel = curModelList.get(j); - if (curModel.isPublish()) { - list.add(curModel); - removeList.add(model); - break; - } - } - } - allDeptList.removeAll(removeList); - } - list.addAll(allDeptList); - return list; - } + /** + * 获取有发布版本部门根节点下流程,没有发布版本的流程不显示 + * + * @param uid + * @param wsId + * @param methodId + * @param category + * @param isUsed + * @param isPublish + * @return + */ + public List getPublishProcessIsHiddenModelListByDept(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { + List list = new ArrayList(); + List publishRootList = getRootRepositoryModelListByDept(uid, wsId, methodId, category, isUsed, isPublish); + if (publishRootList != null && publishRootList.size() > 0) { + for (PALRepositoryModel rootModel : publishRootList) { + if (rootModel.isPublish()) { + list.add(rootModel); + } + List childrenList = new ArrayList(); + getAllPublishedPalRepositoryModelsByPid(rootModel.getWsId(), rootModel.getId(), childrenList); + list.addAll(childrenList); + } + } + return list; + } - /** - * 获取有发布版本部门根节点下流程,没有发布版本的流程不显示 - * @param uid - * @param wsId - * @param methodId - * @param category - * @param isUsed - * @param isPublish - * @return - */ - public List getPublishProcessIsHiddenModelListByDept(String uid, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { - List list = new ArrayList(); - List publishRootList = getRootRepositoryModelListByDept(uid, wsId, methodId, category, isUsed, isPublish); - if (publishRootList != null && publishRootList.size() > 0) { - for (PALRepositoryModel rootModel : publishRootList) { - if (rootModel.isPublish()) { - list.add(rootModel); - } - List childrenList = new ArrayList(); - getAllPublishedPalRepositoryModelsByPid(rootModel.getWsId(), rootModel.getId(), childrenList); - list.addAll(childrenList); - } - } - return list; - } + /** + * 流程树--根据流程名称搜索流程 + * + * @param context + * @param wsId + * @param methodId + * @param category + * @param processType + * @param isUse + * @param isPublish + * @param palName + * @return + */ + public List searchPALRepositoryByName(UserContext context, String wsId, String methodId, String category, String processType, boolean isUse, boolean isPublish, String palName) { + String deptIds = ""; + if (!UtilString.isEmpty(processType) && processType.equals("dept")) { + deptIds = getDeptIdsInSql(context.getUID()); + } + return new PALRepository().searchRepositoryListForProcessTree(wsId, methodId, category, isUse, isPublish, deptIds, palName); + } - /** - * 流程树--根据流程名称搜索流程 - * @param context - * @param wsId - * @param methodId - * @param category - * @param processType - * @param isUse - * @param isPublish - * @param palName - * @return - */ - public List searchPALRepositoryByName(UserContext context, String wsId, String methodId, String category, String processType, boolean isUse, boolean isPublish, String palName) { - String deptIds = ""; - if (!UtilString.isEmpty(processType) && processType.equals("dept")) { - deptIds = getDeptIdsInSql(context.getUID()); - } - return new PALRepository().searchRepositoryListForProcessTree(wsId, methodId, category, isUse, isPublish, deptIds, palName); - } + public JSONArray searchList2Json(UserContext context, List list, boolean isUsed, boolean isPublished) { + return searchList2Json(context, list, isUsed, isPublished, null); + } - public JSONArray searchList2Json(UserContext context, List list, boolean isUsed, boolean isPublished) { - return searchList2Json(context, list, isUsed, isPublished, null); - } + private JSONArray searchList2Json(UserContext context, List list, boolean isUsed, boolean isPublished, String removeIds) { + JSONArray jsonArray = new JSONArray(); + for (PALRepositoryModel model : list) { + JSONObject object = new JSONObject(); + object.put("id", model.getId().trim()); + object.put("pid", model.getNewParentId().trim()); + if (removeIds != null && removeIds.contains(model.getId().trim())) { + object.put("nocheck", true); + } else { + object.put("nocheck", false); + } + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("title", object.get("name")); + } else { + object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); + } + object.put("drop", false); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + object.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/default/16.png"); + } else { + object.put("icon", "../apps/" + PALMethodCache.getPALMethodModelById(model.getMethodId()).getApp().getId() + "/img/method/" + model.getMethodId() + "/16.png"); + } - private JSONArray searchList2Json(UserContext context, List list, boolean isUsed, boolean isPublished, String removeIds) { - JSONArray jsonArray = new JSONArray(); - for (PALRepositoryModel model : list) { - JSONObject object = new JSONObject(); - object.put("id", model.getId().trim()); - object.put("pid", model.getNewParentId().trim()); - if (removeIds != null && removeIds.contains(model.getId().trim())) { - object.put("nocheck", true); - } else { - object.put("nocheck", false); - } - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("title", object.get("name")); - } else { - object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim()); - } - object.put("drop", false); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - object.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/default/16.png"); - } else { - object.put("icon", "../apps/" + PALMethodCache.getPALMethodModelById(model.getMethodId()).getApp().getId() + "/img/method/" + model.getMethodId() + "/16.png"); - } + List children = null; + if (isUsed) { + children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + } else if (isPublished) { + children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); + } + if (children == null || children.size() == 0) { + object.put("isParent", false); + String icon = object.getString("icon"); + object.put("icon", icon.replace("16.png", "16.leaf.png")); + } else { + object.put("isParent", true); + object.put("open", false); + } - List children = null; - if (isUsed) { - children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - } else if (isPublished) { - children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId()); - } - if (children == null || children.size() == 0) { - object.put("isParent", false); - String icon = object.getString("icon"); - object.put("icon", icon.replace("16.png", "16.leaf.png")); - } else { - object.put("isParent", true); - object.put("open", false); - } + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isUse", model.isUse()); + object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + String dutyDeptId = model.getDutyDept(); + object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); + String plDutyDeptName = dutyDeptId; + if (!UtilString.isEmpty(dutyDeptId)) { + if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { + plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); + } + } + object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); + String plDutyPerson = model.getDutyUser(); + object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); + object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); + List models = new ArrayList(); + models.add(model); + PALRepositoryModel tempModel; + String parentId = model.getParentId(); + while (true) { + tempModel = PALRepositoryCache.getCache().get(parentId); + if (tempModel != null) { + models.add(tempModel); + parentId = tempModel.getParentId(); + } else { + if (parentId.length() < 36) { + PALRepositoryModelImpl cplm = new PALRepositoryModelImpl(); + cplm.setId(parentId); + cplm.setName(parentId); + models.add(cplm); + } + break; + } + } + StringBuffer sb = new StringBuffer(); + for (int ii = models.size() - 1; ii >= 0; ii--) { + PALRepositoryModel plModel = models.get(ii); + sb.append(I18nRes.findValue(CoEConstant.APP_ID, plModel.getName())); + if (ii != 0) { + sb.append(">"); + } + } + object.put("currentPath", sb.toString()); + jsonArray.add(object); + } + return jsonArray; + } - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isUse", model.isUse()); - object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - String dutyDeptId = model.getDutyDept(); - object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId); - String plDutyDeptName = dutyDeptId; - if (!UtilString.isEmpty(dutyDeptId)) { - if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) { - plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName(); - } - } - object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName); - String plDutyPerson = model.getDutyUser(); - object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser()); - object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson)); - List models = new ArrayList(); - models.add(model); - PALRepositoryModel tempModel; - String parentId = model.getParentId(); - while (true) { - tempModel = PALRepositoryCache.getCache().get(parentId); - if (tempModel != null) { - models.add(tempModel); - parentId = tempModel.getParentId(); - } else { - if (parentId.length() < 36) { - PALRepositoryModelImpl cplm = new PALRepositoryModelImpl(); - cplm.setId(parentId); - cplm.setName(parentId); - models.add(cplm); - } - break; - } - } - StringBuffer sb = new StringBuffer(); - for (int ii = models.size() - 1; ii >= 0; ii--) { - PALRepositoryModel plModel = models.get(ii); - sb.append(I18nRes.findValue(CoEConstant.APP_ID, plModel.getName())); - if (ii != 0) { - sb.append(">"); - } - } - object.put("currentPath", sb.toString()); - jsonArray.add(object); - } - return jsonArray; - } + /** + * 根据部门Id获取流程 + * + * @param deptIds + * @param wsId + * @param methodId + * @param category + * @param isUsed + * @param isPublish + * @return + */ + public List getRootPALRepositoryModelsByBP(String deptIds, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { + List list = new PALRepository().getRootPALRepositoryModelsByDeptId(deptIds, wsId, methodId, category, isUsed, isPublish); + List rootList = new ArrayList(); + if (list != null && list.size() > 0) { + Set versionIds = new HashSet(); + for (PALRepositoryModel model : list) { + versionIds.add(model.getVersionId()); + } + for (PALRepositoryModel model : list) { + boolean flag = true; + String pid = model.getParentId(); + while (pid.length() == 36) { + if (versionIds.contains(pid)) { + flag = false; + break; + } + List pList = PALRepositoryCache.getByVersionId(model.getWsId(), pid); + if (pList == null || pList.size() == 0) { + // 如果父节点已经不在资产库中,则不显示该节点。 + flag = false; + break; + } + pid = pList.get(0).getParentId(); - /** - * 根据部门Id获取流程 - * @param deptIds - * @param wsId - * @param methodId - * @param category - * @param isUsed - * @param isPublish - * @return - */ - public List getRootPALRepositoryModelsByBP(String deptIds, String wsId, String methodId, String category, boolean isUsed, boolean isPublish) { - List list = new PALRepository().getRootPALRepositoryModelsByDeptId(deptIds, wsId, methodId, category, isUsed, isPublish); - List rootList = new ArrayList(); - if (list != null && list.size() > 0) { - Set versionIds = new HashSet(); - for (PALRepositoryModel model : list) { - versionIds.add(model.getVersionId()); - } - for (PALRepositoryModel model : list) { - boolean flag = true; - String pid = model.getParentId(); - while (pid.length() == 36) { - if (versionIds.contains(pid)) { - flag = false; - break; - } - List pList = PALRepositoryCache.getByVersionId(model.getWsId(), pid); - if (pList == null || pList.size() == 0) { - // 如果父节点已经不在资产库中,则不显示该节点。 - flag = false; - break; - } - pid = pList.get(0).getParentId(); + } + if (flag) { + rootList.add(model); + } + } + /** + * 如果流程的父节点也在列表中,则只保留 + */ + } + return rootList; + } - } - if (flag) { - rootList.add(model); - } - } - /** - * 如果流程的父节点也在列表中,则只保留 - */ - } - return rootList; - } + /** + * 获取指定层级的流程 + * + * @param _uc + * @param wsId + * @param methodId + * @param category + * @param isUsed + * @param isPublish + * @param level + * @return + */ + public JSONArray getSpecityLevelRepository(UserContext _uc, String wsId, String methodId, String category, boolean isUsed, boolean isPublish, int level) { + JSONArray array = new JSONArray(); + PALRepository dao = new PALRepository(); + String deptId = getDeptIdsInSql(_uc); + List list = dao.getSpecityLevelByDeptId(deptId, wsId, methodId, category, isUsed, isPublish, level); + if (list != null && list.size() > 0) { + StringBuilder filePerms = new StringBuilder(); + for (PALRepositoryModel model : list) { + filePerms.append(model.getId()).append(","); + } - /** - * 获取指定层级的流程 - * @param _uc - * @param wsId - * @param methodId - * @param category - * @param isUsed - * @param isPublish - * @param level - * @return - */ - public JSONArray getSpecityLevelRepository(UserContext _uc, String wsId, String methodId, String category, boolean isUsed, boolean isPublish, int level) { - JSONArray array = new JSONArray(); - PALRepository dao = new PALRepository(); - String deptId = getDeptIdsInSql(_uc); - List list = dao.getSpecityLevelByDeptId(deptId, wsId, methodId, category, isUsed, isPublish, level); - if (list != null && list.size() > 0) { - StringBuilder filePerms = new StringBuilder(); - for (PALRepositoryModel model : list) { - filePerms.append(model.getId()).append(","); - } + for (int i = 0; i < list.size(); i++) { + PALRepositoryModel model = list.get(i); + JSONObject obj = JSONObject.parseObject(model.toJson()); + String openUrl = "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_viewer" + "&uuid=" + model.getId() + "&openType=0&processDefId=" + model.getVersionId() + "&collaboration=1&teamId=&perms=v" + "&filePerms=" + filePerms; + obj.put("openUrl", openUrl); + array.add(obj); + } - for (int i = 0; i < list.size(); i++) { - PALRepositoryModel model = list.get(i); - JSONObject obj = JSONObject.parseObject(model.toJson()); - String openUrl = "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_viewer" + "&uuid=" + model.getId() + "&openType=0&processDefId=" + model.getVersionId() + "&collaboration=1&teamId=&perms=v" + "&filePerms=" + filePerms; - obj.put("openUrl", openUrl); - array.add(obj); - } + } + return array; + } - } - return array; - } + /** + * 根据uc,获取可以查看的流程的责任部门Id + * + * @param uc + * @return + */ + public String getDeptIdsInSql(UserContext uc) { + String plDeptLayerS = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_PLDEPT_LAYER); + int plDeptLayer = Integer.parseInt(plDeptLayerS); + String deptId = ""; // 要查找的顶级部门 + String deptIds = ""; + DepartmentModel dept = SDK.getORGAPI().getDepartmentByUser(uc.getUID()); + // 如果属性设置的流程责任部门组织级别为-1,则查询责任部门为当前部门及子部门的流程 + if ("-1".equals(plDeptLayerS)) { + deptId = dept.getId(); + } else { + int deptLayer = dept.getLayer(); + if (deptLayer == plDeptLayer) { + deptId = dept.getId(); + } else if (deptLayer > plDeptLayer) { + // 当前用户的级别小于流程责任部门组织级别,则向上查找上级部门 + while (deptLayer > plDeptLayer) { + String pDeptId = dept.getParentDepartmentId(); + dept = SDK.getORGAPI().getDepartmentById(pDeptId); + if (dept == null) { + break; + } + deptLayer = dept.getLayer(); + } + if (deptLayer == plDeptLayer) { + deptId = dept.getId(); + } + } else if (deptLayer < plDeptLayer) { + // 当前用户的级别大于流程责任部门组织级别,则从当前部门向下查找所有子部门 + deptId = dept.getId(); + } + } + // 查询所有子部门 + List departmentList = new ArrayList(); + DepartmentCache.getAllDepartmentList(deptId, departmentList); + StringBuilder ids = new StringBuilder("'" + deptId + "'"); + for (DepartmentModel model : departmentList) { + ids.append(",'").append(model.getId()).append("'"); + } + deptIds = ids.toString(); + return deptIds; + } - /** - * 根据uc,获取可以查看的流程的责任部门Id - * @param uc - * @return - */ - public String getDeptIdsInSql(UserContext uc) { - String plDeptLayerS = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_PLDEPT_LAYER); - int plDeptLayer = Integer.parseInt(plDeptLayerS); - String deptId = ""; // 要查找的顶级部门 - String deptIds = ""; - DepartmentModel dept = SDK.getORGAPI().getDepartmentByUser(uc.getUID()); - // 如果属性设置的流程责任部门组织级别为-1,则查询责任部门为当前部门及子部门的流程 - if ("-1".equals(plDeptLayerS)) { - deptId = dept.getId(); - } else { - int deptLayer = dept.getLayer(); - if (deptLayer == plDeptLayer) { - deptId = dept.getId(); - } else if (deptLayer > plDeptLayer) { - // 当前用户的级别小于流程责任部门组织级别,则向上查找上级部门 - while (deptLayer > plDeptLayer) { - String pDeptId = dept.getParentDepartmentId(); - dept = SDK.getORGAPI().getDepartmentById(pDeptId); - if (dept == null) { - break; - } - deptLayer = dept.getLayer(); - } - if (deptLayer == plDeptLayer) { - deptId = dept.getId(); - } - } else if (deptLayer < plDeptLayer) { - // 当前用户的级别大于流程责任部门组织级别,则从当前部门向下查找所有子部门 - deptId = dept.getId(); - } - } - // 查询所有子部门 - List departmentList = new ArrayList(); - DepartmentCache.getAllDepartmentList(deptId, departmentList); - StringBuilder ids = new StringBuilder("'" + deptId + "'"); - for (DepartmentModel model : departmentList) { - ids.append(",'").append(model.getId()).append("'"); - } - deptIds = ids.toString(); - return deptIds; - } + /** + * 获取流程图片 + * + * @param _uc 用户上下文对象 + * @param uuid 流程Id + * @return 图片url + */ + public String getPalRepositoryModelPicture(UserContext _uc, String uuid) { + PALRepositoryModel cplm = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + if (cplm == null) { + return null; + } + String p = cplm.getFilePath(); + String url = ""; + if (!"".equals(p)) { + UtilFile file = new UtilFile(p + "/" + cplm.getId() + ".png"); + if (file.exists()) { + DCContext dcContext = null; + DCUtil.getInstance(); + dcContext = DCUtil.createTempFileContext(CoEConstant.APP_ID, "Designer", "PNG", "png"); + String cplmName = cplm.getName().replace("\n", ""); + cplmName = StringHandleUtil.filenameFilter(cplmName, "-"); + dcContext.setFileName(cplmName + ".png"); + File ff = new File(dcContext.getFilePath()); + FileOutputStream fos = null; + try { + fos = new FileOutputStream(ff); + fos.write(file.readBytes()); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (fos != null) { + fos.flush(); + fos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + dcContext.setSession(_uc); + url = SDK.getConfAPI().getPortalUrl() + "/r/" + dcContext.getDownloadURL().replace("./", ""); + } + } + return url; + } - /** - * 获取流程图片 - * @param _uc 用户上下文对象 - * @param uuid 流程Id - * @return 图片url - */ - public String getPalRepositoryModelPicture(UserContext _uc, String uuid) { - PALRepositoryModel cplm = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - if (cplm == null) { - return null; - } - String p = cplm.getFilePath(); - String url = ""; - if (!"".equals(p)) { - UtilFile file = new UtilFile(p + "/" + cplm.getId() + ".png"); - if (file.exists()) { - DCContext dcContext = null; - DCUtil.getInstance(); - dcContext = DCUtil.createTempFileContext(CoEConstant.APP_ID, "Designer", "PNG", "png"); - String cplmName = cplm.getName().replace("\n", ""); - cplmName = StringHandleUtil.filenameFilter(cplmName, "-"); - dcContext.setFileName(cplmName + ".png"); - File ff = new File(dcContext.getFilePath()); - FileOutputStream fos = null; - try { - fos = new FileOutputStream(ff); - fos.write(file.readBytes()); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (fos != null) { - fos.flush(); - fos.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - dcContext.setSession(_uc); - url = SDK.getConfAPI().getPortalUrl() + "/r/" + dcContext.getDownloadURL().replace("./", ""); - } - } - return url; - } - - /** - * 导出单个流程手册 - * 仅限于应用流程手册com.actionsoft.apps.coe.pal.output.pr下的手册导出 - * @param wsId 资产库Id - * @param userId 用户Id - * @param teamId 小组Id - * @param fileId 流程文件Id - * @return 返回创建流程手册结果及taskId - */ - public String createOutputReportPr(String wsId, String userId, String teamId, String fileId) { - UserContext _uc = UserContext.fromUID(userId); - OutPutReportWeb web = new OutPutReportWeb(_uc); - String appId = "com.actionsoft.apps.coe.pal.output.pr"; - // 报告生成器参数配置 - boolean shapeNumberSort = SDK.getAppAPI().getPropertyBooleanValue(appId, "SHAPE_NUMBER_SORT", true); - String config = "{'isItReport':true,'orderNuberFirst':" + shapeNumberSort + ",'orderNametwo':false,'reportNameIsItName':'%fileName%_%fileVersion%'}";// 配置 - // 流程手册参数配置 cross:步骤横表,默认值/ vertical:步骤竖表/ project:项目定制 - String defaultReportPr = SDK.getAppAPI().getProperty(appId, "DEFAULT_REPORT_PR"); - String title = ""; - if ("cross".equals(defaultReportPr) || defaultReportPr == null || "".equals(defaultReportPr)) {// 步骤横表(默认) - title = "步骤横表"; - } - if ("vertical".equals(defaultReportPr)) {// 步骤竖表 - title = "步骤竖表"; - } + /** + * 导出单个流程手册 + * 仅限于应用流程手册com.actionsoft.apps.coe.pal.output.pr下的手册导出 + * + * @param wsId 资产库Id + * @param userId 用户Id + * @param teamId 小组Id + * @param fileId 流程文件Id + * @return 返回创建流程手册结果及taskId + */ + public String createOutputReportPr(String wsId, String userId, String teamId, String fileId) { + UserContext _uc = UserContext.fromUID(userId); + OutPutReportWeb web = new OutPutReportWeb(_uc); + String appId = "com.actionsoft.apps.coe.pal.output.pr"; + // 报告生成器参数配置 + boolean shapeNumberSort = SDK.getAppAPI().getPropertyBooleanValue(appId, "SHAPE_NUMBER_SORT", true); + String config = "{'isItReport':true,'orderNuberFirst':" + shapeNumberSort + ",'orderNametwo':false,'reportNameIsItName':'%fileName%_%fileVersion%'}";// 配置 + // 流程手册参数配置 cross:步骤横表,默认值/ vertical:步骤竖表/ project:项目定制 + String defaultReportPr = SDK.getAppAPI().getProperty(appId, "DEFAULT_REPORT_PR"); + String title = ""; + if ("cross".equals(defaultReportPr) || defaultReportPr == null || "".equals(defaultReportPr)) {// 步骤横表(默认) + title = "步骤横表"; + } + if ("vertical".equals(defaultReportPr)) {// 步骤竖表 + title = "步骤竖表"; + } /*if ("project".equals(defaultReportPr)) {// 项目定制 }*/ - // 获取流程手册下所有的流程模板 - List list = web.getOutputAppByAppId(appId); - OutputAppProfile outputAppProfile = null; - for (OutputAppProfile profile : list) { - if ("".equals(title) && !"步骤横表".equals(profile.getTitle()) && !"步骤竖表".equals(profile.getTitle())) { - outputAppProfile = profile; - break; - } - if (!"".equals(title) && title.equals(profile.getTitle())) { - outputAppProfile = profile; - break; - } - } - if (outputAppProfile == null) { - throw new AWSException("创建流程手册失败,未找到报告模版"); - } - String profileId = outputAppProfile.getId(); - String taskName = outputAppProfile.getTitle(); - String language = "".equals(outputAppProfile.getLang())?"cn":outputAppProfile.getLang(); - String isExecute = "Y"; - String targetShape = ""; - String relationFileId = ""; - String isModify = "false"; - String taskId = ""; - String result = web.reportSaveByCallable(language, taskName, userId, teamId, profileId, wsId, isExecute, config, fileId, targetShape, relationFileId, isModify, taskId); - ResponseObject ro = ResponseObject.parse(result); - if (ro.isOk()) { - com.alibaba.fastjson.JSONObject object = (com.alibaba.fastjson.JSONObject) ro.getData(); - String id = object.getString("taskId"); - // 更改状态为隐藏,不在界面显示该方式创建的流程手册数据 - new OutputTask().updateIsDisplayStatus(id); - } - return result; - } + // 获取流程手册下所有的流程模板 + List list = web.getOutputAppByAppId(appId); + OutputAppProfile outputAppProfile = null; + for (OutputAppProfile profile : list) { + if ("".equals(title) && !"步骤横表".equals(profile.getTitle()) && !"步骤竖表".equals(profile.getTitle())) { + outputAppProfile = profile; + break; + } + if (!"".equals(title) && title.equals(profile.getTitle())) { + outputAppProfile = profile; + break; + } + } + if (outputAppProfile == null) { + throw new AWSException("创建流程手册失败,未找到报告模版"); + } + String profileId = outputAppProfile.getId(); + String taskName = outputAppProfile.getTitle(); + String language = "".equals(outputAppProfile.getLang()) ? "cn" : outputAppProfile.getLang(); + String isExecute = "Y"; + String targetShape = ""; + String relationFileId = ""; + String isModify = "false"; + String taskId = ""; + String result = web.reportSaveByCallable(language, taskName, userId, teamId, profileId, wsId, isExecute, config, fileId, targetShape, relationFileId, isModify, taskId); + ResponseObject ro = ResponseObject.parse(result); + if (ro.isOk()) { + com.alibaba.fastjson.JSONObject object = (com.alibaba.fastjson.JSONObject) ro.getData(); + String id = object.getString("taskId"); + // 更改状态为隐藏,不在界面显示该方式创建的流程手册数据 + new OutputTask().updateIsDisplayStatus(id); + } + return result; + } - /** - * 导出单个表单手册 - * 仅限于应用流程手册com.awspaas.user.apps.coe.pal.output.bd下的手册导出 - * @param wsId 资产库Id - * @param userId 用户Id - * @param teamId 小组Id - * @param fileId 流程文件Id - * @return 返回创建流程手册结果及taskId - */ - public String createOutputReportBd(String wsId, String userId, String teamId, String fileId) { - UserContext _uc = UserContext.fromUID(userId); - OutPutReportWeb web = new OutPutReportWeb(_uc); - String appId = "com.awspaas.user.apps.coe.pal.output.bd"; - // 报告生成器参数配置 - String config = "{'isItReport':true,'orderNuberFirst':true,'orderNametwo':false,'reportNameIsItName':'%fileName%_%fileVersion%'}";// 配置 - String title = "表单-手册"; + /** + * 导出单个表单手册 + * 仅限于应用流程手册com.awspaas.user.apps.coe.pal.output.bd下的手册导出 + * + * @param wsId 资产库Id + * @param userId 用户Id + * @param teamId 小组Id + * @param fileId 流程文件Id + * @return 返回创建流程手册结果及taskId + */ + public String createOutputReportBd(String wsId, String userId, String teamId, String fileId) { + UserContext _uc = UserContext.fromUID(userId); + OutPutReportWeb web = new OutPutReportWeb(_uc); + String appId = "com.awspaas.user.apps.coe.pal.output.bd"; + // 报告生成器参数配置 + String config = "{'isItReport':true,'orderNuberFirst':true,'orderNametwo':false,'reportNameIsItName':'%fileName%_%fileVersion%'}";// 配置 + String title = "表单-手册"; - // 获取流程手册下所有的流程模板 - List list = web.getOutputAppByAppId(appId); - OutputAppProfile outputAppProfile = null; - for (OutputAppProfile profile : list) { - if (!"".equals(title) && title.equals(profile.getTitle())) { - outputAppProfile = profile; - break; - } - } - if (outputAppProfile == null) { - throw new AWSException("创建表单手册失败,未找到报告模版"); - } - String profileId = outputAppProfile.getId(); - String taskName = outputAppProfile.getTitle(); - String language = "".equals(outputAppProfile.getLang())?"cn":outputAppProfile.getLang(); - String isExecute = "Y"; - String targetShape = ""; - String relationFileId = ""; - String isModify = "false"; - String taskId = ""; - String result = web.reportSaveByCallable(language, taskName, userId, teamId, profileId, wsId, isExecute, config, fileId, targetShape, relationFileId, isModify, taskId); - ResponseObject ro = ResponseObject.parse(result); - if (ro.isOk()) { - com.alibaba.fastjson.JSONObject object = (com.alibaba.fastjson.JSONObject) ro.getData(); - String id = object.getString("taskId"); - // 更改状态为隐藏,不在界面显示该方式创建的流程手册数据 - new OutputTask().updateIsDisplayStatus(id); - } - return result; - } + // 获取流程手册下所有的流程模板 + List list = web.getOutputAppByAppId(appId); + OutputAppProfile outputAppProfile = null; + for (OutputAppProfile profile : list) { + if (!"".equals(title) && title.equals(profile.getTitle())) { + outputAppProfile = profile; + break; + } + } + if (outputAppProfile == null) { + throw new AWSException("创建表单手册失败,未找到报告模版"); + } + String profileId = outputAppProfile.getId(); + String taskName = outputAppProfile.getTitle(); + String language = "".equals(outputAppProfile.getLang()) ? "cn" : outputAppProfile.getLang(); + String isExecute = "Y"; + String targetShape = ""; + String relationFileId = ""; + String isModify = "false"; + String taskId = ""; + String result = web.reportSaveByCallable(language, taskName, userId, teamId, profileId, wsId, isExecute, config, fileId, targetShape, relationFileId, isModify, taskId); + ResponseObject ro = ResponseObject.parse(result); + if (ro.isOk()) { + com.alibaba.fastjson.JSONObject object = (com.alibaba.fastjson.JSONObject) ro.getData(); + String id = object.getString("taskId"); + // 更改状态为隐藏,不在界面显示该方式创建的流程手册数据 + new OutputTask().updateIsDisplayStatus(id); + } + return result; + } - /** - * 导出单个制度手册 - * 仅限于应用流程手册com.awspaas.user.apps.coe.pal.output.bd下的手册导出 - * @param wsId 资产库Id - * @param userId 用户Id - * @param teamId 小组Id - * @param fileId 流程文件Id - * @return 返回创建流程手册结果及taskId - */ - public String createOutputReportZd(String wsId, String userId, String teamId, String fileId) { - UserContext _uc = UserContext.fromUID(userId); - OutPutReportWeb web = new OutPutReportWeb(_uc); - String appId = "com.awspaas.user.apps.coe.pal.output.zd"; - // 报告生成器参数配置 - String config = "{'isItReport':true,'orderNuberFirst':true,'orderNametwo':false,'reportNameIsItName':'%fileName%_%fileVersion%'}";// 配置 - String title = "制度-手册"; + /** + * 导出单个制度手册 + * 仅限于应用流程手册com.awspaas.user.apps.coe.pal.output.bd下的手册导出 + * + * @param wsId 资产库Id + * @param userId 用户Id + * @param teamId 小组Id + * @param fileId 流程文件Id + * @return 返回创建流程手册结果及taskId + */ + public String createOutputReportZd(String wsId, String userId, String teamId, String fileId) { + UserContext _uc = UserContext.fromUID(userId); + OutPutReportWeb web = new OutPutReportWeb(_uc); + String appId = "com.awspaas.user.apps.coe.pal.output.zd"; + // 报告生成器参数配置 + String config = "{'isItReport':true,'orderNuberFirst':true,'orderNametwo':false,'reportNameIsItName':'%fileName%_%fileVersion%'}";// 配置 + String title = "制度-手册"; - // 获取流程手册下所有的流程模板 - List list = web.getOutputAppByAppId(appId); - OutputAppProfile outputAppProfile = null; - for (OutputAppProfile profile : list) { - if (!"".equals(title) && title.equals(profile.getTitle())) { - outputAppProfile = profile; - break; - } - } - if (outputAppProfile == null) { - throw new AWSException("创建制度手册失败,未找到报告模版"); - } - String profileId = outputAppProfile.getId(); - String taskName = outputAppProfile.getTitle(); - String language = "".equals(outputAppProfile.getLang())?"cn":outputAppProfile.getLang(); - String isExecute = "Y"; - String targetShape = ""; - String relationFileId = ""; - String isModify = "false"; - String taskId = ""; - String result = web.reportSaveByCallable(language, taskName, userId, teamId, profileId, wsId, isExecute, config, fileId, targetShape, relationFileId, isModify, taskId); - ResponseObject ro = ResponseObject.parse(result); - if (ro.isOk()) { - com.alibaba.fastjson.JSONObject object = (com.alibaba.fastjson.JSONObject) ro.getData(); - String id = object.getString("taskId"); - // 更改状态为隐藏,不在界面显示该方式创建的流程手册数据 - new OutputTask().updateIsDisplayStatus(id); - } - return result; - } + // 获取流程手册下所有的流程模板 + List list = web.getOutputAppByAppId(appId); + OutputAppProfile outputAppProfile = null; + for (OutputAppProfile profile : list) { + if (!"".equals(title) && title.equals(profile.getTitle())) { + outputAppProfile = profile; + break; + } + } + if (outputAppProfile == null) { + throw new AWSException("创建制度手册失败,未找到报告模版"); + } + String profileId = outputAppProfile.getId(); + String taskName = outputAppProfile.getTitle(); + String language = "".equals(outputAppProfile.getLang()) ? "cn" : outputAppProfile.getLang(); + String isExecute = "Y"; + String targetShape = ""; + String relationFileId = ""; + String isModify = "false"; + String taskId = ""; + String result = web.reportSaveByCallable(language, taskName, userId, teamId, profileId, wsId, isExecute, config, fileId, targetShape, relationFileId, isModify, taskId); + ResponseObject ro = ResponseObject.parse(result); + if (ro.isOk()) { + com.alibaba.fastjson.JSONObject object = (com.alibaba.fastjson.JSONObject) ro.getData(); + String id = object.getString("taskId"); + // 更改状态为隐藏,不在界面显示该方式创建的流程手册数据 + new OutputTask().updateIsDisplayStatus(id); + } + return result; + } - /** - * 预览流程手册 - * @param _uc - * @param taskId - * @return - */ - public String outputReportPreview(UserContext _uc, String taskId) { - OutputTaskModel model = new OutputTask().getTaskReportById(taskId); - ResponseObject result = ResponseObject.newOkResponse(); - if (model != null) { - try { - UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId()); - if (file.exists()) { - File[] fileList = file.listFiles(); - if (fileList.length > 0) { - File docFile = null; - for (File file2 : fileList) { - if (file2.isFile() && "doc".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) { - docFile = file2; - break; - } - } - if (docFile == null) { - return ResponseObject.newErrResponse("没有找到文件").toString(); - } - if (SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) { - OutputAppProfile appFile = OutputAppManager.getProfile(model.getProfileId()); - String sourceAppId = appFile.getAppContext().getId(); - String filename = docFile.getName(); - DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename); - Map aslpParams = new HashMap(); + /** + * 预览流程手册 + * + * @param _uc + * @param taskId + * @return + */ + public String outputReportPreview(UserContext _uc, String taskId) { + OutputTaskModel model = new OutputTask().getTaskReportById(taskId); + ResponseObject result = ResponseObject.newOkResponse(); + if (model != null) { + try { + UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId()); + if (file.exists()) { + File[] fileList = file.listFiles(); + if (fileList.length > 0) { + File docFile = null; + for (File file2 : fileList) { + if (file2.isFile() && "doc".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) { + docFile = file2; + break; + } + } + if (docFile == null) { + return ResponseObject.newErrResponse("没有找到文件").toString(); + } + if (SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) { + OutputAppProfile appFile = OutputAppManager.getProfile(model.getProfileId()); + String sourceAppId = appFile.getAppContext().getId(); + String filename = docFile.getName(); + DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename); + Map aslpParams = new HashMap(); - aslpParams.put("sid", _uc.getSessionId()); - aslpParams.put("fileNameOriginal", filename); - aslpParams.put("sourceDc", sourceDc); - aslpParams.put("isShowDefaultToolbar", true); - aslpParams.put("isShowBackbtn", false); - aslpParams.put("isEncrypt", true); - aslpParams.put("isCopy", true); - aslpParams.put("isPrint", true); - aslpParams.put("isDownload", true); - AppAPI appAPI = SDK.getAppAPI(); - ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext(sourceAppId), "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview", aslpParams); - if (responseObject != null) { - if (responseObject.isOk()) { - String url = responseObject.get("url").toString(); - result.put("url", url); - result.put("filename", filename); - } else { - result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员"); - } - } - } else { - result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员"); - } - } - }else{ - result = ResponseObject.newErrResponse("没有可预览文件"); - } - } catch (Exception e) { - e.printStackTrace(); - return ResponseObject.newErrResponse().toString(); - } - } - return result.toString(); - } + aslpParams.put("sid", _uc.getSessionId()); + aslpParams.put("fileNameOriginal", filename); + aslpParams.put("sourceDc", sourceDc); + aslpParams.put("isShowDefaultToolbar", true); + aslpParams.put("isShowBackbtn", false); + aslpParams.put("isEncrypt", true); + aslpParams.put("isCopy", true); + aslpParams.put("isPrint", true); + aslpParams.put("isDownload", true); + AppAPI appAPI = SDK.getAppAPI(); + ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext(sourceAppId), "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview", aslpParams); + if (responseObject != null) { + if (responseObject.isOk()) { + String url = responseObject.get("url").toString(); + result.put("url", url); + result.put("filename", filename); + } else { + result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员"); + } + } + } else { + result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员"); + } + } + } else { + result = ResponseObject.newErrResponse("没有可预览文件"); + } + } catch (Exception e) { + e.printStackTrace(); + return ResponseObject.newErrResponse().toString(); + } + } + return result.toString(); + } - /** - * 流程手册下载 - * @param _uc - * @param taskId - * @return - */ - public String outputReportDownload(UserContext _uc, String taskId,String ruuid) { - OutputTaskModel model = new OutputTask().getTaskReportById(taskId); - ResponseObject result = ResponseObject.newOkResponse(); - if (model != null) { - try { - UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId()); - if (file.exists()) { - File[] fileList = file.listFiles(); - if (fileList.length > 0) { - File docFile = null; - for (File file2 : fileList) { - if (file2.isFile() && "doc".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) { - docFile = file2; - break; - } - } - if (docFile == null) { - return ResponseObject.newErrResponse("没有找到文件").toString(); - } - + /** + * 流程手册下载 + * + * @param _uc + * @param taskId + * @return + */ + public String outputReportDownload(UserContext _uc, String taskId, String ruuid) { + OutputTaskModel model = new OutputTask().getTaskReportById(taskId); + ResponseObject result = ResponseObject.newOkResponse(); + if (model != null) { + try { + UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId()); + if (file.exists()) { + File[] fileList = file.listFiles(); + if (fileList.length > 0) { + File docFile = null; + for (File file2 : fileList) { + if (file2.isFile() && "doc".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) { + docFile = file2; + break; + } + } + if (docFile == null) { + return ResponseObject.newErrResponse("没有找到文件").toString(); + } + /*String plId = DBSql.getString("SELECT PALREPOSITORYID FROM app_act_coe_pal_publish_list WHERE TASKID ='"+taskId+"'"); if(UtilString.isNotEmpty(plId)) { PALRepositoryModel plmodel = PALRepositoryCache.getCache().get(plId); @@ -3555,2059 +3567,2102 @@ public class PALRepositoryQueryAPIManager { DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename); String downUrl=SDK.getConfAPI().getPortalUrl() + "/r/" + sourceDc.getDownloadURL().replace("./", ""); result.put("url",downUrl); - + } }*/ - PALRepositoryModel plmodel = PALRepositoryCache.getCache().get(ruuid); - if(plmodel!=null) { - String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr"; - String methodId = plmodel.getMethodId(); - if(methodId.contains("control")) { - sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd"; - }else if(methodId.contains("data")) { - sourceAppId = "com.awspaas.user.apps.coe.pal.output.bd"; - } - String filename = docFile.getName(); - DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename); - String downUrl=SDK.getConfAPI().getPortalUrl() + "/r/" + sourceDc.getDownloadURL().replace("./", ""); - result.put("url",downUrl); + PALRepositoryModel plmodel = PALRepositoryCache.getCache().get(ruuid); + if (plmodel != null) { + String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr"; + String methodId = plmodel.getMethodId(); + if (methodId.contains("control")) { + sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd"; + } else if (methodId.contains("data")) { + sourceAppId = "com.awspaas.user.apps.coe.pal.output.bd"; + } + String filename = docFile.getName(); + DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename); + String downUrl = SDK.getConfAPI().getPortalUrl() + "/r/" + sourceDc.getDownloadURL().replace("./", ""); + result.put("url", downUrl); - } - - - } - }else{ - result = ResponseObject.newErrResponse("没有可预览文件"); - } - } catch (Exception e) { - e.printStackTrace(); - return ResponseObject.newErrResponse().toString(); - } - } - return result.toString(); - } - - /** - * 发布流程访问量+1 - */ - public void UpDatePublishCount(PALRepositoryModel plModel) { - // 查询是否有访问数据 - PublishFrequencyDao dao = new PublishFrequencyDao(); - PublishFrequencyModel model = dao.getDataByVersionId(plModel.getVersionId()); - if (model == null) { - // 无访问量数据,新增数据,访问量初始化为1 - PublishFrequencyModel model2 = new PublishFrequencyModel(); - model2.setId(UUIDGener.getUUID()); - model2.setWsId(plModel.getWsId()); - model2.setPlversionId(plModel.getVersionId()); - model2.setCount(1); - dao.insert(model2); - } else { - // 有访问数据,访问量+1 - dao.update(model); - } - } - - /** - * 预览流程手册且流程访问量+1 - * @param _uc - * @param taskId - * @param uuid - * @return - */ - public String outputReportPreviewAndUpdatePublishCount(UserContext _uc, String taskId, String uuid) { - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); - if (plModel == null) { - throw new AWSException("该流程未找到,预览失败"); - } - if (!plModel.isPublish()) { - throw new AWSException("该流程当前状态为未发布状态,不允许打开"); - } - UpDatePublishCount(plModel); - return outputReportPreview(_uc, taskId);// 预览流程 - } - - /** - * 获取高频流程列表 - * @param wsId 资产库id - * @param category 大分类 process流程,org组织,data数据,itsystem IT系统,control 风险与控制,null则不过滤 - * @param methodId 具体分类 - * @param count 获取数据条数,-1则获取所有数据 - * @return 返回高频表中数据,按照访问量降序,若高频表数据不足,返回符合条件的无序数据 - */ - public List getFrequenceProcess(String wsId, String category, String methodId, int count) { - boolean hasCategory = !UtilString.isEmpty(category); - boolean hasMehtod = false; - if (!UtilString.isEmpty(hasMehtod)) { - hasMehtod = true; - } - PublishFrequencyDao dao = new PublishFrequencyDao(); - List list = dao.getDataOrderByCount(wsId); - int index = 0;// 计数 - Set versionIds = new HashSet<>(); - List result = new ArrayList<>(); - - if (list != null && list.size() > 0) { - for (int i = 0; i < list.size(); i++) { - if (count != -1 && index == count) { - break; - } - PublishFrequencyModel model = list.get(i); - List plModels = PALRepositoryCache.getByVersionId(wsId, model.getPlversionId()); - if(plModels == null || plModels.size() == 0) { - continue; - } - for (int j = 0; j < plModels.size(); j++) { - PALRepositoryModel plModel = plModels.get(i); - if (plModel.isPublish()) { - boolean flag = false; - if (hasCategory && hasMehtod) { - if (category.equals(plModel.getMethodCategory()) && methodId.equals(plModel.getMethodId())) { - flag = true; - } - } else if (hasCategory) { - if (category.equals(plModel.getMethodCategory())) { - flag = true; - } - } else if (hasMehtod) { - if (methodId.equals(plModel.getMethodId())) { - flag = true; - } - } else { - flag = true; - } - if (flag && !versionIds.contains(plModel.getVersionId())) { - index ++; - versionIds.add(plModel.getVersionId()); - result.add(plModel); - } - } - } - } - } - - if (index < count) { - List list2 = IteratorUtils.toList(PALRepositoryCache.getByWsId(wsId)); - if (list2 != null && list2.size() > 0) { - for (int j = 0; j < list2.size(); j++) { - if (count != -1 && index == count) { - break; - } - PALRepositoryModel plModel = list2.get(j); - if (plModel.isPublish()) { - boolean flag = false; - if (hasCategory && hasMehtod) { - if (category.equals(plModel.getMethodCategory()) && methodId.equals(plModel.getMethodId())) { - flag = true; - } - } else if (hasCategory) { - if (category.equals(plModel.getMethodCategory())) { - flag = true; - } - } else if (hasMehtod) { - if (methodId.equals(plModel.getMethodId())) { - flag = true; - } - } else { - flag = true; - } - if (flag && !versionIds.contains(plModel.getVersionId())) { - index++; - versionIds.add(plModel.getVersionId()); - result.add(plModel); - } - } - } - } - } - return result; - } - - /** - * 创建模型图片和缩略图 - * @param uuid 流程Id - * @param bigImage 是否生成大图(正常图片大小) - * @param smallImage 是否生成缩略图 - */ - public void saveImage(String uuid, boolean bigImage, boolean smallImage){ - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); - BaseModel model = null; - if (plModel != null) { - if (plModel.getMethodId().contains("bpmn")) { - model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); - } else { - model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); - } - if (model != null) { - // 形状锚点更新 - String define = CoeDesignerShapeAPIManager.getInstance().updateShapeConfig(uuid, model.getDefinition()); - - //特殊处理shape外属性显示内容被切割问题 - boolean addEmptyFlag = false; - String str = ""; - int maxX = 0; - int maxY = 0; - int maxW = 0; - boolean isRight = false; - JSONObject defineObj = JSON.parseObject(define); - if (defineObj.containsKey("elements")){ - JSONObject elements = defineObj.getJSONObject("elements"); - for (String key : elements.keySet()) { - JSONObject shapeObj = elements.getJSONObject(key); - if (null !=shapeObj && shapeObj.containsKey("dataAttributes")){ - JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes"); - for (int i = 0; i < dataAttributes.size(); i++) { - JSONObject dataAttribute = dataAttributes.getJSONObject(i); - if (null != dataAttribute && null != dataAttribute.getJSONObject("dataShowConfig") - && null != dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value") - && dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value").size()>0){ - addEmptyFlag = true; - JSONArray configs = dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value"); - for (int i1 = 0; i1 < configs.size(); i1++) { - JSONObject config = configs.getJSONObject(i1); - if (null == config ){ - continue; - } - String value = config.getString("value"); - if (value.length()>str.length()){ - str = value; - String horizontal = config.getString("horizontal"); - isRight = horizontal.contains("right"); - } - } - } - } - } - - if (null != shapeObj && shapeObj.containsKey("props")){ - JSONObject props = shapeObj.getJSONObject("props"); - if ( null == props ){ - continue; - } - Integer x = props.getInteger("x"); - if(null != x && x > maxX){ - maxX = x; - maxW = props.getInteger("w"); - maxY = props.getInteger("y"); - } - } - } - - if (addEmptyFlag){ - JSONObject textShape = JSON.parseObject("{\"parent\":\"\",\"textBlockFinal\":{\"w\":91,\"x\":0,\"h\":50,\"y\":0},\"link\":\"\",\"shapeStyle\":{\"alpha\":1},\"anchors\":[],\"textBlock\":{\"w\":\"w\",\"x\":0,\"h\":\"h\",\"y\":0},\"title\":\"\",\"fontStyle\":{\"orientation\":\"vertical\",\"fontFamily\":\"Arial\",\"size\":14,\"color\":\"50,50,50\",\"underline\":false,\"textAlign\":\"center\",\"bold\":false,\"italic\":false,\"vAlign\":\"middle\"},\"dataAttributes\":[{\"relevanceShapes\":[],\"attributesContent\":\"\",\"type\":\"string\",\"attributesJsonArray\":[],\"linksArray\":[],\"shapeDesc\":\"\",\"privateAttributeContent\":[],\"name\":\"AWSProperties\",\"privateShapesName\":[],\"id\":\"obj_c9e885014030000150f7ed506b48d010\",\"category\":\"default\",\"value\":\"\",\"upFilesArray\":[],\"privateAttribute\":[],\"isCopy\":\"\",\"shapeGroupId\":\"\"}],\"props\":{\"zindex\":51,\"w\":91,\"x\":629,\"h\":50,\"y\":250,\"angle\":0},\"path\":[{\"lineStyle\":{\"lineWidth\":0},\"fillStyle\":{\"type\":\"none\"},\"actions\":[{\"x\":\"0\",\"action\":\"move\",\"y\":\"0\"},{\"x\":\"w\",\"action\":\"line\",\"y\":\"0\"},{\"x\":\"w\",\"action\":\"line\",\"y\":\"h\"},{\"x\":\"0\",\"action\":\"line\",\"y\":\"h\"},{\"action\":\"close\"}]}],\"lineStyle\":{\"lineStyle\":\"solid\",\"lineColor\":\"50,50,50\",\"lineWidth\":1},\"children\":[],\"resizeDir\":[\"tl\",\"tr\",\"br\",\"bl\"],\"name\":\"standardText\",\"orderIndex\":0,\"fillStyle\":{\"color\":\"255,255,255\",\"type\":\"solid\"},\"id\":\"obj_c9e885014020000183f8bc75be204580\",\"text\":\"\",\"attribute\":{\"container\":false,\"rotatable\":false,\"visible\":true,\"editable\":true,\"linkable\":false,\"markerOffset\":5},\"resizeable\":\"1\",\"locked\":false,\"category\":\"standard\",\"group\":\"\"}"); - - if (textShape != null && textShape.containsKey("props")){ - JSONObject props = textShape.getJSONObject("props"); - props.put("w",100); - props.put("y",maxY); - props.put("h",50); - if (isRight){ - props.put("x",maxX + maxW + (str.length()* 2)); - }else { - props.put("x",maxX - (str.length()* 2)); - } - - elements.put(textShape.getString("id"),textShape); - } - } - } - - model.setDefinition(defineObj.toString()); - // 生成图片 - CoeDesignerImage.saveImage(model, bigImage, smallImage); - } - } - if(bigImage && smallImage) { - CoeDesignerImageCache.getCache().remove(uuid); - } - } - - /** - * 创建模型图片和缩略图,图片中流程图上方中间位置增加流程标题 - * 缩略图不进行标题处理 - * @param uuid 流程Id - * @param bigImage 是否生成大图(正常图片大小) - * @param smallImage 是否生成缩略图 - * @param title 可自定义标题,若为空,则默认为流程名称 - */ - public void saveImage(String uuid, boolean bigImage, boolean smallImage, String title){ - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); - BaseModel model = null; - if (plModel != null) { - if (plModel.getMethodId().contains("bpmn")) { - model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); - } else { - model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); - } - if (model != null) { - - if (smallImage) { - CoeDesignerImage.saveImage(model, false, true); - } - if (bigImage) { - if (UtilString.isEmpty(title)) { - title = plModel.getName(); - } - // 新建一个对象,避免直接修改缓存导致缓存与文件数据不一致 - BaseModel copyModel = new BaseModel(); - copyModel.setUUID(model.getUUID()); - copyModel.setDefinition(model.getDefinition()); - copyModel.setPath(model.getPath()); - copyModel.setType(model.getType()); - copyModel.setMethodId(model.getMethodId()); - copyModel.setVer(model.getVer()); - copyModel.setDraw(model.getDraw()); - copyModel.setAction(model.getAction()); - copyModel.setCreateHistory(model.isCreateHistory()); - copyModel.setUpdateTime(model.getUpdateTime()); - copyModel.setVersionUuid(model.getVersionUuid()); - copyModel.setFileName(model.getFileName()); - - copyModel.setDefinition(createTextTitle(copyModel, title)); - CoeDesignerImage.saveImage(copyModel, true, false); - } - } - } - if(bigImage && smallImage) { - CoeDesignerImageCache.getCache().remove(uuid); - } - } - - /** - * 创建文本类型节点作为标题并返回流程定义 - * @param model - * @param title - * @return - */ - private String createTextTitle(BaseModel model, String title) { - JSONObject position = getDefinitionPosition(model); - if (position == null) { - return model.getDefinition(); - } - - int minX = position.getInteger("minX"); - int minY = position.getInteger("minY"); - int maxX = position.getInteger("maxX"); - // 添加文本 - String standardText = "{\"name\":\"standardText\",\"title\":\"\",\"category\":\"standard\",\"group\":\"\",\"groupName\":null,\"locked\":false,\"link\":\"\",\"children\":[],\"parent\":\"\",\"orderIndex\":0,\"resizeDir\":[\"tl\",\"tr\",\"br\",\"bl\"],\"attribute\":{\"container\":false,\"visible\":true,\"rotatable\":false,\"linkable\":false,\"editable\":true,\"markerOffset\":5},\"dataAttributes\":[{\"name\":\"AWSProperties\",\"type\":\"string\",\"value\":\"\",\"category\":\"default\",\"linksArray\":[],\"attributesContent\":\"\",\"attributesJsonArray\":[],\"privateAttribute\":[],\"privateAttributeContent\":[],\"privateShapesName\":[],\"shapeGroupId\":\"\",\"isCopy\":\"\",\"shapeDesc\":\"\",\"upFilesArray\":[],\"relevanceShapes\":[]}],\"props\":{\"x\":117,\"y\":130,\"w\":220,\"h\":32,\"zindex\":1,\"angle\":0},\"shapeStyle\":{\"alpha\":1},\"lineStyle\":{\"lineWidth\":2,\"lineColor\":\"50,50,50\",\"lineStyle\":\"solid\"},\"fillStyle\":{\"type\":\"solid\",\"color\":\"255,255,255\"},\"fontStyle\":{\"fontFamily\":\"Arial\",\"size\":20,\"color\":\"50,50,50\",\"bold\":false,\"italic\":false,\"underline\":false,\"textAlign\":\"center\",\"vAlign\":\"middle\",\"orientation\":\"vertical\"},\"path\":[{\"lineStyle\":{\"lineWidth\":0},\"fillStyle\":{\"type\":\"none\"},\"actions\":[{\"action\":\"move\",\"x\":\"0\",\"y\":\"0\"},{\"action\":\"line\",\"x\":\"w\",\"y\":\"0\"},{\"action\":\"line\",\"x\":\"w\",\"y\":\"h\"},{\"action\":\"line\",\"x\":\"0\",\"y\":\"h\"},{\"action\":\"close\"}]}],\"textBlock\":{\"x\":0,\"y\":0,\"w\":\"w\",\"h\":\"h\"},\"textBlockFinal\":{\"x\":0,\"y\":0,\"w\":220,\"h\":32},\"anchors\":[],\"resizeable\":\"1\"}"; - JSONObject shape = JSONObject.parseObject(standardText); - String shapeId = UUIDGener.getObjectId();//连线id - shape.put("id", shapeId); - shape.put("text", title); - JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); - for (int index = 0; index < dataAttributes.size(); index++) { - dataAttributes.getJSONObject(index).put("id", UUIDGener.getObjectId()); - } - shape.put("dataAttributes", dataAttributes); - // 后续通过调整位置可支持标题在任何位置显示 - JSONObject props = shape.getJSONObject("props"); - props.put("x", minX); - props.put("y", minY - 40 - 10);// 40:文本高度,10:间距 - props.put("w", maxX - minX); - props.put("h", 40); - shape.put("props", props); - JSONObject textBlockFinal = shape.getJSONObject("textBlockFinal"); - if (textBlockFinal != null) { - textBlockFinal.put("w", maxX - minX); - textBlockFinal.put("h", 40); - } - shape.put("textBlockFinal", textBlockFinal); - String define = model.getDefinition(); - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - elements.put(shapeId, shape); - definition.put("elements", elements); - // model.setDefinition(definition.toString()); - return definition.toString(); - } - - /** - * 获取文件的位置 - * @param model - * @return {x:最小横坐标,y:最小y坐标,w:最大宽度,h:最大高度} - */ - private JSONObject getDefinitionPosition(BaseModel model) { - int minX = 99999; - int minY = 99999; - int maxX = -99999; - int maxY = -99999; - String define = model.getDefinition(); - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - Iterator it = elements.keySet().iterator(); - while (it.hasNext()) { - String elementId = it.next(); - JSONObject shape = elements.getJSONObject(elementId); - String shapeName = shape.getString("name"); - if (shapeName.equals("linker")) {// 连线处理 - // 连线拐点 - JSONArray points = shape.getJSONArray("points"); - if (points != null && points.size() > 0) { - for (int i = 0; i < points.size(); i++) { - JSONObject point = points.getJSONObject(i); - int x = point.getDouble("x").intValue(); - int y = point.getDouble("y").intValue(); - if (minX > x) { - minX = x; - } - if (minY > y) { - minY = y; - } - if (maxX < x) { - maxX = x; - } - if (maxY < y) { - maxY = y; - } - } - } - // 起点终点 - JSONObject from = shape.getJSONObject("from"); - if (from != null && from.size() > 0) { - int x = from.getInteger("x"); - int y = from.getInteger("y"); - if (minX > x) { - minX = x; - } - if (minY > y) { - minY = y; - } - if (maxX < x) { - maxX = x; - } - if (maxY < y) { - maxY = y; - } - } - JSONObject to = shape.getJSONObject("to"); - if (to != null && to.size() > 0) { - int x = to.getInteger("x"); - int y = to.getInteger("y"); - if (minX > x) { - minX = x; - } - if (minY > y) { - minY = y; - } - if (maxX < x) { - maxX = x; - } - if (maxY < y) { - maxY = y; - } - } - - } else {// 其他类型处理 - JSONObject props = shape.getJSONObject("props"); - int x = props.getInteger("x"); - int y = props.getInteger("y"); - int w = props.getInteger("w"); - int h = props.getInteger("h"); - if (minX > x) { - minX = x; - } - if (minY > y) { - minY = y; - } - if (maxX < x + w) { - maxX = x + w; - } - if (maxY < y + h) { - maxY = y + h; - } - } - } - if ( minX != 99999 && minY != 99999 && maxX != -99999 && maxY != -99999) { - JSONObject object = new JSONObject(); - object.put("minX", minX); - object.put("minY", minY); - object.put("maxX", maxX); - object.put("maxY", maxY); - return object; - } - return null; - } - - /** - * 校验图片,若该模型id在定时任务的缓存中,则生成图片,若不在缓存中则跳过 - * @param uuid 流程Id - * @param bigImage 是否生成大图(正常图片大小) - * @param smallImage 是否生成缩略图 - */ - public void checkImage(String uuid, boolean bigImage, boolean smallImage) { - //CoeDesignerImageCache.getCache().get(uuid)可能有为空的情况,此时不生成报告中的图片(待验证出现的条件) - //if (CoeDesignerImageCache.getCache().get(uuid) != null) { - saveImage(uuid, bigImage, smallImage); - //} - } - - /** - * 校验图片,若该模型id在定时任务的缓存中,则生成图片,若不在缓存中则跳过 - * @param uuid 流程Id - * @param bigImage 是否生成大图(正常图片大小) - * @param smallImage 是否生成缩略图 - */ - public void checkImage(String uuid, boolean bigImage, boolean smallImage, String title) { - //CoeDesignerImageCache.getCache().get(uuid)可能有为空的情况,此时不生成报告中的图片(待验证出现的条件) - //if (CoeDesignerImageCache.getCache().get(uuid) != null) { - saveImage(uuid, bigImage, smallImage, title); - //} - } - - /** - * 流程发布门户详情页面 - * - * @return - */ - public String getPublishPortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish) { - return getPublishPortalHtml(uc, uuid, taskId, checkPublish, true); - } + } - /** - * 流程发布门户详情页面(移动端) - * - * @return - */ - public String getPublishMobilePortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish) { - return getPublishMobilePortalHtml(uc, uuid, taskId, checkPublish, true); - } + } + } else { + result = ResponseObject.newErrResponse("没有可预览文件"); + } + } catch (Exception e) { + e.printStackTrace(); + return ResponseObject.newErrResponse().toString(); + } + } + return result.toString(); + } + + /** + * 发布流程访问量+1 + */ + public void UpDatePublishCount(PALRepositoryModel plModel) { + // 查询是否有访问数据 + PublishFrequencyDao dao = new PublishFrequencyDao(); + PublishFrequencyModel model = dao.getDataByVersionId(plModel.getVersionId()); + if (model == null) { + // 无访问量数据,新增数据,访问量初始化为1 + PublishFrequencyModel model2 = new PublishFrequencyModel(); + model2.setId(UUIDGener.getUUID()); + model2.setWsId(plModel.getWsId()); + model2.setPlversionId(plModel.getVersionId()); + model2.setCount(1); + dao.insert(model2); + } else { + // 有访问数据,访问量+1 + dao.update(model); + } + } + + /** + * 预览流程手册且流程访问量+1 + * + * @param _uc + * @param taskId + * @param uuid + * @return + */ + public String outputReportPreviewAndUpdatePublishCount(UserContext _uc, String taskId, String uuid) { + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); + if (plModel == null) { + throw new AWSException("该流程未找到,预览失败"); + } + if (!plModel.isPublish()) { + throw new AWSException("该流程当前状态为未发布状态,不允许打开"); + } + UpDatePublishCount(plModel); + return outputReportPreview(_uc, taskId);// 预览流程 + } + + /** + * 获取高频流程列表 + * + * @param wsId 资产库id + * @param category 大分类 process流程,org组织,data数据,itsystem IT系统,control 风险与控制,null则不过滤 + * @param methodId 具体分类 + * @param count 获取数据条数,-1则获取所有数据 + * @return 返回高频表中数据,按照访问量降序,若高频表数据不足,返回符合条件的无序数据 + */ + public List getFrequenceProcess(String wsId, String category, String methodId, int count) { + boolean hasCategory = !UtilString.isEmpty(category); + boolean hasMehtod = false; + if (!UtilString.isEmpty(hasMehtod)) { + hasMehtod = true; + } + PublishFrequencyDao dao = new PublishFrequencyDao(); + List list = dao.getDataOrderByCount(wsId); + int index = 0;// 计数 + Set versionIds = new HashSet<>(); + List result = new ArrayList<>(); + + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + if (count != -1 && index == count) { + break; + } + PublishFrequencyModel model = list.get(i); + List plModels = PALRepositoryCache.getByVersionId(wsId, model.getPlversionId()); + if (plModels == null || plModels.size() == 0) { + continue; + } + for (int j = 0; j < plModels.size(); j++) { + PALRepositoryModel plModel = plModels.get(i); + if (plModel.isPublish()) { + boolean flag = false; + if (hasCategory && hasMehtod) { + if (category.equals(plModel.getMethodCategory()) && methodId.equals(plModel.getMethodId())) { + flag = true; + } + } else if (hasCategory) { + if (category.equals(plModel.getMethodCategory())) { + flag = true; + } + } else if (hasMehtod) { + if (methodId.equals(plModel.getMethodId())) { + flag = true; + } + } else { + flag = true; + } + if (flag && !versionIds.contains(plModel.getVersionId())) { + index++; + versionIds.add(plModel.getVersionId()); + result.add(plModel); + } + } + } + } + } + + if (index < count) { + List list2 = IteratorUtils.toList(PALRepositoryCache.getByWsId(wsId)); + if (list2 != null && list2.size() > 0) { + for (int j = 0; j < list2.size(); j++) { + if (count != -1 && index == count) { + break; + } + PALRepositoryModel plModel = list2.get(j); + if (plModel.isPublish()) { + boolean flag = false; + if (hasCategory && hasMehtod) { + if (category.equals(plModel.getMethodCategory()) && methodId.equals(plModel.getMethodId())) { + flag = true; + } + } else if (hasCategory) { + if (category.equals(plModel.getMethodCategory())) { + flag = true; + } + } else if (hasMehtod) { + if (methodId.equals(plModel.getMethodId())) { + flag = true; + } + } else { + flag = true; + } + if (flag && !versionIds.contains(plModel.getVersionId())) { + index++; + versionIds.add(plModel.getVersionId()); + result.add(plModel); + } + } + } + } + } + return result; + } + + /** + * 创建模型图片和缩略图 + * + * @param uuid 流程Id + * @param bigImage 是否生成大图(正常图片大小) + * @param smallImage 是否生成缩略图 + */ + public void saveImage(String uuid, boolean bigImage, boolean smallImage) { + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); + BaseModel model = null; + if (plModel != null) { + if (plModel.getMethodId().contains("bpmn")) { + model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); + } else { + model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); + } + if (model != null) { + // 形状锚点更新 + String define = CoeDesignerShapeAPIManager.getInstance().updateShapeConfig(uuid, model.getDefinition()); + + //特殊处理shape外属性显示内容被切割问题 + boolean addEmptyFlag = false; + String str = ""; + int maxX = 0; + int maxY = 0; + int maxW = 0; + boolean isRight = false; + JSONObject defineObj = JSON.parseObject(define); + if (defineObj.containsKey("elements")) { + JSONObject elements = defineObj.getJSONObject("elements"); + for (String key : elements.keySet()) { + JSONObject shapeObj = elements.getJSONObject(key); + if (null != shapeObj && shapeObj.containsKey("dataAttributes")) { + JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes"); + for (int i = 0; i < dataAttributes.size(); i++) { + JSONObject dataAttribute = dataAttributes.getJSONObject(i); + if (null != dataAttribute && null != dataAttribute.getJSONObject("dataShowConfig") + && null != dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value") + && dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value").size() > 0) { + addEmptyFlag = true; + JSONArray configs = dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value"); + for (int i1 = 0; i1 < configs.size(); i1++) { + JSONObject config = configs.getJSONObject(i1); + if (null == config) { + continue; + } + String value = config.getString("value"); + if (value.length() > str.length()) { + str = value; + String horizontal = config.getString("horizontal"); + isRight = horizontal.contains("right"); + } + } + } + } + } + + if (null != shapeObj && shapeObj.containsKey("props")) { + JSONObject props = shapeObj.getJSONObject("props"); + if (null == props) { + continue; + } + Integer x = props.getInteger("x"); + if (null != x && x > maxX) { + maxX = x; + maxW = props.getInteger("w"); + maxY = props.getInteger("y"); + } + } + } + + if (addEmptyFlag) { + JSONObject textShape = JSON.parseObject("{\"parent\":\"\",\"textBlockFinal\":{\"w\":91,\"x\":0,\"h\":50,\"y\":0},\"link\":\"\",\"shapeStyle\":{\"alpha\":1},\"anchors\":[],\"textBlock\":{\"w\":\"w\",\"x\":0,\"h\":\"h\",\"y\":0},\"title\":\"\",\"fontStyle\":{\"orientation\":\"vertical\",\"fontFamily\":\"Arial\",\"size\":14,\"color\":\"50,50,50\",\"underline\":false,\"textAlign\":\"center\",\"bold\":false,\"italic\":false,\"vAlign\":\"middle\"},\"dataAttributes\":[{\"relevanceShapes\":[],\"attributesContent\":\"\",\"type\":\"string\",\"attributesJsonArray\":[],\"linksArray\":[],\"shapeDesc\":\"\",\"privateAttributeContent\":[],\"name\":\"AWSProperties\",\"privateShapesName\":[],\"id\":\"obj_c9e885014030000150f7ed506b48d010\",\"category\":\"default\",\"value\":\"\",\"upFilesArray\":[],\"privateAttribute\":[],\"isCopy\":\"\",\"shapeGroupId\":\"\"}],\"props\":{\"zindex\":51,\"w\":91,\"x\":629,\"h\":50,\"y\":250,\"angle\":0},\"path\":[{\"lineStyle\":{\"lineWidth\":0},\"fillStyle\":{\"type\":\"none\"},\"actions\":[{\"x\":\"0\",\"action\":\"move\",\"y\":\"0\"},{\"x\":\"w\",\"action\":\"line\",\"y\":\"0\"},{\"x\":\"w\",\"action\":\"line\",\"y\":\"h\"},{\"x\":\"0\",\"action\":\"line\",\"y\":\"h\"},{\"action\":\"close\"}]}],\"lineStyle\":{\"lineStyle\":\"solid\",\"lineColor\":\"50,50,50\",\"lineWidth\":1},\"children\":[],\"resizeDir\":[\"tl\",\"tr\",\"br\",\"bl\"],\"name\":\"standardText\",\"orderIndex\":0,\"fillStyle\":{\"color\":\"255,255,255\",\"type\":\"solid\"},\"id\":\"obj_c9e885014020000183f8bc75be204580\",\"text\":\"\",\"attribute\":{\"container\":false,\"rotatable\":false,\"visible\":true,\"editable\":true,\"linkable\":false,\"markerOffset\":5},\"resizeable\":\"1\",\"locked\":false,\"category\":\"standard\",\"group\":\"\"}"); + + if (textShape != null && textShape.containsKey("props")) { + JSONObject props = textShape.getJSONObject("props"); + props.put("w", 100); + props.put("y", maxY); + props.put("h", 50); + if (isRight) { + props.put("x", maxX + maxW + (str.length() * 2)); + } else { + props.put("x", maxX - (str.length() * 2)); + } + + elements.put(textShape.getString("id"), textShape); + } + } + } + + model.setDefinition(defineObj.toString()); + // 生成图片 + CoeDesignerImage.saveImage(model, bigImage, smallImage); + } + } + if (bigImage && smallImage) { + CoeDesignerImageCache.getCache().remove(uuid); + } + } + + /** + * 创建模型图片和缩略图,图片中流程图上方中间位置增加流程标题 + * 缩略图不进行标题处理 + * + * @param uuid 流程Id + * @param bigImage 是否生成大图(正常图片大小) + * @param smallImage 是否生成缩略图 + * @param title 可自定义标题,若为空,则默认为流程名称 + */ + public void saveImage(String uuid, boolean bigImage, boolean smallImage, String title) { + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); + BaseModel model = null; + if (plModel != null) { + if (plModel.getMethodId().contains("bpmn")) { + model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); + } else { + model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); + } + if (model != null) { + + if (smallImage) { + CoeDesignerImage.saveImage(model, false, true); + } + if (bigImage) { + if (UtilString.isEmpty(title)) { + title = plModel.getName(); + } + // 新建一个对象,避免直接修改缓存导致缓存与文件数据不一致 + BaseModel copyModel = new BaseModel(); + copyModel.setUUID(model.getUUID()); + copyModel.setDefinition(model.getDefinition()); + copyModel.setPath(model.getPath()); + copyModel.setType(model.getType()); + copyModel.setMethodId(model.getMethodId()); + copyModel.setVer(model.getVer()); + copyModel.setDraw(model.getDraw()); + copyModel.setAction(model.getAction()); + copyModel.setCreateHistory(model.isCreateHistory()); + copyModel.setUpdateTime(model.getUpdateTime()); + copyModel.setVersionUuid(model.getVersionUuid()); + copyModel.setFileName(model.getFileName()); + + copyModel.setDefinition(createTextTitle(copyModel, title)); + CoeDesignerImage.saveImage(copyModel, true, false); + } + } + } + if (bigImage && smallImage) { + CoeDesignerImageCache.getCache().remove(uuid); + } + } + + /** + * 创建文本类型节点作为标题并返回流程定义 + * + * @param model + * @param title + * @return + */ + private String createTextTitle(BaseModel model, String title) { + JSONObject position = getDefinitionPosition(model); + if (position == null) { + return model.getDefinition(); + } + + int minX = position.getInteger("minX"); + int minY = position.getInteger("minY"); + int maxX = position.getInteger("maxX"); + // 添加文本 + String standardText = "{\"name\":\"standardText\",\"title\":\"\",\"category\":\"standard\",\"group\":\"\",\"groupName\":null,\"locked\":false,\"link\":\"\",\"children\":[],\"parent\":\"\",\"orderIndex\":0,\"resizeDir\":[\"tl\",\"tr\",\"br\",\"bl\"],\"attribute\":{\"container\":false,\"visible\":true,\"rotatable\":false,\"linkable\":false,\"editable\":true,\"markerOffset\":5},\"dataAttributes\":[{\"name\":\"AWSProperties\",\"type\":\"string\",\"value\":\"\",\"category\":\"default\",\"linksArray\":[],\"attributesContent\":\"\",\"attributesJsonArray\":[],\"privateAttribute\":[],\"privateAttributeContent\":[],\"privateShapesName\":[],\"shapeGroupId\":\"\",\"isCopy\":\"\",\"shapeDesc\":\"\",\"upFilesArray\":[],\"relevanceShapes\":[]}],\"props\":{\"x\":117,\"y\":130,\"w\":220,\"h\":32,\"zindex\":1,\"angle\":0},\"shapeStyle\":{\"alpha\":1},\"lineStyle\":{\"lineWidth\":2,\"lineColor\":\"50,50,50\",\"lineStyle\":\"solid\"},\"fillStyle\":{\"type\":\"solid\",\"color\":\"255,255,255\"},\"fontStyle\":{\"fontFamily\":\"Arial\",\"size\":20,\"color\":\"50,50,50\",\"bold\":false,\"italic\":false,\"underline\":false,\"textAlign\":\"center\",\"vAlign\":\"middle\",\"orientation\":\"vertical\"},\"path\":[{\"lineStyle\":{\"lineWidth\":0},\"fillStyle\":{\"type\":\"none\"},\"actions\":[{\"action\":\"move\",\"x\":\"0\",\"y\":\"0\"},{\"action\":\"line\",\"x\":\"w\",\"y\":\"0\"},{\"action\":\"line\",\"x\":\"w\",\"y\":\"h\"},{\"action\":\"line\",\"x\":\"0\",\"y\":\"h\"},{\"action\":\"close\"}]}],\"textBlock\":{\"x\":0,\"y\":0,\"w\":\"w\",\"h\":\"h\"},\"textBlockFinal\":{\"x\":0,\"y\":0,\"w\":220,\"h\":32},\"anchors\":[],\"resizeable\":\"1\"}"; + JSONObject shape = JSONObject.parseObject(standardText); + String shapeId = UUIDGener.getObjectId();//连线id + shape.put("id", shapeId); + shape.put("text", title); + JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); + for (int index = 0; index < dataAttributes.size(); index++) { + dataAttributes.getJSONObject(index).put("id", UUIDGener.getObjectId()); + } + shape.put("dataAttributes", dataAttributes); + // 后续通过调整位置可支持标题在任何位置显示 + JSONObject props = shape.getJSONObject("props"); + props.put("x", minX); + props.put("y", minY - 40 - 10);// 40:文本高度,10:间距 + props.put("w", maxX - minX); + props.put("h", 40); + shape.put("props", props); + JSONObject textBlockFinal = shape.getJSONObject("textBlockFinal"); + if (textBlockFinal != null) { + textBlockFinal.put("w", maxX - minX); + textBlockFinal.put("h", 40); + } + shape.put("textBlockFinal", textBlockFinal); + String define = model.getDefinition(); + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + elements.put(shapeId, shape); + definition.put("elements", elements); + // model.setDefinition(definition.toString()); + return definition.toString(); + } + + /** + * 获取文件的位置 + * + * @param model + * @return {x:最小横坐标,y:最小y坐标,w:最大宽度,h:最大高度} + */ + private JSONObject getDefinitionPosition(BaseModel model) { + int minX = 99999; + int minY = 99999; + int maxX = -99999; + int maxY = -99999; + String define = model.getDefinition(); + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + Iterator it = elements.keySet().iterator(); + while (it.hasNext()) { + String elementId = it.next(); + JSONObject shape = elements.getJSONObject(elementId); + String shapeName = shape.getString("name"); + if (shapeName.equals("linker")) {// 连线处理 + // 连线拐点 + JSONArray points = shape.getJSONArray("points"); + if (points != null && points.size() > 0) { + for (int i = 0; i < points.size(); i++) { + JSONObject point = points.getJSONObject(i); + int x = point.getDouble("x").intValue(); + int y = point.getDouble("y").intValue(); + if (minX > x) { + minX = x; + } + if (minY > y) { + minY = y; + } + if (maxX < x) { + maxX = x; + } + if (maxY < y) { + maxY = y; + } + } + } + // 起点终点 + JSONObject from = shape.getJSONObject("from"); + if (from != null && from.size() > 0) { + int x = from.getInteger("x"); + int y = from.getInteger("y"); + if (minX > x) { + minX = x; + } + if (minY > y) { + minY = y; + } + if (maxX < x) { + maxX = x; + } + if (maxY < y) { + maxY = y; + } + } + JSONObject to = shape.getJSONObject("to"); + if (to != null && to.size() > 0) { + int x = to.getInteger("x"); + int y = to.getInteger("y"); + if (minX > x) { + minX = x; + } + if (minY > y) { + minY = y; + } + if (maxX < x) { + maxX = x; + } + if (maxY < y) { + maxY = y; + } + } + + } else {// 其他类型处理 + JSONObject props = shape.getJSONObject("props"); + int x = props.getInteger("x"); + int y = props.getInteger("y"); + int w = props.getInteger("w"); + int h = props.getInteger("h"); + if (minX > x) { + minX = x; + } + if (minY > y) { + minY = y; + } + if (maxX < x + w) { + maxX = x + w; + } + if (maxY < y + h) { + maxY = y + h; + } + } + } + if (minX != 99999 && minY != 99999 && maxX != -99999 && maxY != -99999) { + JSONObject object = new JSONObject(); + object.put("minX", minX); + object.put("minY", minY); + object.put("maxX", maxX); + object.put("maxY", maxY); + return object; + } + return null; + } + + /** + * 校验图片,若该模型id在定时任务的缓存中,则生成图片,若不在缓存中则跳过 + * + * @param uuid 流程Id + * @param bigImage 是否生成大图(正常图片大小) + * @param smallImage 是否生成缩略图 + */ + public void checkImage(String uuid, boolean bigImage, boolean smallImage) { + //CoeDesignerImageCache.getCache().get(uuid)可能有为空的情况,此时不生成报告中的图片(待验证出现的条件) + //if (CoeDesignerImageCache.getCache().get(uuid) != null) { + saveImage(uuid, bigImage, smallImage); + //} + } + + /** + * 校验图片,若该模型id在定时任务的缓存中,则生成图片,若不在缓存中则跳过 + * + * @param uuid 流程Id + * @param bigImage 是否生成大图(正常图片大小) + * @param smallImage 是否生成缩略图 + */ + public void checkImage(String uuid, boolean bigImage, boolean smallImage, String title) { + //CoeDesignerImageCache.getCache().get(uuid)可能有为空的情况,此时不生成报告中的图片(待验证出现的条件) + //if (CoeDesignerImageCache.getCache().get(uuid) != null) { + saveImage(uuid, bigImage, smallImage, title); + //} + } + + /** + * 流程发布门户详情页面 + * + * @return + */ + public String getPublishPortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish) { + return getPublishPortalHtml(uc, uuid, taskId, checkPublish, true); + } - - /** - * 流程发布门户详情页面 - * - * @return - */ - public String getPublishPortalHtml(UserContext uc, String uuid, String taskId) { - return getPublishPortalHtml(uc, uuid, taskId, true, true); - } + /** + * 流程发布门户详情页面(移动端) + * + * @return + */ + public String getPublishMobilePortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish) { + return getPublishMobilePortalHtml(uc, uuid, taskId, checkPublish, true); + } + /** + * 流程发布门户详情页面 + * + * @return + */ + public String getPublishPortalHtml(UserContext uc, String uuid, String taskId) { + return getPublishPortalHtml(uc, uuid, taskId, true, true); + } - /** - * 流程发布门户详情页面 - * - * @return - */ - public String getPublishPortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish, boolean upVisit) { + /** + * 流程发布门户详情页面 + * + * @return + */ + public String getPublishPortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish, boolean upVisit) { - //权限校验 + //权限校验 // if (!CoeCooperationAPIManager.getInstance().hasRepositoryPermision(uuid)) { // return AlertWindow.getWarningMessagePage("打开失败", "无该文件查看权限"); // } - //三员管理,文件密级权限校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - CoeProcessLevelWeb web = new CoeProcessLevelWeb(uc); - ResponseObject responseObject = web.checkFilePemission(uuid); - if (responseObject.isErr()){ - return AlertWindow.getWarningMessagePage("打开失败", responseObject.getMsg()); - } - } + //三员管理,文件密级权限校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + CoeProcessLevelWeb web = new CoeProcessLevelWeb(uc); + ResponseObject responseObject = web.checkFilePemission(uuid); + if (responseObject.isErr()) { + return AlertWindow.getWarningMessagePage("打开失败", responseObject.getMsg()); + } + } - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - if (model == null) { - throw new AWSException("该流程未找到,打开失败"); - } - if ("default".equals(model.getMethodId())) { - throw new AWSException("文件夹类型不支持打开"); - } - if (checkPublish) { - if (!model.isPublish()) { - throw new AWSException("该流程当前状态为未发布状态,不允许打开"); - } - } + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model == null) { + throw new AWSException("该流程未找到,打开失败"); + } + if ("default".equals(model.getMethodId())) { + throw new AWSException("文件夹类型不支持打开"); + } + if (checkPublish) { + if (!model.isPublish()) { + throw new AWSException("该流程当前状态为未发布状态,不允许打开"); + } + } - // 新的权限校验,若是该模型已发布,按照权限范围表中的权限控制是否可访问,若是该模型尚未发布(例如在发布过程中、已停用等),则不进行权限控制,都可访问 - if (model.isPublish()) { - if (!hasAccessPortalDesignerPerm(uc, model)) { - return AlertWindow.getWarningMessagePage("打开失败", "您所在组织/职级暂未被授予该文件的阅览权限"); - } - } + // 新的权限校验,若是该模型已发布,按照权限范围表中的权限控制是否可访问,若是该模型尚未发布(例如在发布过程中、已停用等),则不进行权限控制,都可访问 + if (model.isPublish()) { + if (!hasAccessPortalDesignerPerm(uc, model)) { + return AlertWindow.getWarningMessagePage("打开失败", "您所在组织/职级暂未被授予该文件的阅览权限"); + } + } - if (UtilString.isEmpty(taskId)) {// 停用或已发布状态查询流程手册 - taskId = getProcessReportTaskId(model); - } - CoeDesignerWeb web = new CoeDesignerWeb(uc); - // 操作行为日志记录 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_REPOSITORY_ACCESS); - } - return web.getPortalDesignerHtml(uuid, upVisit, taskId);// 返回页面 - } + if (UtilString.isEmpty(taskId)) {// 停用或已发布状态查询流程手册 + taskId = getProcessReportTaskId(model); + } + CoeDesignerWeb web = new CoeDesignerWeb(uc); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_REPOSITORY_ACCESS); + } + return web.getPortalDesignerHtml(uuid, upVisit, taskId);// 返回页面 + } + /** + * 流程发布门户详情页面 + * + * @return + */ + public String getPublishMobilePortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish, boolean upVisit) { - - - /** - * 流程发布门户详情页面 - * - * @return - */ - public String getPublishMobilePortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish, boolean upVisit) { - - //权限校验 + //权限校验 // if (!CoeCooperationAPIManager.getInstance().hasRepositoryPermision(uuid)) { // return AlertWindow.getWarningMessagePage("打开失败", "无该文件查看权限"); // } - //三员管理,文件密级权限校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - CoeProcessLevelWeb web = new CoeProcessLevelWeb(uc); - ResponseObject responseObject = web.checkFilePemission(uuid); - if (responseObject.isErr()){ - return AlertWindow.getWarningMessagePage("打开失败", responseObject.getMsg()); - } - } - - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - if (model == null) { - throw new AWSException("该流程未找到,打开失败"); - } - if ("default".equals(model.getMethodId())) { - throw new AWSException("文件夹类型不支持打开"); - } - if (checkPublish) { - if (!model.isPublish()) { - throw new AWSException("该流程当前状态为未发布状态,不允许打开"); - } - } - - // 新的权限校验,若是该模型已发布,按照权限范围表中的权限控制是否可访问,若是该模型尚未发布(例如在发布过程中、已停用等),则不进行权限控制,都可访问 - if (model.isPublish()) { - if (!hasAccessPortalDesignerPerm(uc, model)) { - return AlertWindow.getWarningMessagePage("打开失败", "您所在组织/职级暂未被授予该文件的阅览权限"); - } - } - - if (UtilString.isEmpty(taskId)) {// 停用或已发布状态查询流程手册 - taskId = getProcessReportTaskId(model); - } - CoeDesignerWeb web = new CoeDesignerWeb(uc); - // 操作行为日志记录 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_REPOSITORY_ACCESS); - } - - - return web.getMobilePortalDesignerHtml(uuid, upVisit, taskId);// 返回页面 - } - - - - - public boolean hasAccessPortalDesignerPerm(UserContext uc, PALRepositoryModel model) { - String newBoName = "BO_ACT_PUBLISH_PERM_SCOPE"; - BO bo = SDK.getBOAPI().query(newBoName).addQuery("PALVERSIONID=", model.getVersionId()).detail(); - if (bo == null) { - return false; - } - String permType = bo.getString("PERMTYPE"); - if ("1".equals(permType)) {// 全集团,都有权限 - return true; - } - // 如果当前人是系统管理员角色或者兼职系统管理员角色,默认有权限 - String roleId = "d102c89d-55f3-4865-9d5c-c00b7f47b803";// 系统管理员 - if (roleId.equals(uc.getRoleModel().getId())) { - return true; - } - // 兼职 - List adminUserMapModels = UserMapCache.getMapListOfUser(uc.getUID()); - for (UserMapModel mapModel : adminUserMapModels) { - if (roleId.equals(mapModel.getRoleId())) { - return true; - } - } - String orgPerm = bo.getString("ORGPERM"); - String postPerm = bo.getString("POSTPERM"); - String levelPerm = bo.getString("LEVELPERM"); - - // 根据发布流程选择的发布范围,获取所选组织、岗位、职级的交集进行权限控制 - - // 都不为空时 - if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm)) { - if ((getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc) )||getPostPerm(postPerm, uc) ) { - return true; - } - // 职级为空时 - } else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm)) { - if (getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) { - return true; - } - // 岗位为空时 - } else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm)) { - if (getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc)) { - return true; - } - // 组织为空时 - } else if (UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(orgPerm)) { - if (getPostPerm(postPerm, uc) || getLevelPerm(levelPerm, uc)) { - return true; - } - // 组织、岗位为空时 - } else if (UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm) && UtilString.isEmpty(orgPerm)) { - if (getLevelPerm(levelPerm, uc)) { - return true; - } - // 组织、职级为空时 - } else if (UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm) && UtilString.isEmpty(orgPerm)) { - if (getPostPerm(postPerm, uc)) { - return true; - } - // 岗位、职级为空时 - } else if (UtilString.isNotEmpty(orgPerm) && UtilString.isEmpty(levelPerm) && UtilString.isEmpty(postPerm)) { - if (getOrgPerm(orgPerm, uc)) { - return true; - } - } - return false; - } - - //组织权限 - private boolean getOrgPerm(String orgPerm,UserContext uc) { - if (UtilString.isNotEmpty(orgPerm)) { - // 兼职 - Set deptIdSet = new HashSet<>(); - String [] deptIds = orgPerm.split(","); - for (int i = 0; i < deptIds.length; i++) { - if (UtilString.isNotEmpty(deptIds[i])) { - String deptId = deptIds[i]; - deptIdSet.add(deptId); - queryChildDeptList(deptId, deptIdSet); - } - } - // 判断用户的所属部门 - String currUserDeptId = uc.getDepartmentModel().getId(); - if (deptIdSet.contains(currUserDeptId)) { - return true; - } - // 判断用户的兼职部门 - List userMapModels = UserMapCache.getMapListOfUser(uc.getUID()); - for (UserMapModel mapModel : userMapModels) { - if (deptIdSet.contains(mapModel.getDepartmentId())) { - return true; - } - } - } - return false; - } - //岗位权限 - private boolean getPostPerm(String postPerm,UserContext uc) { - if (UtilString.isNotEmpty(postPerm)) { - String positionNo = uc.getUserModel().getPositionNo(); - String [] positionIds = postPerm.split(","); - Set positionIdSet = new HashSet<>(); - for (int i = 0; i < positionIds.length; i++) { - positionIdSet.add(positionIds[i]); - } - if (positionIdSet.contains(positionNo)) { - return true; - } - } - return false; - - } - //职级权限 - private boolean getLevelPerm(String levelPerm,UserContext uc) { - if (UtilString.isNotEmpty(levelPerm)) { - String userLevelPerm = uc.getUserModel().getExt2(); - String[] levelPermspArray = levelPerm.split(","); - Set levelPermspSet = new HashSet<>(); - for (int i = 0; i < levelPermspArray.length; i++) { - levelPermspSet.add(levelPermspArray[i]); - } - if(levelPermspSet.contains(userLevelPerm)) { - return true; - } - } - return false; - } - - private void queryChildDeptList(String pid, Set deptIdSet) { - List list = SDK.getORGAPI().getSubDepartments(pid); - if (list != null && list.size() > 0) { - for (DepartmentModel child : list) { - deptIdSet.add(child.getId()); - queryChildDeptList(child.getId(), deptIdSet); - } - } - } - - /** - * 查询流程的最新流程手册id - * - * @param model - * @return - */ - public String getProcessReportTaskId(PALRepositoryModel model) { - if (model != null) { - if (model.isPublish() || model.isStop()) {// 停用或已发布状态查询最新流程手册 - return new PublishListHistory().getLastPublishTaskIdByModelId(model.getId()); - } - } - return null; - } - - /** - * 无session打开流程只读页面 - * @param uid - * @param uuid - * @param processDefId - * @return - */ - public String openDesignerRepositoryViewer(String uid, String uuid, String processDefId) { - if (UtilString.isEmpty(uid)) { - uid = "admin"; - } - if (UtilString.isEmpty(uuid)) { - throw new AWSException("参数uuid不能为空"); - } - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - if (model == null) { - throw new AWSException("流程不存在uuid=" + uuid); - } - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - throw new AWSException("未知类型或文件夹类型文件不支持打开uuid=" + uuid); - } - if (HighSecurity.isON()) { - String secAdmin = HighSecurity.getSecModel().getSysAdmin(); - String[] arr = secAdmin.split(" "); - uid = arr[0]; - } - String sid = new SSOUtil().registerClientSessionNoPassword(uid, "cn", "127.0.0.1", "pc"); - UserContext me = UserContext.fromSessionId(sid); - CoeDesignerWeb designerWeb = new CoeDesignerWeb(me); - return designerWeb.getDesignerHtml(uuid, 0, null, true, "", "", "", "1", ""); - } - - /** - * 变更表 - * @param uuid id - * @param setStr set部分sql - * @return - */ - public int updatePALRepositoryById(String uuid, String setStr) { - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - if (model == null) { - return -1; - } - String sql = "UPDATE " + PALRepositoryModelImpl.DATABASE_ENTITY + " set "; - sql += setStr; - sql += " where " + PALRepositoryModelImpl.FIELD_UUID + "='" + uuid + "'"; - return CoeProcessLevelDaoFacotory.createCoeProcessLevel().updatePALRepository(uuid, sql); - } - - /** - * 获取流程缩略图片 - * 图片不重新生成,适用于快速查看,卡片展示对实时性要求不强的场景 - * 通过定时任务进行图片更新 - * @param uuid pal流程id,若该流程为关联/(在bpm运行)流程,则返回bpm流程图片 - * @return - */ - public String getProcessImageThumbnail(String uuid) { - PALRepositoryModel cplm = PALRepositoryCache.getCache().get(uuid); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(cplm.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - return "../apps/" + CoEConstant.APP_ID + "/img/method/default_folder.png"; - } - String photo = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; - String processDefId = queryBpmsProcessDefIdByPalId(uuid, true); - if (UtilString.isEmpty(processDefId)) { - String path = cplm.getFilePath(); - if (!UtilString.isEmpty(path)) { - UtilFile utilFile = new UtilFile(path + "/" + cplm.getId() + ".small.png"); - if (utilFile.exists()) { - byte[] base64Bytes = Base64.encode(utilFile.readBytes()); - photo = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); - } - } - } else {// 获取执行平台图片 - photo = "data:image/png;base64," + BPMNIO.getBPMNImageThumbnail(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId); - } - return photo; - } - - /** - * 获取流程图片 - * 图片重新生成,适用于实时查看图片,打印报告等耗费时间性能的操作 - * @param uuid pal流程id,若该流程为关联/(在bpm运行)流程,则返回bpm流程图片 - * @return - */ - public String getProcessImg(String uuid) { - PALRepositoryModel cplm = PALRepositoryCache.getCache().get(uuid); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(cplm.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - return "../apps/" + CoEConstant.APP_ID + "/img/method/default_folder.png"; - } - String photo = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; - String processDefId = queryBpmsProcessDefIdByPalId(uuid, true); - if (UtilString.isEmpty(processDefId)) { - PALRepositoryQueryAPIManager.getInstance().checkImage(cplm.getId(), true, false);// 生成图片 - String path = cplm.getFilePath(); - if (!UtilString.isEmpty(path)) { - UtilFile utilFile = new UtilFile(path + "/" + cplm.getId() + ".png"); - if (utilFile.exists()) { - byte[] base64Bytes = Base64.encode(utilFile.readBytes()); - photo = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); - } - } - } else {// 获取执行平台图片 - photo = "data:image/png;base64," + BPMNIO.getBPMNImage(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId); - } - return photo; - } - - /** - * 获取流程图片路径,,若该流程为关联/(在bpm运行)流程,则返回bpm流程图片路径 - * 图片重新创建,适用于实时查看图片,打印报告等耗费时间性能的操作 - * @param uuid pal流程id - * @return - */ - public String getProcessImgPath(String uuid) { - PALRepositoryModel cplm = PALRepositoryCache.getCache().get(uuid); - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(cplm.getMethodId()); - if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 - return "../apps/" + CoEConstant.APP_ID + "/img/method/default_folder.png"; - } - String imageFilePath = ""; - String processDefId = queryBpmsProcessDefIdByPalId(uuid, true); - if (UtilString.isEmpty(processDefId)) { - PALRepositoryQueryAPIManager.getInstance().checkImage(cplm.getId(), true, false);// 生成图片 - String path = cplm.getFilePath(); - imageFilePath = path + "/" + cplm.getId() + ".png"; - } else { - BPMNIO.getBPMNImage(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId); - imageFilePath = BPMNFileUtil.getBPMNFileRealpath(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId) + processDefId + BPMNFileConstant.IMG_FILE_EXT_NAME; - } - return imageFilePath; - } - - /** - * 获取流程文件,若该流程为关联/(在bpm运行)流程,则返回bpm平台流程文件 - * @param uc UserContext对象 - * @param uuid pal流程id - * @return - */ - public String getProcessDefinition(UserContext uc, String uuid) { - String define = ""; - String processDefId = queryBpmsProcessDefIdByPalId(uuid, true); - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); - if (UtilString.isEmpty(processDefId)) {// 从pal获取 - if ("process.bpmn2".equals(plModel.getMethodId())) {// bpmn模型 - BPMNModel model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); - if (model == null) { - define = CoeDesignerUtil.getTemplateOfDefine(uuid); - } else { - define = model.getDefinition(); - } - } else {// 其他模型 - BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); - if (model == null) { - model = CoeDesignerUtil.createModel(uuid, 0); - define = model.getDefinition(); - } else { - define = model.getDefinition(); - } - } - } else {// 从bpm平台获取 - if (uc == null) { - uc = UserContext.fromUID("admin"); - } - CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(uc); - define = coeAdapter.readDefinition(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId).toString(); - } - if ("process.bpmn2".equals(plModel.getMethodId())) {// bpmn模型 - JSONObject definition = JSONObject.parseObject(define); - JSONObject localAttribute = definition.containsKey("localAttribute") ? definition.getJSONObject("localAttribute") : new JSONObject(); - if(localAttribute.isEmpty()) { - localAttribute = new JSONObject(); - } - if (localAttribute.isEmpty()) { - PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(plModel.getMethodId()); - List attributes = palMethodModel.getAttributes(); - Map> attributeMap = new HashMap>(); - if (attributes != null) { - for (PALMethodAttributeModel AttributeModel : attributes) { - Map map1 = new HashMap(); - map1.put("id", AttributeModel.getKey()); - map1.put("name", AttributeModel.getTitle()); - map1.put("key", AttributeModel.getKey()); - map1.put("value", AttributeModel.getValue()); - map1.put("type", AttributeModel.getType()); - map1.put("ref", AttributeModel.getRef()); - map1.put("readonly", AttributeModel.getReadonly()); - map1.put("groupPath", AttributeModel.getGroupPath()); - map1.put("scope", AttributeModel.getScope()); - attributeMap.put(AttributeModel.getKey(), map1); - } - } - List shapeAttributeList = PALRepositoryShapeAttributeCache.getAttributeListByMethod(plModel.getWsId(), plModel.getMethodId()); - if (shapeAttributeList != null && shapeAttributeList.size() > 0) { - for (PALRepositoryShapeAttributeModel shapeAttributeModel : shapeAttributeList) { - String shapeName = shapeAttributeModel.getShapeName(); - String attrId = shapeAttributeModel.getAttrId(); - if (localAttribute.containsKey(shapeName)) { - JSONArray array = localAttribute.getJSONArray(shapeName); - Map map = attributeMap.get(attrId); - if (map != null) { - JSONObject obj = JSONObject.parseObject(JSON.toJSONString(map)); - array.add(obj); - localAttribute.put(shapeName, array); - } - } else { - JSONArray array = new JSONArray(); - Map map = attributeMap.get(attrId); - if (map != null) { - JSONObject obj = JSONObject.parseObject(JSON.toJSONString(map)); - array.add(obj); - localAttribute.put(shapeName, array); - } - } - } - } - } - definition.put("localAttribute", localAttribute); - // 处理属性问题 - definition = CoeDesignerShapeAPIManager.getInstance().updateShapeDataAttributes(definition, localAttribute); - define = definition.toString(); - } - return define; - } - - /** - * 获取当前流程的所有版本,不同的是若流程与BPMS有关联,则获取与BPMS有关联的流程并更新版本号为BPMS流程版本号 - * @param uuid - * @return list - */ - public List queryPalRepositoryModelsByPalId(String uuid) { - return CoeProcessLevelUtil.queryPalRepositoryModelsByPalId(uuid); - } - - /** - * 获取版本,若PAL与BPMS关联,则获取关联的所有版本,若未关联,获取PAL数据 - * @return - */ - public PALRepositoryModel queryPalRepositoryModelByPalId(String uuid) { - return CoeProcessLevelUtil.queryPalRepositoryModelByPalId(uuid); - } - - /** - * 校验PAL是否关联了bpm流程但是在bpm端流程被删除,若存在此情况则进行关联关系删除 - * @param uuid - * @return - */ - public String correlateResourceCheck(String uuid) { - return CoeProcessLevelUtil.correlateResourceCheck(uuid); - } - - /** - * 获取PAL推送到BPMS但是尚未分配的流程-JSON方式 - * 返回通用的JSON,可供其他jar调用而不用引用相关类 - * @return JSONArray - */ - public JSONArray getCoePalNoDistributionJSON() { - return getCoePalNoDistributionJSONByVersionId(null); - } - - /** - * 获取PAL推送到BPMS但是尚未分配的流程-JSON方式 - * 返回通用的JSON,可供其他jar调用而不用引用相关类 - * @param versionId pal流程版本id - * @return JSONArray - */ - public JSONArray getCoePalNoDistributionJSONByVersionId(String versionId) { - return CoeProcessLevelUtil.getCoePalNoDistributionJSONByVersionId(versionId); - } - - /** - * 保存coe与bpms流程之间的关联关系,供其他jar调用 - * @param object - * @return - */ - public int coePalNoDistributionInsert(JSONObject object) { - return CoeProcessLevelUtil.coePalNoDistributionInsert(object); - } - - /** - * 校验PAL流程是否与BPMS有关联/推送关系 - * @param uuid PAL流程id - * @param checkBpmsExist 若有关联关系,是否进一步校验BPMS端流程是否存在,true:PAL关联了BPMS并且BPMS端被关联流程存在则返回BPMS流程id,false:PAL关联了BPMS流程(不管BPMS端流程是否存在)返回BPMS流程id - * @return 若是关联/推送流程,返回BPMS流程的ID,若不是或者BPMS端流程被删除,返回空字符串 - */ - public String queryBpmsProcessDefIdByPalId(String uuid, boolean checkBpmsExist) { - return CoeProcessLevelUtil.queryBpmsProcessDefIdByPalId(uuid, checkBpmsExist); - } - - /** - * 校验PAL流程是否与BPMS端流程有关联关系 - * @param uuid PAL id - * @param checkBpmsExist 若有关联关系,是否进一步校验BPMS端流程是否存在,true:PAL关联了BPMS并且BPMS端被关联流程存在则返回true,false:PAL关联了BPMS流程(不管BPMS端流程是否存在)返回true - * @return - */ - public boolean isCorrelateBpms(String uuid, boolean checkBpmsExist) { - return CoeProcessLevelUtil.isCorrelateBpms(uuid, checkBpmsExist); - } - - /** - * 根据BPMS流程id查询与PAL关联的流程id - * @param plAwsId - * @return BPMS与PAL有关联关系则返回PAL流程id,无关联关系返回null - */ - public String queryPlIdByPlAwsId(String plAwsId) { - CoeProcessLevelCorrelateModel model = CoeProcessLevelUtil.queryCorrelateModelyPlAwsId(plAwsId); - if (model != null) { - return model.getPlId(); - } - return null; - } - - /** - * 组名称是否可修改、删除判断依据 - * @param processVerIds BPM流程verId集合 - * @return true:可以修改/删除 false:锁定结构,不可以修改/删除 - */ - public boolean BpmUpdateGroup(List processVerIds) { - if (CoeProcessLevelUtil.isPalManage()) { - if (processVerIds == null || processVerIds.size() == 0) { - return true; - } - for (String verId : processVerIds) { - List list = CoeProcessLevelUtil.queryCorrelateModelsyPlAwsId(verId); - if (list == null) { - continue; - } - for (CoeProcessLevelCorrelateModel model : list) { - if (model.isCorrelate() && model.getCorrelateType() == 1 && "show".equals(model.getExt1())) { - return false; - } - } - } - } - return true; - } - - /** - * 流程是否可显示/隐藏 - * @param processVerId - * @return null:该流程/流程版本与PAL 关联关系,依照平台机制处 不为null,[xxx,xxx]:xxx为所有可以显示的流程,且其所有显示流程锁定结构,若size为0, 代表该流程版本下所有流程 显示(及特殊情况出现) - */ - public List getShowBpmProcessList(String processVerId) { - if (CoeProcessLevelUtil.isPalManage()) { - if (UtilString.isEmpty(processVerId)) { - return null; - } - List list = CoeProcessLevelUtil.queryCorrelateModelsyPlAwsId(processVerId); - if (list == null || list.size() == 0) { - return null; - } - List result = new ArrayList<>(); - for (CoeProcessLevelCorrelateModel model : list) { - if (model.isCorrelate() && model.getCorrelateType() == 1 && "show".equals(model.getExt1())) { - result.add(model.getPlAwsId()); - } - } - return result; - } - return null; - } - - /** - * 流程是否锁定结构 - * @param processDefId BPM流程id - * @return true:可以修改/删除 false:锁定结构, 可以修改/删除 - */ - public boolean isLockStructure(String processDefId) { - String plId = queryPlIdByPlAwsId(processDefId); - if (UtilString.isEmpty(plId)) { - return false; - } - CoeProcessLevelCorrelateModel model = CoeProcessLevelCorrelateCache.getCache().get(plId); - if (model == null) { - return false; - } - if (!CoeProcessLevelUtil.isBpmProcessEdit()) { - return model.isCorrelate(); - } - return false; - } - - /** - * 流程是否显示 - * @param processDefId - * @return - */ - public boolean isShowBpmProcess(String processDefId) { - if (!CoeProcessLevelUtil.isPalManage()) { - return true; - } - String plId = queryPlIdByPlAwsId(processDefId); - if (UtilString.isEmpty(plId)) { - return true; - } - CoeProcessLevelCorrelateModel model = CoeProcessLevelCorrelateCache.getCache().get(plId); - if (model == null) { - return true; - } - return model.isCorrelate() && model.getCorrelateType() == 1 && "show".equals(model.getExt1()); - } - - private static class Inner { - private final static PALRepositoryQueryAPIManager instance = new PALRepositoryQueryAPIManager(); - } - - /** - * 根据级别排序 并设置父节点 - * - * @author wangyh - *

- * 2014年7月25日 - */ - private class ComparatorLevel implements Comparator { - @Override - public int compare(PALRepositoryModelImpl model1, PALRepositoryModelImpl model2) { - Integer level1 = model1.getLevel(); - Integer level2 = model2.getLevel(); - int result = level1.compareTo(level2); - model2.setParentId(model1.getId()); - model1.setPublish(true);// 不是代表发布,用来代替是否是父节点 - return result; - } - } - - /** - * 根据级别排序 - * - * @author wangyh - *

- * 2014年7月25日 - */ - private class Comparator1 implements Comparator { - @Override - public int compare(PALRepositoryModel model1, PALRepositoryModel model2) { - Integer level1 = model1.getLevel(); - Integer level2 = model2.getLevel(); - int result = level1.compareTo(level2); - if (result == 0) { - Integer index1 = model1.getOrderIndex(); - Integer index2 = model2.getOrderIndex(); - result = index1.compareTo(index2); - } - return result; - } - } - - /** - * 获取更多特性树 - * @param wsId 资产库id - * @param methodId 模型分类 - * @param type file:文件属性,shape:形状属性 - * @param shapeName 形状名称,type为shape时有效,可为空 - * @return - */ - public static JSONArray getPalRepositoryMoreAttrConfig(String wsId, String methodId, String type, String shapeName) { - return CoeProcessLevelUtil.getPalRepositoryMoreAttrConfig(wsId, methodId, type, shapeName); - } - - /****************************************重构一些新的方法 20201209 sunlh********************************************/ - - /** - * 根据pid获取符合条件的子流程数据 - * @param uc - * @param wsId - * @param teamId - * @param pid - * @return - */ - public JSONArray getUsedPalRepositoryTreeDataByPidNew(UserContext uc, String wsId, String teamId, String pid) { - // 获取符合权限的子流程 - List childrenList = getUsedPalRepositoryModelsByPidNew(uc, wsId, teamId, pid); - Collections.sort(childrenList, new Comparator1()); - Map grandChildrenCountMap = new HashMap<>(); - for (PALRepositoryModel chlidModel : childrenList) { - List grandChildrenList = getUsedPalRepositoryModelsByPidNew(uc, wsId, teamId, chlidModel.getId()); - grandChildrenCountMap.put(chlidModel.getId(), grandChildrenList.size()); - } - JSONArray result = list2JsonNew(uc, childrenList, grandChildrenCountMap); - return result; - } - - /** - * 获取某个流程的使用中的子流程 - * - * @param wsId - * @param pid - * @return - */ - public List getUsedPalRepositoryModelsByPidNew(UserContext uc, String wsId, String teamId, String pid) { - if (UtilString.isEmpty(teamId)) { - return getUsedPalRepositoryModelsByPid(wsId, pid); - } else { - List result = new ArrayList<>(); - // 获取权限versionIds - Set permVerIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, uc.getUID(), null, null); - if (permVerIds.size() > 0) { - getPermRepositoryByPid(wsId, pid, permVerIds, true, false, new HashSet<>(), result); - } - return result; - } - } - - /** - * 根据父节点获取权限范围内的子流程 - * @param wsId - * @param pid - * @param permVersionIds 权限versionIds - * @param isUse - * @param isPublish - * @param verIds 给一个空的Set,防止数据造成的死循环 - * @param result 结果集 - */ - private void getPermRepositoryByPid(String wsId, String pid, Set permVersionIds, boolean isUse, boolean isPublish, Set verIds, List result) { - List childList = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); - if (childList != null && childList.size() > 0) { - for (PALRepositoryModel model : childList) { - if (verIds.contains(model.getVersionId())) { - //防止无限循环 - continue; - } - if (isUse) { - if (model.isUse()) {// 设计中的流程是连贯的,与发布不同 - verIds.add(model.getVersionId()); - if (permVersionIds.contains(model.getVersionId())) { - result.add(model); - } else { - getPermRepositoryByPid(wsId, model.getId(), permVersionIds, isUse, isPublish, verIds, result); - } - } - } else if (isPublish) { - if (model.isPublish() && permVersionIds.contains(model.getVersionId())) { - verIds.add(model.getVersionId()); - result.add(model); - } else { - getPermRepositoryByPid(wsId, model.getId(), permVersionIds, isUse, isPublish, verIds, result); - } - } - } - } - } - - /** - * 新的流程树list转换json方法 - * @param uc - * @param list - * @param childrenCountMap list中的model是否具有子节点map记录 - * @return - */ - private JSONArray list2JsonNew(UserContext uc, List list, Map childrenCountMap) { - JSONArray jsonArray = new JSONArray(); - for (PALRepositoryModel model : list) { - JSONObject object = new JSONObject(); - object.put("id", model.getVersionId().trim()); - object.put("currId", model.getId()); - object.put("pid", model.getNewParentId().trim()); - object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); - object.put("name", I18nRes.findValue(CoEConstant.APP_ID, uc.getLanguage(), model.getName()).trim()); - object.put("wsId", model.getWsId()); - object.put("isSystemFile", model.isSystemFile()); - object.put("plMethodId", model.getMethodId().trim()); - JSONObject icon = new JSONObject(); - object.put("folder", true);// 类型,文件夹 - if ("default".equals(model.getMethodId())) {// 默认文件夹 - JSONObject methodIcon = PALMethodManager.getInstance().getPALMethodIconById(model.getMethodId()); - if (methodIcon != null) { - icon.put("icon", methodIcon.getString("code")); - icon.put("color", methodIcon.getString("color")); - } - } else {// 非默认文件夹 - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if (methodModel != null) {// 存在该建模方法 - if (methodModel.isFolder()) {// 文件夹类型扩展的建模方法 - - JSONObject methodIcon = PALMethodManager.getInstance().getPALMethodIconById(model.getMethodId()); - icon.put("icon", methodIcon.getString("code")); - icon.put("color", methodIcon.getString("color")); - } else {// 文件类型模型文件 - //判断如果是组织图,更换组织图图标 - if(methodModel.getId().equals("org.role") || methodModel.getId().equals("org.normal")){ - icon.put("icon", ""); - icon.put("color", "#ef7b40"); - }else{ - icon.put("icon", ""); - icon.put("color", "#8E8E8E"); - } - object.put("folder", false);// 非文件夹 - } - } - } - if (icon.isEmpty()) {// 默认 - //判断如果是组织图,更换组织图图标 - if(model.getMethodId().equals("org.role") || model.getMethodId().equals("org.normal")){ - icon.put("icon", ""); - icon.put("color", "#ef7b40"); - }else{ - icon.put("icon", ""); - icon.put("color", "#FFB718"); - } - - } - object.put("icon", icon); - List children = null; - if (childrenCountMap.containsKey(model.getId()) && childrenCountMap.get(model.getId()) > 0) { - object.put("leaf", false);// 非叶子节点 - object.put("childCount", childrenCountMap.get(model.getId())); - } else { - object.put("leaf", true);// 叶子节点 - object.put("childCount", 0); - } - object.put("plLevel", model.getLevel()); - object.put("plOrdexIndex", model.getOrderIndex()); - object.put("plDiagramUrl", model.getDiagramUrl()); - object.put("isDrops", model.isSystemFile()); - object.put("isPublish", model.isPublish()); - object.put("isStop", model.isStop()); - object.put("isApproval", model.isApproval()); - object.put("ext1", model.getExt1()); - object.put("ext2", model.getExt2()); - object.put("ext3", model.getExt3()); - object.put("ext4", model.getExt4()); - object.put("isUse", model.isUse()); - object.put("plCategory", model.getMethodCategory()); - object.put("versionId", model.getVersionId()); - object.put("orderIndex", model.getOrderIndex()); - object.put("isBottomLevel", model.isBottomLevel()); - object.put("createUser",model.getCreateUser()); - object.put("modifyUser",model.getModifyUser()); - - - //三员管理下,附件是否存在未标定密级 - if(HighSecurityUtil.isON()){ - object.put("isUpfileUnmark",this.checkUpfileSecurity(model)); - if (HighSecurityUtil.fileSecuritySwitch()){ - //流程文件密级回显 - Integer securityLevel = model.getSecurityLevel(); - HashMap securityMap = HighSecurityUtil.getObjSecurityMap(); - String securityLevelName= securityMap.get(String.valueOf(securityLevel)); - object.put("securityLevelName", securityLevelName == null ? "未标密" : securityLevelName); - object.put("isFileSecurity",true); - object.put("securityLevel",securityLevel); - } - } - jsonArray.add(object); - } - return jsonArray; - } - - /** - * 三员管理下,附件是否存在未标定密级 - * @param model - * @return - */ - public boolean checkUpfileSecurity(PALRepositoryModel model){ - List upfileModels = new UpFileDao().search(model.getId(), null, null); - for (UpfileModel upfile: upfileModels){ - if(upfile.getSecurityLevel()==-1){ - return true; - } - } - return false; - } - - - /** - * 形状属性-类型 - */ - public String shapePropertyType(String myTypeName) { - if("linker".equals(myTypeName)) { - return "连线"; - } - Class clzz = BPMNConstant.class; - Field[] fields = clzz.getDeclaredFields(); - for(Field field : fields) { - field.setAccessible(true); - try { - String typeName = (String)field.get(null); - if( myTypeName!=null && myTypeName.equals(typeName) ) { - String type = field.getName(); - Field typeTitle = clzz.getDeclaredField(type + "_TITLE"); - String typeTitleName = (String)typeTitle.get(null); - return typeTitleName; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - return ""; - } - - /** - * 获取模型形状的附件 - * @param palId - * @param uc 可为null - * @return - */ - public static List queryShapeUpfileList(String palId, UserContext uc) { - return new UpfileQuery().loadUpFiles(palId, null, "shape", (uc == null ? UserContext.fromUID("admin") : uc)); - } - - /** - * 获取模型形状的关联附件 - * @param palId - * @param uc 可为null - * @return - */ - public static List queryShapeRelationUpfileList(String palId, UserContext uc) { - return new UpfileQuery().loadRelationUpfiles(palId, null, "shape", (uc == null ? UserContext.fromUID("admin") : uc)); - } - - /** - * 获取文件的附件 - * @param palId - * @param uc 可为null - * @return - */ - public static List queryProcessUpfileList(String palId, UserContext uc) { - return new UpfileQuery().loadUpFiles(palId, null, "file", (uc == null ? UserContext.fromUID("admin") : uc)); - } - - /** - * 获取文件的关联附件 - * @param palId - * @param uc 可为null - * @return - */ - public static List queryProcessRelationUpfileList(String palId, UserContext uc) { - return new UpfileQuery().loadRelationUpfiles(palId, null, "file", (uc == null ? UserContext.fromUID("admin") : uc)); - } - - static class UpfileQuery { - /** - * 加载流程文件/形状附件 - * @param palId - * @param type file 文件附件 shape 形状附件 - * @param shapeId - * @return - */ - private List loadUpFiles(String palId, String shapeId, String type, UserContext uc) { - List result = new ArrayList<>(); - UpFileDao upFileDao = new UpFileDao(); - List upfileList = upFileDao.search(palId, shapeId, type); - if (upfileList != null) { - Set ids = new HashSet<>(); - for (UpfileModel model : upfileList) { - if (ids.contains(model.getUuid())) { - continue; - } - ids.add(model.getUuid()); - String downloadURL = ""; - DCContext dcContext = getDCContext(model, uc); - if (dcContext != null) { - downloadURL = dcContext.getDownloadURL() + "&isInline=false"; - } - model.setDownloadUrl(downloadURL); - result.add(model); - } - } - sortByCreateTime(result); - return result; - } - - /** - * 加载关联附件 - * - * @param palId 模型Id - * @param shapeId 图形Id - * @param type file/shape(模型附件还是图形附件) - * @return - */ - private List loadRelationUpfiles(String palId, String shapeId, String type, UserContext uc) { - List result = new ArrayList<>(); - // 获取属性的关联类型(relationType) - Map relationTypeMap = new HashMap<>(); - PALRepositoryModel m = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(palId); - PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(m.getMethodId()); - if (palMethodModel != null) { - List attributes = palMethodModel.getAttributes(); - for (PALMethodAttributeModel model : attributes) { - if ("relation".equals(model.getType())) { - JSONObject refObj = JSONObject.parseObject(model.getRef()); - String relationType = refObj.containsKey("type") ? refObj.getString("type") : "shape"; - relationTypeMap.put(model.getKey(), relationType); - } - } - } - if (UtilString.isEmpty(shapeId) || "file".equals(type)) { - shapeId = ""; - } - Iterator iterator = DesignerShapeRelationCache.getByShapeId(palId, shapeId); - List list = new ArrayList<>(); - UpFileDao dao = new UpFileDao(); - while (iterator.hasNext()) { - DesignerShapeRelationModel model = iterator.next(); - if (relationTypeMap.containsKey(model.getAttrId())) { - if("file".equals(relationTypeMap.get(model.getAttrId()))) {// 文件 - String versionId = model.getRelationFileId(); - PALRepositoryModel palModel = CoeProcessLevelUtil.getUseRepositoryByVersionId(versionId);// 获取工作版本 - if (palModel != null) { - List list2 = dao.search(palModel.getId(), null, type); - if (list2 != null && list2.size() > 0) { - list.addAll(list2); - } - } - } else {// 形状 - List list2 = dao.search(model.getRelationFileId(), model.getRelationShapeId(), type); - if (list2 != null && list2.size() > 0) { - list.addAll(list2); - } - } - } - } - if (list != null) { - Set ids = new HashSet<>(); - for (UpfileModel model : list) { - if (ids.contains(model.getUuid())) { - continue; - } - ids.add(model.getUuid()); - PALRepositoryModel palModel = PALRepositoryCache.getCache().get(model.getPl_uuid()); - if (palModel != null) { - String downloadURL = ""; - DCContext dcContext = getDCContext(model, uc); - if (dcContext != null) { - downloadURL = dcContext.getDownloadURL() + "&isInline=false"; - } - model.setDownloadUrl(downloadURL); - result.add(model); - } - } - } - sortByCreateTime(result); - return result; - } - - public void sortByCreateTime(List list) { - list.sort((m1, m2) -> {return m2.getCreateTime().compareTo(m1.getCreateTime());}); - } - - /** - * 获取dccontext - * - * @param model - * @return - */ - private DCContext getDCContext(UpfileModel model, UserContext uc) { - DCContext dcContext = null; - DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); - if (dcProfile != null) { - if ("f".equals(model.getType())) {// 文件 - dcContext = new DCContext(uc, dcProfile, CoEConstant.APP_ID, "file", - model.getPl_uuid(), model.getFileName()); - } else {// 图形 - dcContext = new DCContext(uc, dcProfile, CoEConstant.APP_ID, model.getPl_uuid(), - model.getShape_uuid(), model.getFileName()); - } - } - return dcContext; - } - } - - /*************************************流程附件 start****************************************/ - /** - * 检测平台是否开启三员管理,同时设置返回参数 - * @param ro - */ - public void checkHighSecurity(String uuid,ResponseObject ro){ - //平台开启三元模式 - if(HighSecurityUtil.isON()){ - PALRepositoryModel plModel = null; - if(null != uuid && HighSecurityUtil.fileSecuritySwitch()){ - plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - } - //全部文件密级 - HashMap securityMap = HighSecurityUtil.getObjSecurityMap(); - //筛选用户与文件密级 - Set entrySet = securityMap.keySet(); - Iterator iterator = entrySet.iterator(); - UserContext userContext = DispatcherRequest.getUserContext(); - while (iterator.hasNext()){ - String next = iterator.next(); - if (!HighSecurityUtil.hasSecurityLevel(userContext,Integer.parseInt(next),plModel)){ - iterator.remove(); - } - } - ro.put("securityList",securityMap); - ro.put("isHighSecurity",true); - if(HighSecurityUtil.fileSecuritySwitch()){ - ro.put("isFileSecurity",true); - } - } - } - - - - /** - * 附件密级根据用户与文件密级过滤 - * @param uc - * @param list - */ - public void upFileSecurityFilter(UserContext uc,List list){ - Iterator iterator = list.iterator(); - while (iterator.hasNext()){ - UpfileModel model = iterator.next(); - if ((!HighSecurityUtil.hasSecurityLevel(uc,model.getSecurityLevel(),model))|| -1 == model.getSecurityLevel()){ - iterator.remove(); - } - } - } - - /** - * 附件密级根据用户筛选其下所有密级文件,包含未标密 - * @param uc - * @param list - */ - public void upFileSecurityUnmarkFilter(UserContext uc,List list){ - Iterator iterator = list.iterator(); - while (iterator.hasNext()){ - UpfileModel model = iterator.next(); - if ((!HighSecurityUtil.hasSecurityLevel(uc,model.getSecurityLevel(),model))){ - iterator.remove(); - } - } - } - - /** - * 是否开启三员管理 - * @return - */ - public boolean isSecurityMode(){ - return HighSecurityUtil.isON(); - } - - /** - * 获取流程树中第一个流程文件未标密 或者 附件未标密文件在树中路径 - * @return - */ - public String getUnmarkPath(UserContext me,String wsId,String teamId){ - ResponseObject ro = ResponseObject.newOkResponse(); - - if (!HighSecurityUtil.isON()){ - ro = ResponseObject.newErrResponse().msg("三员管理应用未开启"); - return ro.toString(); - } - - //小组权限 - Set versionIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, me.getUID(), null, null); - - //未标密的文件 - PALRepositoryModel unmarkModel = this.findFileUnmarkModel(versionIds, wsId, teamId); - - if (null == unmarkModel){ - //未标密的附件 - unmarkModel = new UpfileWeb(me).findUpfileUnmarkModel(versionIds, wsId, teamId); - } - - // 获取文件路径 - List path = new ArrayList<>(); - if (null == unmarkModel) { - ro.put("path",path.toArray()); - return ro.toString(); - } - JSONArray repositoryPathData = CoeProcessLevelUtil.getRepositoryPath(unmarkModel.getId()); - // 前面大类不显示,根据小组进行级别处理 - for (int i = 0; i < repositoryPathData.size(); i++) { - JSONObject currObj = repositoryPathData.getJSONObject(i); - PALRepositoryModel currModel = PALRepositoryCache.getCache().get(currObj.getString("id")); - if (currModel != null && versionIds.contains(currModel.getVersionId())) { - path.add(currModel.getVersionId()); - } else if (currObj.getString("id").length() < 36) { - path.add(currObj.getString("id")); - } - } - ro.put("path",path.toArray()); - return ro.toString(); - } - - /** - * 获取第一个流程文件未标密model - * @param me - * @param versionIds - * @param wsId - * @param teamId - * @return - */ - public PALRepositoryModel findFileUnmarkModel(Set versionIds,String wsId,String teamId){ - PALRepositoryModel targetModel = null; - //开启三员管理下,流程文件密级标定switch - if (HighSecurityUtil.fileSecuritySwitch()){ - List repositoryList = this.getInuseRepositoryList(versionIds, wsId, teamId); - for (PALRepositoryModel model : repositoryList){ - //查询流程文件 是否存在未标定密级 - boolean flag = PALRepositoryQueryAPIManager.getInstance().checkFileSecurity(model); - if(flag){ - targetModel = model; - break; - } - } - } - return targetModel; - } - - /** - * 获取流程树中inuse文件 - * @param versionIds 小组权限下的流程文件uuid - * @param wsId - * @param teamId - * @return - */ - public List getInuseRepositoryList(Set versionIds,String wsId,String teamId){ - //获取资产库下所有流程 - List list = new ArrayList<>(); - Iterator iterator = PALRepositoryCache.getByWsId(wsId); - - while (iterator.hasNext()){ - PALRepositoryModel model = iterator.next(); - if (!UtilString.isEmpty(teamId)){ - //小组过滤 - if (model.isUse() && versionIds.contains(model.getVersionId())) { - list.add(model); - } - }else{ - if (model.isUse()){ - list.add(model); - } - } - } - // 排序 - Collections.sort(list, new Comparator1()); - - return list; - } - - /** - * 三员管理下,流程文件是否存在未标定密级 - * @param model - * @return - */ - public boolean checkFileSecurity(PALRepositoryModel model){ - - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - return null != methodModel && !methodModel.isFolder() && model.getSecurityLevel() == -1; - } - - /** - * 获取流程树下未标密文件的数量 - * @param wsId - * @param teamId - * @return - */ - public Integer getUnMarkFileNum(UserContext me,String wsId, String teamId){ - if (!HighSecurityUtil.isON() || !HighSecurityUtil.fileSecuritySwitch()){ - return null; - } - int num = 0; - - //小组权限 - Set versionIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, me.getUID(), null, null); - - //开启三员管理下,流程文件密级标定switch - List repositoryList = this.getInuseRepositoryList(versionIds, wsId, teamId); - for (PALRepositoryModel model : repositoryList){ - //查询流程文件 是否存在未标定密级 - boolean flag = PALRepositoryQueryAPIManager.getInstance().checkFileSecurity(model); - if(flag){ - num ++; - } - } - return num; - } - - /** - * 报告生成器应用,前置校验密级访问权限 - * @param me - * @param model - * @return - */ - public ResponseObject checkOutputSecurityPermission(UserContext me,OutputTaskModel model){ - ResponseObject rs = ResponseObject.newOkResponse(); - - OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), model.getId(), OutputConst.FILE_WIZARD_CONFIG); - - //获取config.txt配置 - UtilFile file = new UtilFile(dcContext.getPath()+"/config.txt"); - String s = file.readStrUTF8(); - JSONObject jsonObject = JSON.parseObject(s); - String targetFileId = String.valueOf(jsonObject.get("targetFileId")); - targetFileId = targetFileId.contains(",") ? targetFileId.substring(targetFileId.indexOf(',')+1) : targetFileId; - - //密级权限校验 - CoeProcessLevelWeb web = new CoeProcessLevelWeb(me); - return web.checkFilePemission(targetFileId); - } - /*************************************流程附件 end****************************************/ - - /** - * 根据报告生成器的任务ID查询对应的文件存储路径 - * @param uc - * @param taskId 表APP_ACT_COE_PAL_OUTPUT_TASK的ID - * @return - */ - public String queryReportFilePath(UserContext uc,String taskId){ - String dirPath = ""; - if (UtilString.isEmpty(taskId)) return dirPath; - OutputTask taskDao = new OutputTask(); - OutputTaskModel taskModel = taskDao.getTaskReportById(taskId); - if (taskDao != null){ - String profileId = taskModel.getProfileId(); - OutputAppProfile profile = OutputAppManager.getProfile(profileId); - if (profile != null) { - String appId = profile.getAppContext().getId(); - DCPluginProfile dcProfile = DCProfileManager.getDCProfile(appId, OutputConst.EXT_APP_DC_OUTPUT); - DCContext dcContext = new DCContext(uc, dcProfile, appId, taskModel.getWsId(), taskModel.getId()); - dirPath = dcContext.getPath(); - } - } - return dirPath; - } - - /** - * 根据模型ID查询所有文件扩展属性 - * - * @param uuid - * @return - */ - public static Map queryRepositoryAttributeById(String uuid) { - Map result = new HashMap<>(); - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); - // 获取所有文件属性 - List methodAttrModels = PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels(plModel.getWsId(), plModel.getMethodId()); - if (methodAttrModels != null && methodAttrModels.size() > 0) { - Map attributeModelMap = new HashMap<>(); - Map sortAttrMap = new HashMap<>(); - if (methodAttrModels != null) { - int sort = 0; - for (PALMethodAttributeModel attr : methodAttrModels) { - attributeModelMap.put(attr.getKey(), attr); - sortAttrMap.put(attr.getKey(), ++sort); - } - } - List propertys = PALRepositoryPropertyCache.getPropertyByPlId(plModel.getId()); - // 排序 - // propertys.sort((p1, p2) -> (sortAttrMap.containsKey(p1.getPropertyId()) ? sortAttrMap.get(p1.getPropertyId()) : 0) - (sortAttrMap.containsKey(p2.getPropertyId()) ? sortAttrMap.get(p2.getPropertyId()) : 0)); - - for (PALRepositoryPropertyModel property : propertys) { - String id = property.getPropertyId(); - if (!attributeModelMap.containsKey(id) || !attributeModelMap.get(id).getUse()) { - continue; - } - PALMethodAttributeModel attributeModel = attributeModelMap.get(id); - // 记录结果集 - JSONObject attrObj = new JSONObject(); - attrObj.put("ref", attributeModel.getRef());// ref - attrObj.put("type", attributeModel.getType());// 类型 relation string ... - attrObj.put("attrId", attributeModel.getKey());// 属性key - attrObj.put("attrTitle", attributeModel.getNewTitle());// 属性标题 - attrObj.put("text", "");// 属性内容单行文本 - attrObj.put("value", new JSONArray());// 属性内容集,relation或awsorg类型时存储对应的json数据 - String inputValue = property.getPropertyValue(); - inputValue = UtilString.isEmpty(inputValue) ? "" : inputValue; - if ("relation".equals(attributeModel.getType())) { - List inputValueList = new ArrayList<>(); - List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); - list.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText)); - if (list != null && list.size() > 0) { - // 判断是否有重复数据,进行重复过滤 - Set tempStrs = new HashSet<>(); - List tempList = new ArrayList<>(); - for (int i = 0; i < list.size(); i++) { - DesignerShapeRelationModel model = list.get(i); - String str = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId(); - if (!tempStrs.contains(str)) { - tempList.add(model); - tempStrs.add(str); - } - } - list = tempList; - for (int i = 0; i < list.size(); i++) { - DesignerShapeRelationModel model = list.get(i); - JSONObject refObj = JSONObject.parseObject(attributeModel.getRef()); - String relationTyp = refObj.containsKey("type") ? refObj.getString("type") : "shape"; - if ("file".equals(relationTyp)) {// 关联的模型文件 - if (model.getRelationFileId().length() < 36) { - continue; - } - List list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); - for (PALRepositoryModel model2 : list2) { - if (model2.isUse()) { - inputValueList.add(model2.getName()); - JSONObject tmp = new JSONObject(); - tmp.put("fileId", model2.getId()); - tmp.put("name", model2.getName()); - tmp.put("isFile", true); - attrObj.getJSONArray("value").add(tmp); - break; - } - } - } else if ("shapeAndFile".equals(relationTyp)) {// 关联的模型形状和文件都有 伊利 - if (UtilString.isEmpty(model.getRelationShapeId())) {// 关联文件,发现记录的不是versionID,而是id 伊利 - PALRepositoryModel relationModel = PALRepositoryCache.getCache().get(model.getRelationFileId()); - if (relationModel != null) { - inputValueList.add(relationModel.getName()); - JSONObject tmp = new JSONObject(); - tmp.put("fileId", relationModel.getId()); - tmp.put("name", relationModel.getName()); - tmp.put("isFile", true); - attrObj.getJSONArray("value").add(tmp); - } - } else { - // 关联形状 - inputValueList.add(model.getRelationShapeText()); - JSONObject tmp = new JSONObject(); - tmp.put("fileId", model.getRelationFileId()); - tmp.put("shapeId", model.getRelationShapeId()); - tmp.put("name", model.getRelationShapeText()); - tmp.put("isFile", false); - attrObj.getJSONArray("value").add(tmp); - } - } else {// 关联的模型形状 - inputValueList.add(model.getRelationShapeText()); - JSONObject tmp = new JSONObject(); - tmp.put("fileId", model.getRelationFileId()); - tmp.put("shapeId", model.getRelationShapeId()); - tmp.put("name", model.getRelationShapeText()); - tmp.put("isFile", false); - attrObj.getJSONArray("value").add(tmp); - } - } - } - inputValue = StringUtils.join(inputValueList, ","); - } - // 关联bpm组织架构 - if ("awsorg".equals(attributeModel.getType())) { - List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); - List deptValList = new ArrayList<>(); - List positionValList = new ArrayList<>(); - List roleValList = new ArrayList<>(); - List userValList = new ArrayList<>(); - - JSONArray depjsonArray=new JSONArray(); - if (list != null && list.size() > 0) { - Set filter = new HashSet();// 去重记录 - - list.sort((m1, m2) -> { - return m1.getId().compareTo(m2.getId()); - }); - for (DesignerShapeRelationModel model : list) { - if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) { - JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); - boolean flag = false; - // 查询最新名称 + //三员管理,文件密级权限校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + CoeProcessLevelWeb web = new CoeProcessLevelWeb(uc); + ResponseObject responseObject = web.checkFilePemission(uuid); + if (responseObject.isErr()) { + return AlertWindow.getWarningMessagePage("打开失败", responseObject.getMsg()); + } + } + + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model == null) { + throw new AWSException("该流程未找到,打开失败"); + } + if ("default".equals(model.getMethodId())) { + throw new AWSException("文件夹类型不支持打开"); + } + if (checkPublish) { + if (!model.isPublish()) { + throw new AWSException("该流程当前状态为未发布状态,不允许打开"); + } + } + + // 新的权限校验,若是该模型已发布,按照权限范围表中的权限控制是否可访问,若是该模型尚未发布(例如在发布过程中、已停用等),则不进行权限控制,都可访问 + if (model.isPublish()) { + if (!hasAccessPortalDesignerPerm(uc, model)) { + return AlertWindow.getWarningMessagePage("打开失败", "您所在组织/职级暂未被授予该文件的阅览权限"); + } + } + + if (UtilString.isEmpty(taskId)) {// 停用或已发布状态查询流程手册 + taskId = getProcessReportTaskId(model); + } + CoeDesignerWeb web = new CoeDesignerWeb(uc); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_REPOSITORY_ACCESS); + } + + + return web.getMobilePortalDesignerHtml(uuid, upVisit, taskId);// 返回页面 + } + + + public boolean hasAccessPortalDesignerPerm(UserContext uc, PALRepositoryModel model) { + String newBoName = "BO_ACT_PUBLISH_PERM_SCOPE"; + BO bo = SDK.getBOAPI().query(newBoName).addQuery("PALVERSIONID=", model.getVersionId()).detail(); + if (bo == null) { + return false; + } + String permType = bo.getString("PERMTYPE"); + if ("1".equals(permType)) {// 全集团,都有权限 + return true; + } + // 如果当前人是系统管理员角色或者兼职系统管理员角色,默认有权限 + String roleId = "d102c89d-55f3-4865-9d5c-c00b7f47b803";// 系统管理员 + if (roleId.equals(uc.getRoleModel().getId())) { + return true; + } + // 兼职 + List adminUserMapModels = UserMapCache.getMapListOfUser(uc.getUID()); + for (UserMapModel mapModel : adminUserMapModels) { + if (roleId.equals(mapModel.getRoleId())) { + return true; + } + } + String orgPerm = bo.getString("ORGPERM"); + String postPerm = bo.getString("POSTPERM"); + String levelPerm = bo.getString("LEVELPERM"); + + // 根据发布流程选择的发布范围,获取所选组织、岗位、职级的交集进行权限控制 + + // 都不为空时 + if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm)) { + if ((getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc)) || getPostPerm(postPerm, uc)) { + return true; + } + // 职级为空时 + } else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm)) { + if (getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) { + return true; + } + // 岗位为空时 + } else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm)) { + if (getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc)) { + return true; + } + // 组织为空时 + } else if (UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(orgPerm)) { + if (getPostPerm(postPerm, uc) || getLevelPerm(levelPerm, uc)) { + return true; + } + // 组织、岗位为空时 + } else if (UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm) && UtilString.isEmpty(orgPerm)) { + if (getLevelPerm(levelPerm, uc)) { + return true; + } + // 组织、职级为空时 + } else if (UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm) && UtilString.isEmpty(orgPerm)) { + if (getPostPerm(postPerm, uc)) { + return true; + } + // 岗位、职级为空时 + } else if (UtilString.isNotEmpty(orgPerm) && UtilString.isEmpty(levelPerm) && UtilString.isEmpty(postPerm)) { + if (getOrgPerm(orgPerm, uc)) { + return true; + } + } + return false; + } + + //组织权限 + private boolean getOrgPerm(String orgPerm, UserContext uc) { + if (UtilString.isNotEmpty(orgPerm)) { + // 兼职 + Set deptIdSet = new HashSet<>(); + String[] deptIds = orgPerm.split(","); + for (int i = 0; i < deptIds.length; i++) { + if (UtilString.isNotEmpty(deptIds[i])) { + String deptId = deptIds[i]; + deptIdSet.add(deptId); + queryChildDeptList(deptId, deptIdSet); + } + } + // 判断用户的所属部门 + String currUserDeptId = uc.getDepartmentModel().getId(); + if (deptIdSet.contains(currUserDeptId)) { + return true; + } + // 判断用户的兼职部门 + List userMapModels = UserMapCache.getMapListOfUser(uc.getUID()); + for (UserMapModel mapModel : userMapModels) { + if (deptIdSet.contains(mapModel.getDepartmentId())) { + return true; + } + } + } + return false; + } + + //岗位权限 + private boolean getPostPerm(String postPerm, UserContext uc) { + if (UtilString.isNotEmpty(postPerm)) { + String positionNo = uc.getUserModel().getPositionNo(); + String[] positionIds = postPerm.split(","); + Set positionIdSet = new HashSet<>(); + for (int i = 0; i < positionIds.length; i++) { + positionIdSet.add(positionIds[i]); + } + if (positionIdSet.contains(positionNo)) { + return true; + } + } + return false; + + } + + //职级权限 + private boolean getLevelPerm(String levelPerm, UserContext uc) { + if (UtilString.isNotEmpty(levelPerm)) { + String userLevelPerm = uc.getUserModel().getExt2(); + String[] levelPermspArray = levelPerm.split(","); + Set levelPermspSet = new HashSet<>(); + for (int i = 0; i < levelPermspArray.length; i++) { + levelPermspSet.add(levelPermspArray[i]); + } + if (levelPermspSet.contains(userLevelPerm)) { + return true; + } + } + return false; + } + + private void queryChildDeptList(String pid, Set deptIdSet) { + List list = SDK.getORGAPI().getSubDepartments(pid); + if (list != null && list.size() > 0) { + for (DepartmentModel child : list) { + deptIdSet.add(child.getId()); + queryChildDeptList(child.getId(), deptIdSet); + } + } + } + + /** + * 查询流程的最新流程手册id + * + * @param model + * @return + */ + public String getProcessReportTaskId(PALRepositoryModel model) { + if (model != null) { + if (model.isPublish() || model.isStop()) {// 停用或已发布状态查询最新流程手册 + return new PublishListHistory().getLastPublishTaskIdByModelId(model.getId()); + } + } + return null; + } + + /** + * 无session打开流程只读页面 + * + * @param uid + * @param uuid + * @param processDefId + * @return + */ + public String openDesignerRepositoryViewer(String uid, String uuid, String processDefId) { + if (UtilString.isEmpty(uid)) { + uid = "admin"; + } + if (UtilString.isEmpty(uuid)) { + throw new AWSException("参数uuid不能为空"); + } + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model == null) { + throw new AWSException("流程不存在uuid=" + uuid); + } + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + throw new AWSException("未知类型或文件夹类型文件不支持打开uuid=" + uuid); + } + if (HighSecurity.isON()) { + String secAdmin = HighSecurity.getSecModel().getSysAdmin(); + String[] arr = secAdmin.split(" "); + uid = arr[0]; + } + String sid = new SSOUtil().registerClientSessionNoPassword(uid, "cn", "127.0.0.1", "pc"); + UserContext me = UserContext.fromSessionId(sid); + CoeDesignerWeb designerWeb = new CoeDesignerWeb(me); + return designerWeb.getDesignerHtml(uuid, 0, null, true, "", "", "", "1", ""); + } + + /** + * 变更表 + * + * @param uuid id + * @param setStr set部分sql + * @return + */ + public int updatePALRepositoryById(String uuid, String setStr) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model == null) { + return -1; + } + String sql = "UPDATE " + PALRepositoryModelImpl.DATABASE_ENTITY + " set "; + sql += setStr; + sql += " where " + PALRepositoryModelImpl.FIELD_UUID + "='" + uuid + "'"; + return CoeProcessLevelDaoFacotory.createCoeProcessLevel().updatePALRepository(uuid, sql); + } + + /** + * 获取流程缩略图片 + * 图片不重新生成,适用于快速查看,卡片展示对实时性要求不强的场景 + * 通过定时任务进行图片更新 + * + * @param uuid pal流程id,若该流程为关联/(在bpm运行)流程,则返回bpm流程图片 + * @return + */ + public String getProcessImageThumbnail(String uuid) { + PALRepositoryModel cplm = PALRepositoryCache.getCache().get(uuid); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(cplm.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + return "../apps/" + CoEConstant.APP_ID + "/img/method/default_folder.png"; + } + String photo = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; + String processDefId = queryBpmsProcessDefIdByPalId(uuid, true); + if (UtilString.isEmpty(processDefId)) { + String path = cplm.getFilePath(); + if (!UtilString.isEmpty(path)) { + UtilFile utilFile = new UtilFile(path + "/" + cplm.getId() + ".small.png"); + if (utilFile.exists()) { + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + photo = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); + } + } + } else {// 获取执行平台图片 + photo = "data:image/png;base64," + BPMNIO.getBPMNImageThumbnail(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId); + } + return photo; + } + + /** + * 获取流程图片 + * 图片重新生成,适用于实时查看图片,打印报告等耗费时间性能的操作 + * + * @param uuid pal流程id,若该流程为关联/(在bpm运行)流程,则返回bpm流程图片 + * @return + */ + public String getProcessImg(String uuid) { + PALRepositoryModel cplm = PALRepositoryCache.getCache().get(uuid); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(cplm.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + return "../apps/" + CoEConstant.APP_ID + "/img/method/default_folder.png"; + } + String photo = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; + String processDefId = queryBpmsProcessDefIdByPalId(uuid, true); + if (UtilString.isEmpty(processDefId)) { + PALRepositoryQueryAPIManager.getInstance().checkImage(cplm.getId(), true, false);// 生成图片 + String path = cplm.getFilePath(); + if (!UtilString.isEmpty(path)) { + UtilFile utilFile = new UtilFile(path + "/" + cplm.getId() + ".png"); + if (utilFile.exists()) { + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + photo = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); + } + } + } else {// 获取执行平台图片 + photo = "data:image/png;base64," + BPMNIO.getBPMNImage(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId); + } + return photo; + } + + /** + * 获取流程图片路径,,若该流程为关联/(在bpm运行)流程,则返回bpm流程图片路径 + * 图片重新创建,适用于实时查看图片,打印报告等耗费时间性能的操作 + * + * @param uuid pal流程id + * @return + */ + public String getProcessImgPath(String uuid) { + PALRepositoryModel cplm = PALRepositoryCache.getCache().get(uuid); + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(cplm.getMethodId()); + if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类 + return "../apps/" + CoEConstant.APP_ID + "/img/method/default_folder.png"; + } + String imageFilePath = ""; + String processDefId = queryBpmsProcessDefIdByPalId(uuid, true); + if (UtilString.isEmpty(processDefId)) { + PALRepositoryQueryAPIManager.getInstance().checkImage(cplm.getId(), true, false);// 生成图片 + String path = cplm.getFilePath(); + imageFilePath = path + "/" + cplm.getId() + ".png"; + } else { + BPMNIO.getBPMNImage(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId); + imageFilePath = BPMNFileUtil.getBPMNFileRealpath(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId) + processDefId + BPMNFileConstant.IMG_FILE_EXT_NAME; + } + return imageFilePath; + } + + /** + * 获取流程文件,若该流程为关联/(在bpm运行)流程,则返回bpm平台流程文件 + * + * @param uc UserContext对象 + * @param uuid pal流程id + * @return + */ + public String getProcessDefinition(UserContext uc, String uuid) { + String define = ""; + String processDefId = queryBpmsProcessDefIdByPalId(uuid, true); + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); + if (UtilString.isEmpty(processDefId)) {// 从pal获取 + if ("process.bpmn2".equals(plModel.getMethodId())) {// bpmn模型 + BPMNModel model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); + if (model == null) { + define = CoeDesignerUtil.getTemplateOfDefine(uuid); + } else { + define = model.getDefinition(); + } + } else {// 其他模型 + BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); + if (model == null) { + model = CoeDesignerUtil.createModel(uuid, 0); + define = model.getDefinition(); + } else { + define = model.getDefinition(); + } + } + } else {// 从bpm平台获取 + if (uc == null) { + uc = UserContext.fromUID("admin"); + } + CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(uc); + define = coeAdapter.readDefinition(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId).toString(); + } + if ("process.bpmn2".equals(plModel.getMethodId())) {// bpmn模型 + JSONObject definition = JSONObject.parseObject(define); + JSONObject localAttribute = definition.containsKey("localAttribute") ? definition.getJSONObject("localAttribute") : new JSONObject(); + if (localAttribute.isEmpty()) { + localAttribute = new JSONObject(); + } + if (localAttribute.isEmpty()) { + PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(plModel.getMethodId()); + List attributes = palMethodModel.getAttributes(); + Map> attributeMap = new HashMap>(); + if (attributes != null) { + for (PALMethodAttributeModel AttributeModel : attributes) { + Map map1 = new HashMap(); + map1.put("id", AttributeModel.getKey()); + map1.put("name", AttributeModel.getTitle()); + map1.put("key", AttributeModel.getKey()); + map1.put("value", AttributeModel.getValue()); + map1.put("type", AttributeModel.getType()); + map1.put("ref", AttributeModel.getRef()); + map1.put("readonly", AttributeModel.getReadonly()); + map1.put("groupPath", AttributeModel.getGroupPath()); + map1.put("scope", AttributeModel.getScope()); + attributeMap.put(AttributeModel.getKey(), map1); + } + } + List shapeAttributeList = PALRepositoryShapeAttributeCache.getAttributeListByMethod(plModel.getWsId(), plModel.getMethodId()); + if (shapeAttributeList != null && shapeAttributeList.size() > 0) { + for (PALRepositoryShapeAttributeModel shapeAttributeModel : shapeAttributeList) { + String shapeName = shapeAttributeModel.getShapeName(); + String attrId = shapeAttributeModel.getAttrId(); + if (localAttribute.containsKey(shapeName)) { + JSONArray array = localAttribute.getJSONArray(shapeName); + Map map = attributeMap.get(attrId); + if (map != null) { + JSONObject obj = JSONObject.parseObject(JSON.toJSONString(map)); + array.add(obj); + localAttribute.put(shapeName, array); + } + } else { + JSONArray array = new JSONArray(); + Map map = attributeMap.get(attrId); + if (map != null) { + JSONObject obj = JSONObject.parseObject(JSON.toJSONString(map)); + array.add(obj); + localAttribute.put(shapeName, array); + } + } + } + } + } + definition.put("localAttribute", localAttribute); + // 处理属性问题 + definition = CoeDesignerShapeAPIManager.getInstance().updateShapeDataAttributes(definition, localAttribute); + define = definition.toString(); + } + return define; + } + + /** + * 获取当前流程的所有版本,不同的是若流程与BPMS有关联,则获取与BPMS有关联的流程并更新版本号为BPMS流程版本号 + * + * @param uuid + * @return list + */ + public List queryPalRepositoryModelsByPalId(String uuid) { + return CoeProcessLevelUtil.queryPalRepositoryModelsByPalId(uuid); + } + + /** + * 获取版本,若PAL与BPMS关联,则获取关联的所有版本,若未关联,获取PAL数据 + * + * @return + */ + public PALRepositoryModel queryPalRepositoryModelByPalId(String uuid) { + return CoeProcessLevelUtil.queryPalRepositoryModelByPalId(uuid); + } + + /** + * 校验PAL是否关联了bpm流程但是在bpm端流程被删除,若存在此情况则进行关联关系删除 + * + * @param uuid + * @return + */ + public String correlateResourceCheck(String uuid) { + return CoeProcessLevelUtil.correlateResourceCheck(uuid); + } + + /** + * 获取PAL推送到BPMS但是尚未分配的流程-JSON方式 + * 返回通用的JSON,可供其他jar调用而不用引用相关类 + * + * @return JSONArray + */ + public JSONArray getCoePalNoDistributionJSON() { + return getCoePalNoDistributionJSONByVersionId(null); + } + + /** + * 获取PAL推送到BPMS但是尚未分配的流程-JSON方式 + * 返回通用的JSON,可供其他jar调用而不用引用相关类 + * + * @param versionId pal流程版本id + * @return JSONArray + */ + public JSONArray getCoePalNoDistributionJSONByVersionId(String versionId) { + return CoeProcessLevelUtil.getCoePalNoDistributionJSONByVersionId(versionId); + } + + /** + * 保存coe与bpms流程之间的关联关系,供其他jar调用 + * + * @param object + * @return + */ + public int coePalNoDistributionInsert(JSONObject object) { + return CoeProcessLevelUtil.coePalNoDistributionInsert(object); + } + + /** + * 校验PAL流程是否与BPMS有关联/推送关系 + * + * @param uuid PAL流程id + * @param checkBpmsExist 若有关联关系,是否进一步校验BPMS端流程是否存在,true:PAL关联了BPMS并且BPMS端被关联流程存在则返回BPMS流程id,false:PAL关联了BPMS流程(不管BPMS端流程是否存在)返回BPMS流程id + * @return 若是关联/推送流程,返回BPMS流程的ID,若不是或者BPMS端流程被删除,返回空字符串 + */ + public String queryBpmsProcessDefIdByPalId(String uuid, boolean checkBpmsExist) { + return CoeProcessLevelUtil.queryBpmsProcessDefIdByPalId(uuid, checkBpmsExist); + } + + /** + * 校验PAL流程是否与BPMS端流程有关联关系 + * + * @param uuid PAL id + * @param checkBpmsExist 若有关联关系,是否进一步校验BPMS端流程是否存在,true:PAL关联了BPMS并且BPMS端被关联流程存在则返回true,false:PAL关联了BPMS流程(不管BPMS端流程是否存在)返回true + * @return + */ + public boolean isCorrelateBpms(String uuid, boolean checkBpmsExist) { + return CoeProcessLevelUtil.isCorrelateBpms(uuid, checkBpmsExist); + } + + /** + * 根据BPMS流程id查询与PAL关联的流程id + * + * @param plAwsId + * @return BPMS与PAL有关联关系则返回PAL流程id,无关联关系返回null + */ + public String queryPlIdByPlAwsId(String plAwsId) { + CoeProcessLevelCorrelateModel model = CoeProcessLevelUtil.queryCorrelateModelyPlAwsId(plAwsId); + if (model != null) { + return model.getPlId(); + } + return null; + } + + /** + * 组名称是否可修改、删除判断依据 + * + * @param processVerIds BPM流程verId集合 + * @return true:可以修改/删除 false:锁定结构,不可以修改/删除 + */ + public boolean BpmUpdateGroup(List processVerIds) { + if (CoeProcessLevelUtil.isPalManage()) { + if (processVerIds == null || processVerIds.size() == 0) { + return true; + } + for (String verId : processVerIds) { + List list = CoeProcessLevelUtil.queryCorrelateModelsyPlAwsId(verId); + if (list == null) { + continue; + } + for (CoeProcessLevelCorrelateModel model : list) { + if (model.isCorrelate() && model.getCorrelateType() == 1 && "show".equals(model.getExt1())) { + return false; + } + } + } + } + return true; + } + + /** + * 流程是否可显示/隐藏 + * + * @param processVerId + * @return null:该流程/流程版本与PAL 关联关系,依照平台机制处 不为null,[xxx,xxx]:xxx为所有可以显示的流程,且其所有显示流程锁定结构,若size为0, 代表该流程版本下所有流程 显示(及特殊情况出现) + */ + public List getShowBpmProcessList(String processVerId) { + if (CoeProcessLevelUtil.isPalManage()) { + if (UtilString.isEmpty(processVerId)) { + return null; + } + List list = CoeProcessLevelUtil.queryCorrelateModelsyPlAwsId(processVerId); + if (list == null || list.size() == 0) { + return null; + } + List result = new ArrayList<>(); + for (CoeProcessLevelCorrelateModel model : list) { + if (model.isCorrelate() && model.getCorrelateType() == 1 && "show".equals(model.getExt1())) { + result.add(model.getPlAwsId()); + } + } + return result; + } + return null; + } + + /** + * 流程是否锁定结构 + * + * @param processDefId BPM流程id + * @return true:可以修改/删除 false:锁定结构, 可以修改/删除 + */ + public boolean isLockStructure(String processDefId) { + String plId = queryPlIdByPlAwsId(processDefId); + if (UtilString.isEmpty(plId)) { + return false; + } + CoeProcessLevelCorrelateModel model = CoeProcessLevelCorrelateCache.getCache().get(plId); + if (model == null) { + return false; + } + if (!CoeProcessLevelUtil.isBpmProcessEdit()) { + return model.isCorrelate(); + } + return false; + } + + /** + * 流程是否显示 + * + * @param processDefId + * @return + */ + public boolean isShowBpmProcess(String processDefId) { + if (!CoeProcessLevelUtil.isPalManage()) { + return true; + } + String plId = queryPlIdByPlAwsId(processDefId); + if (UtilString.isEmpty(plId)) { + return true; + } + CoeProcessLevelCorrelateModel model = CoeProcessLevelCorrelateCache.getCache().get(plId); + if (model == null) { + return true; + } + return model.isCorrelate() && model.getCorrelateType() == 1 && "show".equals(model.getExt1()); + } + + private static class Inner { + private final static PALRepositoryQueryAPIManager instance = new PALRepositoryQueryAPIManager(); + } + + /** + * 根据级别排序 并设置父节点 + * + * @author wangyh + *

+ * 2014年7月25日 + */ + private class ComparatorLevel implements Comparator { + @Override + public int compare(PALRepositoryModelImpl model1, PALRepositoryModelImpl model2) { + Integer level1 = model1.getLevel(); + Integer level2 = model2.getLevel(); + int result = level1.compareTo(level2); + model2.setParentId(model1.getId()); + model1.setPublish(true);// 不是代表发布,用来代替是否是父节点 + return result; + } + } + + /** + * 根据级别排序 + * + * @author wangyh + *

+ * 2014年7月25日 + */ + private class Comparator1 implements Comparator { + @Override + public int compare(PALRepositoryModel model1, PALRepositoryModel model2) { + Integer level1 = model1.getLevel(); + Integer level2 = model2.getLevel(); + int result = level1.compareTo(level2); + if (result == 0) { + Integer index1 = model1.getOrderIndex(); + Integer index2 = model2.getOrderIndex(); + result = index1.compareTo(index2); + } + return result; + } + } + + /** + * 获取更多特性树 + * + * @param wsId 资产库id + * @param methodId 模型分类 + * @param type file:文件属性,shape:形状属性 + * @param shapeName 形状名称,type为shape时有效,可为空 + * @return + */ + public static JSONArray getPalRepositoryMoreAttrConfig(String wsId, String methodId, String type, String shapeName) { + return CoeProcessLevelUtil.getPalRepositoryMoreAttrConfig(wsId, methodId, type, shapeName); + } + + /****************************************重构一些新的方法 20201209 sunlh********************************************/ + + /** + * 根据pid获取符合条件的子流程数据 + * + * @param uc + * @param wsId + * @param teamId + * @param pid + * @return + */ + public JSONArray getUsedPalRepositoryTreeDataByPidNew(UserContext uc, String wsId, String teamId, String pid) { + // 获取符合权限的子流程 + List childrenList = getUsedPalRepositoryModelsByPidNew(uc, wsId, teamId, pid); + Collections.sort(childrenList, new Comparator1()); + Map grandChildrenCountMap = new HashMap<>(); + for (PALRepositoryModel chlidModel : childrenList) { + List grandChildrenList = getUsedPalRepositoryModelsByPidNew(uc, wsId, teamId, chlidModel.getId()); + grandChildrenCountMap.put(chlidModel.getId(), grandChildrenList.size()); + } + JSONArray result = list2JsonNew(uc, childrenList, grandChildrenCountMap); + return result; + } + + /** + * 获取某个流程的使用中的子流程 + * + * @param wsId + * @param pid + * @return + */ + public List getUsedPalRepositoryModelsByPidNew(UserContext uc, String wsId, String teamId, String pid) { + if (UtilString.isEmpty(teamId)) { + return getUsedPalRepositoryModelsByPid(wsId, pid); + } else { + List result = new ArrayList<>(); + // 获取权限versionIds + Set permVerIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, uc.getUID(), null, null); + if (permVerIds.size() > 0) { + getPermRepositoryByPid(wsId, pid, permVerIds, true, false, new HashSet<>(), result); + } + return result; + } + } + + /** + * 根据父节点获取权限范围内的子流程 + * + * @param wsId + * @param pid + * @param permVersionIds 权限versionIds + * @param isUse + * @param isPublish + * @param verIds 给一个空的Set,防止数据造成的死循环 + * @param result 结果集 + */ + private void getPermRepositoryByPid(String wsId, String pid, Set permVersionIds, boolean isUse, boolean isPublish, Set verIds, List result) { + List childList = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); + if (childList != null && childList.size() > 0) { + for (PALRepositoryModel model : childList) { + if (verIds.contains(model.getVersionId())) { + //防止无限循环 + continue; + } + if (isUse) { + if (model.isUse()) {// 设计中的流程是连贯的,与发布不同 + verIds.add(model.getVersionId()); + if (permVersionIds.contains(model.getVersionId())) { + result.add(model); + } else { + getPermRepositoryByPid(wsId, model.getId(), permVersionIds, isUse, isPublish, verIds, result); + } + } + } else if (isPublish) { + if (model.isPublish() && permVersionIds.contains(model.getVersionId())) { + verIds.add(model.getVersionId()); + result.add(model); + } else { + getPermRepositoryByPid(wsId, model.getId(), permVersionIds, isUse, isPublish, verIds, result); + } + } + } + } + } + + /** + * 新的流程树list转换json方法 + * + * @param uc + * @param list + * @param childrenCountMap list中的model是否具有子节点map记录 + * @return + */ + private JSONArray list2JsonNew(UserContext uc, List list, Map childrenCountMap) { + JSONArray jsonArray = new JSONArray(); + for (PALRepositoryModel model : list) { + JSONObject object = new JSONObject(); + object.put("id", model.getVersionId().trim()); + object.put("currId", model.getId()); + object.put("pid", model.getNewParentId().trim()); + object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim()); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, uc.getLanguage(), model.getName()).trim()); + object.put("wsId", model.getWsId()); + object.put("isSystemFile", model.isSystemFile()); + object.put("plMethodId", model.getMethodId().trim()); + JSONObject icon = new JSONObject(); + object.put("folder", true);// 类型,文件夹 + if ("default".equals(model.getMethodId())) {// 默认文件夹 + JSONObject methodIcon = PALMethodManager.getInstance().getPALMethodIconById(model.getMethodId()); + if (methodIcon != null) { + icon.put("icon", methodIcon.getString("code")); + icon.put("color", methodIcon.getString("color")); + } + } else {// 非默认文件夹 + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (methodModel != null) {// 存在该建模方法 + if (methodModel.isFolder()) {// 文件夹类型扩展的建模方法 + + JSONObject methodIcon = PALMethodManager.getInstance().getPALMethodIconById(model.getMethodId()); + icon.put("icon", methodIcon.getString("code")); + icon.put("color", methodIcon.getString("color")); + } else {// 文件类型模型文件 + //判断如果是组织图,更换组织图图标 + if (methodModel.getId().equals("org.role") || methodModel.getId().equals("org.normal")) { + icon.put("icon", ""); + icon.put("color", "#ef7b40"); + } else { + icon.put("icon", ""); + icon.put("color", "#8E8E8E"); + } + object.put("folder", false);// 非文件夹 + } + } + } + if (icon.isEmpty()) {// 默认 + //判断如果是组织图,更换组织图图标 + if (model.getMethodId().equals("org.role") || model.getMethodId().equals("org.normal")) { + icon.put("icon", ""); + icon.put("color", "#ef7b40"); + } else { + icon.put("icon", ""); + icon.put("color", "#FFB718"); + } + + } + object.put("icon", icon); + List children = null; + if (childrenCountMap.containsKey(model.getId()) && childrenCountMap.get(model.getId()) > 0) { + object.put("leaf", false);// 非叶子节点 + object.put("childCount", childrenCountMap.get(model.getId())); + } else { + object.put("leaf", true);// 叶子节点 + object.put("childCount", 0); + } + object.put("plLevel", model.getLevel()); + object.put("plOrdexIndex", model.getOrderIndex()); + object.put("plDiagramUrl", model.getDiagramUrl()); + object.put("isDrops", model.isSystemFile()); + object.put("isPublish", model.isPublish()); + object.put("isStop", model.isStop()); + object.put("isApproval", model.isApproval()); + object.put("ext1", model.getExt1()); + object.put("ext2", model.getExt2()); + object.put("ext3", model.getExt3()); + object.put("ext4", model.getExt4()); + object.put("isUse", model.isUse()); + object.put("plCategory", model.getMethodCategory()); + object.put("versionId", model.getVersionId()); + object.put("orderIndex", model.getOrderIndex()); + object.put("isBottomLevel", model.isBottomLevel()); + object.put("createUser", model.getCreateUser()); + object.put("modifyUser", model.getModifyUser()); + + + //三员管理下,附件是否存在未标定密级 + if (HighSecurityUtil.isON()) { + object.put("isUpfileUnmark", this.checkUpfileSecurity(model)); + if (HighSecurityUtil.fileSecuritySwitch()) { + //流程文件密级回显 + Integer securityLevel = model.getSecurityLevel(); + HashMap securityMap = HighSecurityUtil.getObjSecurityMap(); + String securityLevelName = securityMap.get(String.valueOf(securityLevel)); + object.put("securityLevelName", securityLevelName == null ? "未标密" : securityLevelName); + object.put("isFileSecurity", true); + object.put("securityLevel", securityLevel); + } + } + jsonArray.add(object); + } + return jsonArray; + } + + /** + * 三员管理下,附件是否存在未标定密级 + * + * @param model + * @return + */ + public boolean checkUpfileSecurity(PALRepositoryModel model) { + List upfileModels = new UpFileDao().search(model.getId(), null, null); + for (UpfileModel upfile : upfileModels) { + if (upfile.getSecurityLevel() == -1) { + return true; + } + } + return false; + } + + + /** + * 形状属性-类型 + */ + public String shapePropertyType(String myTypeName) { + if ("linker".equals(myTypeName)) { + return "连线"; + } + Class clzz = BPMNConstant.class; + Field[] fields = clzz.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + try { + String typeName = (String) field.get(null); + if (myTypeName != null && myTypeName.equals(typeName)) { + String type = field.getName(); + Field typeTitle = clzz.getDeclaredField(type + "_TITLE"); + String typeTitleName = (String) typeTitle.get(null); + return typeTitleName; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return ""; + } + + /** + * 获取模型形状的附件 + * + * @param palId + * @param uc 可为null + * @return + */ + public static List queryShapeUpfileList(String palId, UserContext uc) { + return new UpfileQuery().loadUpFiles(palId, null, "shape", (uc == null ? UserContext.fromUID("admin") : uc)); + } + + /** + * 获取模型形状的关联附件 + * + * @param palId + * @param uc 可为null + * @return + */ + public static List queryShapeRelationUpfileList(String palId, UserContext uc) { + return new UpfileQuery().loadRelationUpfiles(palId, null, "shape", (uc == null ? UserContext.fromUID("admin") : uc)); + } + + /** + * 获取文件的附件 + * + * @param palId + * @param uc 可为null + * @return + */ + public static List queryProcessUpfileList(String palId, UserContext uc) { + return new UpfileQuery().loadUpFiles(palId, null, "file", (uc == null ? UserContext.fromUID("admin") : uc)); + } + + /** + * 获取文件的关联附件 + * + * @param palId + * @param uc 可为null + * @return + */ + public static List queryProcessRelationUpfileList(String palId, UserContext uc) { + return new UpfileQuery().loadRelationUpfiles(palId, null, "file", (uc == null ? UserContext.fromUID("admin") : uc)); + } + + static class UpfileQuery { + /** + * 加载流程文件/形状附件 + * + * @param palId + * @param type file 文件附件 shape 形状附件 + * @param shapeId + * @return + */ + private List loadUpFiles(String palId, String shapeId, String type, UserContext uc) { + List result = new ArrayList<>(); + UpFileDao upFileDao = new UpFileDao(); + List upfileList = upFileDao.search(palId, shapeId, type); + if (upfileList != null) { + Set ids = new HashSet<>(); + for (UpfileModel model : upfileList) { + if (ids.contains(model.getUuid())) { + continue; + } + ids.add(model.getUuid()); + String downloadURL = ""; + DCContext dcContext = getDCContext(model, uc); + if (dcContext != null) { + downloadURL = dcContext.getDownloadURL() + "&isInline=false"; + } + model.setDownloadUrl(downloadURL); + result.add(model); + } + } + sortByCreateTime(result); + return result; + } + + /** + * 加载关联附件 + * + * @param palId 模型Id + * @param shapeId 图形Id + * @param type file/shape(模型附件还是图形附件) + * @return + */ + private List loadRelationUpfiles(String palId, String shapeId, String type, UserContext uc) { + List result = new ArrayList<>(); + // 获取属性的关联类型(relationType) + Map relationTypeMap = new HashMap<>(); + PALRepositoryModel m = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(palId); + PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(m.getMethodId()); + if (palMethodModel != null) { + List attributes = palMethodModel.getAttributes(); + for (PALMethodAttributeModel model : attributes) { + if ("relation".equals(model.getType())) { + JSONObject refObj = JSONObject.parseObject(model.getRef()); + String relationType = refObj.containsKey("type") ? refObj.getString("type") : "shape"; + relationTypeMap.put(model.getKey(), relationType); + } + } + } + if (UtilString.isEmpty(shapeId) || "file".equals(type)) { + shapeId = ""; + } + Iterator iterator = DesignerShapeRelationCache.getByShapeId(palId, shapeId); + List list = new ArrayList<>(); + UpFileDao dao = new UpFileDao(); + while (iterator.hasNext()) { + DesignerShapeRelationModel model = iterator.next(); + if (relationTypeMap.containsKey(model.getAttrId())) { + if ("file".equals(relationTypeMap.get(model.getAttrId()))) {// 文件 + String versionId = model.getRelationFileId(); + PALRepositoryModel palModel = CoeProcessLevelUtil.getUseRepositoryByVersionId(versionId);// 获取工作版本 + if (palModel != null) { + List list2 = dao.search(palModel.getId(), null, type); + if (list2 != null && list2.size() > 0) { + list.addAll(list2); + } + } + } else {// 形状 + List list2 = dao.search(model.getRelationFileId(), model.getRelationShapeId(), type); + if (list2 != null && list2.size() > 0) { + list.addAll(list2); + } + } + } + } + if (list != null) { + Set ids = new HashSet<>(); + for (UpfileModel model : list) { + if (ids.contains(model.getUuid())) { + continue; + } + ids.add(model.getUuid()); + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(model.getPl_uuid()); + if (palModel != null) { + String downloadURL = ""; + DCContext dcContext = getDCContext(model, uc); + if (dcContext != null) { + downloadURL = dcContext.getDownloadURL() + "&isInline=false"; + } + model.setDownloadUrl(downloadURL); + result.add(model); + } + } + } + sortByCreateTime(result); + return result; + } + + public void sortByCreateTime(List list) { + list.sort((m1, m2) -> { + return m2.getCreateTime().compareTo(m1.getCreateTime()); + }); + } + + /** + * 获取dccontext + * + * @param model + * @return + */ + private DCContext getDCContext(UpfileModel model, UserContext uc) { + DCContext dcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile != null) { + if ("f".equals(model.getType())) {// 文件 + dcContext = new DCContext(uc, dcProfile, CoEConstant.APP_ID, "file", + model.getPl_uuid(), model.getFileName()); + } else {// 图形 + dcContext = new DCContext(uc, dcProfile, CoEConstant.APP_ID, model.getPl_uuid(), + model.getShape_uuid(), model.getFileName()); + } + } + return dcContext; + } + } + + /*************************************流程附件 start****************************************/ + /** + * 检测平台是否开启三员管理,同时设置返回参数 + * + * @param ro + */ + public void checkHighSecurity(String uuid, ResponseObject ro) { + //平台开启三元模式 + if (HighSecurityUtil.isON()) { + PALRepositoryModel plModel = null; + if (null != uuid && HighSecurityUtil.fileSecuritySwitch()) { + plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + } + //全部文件密级 + HashMap securityMap = HighSecurityUtil.getObjSecurityMap(); + //筛选用户与文件密级 + Set entrySet = securityMap.keySet(); + Iterator iterator = entrySet.iterator(); + UserContext userContext = DispatcherRequest.getUserContext(); + while (iterator.hasNext()) { + String next = iterator.next(); + if (!HighSecurityUtil.hasSecurityLevel(userContext, Integer.parseInt(next), plModel)) { + iterator.remove(); + } + } + ro.put("securityList", securityMap); + ro.put("isHighSecurity", true); + if (HighSecurityUtil.fileSecuritySwitch()) { + ro.put("isFileSecurity", true); + } + } + } + + + /** + * 附件密级根据用户与文件密级过滤 + * + * @param uc + * @param list + */ + public void upFileSecurityFilter(UserContext uc, List list) { + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + UpfileModel model = iterator.next(); + if ((!HighSecurityUtil.hasSecurityLevel(uc, model.getSecurityLevel(), model)) || -1 == model.getSecurityLevel()) { + iterator.remove(); + } + } + } + + /** + * 附件密级根据用户筛选其下所有密级文件,包含未标密 + * + * @param uc + * @param list + */ + public void upFileSecurityUnmarkFilter(UserContext uc, List list) { + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + UpfileModel model = iterator.next(); + if ((!HighSecurityUtil.hasSecurityLevel(uc, model.getSecurityLevel(), model))) { + iterator.remove(); + } + } + } + + /** + * 是否开启三员管理 + * + * @return + */ + public boolean isSecurityMode() { + return HighSecurityUtil.isON(); + } + + /** + * 获取流程树中第一个流程文件未标密 或者 附件未标密文件在树中路径 + * + * @return + */ + public String getUnmarkPath(UserContext me, String wsId, String teamId) { + ResponseObject ro = ResponseObject.newOkResponse(); + + if (!HighSecurityUtil.isON()) { + ro = ResponseObject.newErrResponse().msg("三员管理应用未开启"); + return ro.toString(); + } + + //小组权限 + Set versionIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, me.getUID(), null, null); + + //未标密的文件 + PALRepositoryModel unmarkModel = this.findFileUnmarkModel(versionIds, wsId, teamId); + + if (null == unmarkModel) { + //未标密的附件 + unmarkModel = new UpfileWeb(me).findUpfileUnmarkModel(versionIds, wsId, teamId); + } + + // 获取文件路径 + List path = new ArrayList<>(); + if (null == unmarkModel) { + ro.put("path", path.toArray()); + return ro.toString(); + } + JSONArray repositoryPathData = CoeProcessLevelUtil.getRepositoryPath(unmarkModel.getId()); + // 前面大类不显示,根据小组进行级别处理 + for (int i = 0; i < repositoryPathData.size(); i++) { + JSONObject currObj = repositoryPathData.getJSONObject(i); + PALRepositoryModel currModel = PALRepositoryCache.getCache().get(currObj.getString("id")); + if (currModel != null && versionIds.contains(currModel.getVersionId())) { + path.add(currModel.getVersionId()); + } else if (currObj.getString("id").length() < 36) { + path.add(currObj.getString("id")); + } + } + ro.put("path", path.toArray()); + return ro.toString(); + } + + /** + * 获取第一个流程文件未标密model + * + * @param me + * @param versionIds + * @param wsId + * @param teamId + * @return + */ + public PALRepositoryModel findFileUnmarkModel(Set versionIds, String wsId, String teamId) { + PALRepositoryModel targetModel = null; + //开启三员管理下,流程文件密级标定switch + if (HighSecurityUtil.fileSecuritySwitch()) { + List repositoryList = this.getInuseRepositoryList(versionIds, wsId, teamId); + for (PALRepositoryModel model : repositoryList) { + //查询流程文件 是否存在未标定密级 + boolean flag = PALRepositoryQueryAPIManager.getInstance().checkFileSecurity(model); + if (flag) { + targetModel = model; + break; + } + } + } + return targetModel; + } + + /** + * 获取流程树中inuse文件 + * + * @param versionIds 小组权限下的流程文件uuid + * @param wsId + * @param teamId + * @return + */ + public List getInuseRepositoryList(Set versionIds, String wsId, String teamId) { + //获取资产库下所有流程 + List list = new ArrayList<>(); + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + + while (iterator.hasNext()) { + PALRepositoryModel model = iterator.next(); + if (!UtilString.isEmpty(teamId)) { + //小组过滤 + if (model.isUse() && versionIds.contains(model.getVersionId())) { + list.add(model); + } + } else { + if (model.isUse()) { + list.add(model); + } + } + } + // 排序 + Collections.sort(list, new Comparator1()); + + return list; + } + + /** + * 三员管理下,流程文件是否存在未标定密级 + * + * @param model + * @return + */ + public boolean checkFileSecurity(PALRepositoryModel model) { + + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + return null != methodModel && !methodModel.isFolder() && model.getSecurityLevel() == -1; + } + + /** + * 获取流程树下未标密文件的数量 + * + * @param wsId + * @param teamId + * @return + */ + public Integer getUnMarkFileNum(UserContext me, String wsId, String teamId) { + if (!HighSecurityUtil.isON() || !HighSecurityUtil.fileSecuritySwitch()) { + return null; + } + int num = 0; + + //小组权限 + Set versionIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, me.getUID(), null, null); + + //开启三员管理下,流程文件密级标定switch + List repositoryList = this.getInuseRepositoryList(versionIds, wsId, teamId); + for (PALRepositoryModel model : repositoryList) { + //查询流程文件 是否存在未标定密级 + boolean flag = PALRepositoryQueryAPIManager.getInstance().checkFileSecurity(model); + if (flag) { + num++; + } + } + return num; + } + + /** + * 报告生成器应用,前置校验密级访问权限 + * + * @param me + * @param model + * @return + */ + public ResponseObject checkOutputSecurityPermission(UserContext me, OutputTaskModel model) { + ResponseObject rs = ResponseObject.newOkResponse(); + + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), model.getId(), OutputConst.FILE_WIZARD_CONFIG); + + //获取config.txt配置 + UtilFile file = new UtilFile(dcContext.getPath() + "/config.txt"); + String s = file.readStrUTF8(); + JSONObject jsonObject = JSON.parseObject(s); + String targetFileId = String.valueOf(jsonObject.get("targetFileId")); + targetFileId = targetFileId.contains(",") ? targetFileId.substring(targetFileId.indexOf(',') + 1) : targetFileId; + + //密级权限校验 + CoeProcessLevelWeb web = new CoeProcessLevelWeb(me); + return web.checkFilePemission(targetFileId); + } + /*************************************流程附件 end****************************************/ + + /** + * 根据报告生成器的任务ID查询对应的文件存储路径 + * + * @param uc + * @param taskId 表APP_ACT_COE_PAL_OUTPUT_TASK的ID + * @return + */ + public String queryReportFilePath(UserContext uc, String taskId) { + String dirPath = ""; + if (UtilString.isEmpty(taskId)) return dirPath; + OutputTask taskDao = new OutputTask(); + OutputTaskModel taskModel = taskDao.getTaskReportById(taskId); + if (taskDao != null) { + String profileId = taskModel.getProfileId(); + OutputAppProfile profile = OutputAppManager.getProfile(profileId); + if (profile != null) { + String appId = profile.getAppContext().getId(); + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(appId, OutputConst.EXT_APP_DC_OUTPUT); + DCContext dcContext = new DCContext(uc, dcProfile, appId, taskModel.getWsId(), taskModel.getId()); + dirPath = dcContext.getPath(); + } + } + return dirPath; + } + + /** + * 根据模型ID查询所有文件扩展属性 + * + * @param uuid + * @return + */ + public static Map queryRepositoryAttributeById(String uuid) { + Map result = new HashMap<>(); + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); + // 获取所有文件属性 + List methodAttrModels = PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels(plModel.getWsId(), plModel.getMethodId()); + if (methodAttrModels != null && methodAttrModels.size() > 0) { + Map attributeModelMap = new HashMap<>(); + Map sortAttrMap = new HashMap<>(); + if (methodAttrModels != null) { + int sort = 0; + for (PALMethodAttributeModel attr : methodAttrModels) { + attributeModelMap.put(attr.getKey(), attr); + sortAttrMap.put(attr.getKey(), ++sort); + } + } + List propertys = PALRepositoryPropertyCache.getPropertyByPlId(plModel.getId()); + // 排序 + // propertys.sort((p1, p2) -> (sortAttrMap.containsKey(p1.getPropertyId()) ? sortAttrMap.get(p1.getPropertyId()) : 0) - (sortAttrMap.containsKey(p2.getPropertyId()) ? sortAttrMap.get(p2.getPropertyId()) : 0)); + + for (PALRepositoryPropertyModel property : propertys) { + String id = property.getPropertyId(); + if (!attributeModelMap.containsKey(id) || !attributeModelMap.get(id).getUse()) { + continue; + } + PALMethodAttributeModel attributeModel = attributeModelMap.get(id); + // 记录结果集 + JSONObject attrObj = new JSONObject(); + attrObj.put("ref", attributeModel.getRef());// ref + attrObj.put("type", attributeModel.getType());// 类型 relation string ... + attrObj.put("attrId", attributeModel.getKey());// 属性key + attrObj.put("attrTitle", attributeModel.getNewTitle());// 属性标题 + attrObj.put("text", "");// 属性内容单行文本 + attrObj.put("value", new JSONArray());// 属性内容集,relation或awsorg类型时存储对应的json数据 + String inputValue = property.getPropertyValue(); + inputValue = UtilString.isEmpty(inputValue) ? "" : inputValue; + if ("relation".equals(attributeModel.getType())) { + List inputValueList = new ArrayList<>(); + List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); + list.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText)); + if (list != null && list.size() > 0) { + // 判断是否有重复数据,进行重复过滤 + Set tempStrs = new HashSet<>(); + List tempList = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + DesignerShapeRelationModel model = list.get(i); + String str = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId(); + if (!tempStrs.contains(str)) { + tempList.add(model); + tempStrs.add(str); + } + } + list = tempList; + for (int i = 0; i < list.size(); i++) { + DesignerShapeRelationModel model = list.get(i); + JSONObject refObj = JSONObject.parseObject(attributeModel.getRef()); + String relationTyp = refObj.containsKey("type") ? refObj.getString("type") : "shape"; + if ("file".equals(relationTyp)) {// 关联的模型文件 + if (model.getRelationFileId().length() < 36) { + continue; + } + List list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + inputValueList.add(model2.getName()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model2.getId()); + tmp.put("name", model2.getName()); + tmp.put("isFile", true); + attrObj.getJSONArray("value").add(tmp); + break; + } + } + } else if ("shapeAndFile".equals(relationTyp)) {// 关联的模型形状和文件都有 伊利 + if (UtilString.isEmpty(model.getRelationShapeId())) {// 关联文件,发现记录的不是versionID,而是id 伊利 + PALRepositoryModel relationModel = PALRepositoryCache.getCache().get(model.getRelationFileId()); + if (relationModel != null) { + inputValueList.add(relationModel.getName()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", relationModel.getId()); + tmp.put("name", relationModel.getName()); + tmp.put("isFile", true); + attrObj.getJSONArray("value").add(tmp); + } + } else { + // 关联形状 + inputValueList.add(model.getRelationShapeText()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model.getRelationFileId()); + tmp.put("shapeId", model.getRelationShapeId()); + tmp.put("name", model.getRelationShapeText()); + tmp.put("isFile", false); + attrObj.getJSONArray("value").add(tmp); + } + } else {// 关联的模型形状 + inputValueList.add(model.getRelationShapeText()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model.getRelationFileId()); + tmp.put("shapeId", model.getRelationShapeId()); + tmp.put("name", model.getRelationShapeText()); + tmp.put("isFile", false); + attrObj.getJSONArray("value").add(tmp); + } + } + } + inputValue = StringUtils.join(inputValueList, ","); + } + // 关联bpm组织架构 + if ("awsorg".equals(attributeModel.getType())) { + List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); + List deptValList = new ArrayList<>(); + List positionValList = new ArrayList<>(); + List roleValList = new ArrayList<>(); + List userValList = new ArrayList<>(); + + JSONArray depjsonArray = new JSONArray(); + if (list != null && list.size() > 0) { + Set filter = new HashSet();// 去重记录 + + list.sort((m1, m2) -> { + return m1.getId().compareTo(m2.getId()); + }); + for (DesignerShapeRelationModel model : list) { + if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + boolean flag = false; + // 查询最新名称 /*if ("department".equals(object.getString("type"))) { DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); if (dept != null && !filter.contains(dept.getId())) { @@ -5617,287 +5672,287 @@ public class PALRepositoryQueryAPIManager { } }*/ - /*************************************部门自定义排序改造******************************************************/ - if ("department".equals(object.getString("type"))) { - DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); - if (dept != null && !filter.contains(dept.getId())) { - if(object.getString("timestamp")!=null){ - flag = false; - depjsonArray.add(object); - }else{ - deptValList.add(dept.getName()); - filter.add(dept.getId()); - flag = true; - } + /*************************************部门自定义排序改造******************************************************/ + if ("department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept != null && !filter.contains(dept.getId())) { + if (object.getString("timestamp") != null) { + flag = false; + depjsonArray.add(object); + } else { + deptValList.add(dept.getName()); + filter.add(dept.getId()); + flag = true; + } - } - } + } + } - if ("position".equals(object.getString("type"))) {// 岗位,先用角色代替 - RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); - if (role != null && !filter.contains(role.getId())) { - positionValList.add(role.getName()); - filter.add(role.getId()); - flag = true; - } - } - if ("user".equals(object.getString("type"))) { - UserModel user = SDK.getORGAPI().getUser(object.getString("id")); - if (user != null && !filter.contains(user.getUID())) { - userValList.add(user.getUserName()); - filter.add(user.getUID()); - flag = true; - } - } - if ("role".equals(object.getString("type"))) { - RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); - if (role != null && !filter.contains(role.getId())) { - roleValList.add(role.getName()); - filter.add(role.getId()); - flag = true; - } - } - if (flag) { - attrObj.getJSONArray("value").add(object); - } + if ("position".equals(object.getString("type"))) {// 岗位,先用角色代替 + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + positionValList.add(role.getName()); + filter.add(role.getId()); + flag = true; + } + } + if ("user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user != null && !filter.contains(user.getUID())) { + userValList.add(user.getUserName()); + filter.add(user.getUID()); + flag = true; + } + } + if ("role".equals(object.getString("type"))) { + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + roleValList.add(role.getName()); + filter.add(role.getId()); + flag = true; + } + } + if (flag) { + attrObj.getJSONArray("value").add(object); + } - } - } + } + } - /*********************************自定义排序*******************************/ - if(depjsonArray.size()>0 && depjsonArray.getJSONObject(0).getString("timestamp")!=null){ - Set filter1 = new HashSet();// 去重记录 - depjsonArray.sort(Comparator.comparing(st ->((JSONObject)st).getString("timestamp"))); - JSONObject jo = new JSONObject(new LinkedHashMap()); - for(int b=0;b 0 && depjsonArray.getJSONObject(0).getString("timestamp") != null) { + Set filter1 = new HashSet();// 去重记录 + depjsonArray.sort(Comparator.comparing(st -> ((JSONObject) st).getString("timestamp"))); + JSONObject jo = new JSONObject(new LinkedHashMap()); + for (int b = 0; b < depjsonArray.size(); b++) { + JSONObject onedata = depjsonArray.getJSONObject(b); + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(onedata.getString("id")); + deptValList.add(dept.getName()); + filter1.add(dept.getId()); - attrObj.getJSONArray("value").add(onedata); - } - } - } - // 数据组合 - deptValList.addAll(positionValList); - deptValList.addAll(roleValList); - deptValList.addAll(userValList); - inputValue = StringUtils.join(deptValList, ","); + attrObj.getJSONArray("value").add(onedata); + } + } + } + // 数据组合 + deptValList.addAll(positionValList); + deptValList.addAll(roleValList); + deptValList.addAll(userValList); + inputValue = StringUtils.join(deptValList, ","); - } - inputValue = inputValue.replaceAll("'", "'"); - inputValue = inputValue.replaceAll("\"", """); - attrObj.put("text", inputValue); - result.put(attributeModel.getKey(), attrObj); - } - } - return result; - } + } + inputValue = inputValue.replaceAll("'", "'"); + inputValue = inputValue.replaceAll("\"", """); + attrObj.put("text", inputValue); + result.put(attributeModel.getKey(), attrObj); + } + } + return result; + } - /** - * 根据模型和形状查询所有形状扩展属性 - * - * @param uuid - * @param shapeId - * @param shapeObject 当前节点的定义json,可以通过PALRepositoryQueryAPIManager.getInstance().getProcessDefinition获取string--》转换JSONObject--》获取elements--》elements.getJSONObject(shapeId)得到 - * @param separator 分隔符,不清楚作用请给null或"" - * @return - */ - public Map queryRepositoryShapeAttributeById(String uuid, String shapeId, JSONObject shapeObject, String separator) { - separator = UtilString.isEmpty(separator) ? "," : separator; - Map result = new HashMap<>(); - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - String methodId = model.getMethodId(); - String wsId = model.getWsId(); - JSONObject dataAttributes = ShapeUtil.getCustom(shapeObject.getJSONArray("dataAttributes")); - JSONArray attributesJsonArray = dataAttributes.containsKey("attributesJsonArray") ? dataAttributes.getJSONArray("attributesJsonArray") : new JSONArray(); //扩展属性 - // 查询属性数据集合 - Map attrDataMap = new HashMap<>(); - for (Object obj : attributesJsonArray) { - if (obj == null) { - continue; //删除的节点不存在 - } - JSONObject jsonObj = (JSONObject) obj; - if (!jsonObj.containsKey("groupPath") || UtilString.isEmpty(jsonObj.getString("groupPath"))) { - continue; //排除组 - } - if (!jsonObj.containsKey("type") || UtilString.isEmpty(jsonObj.getString("type"))) { - continue; //排除无type的 - } - attrDataMap.put(jsonObj.getString("key"), jsonObj); - } - // 获取形状的属性配置(有效且使用中) - List methodAttrModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, methodId, shapeObject.getString("name"), methodId); - for (PALMethodAttributeModel attributeModel : methodAttrModels) { - // 记录结果集 - JSONObject attrObj = new JSONObject(); - attrObj.put("ref", attributeModel.getRef());// ref - attrObj.put("type", attributeModel.getType());// 类型 relation string ... - attrObj.put("attrId", attributeModel.getKey());// 属性key - attrObj.put("attrTitle", attributeModel.getNewTitle());// 属性标题 - attrObj.put("text", "");// 属性内容单行文本 - attrObj.put("value", new JSONArray());// 属性内容集,relation或awsorg类型时存储对应的json数据 + /** + * 根据模型和形状查询所有形状扩展属性 + * + * @param uuid + * @param shapeId + * @param shapeObject 当前节点的定义json,可以通过PALRepositoryQueryAPIManager.getInstance().getProcessDefinition获取string--》转换JSONObject--》获取elements--》elements.getJSONObject(shapeId)得到 + * @param separator 分隔符,不清楚作用请给null或"" + * @return + */ + public Map queryRepositoryShapeAttributeById(String uuid, String shapeId, JSONObject shapeObject, String separator) { + separator = UtilString.isEmpty(separator) ? "," : separator; + Map result = new HashMap<>(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + String methodId = model.getMethodId(); + String wsId = model.getWsId(); + JSONObject dataAttributes = ShapeUtil.getCustom(shapeObject.getJSONArray("dataAttributes")); + JSONArray attributesJsonArray = dataAttributes.containsKey("attributesJsonArray") ? dataAttributes.getJSONArray("attributesJsonArray") : new JSONArray(); //扩展属性 + // 查询属性数据集合 + Map attrDataMap = new HashMap<>(); + for (Object obj : attributesJsonArray) { + if (obj == null) { + continue; //删除的节点不存在 + } + JSONObject jsonObj = (JSONObject) obj; + if (!jsonObj.containsKey("groupPath") || UtilString.isEmpty(jsonObj.getString("groupPath"))) { + continue; //排除组 + } + if (!jsonObj.containsKey("type") || UtilString.isEmpty(jsonObj.getString("type"))) { + continue; //排除无type的 + } + attrDataMap.put(jsonObj.getString("key"), jsonObj); + } + // 获取形状的属性配置(有效且使用中) + List methodAttrModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, methodId, shapeObject.getString("name"), methodId); + for (PALMethodAttributeModel attributeModel : methodAttrModels) { + // 记录结果集 + JSONObject attrObj = new JSONObject(); + attrObj.put("ref", attributeModel.getRef());// ref + attrObj.put("type", attributeModel.getType());// 类型 relation string ... + attrObj.put("attrId", attributeModel.getKey());// 属性key + attrObj.put("attrTitle", attributeModel.getNewTitle());// 属性标题 + attrObj.put("text", "");// 属性内容单行文本 + attrObj.put("value", new JSONArray());// 属性内容集,relation或awsorg类型时存储对应的json数据 - String key = attributeModel.getKey(); - String attrValue = ""; - if (attrDataMap.containsKey(key)) { - JSONObject jsonObj = attrDataMap.get(key); - if (jsonObj == null) { - continue; - } - String type = attributeModel.getType(); - if ("string".equals(type)) { - attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; - } else if ("number".equals(type)) { - attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; - } else if ("textarea".equals(type)) { - attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; - } else if ("boolean".equals(type)) { - attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; - } else if ("select".equals(type)) { - attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; - } else if ("select_m".equals(type)) { - attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; - String[] values = attrValue.split(","); - List valueList = new ArrayList<>(); - for (int i = 0; i < values.length; i++) { - if (!UtilString.isEmpty(values[i])) { - valueList.add(values[i]); - } - } - attrValue = StringUtils.join(valueList, separator); - } else if ("relation".equals(type)) { - List inputValues = new ArrayList<>(); - JSONObject refObj = JSONObject.parseObject(attributeModel.getRef()); - String relationType = refObj.containsKey("type") ? refObj.getString("type") : "shape"; - List list = DesignerShapeRelationCache.getListByAttrId(uuid, shapeId, key); - if (list != null && list.size() > 0) { - // 判断是否有重复数据,进行重复过滤 - Set tempStrs = new HashSet<>(); - List tempList = new ArrayList<>(); - for (int i = 0; i < list.size(); i++) { - DesignerShapeRelationModel relationModel = list.get(i); - String str = relationModel.getFileId() + relationModel.getShapeId() + relationModel.getAttrId() + relationModel.getRelationFileId() + relationModel.getRelationShapeId(); - if (!tempStrs.contains(str)) { - tempList.add(relationModel); - tempStrs.add(str); - } - } - list = tempList; - for (int i = 0; i < list.size(); i++) { - DesignerShapeRelationModel relationModel = list.get(i); - if ("file".equals(relationType)) {// 文件属性 - String versionId = UtilString.isEmpty(relationModel.getRelationShapeId()) ? relationModel.getRelationFileId() : relationModel.getRelationShapeId(); - if (!UtilString.isEmpty(versionId)) { - List list2 = PALRepositoryCache.getByVersionId(wsId, versionId); - for (PALRepositoryModel model2 : list2) { - if (model2.isUse()) { - inputValues.add(model2.getName()); - JSONObject tmp = new JSONObject(); - tmp.put("fileId", model2.getId()); - tmp.put("name", model2.getName()); - tmp.put("isFile", true); - attrObj.getJSONArray("value").add(tmp); - break; - } - } - } - } else if ("shapeAndFile".equals(relationType)) {// 关联的模型形状和文件都有 伊利 - if (UtilString.isEmpty(relationModel.getRelationShapeId())) {// 关联文件,发现记录的不是versionID,而是id 伊利 - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(relationModel.getRelationFileId()); - if (plModel != null) { - inputValues.add(plModel.getName()); - JSONObject tmp = new JSONObject(); - tmp.put("fileId", plModel.getId()); - tmp.put("name", plModel.getName()); - tmp.put("isFile", true); - attrObj.getJSONArray("value").add(tmp); - } - } else { - // 关联形状 - inputValues.add(relationModel.getRelationShapeText()); - JSONObject tmp = new JSONObject(); - tmp.put("fileId", relationModel.getRelationFileId()); - tmp.put("shapeId", relationModel.getRelationShapeId()); - tmp.put("name", relationModel.getRelationShapeText()); - tmp.put("isFile", false); - attrObj.getJSONArray("value").add(tmp); - } - } else {// 形状属性 - inputValues.add(relationModel.getRelationShapeText()); - JSONObject tmp = new JSONObject(); - tmp.put("fileId", relationModel.getRelationFileId()); - tmp.put("shapeId", relationModel.getRelationShapeId()); - tmp.put("name", relationModel.getRelationShapeText()); - tmp.put("isFile", false); - attrObj.getJSONArray("value").add(tmp); - } - } - } - attrValue = StringUtils.join(inputValues, separator); - } else if ("awsorg".equals(type)) {// 关联bpm组织架构 - List list = DesignerShapeRelationCache.getListByAttrId(uuid, shapeId, key); - List awsOrgResultList = new ArrayList<>(); - List deptValueList = new ArrayList<>(); - List positionValueList = new ArrayList<>(); - List userValueList = new ArrayList<>(); - List roleValueList = new ArrayList<>(); - if (list != null && list.size() > 0) { - for (DesignerShapeRelationModel relationModel : list) { - JSONObject object = JSONObject.parseObject(relationModel.getRelationShapeText()); - String orgType = object.getString("type"); - String keyId = object.getString("id"); - boolean flag = false; - if ("department".equals(orgType)) {// 部门 - DepartmentModel deptModel = SDK.getORGAPI().getDepartmentById(keyId); - if (deptModel != null) { - deptValueList.add(deptModel.getName()); - flag = true; - } - } - if ("position".equals(orgType)) {// 岗位 - RoleModel roleModel = SDK.getORGAPI().getRoleById(keyId); - if (roleModel != null) { - positionValueList.add(roleModel.getName()); - flag = true; - } - } - if ("user".equals(orgType)) {// 人员 - UserModel userModel = SDK.getORGAPI().getUser(keyId); - if (userModel != null) { - userValueList.add(userModel.getUserName()); - flag = true; - } - } - if ("role".equals(orgType)) {// 角色 - RoleModel roleModel = SDK.getORGAPI().getRoleById(keyId); - if (roleModel != null) { - roleValueList.add(roleModel.getName()); - flag = true; - } - } - if (flag) { - attrObj.getJSONArray("value").add(object); - } - } - } - awsOrgResultList.addAll(deptValueList); - awsOrgResultList.addAll(positionValueList); - awsOrgResultList.addAll(roleValueList); - awsOrgResultList.addAll(userValueList); - attrValue = StringUtils.join(awsOrgResultList, separator); - } else { - attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; - } - } - attrValue = attrValue.replaceAll("'", "'"); - attrValue = attrValue.replaceAll("\"", """); - attrObj.put("text", attrValue); - result.put(attributeModel.getKey(), attrObj); - } - return result; - } + String key = attributeModel.getKey(); + String attrValue = ""; + if (attrDataMap.containsKey(key)) { + JSONObject jsonObj = attrDataMap.get(key); + if (jsonObj == null) { + continue; + } + String type = attributeModel.getType(); + if ("string".equals(type)) { + attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; + } else if ("number".equals(type)) { + attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; + } else if ("textarea".equals(type)) { + attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; + } else if ("boolean".equals(type)) { + attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; + } else if ("select".equals(type)) { + attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; + } else if ("select_m".equals(type)) { + attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; + String[] values = attrValue.split(","); + List valueList = new ArrayList<>(); + for (int i = 0; i < values.length; i++) { + if (!UtilString.isEmpty(values[i])) { + valueList.add(values[i]); + } + } + attrValue = StringUtils.join(valueList, separator); + } else if ("relation".equals(type)) { + List inputValues = new ArrayList<>(); + JSONObject refObj = JSONObject.parseObject(attributeModel.getRef()); + String relationType = refObj.containsKey("type") ? refObj.getString("type") : "shape"; + List list = DesignerShapeRelationCache.getListByAttrId(uuid, shapeId, key); + if (list != null && list.size() > 0) { + // 判断是否有重复数据,进行重复过滤 + Set tempStrs = new HashSet<>(); + List tempList = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + DesignerShapeRelationModel relationModel = list.get(i); + String str = relationModel.getFileId() + relationModel.getShapeId() + relationModel.getAttrId() + relationModel.getRelationFileId() + relationModel.getRelationShapeId(); + if (!tempStrs.contains(str)) { + tempList.add(relationModel); + tempStrs.add(str); + } + } + list = tempList; + for (int i = 0; i < list.size(); i++) { + DesignerShapeRelationModel relationModel = list.get(i); + if ("file".equals(relationType)) {// 文件属性 + String versionId = UtilString.isEmpty(relationModel.getRelationShapeId()) ? relationModel.getRelationFileId() : relationModel.getRelationShapeId(); + if (!UtilString.isEmpty(versionId)) { + List list2 = PALRepositoryCache.getByVersionId(wsId, versionId); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + inputValues.add(model2.getName()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model2.getId()); + tmp.put("name", model2.getName()); + tmp.put("isFile", true); + attrObj.getJSONArray("value").add(tmp); + break; + } + } + } + } else if ("shapeAndFile".equals(relationType)) {// 关联的模型形状和文件都有 伊利 + if (UtilString.isEmpty(relationModel.getRelationShapeId())) {// 关联文件,发现记录的不是versionID,而是id 伊利 + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(relationModel.getRelationFileId()); + if (plModel != null) { + inputValues.add(plModel.getName()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", plModel.getId()); + tmp.put("name", plModel.getName()); + tmp.put("isFile", true); + attrObj.getJSONArray("value").add(tmp); + } + } else { + // 关联形状 + inputValues.add(relationModel.getRelationShapeText()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", relationModel.getRelationFileId()); + tmp.put("shapeId", relationModel.getRelationShapeId()); + tmp.put("name", relationModel.getRelationShapeText()); + tmp.put("isFile", false); + attrObj.getJSONArray("value").add(tmp); + } + } else {// 形状属性 + inputValues.add(relationModel.getRelationShapeText()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", relationModel.getRelationFileId()); + tmp.put("shapeId", relationModel.getRelationShapeId()); + tmp.put("name", relationModel.getRelationShapeText()); + tmp.put("isFile", false); + attrObj.getJSONArray("value").add(tmp); + } + } + } + attrValue = StringUtils.join(inputValues, separator); + } else if ("awsorg".equals(type)) {// 关联bpm组织架构 + List list = DesignerShapeRelationCache.getListByAttrId(uuid, shapeId, key); + List awsOrgResultList = new ArrayList<>(); + List deptValueList = new ArrayList<>(); + List positionValueList = new ArrayList<>(); + List userValueList = new ArrayList<>(); + List roleValueList = new ArrayList<>(); + if (list != null && list.size() > 0) { + for (DesignerShapeRelationModel relationModel : list) { + JSONObject object = JSONObject.parseObject(relationModel.getRelationShapeText()); + String orgType = object.getString("type"); + String keyId = object.getString("id"); + boolean flag = false; + if ("department".equals(orgType)) {// 部门 + DepartmentModel deptModel = SDK.getORGAPI().getDepartmentById(keyId); + if (deptModel != null) { + deptValueList.add(deptModel.getName()); + flag = true; + } + } + if ("position".equals(orgType)) {// 岗位 + RoleModel roleModel = SDK.getORGAPI().getRoleById(keyId); + if (roleModel != null) { + positionValueList.add(roleModel.getName()); + flag = true; + } + } + if ("user".equals(orgType)) {// 人员 + UserModel userModel = SDK.getORGAPI().getUser(keyId); + if (userModel != null) { + userValueList.add(userModel.getUserName()); + flag = true; + } + } + if ("role".equals(orgType)) {// 角色 + RoleModel roleModel = SDK.getORGAPI().getRoleById(keyId); + if (roleModel != null) { + roleValueList.add(roleModel.getName()); + flag = true; + } + } + if (flag) { + attrObj.getJSONArray("value").add(object); + } + } + } + awsOrgResultList.addAll(deptValueList); + awsOrgResultList.addAll(positionValueList); + awsOrgResultList.addAll(roleValueList); + awsOrgResultList.addAll(userValueList); + attrValue = StringUtils.join(awsOrgResultList, separator); + } else { + attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : ""; + } + } + attrValue = attrValue.replaceAll("'", "'"); + attrValue = attrValue.replaceAll("\"", """); + attrObj.put("text", attrValue); + result.put(attributeModel.getKey(), attrObj); + } + return result; + } } diff --git a/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar b/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar index e59a46dc..7a3e4a03 100644 Binary files a/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar and b/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar differ diff --git a/com.awspaas.user.apps.coe.pal.output.zd/lib/poi-tl-1.12.1.jar b/com.awspaas.user.apps.coe.pal.output.zd/lib/poi-tl-1.12.1.jar new file mode 100644 index 00000000..31fe3b3a Binary files /dev/null and b/com.awspaas.user.apps.coe.pal.output.zd/lib/poi-tl-1.12.1.jar differ diff --git a/com.awspaas.user.apps.coe.pal.output.zd/lib/Spire.Doc.jar b/com.awspaas.user.apps.coe.pal.output.zd/lib/spirej.doc.cracked-11.4.2.jar similarity index 70% rename from com.awspaas.user.apps.coe.pal.output.zd/lib/Spire.Doc.jar rename to com.awspaas.user.apps.coe.pal.output.zd/lib/spirej.doc.cracked-11.4.2.jar index a0c4d895..5db61374 100644 Binary files a/com.awspaas.user.apps.coe.pal.output.zd/lib/Spire.Doc.jar and b/com.awspaas.user.apps.coe.pal.output.zd/lib/spirej.doc.cracked-11.4.2.jar differ diff --git a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java index 26db4957..1c7073ed 100644 --- a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java +++ b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java @@ -6,10 +6,7 @@ import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; import com.actionsoft.apps.coe.pal.pal.output.util.OutputExcelUtil; import com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; -import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; -import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao; -import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; @@ -17,35 +14,46 @@ import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstan import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao; import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; import com.actionsoft.apps.coe.pal.system.property.CoePropertyUtil; -import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; import com.actionsoft.bpms.commons.database.RowMap; import com.actionsoft.bpms.commons.mvc.view.ActionWeb; -import com.actionsoft.bpms.server.Quota; +import com.actionsoft.bpms.server.DispatcherRequest; import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.conf.server.AWSServerConf; import com.actionsoft.bpms.server.fs.DCContext; import com.actionsoft.bpms.server.fs.dc.DCProfileManager; -import com.actionsoft.bpms.util.*; -import com.actionsoft.exception.AWSQuotaException; +import com.actionsoft.bpms.server.fs.dc.DCUtil; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.bpms.util.UtilFile; +import com.actionsoft.bpms.util.UtilString; import com.actionsoft.sdk.local.SDK; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.awspaas.apps.coe.pal.output.zd.util.PrReportComment; import com.awspaas.apps.coe.pal.output.zd.util.ReportRepositoryCompare; import com.awspaas.apps.coe.pal.output.zd.util.XMLUtil; -import com.spire.doc.FileFormat; -import org.apache.commons.lang.StringUtils; +import com.sini.com.spire.doc.*; +import com.sini.com.spire.doc.collections.SectionCollection; +import com.sini.com.spire.doc.documents.*; +import com.sini.com.spire.doc.fields.TextRange; +import com.sini.com.spire.doc.formatting.CharacterFormat; +import com.sini.com.spire.doc.formatting.ParagraphFormat; +import freemarker.template.Configuration; +import freemarker.template.Template; +import org.apache.commons.compress.utils.IOUtils; import org.dom4j.Document; import org.dom4j.DocumentException; -import org.dom4j.Element; +import java.awt.*; import java.io.*; import java.nio.charset.StandardCharsets; -import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.List; import java.util.*; -import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.specialCharTransfer; - /** * 生成流程手册-步骤横表横表的入口 * @@ -55,6 +63,7 @@ public class InstitutionalTextWeb extends ActionWeb { UserContext _uc; GenerLogExd log = new GenerLogExd(); + public InstitutionalTextWeb(UserContext uc) { super(uc); _uc = uc; @@ -71,46 +80,130 @@ public class InstitutionalTextWeb extends ActionWeb { * @param teamId * @return */ - public void systemManualTextExport() { + public String systemManualTextExport() { List listIds = OutputAppManager.getProfileName(""); - String tempName = "制度-手册6.xml"; - String tempPath = "../apps/install/com.awspaas.user.apps.coe.pal.output.zd/"; - String wsId = ""; - boolean dev = Quota.isDEV(); - if (dev) { - wsId = "0285ff6a-e418-4d8b-a5b1-22240296f769"; - } - boolean prd = Quota.isPRD(); - if (prd) { - wsId = "7d3ca852-a0bd-42e6-80b1-3dcea6f55083"; - } - boolean qas = Quota.isQAS(); - if (qas) { - wsId = "7d3ca852-a0bd-42e6-80b1-3dcea6f55083"; - } - - //查询制度流程文件 - List policyMap = DBSql.getMaps("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLMETHODID='control.policy' AND ID='ca45dc6a-0f77-44ee-adfe-f36b014586f3' "); + List policyMap = DBSql.getMaps("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLMETHODID='control.policy' "); + String downUrl = ""; + + Date date = new Date(); + SimpleDateFormat dateFormat = new + SimpleDateFormat("yyyyMMddhhmmss"); + + long times = System.currentTimeMillis(); + final String zipName = "批量下载正文导出" + dateFormat.format(date) + ".zip"; + String targetDir = AWSServerConf.getProperty("dc.path") + File.separator + "com.awspaas.user.apps.coe.pal.output.zd" + File.separator + "tmp/grouppackage/zip" + times + "/"; + + File targetFileDir = new File(targetDir); + if (!targetFileDir.exists()) { + targetFileDir.mkdirs(); + } for (int i = 0; i < policyMap.size(); i++) { + exportText(policyMap.get(i).getString("ID"), policyMap.get(i).getString("WSID"), policyMap.get(i).getString("PLNAME"), policyMap.get(i).getString("PLVER"), zipName, times, targetDir, targetFileDir); + } - // - String targetFileId = policyMap.get(i).getString("ID"); + try { + UtilFile.zipCompress(targetDir, new File(targetDir + zipName)); + + File[] files = targetFileDir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + if (name.equals(zipName)) { + return false; + } + return true; + } + }); + for (File file : files) { + try { + file.delete(); + } catch (Exception exception) { + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + DCContext zipDcContext = new DCContext(getContext(), DCProfileManager.getDCProfile("com.awspaas.user.apps.coe.pal.output.zd", "tmp"), "com.awspaas.user.apps.coe.pal.output.zd", "grouppackage", "zip" + times, zipName); + + downUrl = SDK.getConfAPI().getPortalUrl() + "/r/" + zipDcContext.getDownloadURL().replace("./", ""); + + + return downUrl; + + } + + /** + * 制度正文单条导出 + * + * @param targetFileId + * @return + */ + public String systemManualTextExportoOnce(String targetFileId) { + List listIds = OutputAppManager.getProfileName(""); + String downUrl = ""; + + Date date = new Date(); + SimpleDateFormat dateFormat = new + SimpleDateFormat("yyyyMMddhhmmss"); + + long times = System.currentTimeMillis(); + final String zipName = "批量下载正文导出" + dateFormat.format(date) + ".zip"; + String targetDir = AWSServerConf.getProperty("dc.path") + File.separator + "com.awspaas.user.apps.coe.pal.output.zd" + File.separator + "tmp/grouppackage/zip" + times + "/"; + + File targetFileDir = new File(targetDir); + if (!targetFileDir.exists()) { + targetFileDir.mkdirs(); + } + + if (targetFileId != null) { + + String[] targetFileIdArray = targetFileId.split(","); + + for (int i = 0; i < targetFileIdArray.length; i++) { + //查询制度流程文件 + RowMap policyMap = DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLMETHODID='control.policy' AND ID='" + targetFileIdArray[i] + "' "); + + if (policyMap != null) { + exportText(policyMap.getString("ID"), policyMap.getString("WSID"), policyMap.getString("PLNAME"), policyMap.getString("PLVER"), zipName, times, targetDir, targetFileDir); + } + + } + try { + UtilFile.zipCompress(targetDir, new File(targetDir + zipName)); + } catch (Exception e) { + e.printStackTrace(); + } + + DCContext zipDcContext = new DCContext(getContext(), DCProfileManager.getDCProfile("com.awspaas.user.apps.coe.pal.output.zd", "tmp"), "com.awspaas.user.apps.coe.pal.output.zd", "grouppackage", "zip" + times, zipName); + downUrl = SDK.getConfAPI().getPortalUrl() + "/r/" + zipDcContext.getDownloadURL().replace("./", ""); + } + + return downUrl; + + } + + public void exportText(String targetFileId, String wsId, String plname, String versionNumer, String zipName, long times, String targetDir, File targetFileDir) { + ProcessInstance boProcessInstance = SDK.getProcessAPI() + .createBOProcessInstance("obj_c0fd5262f1c64df9ab5e725aae3eff2e", "admin", "正文导出"); + + String fileName = null; + try { + String tempName = "制度-手册7.xml"; + String tempPath = "../apps/install/com.awspaas.user.apps.coe.pal.output.zd/"; String fileValue = UUIDGener.getUUID() + "_outputText"; String sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd"; - String filename = policyMap.get(i).getString("PLNAME"); + String filename = plname; DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, fileValue, filename); String docPath = sourceDc.getPath(); UtilFile upfileDir = new UtilFile(docPath); if (!upfileDir.exists()) { upfileDir.mkdirs(); } - - //{"orderNuberFirst":true,"targetShape":"","targetFileId":"ca45dc6a-0f77-44ee-adfe-f36b014586f3", // "orderNametwo":false,"reportNameIsItName":"%fileName%_%fileVersion%","relationFileId":"","isItReport":true} @@ -171,7 +264,6 @@ public class InstitutionalTextWeb extends ActionWeb { reportNameValue = reportNameValue.substring(0, 255); } String docName = ""; - String fileName = ""; if (indexMap.containsKey(reportNameValue)) { int index = indexMap.get(reportNameValue); index++; @@ -186,18 +278,596 @@ public class InstitutionalTextWeb extends ActionWeb { indexMap.put(fileName, 1); } + JSONObject dataMap = getData2(targetFileId, wizardJsonData, docPath, fileName); System.out.println("dpcpath=======" + docPath); + if (dataMap != null) { - OutputWordUtil.createDoc2(dataMap, tempPath, tempName, docName); + + String filePath = createDoc2(dataMap, tempPath, tempName, docName, wizardJsonData, targetFileId, docPath); + DCContext sourceDc2 = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, fileValue, fileName + ".doc"); + String downUrl = SDK.getConfAPI().getPortalUrl() + "/r/" + + sourceDc2.getDownloadURL().replace("./", ""); + + + File targetFile = new File(targetDir + fileName + ".doc"); + if (!targetFile.exists()) { + targetFile.createNewFile(); + } + OutputStream out = new FileOutputStream(targetFile); + InputStream in = DCUtil.decryptFile(sourceDc2); + if (in == null) { + String msg = "+ dcContext.getFileName() + "; + if (sourceDc.getDCMessage() != null) { + msg = sourceDc.getDCMessage().getMessage(); + } + } + try { + IOUtils.copy(in, out); + in.close(); + out.close(); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(out); + } + + + if (filePath != null) { + + BO actTextDerivation = SDK.getBOAPI().query("BO_ACT_TEXT_DERIVATION").addQuery("PALID=", targetFileId).addQuery("UPFILESTATE=", "上传成功").detail(); + if (actTextDerivation == null) { + BO bo = new BO(); + bo.set("PALID", targetFileId); + bo.set("FILENAME", fileName); + bo.set("VERSIONNUMBER", versionNumer); + bo.set("UPFILESTATE", "下载成功"); + bo.set("PALNAME", plname); + SDK.getBOAPI().create("BO_ACT_TEXT_DERIVATION", bo, boProcessInstance.getId(), ""); + } else { + BO bo = SDK.getBOAPI().query("BO_ACT_TEXT_DERIVATION").addQuery("PALID=", targetFileId).addQuery("UPFILESTATE=", "下载失败").detail(); + if (bo != null) { + bo.set("ID", bo.getId()); + bo.set("UPFILESTATE", "下载成功"); + SDK.getBOAPI().update("BO_ACT_TEXT_DERIVATION", bo); + } + + } + + } } + + + } + } catch (Exception e) { + e.printStackTrace(); + BO actTextDerivation = SDK.getBOAPI().query("BO_ACT_TEXT_DERIVATION").addQuery("PALID=", targetFileId).addQuery("UPFILESTATE=", "下载失败").detail(); + if (actTextDerivation == null) { + BO bo = new BO(); + bo.set("PALID", targetFileId); + bo.set("FILENAME", fileName); + bo.set("VERSIONNUMBER", versionNumer); + bo.set("UPFILESTATE", "下载失败"); + bo.set("PALNAME", plname); + bo.set("REASONSPROBLEM", e.getMessage()); + SDK.getBOAPI().create("BO_ACT_TEXT_DERIVATION", bo, boProcessInstance.getId(), ""); } - } + } + /** + * 生成word文件 + * + * @param dataMap + * @param tempPath + * @param tempName + * @param docName + */ + public static String createDoc2(com.alibaba.fastjson.JSONObject dataMap, String tempPath, String tempName, String docName, JSONObject wizardJsonData, String repositoryId, String docPath) throws Exception { + Configuration configuration = new Configuration(); + configuration.setDefaultEncoding("UTF-8"); + + + // 设置模本装置方法和路径 + UtilFile temps = new UtilFile(tempPath); + configuration.setDirectoryForTemplateLoading(temps); + + + Template t = null; + t = configuration.getTemplate(tempName, "UTF-8"); + + // 输出文档路径及名称 + File outFile = new File(docName); + Writer out = null; + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8")); + + + if (t != null && out != null) { + t.process(dataMap, out); + out.flush(); + out.close(); + } + + + //***********************************************************使用spire 生成模板后复制文件****************************************************/ + List> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson4(repositoryId); //流程文件内容 + if (wizardJsonData.getBoolean("orderNuberFirst")) { // 根据页面选择进行排序 + OutputWordUtil.orderByNumber(repositoryFileElements); + } + + String controlShapeId = ""; + if (repositoryFileElements != null) { + int index = 1;// 流程步骤序号 + int dangerIndex = 1;// 风险序号 + int regulateIndex = 1;// 控制序号 + for (Map shape : repositoryFileElements) { + String type = shape.get("type").toString(); + if ("regulation".equals(type)) { + controlShapeId = shape.get("id").toString(); + } else if ("I/O_L4".equals(type)) { + controlShapeId = shape.get("id").toString(); + } + } + } + + + UserContext userContext = DispatcherRequest.getUserContext(); + + Map result = new HashMap<>(); + result.put("listDef", ""); + result.put("content", ""); + if (UtilString.isEmpty(controlShapeId)) { + + } + PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId); + if (repositoryModel == null) { + + } + String content = ""; + StringBuilder listStr = new StringBuilder(); + // 读取附件 + // 流程附件列表 + UpFileDao upFileDao = new UpFileDao(); + List search = upFileDao.search(repositoryModel.getId(), controlShapeId, null); + + DCContext dcContextpdf = null; + File file = null; + + + if (search != null && search.size() > 0) { + long b1 = System.currentTimeMillis(); + // 复制附件 + for (UpfileModel upfileModel : search) { + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + + if (dcProfile != null) { + dcContextpdf = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), upfileModel.getFileName()); + String path = dcContextpdf.getPath(); + String fileName = dcContextpdf.getFileName(); + + + String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + + if (suffix.equals("xml")) { + // 输出文档路径及名称 + + + File sourceFile = new UtilFile(path + fileName); + File targetFile = new UtilFile(docPath + fileName); + try { + UtilFile.copyFile(sourceFile, targetFile); + } catch (Exception e) { + System.out.println(e); + e.printStackTrace(); + } + + //创建实例,加载xml测试文档 + com.sini.com.spire.doc.Document doc = new com.sini.com.spire.doc.Document(); + doc.loadFromFile(docPath + fileName); + + //保存为xml格式 + String substring = fileName.substring(0, fileName.lastIndexOf(".xml")); + //保存为Word + doc.saveToFile(docPath + substring + ".docx", FileFormat.Docx);//支持.doc + + } + + + //获取section + /*Section section1 = doc1.getSections().get(0); + + //获取文档1的页眉页脚 + HeaderFooter headerword = section1.getHeadersFooters().getHeader(); + HeaderFooter footerword = section1.getHeadersFooters().getFooter(); + + //加载文档2 + com.sini.com.spire.doc.Document doc2 = new com.sini.com.spire.doc.Document(); + + + doc2.loadFromFile(outFile.getPath()); + + + //获取第一节 + Section sec = doc2.getSections().get(0); + + //删除页眉 + sec.getHeadersFooters().getHeader().getChildObjects().clear(); + + //删除页脚 + sec.getHeadersFooters().getFooter().getChildObjects().clear(); + + //遍历文档2的section + for (int i = 0; i < doc2.getSections().getCount(); i++) { + Section section2 = doc2.getSections().get(i); + //遍历页眉中的对象 + for (int j = 0; j < headerword.getChildObjects().getCount(); j++) { + //获取页眉中的所有子对象 + Object object1 = headerword.getChildObjects().get(j); + //复制文档1的页眉添加到文档2 + section2.getHeadersFooters().getHeader().getChildObjects().add(((DocumentObject) object1).deepClone()); + } + + //同理复制页脚 + for (int z = 0; z < footerword.getChildObjects().getCount(); z++) { + Object object2 = footerword.getChildObjects().get(z); + section2.getHeadersFooters().getFooter().getChildObjects().add(((DocumentObject) object2).deepClone()); + } + } + + doc2.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + + doc2.dispose();*/ + + + //创建 Document 类的对象并从磁盘加载 Word 文档 + com.sini.com.spire.doc.Document document = new com.sini.com.spire.doc.Document(outFile.getPath()); + + Section section = document.getLastSection(); + // 删除第一页 + Section section2 = document.getSections().get(0); + document.getSections().remove(section2); + + + //添加段落 + Paragraph paragraph = section.addParagraph(); + + + ParagraphFormat paragraphFormat = paragraph.getFormat(); + paragraphFormat.setHorizontalAlignment(HorizontalAlignment.Left); + + TextRange tr = paragraph.appendText("1.目的"); + + + tr.getCharacterFormat().setBold(true); + tr.getCharacterFormat().setFontName("宋体"); + tr.getCharacterFormat().setFontSize(12); + paragraph.applyStyle(BuiltinStyle.Heading_1); //应用标题1样式 + + + CharacterFormat format = new CharacterFormat(document); + format.setFontName("黑体"); + + + //添加段落 + Paragraph Purposeparagraph = section.addParagraph(); + Purposeparagraph.appendText(dataMap.getString("pl_Purpose")); + + + //获取第三段并设置首行缩进 + Paragraph para3 = section.getParagraphs().get(2); + para3.getFormat().setFirstLineIndent(30); + + //添加段落 + Paragraph paragraph1 = section.addParagraph(); + + ParagraphFormat paragraphFormat1 = paragraph1.getFormat(); + paragraphFormat1.setHorizontalAlignment(HorizontalAlignment.Left); + + TextRange tr1 = paragraph1.appendText("2.术语"); + + + tr1.getCharacterFormat().setBold(true); + tr1.getCharacterFormat().setFontName("宋体"); + tr1.getCharacterFormat().setFontSize(12); + paragraph1.applyStyle(BuiltinStyle.Heading_1); //应用标题1样式 + + + PALRepositoryPropertyModel term = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(), "term"); + + + JSONArray termTable = new JSONArray(); //术语定义Table + // 属性特征 属性代码KEY + String termVal = term.getPropertyValue(); + JSONObject termObj = JSONObject.parseObject(termVal); + if (termObj != null && !termObj.isEmpty()) { + JSONArray tableArr = termObj.getJSONArray("table"); + if (tableArr != null && !tableArr.isEmpty()) { + for (Object obj : tableArr) { + JSONObject obj2 = (JSONObject) obj; + if (!"table_head".equals(obj2.getString("id"))) { + String name = obj2.getString("name"); + String desc = obj2.getString("desc"); + JSONObject tmp = new JSONObject(); + tmp.put("name", name); + tmp.put("desc", desc); + termTable.add(tmp); + } + } + } + } + + + //定义表格数据 + String[] header = {"术语", "定义"}; + + if (termTable != null && !termTable.isEmpty()) { + + String[][] strArray2 = new String[termTable.size()][]; + + + List list = new LinkedList<>(); + for (int i = 0; i < termTable.size(); i++) { + JSONObject obj2 = termObj.getJSONArray("table").getJSONObject(i); + String[] strArray = new String[2]; + strArray[0] = obj2.getString("name"); + strArray[1] = obj2.getString("desc"); + list.add(strArray); + strArray2[i] = strArray; + } + String[][] data = strArray2; + + //添加表格 + Table table = section.addTable(true); + table.resetCells(data.length + 1, header.length); + + TableRow row = table.getRows().get(0); + row.isHeader(true); + row.setHeight(20); + row.setHeightType(TableRowHeightType.Exactly); + for (int i = 0; i < header.length; i++) { + row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + Paragraph p = row.getCells().get(i).addParagraph(); + p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center); + TextRange txtRange = p.appendText(header[i]); + txtRange.getCharacterFormat().setBold(true); + } + + //将数据添加到其余行 + for (int r = 0; r < data.length; r++) { + TableRow dataRow = table.getRows().get(r + 1); + dataRow.setHeight(25); + dataRow.setHeightType(TableRowHeightType.Exactly); + dataRow.getRowFormat().setBackColor(Color.white); + for (int c = 0; c < data[r].length; c++) { + dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); + } + } + + + } + + + //添加段落 + Paragraph paragraph2 = section.addParagraph(); + + ParagraphFormat paragraphFormat2 = paragraph2.getFormat(); + paragraphFormat2.setHorizontalAlignment(HorizontalAlignment.Left); + + TextRange tr2 = paragraph2.appendText("3.组织/角色与职责"); + + + tr2.getCharacterFormat().setBold(true); + tr2.getCharacterFormat().setFontName("宋体"); + tr2.getCharacterFormat().setFontSize(12); + paragraph2.applyStyle(BuiltinStyle.Heading_1); //应用标题1样式 + + + JSONArray organizationTable = new JSONArray(); //组织职责Table + // 属性特征 属性代码KEY + PALRepositoryPropertyModel Organizational = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(), "Organizational_role"); + String OrganizationalVal = Organizational.getPropertyValue(); + JSONObject OrganizationalObj = JSONObject.parseObject(OrganizationalVal); + if (OrganizationalObj != null && !OrganizationalObj.isEmpty()) { + JSONArray tableArr = OrganizationalObj.getJSONArray("table"); + if (tableArr != null && !tableArr.isEmpty()) { + for (Object obj : tableArr) { + JSONObject obj2 = (JSONObject) obj; + if (!"table_head".equals(obj2.getString("id"))) { + String name = obj2.getString("name"); + String desc = obj2.getString("desc"); + JSONObject tmp = new JSONObject(); + tmp.put("name", name); + tmp.put("desc", desc); + organizationTable.add(tmp); + } + } + } + } + + + //定义表格数据 + String[] orgheader = {"组织", "职责"}; + if (organizationTable != null && !organizationTable.isEmpty()) { + + String[][] strArray2 = new String[organizationTable.size()][]; + + List list = new LinkedList<>(); + for (int i = 0; i < organizationTable.size(); i++) { + JSONObject obj2 = (JSONObject) organizationTable.get(i); + String[] strArray = new String[2]; + strArray[0] = obj2.getString("name"); + strArray[1] = obj2.getString("desc"); + list.add(strArray); + strArray2[i] = strArray; + + } + String[][] data = strArray2; + + //添加表格 + Table table = section.addTable(true); + table.resetCells(data.length + 1, header.length); + + TableRow row = table.getRows().get(0); + row.isHeader(true); + row.setHeight(20); + row.setHeightType(TableRowHeightType.Exactly); + for (int i = 0; i < header.length; i++) { + row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + Paragraph p = row.getCells().get(i).addParagraph(); + p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center); + TextRange txtRange = p.appendText(header[i]); + txtRange.getCharacterFormat().setBold(true); + } + + //将数据添加到其余行 + for (int r = 0; r < data.length; r++) { + TableRow dataRow = table.getRows().get(r + 1); + dataRow.setHeight(25); + dataRow.setHeightType(TableRowHeightType.Exactly); + dataRow.getRowFormat().setBackColor(Color.white); + for (int c = 0; c < data[r].length; c++) { + dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); + } + } + + + } + + + //添加段落 + Paragraph paragraph3 = section.addParagraph(); + + ParagraphFormat paragraphFormat3 = paragraph3.getFormat(); + paragraphFormat3.setHorizontalAlignment(HorizontalAlignment.Left); + + TextRange tr3 = paragraph3.appendText("4.内容"); + + + tr3.getCharacterFormat().setBold(true); + tr3.getCharacterFormat().setFontName("宋体"); + tr3.getCharacterFormat().setFontSize(12); + paragraph3.applyStyle(BuiltinStyle.Heading_1); //应用标题1样式 + + + if (suffix.equals("xml")) { + //保存为xml格式 + String substring = fileName.substring(0, fileName.lastIndexOf(".xml")); + //保存为Word + document.insertTextFromFile(docPath + substring + ".docx", FileFormat.Docx_2013); + } else { + document.insertTextFromFile(path + fileName, FileFormat.Docx_2013); + } + + // document.insertTextFromFile("/Users/sunlh/Downloads/手册格式问题测试文档(3)new.docx", FileFormat.Docx_2013); + //保存结果文档 + document.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + + + } + } + long b2 = System.currentTimeMillis(); + + System.err.println("复制附件用时:" + + (b2 - b1) / 1000 + "秒"); + } + + + //创建 Document 类的对象并从磁盘加载 Word 文档 + com.sini.com.spire.doc.Document document = new com.sini.com.spire.doc.Document(outFile.getPath()); + // 删除第一页 + /*Section section1 = document.getSections().get(0); + document.getSections().remove(section1);*/ + + Section section = document.getLastSection(); + + + //添加段落 + Paragraph paragraph3 = section.addParagraph(); + + ParagraphFormat paragraphFormat3 = paragraph3.getFormat(); + paragraphFormat3.setHorizontalAlignment(HorizontalAlignment.Left); + + TextRange tr3 = paragraph3.appendText("5.附则"); + + + tr3.getCharacterFormat().setBold(true); + tr3.getCharacterFormat().setFontName("宋体"); + tr3.getCharacterFormat().setFontSize(12); + paragraph3.applyStyle(BuiltinStyle.Heading_1); //应用标题1样式 + + + CharacterFormat format = new CharacterFormat(document); + format.setFontName("黑体"); + format.setFontSize(12); + + + //添加段落 + Paragraph articlesparagraph = section.addParagraph(); + articlesparagraph.appendText(dataMap.getString("pl_T_supplementary_articles")).applyCharacterFormat(format); + + + document.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + + + //加载文档1 + com.sini.com.spire.doc.Document doc1 = new com.sini.com.spire.doc.Document(); + doc1.loadFromFile(tempPath + "制度-手册5.doc"); + + + //获取section + Section section1 = doc1.getSections().get(0); + + //获取文档1的页眉页脚 + HeaderFooter headerword = section1.getHeadersFooters().getHeader(); + HeaderFooter footerword = section1.getHeadersFooters().getFooter(); + + //加载文档2 + com.sini.com.spire.doc.Document doc2 = new com.sini.com.spire.doc.Document(); + + + doc2.loadFromFile(outFile.getPath()); + + + SectionCollection sections = doc2.getSections(); + + + // 获取源文档的页眉页脚 + Section sourceSection = doc1.getSections().get(0); + HeaderFooter sourceHeader = sourceSection.getHeadersFooters().getHeader(); + HeaderFooter sourceFooter = sourceSection.getHeadersFooters().getFooter(); + + // 将页眉复制到目标文档的第三节以及后续节 + for (int i = 0; i < doc2.getSections().getCount(); i++) { + Section targetSection = doc2.getSections().get(i); + HeaderFooter targetHeader = targetSection.getHeadersFooters().getHeader(); + targetHeader.getChildObjects().clear(); + for (int j = 0; j < sourceHeader.getChildObjects().getCount(); j++) { + DocumentObject obj = sourceHeader.getChildObjects().get(j).deepClone(); + targetHeader.getChildObjects().add(obj); + } + } + + // 将页脚复制到目标文档的第三节以及后续节 + for (int i = 0; i < doc2.getSections().getCount(); i++) { + Section targetSection = doc2.getSections().get(i); + HeaderFooter targetFooter = targetSection.getHeadersFooters().getFooter(); + targetFooter.getChildObjects().clear(); + for (int j = 0; j < sourceFooter.getChildObjects().getCount(); j++) { + DocumentObject obj = sourceFooter.getChildObjects().get(j).deepClone(); + targetFooter.getChildObjects().add(obj); + } + } + + doc2.saveToFile(outFile.getPath(), FileFormat.Docx_2013); + + + return outFile.getPath(); + } + /** * 获取条款内容xml * @@ -205,7 +875,7 @@ public class InstitutionalTextWeb extends ActionWeb { * @param controlShapeId * @return */ - private Map getContentData(String repositoryId, String controlShapeId) { + /*private Map getContentData(String repositoryId, String controlShapeId) throws Exception { Map result = new HashMap<>(); result.put("listDef", ""); result.put("content", ""); @@ -232,15 +902,15 @@ public class InstitutionalTextWeb extends ActionWeb { if (upfileModel.getFileName().contains(".xml")) { if (dcProfile != null) { dcContextpdf = new DCContext(_uc, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), upfileModel.getFileName()); - /* - * String path = dcContextpdf.getPath(); String fileName = - * dcContextpdf.getFileName(); com.spire.doc.Document docs = new - * com.spire.doc.Document(); docs.loadFromFile("/"+path+fileName); String - * substring = fileName.substring(0, fileName.lastIndexOf(".xml")); - * docs.saveToFile("/"+path+substring+".xml",FileFormat.Word_ML); dcContextpdf = - * new DCContext(userContext, dcProfile, CoEConstant.APP_ID, - * upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), substring+".xml"); - */ + *//* + * String path = dcContextpdf.getPath(); String fileName = + * dcContextpdf.getFileName(); com.spire.doc.Document docs = new + * com.spire.doc.Document(); docs.loadFromFile("/"+path+fileName); String + * substring = fileName.substring(0, fileName.lastIndexOf(".xml")); + * docs.saveToFile("/"+path+substring+".xml",FileFormat.Word_ML); dcContextpdf = + * new DCContext(userContext, dcProfile, CoEConstant.APP_ID, + * upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), substring+".xml"); + *//* break; } } @@ -251,11 +921,16 @@ public class InstitutionalTextWeb extends ActionWeb { String fileName = dcContextpdf.getFileName(); //创建实例,加载doc测试文档 String s = path + fileName; - com.spire.doc.Document docs = new com.spire.doc.Document(); + + + com.sini.com.spire.doc.Document docs = new com.sini.com.spire.doc.Document(); + + docs.loadFromFile(path + fileName); //保存为xml格式 String substring = fileName.substring(0, fileName.lastIndexOf(".doc")); - docs.saveToFile(path + substring + ".xml", FileFormat.Word_ML); + docs.saveToFile(path + substring + ".xml", FileFormat.Word_Xml); + dcContextpdf = new DCContext(_uc, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), substring + ".xml"); break; } @@ -297,22 +972,6 @@ public class InstitutionalTextWeb extends ActionWeb { } } -// if (listStr.length() > 0) { -// System.out.println(listStr); -// } -// Element body = root.element("body"); -// if (body != null) { -// // System.out.println(body.getName()); -// //System.out.println(body.asXML()); -// List childList = body.elements(); -// if (childList != null) { -// for (Element e : childList) { -// //System.out.println(e.getName()); -// // str += e.asXML(); -// } -// } -// -// } // 获取字符串 content = getFileContent(file); @@ -363,8 +1022,7 @@ public class InstitutionalTextWeb extends ActionWeb { result.put("listDef", listStr2); result.put("content", content); return result; - } - + }*/ public static String getFileContent(File file) { StringBuilder builder = new StringBuilder(); @@ -423,7 +1081,8 @@ public class InstitutionalTextWeb extends ActionWeb { * @param wizardJsonData * @return */ - private JSONObject getData2(String repositoryId, JSONObject wizardJsonData, String docPath, String fileName) { + private JSONObject getData2(String repositoryId, JSONObject wizardJsonData, String docPath, String + fileName) throws Exception { JSONObject dataMap = new JSONObject(); dataMap.put("organizationType", "涉及部门及岗位\\角色"); boolean raciRelationType = SDK.getAppAPI().getPropertyBooleanValue("com.awspaas.user.apps.coe.pal.output.zd", "DETY_POSITION_ROLE_RELATION_TYPE", false); @@ -455,407 +1114,13 @@ public class InstitutionalTextWeb extends ActionWeb { OutputWordUtil.orderByNumber(repositoryFileElements); } - // 流程附件列表 - String shpId = ""; - UpFileDao upFileDao = new UpFileDao(); - StringBuffer sqlWhere = new StringBuffer(); - sqlWhere.append(" and PALREPOSITORYID ='").append(repositoryModel.getId()).append("'").append(" ORDER BY FILENAME ASC"); - List search = upFileDao.search(sqlWhere.toString()); - File file = null; - //三员管理下,用户密级与文件密级过滤显示 - if (HighSecurityUtil.isON()) { - PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc, search); - } - if (search != null && search.size() > 0) { - //创建附件目录及复制附件 - fileName = fileName + "_file"; - file = new File(docPath, fileName); - if (!file.exists()) { - log.info("创建附件"); - file.mkdir(); - } - } - - //文件属性附件 - int fileIndex = 1; - ArrayList isNumberAscArray = new ArrayList(); - if (search != null && search.size() > 0) { - // 复制附件 - for (UpfileModel upfileModel : search) { - if (!"f".equals(upfileModel.getType())) { - continue; - } - // 复制doccenter下的文件 - DCContext dcContext = null; - DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); - if (dcProfile != null) { - dcContext = new DCContext(_uc, dcProfile, CoEConstant.APP_ID, "file", upfileModel.getPl_uuid(), upfileModel.getFileName()); - } - File sourceFile = new UtilFile(dcContext.getFilePath()); - File targetFile = new UtilFile(file.toString() + File.separator + dcContext.getFileName()); - try { - UtilFile.copyFile(sourceFile, targetFile); - } catch (Exception e) { - System.out.println(e); - e.printStackTrace(); - } - JSONObject object = new JSONObject(); - //按照附件编号排序 - /* String fileNamel = upfileModel.getFileName(); - if (UtilString.isNotEmpty(fileNamel) && fileNamel.contains("附件") && fileNamel.length() > 2 && (fileNamel.contains(":") || fileNamel.contains(":"))) { - if (fileNamel.indexOf("附件") == 0) { - int indexOf2 = 3; - if (fileNamel.contains(":")) { - indexOf2 = fileNamel.indexOf(":"); - } else if (fileNamel.contains(":")) { - indexOf2 = fileNamel.indexOf(":"); - } - String numberStr = fileNamel.substring(2, indexOf2); - if (isNumeric(numberStr) && !"".equals(numberStr)) { - isNumberAscArray.add("true"); - int fileNumber = Integer.parseInt(numberStr); - object.put("file_number", fileNumber); - } else { - isNumberAscArray.add("false"); - } - } else { - isNumberAscArray.add("false"); - } - - } else { - - }*/ - isNumberAscArray.add("false"); - object.put("file_name", upfileModel.getFileName()); - String link = fileName + File.separator + upfileModel.getFileName(); - object.put("link", link); - fileTable.add(object); - fileIndex++; - } - } - - - String controlShapeId = ""; - if (repositoryFileElements != null) { - int index = 1;// 流程步骤序号 - int dangerIndex = 1;// 风险序号 - int regulateIndex = 1;// 控制序号 - for (Map shape : repositoryFileElements) { - String type = shape.get("type").toString(); - if ("regulation".equals(type)) { - controlShapeId = shape.get("id").toString(); - } else if ("I/O_L4".equals(type)) { - controlShapeId = shape.get("id").toString(); - } - //如果图形元素不是流程步骤,不导出该元素 -// if (PrReportComment.PROCESS_STEP.indexOf((String)shape.get("type")) == -1) { -// continue; -// } - JSONObject _tr = new JSONObject(); - OutputWordUtil.setShapeDefaultValue2(repositoryId, _tr); //设置默认值 - _tr.put(OutputWordUtil.SERIAL_NUMBER, index); //序号 - _tr.put(OutputWordUtil.REPOSITORY_NAME, specialCharTransfer(repositoryModel.getName().replace("\n", ""))); //流程名称 - _tr.put(OutputWordUtil.SHAPE_NAME, specialCharTransfer(shape.get("text").toString()).replace("\n", WRAPSTRING)); //步骤名称 - - /**序号改为流程编号**/ - /*_tr.put(OutputWordUtil.SERIAL_NUMBER, ""); //序号置空 - if (shape.containsKey("number")) { - _tr.put(OutputWordUtil.SERIAL_NUMBER, shape.get("number")); - }*/ - /**序号改为流程编号**/ - - // 节点的附件处理 - JSONArray shapeFileTable = new JSONArray(); //流程节点附件Table - if (search != null && search.size() > 0) { - // 复制附件 - for (UpfileModel upfileModel : search) { - /* - * if ("f".equals(upfileModel.getType())) { continue; } if - * (!shape.get("id").equals(upfileModel.getShape_uuid())) { continue; } - */ - - - // 复制doccenter下的文件 -// DCContext dcContext = null; -// DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); -// if (dcProfile != null) { -// dcContext = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), upfileModel.getFileName()); -// } -// File sourceFile = new UtilFile(dcContext.getFilePath()); -// File targetFile = new UtilFile(file.toString() + File.separator + dcContext.getFileName()); -// try { -// UtilFile.copyFile(sourceFile, targetFile); -// } catch (Exception e) { -// System.out.println(e); -// e.printStackTrace(); -// } - /* - * JSONObject object = new JSONObject(); object.put("file_name", - * upfileModel.getFileName()); String link = fileName + File.separator + - * upfileModel.getFileName(); object.put("link", link); fileTable.add(object); - */ - } - } - fileTable.sort(Comparator.comparing(obj -> ((JSONObject) obj).getString("file_name"))); - if (shapeFileTable.size() == 0) {// 没有附件时给空值,不然使用office打开会解析错误 - JSONObject object = new JSONObject(); - object.put("shape_file_name", ""); - object.put("shape_file_link", ""); - shapeFileTable.add(object); - } - _tr.put("shape_File_Table", shapeFileTable); - - JSONArray dataAttributes = (JSONArray) shape.get("attributes"); - if (!dataAttributes.isEmpty()) { - for (int i = 0; i < dataAttributes.size(); i++) { - JSONObject obj = dataAttributes.getJSONObject(i); - String attrId = obj.getString("key"); - String attrValue = obj.getString("value"); - _tr.put("shape_" + attrId, attrValue.replace("\n", WRAPSTRING)); - if (raciRelationType) {// 涉及部门、岗位/角色关联的是bpm组织部门、岗位、角色 - if ("bpm_duty_r".equals(attrId)) { - _tr.put("shape_duty_r", attrValue.replace("\n", WRAPSTRING)); - } - if ("bpm_approval_a".equals(attrId)) { - _tr.put("shape_approval_a", attrValue.replace("\n", WRAPSTRING)); - } - if ("bpm_counselor_c".equals(attrId)) { - _tr.put("shape_counselor_c", attrValue.replace("\n", WRAPSTRING)); - } - if ("bpm_notify_i".equals(attrId)) { - _tr.put("shape_notify_i", attrValue.replace("\n", WRAPSTRING)); - } - } - if ("danger".equals(attrId)) { - dangerIndex = setTableValueOfControlAndRisk(attrId, repositoryId, shape.get("id").toString(), dangerTable, dangerIndex, _tr.getString(OutputWordUtil.SHAPE_NAME), relationFileMap); - dangerSet.clear(); - } else if ("regulate".equals(attrId)) { - regulateIndex = setTableValueOfControlAndRisk(attrId, repositoryId, shape.get("id").toString(), regulateTable, regulateIndex, _tr.getString(OutputWordUtil.SHAPE_NAME), relationFileMap); - regulateSet.clear(); - } - } - } - repositoryShapeTable.add(_tr); - index++; - } - } - - // 条款内容xml - Map contentMap = getContentData(repositoryId, controlShapeId); - String listDef = contentMap.get("listDef"); - String contentXml = contentMap.get("content"); - // 流程步骤的指标表格 - setTableValueOfKPI("kpi", repositoryId, KPITable, relationFileMap); - if (search != null && search.size() > 0) { - // 复制附件 - int index = 1; - for (UpfileModel upfileModel : search) { - if (!"f".equals(upfileModel.getType())) {// 文件 - continue; - } - // 复制doccenter下的文件 - /* - * DCContext dcContext = null; DCPluginProfile dcProfile = - * DCProfileManager.getDCProfile(CoEConstant.APP_ID, - * CoeFileConstant.COE_UPFILE); if (dcProfile != null) { dcContext = new - * DCContext(userContext, dcProfile, CoEConstant.APP_ID, "file", - * upfileModel.getPl_uuid(), upfileModel.getFileName()); } File sourceFile = new - * UtilFile(dcContext.getFilePath()); File targetFile = new - * UtilFile(file.toString() + File.separator + dcContext.getFileName()); try { - * UtilFile.copyFile(sourceFile, targetFile); } catch (Exception e) { - * System.out.println(e); e.printStackTrace(); } JSONObject object = new - * JSONObject(); object.put("file_name", index + "." + - * upfileModel.getFileName()); String link = fileName + File.separator + - * upfileModel.getFileName(); object.put("link", link); - * System.err.println("==1==>"+object); fileTable.add(object); - * System.err.println("==2==>"+fileTable); index++; - */ - } - } - JSONArray termTable = new JSONArray(); //术语定义Table - // 属性特征 属性代码KEY - try { - PALRepositoryPropertyModel term = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(), "term"); - String termVal = term.getPropertyValue(); - JSONObject termObj = JSONObject.parseObject(termVal); - if (termObj != null && !termObj.isEmpty()) { - JSONArray tableArr = termObj.getJSONArray("table"); - if (tableArr != null && !tableArr.isEmpty()) { - for (Object obj : tableArr) { - JSONObject obj2 = (JSONObject) obj; - if (!"table_head".equals(obj2.getString("id"))) { - String name = obj2.getString("name"); - String desc = obj2.getString("desc"); - JSONObject tmp = new JSONObject(); - tmp.put("name", specialCharTransfer(name).replace("\n", WRAPSTRING)); - tmp.put("desc", specialCharTransfer(desc).replace("\n", WRAPSTRING)); - termTable.add(tmp); - } - } - } - } - } catch (Exception e) { - // TODO: handle exception - } - - JSONArray organizationTable = new JSONArray(); //组织职责Table - // 属性特征 属性代码KEY - try { - PALRepositoryPropertyModel Organizational = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(), "Organizational_role"); - String OrganizationalVal = Organizational.getPropertyValue(); - JSONObject OrganizationalObj = JSONObject.parseObject(OrganizationalVal); - if (OrganizationalObj != null && !OrganizationalObj.isEmpty()) { - JSONArray tableArr = OrganizationalObj.getJSONArray("table"); - if (tableArr != null && !tableArr.isEmpty()) { - for (Object obj : tableArr) { - JSONObject obj2 = (JSONObject) obj; - if (!"table_head".equals(obj2.getString("id"))) { - String name = obj2.getString("name"); - String desc = obj2.getString("desc"); - JSONObject tmp = new JSONObject(); - tmp.put("name", specialCharTransfer(name).replace("\n", WRAPSTRING)); - tmp.put("desc", specialCharTransfer(desc).replace("\n", WRAPSTRING)); - organizationTable.add(tmp); - } - } - } - } - } catch (Exception e) { - // TODO: handle exception - } - - - //支持文件 - JSONArray support_files = new JSONArray(); - try { - int count = 0; - String sql = "select PROPERTYVALUE from APP_ACT_COE_PAL_PROP where PLID = '" + repositoryModel.getId() + "' and PROPERTYID = 'support_files'"; - String relatFileJson = DBSql.getString(sql); - if (UtilString.isNotEmpty(relatFileJson)) { - JSONObject parseObject = JSONObject.parseObject(relatFileJson); - String fileNames = parseObject.getString("relationShapeText"); - if (UtilString.isNotEmpty(fileNames)) { - String[] names = fileNames.split(","); - for (String name : names) { - count++; - JSONObject tmp = new JSONObject(); - tmp.put("name", name); - tmp.put("desc", count); - support_files.add(tmp); - } - } - - } - } catch (Exception e) { - // TODO: handle exception - } - - /* - * JSONArray support_files = new JSONArray(); //组织职责Table - * List relationList = - * DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", - * "support_files"); - * - * relationList.sort(Comparator.comparing(DesignerShapeRelationModel:: - * getShapeText)); - * - * int index = 0; for (DesignerShapeRelationModel relation : relationList) { - * String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID - * PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId); - * if (model != null) { index++; String name = model.getName(); JSONObject tmp = - * new JSONObject(); tmp.put("name", name); tmp.put("desc", index); - * support_files.add(tmp); } } - */ - - //相关文件 related_files - JSONArray related_files = new JSONArray(); - try { - int count = 0; - String sql = "select PROPERTYVALUE from APP_ACT_COE_PAL_PROP where PLID = '" + repositoryModel.getId() + "' and PROPERTYID = 'related_files'"; - String relatFileJson = DBSql.getString(sql); - if (UtilString.isNotEmpty(relatFileJson)) { - JSONObject parseObject = JSONObject.parseObject(relatFileJson); - String fileNames = parseObject.getString("relationShapeText"); - if (UtilString.isNotEmpty(fileNames)) { - String[] names = fileNames.split(","); - for (String name : names) { - count++; - JSONObject tmp = new JSONObject(); - tmp.put("name", name); - tmp.put("desc", count); - related_files.add(tmp); - } - } - - } - - //外部相关文件 - String sqlOut = "select PROPERTYVALUE from APP_ACT_COE_PAL_PROP where PLID = '" + repositoryModel.getId() + "' and PROPERTYID = 'Out_related_files'"; - String outRelatFileJson = DBSql.getString(sqlOut); - if (UtilString.isNotEmpty(outRelatFileJson)) { - if (outRelatFileJson.contains(",")) { - String[] split = outRelatFileJson.split(","); - for (String str : split) { - count++; - JSONObject tmp = new JSONObject(); - tmp.put("name", str + "【外部】"); - tmp.put("desc", count); - related_files.add(tmp); - } - } else if (outRelatFileJson.contains(",")) { - String[] split = outRelatFileJson.split(","); - for (String str : split) { - count++; - JSONObject tmp = new JSONObject(); - tmp.put("name", str + "【外部】"); - tmp.put("desc", count); - related_files.add(tmp); - } - } else { - count++; - JSONObject tmp = new JSONObject(); - tmp.put("name", outRelatFileJson + "【外部】"); - tmp.put("desc", count); - related_files.add(tmp); - } - } - } catch (Exception e) { - // TODO: handle exception - } - - - /* - * JSONArray related_files = new JSONArray(); //组织职责Table - * List relationList2 = - * DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", - * "related_files"); - * relationList2.sort(Comparator.comparing(DesignerShapeRelationModel:: - * getShapeText)); int count = 0; for (DesignerShapeRelationModel relation : - * relationList2) { String relationFileId = relation.getRelationFileId();// - * 支持或相关文件的ID //System.err.println("生成手册时相关文件id=======>"+relationFileId); - * PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId); - * if (model != null) { count++; String name = model.getName(); JSONObject tmp = - * new JSONObject(); tmp.put("name", name); tmp.put("desc", count); - * related_files.add(tmp); } } - */ - - //术语 - dataMap.put("term_table", termTable);//table4 - //如果termTable.size()==0 则显示无 - dataMap.put("term_table_count", termTable.size());//table4 //组织和职责 - dataMap.put("organization_table", organizationTable);//table5 - dataMap.put("organization_table_count", organizationTable.size());//table5 - //支持文件 - dataMap.put("supports_table", support_files);//table6 - dataMap.put("supports_table_count", support_files.size());//table6 - //相关文件 - dataMap.put("relevant_table", related_files);//table7 - dataMap.put("relevant_table_count", related_files.size());//table7 + /*dataMap.put("organization_table", organizationTable);//table5 + dataMap.put("organization_table_count", organizationTable.size());//table5*/ - dataMap.put(OutputWordUtil.TABLE_REPOSITORY_SHAPE, repositoryShapeTable); + /* dataMap.put(OutputWordUtil.TABLE_REPOSITORY_SHAPE, repositoryShapeTable); boolean contains = isNumberAscArray.contains("false"); if (contains) { fileTable.sort(Comparator.comparing(obj -> ((JSONObject) obj).getString("file_name"))); @@ -865,7 +1130,7 @@ public class InstitutionalTextWeb extends ActionWeb { } catch (Exception e) { throw new AWSQuotaException("附件格式请以:《附件1:XXXXXX》格式命名"); } - } + }*/ dataMap.put("file_table", fileTable); dataMap.put("file_table_count", fileTable.size()); //dataMap.put("file_table_count", 0);// 暂时置空 @@ -876,34 +1141,7 @@ public class InstitutionalTextWeb extends ActionWeb { JSONArray historyVersionModify = compare.getModifyVersionHistory(repositoryId); dataMap.put("history_table", historyVersionModify); - // 修订记录 - dataMap.put("version_history_table", getVersionHistoryTable(repositoryModel)); - // 附则处理 - List T_supplementary_articles_table = new ArrayList<>(); - String[] tmp = dataMap.getString("pl_T_supplementary_articles").split("\n"); - for (int i = 0; i < tmp.length; i++) { - if (UtilString.isNotEmpty(tmp[i])) { - T_supplementary_articles_table.add(tmp[i]); - } - } - dataMap.put("T_supplementary_articles_table", T_supplementary_articles_table);// 换行 - dataMap.put("T_supplementary_articles_count", T_supplementary_articles_table.size()); - // 目的处理 - List Purpose_table = new ArrayList<>(); - String[] tmp2 = dataMap.getString("pl_Purpose").split("\n"); - for (int i = 0; i < tmp2.length; i++) { - if (UtilString.isNotEmpty(tmp2[i])) { - Purpose_table.add(tmp2[i]); - } - } - dataMap.put("Purpose_count", Purpose_table.size()); - dataMap.put("Purpose_table", Purpose_table); - - // 条款word xml内容处理 - dataMap.put("control_content_count", contentXml.length()); - dataMap.put("control_content", contentXml); - dataMap.put("listDef", listDef);// 列表编号 return dataMap; } @@ -916,210 +1154,5 @@ public class InstitutionalTextWeb extends ActionWeb { return true; } - /** - * 修订记录 - * - * @param repositoryModel - * @return - */ - private JSONArray getVersionHistoryTable(PALRepositoryModel repositoryModel) { - JSONArray versionHistoryTable = new JSONArray();// 修订记录 - List list = PALRepositoryCache.getByVersionId(repositoryModel.getVersionId()); - list.sort((m1, m2) -> { - return m1.getVersion() - m2.getVersion() > 0 ? 1 : -1; - }); - for (PALRepositoryModel model : list) { - if (model.getVersion() > repositoryModel.getVersion()) { - continue; - } - JSONObject obj = new JSONObject(); - Map map = PALRepositoryQueryAPIManager.queryRepositoryAttributeById(model.getId()); - // 版本P_versions,制度用的是versions - String attr = "versions"; - String val = ""; - String plvers = model.getVersion() + ""; - String plver = ""; - if (!"".equals(plvers)) { - if (plvers.length() > 1) { - plver = plvers.substring(0, 1) + "." - + plvers.substring(plvers.length() - 1, plvers.length()); - } else { - plver = plvers.substring(0, 1) + ".0"; - } - } - //val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING); - obj.put(attr, "V" + plver); - // 拟制/修订单位Issuing_department - attr = "Issuing_department"; - val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING); - obj.put(attr, val); - // 拟制/修订人Drafted_and_revised_by - attr = "Drafted_and_revised_by"; - val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING); - obj.put(attr, val); - // 拟制/修订日期Drafted_and_revised_date - attr = "Drafted_and_revised_date"; - val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING); - if (UtilString.isNotEmpty(val)) { - try { - Timestamp timestamp = UtilDate.parseTsFromDateTime(val); - val = UtilDate.yearFormat(timestamp) + "年" + Integer.parseInt(UtilDate.monthFormat(timestamp)) + "月" + UtilDate.dayFormat(timestamp) + "日"; - } catch (Exception e) { - //e.printStackTrace(); - } - } - obj.put(attr, val); - // 审核人auditor - attr = "auditor"; - val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING); - obj.put(attr, val); - // 复核人reviewer - attr = "reviewer"; - val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING); - obj.put(attr, val); - // 审批人approver - attr = "approver"; - val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING); - obj.put(attr, val); - // 修订内容及理由Contents_and_reasons_for_revision - attr = "Contents_and_reasons_for_revision"; - val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING); - obj.put(attr, val); - - versionHistoryTable.add(obj); - } - return versionHistoryTable; - } - - - /** - * 设置风险控制表格 - * - * @param attrId - * @param fileId - * @param shapeId - * @param table - * @param index - * @param relationFileMap - * @return - */ - public int setTableValueOfControlAndRisk(String attrId, String fileId, String shapeId, JSONArray table, int index, String processShapeName, Map> relationFileMap) { - JSONArray result = new JSONArray(); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List list = dao.query(fileId, shapeId, attrId, null, null); - for (DesignerShapeRelationModel model : list) { - String relationFileId = model.getRelationFileId(); - if (!relationFileMap.containsKey(relationFileId) && PALRepositoryCache.getCache().get(relationFileId) != null) { - Map shapes = new HashMap<>(); - List> fileElements = CoeDesignerUtil.getShapeMessageJson4(relationFileId); - for (Map shape : fileElements) { - String tempShapeId = shape.get("id").toString(); - shapes.put(tempShapeId, shape); - } - relationFileMap.put(relationFileId, shapes); - } - } - - Set relationShapeIdSet = new HashSet<>(); // 去重 - String filterShapeName = ""; - if ("danger".equals(attrId)) {// 风险 - filterShapeName = "risk"; - } else if ("regulate".equals(attrId)) {// 控制 - filterShapeName = "control"; - } - for (DesignerShapeRelationModel model : list) { - String relationFileId = model.getRelationFileId(); - String relationShapeId = model.getRelationShapeId(); - if (relationFileMap.containsKey(relationFileId)) { - Map elements = relationFileMap.get(relationFileId); - if (elements != null && elements.containsKey(relationShapeId)) { - Map shape = (Map) elements.get(relationShapeId); - if (!relationShapeIdSet.contains(shape.get("id").toString()) && filterShapeName.equals(shape.get("type"))) { - relationShapeIdSet.add(shape.get("id").toString()); - result.add(shape); - } - } - } - } - - for (int i = 0; i < result.size(); i++) { - Map shape = result.getJSONObject(i); - JSONObject _tr = new JSONObject(); - OutputWordUtil.setShapeDefaultValue2(shape.get("uuid").toString(), _tr); //设置默认值 - String name = specialCharTransfer(shape.get("text").toString()); - _tr.put("related_" + OutputWordUtil.SHAPE_NAME, processShapeName); - _tr.put(OutputWordUtil.SHAPE_NAME, name.replace("\n", WRAPSTRING)); - _tr.put(OutputWordUtil.SERIAL_NUMBER, index); - JSONArray dataAttributes = (JSONArray) shape.get("attributes"); - for (int j = 0; j < dataAttributes.size(); j++) { - _tr.put("shape_" + dataAttributes.getJSONObject(j).getString("key"), specialCharTransfer(dataAttributes.getJSONObject(j).getString("value")).replace("\n", " ")); - } - table.add(_tr); - index++; - } - return index; - - } - - /** - * 设置流程步骤的KPI表格 - * - * @param attrId - * @param fileId - * @param table - * @param relationFileMap - * @return - */ - public int setTableValueOfKPI(String attrId, String fileId, JSONArray table, Map> relationFileMap) { - int index = 1; - JSONArray result = new JSONArray(); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List list = dao.query(fileId, null, attrId, null, null); - for (DesignerShapeRelationModel model : list) { - String relationFileId = model.getRelationFileId(); - if (!relationFileMap.containsKey(relationFileId) && !UtilString.isEmpty(model.getShapeId())) { - Map shapes = new HashMap<>(); - List> fileElements = CoeDesignerUtil.getShapeMessageJson4(relationFileId); - for (Map shape : fileElements) { - String tempShapeId = shape.get("id").toString(); - shapes.put(tempShapeId, shape); - } - relationFileMap.put(relationFileId, shapes); - } - } - - Set relationShapeIdSet = new HashSet<>(); // 去重 - for (DesignerShapeRelationModel model : list) { - String relationFileId = model.getRelationFileId(); - String relationShapeId = model.getRelationShapeId(); - if (relationFileMap.containsKey(relationFileId)) { - Map elements = relationFileMap.get(relationFileId); - if (elements != null && elements.containsKey(relationShapeId)) { - Map shape = (Map) elements.get(relationShapeId); - if (!relationShapeIdSet.contains(shape.get("id").toString())) { - relationShapeIdSet.add(shape.get("id").toString()); - result.add(shape); - } - } - } - } - - for (int i = 0; i < result.size(); i++) { - Map shape = result.getJSONObject(i); - JSONObject _tr = new JSONObject(); - OutputWordUtil.setShapeDefaultValue2(shape.get("uuid").toString(), _tr); //设置默认值 - String name = specialCharTransfer(shape.get("text").toString()); - _tr.put(OutputWordUtil.SHAPE_NAME, name.replace("\n", WRAPSTRING)); - _tr.put(OutputWordUtil.SERIAL_NUMBER, index); - JSONArray dataAttributes = (JSONArray) shape.get("attributes"); - for (int j = 0; j < dataAttributes.size(); j++) { - _tr.put("shape_" + dataAttributes.getJSONObject(j).getString("key"), specialCharTransfer(dataAttributes.getJSONObject(j).getString("value")).replace("\n", " ")); - } - table.add(_tr); - index++; - } - return index; - - } } diff --git a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/ReportPrController.java b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/ReportPrController.java index 5087b3bc..c54ed163 100644 --- a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/ReportPrController.java +++ b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/ReportPrController.java @@ -175,16 +175,31 @@ public class ReportPrController { * @return */ @Mapping("com.awspaas.user.apps.coe.pal.output.zd_systemManualTextExport") - public String systemManualTextExport(UserContext me, String id, String teamId, String wsid) { + public String systemManualTextExport(UserContext me) { ResponseObject ro = null; - try { - ro = ResponseObject.newOkResponse(); - InstitutionalTextWeb institutionalTextWeb = new InstitutionalTextWeb(me); - institutionalTextWeb.systemManualTextExport(); - } catch (Exception e) { - ro = ResponseObject.newErrResponse(); - e.printStackTrace(); - } + ro = ResponseObject.newOkResponse(); + InstitutionalTextWeb institutionalTextWeb = new InstitutionalTextWeb(me); + String result = institutionalTextWeb.systemManualTextExport(); + + ro.put("result", result); + return ro.toString(); + } + + /** + * 制度手册正文导出 + * + * @param me + * @param teamId + * @param wsid + * @return + */ + @Mapping("com.awspaas.user.apps.coe.pal.output.zd_systemManualTextExportoOnce") + public String systemManualTextExportoOnce(UserContext me, String targetFileId) { + ResponseObject ro = null; + ro = ResponseObject.newOkResponse(); + InstitutionalTextWeb institutionalTextWeb = new InstitutionalTextWeb(me); + String result = institutionalTextWeb.systemManualTextExportoOnce(targetFileId); + ro.put("result", result); return ro.toString(); } diff --git a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/report1/Report1Gener.java b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/report1/Report1Gener.java index fa3b7e42..65d44a7d 100644 --- a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/report1/Report1Gener.java +++ b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/report1/Report1Gener.java @@ -165,7 +165,7 @@ public class Report1Gener { } JSONObject dataMap = getData2(repositoryId, wizardJsonData, docPath, fileName); if (dataMap != null) { - OutputWordUtil.createDoc2(dataMap, tempPath, tempName, docName); + OutputWordUtil.createZdDoc2(dataMap, tempPath, tempName, docName, wizardJsonData, repositoryId, docPath); } } } diff --git a/com.awspaas.user.apps.coe.pal.output.zd/制度-手册7.doc b/com.awspaas.user.apps.coe.pal.output.zd/制度-手册7.doc new file mode 100644 index 00000000..a602dc5f Binary files /dev/null and b/com.awspaas.user.apps.coe.pal.output.zd/制度-手册7.doc differ diff --git a/com.awspaas.user.apps.coe.pal.output.zd/制度-手册7.xml b/com.awspaas.user.apps.coe.pal.output.zd/制度-手册7.xml new file mode 100644 index 00000000..997fbfc4 --- /dev/null +++ b/com.awspaas.user.apps.coe.pal.output.zd/制度-手册7.xml @@ -0,0 +1,3345 @@ + + + + + + Administrator + Microsoft Office User + 2 + 0 + 2023-07-02T05:06:00Z + 2023-07-02T05:06:00Z + 3 + 120 + 565 + 113 + 48 + 637 + 16 + + + 2052-3.6.2.5883 + 1895E579887D400B9B8988E063B2161A + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 内蒙古伊利实业集团股份有限公司 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + iVBORw0KGgoAAAANSUhEUgAAAPMAAAC6CAYAAAB7oXubAAAP30lEQVR42u2dP4hc1xXGp0o9VeqB +kCLdpojbTKEyxQpSpclAmhQpFgIGV15wseUqwZhUHhxw4UIsMa7ihXGQiyhxdiMjR1ggrxRJFnaQ +RpaIZCGHlz2rHXs0eu/NuX/Ouefe+31wm2VmZ+a9+3vn3HPOPXcwgKpX0zTD47F9PGZNfM1O//cY +VxqCwkAdC0HaCIE/wl2DAO4zC1iaZrizUMnQThoIbjuUHbij43EEdtdqD7MFsgjwRjKf9sbDZvvC +nWbz/LVm/PbVZrBz4DXovfR/6P8l0BSzCEoFL0WT55Kzm8DyBVNjTD++K/nzNzDLIGmIo7vPR/ef +nFhVy+Byx97V+wimQaYBjqat/ZtFQOsyyMOAKw6lDmJFsbq1wbtuRNAhZigkboV3//4lgHUYozcu +h17yIWYttAywdyCLgkCA0kRQDWtrQOwngCc7hruXUJgCsVJKWPtmNDbevIJgGRS+Hp68dx1AZby+ +xqwvC+Cxs58WUEWFoTPIUwLUsMTZVlxhBKe5UFVW8pqY6pABRf7DpZ4clNiHeIRoNAZV2DE1BzU2 +QWZ35aDaYUx6uN+w0vYg3uPeNIqEWp14y1sPfbYf0nuo2IKsEoJ3XlAfgaYMglup18RU/EAlnhZ0 ++MWjYnZnuYz5198AaKMQH1mLTJM1LEGl59ThdmdojTPflG9GJabqAHTFENcCLiv8e+yuWo49RIZ6 +F+QlyBkb22tblXKGm9E0AekrrXQTWYoYASpmgAQqcCsox/MCjcJuNVxn2yrN7QaVxkCG9EWeTyFA +Y0tlSogppwrBWsNCGwLZdW1cSt4XUJsEegJiPUHmumme3SggRMJbB1XLIcrNh3gSwxpDiIQninSj +geApyIehrhgi0giWGbDQU7jVnhAHdGyEALXURo0RQHYEGYUddclaBxhEuCOADNUtS5s9ALQnyInO +CIYMylLP8r6vWTXIbVFMuNNQlyx0UemL21QL8upGeEAMcQWgDYFMBR5YF0M5A13N+pmbdoCgEMXY +AisE9KgakJEvhmKJijosAl0FyBBUktvdF+spEuTF0xOCSgS6GJibNacsUrBrTX0rBGUNdN8+gWKK +Qaw0f4fqUora7qxhXndBX/3gJcwqKJlW058JgZ5lDfLL+z/CbIKqAzo76wyQIbjczpVhc2sQb/Zd +tI8+3wPIUPVBsa5UVTYW+dzFsycgv/PJK5g5UPVAdzkJ5lv8EMSLAUEA2ujaGSBDANp9UNfRDo1S +gTwHyFBp0opwm7HOTc+B5o+ePngO5Pc/ex0zBMpKGk0OtvZvpoe5WXOM6jLIsMoQ3G0366wJ8rTr +x99+cAUgQwA6l4owF4v8h3/8ErMBwvrZ2rqZfhd3jQyrDKXUwz+eb+6c+UXvsG6dzVhkaZCPvvcD +9oDq0uO//FVkbhTjaruCLL0bygfm+Wu/c3qfhRHbWpX8+xYiq8v5bJoPLpKs31ZztV1B1nCvfSZM +biDHnvClP6xcf6elYJgKzE1PLrkLZGmYXSzMf//05+xhjjXpAbNdmMXzzX0BL3Kjc7LKgNne73d1 +cy3ArG2dxd3rdz/d6QRZo9KLe7P+86uXv33P/+ZfAeYKrHJpMDcx6rR91smWrTI3KAKYAXMqoEUi +2r4gk8W2CvPT67cAs6Hfc+P7PxaZH+SNcT7/i5//OuhzJCLbXd1pQ0De9gFZq0AkxVPf1UUvIVcu +9ZutzI8n//xX8GfFhpnOmI4Ns3PAiwa1A7Jyo27+8KdZPES4/5Oi95bByBHmGDIdBOv60m2bJ2qx +yhZgtg5GrTBLuNpRYG56uoWsA1kD5q9+P002sVzW26XA7PKbY6aYQq6J1H3StM6xYG7Vzodn1oJs +ycWWEAVLaoNZ6jdLXpMU39kczL7Ray2rzI1Quu6EiT3BqMCfKwrApIz6WnWxQz4zxXeOfVSsGMwc +kC/8+62irbLU51OQLvYDIneYQ3c7STx0ta1zEMwh7rWlwJeUVUbwSy9zcPsnP1OBObZMwNwE5JSt +VXxZsFDcQBBt/khdXNEn162i2td6uUwXMAfmlK3tjrr729eiAVlSNVhuv4H7XiposQQznbucFObj +14za3njv8S02yPTa1FZ5neVysYKAOQ+Y20QP9JTLsdQwB7nX0laZW04Ycx0GmPOFOVXwKznMTU+r +XCswuzYeqMXF5sJsvUVSKpillBLmYJAlYY6xTi4VZm70OLcHEneLKlUCWoSZNkmEgkwnaESB+dq9 +vzmBLNkPuxZX02dwN11Y/g1t69ZQGC2k+tR3TZVglSVuMtbL+brYLo0nLMPc+X8Bs80qKOs7kVy+ +X5fLq11PYOWaCsE8FQVZCuYaujxyrQgnuJfLA8wKzNL7wlWDX5Zhdtnxsjoo/ZQLzNjDnA5maWUJ +s0TwK8Qq0z5WwKz7m2PuYeam0br6dpUA8+S963yYY1plinxbATm33VKWGvi1Aen7/TieldQ1KQFm +p+CXVRebyjEtwizV2cQSzKsBLG5JZNv3SwUj16pL9IUzBfO5i2eTw5z7ESeuLVstwRxzvZwKZs1u +nAlg3mIfM+MDckyY+zZPSMEUGzqXScK1Il1b/FzE6YdVE8waUgl+xXSxY8Hclz6QOl+3pvUyZ4OJ +JsxdGxy4WYyugFsJMDs1v7cGc9d6dHHDQjtOLCwT/b/FoMnEHa5u/rr/53oustbDaFkuTe99yjFL +D36FwNz109gwc9sCxYa5a9LEzHX6AFnjUTTLCimJ5FxvwBzHxZ7HtMqhMGuU58WIkJd+sPpqhVnI +d+Q0J0wZybYM88abV9K52LFg7is60CrarxlmzfVyX1pI4z5LnQMdA+bglBS1x00Fc8xAUVcLmNpB +tgZzX3ePUiLZkWEesWEOAdkSzF2TJEeQY+ZBOcUfmjCHFuaEPrStwux8hGtuMMc4YqRmi8z5/SHN +AVbfi+DXaXXH/k3ZLY85wlxLQwLJ8kJXL8AlkLTqDXGi4Ah+xdkltS0Bc+yNFrFh1vj8GFVaqa6h +pouduvJL63gfja4iRxIwp+7/5dLQT+rzrcpa5VfXtXIpUiltvdyVjjrWWKUZgbW2QaV+vnaxiDTM +XcEr7smeOcDsehKks1WO1YUTMJcNs0u1XJs3JJ1xyCGSLZqO6oP5/c9eNwuzSw1zKhc1d5hX+2CF +draUXi+HPgyswTz/+ht3q9wFM613Y8D86OmDaoNfWhVF1vPLITAvHiR9o6sBn1TjCGmYR29c7px6 +XjCHbLBYHm9d+k21MGO9HAfmUh66omtlyRyzpKudMkdLudfSYZZ4gNb+0CVrywF5uHsJMGu1gAk9 +GzhHqwyYM7HKucGcuqKndKscekB5lzeUovG8lXtFwazAtfLMDMzvfrpTxHrZ+pExoVmArrWjS663 +rze55jWLUbufnVXWgFmjuZ8lmEtaK8e85hZPvrACc49mwTDHSk2lgjl2N06ue0/dSyxqXdGHFhjW +YJZurctxsXvKNt2ssnTRSCqYYx9FU7JV1rRyfa2aSrxfau61RjmnVutdyZvE6S1t2SqHft/Y3lDf +5okY4m7O0Mgvq7nXSzDv5bBuTlXGmbNVbrOErg8dqd+fsuOoBat8dP9Jp3c+8NXxm8caMIcC7dJN +EyC/uFb2OdJW4wGaAuaujRlaMEddJ6eIaMduv2sFZq2N7RYj4NYeaFa+67qKrx6Ns4E5pPuIxQbx +lq0yYLZZ8dX7vhjSgjnEOmu2gMm9JVCNMFv5jtOP7zp32owGsjbM73zyivMFopMVtCYVZ+uc1ch1 +KpgtXA/rrYE2z1/re9tQFObQJvgxrbOWheAE2WpRSDfOWkGmXU8e7vXhIKYaoQ6dXePVD14yB3Ou +O6Fqd7FTnMvtYpXHb1/te8veQEKaMLtaZ+m0VF+hgWTv6lIss0WYY1cB+lpl8YAXF2bqFGIFaM1J +IV2zC8nct9VTK7W0feGOHZClW+5q9giDIG2ZAjmVq23NOkOQq9oKRNZ55MXCLNH0D4JSWeW1r9dS +24df/nJfHGjacglBhYM8HWjq+AN3U1hnuNtQziD3ddU81eEghdq+CVVtAWgIaofZJMipotoAGsoR +5L2r9+2CfArzPCXMH32+h9kCmQd5TWVXepCtWOdzF89i1kDmtEhD9e1+ShLssgwz3G3ImhZbG1nW +25ravmTsrp0AGspFjIj1ycsGFmXBOtO4/eAKZhKUTORSz248zM8ar8A8tAI0BJkOiuWgJnFkG1Fu +KJWYHuHuICdZsc6w0JCWqHkGw3jkBXKfdaYnVwqgXbuUQBBXi5NcinCrc7DO2GkFSYiOHuY0nByU +IGtAw+2GYuje41vc+XQ4KEVd7nZqoNGtBPKVg2GYD0qTRZhp0HnSEMQVBbdcPLxBiTr+XZtWgYbb +DXEDXNWDvM46L6894HZDll1qgMwA2oqFhpWG1s1HgMwo9aQ8sBWgYaXrVVd3HE6dwqA29QGt1WYI +Vhpy8Qzp/LRq0k8eQE+7rgo1GLAENKCuF2LmvZ8MalfTk3/e+fCMOaCRxqoLYibI8vuQdw7GJyPn +gJhFCw1LXeZ6eHVQKirZ+njnYLvreNelMc4OaKsww1LnJZeDDDlbGAVBnn8LbPdrmrWvsQr0opDd +8oDsabVaK9Z9FATZDdBcgbaUtgLUtuWzPOO41Y3kPuSdg0MvMHMF2rrbjVx1OoUETJNa4+eh3Gx1 +pV8ck6XXDc3CXBrQANuOC+3pRc2UQG5YFrf9tTMAnWCgSb+/YtXwO9wDnfY+zwAdecO8+HuuaSsS +VeXkCvVi0LG3kJz19W0bpTrRXaHNEWYO0DlbabQ0el60FKF0X+IOrdvqk5wD7bPCkcWaeZYlzKdA +T9bdAe0TM7QGpeVKFHkkxtosp+sI0gdz2+D+jxxruRdK1fVTu8MoM41iRvR9U6QWHZT2sDZ+oGuY +tZvt43bnUGQiCTt5KVrAk+WTco0VqvJs9Od6BuhuQDR7lCXMp0CPOXfK0iTDsFVaa2pC7xxsBKam +6G/TQa46vh8jblAFk73s4agtkxP6xYBXwwyMHWZrlVugPuLeRUz8cobH+WET0xP5u/Xw1OE9kxcq +wgoAept7R0uNegPiTFxqjru9XNa5rpY7Z/c6lpWGpc4rqOehWbYT+bs01PwE8LZodlvVWKFQq5cI +YtgpfS1iEi/qrdvH0aAmcSPesXbeYMQZdA98NYCKh3roMzEAlu118JI2Mcvrg3rqM1Nc2s1gqJ6V +PcGsBtTDkGongOg/IlSlzTGDoTaoN0JmVQnbLzNqozTDjIVEUlrIX7cPugYRtYuZCamvq2utCxfa +f421MBQd7L3Ys5TWjDlCHtniYh0M5Rk0cy1gIXC0gKeiDM3tkksaY1ZBFsDeQncuLw0xeyDrcG+C +UwN9tCDIYmQc8EKQXcC3AS0ElQs4bQSZWYWWOrngLkGQDPjjU8j2Th8CXWN7aYwROYY4+j8O5ulX +y7fdOgAAAABJRU5ErkJggk== + + + + + + + + + + + + + + + + + ─────────────────────────────────────────────────── + + + + + + + + + + ─────────────────────────────────────────────────── + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 以上信息为伊利公司所有,未经允许不得外传 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PAGE + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file