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 33ad6960..9ada95fc 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/util/OutputWordUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java index 60401fc2..803992ab 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 @@ -39,12 +39,15 @@ import com.sini.com.spire.doc.formatting.ParagraphFormat; import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateException; +import org.apache.commons.lang.StringUtils; import java.awt.*; import java.io.*; import java.util.List; import java.util.*; +import static com.sini.com.spire.doc.documents.HorizontalAlignment.*; + public class OutputWordUtil { public static final String DEPARTMENT = "department"; // 部门 @@ -367,12 +370,6 @@ public class OutputWordUtil { //创建 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); @@ -560,7 +557,7 @@ public class OutputWordUtil { ParagraphFormat paragraphFormat1 = paragraph1.getFormat(); - paragraphFormat1.setHorizontalAlignment(HorizontalAlignment.Left); + paragraphFormat1.setHorizontalAlignment(Left); TextRange tr = paragraph1.appendText("相关文件"); tr.getCharacterFormat().setBold(true); @@ -590,19 +587,24 @@ public class OutputWordUtil { Table table = section.addTable(true); table.resetCells(data.length + 1, header.length); + //自动调整表格大小 + table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window); + + TableRow row = table.getRows().get(0); row.isHeader(true); row.setHeight(20); - row.setHeightType(TableRowHeightType.Exactly); + row.setHeightType(TableRowHeightType.Auto); for (int i = 0; i < header.length; i++) { row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); //设置固定列宽 row.getCells().get(0).setWidth(150); row.getCells().get(1).setWidth(500); Paragraph p = row.getCells().get(i).addParagraph(); - p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center); + p.getFormat().setHorizontalAlignment(Center); TextRange txtRange = p.appendText(header[i]); txtRange.getCharacterFormat().setBold(true); + } //将数据添加到其余行 @@ -617,6 +619,9 @@ public class OutputWordUtil { dataRow.getCells().get(0).setWidth(150); dataRow.getCells().get(1).setWidth(500); dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); + + // cell.getCellFormat().setFitText(true); // 设置内容 + } } @@ -649,7 +654,7 @@ public class OutputWordUtil { //添加段落,设置一级序列 Paragraph paragraph2 = section.addParagraph(); ParagraphFormat paragraphFormat2 = paragraph2.getFormat(); - paragraphFormat2.setHorizontalAlignment(HorizontalAlignment.Left); + paragraphFormat2.setHorizontalAlignment(Left); TextRange tr2 = paragraph2.appendText("支持文件"); tr2.getCharacterFormat().setBold(true); tr2.getCharacterFormat().setFontName("宋体"); @@ -676,17 +681,21 @@ public class OutputWordUtil { Table table = section.addTable(true); table.resetCells(data.length + 1, header.length); + + table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window); + + TableRow row = table.getRows().get(0); row.isHeader(true); row.setHeight(20); - row.setHeightType(TableRowHeightType.Exactly); + row.setHeightType(TableRowHeightType.Auto); for (int i = 0; i < header.length; i++) { row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); //设置固定列宽 row.getCells().get(0).setWidth(150); row.getCells().get(1).setWidth(500); Paragraph p = row.getCells().get(i).addParagraph(); - p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center); + p.getFormat().setHorizontalAlignment(Center); TextRange txtRange = p.appendText(header[i]); txtRange.getCharacterFormat().setBold(true); } @@ -720,7 +729,8 @@ public class OutputWordUtil { 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(":")) { + + if (p1.substring(0, 2).equals("附件") && p2.substring(0, 2).equals("附件") && p1.contains(":") && p2.contains(":") && StringUtils.isNumeric(p1.substring(2, p1.indexOf(":"))) && StringUtils.isNumeric(p2.substring(2, p2.indexOf(":")))) { return Integer.parseInt(p1.substring(2, p1.indexOf(":"))) - Integer.parseInt(p2.substring(2, p2.indexOf(":"))); } else { @@ -742,7 +752,7 @@ public class OutputWordUtil { Paragraph paragraph4 = section.addParagraph(); ParagraphFormat paragraphFormat4 = paragraph4.getFormat(); - paragraphFormat4.setHorizontalAlignment(HorizontalAlignment.Left); + paragraphFormat4.setHorizontalAlignment(Left); TextRange tr4 = paragraph4.appendText("附件"); @@ -843,6 +853,7 @@ public class OutputWordUtil { } try { + System.out.println("生成附件路径是=================="+outFile.getPath()); doc.saveToFile(outFile.getPath(), FileFormat.Docx_2013); } catch (Exception e) { e.printStackTrace(); @@ -1003,7 +1014,7 @@ public class OutputWordUtil { ParagraphFormat paragraphFormat4 = paragraph.getFormat(); - paragraphFormat4.setHorizontalAlignment(HorizontalAlignment.Left); + paragraphFormat4.setHorizontalAlignment(Left); TextRange tr4 = paragraph.appendText("表单/模板"); diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java index e6de512b..9c027de0 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java @@ -4225,6 +4225,7 @@ public class DesignerRelationShapeWeb extends ActionWeb { else throw new AWSException("创建流程手册失败:" + uuid); } else if ("data.form".equals(model.getMethodId())) { + taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportBd(wsId, _uc.getUID(), teamId, uuid); JSONObject object = JSONObject.parseObject(taskId); if ("ok".equals(object.getString("result"))) @@ -4340,10 +4341,8 @@ public class DesignerRelationShapeWeb extends ActionWeb { if (file.exists()) { File[] fileList = file.listFiles(); if (fileList.length > 0) { - System.out.println("fileList==========" + fileList); File docFile = null; for (File file2 : fileList) { - System.out.println("file2==============" + file2); if (file2.isFile() && "xlsx".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) { docFile = file2; break; diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java index a448564e..90dd707b 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java @@ -1,54 +1,71 @@ package com.actionsoft.apps.coe.pal.pal.repository.designer.web; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.nio.charset.StandardCharsets; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.Map.Entry; - -import javax.imageio.ImageIO; - +import com.actionsoft.apps.AppsConst; +import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; import com.actionsoft.apps.coe.pal.cooperation.cache.CooperationCache; import com.actionsoft.apps.coe.pal.cooperation.constant.CoeCooperationConst; import com.actionsoft.apps.coe.pal.cooperation.model.CoeCooperationRoleModel; import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; import com.actionsoft.apps.coe.pal.log.CoEOpLogConst; -import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; +import com.actionsoft.apps.coe.pal.pal.comment.constant.PALCommentConst; +import com.actionsoft.apps.coe.pal.pal.comment.dao.PALComment; +import com.actionsoft.apps.coe.pal.pal.comment.model.PALCommentModel; +import com.actionsoft.apps.coe.pal.pal.manage.publish.constant.PublishConst; +import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; +import com.actionsoft.apps.coe.pal.pal.method.constant.PALMethodConst; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeGroupModel; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodLinkerModel; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; +import com.actionsoft.apps.coe.pal.pal.method.util.PALMethodUtil; +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.output.util.OutputWordUtil; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.cache.*; -import com.actionsoft.apps.coe.pal.pal.ws.dao.CoeWorkSpace; -import com.actionsoft.apps.coe.pal.util.SubUtil; -import com.actionsoft.bpms.commons.database.RowMap; -import com.actionsoft.bpms.util.*; -import com.actionsoft.apps.coe.pal.pal.ws.model.CoeWorkSpaceModel; +import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelCorrelateDao; +import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; +import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.designer.adapter.CoeDesginerAdapter; +import com.actionsoft.apps.coe.pal.pal.repository.designer.constant.CoeDesignerConstant; +import com.actionsoft.apps.coe.pal.pal.repository.designer.io.file.helper.CoeFile; +import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BPMNModel; +import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel; +import com.actionsoft.apps.coe.pal.pal.repository.designer.realtime.manage.CoeListenCacheManager; +import com.actionsoft.apps.coe.pal.pal.repository.designer.realtime.model.ListenClient; +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.manager.DesignerRelationShapeCacheManager; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapePasteModel; +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.designer.util.Img2Pdf; +import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil; +import com.actionsoft.apps.coe.pal.pal.repository.model.*; +import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl; +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.util.CoeProcessLevelUtil; +import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb; +import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessRecycleWeb; +import com.actionsoft.apps.coe.pal.pal.ws.web.VersionUtil; +import com.actionsoft.apps.coe.pal.system.property.CoePropertyUtil; +import com.actionsoft.apps.coe.pal.team.user.dao.CoeUserDaoFactory; +import com.actionsoft.apps.coe.pal.team.user.model.CoeUserModel; import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; -import com.actionsoft.bpms.bpmn.engine.cache.util.ProcessDefVersionUtil; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.hssf.usermodel.HSSFCellStyle; -import org.apache.poi.hssf.usermodel.HSSFFont; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hssf.util.HSSFColor; -import org.apache.poi.ss.usermodel.BorderStyle; -import org.apache.poi.ss.usermodel.FillPatternType; -import org.apache.poi.ss.usermodel.HorizontalAlignment; -import org.apache.poi.ss.usermodel.VerticalAlignment; - -import com.actionsoft.apps.AppsConst; +import com.actionsoft.apps.coe.pal.util.JsonUtil; +import com.actionsoft.apps.coe.pal.util.StringHandleUtil; import com.actionsoft.apps.lifecycle.api.AppsAPIManager; import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; import com.actionsoft.bpms.bpmn.constant.ProcessDefinitionConst; import com.actionsoft.bpms.bpmn.engine.cache.ProcessDefCache; +import com.actionsoft.bpms.bpmn.engine.cache.util.ProcessDefVersionUtil; import com.actionsoft.bpms.bpmn.engine.model.def.ProcessDefinition; import com.actionsoft.bpms.bpmn.modeler.constant.BPMNConstant; import com.actionsoft.bpms.bpmn.modeler.constant.BPMNDesignerConstant; @@ -82,67 +99,7 @@ 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.UUIDGener; -import com.actionsoft.bpms.util.UtilDate; -import com.actionsoft.bpms.util.UtilFile; -import com.actionsoft.bpms.util.UtilString; -import com.actionsoft.apps.coe.pal.constant.CoEConstant; -import com.actionsoft.apps.coe.pal.pal.comment.constant.PALCommentConst; -import com.actionsoft.apps.coe.pal.pal.comment.dao.PALComment; -import com.actionsoft.apps.coe.pal.pal.comment.model.PALCommentModel; -import com.actionsoft.apps.coe.pal.pal.manage.publish.constant.PublishConst; -import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; -import com.actionsoft.apps.coe.pal.pal.method.constant.PALMethodConst; -import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeGroupModel; -import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; -import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodLinkerModel; -import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; -import com.actionsoft.apps.coe.pal.pal.method.util.PALMethodUtil; -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.output.util.OutputWordUtil; -import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; -import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelCorrelateDao; -import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory; -import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository; -import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; -import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager; -import com.actionsoft.apps.coe.pal.pal.repository.designer.adapter.CoeDesginerAdapter; -import com.actionsoft.apps.coe.pal.pal.repository.designer.constant.CoeDesignerConstant; -import com.actionsoft.apps.coe.pal.pal.repository.designer.io.file.helper.CoeFile; -import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager; -import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BPMNModel; -import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel; -import com.actionsoft.apps.coe.pal.pal.repository.designer.realtime.manage.CoeListenCacheManager; -import com.actionsoft.apps.coe.pal.pal.repository.designer.realtime.model.ListenClient; -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.manager.DesignerRelationShapeCacheManager; -import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapePasteModel; -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.designer.util.Img2Pdf; -import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil; -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.PALRepositoryShapeConfigModel; -import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl; -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.util.CoeProcessLevelUtil; -import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb; -import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessRecycleWeb; -import com.actionsoft.apps.coe.pal.pal.ws.web.VersionUtil; -import com.actionsoft.apps.coe.pal.system.property.CoePropertyUtil; -import com.actionsoft.apps.coe.pal.team.user.dao.CoeUserDaoFactory; -import com.actionsoft.apps.coe.pal.team.user.model.CoeUserModel; -import com.actionsoft.apps.coe.pal.util.JsonUtil; -import com.actionsoft.apps.coe.pal.util.StringHandleUtil; +import com.actionsoft.bpms.util.*; import com.actionsoft.exception.AWSException; import com.actionsoft.exception.BPMNDefException; import com.actionsoft.i18n.I18nRes; @@ -151,417 +108,435 @@ import com.actionsoft.sdk.local.api.AppAPI; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.commons.lang.StringUtils; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.Map.Entry; public class CoeDesignerWeb extends ActionWeb { - private static final long serialVersionUID = 1L; - private final UserContext _uc; - private CoeProcessLevelWeb coeProcessLevelWeb; + private static final long serialVersionUID = 1L; + private final UserContext _uc; + private CoeProcessLevelWeb coeProcessLevelWeb; - public CoeDesignerWeb(UserContext uc) { - super(uc); - _uc = uc; - } + public CoeDesignerWeb(UserContext uc) { + super(uc); + _uc = uc; + } - public static String getUserName(String nameList) { - StringBuilder fullName = new StringBuilder(); - nameList = nameList.trim(); - if (nameList.equals("")) { - return ""; - } - nameList = nameList + " "; - UtilString myStr = new UtilString(nameList); - List myArray = myStr.split(" "); - int i = 0; - String uid = ""; - try { - int size = myArray.size(); - for (i = 0; i < size; i++) { - uid = myArray.get(i); - if (uid.trim().equals("")) - continue; - uid = SDK.getORGAPI().getUserId(uid); - UserModel model = UserCache.getModel(uid); - String name = uid; - if (model != null) { - name = model.getUserName(); - } - fullName.append(name).append(' '); - } - return fullName.toString().trim(); - } catch (Exception e) { - return ""; - } - } + public static String getUserName(String nameList) { + StringBuilder fullName = new StringBuilder(); + nameList = nameList.trim(); + if (nameList.equals("")) { + return ""; + } + nameList = nameList + " "; + UtilString myStr = new UtilString(nameList); + List myArray = myStr.split(" "); + int i = 0; + String uid = ""; + try { + int size = myArray.size(); + for (i = 0; i < size; i++) { + uid = myArray.get(i); + if (uid.trim().equals("")) + continue; + uid = SDK.getORGAPI().getUserId(uid); + UserModel model = UserCache.getModel(uid); + String name = uid; + if (model != null) { + name = model.getUserName(); + } + fullName.append(name).append(' '); + } + return fullName.toString().trim(); + } catch (Exception e) { + return ""; + } + } - /** - * 设计器页面 - * - * @param rUUID - * @param openType - * @param teamId 小组Id - * @return - */ - public String getDesignerHtml(String rUUID, int openType, String teamId, String perms, String filePerms, String openAppType) { - return getDesignerHtml(rUUID, openType, null, false, teamId, perms, filePerms, openAppType, null); - } + /** + * 设计器页面 + * + * @param rUUID + * @param openType + * @param teamId 小组Id + * @return + */ + public String getDesignerHtml(String rUUID, int openType, String teamId, String perms, String filePerms, String openAppType) { + return getDesignerHtml(rUUID, openType, null, false, teamId, perms, filePerms, openAppType, null); + } - public String getDesignerHtml(String rUUID, int openType, String shapeId, String teamId, String perms, String filePerms, String openAppType) { - return getDesignerHtml(rUUID, openType, shapeId, false, teamId, perms, filePerms, openAppType, null); - } + public String getDesignerHtml(String rUUID, int openType, String shapeId, String teamId, String perms, String filePerms, String openAppType) { + return getDesignerHtml(rUUID, openType, shapeId, false, teamId, perms, filePerms, openAppType, null); + } - public String getDesignerHtml(String rUUID, int openType, String shapeId, boolean isView, String teamId, String perms, String filePerms, String openAppType, String dockDisplay) { - Map macroLibraries = new HashMap(); - if (shapeId != null) { - macroLibraries.put("selectedElementId", shapeId); - } else { - macroLibraries.put("selectedElementId", ""); - } - macroLibraries.put("js", ""); - PALRepositoryModelImpl plModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(rUUID); + public String getDesignerHtml(String rUUID, int openType, String shapeId, boolean isView, String teamId, String perms, String filePerms, String openAppType, String dockDisplay) { + Map macroLibraries = new HashMap(); + if (shapeId != null) { + macroLibraries.put("selectedElementId", shapeId); + } else { + macroLibraries.put("selectedElementId", ""); + } + macroLibraries.put("js", ""); + PALRepositoryModelImpl plModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(rUUID); - if (plModel == null) { - return AlertWindow.getNotFoundMessagePage("未找到文件", "该文件已被删除"); - } + if (plModel == null) { + return AlertWindow.getNotFoundMessagePage("未找到文件", "该文件已被删除"); + } - if (!CoeCooperationAPIManager.getInstance().hasRepositoryPermision(rUUID)) { - return AlertWindow.getWarningMessagePage("打开失败", "您所在组织/职级暂未被授予该文件的阅览权限"); - } - //三员管理,文件密级权限校验 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - CoeProcessLevelWeb web = new CoeProcessLevelWeb(_uc); - ResponseObject responseObject = web.checkFilePemission(rUUID); - if (responseObject.isErr()){ - return AlertWindow.getWarningMessagePage("打开失败", responseObject.getMsg()); - } - } + if (!CoeCooperationAPIManager.getInstance().hasRepositoryPermision(rUUID)) { + return AlertWindow.getWarningMessagePage("打开失败", "您所在组织/职级暂未被授予该文件的阅览权限"); + } + //三员管理,文件密级权限校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + CoeProcessLevelWeb web = new CoeProcessLevelWeb(_uc); + ResponseObject responseObject = web.checkFilePemission(rUUID); + if (responseObject.isErr()) { + return AlertWindow.getWarningMessagePage("打开失败", responseObject.getMsg()); + } + } - boolean outputPerm = true; - if (UtilString.isNotEmpty(teamId)) { - boolean isOlderVersion = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true); - if (isOlderVersion){ - CoeCooperationRoleModel role = CoeCooperationAPIManager.getInstance().queryCooperationRoleByUser(teamId, _uc.getUID()); - if (role != null) { - perms = role.getActionPerm(); - } - // 没有新建、修改权限则只读 - if (!role.getActionPerm().contains(CoeCooperationConst.ACTION_WRITE)) { - isView = true; - } - if (!"all".equals(role.getAppPerm()) && !role.getAppPerm().contains("com.actionsoft.apps.coe.pal.output")) { - outputPerm = false; - } - }else { - //获取用户对应文件的操作权限 - Set fileActionPerm = CooperationCache.getUserDataOperatePermission(teamId, _uc.getUID(), plModel.getVersionId()); - perms = UtilString.join(fileActionPerm,","); - //没有文件新建、修改权限则只读 - if (!fileActionPerm.contains(CoeCooperationConst.ACTION_WRITE)){ - isView = true; - } - Set userAPPPermission = CooperationCache.getUserAPPPermission(teamId, _uc.getUID()); - if (!userAPPPermission.contains("all") && !userAPPPermission.contains("com.actionsoft.apps.coe.pal.output")) { - outputPerm = false; - } - } + boolean outputPerm = true; + if (UtilString.isNotEmpty(teamId)) { + boolean isOlderVersion = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true); + if (isOlderVersion) { + CoeCooperationRoleModel role = CoeCooperationAPIManager.getInstance().queryCooperationRoleByUser(teamId, _uc.getUID()); + if (role != null) { + perms = role.getActionPerm(); + } + // 没有新建、修改权限则只读 + if (!role.getActionPerm().contains(CoeCooperationConst.ACTION_WRITE)) { + isView = true; + } + if (!"all".equals(role.getAppPerm()) && !role.getAppPerm().contains("com.actionsoft.apps.coe.pal.output")) { + outputPerm = false; + } + } else { + //获取用户对应文件的操作权限 + Set fileActionPerm = CooperationCache.getUserDataOperatePermission(teamId, _uc.getUID(), plModel.getVersionId()); + perms = UtilString.join(fileActionPerm, ","); + //没有文件新建、修改权限则只读 + if (!fileActionPerm.contains(CoeCooperationConst.ACTION_WRITE)) { + isView = true; + } + Set userAPPPermission = CooperationCache.getUserAPPPermission(teamId, _uc.getUID()); + if (!userAPPPermission.contains("all") && !userAPPPermission.contains("com.actionsoft.apps.coe.pal.output")) { + outputPerm = false; + } + } - } - List versionModels = PALRepositoryCache.getByVersionId(plModel.getVersionId()); - //按照版本号排序 - versionModels.sort(Comparator.comparing(PALRepositoryModel::getVersion)); - JSONArray verArray = new JSONArray(); - for (int v = 0; v < versionModels.size(); v++) { - PALRepositoryModel model = versionModels.get(v); - JSONObject tmp = new JSONObject(); - tmp.put("uuid", model.getId()); - tmp.put("nameVersion", model.getName() + "_V" + model.getVersion()); - verArray.add(tmp); - } - macroLibraries.put("verArray", JSON.toJSONString(verArray)); + } + List versionModels = PALRepositoryCache.getByVersionId(plModel.getVersionId()); + //按照版本号排序 + versionModels.sort(Comparator.comparing(PALRepositoryModel::getVersion)); + JSONArray verArray = new JSONArray(); + for (int v = 0; v < versionModels.size(); v++) { + PALRepositoryModel model = versionModels.get(v); + JSONObject tmp = new JSONObject(); + tmp.put("uuid", model.getId()); + tmp.put("nameVersion", model.getName() + "_V" + model.getVersion()); + verArray.add(tmp); + } + macroLibraries.put("verArray", JSON.toJSONString(verArray)); - String type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; - if (plModel.getMethodId() != null && plModel.getMethodId().indexOf(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN) != -1) { - type = CoeDesignerConstant.DESIGNER_DIFINITION_BPMN; - } else { - type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; - } + String type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; + if (plModel.getMethodId() != null && plModel.getMethodId().indexOf(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN) != -1) { + type = CoeDesignerConstant.DESIGNER_DIFINITION_BPMN; + } else { + type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; + } - // 删除与BPMS关联的无效关联关系 - CoeProcessLevelUtil.deleteInvalidCorrelate(plModel.getId()); - String processDefId = ""; - boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(plModel.getId(), true); - if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { - if (isCorrelateBpms) { - processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(plModel.getId(), true); - } else { - processDefId = ""; - } - } - macroLibraries.put("isCorrelateBpms", isCorrelateBpms); - macroLibraries.put("isMarked", false); + // 删除与BPMS关联的无效关联关系 + CoeProcessLevelUtil.deleteInvalidCorrelate(plModel.getId()); + String processDefId = ""; + boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(plModel.getId(), true); + if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { + if (isCorrelateBpms) { + processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(plModel.getId(), true); + } else { + processDefId = ""; + } + } + macroLibraries.put("isCorrelateBpms", isCorrelateBpms); + macroLibraries.put("isMarked", false); - // 自动保存 - String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); - macroLibraries.put("isAutoSave", isSysAutoSave); - // 如果非只读打开,判断文件是否被其他人打开 - String checkoutTip = ""; - boolean isLock = false; - String lockuser = plModel.getLockUser(); - if (!UtilString.isEmpty(lockuser)) {//加锁 - if (lockuser.equals(_uc.getUID())) {//本人加锁 - setCurrentCheckoutRight(rUUID, _uc.getUID());//进入正常编辑界面 - } else {//其他用户,显示已被锁定 - checkoutTip = "
" + "
" + "
已由 " + SDK.getORGAPI().getUserNames(lockuser) + " 编辑该模型时锁定,最后一次保存日期" + "
" + UtilDate.datetimeFormat(plModel.getModifyDate()) + "" + "
" + "
"; - isView = true; - isLock = true; - } - } else {//未上锁 - if ("0".equals(isSysAutoSave) && !isView) { - CheckoutModel checkoutModel = getCurrentCheckoutInfo(rUUID);//打开该流程视图的对象 - if (checkoutModel != null) { - long idel = AWSServerConf.getMainServerConnectionTimeout(); - Map onlines = new SessionImpl().getOnline(idel);//在线状态 - if (onlines.containsKey(checkoutModel.getUser())) {//判断锁定者是否还在会话中 - if (!checkoutModel.getUser().equals(_uc.getUID())) { - isView = true; - isLock = true; - // 是否允许强制获取编辑权,1:允许,0:不允许 - String checkoutRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "CHECKOUTRIGHT"); - if ("1".equals(checkoutRight)) { - checkoutTip = "
" + "
" + "
已由 " + SDK.getORGAPI().getUserNames(checkoutModel.getUser()) + " 编辑该模型时锁定,最后一次保存日期" + "
" + UtilDate.datetimeFormat(plModel.getModifyDate()) - + ",点击此处强行获取编辑权" + "
" + "
"; - } else { - checkoutTip = "
" + "
" + "
已由 " + SDK.getORGAPI().getUserNames(checkoutModel.getUser()) + " 编辑该模型时锁定,最后一次保存日期" + "
" + UtilDate.datetimeFormat(plModel.getModifyDate()) + "" + "
" + "
"; - } - } else { - UserContext wContext = UserContext.fromUID(checkoutModel.getUser()); - CoeDesignerWeb cdw = new CoeDesignerWeb(wContext); - cdw.releaseCheckoutRight(rUUID); - setCurrentCheckoutRight(rUUID, _uc.getUID()); - } - } else { - setCurrentCheckoutRight(rUUID, _uc.getUID()); - } - } else { - setCurrentCheckoutRight(rUUID, _uc.getUID()); - } - } - } + // 自动保存 + String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); + macroLibraries.put("isAutoSave", isSysAutoSave); + // 如果非只读打开,判断文件是否被其他人打开 + String checkoutTip = ""; + boolean isLock = false; + String lockuser = plModel.getLockUser(); + if (!UtilString.isEmpty(lockuser)) {//加锁 + if (lockuser.equals(_uc.getUID())) {//本人加锁 + setCurrentCheckoutRight(rUUID, _uc.getUID());//进入正常编辑界面 + } else {//其他用户,显示已被锁定 + checkoutTip = "
" + "
" + "
已由 " + SDK.getORGAPI().getUserNames(lockuser) + " 编辑该模型时锁定,最后一次保存日期" + "
" + UtilDate.datetimeFormat(plModel.getModifyDate()) + "" + "
" + "
"; + isView = true; + isLock = true; + } + } else {//未上锁 + if ("0".equals(isSysAutoSave) && !isView) { + CheckoutModel checkoutModel = getCurrentCheckoutInfo(rUUID);//打开该流程视图的对象 + if (checkoutModel != null) { + long idel = AWSServerConf.getMainServerConnectionTimeout(); + Map onlines = new SessionImpl().getOnline(idel);//在线状态 + if (onlines.containsKey(checkoutModel.getUser())) {//判断锁定者是否还在会话中 + if (!checkoutModel.getUser().equals(_uc.getUID())) { + isView = true; + isLock = true; + // 是否允许强制获取编辑权,1:允许,0:不允许 + String checkoutRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "CHECKOUTRIGHT"); + if ("1".equals(checkoutRight)) { + checkoutTip = "
" + "
" + "
已由 " + SDK.getORGAPI().getUserNames(checkoutModel.getUser()) + " 编辑该模型时锁定,最后一次保存日期" + "
" + UtilDate.datetimeFormat(plModel.getModifyDate()) + + ",点击此处强行获取编辑权" + "
" + "
"; + } else { + checkoutTip = "
" + "
" + "
已由 " + SDK.getORGAPI().getUserNames(checkoutModel.getUser()) + " 编辑该模型时锁定,最后一次保存日期" + "
" + UtilDate.datetimeFormat(plModel.getModifyDate()) + "" + "
" + "
"; + } + } else { + UserContext wContext = UserContext.fromUID(checkoutModel.getUser()); + CoeDesignerWeb cdw = new CoeDesignerWeb(wContext); + cdw.releaseCheckoutRight(rUUID); + setCurrentCheckoutRight(rUUID, _uc.getUID()); + } + } else { + setCurrentCheckoutRight(rUUID, _uc.getUID()); + } + } else { + setCurrentCheckoutRight(rUUID, _uc.getUID()); + } + } + } - int state = 0;// 版本状态:设计、运行、停用 - String appId = ""; - if (isCorrelateBpms) { - ProcessDefinition definition = ProcessDefCache.getInstance().get(processDefId); - if (definition != null) { - if (definition.getVersionStatus() == 1 || definition.getVersionStatus() == -1) { - isView = true; - } - state = definition.getVersionStatus(); - appId = definition.getAppId(); - if (CoeProcessLevelUtil.isPalManage()) {// PAL为中心管理流程 - CoeProcessLevelCorrelateModel correlateModel = CoeProcessLevelCorrelateCache.getCache().get(plModel.getId()); - if (correlateModel != null && !"show".equals(correlateModel.getExt1()) && correlateModel.getCorrelateType() == 1) { - state = 2; - } - } - } - } + int state = 0;// 版本状态:设计、运行、停用 + String appId = ""; + if (isCorrelateBpms) { + ProcessDefinition definition = ProcessDefCache.getInstance().get(processDefId); + if (definition != null) { + if (definition.getVersionStatus() == 1 || definition.getVersionStatus() == -1) { + isView = true; + } + state = definition.getVersionStatus(); + appId = definition.getAppId(); + if (CoeProcessLevelUtil.isPalManage()) {// PAL为中心管理流程 + CoeProcessLevelCorrelateModel correlateModel = CoeProcessLevelCorrelateCache.getCache().get(plModel.getId()); + if (correlateModel != null && !"show".equals(correlateModel.getExt1()) && correlateModel.getCorrelateType() == 1) { + state = 2; + } + } + } + } - if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { - getBpmnDesginerUI(plModel, macroLibraries, isView, isLock); - getBpmnParams(plModel, processDefId, macroLibraries); - macroLibraries.put("isMarked", CoeProcessLevelUtil.hasMarked(plModel.getId())); - } else { - getCoeDesginerUI(plModel, macroLibraries, isLock, isView); - getCoeParams(plModel, macroLibraries); - } + if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { + getBpmnDesginerUI(plModel, macroLibraries, isView, isLock); + getBpmnParams(plModel, processDefId, macroLibraries); + macroLibraries.put("isMarked", CoeProcessLevelUtil.hasMarked(plModel.getId())); + } else { + getCoeDesginerUI(plModel, macroLibraries, isLock, isView); + getCoeParams(plModel, macroLibraries); + } - macroLibraries.put("BPMNSupport", AWSServerEngineConfiguration.getEngineBPMNSupport()); - macroLibraries.put("BPMNLevel0", AWSServerEngineConfiguration.getEngineBPMNLevel0()); - macroLibraries.put("BPMNLevel1", AWSServerEngineConfiguration.getEngineBPMNLevel1()); - macroLibraries.put("BPMNLevel2", AWSServerEngineConfiguration.getEngineBPMNLevel2()); - String userUrl = SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID()); - getMoreSharpe(plModel.getMethodId(), plModel.getId(), macroLibraries);// 获取更多图形 - macroLibraries.put("ver", 0); - macroLibraries.put("methodId", plModel.getMethodId()); - macroLibraries.put("sid", _uc.getSessionId()); - macroLibraries.put("wsId", plModel.getWsId()); - macroLibraries.put("uuid", rUUID);// definition的UUID - macroLibraries.put("parentChartId", plModel.getParentId()); - macroLibraries.put("uid", _uc.getUID()); - macroLibraries.put("userUrl", userUrl); - macroLibraries.put("userName", _uc.getUserModel().getUserName()); - macroLibraries.put("schema", getSchema(plModel.getId(), plModel.getMethodId(), PALMethodUtil.getCustom(plModel.getMethodId(), plModel.getId()))); - macroLibraries.put("sessionId", _uc.getSessionId()); - macroLibraries.put("fileName", ShapeUtil.replaceBlank(plModel.getName())); - macroLibraries.put("openType", openType); - macroLibraries.put("teamId", teamId); - macroLibraries.put("perms", perms);// 该流程权限(w,d,v) - macroLibraries.put("filePerms", filePerms);// 所有具有权限的流程Id - macroLibraries.put("isPublish", plModel.isPublish()); - macroLibraries.put("isStop", plModel.isStop()); - macroLibraries.put("isApproval", plModel.isApproval()); - macroLibraries.put("ext1", plModel.getExt1()); - macroLibraries.put("ext2", plModel.getExt2()); - macroLibraries.put("ext3", plModel.getExt3()); - macroLibraries.put("ext4", plModel.getExt4()); - macroLibraries.put("isPalManage", CoeProcessLevelUtil.isPalManage()); - CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); - boolean isAdmin = (userModel != null && (userModel.getIsAdmin() == 1)); - macroLibraries.put("isAdmin", isAdmin); - //三员管理,文件密级回显 - if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - Integer securityLevel = plModel.getSecurityLevel(); - HashMap securityMap = HighSecurityUtil.getObjSecurityMap(); - String securityLevelName= securityMap.get(String.valueOf(securityLevel)); - macroLibraries.put("securityLevelName", securityLevelName == null ? "未标密" : securityLevelName); - macroLibraries.put("isHighSecurity",true); - } - // 更多特性权限 - String moreAttrRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "MOREATTR_RIGHT");// 1普通用户有设置更多特性权限, - if ("2".equals(moreAttrRight)) {// 只有admin显示 - if ("admin".equals(_uc.getUID())) { - macroLibraries.put("moreAttrRight", true); - } else { - macroLibraries.put("moreAttrRight", false); - } - } else if ("0".equals(moreAttrRight)) {// 0只有管理员用户有权限 - if (isAdmin) {// 管理员用户 - macroLibraries.put("moreAttrRight", true); - } else{// 普通用户 - macroLibraries.put("moreAttrRight", false); - } - } else { - macroLibraries.put("moreAttrRight", true); - } + macroLibraries.put("BPMNSupport", AWSServerEngineConfiguration.getEngineBPMNSupport()); + macroLibraries.put("BPMNLevel0", AWSServerEngineConfiguration.getEngineBPMNLevel0()); + macroLibraries.put("BPMNLevel1", AWSServerEngineConfiguration.getEngineBPMNLevel1()); + macroLibraries.put("BPMNLevel2", AWSServerEngineConfiguration.getEngineBPMNLevel2()); + String userUrl = SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID()); + getMoreSharpe(plModel.getMethodId(), plModel.getId(), macroLibraries);// 获取更多图形 + macroLibraries.put("ver", 0); + macroLibraries.put("methodId", plModel.getMethodId()); + macroLibraries.put("sid", _uc.getSessionId()); + macroLibraries.put("wsId", plModel.getWsId()); + macroLibraries.put("uuid", rUUID);// definition的UUID + macroLibraries.put("parentChartId", plModel.getParentId()); + macroLibraries.put("uid", _uc.getUID()); + macroLibraries.put("userUrl", userUrl); + macroLibraries.put("userName", _uc.getUserModel().getUserName()); + macroLibraries.put("schema", getSchema(plModel.getId(), plModel.getMethodId(), PALMethodUtil.getCustom(plModel.getMethodId(), plModel.getId()))); + macroLibraries.put("sessionId", _uc.getSessionId()); + macroLibraries.put("fileName", ShapeUtil.replaceBlank(plModel.getName())); + macroLibraries.put("openType", openType); + macroLibraries.put("teamId", teamId); + macroLibraries.put("perms", perms);// 该流程权限(w,d,v) + macroLibraries.put("filePerms", filePerms);// 所有具有权限的流程Id + macroLibraries.put("isPublish", plModel.isPublish()); + macroLibraries.put("isStop", plModel.isStop()); + macroLibraries.put("isApproval", plModel.isApproval()); + macroLibraries.put("ext1", plModel.getExt1()); + macroLibraries.put("ext2", plModel.getExt2()); + macroLibraries.put("ext3", plModel.getExt3()); + macroLibraries.put("ext4", plModel.getExt4()); + macroLibraries.put("isPalManage", CoeProcessLevelUtil.isPalManage()); + CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); + boolean isAdmin = (userModel != null && (userModel.getIsAdmin() == 1)); + macroLibraries.put("isAdmin", isAdmin); + //三员管理,文件密级回显 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + Integer securityLevel = plModel.getSecurityLevel(); + HashMap securityMap = HighSecurityUtil.getObjSecurityMap(); + String securityLevelName = securityMap.get(String.valueOf(securityLevel)); + macroLibraries.put("securityLevelName", securityLevelName == null ? "未标密" : securityLevelName); + macroLibraries.put("isHighSecurity", true); + } + // 更多特性权限 + String moreAttrRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "MOREATTR_RIGHT");// 1普通用户有设置更多特性权限, + if ("2".equals(moreAttrRight)) {// 只有admin显示 + if ("admin".equals(_uc.getUID())) { + macroLibraries.put("moreAttrRight", true); + } else { + macroLibraries.put("moreAttrRight", false); + } + } else if ("0".equals(moreAttrRight)) {// 0只有管理员用户有权限 + if (isAdmin) {// 管理员用户 + macroLibraries.put("moreAttrRight", true); + } else {// 普通用户 + macroLibraries.put("moreAttrRight", false); + } + } else { + macroLibraries.put("moreAttrRight", true); + } - macroLibraries.put("checkoutTip", checkoutTip); - if (plModel.isPublish() || plModel.isStop() || plModel.isApproval()) { - macroLibraries.put("checkoutTip", ""); - } - macroLibraries.put("isView", isView);// 是否只读打开 + macroLibraries.put("checkoutTip", checkoutTip); + if (plModel.isPublish() || plModel.isStop() || plModel.isApproval()) { + macroLibraries.put("checkoutTip", ""); + } + macroLibraries.put("isView", isView);// 是否只读打开 - // 是否允许用户自定义模板,0:不允许;1:允许。 - AppAPI appApi = SDK.getAppAPI(); - String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); - macroLibraries.put("isCustomDefine", isCustomDefine); - macroLibraries.put("openAppType", openAppType == null || "".equals(openAppType) ? "0" : openAppType); + // 是否允许用户自定义模板,0:不允许;1:允许。 + AppAPI appApi = SDK.getAppAPI(); + String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); + macroLibraries.put("isCustomDefine", isCustomDefine); + macroLibraries.put("openAppType", openAppType == null || "".equals(openAppType) ? "0" : openAppType); - //获取是否开启泳道更多特性配置和强制刷新形状属性值 - boolean isLaneAttrConfig = appApi.getPropertyBooleanValue(CoEConstant.APP_ID, "IS_LANE_ATTR_CONFIG", false); - boolean isLaneForceRefreshShapeAttr = appApi.getPropertyBooleanValue(CoEConstant.APP_ID, "IS_LANE_FORCE_REFRESH_SHAPE_ATTR", false); - macroLibraries.put("isLaneAttrConfig", isLaneAttrConfig); - macroLibraries.put("isLaneForceRefreshShapeAttr", isLaneForceRefreshShapeAttr); + //获取是否开启泳道更多特性配置和强制刷新形状属性值 + boolean isLaneAttrConfig = appApi.getPropertyBooleanValue(CoEConstant.APP_ID, "IS_LANE_ATTR_CONFIG", false); + boolean isLaneForceRefreshShapeAttr = appApi.getPropertyBooleanValue(CoEConstant.APP_ID, "IS_LANE_FORCE_REFRESH_SHAPE_ATTR", false); + macroLibraries.put("isLaneAttrConfig", isLaneAttrConfig); + macroLibraries.put("isLaneForceRefreshShapeAttr", isLaneForceRefreshShapeAttr); - if (plModel.isPublish() || isView || plModel.isStop() || plModel.isApproval()) { - macroLibraries.put("editable", "0"); - } else { - macroLibraries.put("editable", "1"); - } + if (plModel.isPublish() || isView || plModel.isStop() || plModel.isApproval()) { + macroLibraries.put("editable", "0"); + } else { + macroLibraries.put("editable", "1"); + } - if (plModel.isPublish() || plModel.isStop() || plModel.isApproval()) { - long viewCount = plModel.getViewCount(); - plModel.setViewCount(viewCount + 1); - PALRepository dao = new PALRepository(); - dao.update(plModel); - } + if (plModel.isPublish() || plModel.isStop() || plModel.isApproval()) { + long viewCount = plModel.getViewCount(); + plModel.setViewCount(viewCount + 1); + PALRepository dao = new PALRepository(); + dao.update(plModel); + } - getDesginerDefaultParams(macroLibraries);// 获取默认参数配置 - // 文件协作者 - if (!plModel.isPublish() && !isView && !plModel.isStop() && !plModel.isApproval()) { - CoeListenCacheManager manager = CoeListenCacheManager.getInstance(); - Map listenClients = manager.getCollaborationUsers(rUUID); - StringBuilder userPhoto = new StringBuilder(); - int userNum = 1; - if (listenClients != null) { - for (ListenClient listenClient : listenClients.values()) { - if (!_uc.getUID().equals(listenClient.getUserId())) { - userPhoto.append(""); - } else { - userNum += listenClient.getUserNum(); - } - } - } - macroLibraries.put("usersPhoto", userPhoto.toString()); - macroLibraries.put("userNum", userNum); - } else { - macroLibraries.put("usersPhoto", ""); - macroLibraries.put("userNum", ""); - } + getDesginerDefaultParams(macroLibraries);// 获取默认参数配置 + // 文件协作者 + if (!plModel.isPublish() && !isView && !plModel.isStop() && !plModel.isApproval()) { + CoeListenCacheManager manager = CoeListenCacheManager.getInstance(); + Map listenClients = manager.getCollaborationUsers(rUUID); + StringBuilder userPhoto = new StringBuilder(); + int userNum = 1; + if (listenClients != null) { + for (ListenClient listenClient : listenClients.values()) { + if (!_uc.getUID().equals(listenClient.getUserId())) { + userPhoto.append(""); + } else { + userNum += listenClient.getUserNum(); + } + } + } + macroLibraries.put("usersPhoto", userPhoto.toString()); + macroLibraries.put("userNum", userNum); + } else { + macroLibraries.put("usersPhoto", ""); + macroLibraries.put("userNum", ""); + } - DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); - Map> shapeMap = relationShapeCache.getShapemap(); - boolean isExistCopy = shapeMap.get(_uc.getUID()) != null; - boolean isAppearCopy = shapeMap.get(_uc.getUID()) == null || shapeMap.get(_uc.getUID()).get("shapeCopyContent") == null; - // 默认为定义复制 - macroLibraries.put("isExistCopy", isExistCopy); - macroLibraries.put("isAppearCopy", isAppearCopy); - // 如果流程只读,获取流程图片信息 - if (!plModel.isPublish() && !isView && !plModel.isStop() && !plModel.isApproval()) { - String p = plModel.getFilePath(); - String diagram = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; - if (isCorrelateBpms) { - diagram = "data:image/png;base64," + BPMNIO.getBPMNImage(appId, processDefId); - } else { - if (!"".equals(p)) { - UtilFile utilFile = new UtilFile(p + "/" + plModel.getId() + ".png"); - if (utilFile.exists()) { - byte[] base64Bytes = Base64.encode(utilFile.readBytes()); - diagram = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); - } - } - } - macroLibraries.put("diagram", diagram); - } else { - macroLibraries.put("diagram", ""); - } - macroLibraries.put("state", state); - // DockBtnBar中的各功能是否显示 - macroLibraries.put("attributeView", ""); - macroLibraries.put("messageView", ""); - macroLibraries.put("printView", ""); - macroLibraries.put("publishView", ""); + DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); + Map> shapeMap = relationShapeCache.getShapemap(); + boolean isExistCopy = shapeMap.get(_uc.getUID()) != null; + boolean isAppearCopy = shapeMap.get(_uc.getUID()) == null || shapeMap.get(_uc.getUID()).get("shapeCopyContent") == null; + // 默认为定义复制 + macroLibraries.put("isExistCopy", isExistCopy); + macroLibraries.put("isAppearCopy", isAppearCopy); + // 如果流程只读,获取流程图片信息 + if (!plModel.isPublish() && !isView && !plModel.isStop() && !plModel.isApproval()) { + String p = plModel.getFilePath(); + String diagram = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; + if (isCorrelateBpms) { + diagram = "data:image/png;base64," + BPMNIO.getBPMNImage(appId, processDefId); + } else { + if (!"".equals(p)) { + UtilFile utilFile = new UtilFile(p + "/" + plModel.getId() + ".png"); + if (utilFile.exists()) { + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + diagram = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); + } + } + } + macroLibraries.put("diagram", diagram); + } else { + macroLibraries.put("diagram", ""); + } + macroLibraries.put("state", state); + // DockBtnBar中的各功能是否显示 + macroLibraries.put("attributeView", ""); + macroLibraries.put("messageView", ""); + macroLibraries.put("printView", ""); + macroLibraries.put("publishView", ""); - if (dockDisplay != null && !"".equals(dockDisplay)) { - JSONObject dockDisplayJson = JSONObject.parseObject(dockDisplay); - Iterator keys = dockDisplayJson.keySet().iterator(); - while (keys.hasNext()) { - String key = keys.next(); - macroLibraries.put(key, dockDisplayJson.get(key)); - } - } - String riskStyle = "display:none;"; - if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.risk") && SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.risk")) { - riskStyle = ""; - } - if (plModel.getMethodId().equals("process.epc") || plModel.getMethodId().equals("process.bpmn2") || plModel.getMethodId().equals("process.flowchart")) { - riskStyle = UtilString.isEmpty(riskStyle) ? "" : "display:none;"; - } else { - riskStyle = "display:none;"; - } - macroLibraries.put("riskStyle", riskStyle); - String processOnIsInstall = "false"; - if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.processon")) { - processOnIsInstall = "true"; - } - String processOnIsActive = "false"; - if (SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.processon")) { - processOnIsActive = "true"; - } - macroLibraries.put("processOnIsInstall", processOnIsInstall); - macroLibraries.put("processOnIsActive", processOnIsActive); - JSONObject relationShapeIds = new JSONObject(); - JSONObject relationShapeModels = new JSONObject(); + if (dockDisplay != null && !"".equals(dockDisplay)) { + JSONObject dockDisplayJson = JSONObject.parseObject(dockDisplay); + Iterator keys = dockDisplayJson.keySet().iterator(); + while (keys.hasNext()) { + String key = keys.next(); + macroLibraries.put(key, dockDisplayJson.get(key)); + } + } + String riskStyle = "display:none;"; + if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.risk") && SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.risk")) { + riskStyle = ""; + } + if (plModel.getMethodId().equals("process.epc") || plModel.getMethodId().equals("process.bpmn2") || plModel.getMethodId().equals("process.flowchart")) { + riskStyle = UtilString.isEmpty(riskStyle) ? "" : "display:none;"; + } else { + riskStyle = "display:none;"; + } + macroLibraries.put("riskStyle", riskStyle); + String processOnIsInstall = "false"; + if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.processon")) { + processOnIsInstall = "true"; + } + String processOnIsActive = "false"; + if (SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.processon")) { + processOnIsActive = "true"; + } + macroLibraries.put("processOnIsInstall", processOnIsInstall); + macroLibraries.put("processOnIsActive", processOnIsActive); + JSONObject relationShapeIds = new JSONObject(); + JSONObject relationShapeModels = new JSONObject(); - - - /*************************************更新当前最新的属性设置 byzhaolei*******************************************************/ + /*************************************更新当前最新的属性设置 byzhaolei*******************************************************/ CoeDesignerShapeAPIManager manager = CoeDesignerShapeAPIManager.getInstance(); - String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, plModel.getId()); - JSONObject definition = JSONObject.parseObject(define); + String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, plModel.getId()); + JSONObject definition = JSONObject.parseObject(define); BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(rUUID, 0); @@ -579,694 +554,690 @@ public class CoeDesignerWeb extends ActionWeb { List sortList = manager.handleShapeAttrSortAndName(definition, plModel.getWsId(), plModel.getMethodId(), attrList); + JSONObject elements = definition.getJSONObject("elements"); + for (String id : elements.keySet()) { + JSONObject shapeObj = elements.getJSONObject(id); + String name = shapeObj.getString("name"); + if ("linker".equals(name)) { + continue; + } + Iterator modelIterator = DesignerShapeRelationCache.getByShapeId(plModel.getId(), id); + if (modelIterator != null) { + while (modelIterator.hasNext()) { + DesignerShapeRelationModel shapeRelationModel = modelIterator.next(); + PALRepositoryModel relationPalModel = PALRepositoryCache.getCache().get(shapeRelationModel.getRelationFileId()); + if (relationPalModel != null) { + relationShapeIds.put(shapeRelationModel.getRelationShapeId(), shapeRelationModel); + } + } + } + Map map = PALRepositoryQueryAPIManager.getInstance().queryRepositoryShapeAttributeById(plModel.getId(), id, shapeObj, "|"); + for (Entry entry : map.entrySet()) { + JSONObject object = entry.getValue(); + if (object == null || object.isEmpty()) { + continue; + } + relationShapeModels.put(id + "_" + entry.getKey(), Arrays.asList(object.getString("text").split("\\|"))); + } + } + macroLibraries.put("relationShapes", relationShapeIds); + macroLibraries.put("relationShapeModels", relationShapeModels); + List defaultAttrSort = new ArrayList<>(); + JSONObject attrDefineObj = new JSONObject(); + List shapeAttrMethods = CoeDesignerShapeAPIManager.getInstance().getAllValidAndUseShapeAttributeModels(plModel.getWsId(), plModel.getMethodId()); + for (PALMethodAttributeModel attrModel : shapeAttrMethods) { + defaultAttrSort.add(attrModel.getKey()); + JSONObject object = new JSONObject(); + object.put("key", attrModel.getKey()); + object.put("name", attrModel.getNewTitle()); + object.put("readonly", attrModel.getReadonly()); + object.put("type", attrModel.getType()); + object.put("desc", attrModel.getDesc() == null ? "" : attrModel.getDesc()); + object.put("isRequired", attrModel.getIsRequired()); + attrDefineObj.put(attrModel.getKey(), object); + } + macroLibraries.put("attrDefineObj", attrDefineObj); + macroLibraries.put("defaultAttrSort", defaultAttrSort.size() > 0 ? StringUtils.join(defaultAttrSort, "|") : ""); + macroLibraries.put("importShapeStyle", "display:none"); + if ("control.policy".equals(plModel.getMethodId()) || "data.form".equals(plModel.getMethodId())) {// 制度/表单活动节点导入 + macroLibraries.put("importShapeStyle", "display:block"); + } + boolean flag1 = "data.form".equals(plModel.getMethodId()) && SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.bd"); + boolean flag2 = "control.policy".equals(plModel.getMethodId()) && SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.zd"); + boolean flag3 = "process".equals(plModel.getMethodCategory()) && !"process.evc".equals(plModel.getMethodId()) && SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.output.pr"); + if (outputPerm && (flag1 || flag2 || flag3) && SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) { + macroLibraries.put("processOutput", true); + } else { + macroLibraries.put("processOutput", false); + } + // 帮助工具栏扩展 + getHelptoolExtUrl(macroLibraries); + // 图形描述 + getMethodObjectDesc(macroLibraries); + // 操作行为日志记录 + 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); + } + // 流程串联分析应用 + getPalProcessLinkTag(plModel, macroLibraries); + if (!plModel.isPublish() && !isView && !plModel.isStop() && !plModel.isApproval()) { + // 集群节点 + macroLibraries.put("BPMInstanceName", SDK.getConfAPI().getInstanceName()); + macroLibraries.put("isCollaborationSwitch", SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "isCollaborationSwitch", false)); + // 是否开启同名校验 + macroLibraries.put("sameNameCheck", SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "SAME_NAME_CHECK", false)); + // 批处理应用 + getPalBatchTag(plModel, macroLibraries); + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.htm", macroLibraries); + } else { + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.html", macroLibraries); + } + } + /** + * 获取形状描述定义 + * + * @param macroLibraries + */ + private void getMethodObjectDesc(Map macroLibraries) { + JSONObject result = new JSONObject(); + JSONObject methodObjectDesc = SDK.getAppAPI().getPropertyJSONObjectValue(CoEConstant.APP_ID, "METHOD_OBJECT_DESC", new JSONObject()); + for (String methodId : methodObjectDesc.keySet()) { + for (String shapeName : methodObjectDesc.getJSONObject(methodId).keySet()) { + JSONObject shapeObj = methodObjectDesc.getJSONObject(methodId).getJSONObject(shapeName); + if (shapeObj.containsKey("desc")) { + String desc = shapeObj.getString("desc"); + if (desc != null && !"".equals(desc.trim())) { + result.put(methodId + '-' + shapeName, desc); + } + } + } + } + macroLibraries.put("methodObjectDesc", result); + } + /** + * 帮助工具栏扩展 + * + * @param macroLibraries + */ + private void getHelptoolExtUrl(Map macroLibraries) { + JSONArray propVal = SDK.getAppAPI().getPropertyJSONArrayValue(CoEConstant.APP_ID, "CUSTOM_HELP_TOOL_EXT_MENU_URL"); + macroLibraries.put("customHelpToolExtMenuUrl", propVal); + } - JSONObject elements = definition.getJSONObject("elements"); - for (String id: elements.keySet()) { - JSONObject shapeObj = elements.getJSONObject(id); - String name = shapeObj.getString("name"); - if ("linker".equals(name)) { - continue; - } - Iterator modelIterator = DesignerShapeRelationCache.getByShapeId(plModel.getId(), id); - if (modelIterator != null) { - while (modelIterator.hasNext()) { - DesignerShapeRelationModel shapeRelationModel = modelIterator.next(); - PALRepositoryModel relationPalModel = PALRepositoryCache.getCache().get(shapeRelationModel.getRelationFileId()); - if (relationPalModel != null) { - relationShapeIds.put(shapeRelationModel.getRelationShapeId(), shapeRelationModel); - } - } - } - Map map = PALRepositoryQueryAPIManager.getInstance().queryRepositoryShapeAttributeById(plModel.getId(), id, shapeObj, "|"); - for (Entry entry : map.entrySet()) { - JSONObject object = entry.getValue(); - if (object == null || object.isEmpty()) { - continue; - } - relationShapeModels.put(id + "_" + entry.getKey(), Arrays.asList(object.getString("text").split("\\|"))); - } - } + // 串联分析应用片段 + public void getPalProcessLinkTag(PALRepositoryModel plModel, Map macroLibraries) { + String processlinkAppId = "com.actionsoft.apps.coe.pal.processlink"; + String processlink_ete_js = ""; + String processlink_ete_analysis = ""; - macroLibraries.put("relationShapes", relationShapeIds); - macroLibraries.put("relationShapeModels", relationShapeModels); + if ("process".equals(plModel.getMethodCategory()) && SDK.getAppAPI().isInstalled(processlinkAppId) && SDK.getAppAPI().isActive(processlinkAppId)) { + processlink_ete_js = ""; + processlink_ete_js += ""; + //滚动条 + processlink_ete_js += ""; + processlink_ete_js += ""; + processlink_ete_js += ""; + processlink_ete_js += ""; + //文件的串联分析 + processlink_ete_analysis = + "
" + + "
" + + "" + + "
" + + "
"; + } + macroLibraries.put("processlink_ete_js", processlink_ete_js); + macroLibraries.put("processlink_ete_analysis", processlink_ete_analysis); + } - List defaultAttrSort = new ArrayList<>(); - JSONObject attrDefineObj = new JSONObject(); - List shapeAttrMethods = CoeDesignerShapeAPIManager.getInstance().getAllValidAndUseShapeAttributeModels(plModel.getWsId(), plModel.getMethodId()); - for (PALMethodAttributeModel attrModel : shapeAttrMethods) { - defaultAttrSort.add(attrModel.getKey()); - JSONObject object = new JSONObject(); - object.put("key", attrModel.getKey()); - object.put("name", attrModel.getNewTitle()); - object.put("readonly", attrModel.getReadonly()); - object.put("type", attrModel.getType()); + // 批量处理相关片段 + public void getPalBatchTag(PALRepositoryModel plModel, Map macroLibraries) { + String batchDlg = ""; + String batchJs = ""; + boolean installBatch = false;// 是否安装该批处理应用 + String appId = "com.actionsoft.apps.coe.pal.batch"; + if ("process".equals(plModel.getMethodCategory()) && SDK.getAppAPI().isInstalled(appId) && SDK.getAppAPI().isActive(appId)) { + batchDlg = HtmlPageTemplate.merge(appId, "batch.dialog.htm", null); + Map jsMap = new HashMap<>(); + jsMap.put("appId", appId); + batchJs = HtmlPageTemplate.merge(appId, "batch.link.htm", jsMap); + installBatch = true; + } + macroLibraries.put("batch-dlg", batchDlg); + macroLibraries.put("batch-js", batchJs); + macroLibraries.put("installBatch", installBatch); + } - object.put("desc", attrModel.getDesc()==null ? "" : attrModel.getDesc()); - object.put("isRequired", attrModel.getIsRequired()); - attrDefineObj.put(attrModel.getKey(), object); - } - macroLibraries.put("attrDefineObj", attrDefineObj); - macroLibraries.put("defaultAttrSort", defaultAttrSort.size() > 0 ? StringUtils.join(defaultAttrSort, "|") : ""); - macroLibraries.put("importShapeStyle", "display:none"); - if ("control.policy".equals(plModel.getMethodId()) || "data.form".equals(plModel.getMethodId())) {// 制度/表单活动节点导入 - macroLibraries.put("importShapeStyle", "display:block"); - } - boolean flag1 = "data.form".equals(plModel.getMethodId()) && SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.bd"); - boolean flag2 = "control.policy".equals(plModel.getMethodId()) && SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.zd"); - boolean flag3 = "process".equals(plModel.getMethodCategory()) && !"process.evc".equals(plModel.getMethodId()) && SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.output.pr"); - if (outputPerm && (flag1 || flag2 || flag3) && SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) { - macroLibraries.put("processOutput", true); - } else { - macroLibraries.put("processOutput", false); - } - // 帮助工具栏扩展 - getHelptoolExtUrl(macroLibraries); - // 图形描述 - getMethodObjectDesc(macroLibraries); - // 操作行为日志记录 - 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); - } - // 流程串联分析应用 - getPalProcessLinkTag(plModel, macroLibraries); - if (!plModel.isPublish() && !isView && !plModel.isStop() && !plModel.isApproval()) { - // 集群节点 - macroLibraries.put("BPMInstanceName", SDK.getConfAPI().getInstanceName()); - macroLibraries.put("isCollaborationSwitch", SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "isCollaborationSwitch", false)); - // 是否开启同名校验 - macroLibraries.put("sameNameCheck", SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "SAME_NAME_CHECK", false)); - // 批处理应用 - getPalBatchTag(plModel, macroLibraries); - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.htm", macroLibraries); - } else { - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.html", macroLibraries); - } - } + protected String getMoreSharpe(String methodId, String uuid, Map macroLibraries) { + StringBuffer div = new StringBuffer(); + if (!PALMethodUtil.haveImport(methodId)) { + macroLibraries.put("btnShapeStyle", "display:none;"); + } else { + macroLibraries.put("btnShapeStyle", ""); + } + macroLibraries.put("liStr", PALMethodUtil.getShapeDialog(methodId, PALMethodUtil.getCustom(methodId, uuid))); + return div.toString(); + } - /** - * 获取形状描述定义 - * @param macroLibraries - */ - private void getMethodObjectDesc(Map macroLibraries) { - JSONObject result = new JSONObject(); - JSONObject methodObjectDesc = SDK.getAppAPI().getPropertyJSONObjectValue(CoEConstant.APP_ID, "METHOD_OBJECT_DESC", new JSONObject()); - for (String methodId : methodObjectDesc.keySet()) { - for (String shapeName : methodObjectDesc.getJSONObject(methodId).keySet()) { - JSONObject shapeObj = methodObjectDesc.getJSONObject(methodId).getJSONObject(shapeName); - if (shapeObj.containsKey("desc")) { - String desc = shapeObj.getString("desc"); - if (desc != null && !"".equals(desc.trim())) { - result.put(methodId + '-' + shapeName, desc); - } - } - } - } - macroLibraries.put("methodObjectDesc", result); - } + /** + * 流程id + * + * @param id + * @return + */ + public String toPalRepositoryPrint(String id) { + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(id); + if (plModel == null) { + return SDK.getPortalAPI().getMessagePageOfError("流程未定义", "id:" + id); + } + boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(id, true); + Map macroLibraries = new HashMap(); + String appId = ""; + String diagram = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; + String heightStyle = ""; + String palTitle = ""; + String version = ""; + String processDefId = ""; + String p = plModel.getFilePath(); + if (isCorrelateBpms) { + processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(id, true); + appId = ProcessDefCache.getInstance().get(processDefId).getAppId(); + diagram = "data:image/png;base64," + BPMNIO.getBPMNImage(appId, processDefId); + } else { + if (p != null && !"".equals(p)) { + PALRepositoryQueryAPIManager.getInstance().checkImage(plModel.getId(), true, false);// 生成图片 + UtilFile utilFile = new UtilFile(p + "/" + plModel.getId() + ".png"); + if (utilFile.exists()) { + BufferedImage sourceImg; + try { + sourceImg = ImageIO.read(utilFile); + if (sourceImg != null) { + int height = sourceImg.getHeight(); + if (height > 600 && height < 1000) { + heightStyle = "height: 600px;"; + } + } else { + heightStyle = "height: 600px;"; + } + } catch (IOException e) { + e.printStackTrace(); + } + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + diagram = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); + } + } + } + palTitle = plModel.getName(); + version = "V" + plModel.getVersion(); + macroLibraries.put("diagram", diagram); + macroLibraries.put("heightStyle", heightStyle); + macroLibraries.put("palTitle", palTitle); + macroLibraries.put("version", version); + macroLibraries.put("sid", _uc.getSessionId()); + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.print.html", macroLibraries); + } - /** - * 帮助工具栏扩展 - * @param macroLibraries - */ - private void getHelptoolExtUrl(Map macroLibraries) { - JSONArray propVal = SDK.getAppAPI().getPropertyJSONArrayValue(CoEConstant.APP_ID, "CUSTOM_HELP_TOOL_EXT_MENU_URL"); - macroLibraries.put("customHelpToolExtMenuUrl", propVal); - } + /** + * 获取aws的bpmn的define + * + * @param appId + * @param processDefId + * @param verNo + * @return + */ + protected String getDefineOfAws(String appId, String processDefId, int verNo) { + String data = ""; + if (processDefId.length() > 0) { + BPMNFile bpmnFile = BPMNFile.getInstance(appId, processDefId); + Definitions definitions = null; + try { + definitions = bpmnFile.parseBPMN(null, verNo); + } catch (BPMNDefException e) { + return BPMNErrorUtil.getErrorJSON(e); + } catch (Exception e) { + return BPMNErrorUtil.getErrorJSON(e); + } + data = new BpmnToJson().getJsonString(definitions); + } + JSONObject define = JSONObject.parseObject(data); + return define.toString(); + } - // 串联分析应用片段 - public void getPalProcessLinkTag(PALRepositoryModel plModel, Map macroLibraries) { - String processlinkAppId = "com.actionsoft.apps.coe.pal.processlink"; - String processlink_ete_js = ""; - String processlink_ete_analysis = ""; + protected void getLinker(BaseModel model, Map macroLibraries) { + // String methodId = model.getMethodId(); + List methodList = PALMethodCache.getPALMethodList(); + List> list = new ArrayList>(); + for (String methodTemp : methodList) { + List methodIdList = PALMethodCache.getPALMethodModelListByMethod(methodTemp); + for (PALMethodModel methodObj : methodIdList) { + // PALMethodModel palMethodModel = + // PALMethodCache.getPALMethodModelById(methodId); + List linker = methodObj.getLinker(); + for (PALMethodLinkerModel method : linker) { + Map m = new HashMap(); + m.put("methodId", method.getMethodId()); + m.put("conceptCode", method.getConceptCode()); + m.put("fromShapeId", method.getFromShapeId()); + m.put("toShapeId", method.getToShapeId()); + m.put("outcomingName", method.getOutcomingName()); + m.put("incomingName", method.getIncomingName()); + list.add(m); + } + } + } + JSONArray linkerRelationshipJsonArray = JSONArray.parseArray(JSON.toJSONString(list)); + macroLibraries.put("linkerRelationship", linkerRelationshipJsonArray); + } - if ("process".equals(plModel.getMethodCategory()) && SDK.getAppAPI().isInstalled(processlinkAppId) && SDK.getAppAPI().isActive(processlinkAppId)) { - processlink_ete_js = ""; - processlink_ete_js += ""; - //滚动条 - processlink_ete_js += ""; - processlink_ete_js += ""; - processlink_ete_js += ""; - processlink_ete_js += ""; - //文件的串联分析 - processlink_ete_analysis = - "
" - + "
" - + "" - + "
" - + "
" ; - } - macroLibraries.put("processlink_ete_js", processlink_ete_js); - macroLibraries.put("processlink_ete_analysis", processlink_ete_analysis); - } + protected void getDesginerDefaultParams(Map macroLibraries) { + macroLibraries.put("BPMN_TYPE_START_EVENT", BPMNConstant.BPMN_TYPE_START_EVENT); + macroLibraries.put("AWS_ELEMENT_START_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_START_EVENT_MESSAGE_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_START_EVENT_TIMER_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_START_EVENT_TIMER_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_START_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_START_EVENT_SIGNAL_EVENT_DEFINITION); + macroLibraries.put("BPMN_TYPE_END_EVENT", BPMNConstant.BPMN_TYPE_END_EVENT); + macroLibraries.put("AWS_ELEMENT_END_EVENT_TERMINATE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_TERMINATE_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_END_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_MESSAGE_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_END_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_SIGNAL_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_END_EVENT_ERROR_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_ERROR_EVENT_DEFINITION); + macroLibraries.put("BPMN_TYPE_SEQUENCE_FLOW", BPMNConstant.BPMN_TYPE_SEQUENCE_FLOW); + macroLibraries.put("BPMN_TYPE_TASK", BPMNConstant.BPMN_TYPE_TASK); + macroLibraries.put("BPMN_TYPE_USER_TASK", BPMNConstant.BPMN_TYPE_USER_TASK); + macroLibraries.put("BPMN_TYPE_SERVICE_TASK", BPMNConstant.BPMN_TYPE_SERVICE_TASK); + macroLibraries.put("BPMN_TYPE_SCRIPT_TASK", BPMNConstant.BPMN_TYPE_SCRIPT_TASK); + macroLibraries.put("BPMN_TYPE_MANUAL_TASK", BPMNConstant.BPMN_TYPE_MANUAL_TASK); + macroLibraries.put("BPMN_TYPE_BUSINESSRULE_TASK", BPMNConstant.BPMN_TYPE_BUSINESSRULE_TASK); + macroLibraries.put("BPMN_TYPE_SEND_TASK", BPMNConstant.BPMN_TYPE_SEND_TASK); + macroLibraries.put("BPMN_TYPE_RECEIVE_TASK", BPMNConstant.BPMN_TYPE_RECEIVE_TASK); + macroLibraries.put("BPMN_TYPE_GATEWAY", BPMNConstant.BPMN_TYPE_GATEWAY); + macroLibraries.put("BPMN_TYPE_EVENTBASED_GATEWAY", BPMNConstant.BPMN_TYPE_EVENTBASED_GATEWAY); + macroLibraries.put("BPMN_TYPE_COMPLEX_GATEWAY", BPMNConstant.BPMN_TYPE_COMPLEX_GATEWAY); + macroLibraries.put("BPMN_TYPE_INTERMEDIATE_CATCH_EVENT", BPMNConstant.BPMN_TYPE_INTERMEDIATE_CATCH_EVENT); + macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_TIMER_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_TIMER_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_MESSAGE_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_SIGNAL_EVENT_DEFINITION); + macroLibraries.put("BPMN_TYPE_INTERMEDIATE_THROW_EVENT", BPMNConstant.BPMN_TYPE_INTERMEDIATE_THROW_EVENT); + macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_MESSAGE_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_SIGNAL_EVENT_DEFINITION); + macroLibraries.put("BPMN_TYPE_BOUNDARY_EVENT", BPMNConstant.BPMN_TYPE_BOUNDARY_EVENT); + macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_COMPENSATION_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_COMPENSATE_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_ERROR_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_ERROR_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_MESSAGE_EVENT_DEFINITION); + macroLibraries.put("BPMN_TYPE_PARALLEL_GATEWAY", BPMNConstant.BPMN_TYPE_PARALLEL_GATEWAY); + macroLibraries.put("BPMN_TYPE_INCLUSIVE_GATEWAY", BPMNConstant.BPMN_TYPE_INCLUSIVE_GATEWAY); + macroLibraries.put("BPMN_TYPE_EXCLUSIVE_GATEWAY", BPMNConstant.BPMN_TYPE_EXCLUSIVE_GATEWAY); + macroLibraries.put("BPMN_TYPE_CALL_ACTIVITY_CALLING_PROCESS", BPMNConstant.BPMN_TYPE_CALL_ACTIVITY_CALLING_PROCESS); + macroLibraries.put("BPMN_TYPE_SUB_PROCESS", BPMNConstant.BPMN_TYPE_SUB_PROCESS); + macroLibraries.put("BPMN_TYPE_TEXT_ANNOTATION", BPMNConstant.BPMN_TYPE_TEXT_ANNOTATION); + macroLibraries.put("BPMN_TYPE_HORIZONTAL_POOL", BPMNConstant.BPMN_TYPE_POOL); + macroLibraries.put("BPMN_TYPE_VERTICAL_POOL", BPMNConstant.BPMN_TYPE_VERTICAL_POOL); + macroLibraries.put("BPMN_TYPE_HORIZONTAL_LANE", BPMNConstant.BPMN_TYPE_LANE); + macroLibraries.put("BPMN_TYPE_VERTICAL_LANE", BPMNConstant.BPMN_TYPE_VERTICAL_LANE); + // + macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_SIGNAL_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_TIMER_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_TIMER_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_COMPENSATE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_COMPENSATE_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_END_EVENT_COMPENSATE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_COMPENSATE_EVENT_DEFINITION); + macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_COMPENSATE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_COMPENSATE_EVENT_DEFINITION); - // 批量处理相关片段 - public void getPalBatchTag(PALRepositoryModel plModel, Map macroLibraries) { - String batchDlg = ""; - String batchJs = ""; - boolean installBatch = false;// 是否安装该批处理应用 - String appId = "com.actionsoft.apps.coe.pal.batch"; - if ("process".equals(plModel.getMethodCategory()) && SDK.getAppAPI().isInstalled(appId) && SDK.getAppAPI().isActive(appId)) { - batchDlg = HtmlPageTemplate.merge(appId, "batch.dialog.htm", null); - Map jsMap = new HashMap<>(); - jsMap.put("appId", appId); - batchJs = HtmlPageTemplate.merge(appId, "batch.link.htm", jsMap); - installBatch = true; - } - macroLibraries.put("batch-dlg", batchDlg); - macroLibraries.put("batch-js", batchJs); - macroLibraries.put("installBatch", installBatch); - } + } - protected String getMoreSharpe(String methodId, String uuid, Map macroLibraries) { - StringBuffer div = new StringBuffer(); - if (!PALMethodUtil.haveImport(methodId)) { - macroLibraries.put("btnShapeStyle", "display:none;"); - } else { - macroLibraries.put("btnShapeStyle", ""); - } - macroLibraries.put("liStr", PALMethodUtil.getShapeDialog(methodId, PALMethodUtil.getCustom(methodId, uuid))); - return div.toString(); - } + protected List getCoeParams(PALRepositoryModel plModel, Map macroLibraries) { + // coe所需参数 + String uuid = plModel.getId(); + String versionUuid = plModel.getVersionId(); + String fileName = ShapeUtil.replaceBlank(plModel.getName()); + String wsid = plModel.getWsId(); + String methodId = plModel.getMethodId(); + BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); + if (model == null) { + model = CoeDesignerUtil.createModel(uuid, 0); + } + List sortList; + CoeDesignerShapeAPIManager manager = CoeDesignerShapeAPIManager.getInstance(); + String define = model.getDefinition(); - /** - * 流程id - * - * @param id - * @return - */ - public String toPalRepositoryPrint(String id) { - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(id); - if (plModel == null) { - return SDK.getPortalAPI().getMessagePageOfError("流程未定义", "id:" + id); - } - boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(id, true); - Map macroLibraries = new HashMap(); - String appId = ""; - String diagram = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; - String heightStyle = ""; - String palTitle = ""; - String version = ""; - String processDefId = ""; - String p = plModel.getFilePath(); - if (isCorrelateBpms) { - processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(id, true); - appId = ProcessDefCache.getInstance().get(processDefId).getAppId(); - diagram = "data:image/png;base64," + BPMNIO.getBPMNImage(appId, processDefId); - } else { - if (p != null && !"".equals(p)) { - PALRepositoryQueryAPIManager.getInstance().checkImage(plModel.getId(), true, false);// 生成图片 - UtilFile utilFile = new UtilFile(p + "/" + plModel.getId() + ".png"); - if (utilFile.exists()) { - BufferedImage sourceImg; - try { - sourceImg = ImageIO.read(utilFile); - if (sourceImg != null) { - int height = sourceImg.getHeight(); - if (height > 600 && height < 1000) { - heightStyle = "height: 600px;"; - } - } else { - heightStyle = "height: 600px;"; - } - } catch (IOException e) { - e.printStackTrace(); - } - byte[] base64Bytes = Base64.encode(utilFile.readBytes()); - diagram = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); - } - } - } - palTitle = plModel.getName(); - version = "V" + plModel.getVersion(); - macroLibraries.put("diagram", diagram); - macroLibraries.put("heightStyle", heightStyle); - macroLibraries.put("palTitle", palTitle); - macroLibraries.put("version", version); - macroLibraries.put("sid", _uc.getSessionId()); - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.print.html", macroLibraries); - } + //获取流程定义和排序 + JSONObject object = manager.getCoeDefinitionAndSort(define, wsid, methodId); - /** - * 获取aws的bpmn的define - * - * @param appId - * @param processDefId - * @param verNo - * @return - */ - protected String getDefineOfAws(String appId, String processDefId, int verNo) { - String data = ""; - if (processDefId.length() > 0) { - BPMNFile bpmnFile = BPMNFile.getInstance(appId, processDefId); - Definitions definitions = null; - try { - definitions = bpmnFile.parseBPMN(null, verNo); - } catch (BPMNDefException e) { - return BPMNErrorUtil.getErrorJSON(e); - } catch (Exception e) { - return BPMNErrorUtil.getErrorJSON(e); - } - data = new BpmnToJson().getJsonString(definitions); - } - JSONObject define = JSONObject.parseObject(data); - return define.toString(); - } + model.setDefinition(object.getString("define")); - protected void getLinker(BaseModel model, Map macroLibraries) { - // String methodId = model.getMethodId(); - List methodList = PALMethodCache.getPALMethodList(); - List> list = new ArrayList>(); - for (String methodTemp : methodList) { - List methodIdList = PALMethodCache.getPALMethodModelListByMethod(methodTemp); - for (PALMethodModel methodObj : methodIdList) { - // PALMethodModel palMethodModel = - // PALMethodCache.getPALMethodModelById(methodId); - List linker = methodObj.getLinker(); - for (PALMethodLinkerModel method : linker) { - Map m = new HashMap(); - m.put("methodId", method.getMethodId()); - m.put("conceptCode", method.getConceptCode()); - m.put("fromShapeId", method.getFromShapeId()); - m.put("toShapeId", method.getToShapeId()); - m.put("outcomingName", method.getOutcomingName()); - m.put("incomingName", method.getIncomingName()); - list.add(m); - } - } - } - JSONArray linkerRelationshipJsonArray = JSONArray.parseArray(JSON.toJSONString(list)); - macroLibraries.put("linkerRelationship", linkerRelationshipJsonArray); - } + sortList = (List) object.get("sort"); - protected void getDesginerDefaultParams(Map macroLibraries) { - macroLibraries.put("BPMN_TYPE_START_EVENT", BPMNConstant.BPMN_TYPE_START_EVENT); - macroLibraries.put("AWS_ELEMENT_START_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_START_EVENT_MESSAGE_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_START_EVENT_TIMER_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_START_EVENT_TIMER_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_START_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_START_EVENT_SIGNAL_EVENT_DEFINITION); - macroLibraries.put("BPMN_TYPE_END_EVENT", BPMNConstant.BPMN_TYPE_END_EVENT); - macroLibraries.put("AWS_ELEMENT_END_EVENT_TERMINATE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_TERMINATE_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_END_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_MESSAGE_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_END_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_SIGNAL_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_END_EVENT_ERROR_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_ERROR_EVENT_DEFINITION); - macroLibraries.put("BPMN_TYPE_SEQUENCE_FLOW", BPMNConstant.BPMN_TYPE_SEQUENCE_FLOW); - macroLibraries.put("BPMN_TYPE_TASK", BPMNConstant.BPMN_TYPE_TASK); - macroLibraries.put("BPMN_TYPE_USER_TASK", BPMNConstant.BPMN_TYPE_USER_TASK); - macroLibraries.put("BPMN_TYPE_SERVICE_TASK", BPMNConstant.BPMN_TYPE_SERVICE_TASK); - macroLibraries.put("BPMN_TYPE_SCRIPT_TASK", BPMNConstant.BPMN_TYPE_SCRIPT_TASK); - macroLibraries.put("BPMN_TYPE_MANUAL_TASK", BPMNConstant.BPMN_TYPE_MANUAL_TASK); - macroLibraries.put("BPMN_TYPE_BUSINESSRULE_TASK", BPMNConstant.BPMN_TYPE_BUSINESSRULE_TASK); - macroLibraries.put("BPMN_TYPE_SEND_TASK", BPMNConstant.BPMN_TYPE_SEND_TASK); - macroLibraries.put("BPMN_TYPE_RECEIVE_TASK", BPMNConstant.BPMN_TYPE_RECEIVE_TASK); - macroLibraries.put("BPMN_TYPE_GATEWAY", BPMNConstant.BPMN_TYPE_GATEWAY); - macroLibraries.put("BPMN_TYPE_EVENTBASED_GATEWAY", BPMNConstant.BPMN_TYPE_EVENTBASED_GATEWAY); - macroLibraries.put("BPMN_TYPE_COMPLEX_GATEWAY", BPMNConstant.BPMN_TYPE_COMPLEX_GATEWAY); - macroLibraries.put("BPMN_TYPE_INTERMEDIATE_CATCH_EVENT", BPMNConstant.BPMN_TYPE_INTERMEDIATE_CATCH_EVENT); - macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_TIMER_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_TIMER_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_MESSAGE_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_CATCH_EVENT_SIGNAL_EVENT_DEFINITION); - macroLibraries.put("BPMN_TYPE_INTERMEDIATE_THROW_EVENT", BPMNConstant.BPMN_TYPE_INTERMEDIATE_THROW_EVENT); - macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_MESSAGE_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_SIGNAL_EVENT_DEFINITION); - macroLibraries.put("BPMN_TYPE_BOUNDARY_EVENT", BPMNConstant.BPMN_TYPE_BOUNDARY_EVENT); - macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_COMPENSATION_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_COMPENSATE_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_ERROR_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_ERROR_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_MESSAGE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_MESSAGE_EVENT_DEFINITION); - macroLibraries.put("BPMN_TYPE_PARALLEL_GATEWAY", BPMNConstant.BPMN_TYPE_PARALLEL_GATEWAY); - macroLibraries.put("BPMN_TYPE_INCLUSIVE_GATEWAY", BPMNConstant.BPMN_TYPE_INCLUSIVE_GATEWAY); - macroLibraries.put("BPMN_TYPE_EXCLUSIVE_GATEWAY", BPMNConstant.BPMN_TYPE_EXCLUSIVE_GATEWAY); - macroLibraries.put("BPMN_TYPE_CALL_ACTIVITY_CALLING_PROCESS", BPMNConstant.BPMN_TYPE_CALL_ACTIVITY_CALLING_PROCESS); - macroLibraries.put("BPMN_TYPE_SUB_PROCESS", BPMNConstant.BPMN_TYPE_SUB_PROCESS); - macroLibraries.put("BPMN_TYPE_TEXT_ANNOTATION", BPMNConstant.BPMN_TYPE_TEXT_ANNOTATION); - macroLibraries.put("BPMN_TYPE_HORIZONTAL_POOL", BPMNConstant.BPMN_TYPE_POOL); - macroLibraries.put("BPMN_TYPE_VERTICAL_POOL", BPMNConstant.BPMN_TYPE_VERTICAL_POOL); - macroLibraries.put("BPMN_TYPE_HORIZONTAL_LANE", BPMNConstant.BPMN_TYPE_LANE); - macroLibraries.put("BPMN_TYPE_VERTICAL_LANE", BPMNConstant.BPMN_TYPE_VERTICAL_LANE); - // - macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_SIGNAL_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_SIGNAL_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_TIMER_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_TIMER_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_BOUNDARY_EVENT_COMPENSATE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_BOUNDARY_EVENT_COMPENSATE_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_END_EVENT_COMPENSATE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_END_EVENT_COMPENSATE_EVENT_DEFINITION); - macroLibraries.put("AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_COMPENSATE_EVENT_DEFINITION", BPMNConstant.AWS_ELEMENT_INTERMEDIATE_THROW_EVENT_COMPENSATE_EVENT_DEFINITION); + //处理流程节点形状的通用配置 + JSONObject obj = manager.getCoeProcessShapeConfig(model.getDefinition(), wsid, methodId, uuid); + model.setDefinition(obj.getString("define")); - } + model.setFileName(fileName); + putCoeProterties(model); + macroLibraries.put("charId", uuid); + macroLibraries.put("versionUuid", versionUuid); + macroLibraries.put("ver", 0); + macroLibraries.put("fileName", fileName); + macroLibraries.put("versionNum", VersionUtil.showVer(plModel.getVersion())); + macroLibraries.put("appId", ""); + macroLibraries.put("processDefId", ""); + macroLibraries.put("processVersion", ""); + macroLibraries.put("processDefVersionId", ""); + macroLibraries.put("processName", ""); + macroLibraries.put("processGroupName", ""); + macroLibraries.put("categoryName", ""); + macroLibraries.put("define", model.getDefinition()); + macroLibraries.put("isRunning", ""); + macroLibraries.put("type", CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT); + getLinker(model, macroLibraries); + return sortList; + } - protected List getCoeParams(PALRepositoryModel plModel, Map macroLibraries) { - // coe所需参数 - String uuid = plModel.getId(); - String versionUuid = plModel.getVersionId(); - String fileName = ShapeUtil.replaceBlank(plModel.getName()); - String wsid = plModel.getWsId(); - String methodId = plModel.getMethodId(); - BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); - if (model == null) { - model = CoeDesignerUtil.createModel(uuid, 0); - } - List sortList; - CoeDesignerShapeAPIManager manager = CoeDesignerShapeAPIManager.getInstance(); - String define = model.getDefinition(); + // 获取是否可以检出状态所需字段 + private void setCheckoutHashMap(String appId, String processDefId, Map macroLibraries) { + if ("".equals(processDefId)) { + return; + } + macroLibraries.put("checkoutstate", BPMNDesignerConstant.BPMN_DESIGNER_CHECKOUT_CHECKOUTING); + macroLibraries.put("checkoutuser", DesignerFileUtil.getCheckOutUser(appId, processDefId)); + macroLibraries.put("checkoutusername", getUserName(DesignerFileUtil.getCheckOutUser(appId, processDefId))); + macroLibraries.put("checkouttime", UtilDate.getAliasDatetime(DesignerFileUtil.getCheckOutTime(appId, processDefId))); + macroLibraries.put("checkoutip", DesignerFileUtil.getCheckOutIP(appId, processDefId)); + macroLibraries.put("user", getContext().getUID()); + UserModel model = UserCache.getModel(getContext().getUID()); + macroLibraries.put("currentUserName", model.getUserName()); + } - //获取流程定义和排序 - JSONObject object = manager.getCoeDefinitionAndSort(define, wsid, methodId); + protected List getBpmnParams(PALRepositoryModel plModel, String processDefId, Map macroLibraries) { + // coe所需参数 + String uuid = plModel.getId(); + String versionUuid = ""; + String fileName = ""; + String wsid = plModel.getWsId(); + String methodId = plModel.getMethodId(); - model.setDefinition(object.getString("define")); + // 流程所需参数 + String appId = ""; + String processDefVersionId = "";// 流程版本id + int processVersion = 0;// 流程版本号 + String processName = "";// 流程名称 + String processGroupName = "";// 流程组名称 + String categoryName = "";// 分类 - sortList = (List) object.get("sort"); + int versionStatus = 0; + String isRunning = ""; + String define = ""; + ProcessDefinition processModel = null; + BPMNModel model = CoeDesignerUtil.createBPMNModel(uuid, 0); + if (!UtilString.isEmpty(processDefId)) { // 关联或者推送到console + processModel = ProcessDefCache.getInstance().getModel(processDefId); + if (processModel == null) {// 资源在console中被删除的情况,从coe中获取数据 + model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); + if (model == null) { + define = CoeDesignerUtil.getTemplateOfDefine(uuid); + } else { + define = model.getDefinition(); + } + } else { // 资源在console中未被删除的情况,从console中获取数据 + CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); + define = coeAdapter.readDefinition(appId = processModel.getAppId(), processDefId).toString(); + // 替换真实类型 + try { + JSONObject defineObj = JSONObject.parseObject(define); + JSONObject eleObj = defineObj.getJSONObject("elements"); + Iterator> eleIt = eleObj.entrySet().iterator(); + while (eleIt.hasNext()) { + Entry entry = eleIt.next(); + JSONObject entryVal = (JSONObject) entry.getValue(); + if ("linker".equals(entryVal.getString("name"))) { + continue; + } + String typeTitleName = PALRepositoryQueryAPIManager.getInstance().shapePropertyType(entryVal.getString("name")); + entryVal.put("title", typeTitleName); + } + define = JSONObject.toJSONString(defineObj); + } catch (Exception e) { + e.printStackTrace(); + } + // + processDefVersionId = processModel.getVersionId(); + processVersion = processModel.getVersionNo(); + processName = processModel.getName(); + processGroupName = processModel.getProcessGroupName(); + categoryName = processModel.getCategoryName(); + versionStatus = processModel.getVersionStatus(); + fileName = ShapeUtil.replaceBlank(processName); + model.setAppId(processModel.getAppId()); + appId = model.getAppId(); + } + } else { // 没有关联console + model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); + if (model == null) { + define = CoeDesignerUtil.getTemplateOfDefine(uuid); + } else { + define = model.getDefinition(); + } + } + versionUuid = plModel.getVersionId(); + if (versionStatus == ProcessDefinitionConst.VERSION_STATUS_RELEASE) {// 如果已经发布,则标注role为running,供设计器判断操作使用 + isRunning = "role = \"running\""; + } + CoeDesignerShapeAPIManager manager = CoeDesignerShapeAPIManager.getInstance(); + //获取流程定义和排序 + JSONObject object = manager.getBpmnDefinitionAndSort(define, wsid, methodId); - //处理流程节点形状的通用配置 - JSONObject obj = manager.getCoeProcessShapeConfig(model.getDefinition(), wsid, methodId, uuid); - model.setDefinition(obj.getString("define")); + define = object.getString("define"); + List sortList = (List) object.get("sort"); + //处理流程节点形状的通用配置 + JSONObject obj = manager.getCoeProcessShapeConfig(define, wsid, methodId, uuid); + define = obj.getString("define"); - model.setFileName(fileName); - putCoeProterties(model); - macroLibraries.put("charId", uuid); - macroLibraries.put("versionUuid", versionUuid); - macroLibraries.put("ver", 0); - macroLibraries.put("fileName", fileName); - macroLibraries.put("versionNum", VersionUtil.showVer(plModel.getVersion())); - macroLibraries.put("appId", ""); - macroLibraries.put("processDefId", ""); - macroLibraries.put("processVersion", ""); - macroLibraries.put("processDefVersionId", ""); - macroLibraries.put("processName", ""); - macroLibraries.put("processGroupName", ""); - macroLibraries.put("categoryName", ""); - macroLibraries.put("define", model.getDefinition()); - macroLibraries.put("isRunning", ""); - macroLibraries.put("type", CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT); - getLinker(model, macroLibraries); - return sortList; - } + macroLibraries.put("charId", "".equals(processDefId) ? uuid : processDefId); + macroLibraries.put("versionUuid", versionUuid); + macroLibraries.put("ver", 0); + macroLibraries.put("fileName", ShapeUtil.replaceBlank(fileName)); + macroLibraries.put("versionNum", processModel == null ? VersionUtil.showVer(plModel.getVersion()) : VersionUtil.showVer(processModel.getVersionNo())); + macroLibraries.put("appId", appId); + macroLibraries.put("processDefId", processDefId); + macroLibraries.put("processVersion", processVersion); + macroLibraries.put("processDefVersionId", processDefVersionId); + macroLibraries.put("processName", processName); + macroLibraries.put("processGroupName", processGroupName); + macroLibraries.put("categoryName", categoryName); + macroLibraries.put("define", define); + macroLibraries.put("isRunning", isRunning); + macroLibraries.put("type", CoeDesignerConstant.DESIGNER_DIFINITION_BPMN); + setCheckoutHashMap(appId, processDefId, macroLibraries); + getLinker(model, macroLibraries); + return sortList; + } - // 获取是否可以检出状态所需字段 - private void setCheckoutHashMap(String appId, String processDefId, Map macroLibraries) { - if ("".equals(processDefId)) { - return; - } - macroLibraries.put("checkoutstate", BPMNDesignerConstant.BPMN_DESIGNER_CHECKOUT_CHECKOUTING); - macroLibraries.put("checkoutuser", DesignerFileUtil.getCheckOutUser(appId, processDefId)); - macroLibraries.put("checkoutusername", getUserName(DesignerFileUtil.getCheckOutUser(appId, processDefId))); - macroLibraries.put("checkouttime", UtilDate.getAliasDatetime(DesignerFileUtil.getCheckOutTime(appId, processDefId))); - macroLibraries.put("checkoutip", DesignerFileUtil.getCheckOutIP(appId, processDefId)); - macroLibraries.put("user", getContext().getUID()); - UserModel model = UserCache.getModel(getContext().getUID()); - macroLibraries.put("currentUserName", model.getUserName()); - } + protected void getBpmnDesginerUI(PALRepositoryModel plModel, Map macroLibraries, boolean isView, boolean isLock) { + // 属性过滤 + String schemeId = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "FILTER_SCHEME"); + if (schemeId == null || schemeId.equals("null")) { + schemeId = ""; + } + macroLibraries.put("schemeId", schemeId); - protected List getBpmnParams(PALRepositoryModel plModel, String processDefId, Map macroLibraries) { - // coe所需参数 - String uuid = plModel.getId(); - String versionUuid = ""; - String fileName = ""; - String wsid = plModel.getWsId(); - String methodId = plModel.getMethodId(); + StringBuffer bpmnJs = new StringBuffer(); + String baseScript = "\t\n"; + String saveUI = ""; + String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); + bpmnJs.append(baseScript.replace("$js$", "designer.extend.events.js")); + boolean flag = Quota.isDeveloperService();// true 有权限,false 无权限 + if (CoeProcessLevelUtil.queryCorrelateType(plModel.getId()) == 1) { // PAL推送至BPMS,且BPMS端已分配 + bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.extend.core.js")); + if (plModel.isApproval() || plModel.isPublish() || plModel.isStop() || isView) { - // 流程所需参数 - String appId = ""; - String processDefVersionId = "";// 流程版本id - int processVersion = 0;// 流程版本号 - String processName = "";// 流程名称 - String processGroupName = "";// 流程组名称 - String categoryName = "";// 分类 + } else { + saveUI += "
"; + } + if (flag) { + if (CoeProcessLevelUtil.isPalManage() && !"show".equals(CoeProcessLevelCorrelateCache.getCache().get(plModel.getId()).getExt1()) && CoeProcessLevelCorrelateCache.getCache().get(plModel.getId()).getCorrelateType() == 1) { + if (CoeProcessLevelUtil.showBpmRunButton(plModel)) {// 显示在bpm运行按钮 + saveUI += "
"; + } + } else { + saveUI += "
"; + if (UtilString.isNotEmpty(schemeId)) { //配置了属性过滤参数 + saveUI += "
"; + saveUI += "
"; + } + } + } + } else if (CoeProcessLevelUtil.hasMarked(plModel.getId())) { // PAL推送至BPMS,但BPMS端未分配 + if (isSysAutoSave.equals("0")) { + if (plModel.isApproval() || plModel.isPublish() || plModel.isStop() || isView) { - int versionStatus = 0; - String isRunning = ""; - String define = ""; - ProcessDefinition processModel = null; - BPMNModel model = CoeDesignerUtil.createBPMNModel(uuid, 0); - if (!UtilString.isEmpty(processDefId)) { // 关联或者推送到console - processModel = ProcessDefCache.getInstance().getModel(processDefId); - if (processModel == null) {// 资源在console中被删除的情况,从coe中获取数据 - model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); - if (model == null) { - define = CoeDesignerUtil.getTemplateOfDefine(uuid); - } else { - define = model.getDefinition(); - } - } else { // 资源在console中未被删除的情况,从console中获取数据 - CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); - define = coeAdapter.readDefinition(appId = processModel.getAppId(), processDefId).toString(); - // 替换真实类型 - try { - JSONObject defineObj = JSONObject.parseObject(define); - JSONObject eleObj = defineObj.getJSONObject("elements"); - Iterator> eleIt = eleObj.entrySet().iterator(); - while(eleIt.hasNext()) { - Entry entry = eleIt.next(); - JSONObject entryVal = (JSONObject)entry.getValue(); - if("linker".equals(entryVal.getString("name"))) { - continue; - } - String typeTitleName = PALRepositoryQueryAPIManager.getInstance().shapePropertyType(entryVal.getString("name")); - entryVal.put("title", typeTitleName); - } - define = JSONObject.toJSONString(defineObj); - } catch(Exception e) { - e.printStackTrace(); - } - // - processDefVersionId = processModel.getVersionId(); - processVersion = processModel.getVersionNo(); - processName = processModel.getName(); - processGroupName = processModel.getProcessGroupName(); - categoryName = processModel.getCategoryName(); - versionStatus = processModel.getVersionStatus(); - fileName = ShapeUtil.replaceBlank(processName); - model.setAppId(processModel.getAppId()); - appId = model.getAppId(); - } - } else { // 没有关联console - model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); - if (model == null) { - define = CoeDesignerUtil.getTemplateOfDefine(uuid); - } else { - define = model.getDefinition(); - } - } - versionUuid = plModel.getVersionId(); - if (versionStatus == ProcessDefinitionConst.VERSION_STATUS_RELEASE) {// 如果已经发布,则标注role为running,供设计器判断操作使用 - isRunning = "role = \"running\""; - } - CoeDesignerShapeAPIManager manager = CoeDesignerShapeAPIManager.getInstance(); - //获取流程定义和排序 - JSONObject object = manager.getBpmnDefinitionAndSort(define, wsid, methodId); + } else { + saveUI += "
"; + } + if (flag) { + saveUI += "
"; + } + } else { + if (flag) { + saveUI = "
"; + } + } + } else if (CoeProcessLevelUtil.queryCorrelateType(plModel.getId()) == 0) { // BPMS流程关联到PAL + bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.extend.core.js")); + if (plModel.isApproval() || plModel.isPublish() || plModel.isStop() || isView) { - define = object.getString("define"); - List sortList = (List) object.get("sort"); - //处理流程节点形状的通用配置 - JSONObject obj = manager.getCoeProcessShapeConfig(define, wsid, methodId, uuid); - define = obj.getString("define"); + } else { + saveUI += "
"; + } + if (flag) { + saveUI += "
"; + if (UtilString.isNotEmpty(schemeId)) { //配置了属性过滤参数 + saveUI += "
"; + saveUI += "
"; + } + } + } else if (plModel.getMethodId().equals("process.bpmn2")) { // 未标记关联,实时保存 + if (isSysAutoSave.equals("0")) { - macroLibraries.put("charId", "".equals(processDefId) ? uuid : processDefId); - macroLibraries.put("versionUuid", versionUuid); - macroLibraries.put("ver", 0); - macroLibraries.put("fileName", ShapeUtil.replaceBlank(fileName)); - macroLibraries.put("versionNum", processModel == null ? VersionUtil.showVer(plModel.getVersion()) : VersionUtil.showVer(processModel.getVersionNo())); - macroLibraries.put("appId", appId); - macroLibraries.put("processDefId", processDefId); - macroLibraries.put("processVersion", processVersion); - macroLibraries.put("processDefVersionId", processDefVersionId); - macroLibraries.put("processName", processName); - macroLibraries.put("processGroupName", processGroupName); - macroLibraries.put("categoryName", categoryName); - macroLibraries.put("define", define); - macroLibraries.put("isRunning", isRunning); - macroLibraries.put("type", CoeDesignerConstant.DESIGNER_DIFINITION_BPMN); - setCheckoutHashMap(appId, processDefId, macroLibraries); - getLinker(model, macroLibraries); - return sortList; - } + if (plModel.isApproval() || plModel.isPublish() || plModel.isStop() || isView) { + if (flag) { + if (CoeProcessLevelUtil.showBpmRunButton(plModel) && !isLock) {// 显示在bpm运行按钮 + saveUI += "
"; + } + } + } else { + saveUI += "
"; + if (flag) { + if (CoeProcessLevelUtil.showBpmRunButton(plModel)) {// 显示在bpm运行按钮 + saveUI += "
"; + saveUI += "
"; + } + } + } - protected void getBpmnDesginerUI(PALRepositoryModel plModel, Map macroLibraries, boolean isView, boolean isLock) { - // 属性过滤 - String schemeId = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "FILTER_SCHEME"); - if(schemeId==null || schemeId.equals("null") ) { - schemeId = ""; - } - macroLibraries.put("schemeId", schemeId); + } else { + if (flag) { + saveUI += "
"; + //saveUI += "
"; + } + } + } + //锁定流程 + String lockUser = plModel.getLockUser(); + if (_uc.getUID().equals(lockUser)) {//当前锁定人 + if (plModel.isPublish() || isView || plModel.isStop()) { + //saveUI += "
"; + } else { + saveUI += "
"; + } + } else { + if (plModel.isPublish() || isView || plModel.isStop()) { + //saveUI += "
"; + } else { + saveUI += "
"; + } + } + bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.extend.events.js")); + bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.ui.js")); + bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.biz.js")); + macroLibraries.put("saveUI", saveUI); + macroLibraries.put("dock_btn_validate", ""); + macroLibraries.put("js", bpmnJs.toString()); + } - StringBuffer bpmnJs = new StringBuffer(); - String baseScript = "\t\n"; - String saveUI = ""; - String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); - bpmnJs.append(baseScript.replace("$js$", "designer.extend.events.js")); - boolean flag = Quota.isDeveloperService();// true 有权限,false 无权限 - if (CoeProcessLevelUtil.queryCorrelateType(plModel.getId()) == 1) { // PAL推送至BPMS,且BPMS端已分配 - bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.extend.core.js")); - if (plModel.isApproval() || plModel.isPublish() || plModel.isStop() || isView) { + protected void getCoeDesginerUI(PALRepositoryModel plModel, Map macroLibraries, boolean isLock, boolean isView) { + String saveUI = ""; + if (!plModel.isApproval() && !plModel.isPublish() && !plModel.isStop() && !isView) { + saveUI = "
"; + String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); + if (isSysAutoSave.equals("1")) { + saveUI = ""; + } + //锁定流程 + String lockUser = plModel.getLockUser(); + if (_uc.getUID().equals(lockUser)) {//当前锁定人 + saveUI += "
"; + } else { + saveUI += "
"; + } + if (isLock) { + saveUI = ""; + } + } + macroLibraries.put("saveUI", saveUI); + macroLibraries.put("type", CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT); + // bpmn所需参数 + macroLibraries.put("dock_btn_validate", ""); + macroLibraries.put("processDefId", ""); + macroLibraries.put("appId", ""); + } - } else { - saveUI += "
"; - } - if (flag) { - if (CoeProcessLevelUtil.isPalManage() && !"show".equals(CoeProcessLevelCorrelateCache.getCache().get(plModel.getId()).getExt1()) && CoeProcessLevelCorrelateCache.getCache().get(plModel.getId()).getCorrelateType() == 1) { - if (CoeProcessLevelUtil.showBpmRunButton(plModel)) {// 显示在bpm运行按钮 - saveUI += "
"; - } - } else { - saveUI += "
"; - if(UtilString.isNotEmpty(schemeId)) { //配置了属性过滤参数 - saveUI += "
"; - saveUI += "
"; - } - } - } - } else if (CoeProcessLevelUtil.hasMarked(plModel.getId())) { // PAL推送至BPMS,但BPMS端未分配 - if (isSysAutoSave.equals("0")) { - if (plModel.isApproval() || plModel.isPublish() || plModel.isStop() || isView) { + protected void putCoeProterties(BaseModel model) { + // JSONObject defineJson = JSONObject.fromObject(model.getDefinition()); + // JSONObject coeProps = defineJson.containsKey("coeProperties") ? defineJson.getJSONObject("coeProperties") : null; + com.alibaba.fastjson.JSONObject defineJson = com.alibaba.fastjson.JSONObject.parseObject(model.getDefinition()); + com.alibaba.fastjson.JSONObject coeProps = defineJson.containsKey("coeProperties") ? defineJson.getJSONObject("coeProperties") : null; + if (coeProps != null && coeProps.getBoolean("update")) {// 第一次更新json里的 + coeProps.put("uuid", model.getUUID()); + coeProps.put("versionUuid", model.getVersionUuid()); + coeProps.put("ver", model.getVer()); + coeProps.put("fileName", ShapeUtil.replaceBlank(model.getFileName())); + coeProps.put("update", false); + model.setDefinition(defineJson.toString()); + } + } - } else { - saveUI += "
"; - } - if (flag) { - saveUI += "
"; - } - } else { - if (flag) { - saveUI = "
"; - } - } - } else if (CoeProcessLevelUtil.queryCorrelateType(plModel.getId()) == 0) { // BPMS流程关联到PAL - bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.extend.core.js")); - if (plModel.isApproval() || plModel.isPublish() || plModel.isStop() || isView) { + public String getDesignerTemplateHtml(String uuid) { + Map macroLibraries = new HashMap(); + macroLibraries.put("uuid", uuid);// definition的UUID + macroLibraries.put("sid", _uc.getSessionId()); + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.template.htm", macroLibraries); + } - } else { - saveUI += "
"; - } - if (flag) { - saveUI += "
"; - if(UtilString.isNotEmpty(schemeId)) { //配置了属性过滤参数 - saveUI += "
"; - saveUI += "
"; - } - } - } else if (plModel.getMethodId().equals("process.bpmn2")) { // 未标记关联,实时保存 - if (isSysAutoSave.equals("0")) { + public String designerMessage(final String type, String uuid, int ver, final String messages, String teamId, String lockUser) { + int check = JsonUtil.checkJsonArray(messages); + String imgPath = ""; + BaseModel definModel = null; + if (check < 0) { + return CoeDesignerConstant.MESSAGES_NOT_JSONARRAY + ""; + } + if (type.equals(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN)) {// bpmn模型 + definModel = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); + } else { + definModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); + } - if (plModel.isApproval() || plModel.isPublish() || plModel.isStop() || isView) { - if (flag) { - if (CoeProcessLevelUtil.showBpmRunButton(plModel) && !isLock) {// 显示在bpm运行按钮 - saveUI += "
"; - } - } - } else { - saveUI += "
"; - if (flag) { - if (CoeProcessLevelUtil.showBpmRunButton(plModel)) {// 显示在bpm运行按钮 - saveUI += "
"; - saveUI += "
"; - } - } - } + if (definModel == null) { + if (type.equals(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN)) {// bpmn模型 + definModel = CoeDesignerUtil.createBPMNModel(uuid, ver); + } else { + definModel = CoeDesignerUtil.createModel(uuid, ver); + } - } else { - if (flag) { - saveUI += "
"; - //saveUI += "
"; - } - } - } - //锁定流程 - String lockUser = plModel.getLockUser(); - if (_uc.getUID().equals(lockUser)) {//当前锁定人 - if (plModel.isPublish() || isView || plModel.isStop()) { - //saveUI += "
"; - } else { - saveUI += "
"; - } - } else { - if (plModel.isPublish() || isView || plModel.isStop()) { - //saveUI += "
"; - } else { - saveUI += "
"; - } - } - bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.extend.events.js")); - bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.ui.js")); - bpmnJs.append(baseScript.replace("$js$", "bpmn.designer.biz.js")); - macroLibraries.put("saveUI", saveUI); - macroLibraries.put("dock_btn_validate", ""); - macroLibraries.put("js", bpmnJs.toString()); - } - - protected void getCoeDesginerUI(PALRepositoryModel plModel, Map macroLibraries, boolean isLock, boolean isView) { - String saveUI = ""; - if (!plModel.isApproval() && !plModel.isPublish() && !plModel.isStop() && !isView) { - saveUI = "
"; - String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); - if (isSysAutoSave.equals("1")) { - saveUI = ""; - } - //锁定流程 - String lockUser = plModel.getLockUser(); - if (_uc.getUID().equals(lockUser)) {//当前锁定人 - saveUI += "
"; - } else { - saveUI += "
"; - } - if (isLock) { - saveUI = ""; - } - } - macroLibraries.put("saveUI", saveUI); - macroLibraries.put("type", CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT); - // bpmn所需参数 - macroLibraries.put("dock_btn_validate", ""); - macroLibraries.put("processDefId", ""); - macroLibraries.put("appId", ""); - } - - protected void putCoeProterties(BaseModel model) { - // JSONObject defineJson = JSONObject.fromObject(model.getDefinition()); - // JSONObject coeProps = defineJson.containsKey("coeProperties") ? defineJson.getJSONObject("coeProperties") : null; - com.alibaba.fastjson.JSONObject defineJson = com.alibaba.fastjson.JSONObject.parseObject(model.getDefinition()); - com.alibaba.fastjson.JSONObject coeProps = defineJson.containsKey("coeProperties") ? defineJson.getJSONObject("coeProperties") : null; - if (coeProps != null && coeProps.getBoolean("update")) {// 第一次更新json里的 - coeProps.put("uuid", model.getUUID()); - coeProps.put("versionUuid", model.getVersionUuid()); - coeProps.put("ver", model.getVer()); - coeProps.put("fileName", ShapeUtil.replaceBlank(model.getFileName())); - coeProps.put("update", false); - model.setDefinition(defineJson.toString()); - } - } - - public String getDesignerTemplateHtml(String uuid) { - Map macroLibraries = new HashMap(); - macroLibraries.put("uuid", uuid);// definition的UUID - macroLibraries.put("sid", _uc.getSessionId()); - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.template.htm", macroLibraries); - } - - public String designerMessage(final String type, String uuid, int ver, final String messages, String teamId, String lockUser) { - int check = JsonUtil.checkJsonArray(messages); - String imgPath = ""; - BaseModel definModel = null; - if (check < 0) { - return CoeDesignerConstant.MESSAGES_NOT_JSONARRAY + ""; - } - if (type.equals(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN)) {// bpmn模型 - definModel = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, 0); - } else { - definModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); - } - - if (definModel == null) { - if (type.equals(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN)) {// bpmn模型 - definModel = CoeDesignerUtil.createBPMNModel(uuid, ver); - } else { - definModel = CoeDesignerUtil.createModel(uuid, ver); - } - - definModel.setCreateHistory(true); - definModel.setUpdateTime(new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date())); - } else { - // 注释掉下面这段代码,不生成历史文件 + definModel.setCreateHistory(true); + definModel.setUpdateTime(new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date())); + } else { + // 注释掉下面这段代码,不生成历史文件 /* * String updateTimeFormat = "yyyy-MM-dd HH:mm:ss"; DateTime lastDateTime = new DateTime(UtilDate.getTimes(definModel.getUpdateTime(), updateTimeFormat)); @@ -1281,831 +1252,836 @@ public class CoeDesignerWeb extends ActionWeb { definModel.setCreateHistory(false); }*/ - definModel.setCreateHistory(false); - } - final BaseModel definModel1 = definModel; - CoeDesignerUtil.resetBaseModelOfMsgAction(definModel1, messages);// 组装model; - if (type.equals(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN)) {// bpmn模型 - CoeDesignerAPIManager.getInstance().storeDefinitionOfBpmn((BPMNModel) definModel1);// dao操作 - } else { - CoeDesignerAPIManager.getInstance().storeDefinition(definModel1);// dao操作 - } - // 修改数据库中的修改日期 - Timestamp modifyDate = new Timestamp(System.currentTimeMillis()); - PALRepositoryModelImpl repositoryModel = (PALRepositoryModelImpl) PALRepositoryCache.getCache().get(uuid); - Timestamp lastModifyDate = repositoryModel.getModifyDate(); // 上次修改时间 - repositoryModel.setModifyDate(modifyDate); - repositoryModel.setModifyUser(_uc.getUID()); - PALRepository repositoryDao = new PALRepository(); - repositoryModel.setLockUser(lockUser); - repositoryDao.update(repositoryModel); + definModel.setCreateHistory(false); + } + final BaseModel definModel1 = definModel; + CoeDesignerUtil.resetBaseModelOfMsgAction(definModel1, messages);// 组装model; + if (type.equals(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN)) {// bpmn模型 + CoeDesignerAPIManager.getInstance().storeDefinitionOfBpmn((BPMNModel) definModel1);// dao操作 + } else { + CoeDesignerAPIManager.getInstance().storeDefinition(definModel1);// dao操作 + } + // 修改数据库中的修改日期 + Timestamp modifyDate = new Timestamp(System.currentTimeMillis()); + PALRepositoryModelImpl repositoryModel = (PALRepositoryModelImpl) PALRepositoryCache.getCache().get(uuid); + Timestamp lastModifyDate = repositoryModel.getModifyDate(); // 上次修改时间 + repositoryModel.setModifyDate(modifyDate); + repositoryModel.setModifyUser(_uc.getUID()); + PALRepository repositoryDao = new PALRepository(); + repositoryModel.setLockUser(lockUser); + repositoryDao.update(repositoryModel); - // 修改流程团队距上次修改日期超过三天,自动发布动态 - if (teamId != null && !"".equals(teamId)) { - if ((modifyDate.getTime() - lastModifyDate.getTime()) > 60 * 60 * 1000 * 24 * 3) { - AppAPI appAPI = SDK.getAppAPI(); - if (appAPI.isActive("com.actionsoft.apps.network")) { - String aslp = ""; - Map params = new HashMap(); - params.put("sid", _uc.getSessionId()); - params.put("sourceAppId", "com.actionsoft.apps.coe.teamwork"); - aslp = "aslp://com.actionsoft.apps.network/createStream"; - SimpleDateFormat m_format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - params.put("message", _uc.getUserName() + "在 " + m_format.format(modifyDate) + " 修改了流程 " + repositoryModel.getName()); - params.put("teamId", teamId); - ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext("com.actionsoft.apps.coe.teamwork"), aslp, params); - } - } - } - return imgPath; - } + // 修改流程团队距上次修改日期超过三天,自动发布动态 + if (teamId != null && !"".equals(teamId)) { + if ((modifyDate.getTime() - lastModifyDate.getTime()) > 60 * 60 * 1000 * 24 * 3) { + AppAPI appAPI = SDK.getAppAPI(); + if (appAPI.isActive("com.actionsoft.apps.network")) { + String aslp = ""; + Map params = new HashMap(); + params.put("sid", _uc.getSessionId()); + params.put("sourceAppId", "com.actionsoft.apps.coe.teamwork"); + aslp = "aslp://com.actionsoft.apps.network/createStream"; + SimpleDateFormat m_format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + params.put("message", _uc.getUserName() + "在 " + m_format.format(modifyDate) + " 修改了流程 " + repositoryModel.getName()); + params.put("teamId", teamId); + ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext("com.actionsoft.apps.coe.teamwork"), aslp, params); + } + } + } + return imgPath; + } - /** - * 版本创建,返回创建的结果 - * 关联流程创建新版本 - * @param uuid - * @param processDefId - * @param correlateType 关联类型 1:PAL推送到BPMS,其他:BPMS关联到PAL - * @return - */ - public String createNewCorrelateProcessVersion(String uuid,String processDefId, int correlateType) { - ResponseObject ro = ResponseObject.newOkResponse(); - PALRepositoryModelImpl lastplModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - String newUUID = UUIDGener.getUUID(); - ProcessDefinition processDef = ProcessDefCache.getInstance().getModel(processDefId); - // 创建关联关系数据 - CoeProcessLevelCorrelateModel cModel = new CoeProcessLevelCorrelateModel(); - cModel.setWsId(lastplModel.getWsId()); - cModel.setPlId(newUUID); - cModel.setPlVersionId(lastplModel.getVersionId()); - cModel.setPlAwsId(processDef.getId()); - cModel.setPlAwsVersionid(processDef.getVersionId()); - cModel.setCorrelateType(correlateType); - cModel.setCorrelate(true); - if(!CoeProcessLevelUtil.isPalManage() && correlateType == 1) { - cModel.setExt1("hidden"); - } - try { - new CoeProcessLevelCorrelateDao().insert(cModel); - } catch (Exception e) { - e.printStackTrace(); - } - String srcPath = "";// 源文件路径 - String targetPath = "";// 目标文件路径 - String oldUUID = lastplModel.getId(); - lastplModel.setId(newUUID); - if (correlateType == 1) {// PAL推送到BPMS,版本号取PAL流程最大值+1 - //Todo:大小版本号变更后未处理 - List list = PALRepositoryCache.getByVersionId(lastplModel.getVersionId()); - double maxVer = 0; - for (PALRepositoryModel model : list) { - maxVer = model.getVersion() > maxVer ? model.getVersion() : maxVer; - } - //Todo: - lastplModel.setVersion(maxVer + 1); - } else {// BPMS关联到PAL,版本号跟随BPMS - lastplModel.setVersion(processDef.getVersionNo()); - } - lastplModel.setHistoryMaxVersion(String.valueOf(processDef.getHistoryMaxVersion())); - lastplModel.setUse(false); - srcPath = lastplModel.getFilePath(); - if (!"".equals(srcPath) && srcPath != null) { - targetPath = srcPath.replace(uuid, lastplModel.getId()); - } - lastplModel.setFilePath(targetPath); - lastplModel.setPublish(false); - lastplModel.setStop(false); - lastplModel.setApproval(false); - Timestamp nowTime = new Timestamp(System.currentTimeMillis()); - String uid = _uc.getUID(); - lastplModel.setCreateUser(uid); - lastplModel.setCreateDate(nowTime); - lastplModel.setModifyUser(uid); - lastplModel.setModifyDate(nowTime); - int store = 0; - try { - store = CoeProcessLevelDaoFacotory.createCoeProcessLevel().insert(lastplModel); - } catch (Exception e) { - e.printStackTrace(); - ro = ResponseObject.newWarnResponse("创建失败," + e.getMessage()); - return ro.toString(); - } - if (store == 1) { - // 修改设计器文件 - CoeFile fileUtil = new CoeFile(); - fileUtil.copyDefaultVersion(srcPath, uuid, targetPath, lastplModel.getId()); - // 查询数据节点id,bpm平台创建新版本节点id不会改变 - Map mapNewUUID = new HashMap(); - String define = ""; - CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); - define = coeAdapter.readDefinition(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId).toString(); - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - Iterator ite = elements.keySet().iterator(); - while (ite.hasNext()) { - String key = ite.next(); - JSONObject shape = elements.getJSONObject(key); - String name = shape.getString("name"); - if (!"linker".equals(name) && shape.get("dataAttributes") != null) { - String oldIdT = shape.getString("id"); - mapNewUUID.put(oldIdT, oldIdT); - } - } + /** + * 版本创建,返回创建的结果 + * 关联流程创建新版本 + * + * @param uuid + * @param processDefId + * @param correlateType 关联类型 1:PAL推送到BPMS,其他:BPMS关联到PAL + * @return + */ + public String createNewCorrelateProcessVersion(String uuid, String processDefId, int correlateType) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepositoryModelImpl lastplModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + String newUUID = UUIDGener.getUUID(); + ProcessDefinition processDef = ProcessDefCache.getInstance().getModel(processDefId); + // 创建关联关系数据 + CoeProcessLevelCorrelateModel cModel = new CoeProcessLevelCorrelateModel(); + cModel.setWsId(lastplModel.getWsId()); + cModel.setPlId(newUUID); + cModel.setPlVersionId(lastplModel.getVersionId()); + cModel.setPlAwsId(processDef.getId()); + cModel.setPlAwsVersionid(processDef.getVersionId()); + cModel.setCorrelateType(correlateType); + cModel.setCorrelate(true); + if (!CoeProcessLevelUtil.isPalManage() && correlateType == 1) { + cModel.setExt1("hidden"); + } + try { + new CoeProcessLevelCorrelateDao().insert(cModel); + } catch (Exception e) { + e.printStackTrace(); + } + String srcPath = "";// 源文件路径 + String targetPath = "";// 目标文件路径 + String oldUUID = lastplModel.getId(); + lastplModel.setId(newUUID); + if (correlateType == 1) {// PAL推送到BPMS,版本号取PAL流程最大值+1 + //Todo:大小版本号变更后未处理 + List list = PALRepositoryCache.getByVersionId(lastplModel.getVersionId()); + double maxVer = 0; + for (PALRepositoryModel model : list) { + maxVer = model.getVersion() > maxVer ? model.getVersion() : maxVer; + } + //Todo: + lastplModel.setVersion(maxVer + 1); + } else {// BPMS关联到PAL,版本号跟随BPMS + lastplModel.setVersion(processDef.getVersionNo()); + } + lastplModel.setHistoryMaxVersion(String.valueOf(processDef.getHistoryMaxVersion())); + lastplModel.setUse(false); + srcPath = lastplModel.getFilePath(); + if (!"".equals(srcPath) && srcPath != null) { + targetPath = srcPath.replace(uuid, lastplModel.getId()); + } + lastplModel.setFilePath(targetPath); + lastplModel.setPublish(false); + lastplModel.setStop(false); + lastplModel.setApproval(false); + Timestamp nowTime = new Timestamp(System.currentTimeMillis()); + String uid = _uc.getUID(); + lastplModel.setCreateUser(uid); + lastplModel.setCreateDate(nowTime); + lastplModel.setModifyUser(uid); + lastplModel.setModifyDate(nowTime); + int store = 0; + try { + store = CoeProcessLevelDaoFacotory.createCoeProcessLevel().insert(lastplModel); + } catch (Exception e) { + e.printStackTrace(); + ro = ResponseObject.newWarnResponse("创建失败," + e.getMessage()); + return ro.toString(); + } + if (store == 1) { + // 修改设计器文件 + CoeFile fileUtil = new CoeFile(); + fileUtil.copyDefaultVersion(srcPath, uuid, targetPath, lastplModel.getId()); + // 查询数据节点id,bpm平台创建新版本节点id不会改变 + Map mapNewUUID = new HashMap(); + String define = ""; + CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); + define = coeAdapter.readDefinition(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId).toString(); + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + Iterator ite = elements.keySet().iterator(); + while (ite.hasNext()) { + String key = ite.next(); + JSONObject shape = elements.getJSONObject(key); + String name = shape.getString("name"); + if (!"linker".equals(name) && shape.get("dataAttributes") != null) { + String oldIdT = shape.getString("id"); + mapNewUUID.put(oldIdT, oldIdT); + } + } - // 处理流程属性 - String property = CoePropertyUtil.getPropertyValue(oldUUID + "_attr"); - if (!UtilString.isEmpty(property)) { - CoePropertyUtil.createProperty(newUUID + "_attr", property); - } - CoeProcessLevelUtil.copyRepositoryProperty(PALRepositoryCache.getCache().get(oldUUID), PALRepositoryCache.getCache().get(newUUID), mapNewUUID, _uc); - ro = ResponseObject.newOkResponse("创建成功"); - JSONObject obj = new JSONObject(); - ro.put("newObj", obj); - ro.put("uuid", lastplModel.getId()); - } else { - ro = ResponseObject.newWarnResponse("创建失败"); - } - return ro.toString(); - } + // 处理流程属性 + String property = CoePropertyUtil.getPropertyValue(oldUUID + "_attr"); + if (!UtilString.isEmpty(property)) { + CoePropertyUtil.createProperty(newUUID + "_attr", property); + } + CoeProcessLevelUtil.copyRepositoryProperty(PALRepositoryCache.getCache().get(oldUUID), PALRepositoryCache.getCache().get(newUUID), mapNewUUID, _uc); + ro = ResponseObject.newOkResponse("创建成功"); + JSONObject obj = new JSONObject(); + ro.put("newObj", obj); + ro.put("uuid", lastplModel.getId()); + } else { + ro = ResponseObject.newWarnResponse("创建失败"); + } + return ro.toString(); + } - public String definitionOfBpmnSave(String uuid, int ver, String appId, String processDefId, String op, String define, String drawMessage) { - ResponseObject responseObject = ResponseObject.newOkResponse().msg(""); - String rs = ""; - String validateResult = ""; + public String definitionOfBpmnSave(String uuid, int ver, String appId, String processDefId, String op, String define, String drawMessage) { + ResponseObject responseObject = ResponseObject.newOkResponse().msg(""); + String rs = ""; + String validateResult = ""; - validateResult = bpmnValidate(appId, processDefId, define); - JSONObject validate = JSONObject.parseObject(validateResult); - String status = validate.getJSONObject("data").getString("result"); - if (!"success".equals(status)) { - return validateResult; - } - if (!UtilString.isEmpty(processDefId)) { - CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); - try { - if (op.contains("newversion")) { - // 重新获取当前versionId中最大的版本号,界面传过来的op中的版本号不一定是最大版本号 - String[] array = op.split("\\|"); - String versionId = array[1]; - List list = ProcessDefCache.getInstance().getListOfProcessVersion(appId, versionId); - int processVer = 0; - for (ProcessDefinition definition : list) { - if (definition.getVersionNo() > processVer) { - processVer = definition.getVersionNo(); - } - } - op = "newversion|" + versionId + "|" + processVer; - } - rs = coeAdapter.storeDefinition(appId, processDefId, op, define, drawMessage); - JSONObject rsJson = JSONObject.parseObject(rs); + validateResult = bpmnValidate(appId, processDefId, define); + JSONObject validate = JSONObject.parseObject(validateResult); + String status = validate.getJSONObject("data").getString("result"); + if (!"success".equals(status)) { + return validateResult; + } + if (!UtilString.isEmpty(processDefId)) { + CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); + try { + if (op.contains("newversion")) { + // 重新获取当前versionId中最大的版本号,界面传过来的op中的版本号不一定是最大版本号 + String[] array = op.split("\\|"); + String versionId = array[1]; + List list = ProcessDefCache.getInstance().getListOfProcessVersion(appId, versionId); + int processVer = 0; + for (ProcessDefinition definition : list) { + if (definition.getVersionNo() > processVer) { + processVer = definition.getVersionNo(); + } + } + op = "newversion|" + versionId + "|" + processVer; + } + rs = coeAdapter.storeDefinition(appId, processDefId, op, define, drawMessage); + JSONObject rsJson = JSONObject.parseObject(rs); - // 已关联的流程进行新建,则新流程默认已关联 - if ("success".equals(rsJson.getString("result")) && op.contains("newversion")) { - CoeProcessLevelCorrelateModel cModel = CoeProcessLevelCorrelateCache.getCache().get(uuid); - if (cModel != null && cModel.isCorrelate()) { - createNewCorrelateProcessVersion(uuid, rsJson.getString("processDefId"), cModel.getCorrelateType()); - } - } - responseObject.setData(rsJson); - } catch (BPMNDefException e) { - e.printStackTrace(); - responseObject.err(); - responseObject.setData(JSONObject.parseObject(BPMNErrorUtil.getErrorJSON(e))); - return responseObject.toString(); - } + // 已关联的流程进行新建,则新流程默认已关联 + if ("success".equals(rsJson.getString("result")) && op.contains("newversion")) { + CoeProcessLevelCorrelateModel cModel = CoeProcessLevelCorrelateCache.getCache().get(uuid); + if (cModel != null && cModel.isCorrelate()) { + createNewCorrelateProcessVersion(uuid, rsJson.getString("processDefId"), cModel.getCorrelateType()); + } + } + responseObject.setData(rsJson); + } catch (BPMNDefException e) { + e.printStackTrace(); + responseObject.err(); + responseObject.setData(JSONObject.parseObject(BPMNErrorUtil.getErrorJSON(e))); + return responseObject.toString(); + } - return responseObject.toString(); - } - return validateResult; - } + return responseObject.toString(); + } + return validateResult; + } - public String bpmnValidate(String appId, String processDefId, String define) { + public String bpmnValidate(String appId, String processDefId, String define) { - ResponseObject responseObject = ResponseObject.newOkResponse().msg("您的文件校验成功"); - String result = ""; - try { - result = BPMNIO.validateBPMNFile(getContext(), appId, processDefId, define); - responseObject.setData(JSONObject.parseObject(result)); - return responseObject.toString(); - } catch (BPMNDefException e) { - e.printStackTrace(); - responseObject.err("您的文件校验失败,请查看右侧校验信息列表"); - responseObject.setData(JSONObject.parseObject(BPMNErrorUtil.getErrorJSON(e))); - return responseObject.toString(); - } catch (Exception e) { - e.printStackTrace(); - responseObject.err("您的文件校验失败,请查看右侧校验信息列表"); - responseObject.setData(JSONObject.parseObject(BPMNErrorUtil.getErrorJSON(e))); + ResponseObject responseObject = ResponseObject.newOkResponse().msg("您的文件校验成功"); + String result = ""; + try { + result = BPMNIO.validateBPMNFile(getContext(), appId, processDefId, define); + responseObject.setData(JSONObject.parseObject(result)); + return responseObject.toString(); + } catch (BPMNDefException e) { + e.printStackTrace(); + responseObject.err("您的文件校验失败,请查看右侧校验信息列表"); + responseObject.setData(JSONObject.parseObject(BPMNErrorUtil.getErrorJSON(e))); + return responseObject.toString(); + } catch (Exception e) { + e.printStackTrace(); + responseObject.err("您的文件校验失败,请查看右侧校验信息列表"); + responseObject.setData(JSONObject.parseObject(BPMNErrorUtil.getErrorJSON(e))); - return responseObject.toString(); - } - } + return responseObject.toString(); + } + } - public JSONArray getHistoryDataJson(String uuid) { - JSONArray historyJson = new JSONArray(); - PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - if (!"".equals(plModel.getFilePath())) { - CoeFile jsonUtil = new CoeFile(); - historyJson = jsonUtil.getHistoryJsonData(plModel.getFilePath()); - } - return historyJson; - } + public JSONArray getHistoryDataJson(String uuid) { + JSONArray historyJson = new JSONArray(); + PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + if (!"".equals(plModel.getFilePath())) { + CoeFile jsonUtil = new CoeFile(); + historyJson = jsonUtil.getHistoryJsonData(plModel.getFilePath()); + } + return historyJson; + } - // 读取所有版本的列表 - public String historyVersions(String type, String appId, String uuid, String processDefId) { - if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) {// bpmn设计器 - // plModel.setPlAwsPidd2"); - } - if (!"".equals(processDefId)) { - CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); - return coeAdapter.readDesignerHistory(appId, processDefId); - } + // 读取所有版本的列表 + public String historyVersions(String type, String appId, String uuid, String processDefId) { + if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) {// bpmn设计器 + // plModel.setPlAwsPidd2"); + } + if (!"".equals(processDefId)) { + CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); + return coeAdapter.readDesignerHistory(appId, processDefId); + } - JSONObject json = new JSONObject(); - JSONArray versions = getHistoryDataJson(uuid); - JSONObject users = new JSONObject(); - UserModel model = UserCache.getModel(getContext().getUID()); - users.put(getContext().getUID(), model.getUserName()); - json.put("users", users); - json.put("versions", versions); - ResponseObject ro = ResponseObject.newOkResponse(); - ro.setData(json); - return ro.toString(); - } + JSONObject json = new JSONObject(); + JSONArray versions = getHistoryDataJson(uuid); + JSONObject users = new JSONObject(); + UserModel model = UserCache.getModel(getContext().getUID()); + users.put(getContext().getUID(), model.getUserName()); + json.put("users", users); + json.put("versions", versions); + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(json); + return ro.toString(); + } - public String getDefine(String type, String appId, String uuid, String processDefId, int ver) { - String define = "{}"; - BaseModel model = null; - if (!"".equals(processDefId)) { - CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); - define = coeAdapter.readDefinition(appId, processDefId, ver); - ResponseObject responseObject = ResponseObject.newOkResponse(); - responseObject.setData(JSONObject.parseObject(define)); - return responseObject.toString(); - } else if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { - model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, ver); - } else { - model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, ver); - } - if (model != null) { - define = model.getDefinition(); - } - ResponseObject responseObject = ResponseObject.newOkResponse(); - responseObject.setData(JSONObject.parseObject(define)); - return responseObject.toString(); - } + public String getDefine(String type, String appId, String uuid, String processDefId, int ver) { + String define = "{}"; + BaseModel model = null; + if (!"".equals(processDefId)) { + CoeDesginerAdapter coeAdapter = new CoeDesginerAdapter(_uc); + define = coeAdapter.readDefinition(appId, processDefId, ver); + ResponseObject responseObject = ResponseObject.newOkResponse(); + responseObject.setData(JSONObject.parseObject(define)); + return responseObject.toString(); + } else if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { + model = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(uuid, ver); + } else { + model = CoeDesignerAPIManager.getInstance().getDefinition(uuid, ver); + } + if (model != null) { + define = model.getDefinition(); + } + ResponseObject responseObject = ResponseObject.newOkResponse(); + responseObject.setData(JSONObject.parseObject(define)); + return responseObject.toString(); + } - /** - * 重置历史版本 - * - * @param type - * @param uuid - * @param processDefId - * @param ver - * @return - */ - public String restoreHistoryVersion(String type, String appId, String uuid, String processDefId, int ver) { - ProcessBPMNDesignerWeb processBPMNDesignerWeb = new ProcessBPMNDesignerWeb(getContext()); - String versionId = ProcessDefCache.getInstance().getModel(processDefId).getVersionId(); - String operateType = "restoreversion|" + versionId + "|" + ver; - return processBPMNDesignerWeb.restoreVersion(appId, processDefId, operateType); - } + /** + * 重置历史版本 + * + * @param type + * @param uuid + * @param processDefId + * @param ver + * @return + */ + public String restoreHistoryVersion(String type, String appId, String uuid, String processDefId, int ver) { + ProcessBPMNDesignerWeb processBPMNDesignerWeb = new ProcessBPMNDesignerWeb(getContext()); + String versionId = ProcessDefCache.getInstance().getModel(processDefId).getVersionId(); + String operateType = "restoreversion|" + versionId + "|" + ver; + return processBPMNDesignerWeb.restoreVersion(appId, processDefId, operateType); + } - /** - * 创建节点关系 - * @param oldModel - * @param createNewShapeId true 返回map中key为文件节点id,value为新创建的id; false 返回map中key为文件节点id,value与key相同 - * @return map key:oldShapeId value:newShapeId/oldShapeId - */ - public Map createShapeIdRelation(PALRepositoryModel oldModel, boolean createNewShapeId) { - // 创建新老节点对应关系 - Map map = new HashMap(); - // 获取原来的节点数据 - String define = ""; - BPMNModel bpmnDefineModel = null; - BaseModel baseDefineModel = null; - if (oldModel.getMethodId().equals("process.bpmn2")) { - bpmnDefineModel = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(oldModel.getId(), 0); - if (bpmnDefineModel == null) { - bpmnDefineModel = CoeDesignerUtil.createBPMNModel(oldModel.getId(), 0); - } - define = bpmnDefineModel.getDefinition(); - } else { - baseDefineModel = CoeDesignerAPIManager.getInstance().getDefinition(oldModel.getId(), 0); - if (baseDefineModel == null) { - baseDefineModel = CoeDesignerUtil.createModel(oldModel.getId(), 0); - } - define = baseDefineModel.getDefinition(); - } - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - Iterator ite = elements.keySet().iterator(); - while (ite.hasNext()) { - String key = ite.next(); - JSONObject shape = elements.getJSONObject(key); - String name = shape.getString("name"); - if (!"linker".equals(name) && shape.get("dataAttributes") != null) { - String oldId = shape.getString("id"); - if (createNewShapeId) { - String id = UUIDGener.getObjectId(); - map.put(oldId, id); - } else { - map.put(oldId, oldId); - } - } - } - return map; - } + /** + * 创建节点关系 + * + * @param oldModel + * @param createNewShapeId true 返回map中key为文件节点id,value为新创建的id; false 返回map中key为文件节点id,value与key相同 + * @return map key:oldShapeId value:newShapeId/oldShapeId + */ + public Map createShapeIdRelation(PALRepositoryModel oldModel, boolean createNewShapeId) { + // 创建新老节点对应关系 + Map map = new HashMap(); + // 获取原来的节点数据 + String define = ""; + BPMNModel bpmnDefineModel = null; + BaseModel baseDefineModel = null; + if (oldModel.getMethodId().equals("process.bpmn2")) { + bpmnDefineModel = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(oldModel.getId(), 0); + if (bpmnDefineModel == null) { + bpmnDefineModel = CoeDesignerUtil.createBPMNModel(oldModel.getId(), 0); + } + define = bpmnDefineModel.getDefinition(); + } else { + baseDefineModel = CoeDesignerAPIManager.getInstance().getDefinition(oldModel.getId(), 0); + if (baseDefineModel == null) { + baseDefineModel = CoeDesignerUtil.createModel(oldModel.getId(), 0); + } + define = baseDefineModel.getDefinition(); + } + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + Iterator ite = elements.keySet().iterator(); + while (ite.hasNext()) { + String key = ite.next(); + JSONObject shape = elements.getJSONObject(key); + String name = shape.getString("name"); + if (!"linker".equals(name) && shape.get("dataAttributes") != null) { + String oldId = shape.getString("id"); + if (createNewShapeId) { + String id = UUIDGener.getObjectId(); + map.put(oldId, id); + } else { + map.put(oldId, oldId); + } + } + } + return map; + } - /** - * 复制出现的时候-已无出现复制功能 - * @param uuId - * @deprecated - */ - private Map updateCPShapes(String olduuid, String uuId, String define) { - PALRepositoryModel levelModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuId); - String filePath = levelModel.getFilePath(); - filePath = filePath + File.separator + levelModel.getId(); - UtilFile utilFile = new UtilFile(filePath); - String messageJson = utilFile.readStrUTF8(); - if (!UtilString.isEmpty(define)) { - messageJson = define; - } - if (messageJson == null || "".equals(messageJson)) { - return new HashMap(); - } - List list = new ArrayList(); - Map mapNewUUIDS = new HashMap(); + /** + * 复制出现的时候-已无出现复制功能 + * + * @param uuId + * @deprecated + */ + private Map updateCPShapes(String olduuid, String uuId, String define) { + PALRepositoryModel levelModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuId); + String filePath = levelModel.getFilePath(); + filePath = filePath + File.separator + levelModel.getId(); + UtilFile utilFile = new UtilFile(filePath); + String messageJson = utilFile.readStrUTF8(); + if (!UtilString.isEmpty(define)) { + messageJson = define; + } + if (messageJson == null || "".equals(messageJson)) { + return new HashMap(); + } + List list = new ArrayList(); + Map mapNewUUIDS = new HashMap(); - messageJson = ShapeUtil.fileJsonToObject(messageJson, list, mapNewUUIDS); - if (mapNewUUIDS != null) { - for (Map.Entry mapNewUUID : mapNewUUIDS.entrySet()) { - messageJson = messageJson.replace(mapNewUUID.getKey(), mapNewUUID.getValue()); - } - } - if (list.size() > 0 && updateShapes(list, uuId)) { - utilFile.write(messageJson.getBytes(StandardCharsets.UTF_8)); - } - DesignerRelationShapeCacheManager cache = DesignerRelationShapeCacheManager.getInstance(); - Map> shapeMap = cache.getEventMap(); - messageJson = ShapeUtil.shapeJsonToObject(messageJson, shapeMap, uuId); - return mapNewUUIDS; - } + messageJson = ShapeUtil.fileJsonToObject(messageJson, list, mapNewUUIDS); + if (mapNewUUIDS != null) { + for (Map.Entry mapNewUUID : mapNewUUIDS.entrySet()) { + messageJson = messageJson.replace(mapNewUUID.getKey(), mapNewUUID.getValue()); + } + } + if (list.size() > 0 && updateShapes(list, uuId)) { + utilFile.write(messageJson.getBytes(StandardCharsets.UTF_8)); + } + DesignerRelationShapeCacheManager cache = DesignerRelationShapeCacheManager.getInstance(); + Map> shapeMap = cache.getEventMap(); + messageJson = ShapeUtil.shapeJsonToObject(messageJson, shapeMap, uuId); + return mapNewUUIDS; + } - /** - * 更新图形到数据库 - * - * @param elementList - * @param subject - * @return - */ - private boolean updateShapes(List elementList, String subject) { - // 粘贴时对缓存中的的图形的id进行更新 - List list = new ArrayList(); - for (int i = 0, size = elementList.size(); i < size; i++) { - JSONObject jsonObj = elementList.get(i); - DesignerShapePasteModel model = new DesignerShapePasteModel(); - model.setShapeId(jsonObj.getString("id")); - JSONArray jsonArr = JSONArray.parseArray(jsonObj.getString("dataAttributes")); - for (int j = 0, size1 = jsonArr.size(); j < size1; j++) { - JSONObject jObj = JSONObject.parseObject(jsonArr.getString(j)); - if (jObj.containsKey("shapeGroupId")) { - String shapeGroupId = jObj.getString("shapeGroupId"); - if (null != shapeGroupId && !"".equals(shapeGroupId)) { - model.setShapeGroupId(shapeGroupId); - break; - } - } + /** + * 更新图形到数据库 + * + * @param elementList + * @param subject + * @return + */ + private boolean updateShapes(List elementList, String subject) { + // 粘贴时对缓存中的的图形的id进行更新 + List list = new ArrayList(); + for (int i = 0, size = elementList.size(); i < size; i++) { + JSONObject jsonObj = elementList.get(i); + DesignerShapePasteModel model = new DesignerShapePasteModel(); + model.setShapeId(jsonObj.getString("id")); + JSONArray jsonArr = JSONArray.parseArray(jsonObj.getString("dataAttributes")); + for (int j = 0, size1 = jsonArr.size(); j < size1; j++) { + JSONObject jObj = JSONObject.parseObject(jsonArr.getString(j)); + if (jObj.containsKey("shapeGroupId")) { + String shapeGroupId = jObj.getString("shapeGroupId"); + if (null != shapeGroupId && !"".equals(shapeGroupId)) { + model.setShapeGroupId(shapeGroupId); + break; + } + } - } - model.setShapeMessage(jsonObj.toString()); - model.setShapecategoryName(jsonObj.getString("category")); - model.setShapeName(jsonObj.getString("name")); - model.setIsPaste("Y"); - model.setPalRepositoryId(subject); - model.setShapeType(jsonObj.getString("title")); - model.setIsDelete("N"); - model.setId(jsonObj.getString("id")); - list.add(model); - } - try { - return CoeProcessLevelDaoFacotory.createCoeProcessLevel().pasteToDatabse(list); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } + } + model.setShapeMessage(jsonObj.toString()); + model.setShapecategoryName(jsonObj.getString("category")); + model.setShapeName(jsonObj.getString("name")); + model.setIsPaste("Y"); + model.setPalRepositoryId(subject); + model.setShapeType(jsonObj.getString("title")); + model.setIsDelete("N"); + model.setId(jsonObj.getString("id")); + list.add(model); + } + try { + return CoeProcessLevelDaoFacotory.createCoeProcessLevel().pasteToDatabse(list); + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } - protected String getDesginerTr(PALRepositoryModel plModel, String uuid, int i) { - StringBuffer tr = new StringBuffer(); - String img = ""; - String title = ""; - String checkedInputAttr = ""; - if (!plModel.isUse()) { - img = "../apps/" + CoEConstant.APP_ID + "/img/ws/red.ball.gif"; - title = "历史版本"; - } else { - img = "../apps/" + CoEConstant.APP_ID + "/img/ws/green.ball.gif"; - title = "正在使用"; - } - /* if(!"".equals(uuid) && plModel.getUUId().equals(uuid)){ - * checkedInputAttr ="checked='checked'"; } */ - String backgroud = " background: none repeat scroll 0 0" + " #FFFFFF;"; - if (i % 2 == 0) - backgroud = " background: none repeat scroll 0 0 " + "#FAFAFA;"; - if (plModel.isUse()) - checkedInputAttr = "checked='checked'"; - tr.append("").append("").append("
").append("").append("
").append("").append("
") - .append(VersionUtil.getVersionStrV(plModel.getVersion())).append("
").append("
").append(plModel.getName()).append("
").append("" + "
").append(" "); - // 已发布版本和正在使用版本不能删除 - if (!plModel.isPublish() && !plModel.isUse()) { - tr.append(""); - } - tr.append(""); - return tr.toString(); + protected String getDesginerTr(PALRepositoryModel plModel, String uuid, int i) { + StringBuffer tr = new StringBuffer(); + String img = ""; + String title = ""; + String checkedInputAttr = ""; + if (!plModel.isUse()) { + img = "../apps/" + CoEConstant.APP_ID + "/img/ws/red.ball.gif"; + title = "历史版本"; + } else { + img = "../apps/" + CoEConstant.APP_ID + "/img/ws/green.ball.gif"; + title = "正在使用"; + } + /* if(!"".equals(uuid) && plModel.getUUId().equals(uuid)){ + * checkedInputAttr ="checked='checked'"; } */ + String backgroud = " background: none repeat scroll 0 0" + " #FFFFFF;"; + if (i % 2 == 0) + backgroud = " background: none repeat scroll 0 0 " + "#FAFAFA;"; + if (plModel.isUse()) + checkedInputAttr = "checked='checked'"; + tr.append("").append("").append("
").append("").append("
").append("").append("
") + .append(VersionUtil.getVersionStrV(plModel.getVersion())).append("
").append("
").append(plModel.getName()).append("
").append("" + "
").append(" "); + // 已发布版本和正在使用版本不能删除 + if (!plModel.isPublish() && !plModel.isUse()) { + tr.append(""); + } + tr.append(""); + return tr.toString(); - } + } - protected void saveDesginerOfAws(BPMNModel model) { - String appId = ProcessDefCache.getInstance().getModel(model.getProcessDefId()).getAppId(); - try { - BPMNIO.saveJsonToBPMNFile(getContext(), appId, model.getProcessDefId(), "", model.getDefinition(), false, model.getDraw()); + protected void saveDesginerOfAws(BPMNModel model) { + String appId = ProcessDefCache.getInstance().getModel(model.getProcessDefId()).getAppId(); + try { + BPMNIO.saveJsonToBPMNFile(getContext(), appId, model.getProcessDefId(), "", model.getDefinition(), false, model.getDraw()); - } catch (BPMNDefException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } + } catch (BPMNDefException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } - /** - * 根据chartId 获得相应图片(预览) - * - * @param uuid chartId - * @return - */ - public String getPNGUrl(String uuid) { - String photo = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; - if (uuid.indexOf("obj_") == 0) { - photo = "data:image/png;base64," + BPMNIO.getBPMNImage( ProcessDefCache.getInstance().getModel(uuid).getAppId(), uuid); - } else { - PALRepositoryModel cplm = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - if (cplm != null) { - 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); - } - } - } - } - ResponseObject ro = ResponseObject.newOkResponse(); - ro.put("url", photo); - return ro.toString(); - } + /** + * 根据chartId 获得相应图片(预览) + * + * @param uuid chartId + * @return + */ + public String getPNGUrl(String uuid) { + String photo = "../apps/" + CoEConstant.APP_ID + "/img/method/default.png"; + if (uuid.indexOf("obj_") == 0) { + photo = "data:image/png;base64," + BPMNIO.getBPMNImage(ProcessDefCache.getInstance().getModel(uuid).getAppId(), uuid); + } else { + PALRepositoryModel cplm = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + if (cplm != null) { + 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); + } + } + } + } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("url", photo); + return ro.toString(); + } - /** - * 下载导出流程图片 - * @param uuid - * @return - */ - public String getPNGDownloadUrl(String uuid, String type) { - ResponseObject ro = ResponseObject.newOkResponse(); - String url = ""; - if (type.equals("image")) { - url = handlePngTypeUrl(uuid); - } - if (type.equals("pdf")) { - url = handlePdfTypeUrl(uuid); - } - if (type.equals("json")) { - url = handleJsonTypeUrl(uuid); - } - if (type.equals("xml")) { - url = handleXmlTypeUrl(uuid); - } - if (type.equals("excel")) { - url = handleExcelTypeUrl(uuid); - } - ro.put("url", url); - // 操作行为日志记录 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_DOWNLOAD, CoEOpLogConst.INFO_REPOSITORY_PNG_DOWNLOAD); - } - return ro.toString(); - } + /** + * 下载导出流程图片 + * + * @param uuid + * @return + */ + public String getPNGDownloadUrl(String uuid, String type) { + ResponseObject ro = ResponseObject.newOkResponse(); + String url = ""; + if (type.equals("image")) { + url = handlePngTypeUrl(uuid); + } + if (type.equals("pdf")) { + url = handlePdfTypeUrl(uuid); + } + if (type.equals("json")) { + url = handleJsonTypeUrl(uuid); + } + if (type.equals("xml")) { + url = handleXmlTypeUrl(uuid); + } + if (type.equals("excel")) { + url = handleExcelTypeUrl(uuid); + } + ro.put("url", url); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_DOWNLOAD, CoEOpLogConst.INFO_REPOSITORY_PNG_DOWNLOAD); + } + return ro.toString(); + } - private String handleExcelTypeUrl(String uuid) { - PALRepositoryModel model = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - //创建工作簿 - HSSFWorkbook workbook = new HSSFWorkbook(); - //创建工作表 - HSSFSheet sheet = workbook.createSheet(model.getName()); - HSSFFont font = workbook.createFont(); - HSSFCellStyle styleHead = workbook.createCellStyle(); - styleHead.setFillForegroundColor(HSSFColor.BLUE_GREY.index); - styleHead.setFillPattern(FillPatternType.SOLID_FOREGROUND); - styleHead.setBorderBottom(BorderStyle.THIN); - styleHead.setBottomBorderColor(HSSFColor.BLACK.index); - styleHead.setBorderLeft(BorderStyle.THIN); - styleHead.setLeftBorderColor(HSSFColor.BLACK.index); - styleHead.setBorderRight(BorderStyle.THIN); - styleHead.setRightBorderColor(HSSFColor.BLACK.index); - styleHead.setBorderTop(BorderStyle.THIN); - styleHead.setTopBorderColor(HSSFColor.BLACK.index); - // 设置左右对齐居中 - styleHead.setAlignment(HorizontalAlignment.CENTER); - // 垂直对其居中 - styleHead.setVerticalAlignment(VerticalAlignment.CENTER); - // 设置true让Cell中的内容以多行显示 - styleHead.setWrapText(true); + private String handleExcelTypeUrl(String uuid) { + PALRepositoryModel model = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + //创建工作簿 + HSSFWorkbook workbook = new HSSFWorkbook(); + //创建工作表 + HSSFSheet sheet = workbook.createSheet(model.getName()); + HSSFFont font = workbook.createFont(); + HSSFCellStyle styleHead = workbook.createCellStyle(); + styleHead.setFillForegroundColor(HSSFColor.BLUE_GREY.index); + styleHead.setFillPattern(FillPatternType.SOLID_FOREGROUND); + styleHead.setBorderBottom(BorderStyle.THIN); + styleHead.setBottomBorderColor(HSSFColor.BLACK.index); + styleHead.setBorderLeft(BorderStyle.THIN); + styleHead.setLeftBorderColor(HSSFColor.BLACK.index); + styleHead.setBorderRight(BorderStyle.THIN); + styleHead.setRightBorderColor(HSSFColor.BLACK.index); + styleHead.setBorderTop(BorderStyle.THIN); + styleHead.setTopBorderColor(HSSFColor.BLACK.index); + // 设置左右对齐居中 + styleHead.setAlignment(HorizontalAlignment.CENTER); + // 垂直对其居中 + styleHead.setVerticalAlignment(VerticalAlignment.CENTER); + // 设置true让Cell中的内容以多行显示 + styleHead.setWrapText(true); - font.setBold(true); - font.setColor(HSSFColor.WHITE.index); - styleHead.setFont(font); + font.setBold(true); + font.setColor(HSSFColor.WHITE.index); + styleHead.setFont(font); - //获取数据 - ExcelData excelData = new ExcelData(); - JSONArray array = excelData.getExcelData(uuid); - //设置数据 - if (array != null && array.size() > 0) { - //表头 - HSSFRow headerRow = sheet.createRow(0); - JSONObject object = array.getJSONObject(0); - Set tmpHeaderSet = object.keySet(); - int k = 0; - for (String key : tmpHeaderSet) { - sheet.setColumnWidth(k, 6000); - HSSFCell cellHeader = headerRow.createCell(k); - cellHeader.setCellValue(key); - cellHeader.setCellStyle(styleHead); - k++; - } - HSSFCellStyle styleData = workbook.createCellStyle(); - styleData.setBorderBottom(BorderStyle.THIN); - styleData.setBottomBorderColor(HSSFColor.BLACK.index); - styleData.setBorderLeft(BorderStyle.THIN); - styleData.setLeftBorderColor(HSSFColor.BLACK.index); - styleData.setBorderRight(BorderStyle.THIN); - styleData.setRightBorderColor(HSSFColor.BLACK.index); - styleData.setBorderTop(BorderStyle.THIN); - styleData.setTopBorderColor(HSSFColor.BLACK.index); - for (int i = 0; i < array.size(); i++) { - JSONObject tmp = array.getJSONObject(i); - HSSFRow sheetRow = sheet.createRow(i + 1); - Set tmpSet = tmp.keySet(); - int j = 0; - for (String key : tmpSet) { - HSSFCell cell = sheetRow.createCell(j); - cell.setCellValue(tmp.getString(key)); - cell.setCellStyle(styleData); - j++; - } - } - } - //写入文件 - DCContext dc = DCUtil.createTempFileContext(CoEConstant.APP_ID, "", "", ".xls"); - dc.setFileName(model.getName() + "_V" + model.getVersion() + ".xls"); - File exportFile = new File(dc.getFilePath()); - try { - workbook.write(new FileOutputStream(exportFile)); - workbook.close(); - } catch (IOException e) { - e.printStackTrace(); - } - dc.setSession(_uc); - return dc.getDownloadURL(); - } + //获取数据 + ExcelData excelData = new ExcelData(); + JSONArray array = excelData.getExcelData(uuid); + //设置数据 + if (array != null && array.size() > 0) { + //表头 + HSSFRow headerRow = sheet.createRow(0); + JSONObject object = array.getJSONObject(0); + Set tmpHeaderSet = object.keySet(); + int k = 0; + for (String key : tmpHeaderSet) { + sheet.setColumnWidth(k, 6000); + HSSFCell cellHeader = headerRow.createCell(k); + cellHeader.setCellValue(key); + cellHeader.setCellStyle(styleHead); + k++; + } + HSSFCellStyle styleData = workbook.createCellStyle(); + styleData.setBorderBottom(BorderStyle.THIN); + styleData.setBottomBorderColor(HSSFColor.BLACK.index); + styleData.setBorderLeft(BorderStyle.THIN); + styleData.setLeftBorderColor(HSSFColor.BLACK.index); + styleData.setBorderRight(BorderStyle.THIN); + styleData.setRightBorderColor(HSSFColor.BLACK.index); + styleData.setBorderTop(BorderStyle.THIN); + styleData.setTopBorderColor(HSSFColor.BLACK.index); + for (int i = 0; i < array.size(); i++) { + JSONObject tmp = array.getJSONObject(i); + HSSFRow sheetRow = sheet.createRow(i + 1); + Set tmpSet = tmp.keySet(); + int j = 0; + for (String key : tmpSet) { + HSSFCell cell = sheetRow.createCell(j); + cell.setCellValue(tmp.getString(key)); + cell.setCellStyle(styleData); + j++; + } + } + } + //写入文件 + DCContext dc = DCUtil.createTempFileContext(CoEConstant.APP_ID, "", "", ".xls"); + dc.setFileName(model.getName() + "_V" + model.getVersion() + ".xls"); + File exportFile = new File(dc.getFilePath()); + try { + workbook.write(new FileOutputStream(exportFile)); + workbook.close(); + } catch (IOException e) { + e.printStackTrace(); + } + dc.setSession(_uc); + return dc.getDownloadURL(); + } - private String handlePdfTypeUrl(String uuid) { - return downloadProcessPdf(uuid); - } + private String handlePdfTypeUrl(String uuid) { + return downloadProcessPdf(uuid); + } - private String handleXmlTypeUrl(String uuid) { - JSONObject object = handleRepositoryJson(uuid); - //json->xml的变换 - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - jsonToXmlstr(object, buffer); + private String handleXmlTypeUrl(String uuid) { + JSONObject object = handleRepositoryJson(uuid); + //json->xml的变换 + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + jsonToXmlstr(object, buffer); - //得到下载url - DCContext dc = DCUtil.createTempFileContext(CoEConstant.APP_ID, "", "", "xml"); - //设置导出文件dc的名称 - PALRepositoryModel model = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - dc.setFileName(model.getName() + "_V" + model.getVersion() + ".xml"); - File exportFile = new File(dc.getFilePath()); - FileOutputStream fos = null; - try { - fos = new FileOutputStream(exportFile); - fos.write(buffer.toString().getBytes(StandardCharsets.UTF_8)); - fos.flush(); - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - dc.setSession(_uc); - return dc.getDownloadURL(); - } + //得到下载url + DCContext dc = DCUtil.createTempFileContext(CoEConstant.APP_ID, "", "", "xml"); + //设置导出文件dc的名称 + PALRepositoryModel model = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + dc.setFileName(model.getName() + "_V" + model.getVersion() + ".xml"); + File exportFile = new File(dc.getFilePath()); + FileOutputStream fos = null; + try { + fos = new FileOutputStream(exportFile); + fos.write(buffer.toString().getBytes(StandardCharsets.UTF_8)); + fos.flush(); + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + dc.setSession(_uc); + return dc.getDownloadURL(); + } - public String jsonToXmlstr(JSONObject jsonObject, StringBuffer buffer ){ - Set> set = jsonObject.entrySet(); - Iterator> iterator = set.iterator(); - while (iterator.hasNext()){ - Map.Entry entry = iterator.next(); - if (entry.getValue().getClass().getName().equals("com.alibaba.fastjson.JSONObject")){ - buffer.append("<" + entry.getKey() + ">"); - JSONObject jo = jsonObject.getJSONObject(entry.getKey()); - jsonToXmlstr(jo, buffer); - buffer.append(""); - } else if(entry.getValue().getClass().getName().equals("com.alibaba.fastjson.JSONArray")){ - JSONArray ja = jsonObject.getJSONArray(entry.getKey()); - if (ja != null && ja.size() > 0 && ja.get(0) instanceof String) { - buffer.append("<" + entry.getKey() + ">" + JSON.toJSONString(ja)); - buffer.append(""); - } else { - for (int i = 0; i < ja.size(); i++) { - buffer.append("<" + entry.getKey() + ">"); - JSONObject joChild = ja.getJSONObject(i); - jsonToXmlstr(joChild, buffer); - buffer.append(""); - } - } - } else if(entry.getValue().getClass().getName().equals("java.lang.String")){ - buffer.append("<" + entry.getKey() + ">" + entry.getValue()); - buffer.append(""); - } - } - return buffer.toString(); - } + public String jsonToXmlstr(JSONObject jsonObject, StringBuffer buffer) { + Set> set = jsonObject.entrySet(); + Iterator> iterator = set.iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + if (entry.getValue().getClass().getName().equals("com.alibaba.fastjson.JSONObject")) { + buffer.append("<" + entry.getKey() + ">"); + JSONObject jo = jsonObject.getJSONObject(entry.getKey()); + jsonToXmlstr(jo, buffer); + buffer.append(""); + } else if (entry.getValue().getClass().getName().equals("com.alibaba.fastjson.JSONArray")) { + JSONArray ja = jsonObject.getJSONArray(entry.getKey()); + if (ja != null && ja.size() > 0 && ja.get(0) instanceof String) { + buffer.append("<" + entry.getKey() + ">" + JSON.toJSONString(ja)); + buffer.append(""); + } else { + for (int i = 0; i < ja.size(); i++) { + buffer.append("<" + entry.getKey() + ">"); + JSONObject joChild = ja.getJSONObject(i); + jsonToXmlstr(joChild, buffer); + buffer.append(""); + } + } + } else if (entry.getValue().getClass().getName().equals("java.lang.String")) { + buffer.append("<" + entry.getKey() + ">" + entry.getValue()); + buffer.append(""); + } + } + return buffer.toString(); + } - private JSONObject handleRepositoryJson(String uuid) { - //执行导出流程 - CoeProcessLevelWeb coeProcessLevelWeb = new CoeProcessLevelWeb(_uc); - coeProcessLevelWeb.coePalPlExport(_uc, uuid); - //处理得到一个包含流程文件的json文件 - DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, "tmp"); - DCContext dcContext = new DCContext(_uc, dcProfile, CoEConstant.APP_ID, "export", uuid); - UtilFile repositoryJsonFile = new UtilFile(dcContext.getPath() + "/" + "repository.json"); - UtilFile repositoryFile = new UtilFile(dcContext.getPath() + "/" + uuid + "/" + uuid); - JSONObject object = JSON.parseObject(repositoryJsonFile.readStrUTF8()); - JSONObject object1 = JSON.parseObject(repositoryFile.readStrUTF8()); - object.put("repositoryFile", object1); - return object; - } + private JSONObject handleRepositoryJson(String uuid) { + //执行导出流程 + CoeProcessLevelWeb coeProcessLevelWeb = new CoeProcessLevelWeb(_uc); + coeProcessLevelWeb.coePalPlExport(_uc, uuid); + //处理得到一个包含流程文件的json文件 + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, "tmp"); + DCContext dcContext = new DCContext(_uc, dcProfile, CoEConstant.APP_ID, "export", uuid); + UtilFile repositoryJsonFile = new UtilFile(dcContext.getPath() + "/" + "repository.json"); + UtilFile repositoryFile = new UtilFile(dcContext.getPath() + "/" + uuid + "/" + uuid); + JSONObject object = JSON.parseObject(repositoryJsonFile.readStrUTF8()); + JSONObject object1 = JSON.parseObject(repositoryFile.readStrUTF8()); + object.put("repositoryFile", object1); + return object; + } - private String handleJsonTypeUrl(String uuid) { - JSONObject object = handleRepositoryJson(uuid); - //得到下载url - DCContext dc = DCUtil.createTempFileContext(CoEConstant.APP_ID, "", "", "json"); - //设置导出文件dc的名称 - PALRepositoryModel model = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - dc.setFileName(model.getName() + "_V" + model.getVersion() + ".json"); - File exportFile = new File(dc.getFilePath()); - FileOutputStream fos = null; - try { - fos = new FileOutputStream(exportFile); - fos.write(JSON.toJSONString(object).getBytes(StandardCharsets.UTF_8)); - fos.flush(); - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - dc.setSession(_uc); - return dc.getDownloadURL(); - } + private String handleJsonTypeUrl(String uuid) { + JSONObject object = handleRepositoryJson(uuid); + //得到下载url + DCContext dc = DCUtil.createTempFileContext(CoEConstant.APP_ID, "", "", "json"); + //设置导出文件dc的名称 + PALRepositoryModel model = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + dc.setFileName(model.getName() + "_V" + model.getVersion() + ".json"); + File exportFile = new File(dc.getFilePath()); + FileOutputStream fos = null; + try { + fos = new FileOutputStream(exportFile); + fos.write(JSON.toJSONString(object).getBytes(StandardCharsets.UTF_8)); + fos.flush(); + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + dc.setSession(_uc); + return dc.getDownloadURL(); + } - private String handlePngTypeUrl(String uuid) { - boolean isCorrelate = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(uuid, true); - if (isCorrelate) { - try { - String processDefId = CoeProcessLevelUtil.queryBpmsProcessDefIdByPalId(uuid, true); - return BPMNIO.getBPMNDiagramUrl(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId, 1, _uc.getSessionId(), 0); - } catch (AWSException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - PALRepositoryModel cplm = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - if (cplm == null) throw new AWSException("流程未找到 " + uuid); - PALRepositoryQueryAPIManager.getInstance().checkImage(cplm.getId(), true, true);// 生成图片 - String path = cplm.getFilePath(); - if (!UtilString.isEmpty(path)) { - UtilFile utilFile = new UtilFile(path + "/" + cplm.getId() + ".png"); - if (utilFile.exists()) { - DCContext dcContext = null; - DCUtil.getInstance(); - dcContext = DCUtil.createTempFileContext(AppsConst.SYS_APP_PLATFORM, "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(utilFile.readBytes()); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (fos != null) { - fos.flush(); - fos.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - dcContext.setSession(_uc); - return dcContext.getDownloadURL(); - } - } - } - return ""; - } + private String handlePngTypeUrl(String uuid) { + boolean isCorrelate = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(uuid, true); + if (isCorrelate) { + try { + String processDefId = CoeProcessLevelUtil.queryBpmsProcessDefIdByPalId(uuid, true); + return BPMNIO.getBPMNDiagramUrl(ProcessDefCache.getInstance().getModel(processDefId).getAppId(), processDefId, 1, _uc.getSessionId(), 0); + } catch (AWSException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + PALRepositoryModel cplm = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + if (cplm == null) throw new AWSException("流程未找到 " + uuid); + PALRepositoryQueryAPIManager.getInstance().checkImage(cplm.getId(), true, true);// 生成图片 + String path = cplm.getFilePath(); + if (!UtilString.isEmpty(path)) { + UtilFile utilFile = new UtilFile(path + "/" + cplm.getId() + ".png"); + if (utilFile.exists()) { + DCContext dcContext = null; + DCUtil.getInstance(); + dcContext = DCUtil.createTempFileContext(AppsConst.SYS_APP_PLATFORM, "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(utilFile.readBytes()); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (fos != null) { + fos.flush(); + fos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + dcContext.setSession(_uc); + return dcContext.getDownloadURL(); + } + } + } + return ""; + } - /** - * 下载图片为pdf - * @param ids 流程id,逗号分隔 - * @return - */ - public String downloadProcessPdf(String ids) { - if (UtilString.isEmpty(ids)) { - throw new AWSException("参数不能为空"); - } - // 获取所有流程 - Set removeIds = new HashSet(); - List list = new ArrayList(); - String [] idArr = ids.split(","); - for (String id : idArr) { - if (!UtilString.isEmpty(id)) { - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(id); - PALRepositoryModel removeModel = PALRepositoryRemoveCache.getCache().get(id);// 回收站 - if (plModel == null && removeModel == null) { - SDK.getLogAPI().consoleInfo("[流程图片PDF下载]未找到流程文件,id:" + id); - continue; - } - if (plModel == null) { - plModel = removeModel; - removeIds.add(plModel.getId()); - } - list.add(plModel); - } - } - // 获取所有图片 - //Collections.sort(list, new ChinaWordCompartor()); // 按名称排序 - int index = 1;// 序号,后期生成pdf按照名称排序,每次导出pdf顺序一致 - // 放入该应用的dc下 - String appId = CoEConstant.APP_ID; - String repositoryName = "tmp"; - String groupValue = "processImgs"; - String fileValue = UUIDGener.getUUID(); - Map titleMap = new HashMap<>(); - // System.out.println(fileValue); - DCPluginProfile dcProfile = DCProfileManager.getDCProfile(appId, repositoryName); - DCContext dc = new DCContext(_uc, dcProfile, appId, groupValue, fileValue); - UtilFile fileDir = new UtilFile(dc.getPath()); - // 创建文件 - fileDir.mkdirs(); - String title = "default"; - for (PALRepositoryModel model : list) { - BPMNModel bpmnDefineModel = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(model.getId(), 0); - if (bpmnDefineModel == null) { - bpmnDefineModel = CoeDesignerUtil.createBPMNModel(model.getId(), 0); - bpmnDefineModel.setCreateHistory(false); - } - // 创建图片 - ChartGraphics brush = new ChartGraphics(); - byte[] desginerImg = null; - try { - // desginerImg = brush.draw(bpmnDefineModel.getDefinition(), (int)PageSize.A4.getHeight() - 70 - 30, (int)PageSize.A4.getWidth() - 30 - 30); // 获得原图 - desginerImg = brush.draw(bpmnDefineModel.getDefinition(), null, null); // 获得原图 - if (desginerImg.length > 0) { - // 保存图片 - UtilFile uf = new UtilFile(fileDir + File.separator + index + ".png"); - uf.write(desginerImg); - //String processNo = getProcessNo(model.getId()); - //String title = model.getName() + " " + (UtilString.isEmpty(processNo) ? "" : processNo) + "(" + StatusContrastUtil.getInstance().getStatusName(model) + ")"; - title = model.getName() + "_V" + model.getVersion(); - SDK.getLogAPI().consoleInfo("【流程PDF下载】创建流程图片【成功】【" + title + "】【uuid=" + model.getId() + "】"); - titleMap.put(index + ".png", title); - index++; - } - } catch (Exception e) { - e.printStackTrace(); - SDK.getLogAPI().consoleInfo("【流程PDF下载】创建流程图片【失败】【" + model.getName() + "】【uuid=" + model.getId() + "】"); - } - } - // 生成pdf图片,tmp文件下 - String pdfFileValue = "pdf"; - DCContext pdfDc = new DCContext(_uc, dcProfile, appId, groupValue, pdfFileValue); - UtilFile pdfDir = new UtilFile(pdfDc.getPath()); - if (!pdfDir.exists()) { - pdfDir.mkdirs(); - } - String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); + /** + * 下载图片为pdf + * + * @param ids 流程id,逗号分隔 + * @return + */ + public String downloadProcessPdf(String ids) { + if (UtilString.isEmpty(ids)) { + throw new AWSException("参数不能为空"); + } + // 获取所有流程 + Set removeIds = new HashSet(); + List list = new ArrayList(); + String[] idArr = ids.split(","); + for (String id : idArr) { + if (!UtilString.isEmpty(id)) { + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(id); + PALRepositoryModel removeModel = PALRepositoryRemoveCache.getCache().get(id);// 回收站 + if (plModel == null && removeModel == null) { + SDK.getLogAPI().consoleInfo("[流程图片PDF下载]未找到流程文件,id:" + id); + continue; + } + if (plModel == null) { + plModel = removeModel; + removeIds.add(plModel.getId()); + } + list.add(plModel); + } + } + // 获取所有图片 + //Collections.sort(list, new ChinaWordCompartor()); // 按名称排序 + int index = 1;// 序号,后期生成pdf按照名称排序,每次导出pdf顺序一致 + // 放入该应用的dc下 + String appId = CoEConstant.APP_ID; + String repositoryName = "tmp"; + String groupValue = "processImgs"; + String fileValue = UUIDGener.getUUID(); + Map titleMap = new HashMap<>(); + // System.out.println(fileValue); + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(appId, repositoryName); + DCContext dc = new DCContext(_uc, dcProfile, appId, groupValue, fileValue); + UtilFile fileDir = new UtilFile(dc.getPath()); + // 创建文件 + fileDir.mkdirs(); + String title = "default"; + for (PALRepositoryModel model : list) { + BPMNModel bpmnDefineModel = CoeDesignerAPIManager.getInstance().getDefinitionOfBpmn(model.getId(), 0); + if (bpmnDefineModel == null) { + bpmnDefineModel = CoeDesignerUtil.createBPMNModel(model.getId(), 0); + bpmnDefineModel.setCreateHistory(false); + } + // 创建图片 + ChartGraphics brush = new ChartGraphics(); + byte[] desginerImg = null; + try { + // desginerImg = brush.draw(bpmnDefineModel.getDefinition(), (int)PageSize.A4.getHeight() - 70 - 30, (int)PageSize.A4.getWidth() - 30 - 30); // 获得原图 + desginerImg = brush.draw(bpmnDefineModel.getDefinition(), null, null); // 获得原图 + if (desginerImg.length > 0) { + // 保存图片 + UtilFile uf = new UtilFile(fileDir + File.separator + index + ".png"); + uf.write(desginerImg); + //String processNo = getProcessNo(model.getId()); + //String title = model.getName() + " " + (UtilString.isEmpty(processNo) ? "" : processNo) + "(" + StatusContrastUtil.getInstance().getStatusName(model) + ")"; + title = model.getName() + "_V" + model.getVersion(); + SDK.getLogAPI().consoleInfo("【流程PDF下载】创建流程图片【成功】【" + title + "】【uuid=" + model.getId() + "】"); + titleMap.put(index + ".png", title); + index++; + } + } catch (Exception e) { + e.printStackTrace(); + SDK.getLogAPI().consoleInfo("【流程PDF下载】创建流程图片【失败】【" + model.getName() + "】【uuid=" + model.getId() + "】"); + } + } + // 生成pdf图片,tmp文件下 + String pdfFileValue = "pdf"; + DCContext pdfDc = new DCContext(_uc, dcProfile, appId, groupValue, pdfFileValue); + UtilFile pdfDir = new UtilFile(pdfDc.getPath()); + if (!pdfDir.exists()) { + pdfDir.mkdirs(); + } + String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); /*File [] pdfFiles = pdfDir.listFiles(new MyFilenameFilter(date)); int maxNo = 0; if (pdfFiles != null && pdfFiles.length > 0) { @@ -2119,926 +2095,928 @@ public class CoeDesignerWeb extends ActionWeb { String suffixNo = formatNo(maxNo + 1); String pdfName = "流程图-" + date + "-" + suffixNo + ".pdf";*/ - String pdfName = title + ".pdf"; - File pdfFile = new File(pdfDir.getPath() + File.separator + pdfName); - Img2Pdf.createPdf(titleMap, pdfFile, fileDir, _uc.getUserName(), pdfName, "流程图", _uc.getUserName()); - SDK.getLogAPI().consoleInfo("创建流程图PDF,图片文件夹名称【" + fileValue + "】,PDF名称【" + pdfName + "】"); - // 删除存储图片的文件夹 - UtilFile.removeFile(fileDir); - // 提供下载流 - DCContext pdfContext = new DCContext(_uc, dcProfile, appId, groupValue, pdfFileValue, pdfName); - pdfContext.setSession(_uc); - return pdfContext.getDownloadURL() + "&isInline=false"; - } + String pdfName = title + ".pdf"; + File pdfFile = new File(pdfDir.getPath() + File.separator + pdfName); + Img2Pdf.createPdf(titleMap, pdfFile, fileDir, _uc.getUserName(), pdfName, "流程图", _uc.getUserName()); + SDK.getLogAPI().consoleInfo("创建流程图PDF,图片文件夹名称【" + fileValue + "】,PDF名称【" + pdfName + "】"); + // 删除存储图片的文件夹 + UtilFile.removeFile(fileDir); + // 提供下载流 + DCContext pdfContext = new DCContext(_uc, dcProfile, appId, groupValue, pdfFileValue, pdfName); + pdfContext.setSession(_uc); + return pdfContext.getDownloadURL() + "&isInline=false"; + } - /* - * 锁定 解锁当前流程 xuwp - * */ - public String lockOrUnlockProcess(String uuid, String optype) { - ResponseObject rs = ResponseObject.newOkResponse(); - //判断流程是否已锁定 - PALRepository dao = new PALRepository(); - PALRepositoryModel model = dao.getInstance(uuid); - if (model != null) { - String lockuser = model.getLockUser(); - if (!UtilString.isEmpty(lockuser) && !lockuser.equals(getContext().getUID())) { - rs.err(); - } else { - lockuser = ""; - if ("lockpro".equals(optype)) {//锁定 - lockuser = getContext().getUID(); - } - try { - dao.updateLockUser(uuid, lockuser, _uc.getUID()); - rs.ok(); - } catch (Exception e) { - rs.msg("锁定失败"); - } - } - } + /* + * 锁定 解锁当前流程 xuwp + * */ + public String lockOrUnlockProcess(String uuid, String optype) { + ResponseObject rs = ResponseObject.newOkResponse(); + //判断流程是否已锁定 + PALRepository dao = new PALRepository(); + PALRepositoryModel model = dao.getInstance(uuid); + if (model != null) { + String lockuser = model.getLockUser(); + if (!UtilString.isEmpty(lockuser) && !lockuser.equals(getContext().getUID())) { + rs.err(); + } else { + lockuser = ""; + if ("lockpro".equals(optype)) {//锁定 + lockuser = getContext().getUID(); + } + try { + dao.updateLockUser(uuid, lockuser, _uc.getUID()); + rs.ok(); + } catch (Exception e) { + rs.msg("锁定失败"); + } + } + } - return rs.toString(); - } + return rs.toString(); + } - /* - * 判断当前流程是否处于锁定状态 - * */ - public String checkProcessLockState(String uuid) { - ResponseObject rs = ResponseObject.newOkResponse(); - if (!UtilString.isEmpty(uuid) && uuid.contains("obj_")) {// 推送过去的,暂时不校验,等改了推送机制再说 - rs.put("lockUser", ""); - rs.put("canSave", true); - return rs.toString(); - } - boolean canSave = true;//是否可执行保存操作 - PALRepository dao = new PALRepository(); - PALRepositoryModel model = dao.getInstance(uuid); - String lockUser = ""; - if (model != null) { - lockUser = model.getLockUser(); - UserModel user = SDK.getORGAPI().getUser(lockUser); - if (UtilString.isNotEmpty(lockUser) && user != null && !user.isClosed() && !_uc.getUID().equals(lockUser)) { - canSave = false; - lockUser = user.getUserName(); - } - } else { - return ResponseObject.newErrResponse("文件已被删除").toString(); - } - rs.put("lockUser", lockUser); - rs.put("canSave", canSave); - return rs.toString(); - } + /* + * 判断当前流程是否处于锁定状态 + * */ + public String checkProcessLockState(String uuid) { + ResponseObject rs = ResponseObject.newOkResponse(); + if (!UtilString.isEmpty(uuid) && uuid.contains("obj_")) {// 推送过去的,暂时不校验,等改了推送机制再说 + rs.put("lockUser", ""); + rs.put("canSave", true); + return rs.toString(); + } + boolean canSave = true;//是否可执行保存操作 + PALRepository dao = new PALRepository(); + PALRepositoryModel model = dao.getInstance(uuid); + String lockUser = ""; + if (model != null) { + lockUser = model.getLockUser(); + UserModel user = SDK.getORGAPI().getUser(lockUser); + if (UtilString.isNotEmpty(lockUser) && user != null && !user.isClosed() && !_uc.getUID().equals(lockUser)) { + canSave = false; + lockUser = user.getUserName(); + } + } else { + return ResponseObject.newErrResponse("文件已被删除").toString(); + } + rs.put("lockUser", lockUser); + rs.put("canSave", canSave); + return rs.toString(); + } - public String getShape(String uuid, String methodId, String categories, String wsId) { - String shapes = getSchema(uuid, methodId, categories); - Map map = Maps.newHashMap(); - map.put("shapes", shapes); - List cateList = PALMethodUtil.distinct(categories); - int len = 0; - StringBuffer methodIds = new StringBuffer(); - for (String cate : cateList) { - List shapeConfigs = PALRepositoryShapeConfigCache.getShapeConfigListByMethodId(wsId, cate); - JSONObject object = new JSONObject(); - for (PALRepositoryShapeConfigModel model : shapeConfigs) { - if (object.containsKey(model.getShapeId())) { - JSONArray array = object.getJSONArray(model.getShapeId()); - array.add(JSON.parseObject(model.getAttribute())); - } else { - JSONArray configArray = new JSONArray(); - configArray.add(JSON.parseObject(model.getAttribute())); - object.put(model.getShapeId(), configArray); - } - } - map.put(cate, JSON.toJSONString(object)); - if (++len == cateList.size()) { - methodIds.append(cate); - break; - } - methodIds.append(cate).append(","); - } - PALMethodUtil.saveCustom(methodId, uuid, methodIds.toString()); - return JSON.toJSONString(map); - } + public String getShape(String uuid, String methodId, String categories, String wsId) { + String shapes = getSchema(uuid, methodId, categories); + Map map = Maps.newHashMap(); + map.put("shapes", shapes); + List cateList = PALMethodUtil.distinct(categories); + int len = 0; + StringBuffer methodIds = new StringBuffer(); + for (String cate : cateList) { + List shapeConfigs = PALRepositoryShapeConfigCache.getShapeConfigListByMethodId(wsId, cate); + JSONObject object = new JSONObject(); + for (PALRepositoryShapeConfigModel model : shapeConfigs) { + if (object.containsKey(model.getShapeId())) { + JSONArray array = object.getJSONArray(model.getShapeId()); + array.add(JSON.parseObject(model.getAttribute())); + } else { + JSONArray configArray = new JSONArray(); + configArray.add(JSON.parseObject(model.getAttribute())); + object.put(model.getShapeId(), configArray); + } + } + map.put(cate, JSON.toJSONString(object)); + if (++len == cateList.size()) { + methodIds.append(cate); + break; + } + methodIds.append(cate).append(","); + } + PALMethodUtil.saveCustom(methodId, uuid, methodIds.toString()); + return JSON.toJSONString(map); + } - public String getSchema(String uuid, String methodId, String categories) { - StringBuffer shapes = new StringBuffer(); - List cateList = PALMethodUtil.distinct(categories); - CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); - boolean isAdmin = userModel != null && userModel.getIsAdmin() == 1; - PALMethodModel mModel = PALMethodCache.getPALMethodModelById(methodId); + public String getSchema(String uuid, String methodId, String categories) { + StringBuffer shapes = new StringBuffer(); + List cateList = PALMethodUtil.distinct(categories); + CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); + boolean isAdmin = userModel != null && userModel.getIsAdmin() == 1; + PALMethodModel mModel = PALMethodCache.getPALMethodModelById(methodId); - // 是否允许用户自定义模板,0:不允许;1:允许。 - AppAPI appApi = SDK.getAppAPI(); - String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); + // 是否允许用户自定义模板,0:不允许;1:允许。 + AppAPI appApi = SDK.getAppAPI(); + String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); - if (mModel != null) { - String schema = mModel.getSchema(); - if ("0".equals(isCustomDefine)) { - shapes.append(schema).append("\r\n"); - } else { - shapes.append(schema).append("\r\n"); + if (mModel != null) { + String schema = mModel.getSchema(); + if ("0".equals(isCustomDefine)) { + shapes.append(schema).append("\r\n"); + } else { + shapes.append(schema).append("\r\n"); // if (isAdmin || methodId.equals("process.bpmn2")) { // shapes.append(schema).append("\r\n"); // } else { // shapes.append(schema.substring(0, schema.indexOf("Schema.addShape"))).append("\r\n"); // } - if (mModel.getCustomSchema() != null) { - shapes.append(mModel.getCustomSchema()).append("\r\n"); - } - } - } - for (String cate : cateList) { - if ("basic".equals(cate)) { - shapes.append(PALMethodCache.getBasicTpl()).append("\r\n"); - continue; - } - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(cate); - if (methodModel == null) { - continue; - } - String schema = methodModel.getSchema(); - if ("0".equals(isCustomDefine)) { - shapes.append(methodModel.getSchema()).append("\r\n"); - } else { - if (isAdmin) { - shapes.append(methodModel.getSchema()).append("\r\n"); - } else { - shapes.append(schema, 0, schema.indexOf("Schema.addShape")).append("\r\n"); - } - if (methodModel.getCustomSchema() != null) { - shapes.append(methodModel.getCustomSchema()).append("\r\n"); - } - } - } - return shapes.toString(); - } + if (mModel.getCustomSchema() != null) { + shapes.append(mModel.getCustomSchema()).append("\r\n"); + } + } + } + for (String cate : cateList) { + if ("basic".equals(cate)) { + shapes.append(PALMethodCache.getBasicTpl()).append("\r\n"); + continue; + } + PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(cate); + if (methodModel == null) { + continue; + } + String schema = methodModel.getSchema(); + if ("0".equals(isCustomDefine)) { + shapes.append(methodModel.getSchema()).append("\r\n"); + } else { + if (isAdmin) { + shapes.append(methodModel.getSchema()).append("\r\n"); + } else { + shapes.append(schema, 0, schema.indexOf("Schema.addShape")).append("\r\n"); + } + if (methodModel.getCustomSchema() != null) { + shapes.append(methodModel.getCustomSchema()).append("\r\n"); + } + } + } + return shapes.toString(); + } - public String getDesignerLinkTree(String wsid, String teamId, String palId) { - Map macroLibraries = new HashMap(); - JSONArray expendIds = new JSONArray(); - if (teamId == null || "".equals(teamId)) { - macroLibraries.put("treeData", PALRepositoryQueryAPIManager.getInstance().getPalRepositoryTreeRootData(_uc, wsid, "", "isUsed")); - PALRepository dao = new PALRepository(); - if (palId != null && !"".equals(palId)) { - List parentModels = new ArrayList(); - PALRepositoryModel pModel = PALRepositoryCache.getCache().get(palId); - while (pModel != null) { - if (pModel.getParentId().length() == 36) { - parentModels.add(pModel); - List pModels = dao.getRepositoryByVersionId(pModel.getParentId()); - pModel = pModels != null && pModels.size() > 0 ? pModels.get(0) : null; - if (pModel != null) { - expendIds.add(0, pModel.getId()); - } - } else { - expendIds.add(0, pModel.getParentId()); - pModel = null; - } + public String getDesignerLinkTree(String wsid, String teamId, String palId) { + Map macroLibraries = new HashMap(); + JSONArray expendIds = new JSONArray(); + if (teamId == null || "".equals(teamId)) { + macroLibraries.put("treeData", PALRepositoryQueryAPIManager.getInstance().getPalRepositoryTreeRootData(_uc, wsid, "", "isUsed")); + PALRepository dao = new PALRepository(); + if (palId != null && !"".equals(palId)) { + List parentModels = new ArrayList(); + PALRepositoryModel pModel = PALRepositoryCache.getCache().get(palId); + while (pModel != null) { + if (pModel.getParentId().length() == 36) { + parentModels.add(pModel); + List pModels = dao.getRepositoryByVersionId(pModel.getParentId()); + pModel = pModels != null && pModels.size() > 0 ? pModels.get(0) : null; + if (pModel != null) { + expendIds.add(0, pModel.getId()); + } + } else { + expendIds.add(0, pModel.getParentId()); + pModel = null; + } - } - } - } else { - macroLibraries.put("treeData", PALRepositoryQueryAPIManager.getInstance().getPermPalRepositoryTreeData(_uc, wsid, teamId, "isUsed")); - } - macroLibraries.put("expendIds", expendIds); - macroLibraries.put("sid", _uc.getSessionId()); - macroLibraries.put("wsid", wsid); - macroLibraries.put("teamId", teamId); - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.link.tree.htm", macroLibraries); - } + } + } + } else { + macroLibraries.put("treeData", PALRepositoryQueryAPIManager.getInstance().getPermPalRepositoryTreeData(_uc, wsid, teamId, "isUsed")); + } + macroLibraries.put("expendIds", expendIds); + macroLibraries.put("sid", _uc.getSessionId()); + macroLibraries.put("wsid", wsid); + macroLibraries.put("teamId", teamId); + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.link.tree.htm", macroLibraries); + } - public String getDesignerLinkTreeSearchByName(String seachName, String wsid) { - PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - List coeProcessLevels = coeProcessLevel.getCoeProcessLevelByName(seachName, wsid, null); - int length = coeProcessLevels.size(); - JSONArray jsonArr = new JSONArray(); - for (int i = 0; i < length; i++) { - PALRepositoryModel model = coeProcessLevels.get(i); - JSONObject json = new JSONObject(); - json.put("id", model.getId()); - jsonArr.add(json); - } - ResponseObject resp = null; - JSONObject data = new JSONObject(); - data.put("jsonArr", jsonArr); - resp = ResponseObject.newOkResponse(); - resp.setData(data); - // resp.msg("创建成功"); - return resp.toString(); - } + public String getDesignerLinkTreeSearchByName(String seachName, String wsid) { + PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); + List coeProcessLevels = coeProcessLevel.getCoeProcessLevelByName(seachName, wsid, null); + int length = coeProcessLevels.size(); + JSONArray jsonArr = new JSONArray(); + for (int i = 0; i < length; i++) { + PALRepositoryModel model = coeProcessLevels.get(i); + JSONObject json = new JSONObject(); + json.put("id", model.getId()); + jsonArr.add(json); + } + ResponseObject resp = null; + JSONObject data = new JSONObject(); + data.put("jsonArr", jsonArr); + resp = ResponseObject.newOkResponse(); + resp.setData(data); + // resp.msg("创建成功"); + return resp.toString(); + } - /** - * 获取流程相关的留言 - * - * @param repositoryId - * @return - */ - public String getPALCommentList(String repositoryId, String openAppType) { - JSONArray result = new JSONArray(); - PALComment dao = new PALComment(); - List list = dao.getCommentList(repositoryId, "-1", openAppType); - if (list != null) { - for (PALCommentModel model : list) { - JSONObject object = new JSONObject(); - UserModel userModel = UserCache.getCache().get(model.getUserId()); - object.put("id", model.getId()); - object.put("userId", userModel.getUID()); - object.put("userName", userModel.getUserName()); - object.put("userPhoto", SDK.getPortalAPI().getUserPhoto(_uc, userModel.getUID())); - object.put("departmentName", DepartmentCache.getCache().get(userModel.getDepartmentId()).getName()); - object.put("userComment", model.getUserComment()); - object.put("commentDate", model.getCommentDate()); - List replyList = dao.getCommentList(repositoryId, model.getId(), null); - if (replyList != null) { - JSONArray replyArray = new JSONArray(); - for (PALCommentModel replyModel : replyList) { - JSONObject replyObject = new JSONObject(); - replyObject.put("userId", replyModel.getUserId()); - UserModel replyUserModel = UserCache.getCache().get(replyModel.getUserId()); - replyObject.put("userName", replyUserModel.getUserName()); - replyObject.put("userPhoto", SDK.getPortalAPI().getUserPhoto(_uc, replyUserModel.getUID())); - replyObject.put("userComment", replyModel.getUserComment()); - replyObject.put("commentDate", replyModel.getCommentDate()); - replyArray.add(replyObject); - } - object.put("replyNum", replyArray.size()); - object.put("replyArray", replyArray); - } else { - object.put("replyNum", 0); - } - result.add(object); - } - } + /** + * 获取流程相关的留言 + * + * @param repositoryId + * @return + */ + public String getPALCommentList(String repositoryId, String openAppType) { + JSONArray result = new JSONArray(); + PALComment dao = new PALComment(); + List list = dao.getCommentList(repositoryId, "-1", openAppType); + if (list != null) { + for (PALCommentModel model : list) { + JSONObject object = new JSONObject(); + UserModel userModel = UserCache.getCache().get(model.getUserId()); + object.put("id", model.getId()); + object.put("userId", userModel.getUID()); + object.put("userName", userModel.getUserName()); + object.put("userPhoto", SDK.getPortalAPI().getUserPhoto(_uc, userModel.getUID())); + object.put("departmentName", DepartmentCache.getCache().get(userModel.getDepartmentId()).getName()); + object.put("userComment", model.getUserComment()); + object.put("commentDate", model.getCommentDate()); + List replyList = dao.getCommentList(repositoryId, model.getId(), null); + if (replyList != null) { + JSONArray replyArray = new JSONArray(); + for (PALCommentModel replyModel : replyList) { + JSONObject replyObject = new JSONObject(); + replyObject.put("userId", replyModel.getUserId()); + UserModel replyUserModel = UserCache.getCache().get(replyModel.getUserId()); + replyObject.put("userName", replyUserModel.getUserName()); + replyObject.put("userPhoto", SDK.getPortalAPI().getUserPhoto(_uc, replyUserModel.getUID())); + replyObject.put("userComment", replyModel.getUserComment()); + replyObject.put("commentDate", replyModel.getCommentDate()); + replyArray.add(replyObject); + } + object.put("replyNum", replyArray.size()); + object.put("replyArray", replyArray); + } else { + object.put("replyNum", 0); + } + result.add(object); + } + } - ResponseObject ro = ResponseObject.newOkResponse(result.toString()); - return ro.toString(); - } + ResponseObject ro = ResponseObject.newOkResponse(result.toString()); + return ro.toString(); + } - /** - * 保存发布信息 - * - * @param comment 发布内容 - * @param wsId 资产库Id - * @param teamId 小组Id(可以为空) - * @param repositoryId (流程Id) - * @param pId 父信息Id(可以为空) - * @return - */ - public String savePALComment(String comment, String wsId, String teamId, String repositoryId, String pId, String openAppType) { - PALComment dao = new PALComment(); - PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(repositoryId); + /** + * 保存发布信息 + * + * @param comment 发布内容 + * @param wsId 资产库Id + * @param teamId 小组Id(可以为空) + * @param repositoryId (流程Id) + * @param pId 父信息Id(可以为空) + * @return + */ + public String savePALComment(String comment, String wsId, String teamId, String repositoryId, String pId, String openAppType) { + PALComment dao = new PALComment(); + PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(repositoryId); - String streamId = ""; - // 如果消息来自小组,将消息发送至工作网络 - if (teamId != null && !"".equals(teamId)) { - AppAPI appAPI = SDK.getAppAPI(); - if (appAPI.isActive("com.actionsoft.apps.network")) { - String aslp = ""; - Map params = new HashMap(); - params.put("sid", _uc.getSessionId()); - params.put("sourceAppId", "com.actionsoft.apps.coe.teamwork"); - if (pId != null && !"".equals(pId)) { // 回复消息 - aslp = "aslp://com.actionsoft.apps.network/replyStream"; - PALCommentModel palCommentModel = dao.queryById(pId); - params.put("message", comment); - params.put("streamId", palCommentModel.getStreamId()); - ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext("com.actionsoft.apps.coe.teamwork"), aslp, params); - if (responseObject != null) { - streamId = responseObject.get("streamCommentId") == null ? "" : responseObject.get("streamCommentId").toString(); - } - } else if (openAppType != null && !"".equals(openAppType) && !"0".equals(openAppType)) { // 创建消息 - aslp = "aslp://com.actionsoft.apps.network/createStream"; - params.put("message", "在流程 " + repositoryModel.getName() + " 中留言 " + comment); - params.put("teamId", teamId); - ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext("com.actionsoft.apps.coe.teamwork"), aslp, params); - if (responseObject != null) { - streamId = responseObject.get("streamId") == null ? "" : responseObject.get("streamId").toString(); - } - } - } - } + String streamId = ""; + // 如果消息来自小组,将消息发送至工作网络 + if (teamId != null && !"".equals(teamId)) { + AppAPI appAPI = SDK.getAppAPI(); + if (appAPI.isActive("com.actionsoft.apps.network")) { + String aslp = ""; + Map params = new HashMap(); + params.put("sid", _uc.getSessionId()); + params.put("sourceAppId", "com.actionsoft.apps.coe.teamwork"); + if (pId != null && !"".equals(pId)) { // 回复消息 + aslp = "aslp://com.actionsoft.apps.network/replyStream"; + PALCommentModel palCommentModel = dao.queryById(pId); + params.put("message", comment); + params.put("streamId", palCommentModel.getStreamId()); + ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext("com.actionsoft.apps.coe.teamwork"), aslp, params); + if (responseObject != null) { + streamId = responseObject.get("streamCommentId") == null ? "" : responseObject.get("streamCommentId").toString(); + } + } else if (openAppType != null && !"".equals(openAppType) && !"0".equals(openAppType)) { // 创建消息 + aslp = "aslp://com.actionsoft.apps.network/createStream"; + params.put("message", "在流程 " + repositoryModel.getName() + " 中留言 " + comment); + params.put("teamId", teamId); + ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext("com.actionsoft.apps.coe.teamwork"), aslp, params); + if (responseObject != null) { + streamId = responseObject.get("streamId") == null ? "" : responseObject.get("streamId").toString(); + } + } + } + } - // 保存至数据库中 - PALCommentModel model = new PALCommentModel(); - model.setId(UUIDGener.getUUID()); - model.setPId(pId == null ? "" : pId); - model.setStreamId(streamId); - if (wsId == null || "".equals(wsId)) { - wsId = PALRepositoryCache.getCache().get(repositoryId).getWsId(); - } - model.setWsId(wsId); - model.setTargetType(PALCommentConst.TARGET_TYPE_FILE); - model.setTargetId(repositoryId); - model.setTeamId(teamId == null ? "" : teamId); - model.setUserId(_uc.getUID()); - model.setUserComment(comment); - model.setCommentDate(new Timestamp(System.currentTimeMillis())); - if (openAppType == null || "".equals(openAppType)) { - model.setInfoType(PALCommentConst.INFO_TYPE_PRIVATE); - } else { - model.setInfoType(PALCommentConst.INFO_TYPE_PUBLIC); - } + // 保存至数据库中 + PALCommentModel model = new PALCommentModel(); + model.setId(UUIDGener.getUUID()); + model.setPId(pId == null ? "" : pId); + model.setStreamId(streamId); + if (wsId == null || "".equals(wsId)) { + wsId = PALRepositoryCache.getCache().get(repositoryId).getWsId(); + } + model.setWsId(wsId); + model.setTargetType(PALCommentConst.TARGET_TYPE_FILE); + model.setTargetId(repositoryId); + model.setTeamId(teamId == null ? "" : teamId); + model.setUserId(_uc.getUID()); + model.setUserComment(comment); + model.setCommentDate(new Timestamp(System.currentTimeMillis())); + if (openAppType == null || "".equals(openAppType)) { + model.setInfoType(PALCommentConst.INFO_TYPE_PRIVATE); + } else { + model.setInfoType(PALCommentConst.INFO_TYPE_PUBLIC); + } - int n = dao.insert(model); + int n = dao.insert(model); - JSONObject object = new JSONObject(); - object.put("id", model.getId()); - object.put("userId", model.getUserId()); - object.put("userName", _uc.getUserName()); - object.put("departmentName", _uc.getDepartmentModel().getName()); - object.put("userPhoto", SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID())); - object.put("userComment", comment); - object.put("commentDate", model.getCommentDate()); - object.put("replyNum", 0); - ResponseObject ro = ResponseObject.newOkResponse(object.toString()); - if (n != 1) { - ro = ResponseObject.newErrResponse(); - } + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("userId", model.getUserId()); + object.put("userName", _uc.getUserName()); + object.put("departmentName", _uc.getDepartmentModel().getName()); + object.put("userPhoto", SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID())); + object.put("userComment", comment); + object.put("commentDate", model.getCommentDate()); + object.put("replyNum", 0); + ResponseObject ro = ResponseObject.newOkResponse(object.toString()); + if (n != 1) { + ro = ResponseObject.newErrResponse(); + } - return ro.toString(); - } + return ro.toString(); + } - /** - * 新增自定义图形模板 - * - * @param schema - * @param methodId - * @param category - * @return - */ - public String saveCOEPALPLCustomSchema(String schema, String methodId, String category) { - ResponseObject ro = null; + /** + * 新增自定义图形模板 + * + * @param schema + * @param methodId + * @param category + * @return + */ + public String saveCOEPALPLCustomSchema(String schema, String methodId, String category) { + ResponseObject ro = null; - String filePath = null; - if (methodId.equals("process.epc")) { - filePath = AppsAPIManager.getInstance().getAppContext(PALMethodConst.APP_PROCESS_EPC).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; - } else if (methodId.equals("process.flowchart")) { - filePath = AppsAPIManager.getInstance().getAppContext(PALMethodConst.APP_PROCESS_FLOWCHART).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; - } else { - filePath = AppsAPIManager.getInstance().getAppContext(CoEConstant.APP_ID).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; - } - UtilFile file = new UtilFile(filePath); - // 如果还没有定义过模板,新建文件 - if (!file.exists()) { - try { - file.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - ro = ResponseObject.newErrResponse(); - return ro.toString(); - } - } - String oldSchemaString = file.readStrUTF8(); - if (oldSchemaString == null) { - oldSchemaString = ""; - } - StringBuilder oldSchema = new StringBuilder(oldSchemaString); - JSONObject schemaJson = JSONObject.parseObject(schema); - String name = schemaJson.getString("name"); - // 如果已经定义过该名称模板,将之前的删除 - if (oldSchemaString.indexOf("\"name\":\"" + name + "\"") > -1) { - oldSchemaString = oldSchemaString.replaceAll("\n\r", ""); - String[] schemas = oldSchemaString.split("Schema.addShape"); - String[] newSchemas = schemas; - for (int i = 0; i < schemas.length; i++) { - String o = schemas[i]; - if (o.indexOf("\"name\":\"" + name + "\"") > -1) { - newSchemas[i] = ""; - } - } - oldSchema = new StringBuilder(); - for (int i = 0; i < newSchemas.length; i++) { - if (!"".equals(newSchemas[i])) { - oldSchema.append("Schema.addShape").append(newSchemas[i]).append("\n\r"); - } - } + String filePath = null; + if (methodId.equals("process.epc")) { + filePath = AppsAPIManager.getInstance().getAppContext(PALMethodConst.APP_PROCESS_EPC).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; + } else if (methodId.equals("process.flowchart")) { + filePath = AppsAPIManager.getInstance().getAppContext(PALMethodConst.APP_PROCESS_FLOWCHART).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; + } else { + filePath = AppsAPIManager.getInstance().getAppContext(CoEConstant.APP_ID).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; + } + UtilFile file = new UtilFile(filePath); + // 如果还没有定义过模板,新建文件 + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + ro = ResponseObject.newErrResponse(); + return ro.toString(); + } + } + String oldSchemaString = file.readStrUTF8(); + if (oldSchemaString == null) { + oldSchemaString = ""; + } + StringBuilder oldSchema = new StringBuilder(oldSchemaString); + JSONObject schemaJson = JSONObject.parseObject(schema); + String name = schemaJson.getString("name"); + // 如果已经定义过该名称模板,将之前的删除 + if (oldSchemaString.indexOf("\"name\":\"" + name + "\"") > -1) { + oldSchemaString = oldSchemaString.replaceAll("\n\r", ""); + String[] schemas = oldSchemaString.split("Schema.addShape"); + String[] newSchemas = schemas; + for (int i = 0; i < schemas.length; i++) { + String o = schemas[i]; + if (o.indexOf("\"name\":\"" + name + "\"") > -1) { + newSchemas[i] = ""; + } + } + oldSchema = new StringBuilder(); + for (int i = 0; i < newSchemas.length; i++) { + if (!"".equals(newSchemas[i])) { + oldSchema.append("Schema.addShape").append(newSchemas[i]).append("\n\r"); + } + } - } - // 写入新模板 - schema = schema.replaceAll("\\\\t\\\\n", "\t\n").replaceAll("\\\\", ""); - schema = "Schema.addShape(" + schema + ");\n\r"; - oldSchema.append(schema); - file.write(oldSchema.toString().getBytes(StandardCharsets.UTF_8)); + } + // 写入新模板 + schema = schema.replaceAll("\\\\t\\\\n", "\t\n").replaceAll("\\\\", ""); + schema = "Schema.addShape(" + schema + ");\n\r"; + oldSchema.append(schema); + file.write(oldSchema.toString().getBytes(StandardCharsets.UTF_8)); - // 更新缓存 - PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelMap().get(methodId); - palMethodModel.setCustomSchema(oldSchema.toString()); - PALMethodCache.getPALMethodModelMap().put(methodId, palMethodModel); + // 更新缓存 + PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelMap().get(methodId); + palMethodModel.setCustomSchema(oldSchema.toString()); + PALMethodCache.getPALMethodModelMap().put(methodId, palMethodModel); - ro = ResponseObject.newOkResponse(oldSchema.toString()); - return ro.toString(); - } + ro = ResponseObject.newOkResponse(oldSchema.toString()); + return ro.toString(); + } - /** - * 删除自定义的模板 - * - * @param schemaName 图形名称 - * @param methodId 模型类型 - * @return - */ - public String removeCOEPALPLCustomSchema(String schemaName, String methodId) { - ResponseObject ro = null; - String filePath = null; - if (methodId.equals("process.epc")) { - filePath = AppsAPIManager.getInstance().getAppContext(PALMethodConst.APP_PROCESS_EPC).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; - } else if (methodId.equals("process.flowchart")) { - filePath = AppsAPIManager.getInstance().getAppContext(PALMethodConst.APP_PROCESS_FLOWCHART).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; - } else { - filePath = AppsAPIManager.getInstance().getAppContext(CoEConstant.APP_ID).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; - } - UtilFile file = new UtilFile(filePath); - // 如果没有文件,说明还没有自定义过模板 - if (!file.exists()) { - ro = ResponseObject.newErrResponse("0"); // 0:没有定义模板 - return ro.toString(); - } else { - // 如果已经定义过模板,判断是否包含该名称 - String oldSchemaString = file.readStrUTF8(); - if (oldSchemaString == null) { - oldSchemaString = ""; - } - // 如果已经定义过该模板,需将其删除 - if (oldSchemaString.indexOf("\"name\":\"" + schemaName + "\"") > -1) { - oldSchemaString = oldSchemaString.replaceAll("\n\r", ""); - String[] schemas = oldSchemaString.split("Schema.addShape"); - String[] newSchemas = schemas; - for (int i = 0; i < schemas.length; i++) { - String o = schemas[i]; - if (o.indexOf("\"name\":\"" + schemaName + "\"") > -1) { - newSchemas[i] = ""; - } - } - StringBuilder oldSchema = new StringBuilder(); - for (int i = 0; i < newSchemas.length; i++) { - if (!"".equals(newSchemas[i])) { - oldSchema.append("Schema.addShape").append(newSchemas[i]).append("\n\r"); - } - } + /** + * 删除自定义的模板 + * + * @param schemaName 图形名称 + * @param methodId 模型类型 + * @return + */ + public String removeCOEPALPLCustomSchema(String schemaName, String methodId) { + ResponseObject ro = null; + String filePath = null; + if (methodId.equals("process.epc")) { + filePath = AppsAPIManager.getInstance().getAppContext(PALMethodConst.APP_PROCESS_EPC).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; + } else if (methodId.equals("process.flowchart")) { + filePath = AppsAPIManager.getInstance().getAppContext(PALMethodConst.APP_PROCESS_FLOWCHART).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; + } else { + filePath = AppsAPIManager.getInstance().getAppContext(CoEConstant.APP_ID).getPath() + PALMethodConst.DIR_ROOT_CONFIG + methodId + "/" + PALMethodConst.FILE_SCHEMA_CUSTOM_CONFIG; + } + UtilFile file = new UtilFile(filePath); + // 如果没有文件,说明还没有自定义过模板 + if (!file.exists()) { + ro = ResponseObject.newErrResponse("0"); // 0:没有定义模板 + return ro.toString(); + } else { + // 如果已经定义过模板,判断是否包含该名称 + String oldSchemaString = file.readStrUTF8(); + if (oldSchemaString == null) { + oldSchemaString = ""; + } + // 如果已经定义过该模板,需将其删除 + if (oldSchemaString.indexOf("\"name\":\"" + schemaName + "\"") > -1) { + oldSchemaString = oldSchemaString.replaceAll("\n\r", ""); + String[] schemas = oldSchemaString.split("Schema.addShape"); + String[] newSchemas = schemas; + for (int i = 0; i < schemas.length; i++) { + String o = schemas[i]; + if (o.indexOf("\"name\":\"" + schemaName + "\"") > -1) { + newSchemas[i] = ""; + } + } + StringBuilder oldSchema = new StringBuilder(); + for (int i = 0; i < newSchemas.length; i++) { + if (!"".equals(newSchemas[i])) { + oldSchema.append("Schema.addShape").append(newSchemas[i]).append("\n\r"); + } + } - // 重新写入文件 - file.write(oldSchema.toString().getBytes(StandardCharsets.UTF_8)); + // 重新写入文件 + file.write(oldSchema.toString().getBytes(StandardCharsets.UTF_8)); - // 重新加载缓存 - PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelMap().get(methodId); - palMethodModel.setCustomSchema(oldSchema.toString()); - PALMethodCache.getPALMethodModelMap().put(methodId, palMethodModel); + // 重新加载缓存 + PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelMap().get(methodId); + palMethodModel.setCustomSchema(oldSchema.toString()); + PALMethodCache.getPALMethodModelMap().put(methodId, palMethodModel); - ro = ResponseObject.newOkResponse(); - return ro.toString(); + ro = ResponseObject.newOkResponse(); + return ro.toString(); - } else { - ro = ResponseObject.newErrResponse("1"); // 1:没有定义该名称模板 - return ro.toString(); - } + } else { + ro = ResponseObject.newErrResponse("1"); // 1:没有定义该名称模板 + return ro.toString(); + } - } - } + } + } - /** - * 获取select类型的属性的options - * - * @param category - * @return - * @author zhangming - */ - public String getAttributeSelectOptions(String category) { - if (category != null && !"".equals(category)) { - category = category.replace("_", "."); - } else { - ResponseObject ro = ResponseObject.newErrResponse(); - return ro.toString(); - } - if (category.equalsIgnoreCase("bpmn")) { - category = "process.bpmn2"; - } - JSONObject result = new JSONObject(); + /** + * 获取select类型的属性的options + * + * @param category + * @return + * @author zhangming + */ + public String getAttributeSelectOptions(String category) { + if (category != null && !"".equals(category)) { + category = category.replace("_", "."); + } else { + ResponseObject ro = ResponseObject.newErrResponse(); + return ro.toString(); + } + if (category.equalsIgnoreCase("bpmn")) { + category = "process.bpmn2"; + } + JSONObject result = new JSONObject(); - List methodModelList = PALMethodCache.getPALMethodModelListByMethod(category.substring(0, category.indexOf("."))); - for (PALMethodModel methodModel : methodModelList) { - if (methodModel.getId().equals(category)) { - List attributeModels = methodModel.getAttributes(); - for (PALMethodAttributeModel attributeModel : attributeModels) { - if ("select".equals(attributeModel.getType()) || "select_m".equals(attributeModel.getType())) { - result.put(attributeModel.getKey(), attributeModel.getRef()); - } - } - } - } + List methodModelList = PALMethodCache.getPALMethodModelListByMethod(category.substring(0, category.indexOf("."))); + for (PALMethodModel methodModel : methodModelList) { + if (methodModel.getId().equals(category)) { + List attributeModels = methodModel.getAttributes(); + for (PALMethodAttributeModel attributeModel : attributeModels) { + if ("select".equals(attributeModel.getType()) || "select_m".equals(attributeModel.getType())) { + result.put(attributeModel.getKey(), attributeModel.getRef()); + } + } + } + } - ResponseObject ro = ResponseObject.newOkResponse(); - ro.put("data", result); - return ro.toString(); - } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("data", result); + return ro.toString(); + } - /** - * 检查流程的锁定用户 - * - * @param uuid - * @return - */ - public String getCheckoutInfo(String uuid) { - ResponseObject ro = ResponseObject.newOkResponse(); - CheckoutModel model = getCurrentCheckoutInfo(uuid); - String uid = model == null ? "" : model.getUser(); - ro.put("currentUserId", uid); - if (!UtilString.isEmpty(uid)) { - ro.put("currentUserName", SDK.getORGAPI().getUserNames(uid)); - } else { - ro.put("currentUserName", ""); - } - if (UtilString.isEmpty(uid) || _uc.getUID().equals(uid)) { - ro.put("isLocked", false); // 是否被其他人锁定 - } else { - ro.put("isLocked", true); - } - PALRepository dao = new PALRepository(); - PALRepositoryModel palmodel = dao.getInstance(uuid); - if (palmodel != null) { - String lockUser = palmodel.getLockUser(); - if (!UtilString.isEmpty(lockUser) && !lockUser.equals(_uc.getUID())) { - ro.put("isLocked", true); - } - } - return ro.toString(); - } + /** + * 检查流程的锁定用户 + * + * @param uuid + * @return + */ + public String getCheckoutInfo(String uuid) { + ResponseObject ro = ResponseObject.newOkResponse(); + CheckoutModel model = getCurrentCheckoutInfo(uuid); + String uid = model == null ? "" : model.getUser(); + ro.put("currentUserId", uid); + if (!UtilString.isEmpty(uid)) { + ro.put("currentUserName", SDK.getORGAPI().getUserNames(uid)); + } else { + ro.put("currentUserName", ""); + } + if (UtilString.isEmpty(uid) || _uc.getUID().equals(uid)) { + ro.put("isLocked", false); // 是否被其他人锁定 + } else { + ro.put("isLocked", true); + } + PALRepository dao = new PALRepository(); + PALRepositoryModel palmodel = dao.getInstance(uuid); + if (palmodel != null) { + String lockUser = palmodel.getLockUser(); + if (!UtilString.isEmpty(lockUser) && !lockUser.equals(_uc.getUID())) { + ro.put("isLocked", true); + } + } + return ro.toString(); + } - /** - * 获取流程编辑权限 - * - * @param uuid - */ - protected void setCurrentCheckoutRight(String uuid, String uid) { - CheckoutModel checkoutModel = getCurrentCheckoutInfo(uuid); - if (checkoutModel == null) { - checkoutModel = new CheckoutModel(); - checkoutModel.setAppId(CoEConstant.APP_ID); - } - checkoutModel.setUser(_uc.getUID()); - checkoutModel.setIp(_uc.getSessionIp()); - checkoutModel.setTime(new Timestamp(System.currentTimeMillis())); - CheckoutCache.getCache().put(CoEConstant.APP_ID + "_" + "designer_" + uuid, checkoutModel); - } + /** + * 获取流程编辑权限 + * + * @param uuid + */ + protected void setCurrentCheckoutRight(String uuid, String uid) { + CheckoutModel checkoutModel = getCurrentCheckoutInfo(uuid); + if (checkoutModel == null) { + checkoutModel = new CheckoutModel(); + checkoutModel.setAppId(CoEConstant.APP_ID); + } + checkoutModel.setUser(_uc.getUID()); + checkoutModel.setIp(_uc.getSessionIp()); + checkoutModel.setTime(new Timestamp(System.currentTimeMillis())); + CheckoutCache.getCache().put(CoEConstant.APP_ID + "_" + "designer_" + uuid, checkoutModel); + } - /** - * 查询当前的编辑用户 - * - * @param uuid - * @return - */ - protected CheckoutModel getCurrentCheckoutInfo(String uuid) { - return CheckoutCache.getValue(CoEConstant.APP_ID + "_" + "designer_" + uuid); - } + /** + * 查询当前的编辑用户 + * + * @param uuid + * @return + */ + protected CheckoutModel getCurrentCheckoutInfo(String uuid) { + return CheckoutCache.getValue(CoEConstant.APP_ID + "_" + "designer_" + uuid); + } - /** - * 强制获取锁 - * - * @param uuid - * @return - */ - public String setCheckoutRight(String uuid) { - ResponseObject ro = ResponseObject.newOkResponse(); - // 如果流程被人为锁住,则放弃强制获取 - String lockUser = PALRepositoryCache.getCache().get(uuid).getLockUser(); - if (!UtilString.isEmpty(lockUser) && !_uc.getUID().equals(lockUser)) { - } else { - setCurrentCheckoutRight(uuid, _uc.getUID()); - } - return ro.toString(); - } + /** + * 强制获取锁 + * + * @param uuid + * @return + */ + public String setCheckoutRight(String uuid) { + ResponseObject ro = ResponseObject.newOkResponse(); + // 如果流程被人为锁住,则放弃强制获取 + String lockUser = PALRepositoryCache.getCache().get(uuid).getLockUser(); + if (!UtilString.isEmpty(lockUser) && !_uc.getUID().equals(lockUser)) { + } else { + setCurrentCheckoutRight(uuid, _uc.getUID()); + } + return ro.toString(); + } - /** - * 释放编辑权 - * - * @param uuid - * @return - */ - public String releaseCheckoutRight(String uuid) { - ResponseObject ro = ResponseObject.newOkResponse(); - PALRepositoryModel process = PALRepositoryCache.getCache().get(uuid); - if (process != null) { - List list = PALRepositoryCache.getByVersionId(process.getWsId(), process.getVersionId()); - for (PALRepositoryModel p : list) { - CheckoutModel model = getCurrentCheckoutInfo(p.getId()); - if (model != null && model.getUser().equals(_uc.getUID())) { - CheckoutCache.removeValue(CoEConstant.APP_ID + "_" + "designer_" + p.getId()); - } - } - } + /** + * 释放编辑权 + * + * @param uuid + * @return + */ + public String releaseCheckoutRight(String uuid) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepositoryModel process = PALRepositoryCache.getCache().get(uuid); + if (process != null) { + List list = PALRepositoryCache.getByVersionId(process.getWsId(), process.getVersionId()); + for (PALRepositoryModel p : list) { + CheckoutModel model = getCurrentCheckoutInfo(p.getId()); + if (model != null && model.getUser().equals(_uc.getUID())) { + CheckoutCache.removeValue(CoEConstant.APP_ID + "_" + "designer_" + p.getId()); + } + } + } - return ro.toString(); - } + return ro.toString(); + } - /** - * 修改流程节点名称/删除流程节点,修改关联表的数据 - * - * @param uuid - * @param shapeId - * @param shapeText - * @param type 1:修改;2:删除 - * @return - */ - public String updateShapeTextOrDeleteShape(String uuid, String shapeId, String shapeText, int type) { - ResponseObject ro = ResponseObject.newOkResponse(); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - if (type == 1) { - dao.updateByShapeId(uuid, shapeId, shapeText); - dao.updateByRelationShapeId(uuid, shapeId, shapeText); - } else if (type == 2) { - String[] shapeIds = shapeId.split(","); - for (String id : shapeIds) { - if (!UtilString.isEmpty(id)) { - dao.deleteByShapeId(uuid, id); - } - } - } - return ro.toString(); - } + /** + * 修改流程节点名称/删除流程节点,修改关联表的数据 + * + * @param uuid + * @param shapeId + * @param shapeText + * @param type 1:修改;2:删除 + * @return + */ + public String updateShapeTextOrDeleteShape(String uuid, String shapeId, String shapeText, int type) { + ResponseObject ro = ResponseObject.newOkResponse(); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + if (type == 1) { + dao.updateByShapeId(uuid, shapeId, shapeText); + dao.updateByRelationShapeId(uuid, shapeId, shapeText); + } else if (type == 2) { + String[] shapeIds = shapeId.split(","); + for (String id : shapeIds) { + if (!UtilString.isEmpty(id)) { + dao.deleteByShapeId(uuid, id); + } + } + } + return ro.toString(); + } - /** - * 根据部门id,获取部门信息 - * - * @param deptIds - * @return - */ - public String getRelationShapDeptName(String deptIds) { - ResponseObject ro = ResponseObject.newOkResponse(); - if (UtilString.isEmpty(deptIds)) { - ro.put("deptObjs", new JSONObject()); - return ro.toString(); - } - JSONObject obj = new JSONObject(); - String[] deptIdArray = deptIds.split(" "); - for (int i = 0, len = deptIdArray.length; i < len; i++) { - String deptId = deptIdArray[i]; - DepartmentModel deptModel = SDK.getORGAPI().getDepartmentById(deptId); - obj.put(deptId, JSONObject.parseObject(JSON.toJSONString(deptModel))); - } - ro.put("deptObjs", obj); - return ro.toString(); - } + /** + * 根据部门id,获取部门信息 + * + * @param deptIds + * @return + */ + public String getRelationShapDeptName(String deptIds) { + ResponseObject ro = ResponseObject.newOkResponse(); + if (UtilString.isEmpty(deptIds)) { + ro.put("deptObjs", new JSONObject()); + return ro.toString(); + } + JSONObject obj = new JSONObject(); + String[] deptIdArray = deptIds.split(" "); + for (int i = 0, len = deptIdArray.length; i < len; i++) { + String deptId = deptIdArray[i]; + DepartmentModel deptModel = SDK.getORGAPI().getDepartmentById(deptId); + obj.put(deptId, JSONObject.parseObject(JSON.toJSONString(deptModel))); + } + ro.put("deptObjs", obj); + return ro.toString(); + } - /** - * 根据aws流程ID获取pal资产库流程ID - * - * @param newDefId - * @return - */ - public String getPLIdByAWSId(String newDefId) { - ResponseObject ro = ResponseObject.newOkResponse(); - // aws流程创建版本之后若创建成功之后切换最新流程的时候,会刷新流程列表,刷新时若缩略图文件不存在则报空指针异常,此处进行循环查询文件是否存在 - // 间隔0.2s,查询次数最多50次 - long timer = new Date().getTime(); - int count = 0; - while (true) { - if (new Date().getTime() > timer) { - timer += 200; - count++; - if (count > 50) { - break; - } - ProcessDefinition definition = ProcessDefCache.getInstance().get(newDefId); - String imageFilePath = BPMNFileUtil.getBPMNFileRealpath(definition.getAppId(), newDefId) + newDefId + BPMNFileConstant.IMG_SMALL_FILE_EXT_NAME; - UtilFile utilFile = new UtilFile(imageFilePath); - if (utilFile.readBytes() != null) { - break; - } - } - } - ro.put("plId", PALRepositoryQueryAPIManager.getInstance().queryPlIdByPlAwsId(newDefId)); - return ro.toString(); - } + /** + * 根据aws流程ID获取pal资产库流程ID + * + * @param newDefId + * @return + */ + public String getPLIdByAWSId(String newDefId) { + ResponseObject ro = ResponseObject.newOkResponse(); + // aws流程创建版本之后若创建成功之后切换最新流程的时候,会刷新流程列表,刷新时若缩略图文件不存在则报空指针异常,此处进行循环查询文件是否存在 + // 间隔0.2s,查询次数最多50次 + long timer = new Date().getTime(); + int count = 0; + while (true) { + if (new Date().getTime() > timer) { + timer += 200; + count++; + if (count > 50) { + break; + } + ProcessDefinition definition = ProcessDefCache.getInstance().get(newDefId); + String imageFilePath = BPMNFileUtil.getBPMNFileRealpath(definition.getAppId(), newDefId) + newDefId + BPMNFileConstant.IMG_SMALL_FILE_EXT_NAME; + UtilFile utilFile = new UtilFile(imageFilePath); + if (utilFile.readBytes() != null) { + break; + } + } + } + ro.put("plId", PALRepositoryQueryAPIManager.getInstance().queryPlIdByPlAwsId(newDefId)); + return ro.toString(); + } - /** - * shape同名符号提示 - * - * @param uuid - * @param shapeId - * @param shapeText - * @return - */ - public String getShapeSameTexts(String uuid, String shapeId, String shapeText) { - ResponseObject ro = ResponseObject.newOkResponse(); - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - String wsId = model.getWsId(); - Set ids = new HashSet<>(); - List list = PALRepositoryQueryAPIManager.getInstance().getRepositoryModelByWsid(wsId); - for (PALRepositoryModel m : list) { - if ("default".equals(m.getMethodId()) || m.getFilePath() == null || "".equals(m.getFilePath())) { - continue; - } - // 获取文件 - List> list2 = CoeDesignerUtil.getShapeMessageJson2(m.getId()); - if (list2 == null || list2.size() == 0) - continue; - for (Map map : list2) { - if (map != null) { - if ("lane".equals(map.get("category")) || ("process.flowchart".equals(map.get("category")) && "terminator".equals(map.get("type")) || ("process.bpmn2".equals(map.get("category")) && "startEvent".equals(map.get("type"))) || ("process.bpmn2".equals(map.get("category")) && "endEvent".equals(map.get("type"))))) - continue; - if (shapeText != null && !"".equals(shapeText) && shapeText.equals(map.get("text"))) { - ids.add((String) map.get("pid")); - } - } - } - } - if (ids.size() > 0) { - StringBuilder sb = new StringBuilder(); - // 获取路径和模型名称 - List pList = new ArrayList<>(); - for (String id : ids) { - pList.add(PALRepositoryCache.getCache().get(id)); - } - sb.append("
  • "); - for (PALRepositoryModel pModel : pList) { - sb.append("
      " + pModel.getName() + " V" + pModel.getVersion() + ".0
    "); - } - sb.append("
  • "); - ro.put("result", sb.toString()); - } - return ro.toString(); - } + /** + * shape同名符号提示 + * + * @param uuid + * @param shapeId + * @param shapeText + * @return + */ + public String getShapeSameTexts(String uuid, String shapeId, String shapeText) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + String wsId = model.getWsId(); + Set ids = new HashSet<>(); + List list = PALRepositoryQueryAPIManager.getInstance().getRepositoryModelByWsid(wsId); + for (PALRepositoryModel m : list) { + if ("default".equals(m.getMethodId()) || m.getFilePath() == null || "".equals(m.getFilePath())) { + continue; + } + // 获取文件 + List> list2 = CoeDesignerUtil.getShapeMessageJson2(m.getId()); + if (list2 == null || list2.size() == 0) + continue; + for (Map map : list2) { + if (map != null) { + if ("lane".equals(map.get("category")) || ("process.flowchart".equals(map.get("category")) && "terminator".equals(map.get("type")) || ("process.bpmn2".equals(map.get("category")) && "startEvent".equals(map.get("type"))) || ("process.bpmn2".equals(map.get("category")) && "endEvent".equals(map.get("type"))))) + continue; + if (shapeText != null && !"".equals(shapeText) && shapeText.equals(map.get("text"))) { + ids.add((String) map.get("pid")); + } + } + } + } + if (ids.size() > 0) { + StringBuilder sb = new StringBuilder(); + // 获取路径和模型名称 + List pList = new ArrayList<>(); + for (String id : ids) { + pList.add(PALRepositoryCache.getCache().get(id)); + } + sb.append("
  • "); + for (PALRepositoryModel pModel : pList) { + sb.append("
      " + pModel.getName() + " V" + pModel.getVersion() + ".0
    "); + } + sb.append("
  • "); + ro.put("result", sb.toString()); + } + return ro.toString(); + } - /** - * 平台与PAL是否存在共享状态 - * @param processDefId - * @return - */ - public String manageFactorJudgeCorrelateBpms(String processDefId) { - boolean checkCorrelate = false; - PALRepositoryQueryAPIManager queryManager = PALRepositoryQueryAPIManager.getInstance(); - String plid = queryManager.queryPlIdByPlAwsId(processDefId); - if( !UtilString.isEmpty(plid) ) { - PALRepository palRepository = new PALRepository(); - PALRepositoryModel plModel = palRepository.getInstance(plid); - if(plModel!=null) { - checkCorrelate = true; - } - } - if(checkCorrelate) { //共享 - ResponseObject ro = ResponseObject.newOkResponse("BPM和PAL有关联关系,["+processDefId+"]关联["+plid+"]"); - return ro.toString(); - } else { //不共享 - ResponseObject ro = ResponseObject.newErrResponse("BPM和PAL不存在关联关系"); - return ro.toString(); - } - } + /** + * 平台与PAL是否存在共享状态 + * + * @param processDefId + * @return + */ + public String manageFactorJudgeCorrelateBpms(String processDefId) { + boolean checkCorrelate = false; + PALRepositoryQueryAPIManager queryManager = PALRepositoryQueryAPIManager.getInstance(); + String plid = queryManager.queryPlIdByPlAwsId(processDefId); + if (!UtilString.isEmpty(plid)) { + PALRepository palRepository = new PALRepository(); + PALRepositoryModel plModel = palRepository.getInstance(plid); + if (plModel != null) { + checkCorrelate = true; + } + } + if (checkCorrelate) { //共享 + ResponseObject ro = ResponseObject.newOkResponse("BPM和PAL有关联关系,[" + processDefId + "]关联[" + plid + "]"); + return ro.toString(); + } else { //不共享 + ResponseObject ro = ResponseObject.newErrResponse("BPM和PAL不存在关联关系"); + return ro.toString(); + } + } - /******************************************新版门户流程详情start********************************************************/ + /******************************************新版门户流程详情start********************************************************/ - /** - * 门户流程详情详情 - * @param rUUID 流程ID - * @param upVisit 记录访问量+1,true:记录 ;false:不记录 - * @param taskId 流程手册id - * @return - */ - public String getPortalDesignerHtml(String rUUID, boolean upVisit, String taskId) { - String processDefId = ""; - Map macroLibraries = new HashMap(); - macroLibraries.put("selectedElementId", ""); - macroLibraries.put("js", ""); - PALRepositoryModelImpl plModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(rUUID); + /** + * 门户流程详情详情 + * + * @param rUUID 流程ID + * @param upVisit 记录访问量+1,true:记录 ;false:不记录 + * @param taskId 流程手册id + * @return + */ + public String getPortalDesignerHtml(String rUUID, boolean upVisit, String taskId) { + String processDefId = ""; + Map macroLibraries = new HashMap(); + macroLibraries.put("selectedElementId", ""); + macroLibraries.put("js", ""); + PALRepositoryModelImpl plModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(rUUID); - if (plModel == null) { - return AlertWindow.getNotFoundMessagePage("未找到文件", "该文件已被删除"); - } + if (plModel == null) { + return AlertWindow.getNotFoundMessagePage("未找到文件", "该文件已被删除"); + } - macroLibraries.put("taskId", taskId); - // 增加三员管理模式taskid为new,change判断 - if ("process".equals(plModel.getMethodCategory()) && !UtilString.isEmpty(taskId) && !"submit_create".equals(taskId) && !"new".equals(taskId) && !"change".equals(taskId)) { - macroLibraries.put("outputFileName", plModel.getName() + ".doc"); - macroLibraries.put("taskId", taskId); - // 压缩包名称 和 手册模板 - OutputTaskModel taskModel = new OutputTask().getTaskReportById(taskId); - if(taskModel!=null){ - // 压缩包名称 - macroLibraries.put("taskName", taskModel.getTaskName() + ".zip"); - OutputAppProfile appFile = OutputAppManager.getProfile(taskModel.getProfileId()); - // 手册模板(com.actionsoft.apps.coe.pal.output.pr) - macroLibraries.put("taskProfile", appFile.getAppContext().getId()); - } - } + macroLibraries.put("taskId", taskId); + // 增加三员管理模式taskid为new,change判断 + if ("process".equals(plModel.getMethodCategory()) && !UtilString.isEmpty(taskId) && !"submit_create".equals(taskId) && !"new".equals(taskId) && !"change".equals(taskId)) { + macroLibraries.put("outputFileName", plModel.getName() + ".doc"); + macroLibraries.put("taskId", taskId); + // 压缩包名称 和 手册模板 + OutputTaskModel taskModel = new OutputTask().getTaskReportById(taskId); + if (taskModel != null) { + // 压缩包名称 + macroLibraries.put("taskName", taskModel.getTaskName() + ".zip"); + OutputAppProfile appFile = OutputAppManager.getProfile(taskModel.getProfileId()); + // 手册模板(com.actionsoft.apps.coe.pal.output.pr) + macroLibraries.put("taskProfile", appFile.getAppContext().getId()); + } + } - String type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; - if (plModel.getMethodId() != null && plModel.getMethodId().indexOf(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN) != -1) { - type = CoeDesignerConstant.DESIGNER_DIFINITION_BPMN; - } else { - type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; - } + String type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; + if (plModel.getMethodId() != null && plModel.getMethodId().indexOf(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN) != -1) { + type = CoeDesignerConstant.DESIGNER_DIFINITION_BPMN; + } else { + type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; + } - boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(plModel.getId(), true); - macroLibraries.put("isMarked", false); - //默认排序 - List defaultAttrSort; - if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { - // 删除与BPMS关联的无效关联关系 - CoeProcessLevelUtil.deleteInvalidCorrelate(plModel.getId()); - if (isCorrelateBpms) { - processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(plModel.getId(), true); - } else { - processDefId = ""; - } - getBpmnDesginerUI(plModel, macroLibraries, true, true); - defaultAttrSort = getBpmnParams(plModel, processDefId, macroLibraries); - macroLibraries.put("isMarked", CoeProcessLevelUtil.hasMarked(plModel.getId())); - } else { - getCoeDesginerUI(plModel, macroLibraries, true, true); - defaultAttrSort = getCoeParams(plModel, macroLibraries); - } - int state = 0;// 版本状态:设计、运行、停用 - if (isCorrelateBpms) { - ProcessDefinition definition = ProcessDefCache.getInstance().get(processDefId); - if (definition != null) { - state = definition.getVersionStatus(); - } - } - macroLibraries.put("BPMNSupport", AWSServerEngineConfiguration.getEngineBPMNSupport()); - macroLibraries.put("BPMNLevel0", AWSServerEngineConfiguration.getEngineBPMNLevel0()); - macroLibraries.put("BPMNLevel1", AWSServerEngineConfiguration.getEngineBPMNLevel1()); - macroLibraries.put("BPMNLevel2", AWSServerEngineConfiguration.getEngineBPMNLevel2()); - String userUrl = SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID()); - getMoreSharpe(plModel.getMethodId(), plModel.getId(), macroLibraries);// 获取更多图形 - macroLibraries.put("ver", 0); - macroLibraries.put("methodId", plModel.getMethodId()); - macroLibraries.put("sid", _uc.getSessionId()); - macroLibraries.put("wsId", plModel.getWsId()); - macroLibraries.put("uuid", rUUID);// definition的UUID - macroLibraries.put("parentChartId", plModel.getParentId()); - macroLibraries.put("uid", _uc.getUID()); - macroLibraries.put("userUrl", userUrl); - macroLibraries.put("userName", _uc.getUserModel().getUserName()); - macroLibraries.put("schema", getSchema(plModel.getId(), plModel.getMethodId(), PALMethodUtil.getCustom(plModel.getMethodId(), plModel.getId()))); - macroLibraries.put("sessionId", _uc.getSessionId()); - macroLibraries.put("fileName", ShapeUtil.replaceBlank(plModel.getName())); - macroLibraries.put("typeName", I18nRes.findValue(CoEConstant.APP_ID, plModel.getMethodCategory()) + "图"); - macroLibraries.put("openType", 0); - macroLibraries.put("teamId", ""); - macroLibraries.put("perms", "");// 该流程权限(w,d,v) - macroLibraries.put("filePerms", "");// 所有具有权限的流程Id - macroLibraries.put("isPublish", plModel.isPublish()); - CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); - boolean isAdmin = (userModel != null && (userModel.getIsAdmin() == 1)); - macroLibraries.put("isAdmin", isAdmin); - // 更多特性权限 - String moreAttrRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "MOREATTR_RIGHT");// 1普通用户有设置更多特性权限, - if ("2".equals(moreAttrRight)) {// 只有admin显示 - if ("admin".equals(_uc.getUID())) { - macroLibraries.put("moreAttrRight", true); - } else { - macroLibraries.put("moreAttrRight", false); - } - } else if ("0".equals(moreAttrRight)) {// 0只有管理员用户有权限 - if (isAdmin) {// 管理员用户 - macroLibraries.put("moreAttrRight", true); - } else{// 普通用户 - macroLibraries.put("moreAttrRight", false); - } - } else { - macroLibraries.put("moreAttrRight", true); - } - // 自动保存 - String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); - macroLibraries.put("isAutoSave", isSysAutoSave); - macroLibraries.put("checkoutTip", ""); - macroLibraries.put("isView", true);// 是否只读打开 + boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(plModel.getId(), true); + macroLibraries.put("isMarked", false); + //默认排序 + List defaultAttrSort; + if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { + // 删除与BPMS关联的无效关联关系 + CoeProcessLevelUtil.deleteInvalidCorrelate(plModel.getId()); + if (isCorrelateBpms) { + processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(plModel.getId(), true); + } else { + processDefId = ""; + } + getBpmnDesginerUI(plModel, macroLibraries, true, true); + defaultAttrSort = getBpmnParams(plModel, processDefId, macroLibraries); + macroLibraries.put("isMarked", CoeProcessLevelUtil.hasMarked(plModel.getId())); + } else { + getCoeDesginerUI(plModel, macroLibraries, true, true); + defaultAttrSort = getCoeParams(plModel, macroLibraries); + } + int state = 0;// 版本状态:设计、运行、停用 + if (isCorrelateBpms) { + ProcessDefinition definition = ProcessDefCache.getInstance().get(processDefId); + if (definition != null) { + state = definition.getVersionStatus(); + } + } + macroLibraries.put("BPMNSupport", AWSServerEngineConfiguration.getEngineBPMNSupport()); + macroLibraries.put("BPMNLevel0", AWSServerEngineConfiguration.getEngineBPMNLevel0()); + macroLibraries.put("BPMNLevel1", AWSServerEngineConfiguration.getEngineBPMNLevel1()); + macroLibraries.put("BPMNLevel2", AWSServerEngineConfiguration.getEngineBPMNLevel2()); + String userUrl = SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID()); + getMoreSharpe(plModel.getMethodId(), plModel.getId(), macroLibraries);// 获取更多图形 + macroLibraries.put("ver", 0); + macroLibraries.put("methodId", plModel.getMethodId()); + macroLibraries.put("sid", _uc.getSessionId()); + macroLibraries.put("wsId", plModel.getWsId()); + macroLibraries.put("uuid", rUUID);// definition的UUID + macroLibraries.put("parentChartId", plModel.getParentId()); + macroLibraries.put("uid", _uc.getUID()); + macroLibraries.put("userUrl", userUrl); + macroLibraries.put("userName", _uc.getUserModel().getUserName()); + macroLibraries.put("schema", getSchema(plModel.getId(), plModel.getMethodId(), PALMethodUtil.getCustom(plModel.getMethodId(), plModel.getId()))); + macroLibraries.put("sessionId", _uc.getSessionId()); + macroLibraries.put("fileName", ShapeUtil.replaceBlank(plModel.getName())); + macroLibraries.put("typeName", I18nRes.findValue(CoEConstant.APP_ID, plModel.getMethodCategory()) + "图"); + macroLibraries.put("openType", 0); + macroLibraries.put("teamId", ""); + macroLibraries.put("perms", "");// 该流程权限(w,d,v) + macroLibraries.put("filePerms", "");// 所有具有权限的流程Id + macroLibraries.put("isPublish", plModel.isPublish()); + CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); + boolean isAdmin = (userModel != null && (userModel.getIsAdmin() == 1)); + macroLibraries.put("isAdmin", isAdmin); + // 更多特性权限 + String moreAttrRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "MOREATTR_RIGHT");// 1普通用户有设置更多特性权限, + if ("2".equals(moreAttrRight)) {// 只有admin显示 + if ("admin".equals(_uc.getUID())) { + macroLibraries.put("moreAttrRight", true); + } else { + macroLibraries.put("moreAttrRight", false); + } + } else if ("0".equals(moreAttrRight)) {// 0只有管理员用户有权限 + if (isAdmin) {// 管理员用户 + macroLibraries.put("moreAttrRight", true); + } else {// 普通用户 + macroLibraries.put("moreAttrRight", false); + } + } else { + macroLibraries.put("moreAttrRight", true); + } + // 自动保存 + String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); + macroLibraries.put("isAutoSave", isSysAutoSave); + macroLibraries.put("checkoutTip", ""); + macroLibraries.put("isView", true);// 是否只读打开 - // 是否允许用户自定义模板,0:不允许;1:允许。 - AppAPI appApi = SDK.getAppAPI(); - String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); - macroLibraries.put("isCustomDefine", isCustomDefine); - macroLibraries.put("openAppType", "0"); + // 是否允许用户自定义模板,0:不允许;1:允许。 + AppAPI appApi = SDK.getAppAPI(); + String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); + macroLibraries.put("isCustomDefine", isCustomDefine); + macroLibraries.put("openAppType", "0"); - macroLibraries.put("editable", "0"); + macroLibraries.put("editable", "0"); - if (plModel.isPublish()) { - long viewCount = plModel.getViewCount(); - plModel.setViewCount(viewCount + 1); - PALRepository dao = new PALRepository(); - dao.update(plModel); - } + if (plModel.isPublish()) { + long viewCount = plModel.getViewCount(); + plModel.setViewCount(viewCount + 1); + PALRepository dao = new PALRepository(); + dao.update(plModel); + } - getDesginerDefaultParams(macroLibraries);// 获取默认参数配置 + getDesginerDefaultParams(macroLibraries);// 获取默认参数配置 - macroLibraries.put("usersPhoto", ""); - macroLibraries.put("userNum", ""); - DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); - Map> shapeMap = relationShapeCache.getShapemap(); - boolean isExistCopy = shapeMap.get(_uc.getUID()) != null; - boolean isAppearCopy = shapeMap.get(_uc.getUID()) == null || shapeMap.get(_uc.getUID()).get("shapeCopyContent") == null; - // 默认为定义复制 - macroLibraries.put("isExistCopy", isExistCopy); - macroLibraries.put("isAppearCopy", isAppearCopy); + macroLibraries.put("usersPhoto", ""); + macroLibraries.put("userNum", ""); + DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); + Map> shapeMap = relationShapeCache.getShapemap(); + boolean isExistCopy = shapeMap.get(_uc.getUID()) != null; + boolean isAppearCopy = shapeMap.get(_uc.getUID()) == null || shapeMap.get(_uc.getUID()).get("shapeCopyContent") == null; + // 默认为定义复制 + macroLibraries.put("isExistCopy", isExistCopy); + macroLibraries.put("isAppearCopy", isAppearCopy); - macroLibraries.put("diagram", ""); - macroLibraries.put("state", state); - // DockBtnBar中的各功能是否显示 - macroLibraries.put("attributeView", ""); - macroLibraries.put("messageView", ""); - macroLibraries.put("printView", ""); - macroLibraries.put("publishView", ""); + macroLibraries.put("diagram", ""); + macroLibraries.put("state", state); + // DockBtnBar中的各功能是否显示 + macroLibraries.put("attributeView", ""); + macroLibraries.put("messageView", ""); + macroLibraries.put("printView", ""); + macroLibraries.put("publishView", ""); - String riskStyle = "display:none;"; - // risk应用已下架 + String riskStyle = "display:none;"; + // risk应用已下架 // if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.risk") && SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.risk")) { // riskStyle = ""; // } @@ -3047,138 +3025,137 @@ public class CoeDesignerWeb extends ActionWeb { // } else { // riskStyle = "display:none;"; // } - macroLibraries.put("riskStyle", riskStyle); - String processOnIsInstall = "false"; - if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.processon")) { - processOnIsInstall = "true"; - } - String processOnIsActive = "false"; - if (SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.processon")) { - processOnIsActive = "true"; - } - macroLibraries.put("processOnIsInstall", processOnIsInstall); - macroLibraries.put("processOnIsActive", processOnIsActive); + macroLibraries.put("riskStyle", riskStyle); + String processOnIsInstall = "false"; + if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.processon")) { + processOnIsInstall = "true"; + } + String processOnIsActive = "false"; + if (SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.processon")) { + processOnIsActive = "true"; + } + macroLibraries.put("processOnIsInstall", processOnIsInstall); + macroLibraries.put("processOnIsActive", processOnIsActive); - JSONObject relationShapeIds = new JSONObject(); - JSONObject relationShapeModels = new JSONObject(); + JSONObject relationShapeIds = new JSONObject(); + JSONObject relationShapeModels = new JSONObject(); + String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, plModel.getId()); + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + for (String id : elements.keySet()) { + JSONObject shapeObj = elements.getJSONObject(id); + String name = shapeObj.getString("name"); + if ("linker".equals(name)) { + continue; + } + Iterator modelIterator = DesignerShapeRelationCache.getByShapeId(plModel.getId(), id); + if (modelIterator != null) { + while (modelIterator.hasNext()) { + DesignerShapeRelationModel shapeRelationModel = modelIterator.next(); + PALRepositoryModel relationPalModel = PALRepositoryCache.getCache().get(shapeRelationModel.getRelationFileId()); + if (relationPalModel != null) { + relationShapeIds.put(shapeRelationModel.getRelationShapeId(), shapeRelationModel); + } + } + } + Map map = PALRepositoryQueryAPIManager.getInstance().queryRepositoryShapeAttributeById(plModel.getId(), id, shapeObj, "|"); + for (Entry entry : map.entrySet()) { + JSONObject object = entry.getValue(); + if (object == null || object.isEmpty()) { + continue; + } + relationShapeModels.put(id + "_" + entry.getKey(), Arrays.asList(object.getString("text").split("\\|"))); + } + } - String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, plModel.getId()); - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - for (String id: elements.keySet()) { - JSONObject shapeObj = elements.getJSONObject(id); - String name = shapeObj.getString("name"); - if ("linker".equals(name)) { - continue; - } - Iterator modelIterator = DesignerShapeRelationCache.getByShapeId(plModel.getId(), id); - if (modelIterator != null) { - while (modelIterator.hasNext()) { - DesignerShapeRelationModel shapeRelationModel = modelIterator.next(); - PALRepositoryModel relationPalModel = PALRepositoryCache.getCache().get(shapeRelationModel.getRelationFileId()); - if (relationPalModel != null) { - relationShapeIds.put(shapeRelationModel.getRelationShapeId(), shapeRelationModel); - } - } - } - Map map = PALRepositoryQueryAPIManager.getInstance().queryRepositoryShapeAttributeById(plModel.getId(), id, shapeObj, "|"); - for (Entry entry : map.entrySet()) { - JSONObject object = entry.getValue(); - if (object == null || object.isEmpty()) { - continue; - } - relationShapeModels.put(id + "_" + entry.getKey(), Arrays.asList(object.getString("text").split("\\|"))); - } - } + macroLibraries.put("relationShapes", relationShapeIds); + macroLibraries.put("relationShapeModels", relationShapeModels); - macroLibraries.put("relationShapes", relationShapeIds); - macroLibraries.put("relationShapeModels", relationShapeModels); + if (defaultAttrSort != null && defaultAttrSort.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < defaultAttrSort.size(); i++) { + if (i == defaultAttrSort.size() - 1) { + sb.append(defaultAttrSort.get(i)); + } else { + sb.append(defaultAttrSort.get(i) + "|"); + } + } + macroLibraries.put("defaultAttrSort", sb.toString()); + } else { + macroLibraries.put("defaultAttrSort", ""); + } + macroLibraries.put("importShapeStyle", "display:none"); + StringBuilder sb = new StringBuilder(); + Set ids = new HashSet<>(); + sb.append(plModel.getName()); + ids.add(plModel.getId()); + getFilePath(sb, ids, plModel); + macroLibraries.put("toolbarName", sb.toString()); - if (defaultAttrSort != null && defaultAttrSort.size() > 0) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < defaultAttrSort.size(); i++) { - if (i == defaultAttrSort.size() - 1) { - sb.append(defaultAttrSort.get(i)); - } else { - sb.append(defaultAttrSort.get(i) + "|"); - } - } - macroLibraries.put("defaultAttrSort", sb.toString()); - } else { - macroLibraries.put("defaultAttrSort", ""); - } - macroLibraries.put("importShapeStyle", "display:none"); - StringBuilder sb = new StringBuilder(); - Set ids = new HashSet<>(); - sb.append(plModel.getName()); - ids.add(plModel.getId()); - getFilePath(sb, ids, plModel); - macroLibraries.put("toolbarName", sb.toString()); + List shapeIds = new ArrayList<>();// 当前流程所有节点 + List> shapeList = CoeDesignerUtil.getShapeMessageJson2(rUUID);//获取所有节点 + if (shapeList != null && shapeList.size() > 0) { + for (Map map : shapeList) { + shapeIds.add((String) map.get("id")); + } + } - List shapeIds = new ArrayList<>();// 当前流程所有节点 - List> shapeList = CoeDesignerUtil.getShapeMessageJson2(rUUID);//获取所有节点 - if (shapeList != null && shapeList.size() > 0) { - for (Map map : shapeList) { - shapeIds.add((String)map.get("id")); - } - } + getPalProcessLinkTag(plModel, macroLibraries); + /********************附件************************/ + // 文件或节点自身附件 + com.alibaba.fastjson.JSONObject upFileObject = new com.alibaba.fastjson.JSONObject(); + upFileObject.put("file", new JSONArray()); + for (String shape : shapeIds) { + upFileObject.put(shape, new JSONArray()); + } + UpFileDao upFileDao = new UpFileDao(); + StringBuilder sqlWhere = new StringBuilder(); + sqlWhere.append(" and PALREPOSITORYID ='").append(rUUID).append("'"); + sqlWhere.append("order by CREATETIME asc"); + List fileList = upFileDao.search(sqlWhere.toString()); - getPalProcessLinkTag(plModel, macroLibraries); - /********************附件************************/ - // 文件或节点自身附件 - com.alibaba.fastjson.JSONObject upFileObject = new com.alibaba.fastjson.JSONObject(); - upFileObject.put("file", new JSONArray()); - for (String shape : shapeIds) { - upFileObject.put(shape, new JSONArray()); - } - UpFileDao upFileDao = new UpFileDao(); - StringBuilder sqlWhere = new StringBuilder(); - sqlWhere.append(" and PALREPOSITORYID ='").append(rUUID).append("'"); - sqlWhere.append("order by CREATETIME asc"); - List fileList = upFileDao.search(sqlWhere.toString()); - - //三员管理下,过滤当前用户与文件密级显示 - if(HighSecurityUtil.isON()){ - macroLibraries.put("isHighSecurity", true); - PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc,fileList); - } - if (fileList != null && fileList.size() > 0) { - for (UpfileModel upfileModel : fileList) { - com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); - object.put("id", upfileModel.getUuid()); - object.put("name", upfileModel.getFileName()); - object.put("type", "self"); - if ("f".equals(upfileModel.getType())) { - upFileObject.getJSONArray("file").add(object); - } - if ("s".equals(upfileModel.getType())) { - if (upFileObject.getJSONArray(upfileModel.getShape_uuid()) == null) { - continue; - } + //三员管理下,过滤当前用户与文件密级显示 + if (HighSecurityUtil.isON()) { + macroLibraries.put("isHighSecurity", true); + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc, fileList); + } + if (fileList != null && fileList.size() > 0) { + for (UpfileModel upfileModel : fileList) { + com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); + object.put("id", upfileModel.getUuid()); + object.put("name", upfileModel.getFileName()); + object.put("type", "self"); + if ("f".equals(upfileModel.getType())) { + upFileObject.getJSONArray("file").add(object); + } + if ("s".equals(upfileModel.getType())) { + if (upFileObject.getJSONArray(upfileModel.getShape_uuid()) == null) { + continue; + } - String filename=upfileModel.getFileName().substring(upfileModel.getFileName().lastIndexOf(".")); + String filename = upfileModel.getFileName().substring(upfileModel.getFileName().lastIndexOf(".")); - if(!filename.equals(".xml")){ - upFileObject.getJSONArray(upfileModel.getShape_uuid()).add(object); - } + if (!filename.equals(".xml")) { + upFileObject.getJSONArray(upfileModel.getShape_uuid()).add(object); + } - } - } - } + } + } + } - // 文件或节点的关联节点的附件 - //查询流程和节点附件 - List relationList = null; - // 查询关联的节点 - DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); - relationList = relationDao.getModelListByFileId(rUUID); + // 文件或节点的关联节点的附件 + //查询流程和节点附件 + List relationList = null; + // 查询关联的节点 + DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); + relationList = relationDao.getModelListByFileId(rUUID); - //关联文件list - List relationUpfFileList = new ArrayList<>(); + //关联文件list + List relationUpfFileList = new ArrayList<>(); /*if (relationList != null && relationList.size() > 0) { for (int i = 0; i < relationList.size(); i++) { DesignerShapeRelationModel model = relationList.get(i); @@ -3193,318 +3170,314 @@ public class CoeDesignerWeb extends ActionWeb { } }*/ - if (relationUpfFileList != null && relationUpfFileList.size() > 0) { - //三员管理,过滤关联文件密级显示 - if(HighSecurityUtil.isON()){ - PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc,relationUpfFileList); - } - for (UpfileModel relationUpFile : relationUpfFileList) { - com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); - object.put("id", relationUpFile.getUuid()); - object.put("name", relationUpFile.getFileName()); - object.put("type", "relation"); - upFileObject.getJSONArray("file").add(object);// 文件 - } - } - macroLibraries.put("upfileData", upFileObject); - /********************附件************************/ - /********************步骤说明************************/ - // 获取所有关联属性 - JSONObject relationShapes = new JSONObject(); - if (shapeList != null && shapeList.size() > 0) { - for (Map map : shapeList) { - String shapeId1 = (String)map.get("id"); - relationShapes.put(shapeId1, new JSONObject()); - String shapeName = (String) map.get("type"); - String shapeCategory = (String) map.get("category"); - String shapeMethod = shapeCategory.replace("_", "."); - List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(plModel.getWsId(), shapeMethod, shapeName, plModel.getMethodId()); - Map refMap = new HashMap(); - Map attrTypeMap = new HashMap<>(); - for (PALMethodAttributeModel model : attributeModelList) { - if (!model.getUse()) { - continue; - } - if ("relation".equals(model.getType()) || "awsorg".equals(model.getType())) { - refMap.put(model.getKey(), JSON.parseObject(model.getRef())); - } - attrTypeMap.put(model.getKey(), model.getType()); - } - List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(plModel.getId(), shapeId1, null, null); - List modelList = new ArrayList<>(); - for (DesignerShapeRelationModel model : list) { - String attrId = model.getAttrId(); - if (attrTypeMap.containsKey(attrId)) { - if ("relation".equals(attrTypeMap.get(attrId))) { - if (refMap.containsKey(attrId)) { - String relationType = refMap.get(attrId).getString("type"); - if ("file".equals(relationType)) {// 关联的文件 - List list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); - for (PALRepositoryModel model2 : list2) { - if (model2.isUse()) { - model.setRelationShapeText(model2.getName()); - model.setRelationFileId(model2.getId()); - break; - } - } - modelList.add(model); - } else { - modelList.add(model); - } - } - } else if ("awsorg".equals(attrTypeMap.get(attrId))) { - JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); - String id = object.getString("id"); - HashSet keys = new HashSet<>(); - if (!keys.contains(id)) { - // 查询最新名称 - if ("department".equals(object.getString("type"))) { - DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); - if (dept == null) continue; - object.put("name", dept.getName()); - } - if ("position".equals(object.getString("type"))) { - RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); - if (roleModel == null) continue; - object.put("name", roleModel.getName()); - } - if ("user".equals(object.getString("type"))) { - UserModel user = SDK.getORGAPI().getUser(object.getString("id")); - if (user == null) continue; - object.put("name", user.getUserName()); - } - if ("role".equals(object.getString("type"))) { - RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); - if (roleModel == null) continue; - object.put("name", roleModel.getName()); - } - modelList.add(model); - keys.add(id); - } - } + if (relationUpfFileList != null && relationUpfFileList.size() > 0) { + //三员管理,过滤关联文件密级显示 + if (HighSecurityUtil.isON()) { + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc, relationUpfFileList); + } + for (UpfileModel relationUpFile : relationUpfFileList) { + com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); + object.put("id", relationUpFile.getUuid()); + object.put("name", relationUpFile.getFileName()); + object.put("type", "relation"); + upFileObject.getJSONArray("file").add(object);// 文件 + } + } + macroLibraries.put("upfileData", upFileObject); + /********************附件************************/ + /********************步骤说明************************/ + // 获取所有关联属性 + JSONObject relationShapes = new JSONObject(); + if (shapeList != null && shapeList.size() > 0) { + for (Map map : shapeList) { + String shapeId1 = (String) map.get("id"); + relationShapes.put(shapeId1, new JSONObject()); + String shapeName = (String) map.get("type"); + String shapeCategory = (String) map.get("category"); + String shapeMethod = shapeCategory.replace("_", "."); + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(plModel.getWsId(), shapeMethod, shapeName, plModel.getMethodId()); + Map refMap = new HashMap(); + Map attrTypeMap = new HashMap<>(); + for (PALMethodAttributeModel model : attributeModelList) { + if (!model.getUse()) { + continue; + } + if ("relation".equals(model.getType()) || "awsorg".equals(model.getType())) { + refMap.put(model.getKey(), JSON.parseObject(model.getRef())); + } + attrTypeMap.put(model.getKey(), model.getType()); + } + List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(plModel.getId(), shapeId1, null, null); + List modelList = new ArrayList<>(); + for (DesignerShapeRelationModel model : list) { + String attrId = model.getAttrId(); + if (attrTypeMap.containsKey(attrId)) { + if ("relation".equals(attrTypeMap.get(attrId))) { + if (refMap.containsKey(attrId)) { + String relationType = refMap.get(attrId).getString("type"); + if ("file".equals(relationType)) {// 关联的文件 + List list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + model.setRelationShapeText(model2.getName()); + model.setRelationFileId(model2.getId()); + break; + } + } + modelList.add(model); + } else { + modelList.add(model); + } + } + } else if ("awsorg".equals(attrTypeMap.get(attrId))) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + String id = object.getString("id"); + HashSet keys = new HashSet<>(); + if (!keys.contains(id)) { + // 查询最新名称 + if ("department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept == null) continue; + object.put("name", dept.getName()); + } + if ("position".equals(object.getString("type"))) { + RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); + if (roleModel == null) continue; + object.put("name", roleModel.getName()); + } + if ("user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user == null) continue; + object.put("name", user.getUserName()); + } + if ("role".equals(object.getString("type"))) { + RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); + if (roleModel == null) continue; + object.put("name", roleModel.getName()); + } + modelList.add(model); + keys.add(id); + } + } - } + } - } - // 去重 - List tempList = new ArrayList(); - Set keys = new HashSet<>(); - for (DesignerShapeRelationModel model : modelList) { - String key = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId() + model.getRelationShapeText(); - if (!keys.contains(key)) { - tempList.add(model); - keys.add(key); - } - } - modelList = tempList; - modelList.sort((m1, m2) -> {return m1.getId().compareTo(m2.getId());}); - for (DesignerShapeRelationModel model : modelList) { - if (attrTypeMap.containsKey(model.getAttrId())) { - if ("relation".equals(attrTypeMap.get(model.getAttrId()))) { - if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { - relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + model.getRelationShapeText()); - } else { - relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), model.getRelationShapeText()); - } - } else if ("awsorg".equals(attrTypeMap.get(model.getAttrId()))) { - if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { - relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + JSONObject.parseObject(model.getRelationShapeText()).getString("name")); - } else { - relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), JSONObject.parseObject(model.getRelationShapeText()).getString("name")); - } - } - } - } - } - } - boolean isLaneAttrConfig = appApi.getPropertyBooleanValue(CoEConstant.APP_ID, "IS_LANE_ATTR_CONFIG", false); - boolean isLaneForceRefreshShapeAttr = appApi.getPropertyBooleanValue(CoEConstant.APP_ID, "IS_LANE_FORCE_REFRESH_SHAPE_ATTR", false); - macroLibraries.put("isLaneAttrConfig", isLaneAttrConfig); - macroLibraries.put("isLaneForceRefreshShapeAttr", isLaneForceRefreshShapeAttr); + } + // 去重 + List tempList = new ArrayList(); + Set keys = new HashSet<>(); + for (DesignerShapeRelationModel model : modelList) { + String key = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId() + model.getRelationShapeText(); + if (!keys.contains(key)) { + tempList.add(model); + keys.add(key); + } + } + modelList = tempList; + modelList.sort((m1, m2) -> { + return m1.getId().compareTo(m2.getId()); + }); + for (DesignerShapeRelationModel model : modelList) { + if (attrTypeMap.containsKey(model.getAttrId())) { + if ("relation".equals(attrTypeMap.get(model.getAttrId()))) { + if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + model.getRelationShapeText()); + } else { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), model.getRelationShapeText()); + } + } else if ("awsorg".equals(attrTypeMap.get(model.getAttrId()))) { + if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + JSONObject.parseObject(model.getRelationShapeText()).getString("name")); + } else { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), JSONObject.parseObject(model.getRelationShapeText()).getString("name")); + } + } + } + } + } + } + boolean isLaneAttrConfig = appApi.getPropertyBooleanValue(CoEConstant.APP_ID, "IS_LANE_ATTR_CONFIG", false); + boolean isLaneForceRefreshShapeAttr = appApi.getPropertyBooleanValue(CoEConstant.APP_ID, "IS_LANE_FORCE_REFRESH_SHAPE_ATTR", false); + macroLibraries.put("isLaneAttrConfig", isLaneAttrConfig); + macroLibraries.put("isLaneForceRefreshShapeAttr", isLaneForceRefreshShapeAttr); - macroLibraries.put("relationShapesData", relationShapes); - /********************步骤说明************************/ - /********************描述************************/ - // 自定义属性 - JSONObject object = CoeProcessLevelUtil.getProcessLevelPropertyVal(plModel.getId()); - macroLibraries.put("processDesc", object); - if (upVisit) { - PALRepositoryQueryAPIManager.getInstance().UpDatePublishCount(plModel); - } - /********************描述************************/ + macroLibraries.put("relationShapesData", relationShapes); + /********************步骤说明************************/ + /********************描述************************/ + // 自定义属性 + JSONObject object = CoeProcessLevelUtil.getProcessLevelPropertyVal(plModel.getId()); + macroLibraries.put("processDesc", object); + if (upVisit) { + PALRepositoryQueryAPIManager.getInstance().UpDatePublishCount(plModel); + } + /********************描述************************/ - if(plModel.getMethodId().equals("process.evc")){ - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.portal.framework.html", macroLibraries); - }else{ - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.portal.html", macroLibraries); - } + if (plModel.getMethodId().equals("process.evc")) { + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.portal.framework.html", macroLibraries); + } else { + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.portal.html", macroLibraries); + } - - } + } + /** + * 门户流程详情详情 (移动端) + * + * @param rUUID 流程ID + * @param upVisit 记录访问量+1,true:记录 ;false:不记录 + * @param taskId 流程手册id + * @return + */ + public String getMobilePortalDesignerHtml(String rUUID, boolean upVisit, String taskId) { + String processDefId = ""; + Map macroLibraries = new HashMap(); + macroLibraries.put("selectedElementId", ""); + macroLibraries.put("js", ""); + PALRepositoryModelImpl plModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(rUUID); + if (plModel == null) { + return AlertWindow.getNotFoundMessagePage("未找到文件", "该文件已被删除"); + } + macroLibraries.put("taskId", taskId); + // 增加三员管理模式taskid为new,change判断 + if ("process".equals(plModel.getMethodCategory()) && !UtilString.isEmpty(taskId) && !"submit_create".equals(taskId) && !"new".equals(taskId) && !"change".equals(taskId)) { + macroLibraries.put("outputFileName", plModel.getName() + ".doc"); + macroLibraries.put("taskId", taskId); + // 压缩包名称 和 手册模板 + OutputTaskModel taskModel = new OutputTask().getTaskReportById(taskId); + if (taskModel != null) { + // 压缩包名称 + macroLibraries.put("taskName", taskModel.getTaskName() + ".zip"); + OutputAppProfile appFile = OutputAppManager.getProfile(taskModel.getProfileId()); + // 手册模板(com.actionsoft.apps.coe.pal.output.pr) + macroLibraries.put("taskProfile", appFile.getAppContext().getId()); + } + } + String type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; + if (plModel.getMethodId() != null && plModel.getMethodId().indexOf(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN) != -1) { + type = CoeDesignerConstant.DESIGNER_DIFINITION_BPMN; + } else { + type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; + } + boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(plModel.getId(), true); + macroLibraries.put("isMarked", false); + //默认排序 + List defaultAttrSort; + if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { + // 删除与BPMS关联的无效关联关系 + CoeProcessLevelUtil.deleteInvalidCorrelate(plModel.getId()); + if (isCorrelateBpms) { + processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(plModel.getId(), true); + } else { + processDefId = ""; + } + getBpmnDesginerUI(plModel, macroLibraries, true, true); + defaultAttrSort = getBpmnParams(plModel, processDefId, macroLibraries); + macroLibraries.put("isMarked", CoeProcessLevelUtil.hasMarked(plModel.getId())); + } else { + getCoeDesginerUI(plModel, macroLibraries, true, true); + defaultAttrSort = getCoeParams(plModel, macroLibraries); + } + int state = 0;// 版本状态:设计、运行、停用 + if (isCorrelateBpms) { + ProcessDefinition definition = ProcessDefCache.getInstance().get(processDefId); + if (definition != null) { + state = definition.getVersionStatus(); + } + } + macroLibraries.put("BPMNSupport", AWSServerEngineConfiguration.getEngineBPMNSupport()); + macroLibraries.put("BPMNLevel0", AWSServerEngineConfiguration.getEngineBPMNLevel0()); + macroLibraries.put("BPMNLevel1", AWSServerEngineConfiguration.getEngineBPMNLevel1()); + macroLibraries.put("BPMNLevel2", AWSServerEngineConfiguration.getEngineBPMNLevel2()); + String userUrl = SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID()); + getMoreSharpe(plModel.getMethodId(), plModel.getId(), macroLibraries);// 获取更多图形 + macroLibraries.put("ver", 0); + macroLibraries.put("methodId", plModel.getMethodId()); + macroLibraries.put("sid", _uc.getSessionId()); + macroLibraries.put("wsId", plModel.getWsId()); + macroLibraries.put("uuid", rUUID);// definition的UUID + macroLibraries.put("parentChartId", plModel.getParentId()); + macroLibraries.put("uid", _uc.getUID()); + macroLibraries.put("userUrl", userUrl); + macroLibraries.put("userName", _uc.getUserModel().getUserName()); + macroLibraries.put("schema", getSchema(plModel.getId(), plModel.getMethodId(), PALMethodUtil.getCustom(plModel.getMethodId(), plModel.getId()))); + macroLibraries.put("sessionId", _uc.getSessionId()); + macroLibraries.put("fileName", ShapeUtil.replaceBlank(plModel.getName())); + macroLibraries.put("typeName", I18nRes.findValue(CoEConstant.APP_ID, plModel.getMethodCategory()) + "图"); + macroLibraries.put("openType", 0); + macroLibraries.put("teamId", ""); + macroLibraries.put("perms", "");// 该流程权限(w,d,v) + macroLibraries.put("filePerms", "");// 所有具有权限的流程Id + macroLibraries.put("isPublish", plModel.isPublish()); + CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); + boolean isAdmin = (userModel != null && (userModel.getIsAdmin() == 1)); + macroLibraries.put("isAdmin", isAdmin); + // 更多特性权限 + String moreAttrRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "MOREATTR_RIGHT");// 1普通用户有设置更多特性权限, + if ("2".equals(moreAttrRight)) {// 只有admin显示 + if ("admin".equals(_uc.getUID())) { + macroLibraries.put("moreAttrRight", true); + } else { + macroLibraries.put("moreAttrRight", false); + } + } else if ("0".equals(moreAttrRight)) {// 0只有管理员用户有权限 + if (isAdmin) {// 管理员用户 + macroLibraries.put("moreAttrRight", true); + } else {// 普通用户 + macroLibraries.put("moreAttrRight", false); + } + } else { + macroLibraries.put("moreAttrRight", true); + } + // 自动保存 + String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); + macroLibraries.put("isAutoSave", isSysAutoSave); + macroLibraries.put("checkoutTip", ""); + macroLibraries.put("isView", true);// 是否只读打开 + // 是否允许用户自定义模板,0:不允许;1:允许。 + AppAPI appApi = SDK.getAppAPI(); + String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); + macroLibraries.put("isCustomDefine", isCustomDefine); + macroLibraries.put("openAppType", "0"); - /** - * 门户流程详情详情 (移动端) - * @param rUUID 流程ID - * @param upVisit 记录访问量+1,true:记录 ;false:不记录 - * @param taskId 流程手册id - * @return - */ - public String getMobilePortalDesignerHtml(String rUUID, boolean upVisit, String taskId) { - String processDefId = ""; - Map macroLibraries = new HashMap(); - macroLibraries.put("selectedElementId", ""); - macroLibraries.put("js", ""); - PALRepositoryModelImpl plModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(rUUID); + macroLibraries.put("editable", "0"); - if (plModel == null) { - return AlertWindow.getNotFoundMessagePage("未找到文件", "该文件已被删除"); - } + if (plModel.isPublish()) { + long viewCount = plModel.getViewCount(); + plModel.setViewCount(viewCount + 1); + PALRepository dao = new PALRepository(); + dao.update(plModel); + } - macroLibraries.put("taskId", taskId); - // 增加三员管理模式taskid为new,change判断 - if ("process".equals(plModel.getMethodCategory()) && !UtilString.isEmpty(taskId) && !"submit_create".equals(taskId) && !"new".equals(taskId) && !"change".equals(taskId)) { - macroLibraries.put("outputFileName", plModel.getName() + ".doc"); - macroLibraries.put("taskId", taskId); - // 压缩包名称 和 手册模板 - OutputTaskModel taskModel = new OutputTask().getTaskReportById(taskId); - if(taskModel!=null){ - // 压缩包名称 - macroLibraries.put("taskName", taskModel.getTaskName() + ".zip"); - OutputAppProfile appFile = OutputAppManager.getProfile(taskModel.getProfileId()); - // 手册模板(com.actionsoft.apps.coe.pal.output.pr) - macroLibraries.put("taskProfile", appFile.getAppContext().getId()); - } - } + getDesginerDefaultParams(macroLibraries);// 获取默认参数配置 - String type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; - if (plModel.getMethodId() != null && plModel.getMethodId().indexOf(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN) != -1) { - type = CoeDesignerConstant.DESIGNER_DIFINITION_BPMN; - } else { - type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; - } + macroLibraries.put("usersPhoto", ""); + macroLibraries.put("userNum", ""); + DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); + Map> shapeMap = relationShapeCache.getShapemap(); + boolean isExistCopy = shapeMap.get(_uc.getUID()) != null; + boolean isAppearCopy = shapeMap.get(_uc.getUID()) == null || shapeMap.get(_uc.getUID()).get("shapeCopyContent") == null; + // 默认为定义复制 + macroLibraries.put("isExistCopy", isExistCopy); + macroLibraries.put("isAppearCopy", isAppearCopy); - boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(plModel.getId(), true); - macroLibraries.put("isMarked", false); - //默认排序 - List defaultAttrSort; - if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { - // 删除与BPMS关联的无效关联关系 - CoeProcessLevelUtil.deleteInvalidCorrelate(plModel.getId()); - if (isCorrelateBpms) { - processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(plModel.getId(), true); - } else { - processDefId = ""; - } - getBpmnDesginerUI(plModel, macroLibraries, true, true); - defaultAttrSort = getBpmnParams(plModel, processDefId, macroLibraries); - macroLibraries.put("isMarked", CoeProcessLevelUtil.hasMarked(plModel.getId())); - } else { - getCoeDesginerUI(plModel, macroLibraries, true, true); - defaultAttrSort = getCoeParams(plModel, macroLibraries); - } - int state = 0;// 版本状态:设计、运行、停用 - if (isCorrelateBpms) { - ProcessDefinition definition = ProcessDefCache.getInstance().get(processDefId); - if (definition != null) { - state = definition.getVersionStatus(); - } - } - macroLibraries.put("BPMNSupport", AWSServerEngineConfiguration.getEngineBPMNSupport()); - macroLibraries.put("BPMNLevel0", AWSServerEngineConfiguration.getEngineBPMNLevel0()); - macroLibraries.put("BPMNLevel1", AWSServerEngineConfiguration.getEngineBPMNLevel1()); - macroLibraries.put("BPMNLevel2", AWSServerEngineConfiguration.getEngineBPMNLevel2()); - String userUrl = SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID()); - getMoreSharpe(plModel.getMethodId(), plModel.getId(), macroLibraries);// 获取更多图形 - macroLibraries.put("ver", 0); - macroLibraries.put("methodId", plModel.getMethodId()); - macroLibraries.put("sid", _uc.getSessionId()); - macroLibraries.put("wsId", plModel.getWsId()); - macroLibraries.put("uuid", rUUID);// definition的UUID - macroLibraries.put("parentChartId", plModel.getParentId()); - macroLibraries.put("uid", _uc.getUID()); - macroLibraries.put("userUrl", userUrl); - macroLibraries.put("userName", _uc.getUserModel().getUserName()); - macroLibraries.put("schema", getSchema(plModel.getId(), plModel.getMethodId(), PALMethodUtil.getCustom(plModel.getMethodId(), plModel.getId()))); - macroLibraries.put("sessionId", _uc.getSessionId()); - macroLibraries.put("fileName", ShapeUtil.replaceBlank(plModel.getName())); - macroLibraries.put("typeName", I18nRes.findValue(CoEConstant.APP_ID, plModel.getMethodCategory()) + "图"); - macroLibraries.put("openType", 0); - macroLibraries.put("teamId", ""); - macroLibraries.put("perms", "");// 该流程权限(w,d,v) - macroLibraries.put("filePerms", "");// 所有具有权限的流程Id - macroLibraries.put("isPublish", plModel.isPublish()); - CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); - boolean isAdmin = (userModel != null && (userModel.getIsAdmin() == 1)); - macroLibraries.put("isAdmin", isAdmin); - // 更多特性权限 - String moreAttrRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "MOREATTR_RIGHT");// 1普通用户有设置更多特性权限, - if ("2".equals(moreAttrRight)) {// 只有admin显示 - if ("admin".equals(_uc.getUID())) { - macroLibraries.put("moreAttrRight", true); - } else { - macroLibraries.put("moreAttrRight", false); - } - } else if ("0".equals(moreAttrRight)) {// 0只有管理员用户有权限 - if (isAdmin) {// 管理员用户 - macroLibraries.put("moreAttrRight", true); - } else{// 普通用户 - macroLibraries.put("moreAttrRight", false); - } - } else { - macroLibraries.put("moreAttrRight", true); - } - // 自动保存 - String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); - macroLibraries.put("isAutoSave", isSysAutoSave); - macroLibraries.put("checkoutTip", ""); - macroLibraries.put("isView", true);// 是否只读打开 + macroLibraries.put("diagram", ""); + macroLibraries.put("state", state); + // DockBtnBar中的各功能是否显示 + macroLibraries.put("attributeView", ""); + macroLibraries.put("messageView", ""); + macroLibraries.put("printView", ""); + macroLibraries.put("publishView", ""); - // 是否允许用户自定义模板,0:不允许;1:允许。 - AppAPI appApi = SDK.getAppAPI(); - String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); - macroLibraries.put("isCustomDefine", isCustomDefine); - macroLibraries.put("openAppType", "0"); - - macroLibraries.put("editable", "0"); - - if (plModel.isPublish()) { - long viewCount = plModel.getViewCount(); - plModel.setViewCount(viewCount + 1); - PALRepository dao = new PALRepository(); - dao.update(plModel); - } - - getDesginerDefaultParams(macroLibraries);// 获取默认参数配置 - - macroLibraries.put("usersPhoto", ""); - macroLibraries.put("userNum", ""); - DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); - Map> shapeMap = relationShapeCache.getShapemap(); - boolean isExistCopy = shapeMap.get(_uc.getUID()) != null; - boolean isAppearCopy = shapeMap.get(_uc.getUID()) == null || shapeMap.get(_uc.getUID()).get("shapeCopyContent") == null; - // 默认为定义复制 - macroLibraries.put("isExistCopy", isExistCopy); - macroLibraries.put("isAppearCopy", isAppearCopy); - - macroLibraries.put("diagram", ""); - macroLibraries.put("state", state); - // DockBtnBar中的各功能是否显示 - macroLibraries.put("attributeView", ""); - macroLibraries.put("messageView", ""); - macroLibraries.put("printView", ""); - macroLibraries.put("publishView", ""); - - String riskStyle = "display:none;"; - // risk应用已下架 + String riskStyle = "display:none;"; + // risk应用已下架 // if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.risk") && SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.risk")) { // riskStyle = ""; // } @@ -3513,137 +3486,136 @@ public class CoeDesignerWeb extends ActionWeb { // } else { // riskStyle = "display:none;"; // } - macroLibraries.put("riskStyle", riskStyle); - String processOnIsInstall = "false"; - if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.processon")) { - processOnIsInstall = "true"; - } - String processOnIsActive = "false"; - if (SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.processon")) { - processOnIsActive = "true"; - } - macroLibraries.put("processOnIsInstall", processOnIsInstall); - macroLibraries.put("processOnIsActive", processOnIsActive); + macroLibraries.put("riskStyle", riskStyle); + String processOnIsInstall = "false"; + if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.processon")) { + processOnIsInstall = "true"; + } + String processOnIsActive = "false"; + if (SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.processon")) { + processOnIsActive = "true"; + } + macroLibraries.put("processOnIsInstall", processOnIsInstall); + macroLibraries.put("processOnIsActive", processOnIsActive); - JSONObject relationShapeIds = new JSONObject(); - JSONObject relationShapeModels = new JSONObject(); + JSONObject relationShapeIds = new JSONObject(); + JSONObject relationShapeModels = new JSONObject(); + String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, plModel.getId()); + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + for (String id : elements.keySet()) { + JSONObject shapeObj = elements.getJSONObject(id); + String name = shapeObj.getString("name"); + if ("linker".equals(name)) { + continue; + } + Iterator modelIterator = DesignerShapeRelationCache.getByShapeId(plModel.getId(), id); + if (modelIterator != null) { + while (modelIterator.hasNext()) { + DesignerShapeRelationModel shapeRelationModel = modelIterator.next(); + PALRepositoryModel relationPalModel = PALRepositoryCache.getCache().get(shapeRelationModel.getRelationFileId()); + if (relationPalModel != null) { + relationShapeIds.put(shapeRelationModel.getRelationShapeId(), shapeRelationModel); + } + } + } + Map map = PALRepositoryQueryAPIManager.getInstance().queryRepositoryShapeAttributeById(plModel.getId(), id, shapeObj, "|"); + for (Entry entry : map.entrySet()) { + JSONObject object = entry.getValue(); + if (object == null || object.isEmpty()) { + continue; + } + relationShapeModels.put(id + "_" + entry.getKey(), Arrays.asList(object.getString("text").split("\\|"))); + } + } - String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, plModel.getId()); - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - for (String id: elements.keySet()) { - JSONObject shapeObj = elements.getJSONObject(id); - String name = shapeObj.getString("name"); - if ("linker".equals(name)) { - continue; - } - Iterator modelIterator = DesignerShapeRelationCache.getByShapeId(plModel.getId(), id); - if (modelIterator != null) { - while (modelIterator.hasNext()) { - DesignerShapeRelationModel shapeRelationModel = modelIterator.next(); - PALRepositoryModel relationPalModel = PALRepositoryCache.getCache().get(shapeRelationModel.getRelationFileId()); - if (relationPalModel != null) { - relationShapeIds.put(shapeRelationModel.getRelationShapeId(), shapeRelationModel); - } - } - } - Map map = PALRepositoryQueryAPIManager.getInstance().queryRepositoryShapeAttributeById(plModel.getId(), id, shapeObj, "|"); - for (Entry entry : map.entrySet()) { - JSONObject object = entry.getValue(); - if (object == null || object.isEmpty()) { - continue; - } - relationShapeModels.put(id + "_" + entry.getKey(), Arrays.asList(object.getString("text").split("\\|"))); - } - } + macroLibraries.put("relationShapes", relationShapeIds); + macroLibraries.put("relationShapeModels", relationShapeModels); - macroLibraries.put("relationShapes", relationShapeIds); - macroLibraries.put("relationShapeModels", relationShapeModels); + if (defaultAttrSort != null && defaultAttrSort.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < defaultAttrSort.size(); i++) { + if (i == defaultAttrSort.size() - 1) { + sb.append(defaultAttrSort.get(i)); + } else { + sb.append(defaultAttrSort.get(i) + "|"); + } + } + macroLibraries.put("defaultAttrSort", sb.toString()); + } else { + macroLibraries.put("defaultAttrSort", ""); + } + macroLibraries.put("importShapeStyle", "display:none"); + StringBuilder sb = new StringBuilder(); + Set ids = new HashSet<>(); + sb.append(plModel.getName()); + ids.add(plModel.getId()); + getFilePath(sb, ids, plModel); + macroLibraries.put("toolbarName", plModel.getName()); - if (defaultAttrSort != null && defaultAttrSort.size() > 0) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < defaultAttrSort.size(); i++) { - if (i == defaultAttrSort.size() - 1) { - sb.append(defaultAttrSort.get(i)); - } else { - sb.append(defaultAttrSort.get(i) + "|"); - } - } - macroLibraries.put("defaultAttrSort", sb.toString()); - } else { - macroLibraries.put("defaultAttrSort", ""); - } - macroLibraries.put("importShapeStyle", "display:none"); - StringBuilder sb = new StringBuilder(); - Set ids = new HashSet<>(); - sb.append(plModel.getName()); - ids.add(plModel.getId()); - getFilePath(sb, ids, plModel); - macroLibraries.put("toolbarName", plModel.getName()); + List shapeIds = new ArrayList<>();// 当前流程所有节点 + List> shapeList = CoeDesignerUtil.getShapeMessageJson2(rUUID);//获取所有节点 + if (shapeList != null && shapeList.size() > 0) { + for (Map map : shapeList) { + shapeIds.add((String) map.get("id")); + } + } - List shapeIds = new ArrayList<>();// 当前流程所有节点 - List> shapeList = CoeDesignerUtil.getShapeMessageJson2(rUUID);//获取所有节点 - if (shapeList != null && shapeList.size() > 0) { - for (Map map : shapeList) { - shapeIds.add((String)map.get("id")); - } - } + getPalProcessLinkTag(plModel, macroLibraries); + /********************附件************************/ + // 文件或节点自身附件 + com.alibaba.fastjson.JSONObject upFileObject = new com.alibaba.fastjson.JSONObject(); + upFileObject.put("file", new JSONArray()); + for (String shape : shapeIds) { + upFileObject.put(shape, new JSONArray()); + } + UpFileDao upFileDao = new UpFileDao(); + StringBuilder sqlWhere = new StringBuilder(); + sqlWhere.append(" and PALREPOSITORYID ='").append(rUUID).append("'"); + List fileList = upFileDao.search(sqlWhere.toString()); - getPalProcessLinkTag(plModel, macroLibraries); - /********************附件************************/ - // 文件或节点自身附件 - com.alibaba.fastjson.JSONObject upFileObject = new com.alibaba.fastjson.JSONObject(); - upFileObject.put("file", new JSONArray()); - for (String shape : shapeIds) { - upFileObject.put(shape, new JSONArray()); - } - UpFileDao upFileDao = new UpFileDao(); - StringBuilder sqlWhere = new StringBuilder(); - sqlWhere.append(" and PALREPOSITORYID ='").append(rUUID).append("'"); - List fileList = upFileDao.search(sqlWhere.toString()); - - //三员管理下,过滤当前用户与文件密级显示 - if(HighSecurityUtil.isON()){ - macroLibraries.put("isHighSecurity", true); - PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc,fileList); - } - if (fileList != null && fileList.size() > 0) { - for (UpfileModel upfileModel : fileList) { - com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); - object.put("id", upfileModel.getUuid()); - object.put("name", upfileModel.getFileName()); - object.put("type", "self"); - if ("f".equals(upfileModel.getType())) { - upFileObject.getJSONArray("file").add(object); - } - if ("s".equals(upfileModel.getType())) { - if (upFileObject.getJSONArray(upfileModel.getShape_uuid()) == null) { - continue; - } + //三员管理下,过滤当前用户与文件密级显示 + if (HighSecurityUtil.isON()) { + macroLibraries.put("isHighSecurity", true); + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc, fileList); + } + if (fileList != null && fileList.size() > 0) { + for (UpfileModel upfileModel : fileList) { + com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); + object.put("id", upfileModel.getUuid()); + object.put("name", upfileModel.getFileName()); + object.put("type", "self"); + if ("f".equals(upfileModel.getType())) { + upFileObject.getJSONArray("file").add(object); + } + if ("s".equals(upfileModel.getType())) { + if (upFileObject.getJSONArray(upfileModel.getShape_uuid()) == null) { + continue; + } - String filename=upfileModel.getFileName().substring(upfileModel.getFileName().lastIndexOf(".")); + String filename = upfileModel.getFileName().substring(upfileModel.getFileName().lastIndexOf(".")); - if(!filename.equals(".xml")){ - upFileObject.getJSONArray(upfileModel.getShape_uuid()).add(object); - } + if (!filename.equals(".xml")) { + upFileObject.getJSONArray(upfileModel.getShape_uuid()).add(object); + } - } - } - } + } + } + } - // 文件或节点的关联节点的附件 - //查询流程和节点附件 - List relationList = null; - // 查询关联的节点 - DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); - relationList = relationDao.getModelListByFileId(rUUID); + // 文件或节点的关联节点的附件 + //查询流程和节点附件 + List relationList = null; + // 查询关联的节点 + DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); + relationList = relationDao.getModelListByFileId(rUUID); - //关联文件list - List relationUpfFileList = new ArrayList<>(); + //关联文件list + List relationUpfFileList = new ArrayList<>(); /*if (relationList != null && relationList.size() > 0) { for (int i = 0; i < relationList.size(); i++) { DesignerShapeRelationModel model = relationList.get(i); @@ -3658,702 +3630,710 @@ public class CoeDesignerWeb extends ActionWeb { } }*/ - if (relationUpfFileList != null && relationUpfFileList.size() > 0) { - //三员管理,过滤关联文件密级显示 - if(HighSecurityUtil.isON()){ - PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc,relationUpfFileList); - } - for (UpfileModel relationUpFile : relationUpfFileList) { - com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); - object.put("id", relationUpFile.getUuid()); - object.put("name", relationUpFile.getFileName()); - object.put("type", "relation"); - upFileObject.getJSONArray("file").add(object);// 文件 - } - } - macroLibraries.put("upfileData", upFileObject); - /********************附件************************/ - /********************步骤说明************************/ - // 获取所有关联属性 - JSONObject relationShapes = new JSONObject(); - if (shapeList != null && shapeList.size() > 0) { - for (Map map : shapeList) { - String shapeId1 = (String)map.get("id"); - relationShapes.put(shapeId1, new JSONObject()); - String shapeName = (String) map.get("type"); - String shapeCategory = (String) map.get("category"); - String shapeMethod = shapeCategory.replace("_", "."); - List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(plModel.getWsId(), shapeMethod, shapeName, plModel.getMethodId()); - Map refMap = new HashMap(); - Map attrTypeMap = new HashMap<>(); - for (PALMethodAttributeModel model : attributeModelList) { - if (!model.getUse()) { - continue; - } - if ("relation".equals(model.getType()) || "awsorg".equals(model.getType())) { - refMap.put(model.getKey(), JSON.parseObject(model.getRef())); - } - attrTypeMap.put(model.getKey(), model.getType()); - } - List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(plModel.getId(), shapeId1, null, null); - List modelList = new ArrayList<>(); - for (DesignerShapeRelationModel model : list) { - String attrId = model.getAttrId(); - if (attrTypeMap.containsKey(attrId)) { - if ("relation".equals(attrTypeMap.get(attrId))) { - if (refMap.containsKey(attrId)) { - String relationType = refMap.get(attrId).getString("type"); - if ("file".equals(relationType)) {// 关联的文件 - List list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); - for (PALRepositoryModel model2 : list2) { - if (model2.isUse()) { - model.setRelationShapeText(model2.getName()); - model.setRelationFileId(model2.getId()); - break; - } - } - modelList.add(model); - } else { - modelList.add(model); - } - } - } else if ("awsorg".equals(attrTypeMap.get(attrId))) { - JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); - String id = object.getString("id"); - HashSet keys = new HashSet<>(); - if (!keys.contains(id)) { - // 查询最新名称 - if ("department".equals(object.getString("type"))) { - DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); - if (dept == null) continue; - object.put("name", dept.getName()); - } - if ("position".equals(object.getString("type"))) { - RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); - if (roleModel == null) continue; - object.put("name", roleModel.getName()); - } - if ("user".equals(object.getString("type"))) { - UserModel user = SDK.getORGAPI().getUser(object.getString("id")); - if (user == null) continue; - object.put("name", user.getUserName()); - } - if ("role".equals(object.getString("type"))) { - RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); - if (roleModel == null) continue; - object.put("name", roleModel.getName()); - } - modelList.add(model); - keys.add(id); - } - } + if (relationUpfFileList != null && relationUpfFileList.size() > 0) { + //三员管理,过滤关联文件密级显示 + if (HighSecurityUtil.isON()) { + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc, relationUpfFileList); + } + for (UpfileModel relationUpFile : relationUpfFileList) { + com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); + object.put("id", relationUpFile.getUuid()); + object.put("name", relationUpFile.getFileName()); + object.put("type", "relation"); + upFileObject.getJSONArray("file").add(object);// 文件 + } + } + macroLibraries.put("upfileData", upFileObject); + /********************附件************************/ + /********************步骤说明************************/ + // 获取所有关联属性 + JSONObject relationShapes = new JSONObject(); + if (shapeList != null && shapeList.size() > 0) { + for (Map map : shapeList) { + String shapeId1 = (String) map.get("id"); + relationShapes.put(shapeId1, new JSONObject()); + String shapeName = (String) map.get("type"); + String shapeCategory = (String) map.get("category"); + String shapeMethod = shapeCategory.replace("_", "."); + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(plModel.getWsId(), shapeMethod, shapeName, plModel.getMethodId()); + Map refMap = new HashMap(); + Map attrTypeMap = new HashMap<>(); + for (PALMethodAttributeModel model : attributeModelList) { + if (!model.getUse()) { + continue; + } + if ("relation".equals(model.getType()) || "awsorg".equals(model.getType())) { + refMap.put(model.getKey(), JSON.parseObject(model.getRef())); + } + attrTypeMap.put(model.getKey(), model.getType()); + } + List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(plModel.getId(), shapeId1, null, null); + List modelList = new ArrayList<>(); + for (DesignerShapeRelationModel model : list) { + String attrId = model.getAttrId(); + if (attrTypeMap.containsKey(attrId)) { + if ("relation".equals(attrTypeMap.get(attrId))) { + if (refMap.containsKey(attrId)) { + String relationType = refMap.get(attrId).getString("type"); + if ("file".equals(relationType)) {// 关联的文件 + List list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + model.setRelationShapeText(model2.getName()); + model.setRelationFileId(model2.getId()); + break; + } + } + modelList.add(model); + } else { + modelList.add(model); + } + } + } else if ("awsorg".equals(attrTypeMap.get(attrId))) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + String id = object.getString("id"); + HashSet keys = new HashSet<>(); + if (!keys.contains(id)) { + // 查询最新名称 + if ("department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept == null) continue; + object.put("name", dept.getName()); + } + if ("position".equals(object.getString("type"))) { + RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); + if (roleModel == null) continue; + object.put("name", roleModel.getName()); + } + if ("user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user == null) continue; + object.put("name", user.getUserName()); + } + if ("role".equals(object.getString("type"))) { + RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); + if (roleModel == null) continue; + object.put("name", roleModel.getName()); + } + modelList.add(model); + keys.add(id); + } + } - } + } - } - // 去重 - List tempList = new ArrayList(); - Set keys = new HashSet<>(); - for (DesignerShapeRelationModel model : modelList) { - String key = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId() + model.getRelationShapeText(); - if (!keys.contains(key)) { - tempList.add(model); - keys.add(key); - } - } - modelList = tempList; - modelList.sort((m1, m2) -> {return m1.getId().compareTo(m2.getId());}); - for (DesignerShapeRelationModel model : modelList) { - if (attrTypeMap.containsKey(model.getAttrId())) { - if ("relation".equals(attrTypeMap.get(model.getAttrId()))) { - if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { - relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + model.getRelationShapeText()); - } else { - relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), model.getRelationShapeText()); - } - } else if ("awsorg".equals(attrTypeMap.get(model.getAttrId()))) { - if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { - relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + JSONObject.parseObject(model.getRelationShapeText()).getString("name")); - } else { - relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), JSONObject.parseObject(model.getRelationShapeText()).getString("name")); - } - } - } - } - } - } - macroLibraries.put("relationShapesData", relationShapes); - /********************步骤说明************************/ - /********************描述************************/ - // 自定义属性 - JSONObject object = CoeProcessLevelUtil.getProcessLevelPropertyVal(plModel.getId()); - macroLibraries.put("processDesc", object); - if (upVisit) { - PALRepositoryQueryAPIManager.getInstance().UpDatePublishCount(plModel); - } - /********************描述************************/ - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.portal.mobile.html", macroLibraries); - } + } + // 去重 + List tempList = new ArrayList(); + Set keys = new HashSet<>(); + for (DesignerShapeRelationModel model : modelList) { + String key = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId() + model.getRelationShapeText(); + if (!keys.contains(key)) { + tempList.add(model); + keys.add(key); + } + } + modelList = tempList; + modelList.sort((m1, m2) -> { + return m1.getId().compareTo(m2.getId()); + }); + for (DesignerShapeRelationModel model : modelList) { + if (attrTypeMap.containsKey(model.getAttrId())) { + if ("relation".equals(attrTypeMap.get(model.getAttrId()))) { + if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + model.getRelationShapeText()); + } else { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), model.getRelationShapeText()); + } + } else if ("awsorg".equals(attrTypeMap.get(model.getAttrId()))) { + if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + JSONObject.parseObject(model.getRelationShapeText()).getString("name")); + } else { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), JSONObject.parseObject(model.getRelationShapeText()).getString("name")); + } + } + } + } + } + } + macroLibraries.put("relationShapesData", relationShapes); + /********************步骤说明************************/ + /********************描述************************/ + // 自定义属性 + JSONObject object = CoeProcessLevelUtil.getProcessLevelPropertyVal(plModel.getId()); + macroLibraries.put("processDesc", object); + if (upVisit) { + PALRepositoryQueryAPIManager.getInstance().UpDatePublishCount(plModel); + } + /********************描述************************/ + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.portal.mobile.html", macroLibraries); + } - /** - * 根据method获取当前文件所定义的自定义属性 - * @param model - */ - public List getFileAttrListByMethod(PALRepositoryModel model) { - PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); - if(palMethodModel == null) { - return null; - } - List attributes = palMethodModel.getAttributes(); - List tempList = new ArrayList<>(); - if (attributes != null) { - for (PALMethodAttributeModel attributeModel : attributes) { - String scope = attributeModel.getScope(); - if ("%".equals(scope) || scope.contains("%")) { - PALRepositoryAttributeModel attrModel = PALRepositoryAttributeCache.getAttributeByMethodIdAndAttrId(model.getWsId(), model.getMethodId(), attributeModel.getKey()); - if (attrModel != null && "0".equals(attrModel.getIsDelete())) { - tempList.add(attributeModel); - } - } - } - } - return tempList; - } + /** + * 根据method获取当前文件所定义的自定义属性 + * + * @param model + */ + public List getFileAttrListByMethod(PALRepositoryModel model) { + PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(model.getMethodId()); + if (palMethodModel == null) { + return null; + } + List attributes = palMethodModel.getAttributes(); + List tempList = new ArrayList<>(); + if (attributes != null) { + for (PALMethodAttributeModel attributeModel : attributes) { + String scope = attributeModel.getScope(); + if ("%".equals(scope) || scope.contains("%")) { + PALRepositoryAttributeModel attrModel = PALRepositoryAttributeCache.getAttributeByMethodIdAndAttrId(model.getWsId(), model.getMethodId(), attributeModel.getKey()); + if (attrModel != null && "0".equals(attrModel.getIsDelete())) { + tempList.add(attributeModel); + } + } + } + } + return tempList; + } - /** - * 更多属性 - * - * @param uuid - * @return - */ - public List getMoreAttr(String uuid) { - if ("0".equals(uuid)) { - return null; - } - if (uuid != null && !"".equals(uuid)) { - PALRepositoryModel m = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(m.getMethodId()); - if (palMethodModel == null) { - return null; - } - List group = palMethodModel.getGroup(); - List parentList = new ArrayList<>(); - if (group != null) { - for (PALMethodAttributeGroupModel groupModel : group) { - parentList.add(groupModel.getName()); - } - } - List attributes = palMethodModel.getAttributes(); - List result = new ArrayList<>(); - if (attributes != null) { - for (int i = 0; i < parentList.size(); i++) { - String parent = parentList.get(i); - result.add(parent); - for (PALMethodAttributeModel AttributeModel : attributes) { - if (parentList.get(i).equals(AttributeModel.getGroupPath())) { - result.add(AttributeModel.getKey()); - } - } - } - } - return result; - } - return null; - } + /** + * 更多属性 + * + * @param uuid + * @return + */ + public List getMoreAttr(String uuid) { + if ("0".equals(uuid)) { + return null; + } + if (uuid != null && !"".equals(uuid)) { + PALRepositoryModel m = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(m.getMethodId()); + if (palMethodModel == null) { + return null; + } + List group = palMethodModel.getGroup(); + List parentList = new ArrayList<>(); + if (group != null) { + for (PALMethodAttributeGroupModel groupModel : group) { + parentList.add(groupModel.getName()); + } + } + List attributes = palMethodModel.getAttributes(); + List result = new ArrayList<>(); + if (attributes != null) { + for (int i = 0; i < parentList.size(); i++) { + String parent = parentList.get(i); + result.add(parent); + for (PALMethodAttributeModel AttributeModel : attributes) { + if (parentList.get(i).equals(AttributeModel.getGroupPath())) { + result.add(AttributeModel.getKey()); + } + } + } + } + return result; + } + return null; + } - private void getFilePath(StringBuilder sb, Set ids, PALRepositoryModel plModel) { - if (plModel.getParentId().length() >= 36) { - PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(plModel.getParentId()); - if (parentModel == null) { - parentModel = PALRepositoryCache.getCache().get(plModel.getVersionId()); - } - if (parentModel != null && !ids.contains(parentModel.getId()) && !ids.contains(parentModel.getVersionId())) { - sb.insert(0, parentModel.getName() + ">"); - ids.add(parentModel.getId()); - getFilePath(sb, ids, parentModel); - } - } - } + private void getFilePath(StringBuilder sb, Set ids, PALRepositoryModel plModel) { + if (plModel.getParentId().length() >= 36) { + PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(plModel.getParentId()); + if (parentModel == null) { + parentModel = PALRepositoryCache.getCache().get(plModel.getVersionId()); + } + if (parentModel != null && !ids.contains(parentModel.getId()) && !ids.contains(parentModel.getVersionId())) { + sb.insert(0, parentModel.getName() + ">"); + ids.add(parentModel.getId()); + getFilePath(sb, ids, parentModel); + } + } + } - /** - * 门户打开之前的校验 - * 对已发布的流程只能打开 - * @param uuid - * @return - */ - public String getDesignerViewerPortalLinkPerm(String uuid) { - ResponseObject ro = ResponseObject.newOkResponse(); - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - String status = "ok"; - if (model == null) { - status = "notFound"; - } else if (!model.isPublish()) { - status = "notPublish"; - } else { - // 判断是否有查看权限 - String isIntegrationAWSUser = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isIntegrationAWSUser"); //是否整合AWS用户 - String roleId = ""; - if ("false".equals(isIntegrationAWSUser)) { - roleId = PublishConst.GUESTROLE; - } else { - roleId = _uc.getRoleModel().getId(); - } - PALRepository dao = new PALRepository(); - Set idSet = dao.getRepositoryVersionIdListByPublishRole(roleId, "'" + model.getWsId() + "'", null); - /**************************先注释掉 后期逻辑调整**********************/ + /** + * 门户打开之前的校验 + * 对已发布的流程只能打开 + * + * @param uuid + * @return + */ + public String getDesignerViewerPortalLinkPerm(String uuid) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + String status = "ok"; + if (model == null) { + status = "notFound"; + } else if (!model.isPublish()) { + status = "notPublish"; + } else { + // 判断是否有查看权限 + String isIntegrationAWSUser = SDK.getAppAPI().getProperty("com.actionsoft.apps.coe.pal.publisher", "isIntegrationAWSUser"); //是否整合AWS用户 + String roleId = ""; + if ("false".equals(isIntegrationAWSUser)) { + roleId = PublishConst.GUESTROLE; + } else { + roleId = _uc.getRoleModel().getId(); + } + PALRepository dao = new PALRepository(); + Set idSet = dao.getRepositoryVersionIdListByPublishRole(roleId, "'" + model.getWsId() + "'", null); + /**************************先注释掉 后期逻辑调整**********************/ /*if (!idSet.contains(model.getVersionId())) { status = "noPerm"; }*/ - } - ro.put("data", status); - return ro.toString(); - } + } + ro.put("data", status); + return ro.toString(); + } - /** - * 校验形状属性 - * @param uuid - * @param define 若为空字符串,则获取系统当前保存的define进行校验 - * @return - */ - public String validRepositoryShapeAttr(String uuid, String define) { - PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); - if (model == null) { - return ResponseObject.newErrResponse("模型不存在").toString(); - } - if (UtilString.isEmpty(define) || "null".equals(define) || "undefined".equals(define)) { - define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, uuid); - } - Map methodAttributeModelMap = new HashMap<>(); + /** + * 校验形状属性 + * + * @param uuid + * @param define 若为空字符串,则获取系统当前保存的define进行校验 + * @return + */ + public String validRepositoryShapeAttr(String uuid, String define) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model == null) { + return ResponseObject.newErrResponse("模型不存在").toString(); + } + if (UtilString.isEmpty(define) || "null".equals(define) || "undefined".equals(define)) { + define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, uuid); + } + Map methodAttributeModelMap = new HashMap<>(); - // 校验形状 - List elements = ShapeUtil.getShapeJsonToJsonObject(define); - List resultList = new ArrayList<>(); - for (JSONObject o : elements) { - String shapeId = o.getString("id"); - String shapeName = o.getString("name"); - String text = UtilString.isEmpty(o.getString("text")) ? o.getString("title") : o.getString("text"); - String shapeCategory = o.getString("category"); - JSONObject dataAttributes = o.getJSONObject("dataAttributes"); - JSONArray attributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray"); - for (int i = 0; i < attributesJsonArray.size(); i++) { - JSONObject attr = attributesJsonArray.getJSONObject(i); - String attrId = attr.getString("id"); - String value = attr.getString("value"); - if (!methodAttributeModelMap.containsKey(shapeName + "-" + attrId)) { - List methodAttributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(model.getWsId(), shapeCategory.replace("_", "."), shapeName, model.getMethodId()); - for (PALMethodAttributeModel attributeModel : methodAttributeModels) { - if (!methodAttributeModelMap.containsKey(shapeName + "-" + attributeModel.getKey())) { - methodAttributeModelMap.put(shapeName + "-" + attributeModel.getKey(), attributeModel); - } - } - } - if (!methodAttributeModelMap.containsKey(shapeName + "-" + attrId)) { - continue;// 没有配置到形状的属性,不处理 - } - PALMethodAttributeModel attrModel = methodAttributeModelMap.get(shapeName + "-" + attrId); - if (attrModel.getIsRequired()) {// 筛选必填 - String attrType = attrModel.getType(); - boolean flag = true; - if ("relation".equals(attrType) || "awsorg".equals(attrType)) { - List list = DesignerShapeRelationCache.getListByAttrId(model.getId(), shapeId, attrId); - if (list == null || list.isEmpty()) { - flag = false; - } - } else { - flag = UtilString.isNotEmpty(value); - } - if (!flag) { - JSONObject tmp = new JSONObject(); - tmp.put("shapeId", shapeId); - tmp.put("shapeName", text); - tmp.put("attrName", attrModel.getNewTitle()); - tmp.put("attrId", attrId); - resultList.add(tmp); - } - } - } - } - ResponseObject ro = ResponseObject.newOkResponse(); - if (!resultList.isEmpty()) { - ro.setData(resultList); - ro.err("校验未通过"); - return ro.toString(); - } - return ResponseObject.newOkResponse().toString(); + // 校验形状 + List elements = ShapeUtil.getShapeJsonToJsonObject(define); + List resultList = new ArrayList<>(); + for (JSONObject o : elements) { + String shapeId = o.getString("id"); + String shapeName = o.getString("name"); + String text = UtilString.isEmpty(o.getString("text")) ? o.getString("title") : o.getString("text"); + String shapeCategory = o.getString("category"); + JSONObject dataAttributes = o.getJSONObject("dataAttributes"); + JSONArray attributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray"); + for (int i = 0; i < attributesJsonArray.size(); i++) { + JSONObject attr = attributesJsonArray.getJSONObject(i); + String attrId = attr.getString("id"); + String value = attr.getString("value"); + if (!methodAttributeModelMap.containsKey(shapeName + "-" + attrId)) { + List methodAttributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(model.getWsId(), shapeCategory.replace("_", "."), shapeName, model.getMethodId()); + for (PALMethodAttributeModel attributeModel : methodAttributeModels) { + if (!methodAttributeModelMap.containsKey(shapeName + "-" + attributeModel.getKey())) { + methodAttributeModelMap.put(shapeName + "-" + attributeModel.getKey(), attributeModel); + } + } + } + if (!methodAttributeModelMap.containsKey(shapeName + "-" + attrId)) { + continue;// 没有配置到形状的属性,不处理 + } + PALMethodAttributeModel attrModel = methodAttributeModelMap.get(shapeName + "-" + attrId); + if (attrModel.getIsRequired()) {// 筛选必填 + String attrType = attrModel.getType(); + boolean flag = true; + if ("relation".equals(attrType) || "awsorg".equals(attrType)) { + List list = DesignerShapeRelationCache.getListByAttrId(model.getId(), shapeId, attrId); + if (list == null || list.isEmpty()) { + flag = false; + } + } else { + flag = UtilString.isNotEmpty(value); + } + if (!flag) { + JSONObject tmp = new JSONObject(); + tmp.put("shapeId", shapeId); + tmp.put("shapeName", text); + tmp.put("attrName", attrModel.getNewTitle()); + tmp.put("attrId", attrId); + resultList.add(tmp); + } + } + } + } + ResponseObject ro = ResponseObject.newOkResponse(); + if (!resultList.isEmpty()) { + ro.setData(resultList); + ro.err("校验未通过"); + return ro.toString(); + } + return ResponseObject.newOkResponse().toString(); - } + } - /******************************************新版门户流程详情end********************************************************/ + /******************************************新版门户流程详情end********************************************************/ - //获取excel数据的内部类 - private class ExcelData { - public String TARGET_METHOD_SCOPE = "process.bpmn2,process.epc,process.flowchart"; - public String PROCESS_STEP = "userTask,serviceTask,manualTask,receiveTask,sendTask,scriptTask,businessRuleTask,callActivityCallingProcess,method,process,predefinedProcess,decision"; - public JSONArray getExcelData(String uuid) { - PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(uuid); - List> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson(uuid); //流程文件内容 - OutputWordUtil.orderByNumber(repositoryFileElements); - JSONArray repositoryShapeTable = new JSONArray(); + //获取excel数据的内部类 + private class ExcelData { + public String TARGET_METHOD_SCOPE = "process.bpmn2,process.epc,process.flowchart"; + public String PROCESS_STEP = "userTask,serviceTask,manualTask,receiveTask,sendTask,scriptTask,businessRuleTask,callActivityCallingProcess,method,process,predefinedProcess,decision"; - if (repositoryFileElements != null) { - int index = 1;// 流程步骤序号 - for (Map shape : repositoryFileElements) { - //如果图形元素不是流程步骤,不导出该元素 - if (PROCESS_STEP.indexOf((String)shape.get("type")) == -1) { - continue; - } - JSONObject _tr = new JSONObject(); - OutputWordUtil.setShapeDefaultValue2(uuid, _tr); //设置默认值 - _tr.put(OutputWordUtil.SERIAL_NUMBER, index); //序号 - _tr.put(OutputWordUtil.REPOSITORY_NAME, repositoryModel.getName()); //流程名称 - _tr.put(OutputWordUtil.SHAPE_NAME, shape.get("text")); //步骤名称 + public JSONArray getExcelData(String uuid) { + PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(uuid); + List> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson(uuid); //流程文件内容 + OutputWordUtil.orderByNumber(repositoryFileElements); + JSONArray repositoryShapeTable = new JSONArray(); - JSONObject dataAttributes = (JSONObject) shape.get("attributes"); - if (dataAttributes != null) { - _tr.put(OutputWordUtil.SHAPE_DESC, (OutputWordUtil.specialCharTransfer((String)dataAttributes.get("shapeDesc"))).replace("\n", OutputWordUtil.WRAPSTRING)); //工作详细描述 - JSONArray dataAttributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray"); - Map shapeModelMap = OutputWordUtil.getShapeRelationMap(uuid, (String) shape.get("id")); - for (int i = 0; i < dataAttributesJsonArray.size(); i++) { - JSONObject dataAttribute = dataAttributesJsonArray.getJSONObject(i); - if (dataAttribute != null && dataAttribute.containsKey("value")) { - //获取关联属性的属性值 - OutputWordUtil.setShapeValue2(_tr, dataAttribute, shapeModelMap); - } - } - } + if (repositoryFileElements != null) { + int index = 1;// 流程步骤序号 + for (Map shape : repositoryFileElements) { + //如果图形元素不是流程步骤,不导出该元素 + if (PROCESS_STEP.indexOf((String) shape.get("type")) == -1) { + continue; + } + JSONObject _tr = new JSONObject(); + OutputWordUtil.setShapeDefaultValue2(uuid, _tr); //设置默认值 + _tr.put(OutputWordUtil.SERIAL_NUMBER, index); //序号 + _tr.put(OutputWordUtil.REPOSITORY_NAME, repositoryModel.getName()); //流程名称 + _tr.put(OutputWordUtil.SHAPE_NAME, shape.get("text")); //步骤名称 - repositoryShapeTable.add(_tr); - index++; - } - } - return repositoryShapeTable; - } - } + JSONObject dataAttributes = (JSONObject) shape.get("attributes"); + if (dataAttributes != null) { + _tr.put(OutputWordUtil.SHAPE_DESC, (OutputWordUtil.specialCharTransfer((String) dataAttributes.get("shapeDesc"))).replace("\n", OutputWordUtil.WRAPSTRING)); //工作详细描述 + JSONArray dataAttributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray"); + Map shapeModelMap = OutputWordUtil.getShapeRelationMap(uuid, (String) shape.get("id")); + for (int i = 0; i < dataAttributesJsonArray.size(); i++) { + JSONObject dataAttribute = dataAttributesJsonArray.getJSONObject(i); + if (dataAttribute != null && dataAttribute.containsKey("value")) { + //获取关联属性的属性值 + OutputWordUtil.setShapeValue2(_tr, dataAttribute, shapeModelMap); + } + } + } - /** - * 设计器-查询版本相关数据 - * @param wsId - * @param teamId - * @param id - * @return - */ - public String getPalProcessLevelVersionData(String wsId, String teamId, String id) { - if (UtilString.isEmpty(id) || PALRepositoryCache.getCache().get(id) == null) { - return ResponseObject.newErrResponse("文件不存在").toString(); - } - ResponseObject ro = ResponseObject.newOkResponse(); - CoeCooperationAPIManager.getInstance().queryCooperationMemberActionPerm(teamId, _uc.getUID(), ro); - CoeCooperationAPIManager.getInstance().queryCooperationFileActionPerm(teamId, _uc.getUID(),PALRepositoryCache.getCache().get(id).getVersionId(), ro); - ro.put("isCorrelatebpms", false); - ro.put("processDefId", ""); - boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(id, true); - if (isCorrelateBpms) {// 与bpm平台关联流程 - String processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(id, true); - ro.put("isCorrelatebpms", true); - ro.put("processDefId", processDefId); - String appId = ProcessDefCache.getInstance().get(processDefId).getAppId(); - List versionList = ProcessDefCache.getInstance().getListOfProcessVersion(appId, processDefId); - ProcessDefCache.getInstance().sortByCreateTimeDesc(versionList); - boolean isPalManage = CoeProcessLevelUtil.isPalManage(); - ro.put("isPalManage", isPalManage); - JSONArray array = new JSONArray(); - for (ProcessDefinition processDefinition : versionList) { - String plId = PALRepositoryQueryAPIManager.getInstance().queryPlIdByPlAwsId(processDefinition.getId()); - if (UtilString.isEmpty(plId)) { - continue; - } - JSONObject obj = new JSONObject(); - String versionStatus = ""; - String color = "#4E7FF9"; - int versionState = processDefinition.getVersionStatus(); - if (versionState == ProcessDefinitionConst.VERSION_STATUS_CLOSED) { - versionStatus = ProcessDefVersionUtil.getVersionName(ProcessDefinitionConst.VERSION_STATUS_CLOSED); - color = "#D9001B"; - } else if (versionState == ProcessDefinitionConst.VERSION_STATUS_DESIGN) { - versionStatus = ProcessDefVersionUtil.getVersionName(ProcessDefinitionConst.VERSION_STATUS_DESIGN); - } else if (versionState == ProcessDefinitionConst.VERSION_STATUS_RELEASE) { - versionStatus = ProcessDefVersionUtil.getVersionName(ProcessDefinitionConst.VERSION_STATUS_RELEASE); - color = "#1AA477"; - } - obj.put("versionNo", VersionUtil.getVersionStrV(processDefinition.getVersionNo())); - obj.put("name", processDefinition.getName()); - obj.put("createUser", SDK.getORGAPI().getUser(processDefinition.getCreateUser()) == null ? processDefinition.getCreateUser() : SDK.getORGAPI().getUser(processDefinition.getCreateUser()).getUserName()); - obj.put("createDate", UtilDate.dateFormat(processDefinition.getCreateTime())); - obj.put("bpmState", I18nRes.findValue(AppsConst.SYS_APP_PLATFORM, versionStatus)); - obj.put("bpmStateCode", versionStatus); - obj.put("bpmStateColor", color); - PALRepositoryModel m = PALRepositoryCache.getCache().get(plId); - obj.put("isUse", m.isUse()); - obj.put("isPublish", m.isPublish()); - obj.put("isStop", m.isStop()); - obj.put("isApproval", m.isApproval()); - obj.put("id", m.getId()); - obj.put("awsId", processDefinition.getId()); - obj.put("isFirst", processDefinition.getId().equals(processDefinition.getVersionId())); - obj.put("versionStatus", processDefinition.getVersionStatus()); - obj.put("isCorrelate", false); - CoeProcessLevelCorrelateModel correlateModel = CoeProcessLevelCorrelateCache.getCache().get(m.getId()); - if (isPalManage) { - if (correlateModel != null && "show".equals(correlateModel.getExt1()) && correlateModel.getCorrelateType() == 1) { - obj.put("isCorrelate", true); - } - } - array.add(obj); - } - ro.put("tableData", array); - return ro.toString(); - } else {// pal自身文件 - PALRepositoryModel model = PALRepositoryCache.getCache().get(id); - List versions = PALRepositoryCache.getByVersionId(model.getVersionId()); - Collections.sort(versions, new Comparator() { - @Override - public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { - return VersionUtil.compareVersionNo(o1.getVersion(),o2.getVersion(),true); - } - }); - JSONArray array = new JSONArray(); - for (PALRepositoryModel m : versions) { - if (m != null) { - JSONObject obj = new JSONObject(); - obj.put("id", m.getId()); - obj.put("isUse", m.isUse()); - obj.put("isPublish", m.isPublish()); - obj.put("isStop", m.isStop()); - obj.put("isApproval", m.isApproval()); - obj.put("versionNo", VersionUtil.getVersionStrV(m.getVersion())); - obj.put("name", m.getName()); - obj.put("createUser", SDK.getORGAPI().getUser(m.getCreateUser()) == null ? m.getCreateUser() : SDK.getORGAPI().getUser(m.getCreateUser()).getUserName()); - obj.put("createDate", UtilDate.dateFormat(m.getCreateDate())); - array.add(obj); - } - } - ro.put("tableData", array); - return ro.toString(); - } - } + repositoryShapeTable.add(_tr); + index++; + } + } + return repositoryShapeTable; + } + } - /** - * 设计器-创建新版本 - * @param wsId - * @param teamId - * @param id - * @return - */ - public String createPalDesignerNewVersion(String wsId, String teamId, String id,boolean isLargeIteration) { - ResponseObject ro = null; - boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(id, true); - if (isCorrelateBpms) { - String processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(id, true); - ProcessDefinition processDefinition = ProcessDefCache.getInstance().get(processDefId); - ResponseObject responseObject = ResponseObject.newOkResponse(); + /** + * 设计器-查询版本相关数据 + * + * @param wsId + * @param teamId + * @param id + * @return + */ + public String getPalProcessLevelVersionData(String wsId, String teamId, String id) { + if (UtilString.isEmpty(id) || PALRepositoryCache.getCache().get(id) == null) { + return ResponseObject.newErrResponse("文件不存在").toString(); + } + ResponseObject ro = ResponseObject.newOkResponse(); + CoeCooperationAPIManager.getInstance().queryCooperationMemberActionPerm(teamId, _uc.getUID(), ro); + CoeCooperationAPIManager.getInstance().queryCooperationFileActionPerm(teamId, _uc.getUID(), PALRepositoryCache.getCache().get(id).getVersionId(), ro); + ro.put("isCorrelatebpms", false); + ro.put("processDefId", ""); + boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(id, true); + if (isCorrelateBpms) {// 与bpm平台关联流程 + String processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(id, true); + ro.put("isCorrelatebpms", true); + ro.put("processDefId", processDefId); + String appId = ProcessDefCache.getInstance().get(processDefId).getAppId(); + List versionList = ProcessDefCache.getInstance().getListOfProcessVersion(appId, processDefId); + ProcessDefCache.getInstance().sortByCreateTimeDesc(versionList); + boolean isPalManage = CoeProcessLevelUtil.isPalManage(); + ro.put("isPalManage", isPalManage); + JSONArray array = new JSONArray(); + for (ProcessDefinition processDefinition : versionList) { + String plId = PALRepositoryQueryAPIManager.getInstance().queryPlIdByPlAwsId(processDefinition.getId()); + if (UtilString.isEmpty(plId)) { + continue; + } + JSONObject obj = new JSONObject(); + String versionStatus = ""; + String color = "#4E7FF9"; + int versionState = processDefinition.getVersionStatus(); + if (versionState == ProcessDefinitionConst.VERSION_STATUS_CLOSED) { + versionStatus = ProcessDefVersionUtil.getVersionName(ProcessDefinitionConst.VERSION_STATUS_CLOSED); + color = "#D9001B"; + } else if (versionState == ProcessDefinitionConst.VERSION_STATUS_DESIGN) { + versionStatus = ProcessDefVersionUtil.getVersionName(ProcessDefinitionConst.VERSION_STATUS_DESIGN); + } else if (versionState == ProcessDefinitionConst.VERSION_STATUS_RELEASE) { + versionStatus = ProcessDefVersionUtil.getVersionName(ProcessDefinitionConst.VERSION_STATUS_RELEASE); + color = "#1AA477"; + } + obj.put("versionNo", VersionUtil.getVersionStrV(processDefinition.getVersionNo())); + obj.put("name", processDefinition.getName()); + obj.put("createUser", SDK.getORGAPI().getUser(processDefinition.getCreateUser()) == null ? processDefinition.getCreateUser() : SDK.getORGAPI().getUser(processDefinition.getCreateUser()).getUserName()); + obj.put("createDate", UtilDate.dateFormat(processDefinition.getCreateTime())); + obj.put("bpmState", I18nRes.findValue(AppsConst.SYS_APP_PLATFORM, versionStatus)); + obj.put("bpmStateCode", versionStatus); + obj.put("bpmStateColor", color); + PALRepositoryModel m = PALRepositoryCache.getCache().get(plId); + obj.put("isUse", m.isUse()); + obj.put("isPublish", m.isPublish()); + obj.put("isStop", m.isStop()); + obj.put("isApproval", m.isApproval()); + obj.put("id", m.getId()); + obj.put("awsId", processDefinition.getId()); + obj.put("isFirst", processDefinition.getId().equals(processDefinition.getVersionId())); + obj.put("versionStatus", processDefinition.getVersionStatus()); + obj.put("isCorrelate", false); + CoeProcessLevelCorrelateModel correlateModel = CoeProcessLevelCorrelateCache.getCache().get(m.getId()); + if (isPalManage) { + if (correlateModel != null && "show".equals(correlateModel.getExt1()) && correlateModel.getCorrelateType() == 1) { + obj.put("isCorrelate", true); + } + } + array.add(obj); + } + ro.put("tableData", array); + return ro.toString(); + } else {// pal自身文件 + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + List versions = PALRepositoryCache.getByVersionId(model.getVersionId()); + Collections.sort(versions, new Comparator() { + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + return VersionUtil.compareVersionNo(o1.getVersion(), o2.getVersion(), true); + } + }); + JSONArray array = new JSONArray(); + for (PALRepositoryModel m : versions) { + if (m != null) { + JSONObject obj = new JSONObject(); + obj.put("id", m.getId()); + obj.put("isUse", m.isUse()); + obj.put("isPublish", m.isPublish()); + obj.put("isStop", m.isStop()); + obj.put("isApproval", m.isApproval()); + obj.put("versionNo", VersionUtil.getVersionStrV(m.getVersion())); + obj.put("name", m.getName()); + obj.put("createUser", SDK.getORGAPI().getUser(m.getCreateUser()) == null ? m.getCreateUser() : SDK.getORGAPI().getUser(m.getCreateUser()).getUserName()); + obj.put("createDate", UtilDate.dateFormat(m.getCreateDate())); + array.add(obj); + } + } + ro.put("tableData", array); + return ro.toString(); + } + } - ProcessBPMNDesignerWeb web = new ProcessBPMNDesignerWeb(_uc); - String appId = processDefinition.getAppId(); - String operateType = "newversion|"+ processDefinition.getVersionId() +"|" + processDefinition.getVersionNo(); - JSONObject defineRo = JSONObject.parseObject(web.getDefine(appId, processDefId, operateType, 0)); - if (!"ok".equals(defineRo.getString("result"))) { - return ResponseObject.newWarnResponse("创建失败," + defineRo.getString("msg")).toString(); - } - JSONObject define = defineRo.getJSONObject("data"); - JSONObject savePalNewVerRo = JSONObject.parseObject(definitionOfBpmnSave(id, 0, appId, processDefId, operateType, define.toString(), "")); - if (!"ok".equals(savePalNewVerRo.getString("result"))) { - return ResponseObject.newWarnResponse("创建失败," + savePalNewVerRo.getString("msg")).toString(); - } - JSONObject defData = savePalNewVerRo.getJSONObject("data"); - String newDefId = defData.getString("processDefId"); - JSONObject plIdRo = JSONObject.parseObject(getPLIdByAWSId(newDefId)); - if (!"ok".equals(plIdRo.getString("result"))) { - return ResponseObject.newWarnResponse("创建失败," + plIdRo.getString("msg")).toString(); - } - String plId = plIdRo.getJSONObject("data").getString("plId"); - ro = ResponseObject.newOkResponse("创建成功"); - ro.put("uuid", plId); - // 操作行为日志记录 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_CREATE, CoEOpLogConst.INFO_REPOSITORY_NEW_VERSION_CREATE); - } - return ro.toString(); - } - double tempVer = 0;// 版本号 - String srcPath = "";// 源文件路径 - String targetPath = "";// 目标文件路径 - PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - PALRepositoryModelImpl lastplModel = (PALRepositoryModelImpl) coeProcessLevel.getInstance(id); - final String oldUUID = lastplModel.getId(); - lastplModel.setId(UUIDGener.getUUID()); - final String newUUID = lastplModel.getId(); - //大小版本号处理 - tempVer = isLargeIteration ? coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId()) : coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId(),lastplModel.getVersion()); - lastplModel.setHistoryMaxVersion("0"); - lastplModel.setVersion(VersionUtil.increaseVersionNo(tempVer,isLargeIteration)); - lastplModel.setUse(false); - srcPath = lastplModel.getFilePath(); - if (!"".equals(srcPath) && srcPath != null) { - targetPath = srcPath.replace(id, lastplModel.getId()); - } - lastplModel.setFilePath(targetPath); - lastplModel.setPublish(false); - lastplModel.setStop(false); - lastplModel.setApproval(false); - Timestamp nowTime = new Timestamp(System.currentTimeMillis()); - String uid = super.getContext().getUID(); - lastplModel.setCreateUser(uid); - lastplModel.setCreateDate(nowTime); - lastplModel.setModifyUser(uid); - lastplModel.setModifyDate(nowTime); + /** + * 设计器-创建新版本 + * + * @param wsId + * @param teamId + * @param id + * @return + */ + public String createPalDesignerNewVersion(String wsId, String teamId, String id, boolean isLargeIteration) { + ResponseObject ro = null; + boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(id, true); + if (isCorrelateBpms) { + String processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(id, true); + ProcessDefinition processDefinition = ProcessDefCache.getInstance().get(processDefId); + ResponseObject responseObject = ResponseObject.newOkResponse(); - //密级 - lastplModel.setSecurityLevel(-1); - int store = 0; - try { - store = CoeProcessLevelDaoFacotory.createCoeProcessLevel().insert(lastplModel); - } catch (Exception e) { - e.printStackTrace(); - ro = ResponseObject.newWarnResponse("创建失败," + e.getMessage()); - return ro.toString(); - } - if (store == 1) { - // 修改设计器文件 - CoeFile fileUtil = new CoeFile(); - fileUtil.copyDefaultVersion(srcPath, id, targetPath, lastplModel.getId()); - // 获取新旧节点关联关系 - final Map mapNewUUID = createShapeIdRelation(PALRepositoryCache.getCache().get(oldUUID), false); - // 处理流程属性 - String property = CoePropertyUtil.getPropertyValue(oldUUID + "_attr"); - if (!UtilString.isEmpty(property)) { - CoePropertyUtil.createProperty(newUUID + "_attr", property); - } + ProcessBPMNDesignerWeb web = new ProcessBPMNDesignerWeb(_uc); + String appId = processDefinition.getAppId(); + String operateType = "newversion|" + processDefinition.getVersionId() + "|" + processDefinition.getVersionNo(); + JSONObject defineRo = JSONObject.parseObject(web.getDefine(appId, processDefId, operateType, 0)); + if (!"ok".equals(defineRo.getString("result"))) { + return ResponseObject.newWarnResponse("创建失败," + defineRo.getString("msg")).toString(); + } + JSONObject define = defineRo.getJSONObject("data"); + JSONObject savePalNewVerRo = JSONObject.parseObject(definitionOfBpmnSave(id, 0, appId, processDefId, operateType, define.toString(), "")); + if (!"ok".equals(savePalNewVerRo.getString("result"))) { + return ResponseObject.newWarnResponse("创建失败," + savePalNewVerRo.getString("msg")).toString(); + } + JSONObject defData = savePalNewVerRo.getJSONObject("data"); + String newDefId = defData.getString("processDefId"); + JSONObject plIdRo = JSONObject.parseObject(getPLIdByAWSId(newDefId)); + if (!"ok".equals(plIdRo.getString("result"))) { + return ResponseObject.newWarnResponse("创建失败," + plIdRo.getString("msg")).toString(); + } + String plId = plIdRo.getJSONObject("data").getString("plId"); + ro = ResponseObject.newOkResponse("创建成功"); + ro.put("uuid", plId); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_CREATE, CoEOpLogConst.INFO_REPOSITORY_NEW_VERSION_CREATE); + } + return ro.toString(); + } + double tempVer = 0;// 版本号 + String srcPath = "";// 源文件路径 + String targetPath = "";// 目标文件路径 + PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); + PALRepositoryModelImpl lastplModel = (PALRepositoryModelImpl) coeProcessLevel.getInstance(id); + final String oldUUID = lastplModel.getId(); + lastplModel.setId(UUIDGener.getUUID()); + final String newUUID = lastplModel.getId(); + //大小版本号处理 + tempVer = isLargeIteration ? coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId()) : coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId(), lastplModel.getVersion()); + lastplModel.setHistoryMaxVersion("0"); + lastplModel.setVersion(VersionUtil.increaseVersionNo(tempVer, isLargeIteration)); + lastplModel.setUse(false); + srcPath = lastplModel.getFilePath(); + if (!"".equals(srcPath) && srcPath != null) { + targetPath = srcPath.replace(id, lastplModel.getId()); + } + lastplModel.setFilePath(targetPath); + lastplModel.setPublish(false); + lastplModel.setStop(false); + lastplModel.setApproval(false); + Timestamp nowTime = new Timestamp(System.currentTimeMillis()); + String uid = super.getContext().getUID(); + lastplModel.setCreateUser(uid); + lastplModel.setCreateDate(nowTime); + lastplModel.setModifyUser(uid); + lastplModel.setModifyDate(nowTime); + + //密级 + lastplModel.setSecurityLevel(-1); + int store = 0; + try { + store = CoeProcessLevelDaoFacotory.createCoeProcessLevel().insert(lastplModel); + } catch (Exception e) { + e.printStackTrace(); + ro = ResponseObject.newWarnResponse("创建失败," + e.getMessage()); + return ro.toString(); + } + if (store == 1) { + // 修改设计器文件 + CoeFile fileUtil = new CoeFile(); + fileUtil.copyDefaultVersion(srcPath, id, targetPath, lastplModel.getId()); + // 获取新旧节点关联关系 + final Map mapNewUUID = createShapeIdRelation(PALRepositoryCache.getCache().get(oldUUID), false); + // 处理流程属性 + String property = CoePropertyUtil.getPropertyValue(oldUUID + "_attr"); + if (!UtilString.isEmpty(property)) { + CoePropertyUtil.createProperty(newUUID + "_attr", property); + } - // 新版本文件 小组权限设置 - if (UtilString.isNotEmpty(teamId)){ - CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(_uc,teamId,lastplModel.getVersionId(),true,true); - } + // 新版本文件 小组权限设置 + if (UtilString.isNotEmpty(teamId)) { + CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(_uc, teamId, lastplModel.getVersionId(), true, true); + } - //1.创建角色模型 - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List oldModelList = dao.getModelListByFileId(oldUUID); - if (oldModelList.size()>0 && oldModelList.get(0).getAttrId().equals("role")) { - CreateRelevanceRoleModel(isLargeIteration,oldUUID,PALRepositoryCache.getCache().get(newUUID),mapNewUUID,tempVer,teamId); - } + //1.创建角色模型 + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List oldModelList = dao.getModelListByFileId(oldUUID); + if (oldModelList.size() > 0 && oldModelList.get(0).getAttrId().equals("role")) { + CreateRelevanceRoleModel(isLargeIteration, oldUUID, PALRepositoryCache.getCache().get(newUUID), mapNewUUID, tempVer, teamId); + } - //创建绩效关联关系 - CreateRelevancePerformanceModel(isLargeIteration,oldUUID,PALRepositoryCache.getCache().get(newUUID),mapNewUUID,tempVer); + //创建绩效关联关系 + CreateRelevancePerformanceModel(isLargeIteration, oldUUID, PALRepositoryCache.getCache().get(newUUID), mapNewUUID, tempVer); + CoeProcessLevelUtil.copyRepositoryProperty(PALRepositoryCache.getCache().get(oldUUID), PALRepositoryCache.getCache().get(newUUID), mapNewUUID, _uc); + ro = ResponseObject.newOkResponse("创建成功"); + ro.put("uuid", lastplModel.getId()); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_CREATE, CoEOpLogConst.INFO_REPOSITORY_NEW_VERSION_CREATE); + } - CoeProcessLevelUtil.copyRepositoryProperty(PALRepositoryCache.getCache().get(oldUUID), PALRepositoryCache.getCache().get(newUUID), mapNewUUID, _uc); - ro = ResponseObject.newOkResponse("创建成功"); - ro.put("uuid", lastplModel.getId()); - // 操作行为日志记录 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_CREATE, CoEOpLogConst.INFO_REPOSITORY_NEW_VERSION_CREATE); - } - - ro = ResponseObject.newOkResponse("创建成功"); - ro.put("uuid", lastplModel.getId()); - } else { - ro = ResponseObject.newWarnResponse("创建失败"); - } - return ro.toString(); - } + ro = ResponseObject.newOkResponse("创建成功"); + ro.put("uuid", lastplModel.getId()); + } else { + ro = ResponseObject.newWarnResponse("创建失败"); + } + return ro.toString(); + } - /** - * 操作升级版本/复制副本 - * @param isLargeIteration - * @param olduuid - */ - public String CreateRelevanceRoleModel(boolean isLargeIteration,String olduuid,PALRepositoryModel newModel,Map mapNewUUID,Double tempVer,String teamId){ - ResponseObject ro = null; - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List oldModelList = dao.getModelListByFileId(olduuid); + /** + * 操作升级版本/复制副本 + * + * @param isLargeIteration + * @param olduuid + */ + public String CreateRelevanceRoleModel(boolean isLargeIteration, String olduuid, PALRepositoryModel newModel, Map mapNewUUID, Double tempVer, String teamId) { + ResponseObject ro = null; + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List oldModelList = dao.getModelListByFileId(olduuid); - //1.创建角色模型 - String relationFileId = oldModelList.get(0).getRelationFileId(); - String srcPath = "";// 源文件路径 - String targetPath = "";// 目标文件路径 - PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - PALRepositoryModelImpl lastplModel = (PALRepositoryModelImpl) coeProcessLevel.getInstance(relationFileId); - final String oldUUID = lastplModel.getId(); - lastplModel.setId(UUIDGener.getUUID()); - final String newUUID = lastplModel.getId(); - //大小版本号处理 - tempVer = isLargeIteration ? coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId()) : coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId(), lastplModel.getVersion()); - lastplModel.setHistoryMaxVersion("0"); - lastplModel.setVersion(VersionUtil.increaseVersionNo(tempVer, isLargeIteration)); - lastplModel.setUse(false); - srcPath = lastplModel.getFilePath(); - if (!"".equals(srcPath) && srcPath != null) { - targetPath = srcPath.replace(relationFileId, lastplModel.getId()); - } - lastplModel.setFilePath(targetPath); - lastplModel.setPublish(false); - lastplModel.setStop(false); - lastplModel.setApproval(false); - Timestamp nowTime = new Timestamp(System.currentTimeMillis()); - String uid = super.getContext().getUID(); - lastplModel.setCreateUser(uid); - lastplModel.setCreateDate(nowTime); - lastplModel.setModifyUser(uid); - lastplModel.setModifyDate(nowTime); - List data = new ArrayList<>(); - data.add(0, "org.role"); - data.add(1, newModel.getId()); - lastplModel.setExt2(data.toString()); - //密级 - lastplModel.setSecurityLevel(-1); - int store = 0; - try { - store = CoeProcessLevelDaoFacotory.createCoeProcessLevel().insert(lastplModel); - if (store == 1) { - // 修改设计器文件 - CoeFile fileUtil = new CoeFile(); - fileUtil.copyDefaultVersion(srcPath, relationFileId, targetPath, lastplModel.getId()); + //1.创建角色模型 + String relationFileId = oldModelList.get(0).getRelationFileId(); + String srcPath = "";// 源文件路径 + String targetPath = "";// 目标文件路径 + PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); + PALRepositoryModelImpl lastplModel = (PALRepositoryModelImpl) coeProcessLevel.getInstance(relationFileId); + final String oldUUID = lastplModel.getId(); + lastplModel.setId(UUIDGener.getUUID()); + final String newUUID = lastplModel.getId(); + //大小版本号处理 + tempVer = isLargeIteration ? coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId()) : coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId(), lastplModel.getVersion()); + lastplModel.setHistoryMaxVersion("0"); + lastplModel.setVersion(VersionUtil.increaseVersionNo(tempVer, isLargeIteration)); + lastplModel.setUse(false); + srcPath = lastplModel.getFilePath(); + if (!"".equals(srcPath) && srcPath != null) { + targetPath = srcPath.replace(relationFileId, lastplModel.getId()); + } + lastplModel.setFilePath(targetPath); + lastplModel.setPublish(false); + lastplModel.setStop(false); + lastplModel.setApproval(false); + Timestamp nowTime = new Timestamp(System.currentTimeMillis()); + String uid = super.getContext().getUID(); + lastplModel.setCreateUser(uid); + lastplModel.setCreateDate(nowTime); + lastplModel.setModifyUser(uid); + lastplModel.setModifyDate(nowTime); + List data = new ArrayList<>(); + data.add(0, "org.role"); + data.add(1, newModel.getId()); + lastplModel.setExt2(data.toString()); + //密级 + lastplModel.setSecurityLevel(-1); + int store = 0; + try { + store = CoeProcessLevelDaoFacotory.createCoeProcessLevel().insert(lastplModel); + if (store == 1) { + // 修改设计器文件 + CoeFile fileUtil = new CoeFile(); + fileUtil.copyDefaultVersion(srcPath, relationFileId, targetPath, lastplModel.getId()); - // 获取新旧节点关联关系 - final Map mapNewUUID1 = createShapeIdRelation(PALRepositoryCache.getCache().get(relationFileId), false); - // 处理流程属性 - String property = CoePropertyUtil.getPropertyValue(relationFileId + "_attr"); - if (!UtilString.isEmpty(property)) { - CoePropertyUtil.createProperty(newUUID + "_attr", property); - } + // 获取新旧节点关联关系 + final Map mapNewUUID1 = createShapeIdRelation(PALRepositoryCache.getCache().get(relationFileId), false); + // 处理流程属性 + String property = CoePropertyUtil.getPropertyValue(relationFileId + "_attr"); + if (!UtilString.isEmpty(property)) { + CoePropertyUtil.createProperty(newUUID + "_attr", property); + } - for (DesignerShapeRelationModel oldModel : oldModelList) { - if (oldModel.getAttrId().equals("role")) { - String methodIds = "org.role"; - if (mapNewUUID.containsKey(oldModel.getShapeId())) { - //重新设置修订关联关系 - DesignerShapeRelationModel newModel1 = new DesignerShapeRelationModel(); - newModel1.setId(UUIDGener.getUUID()); - newModel1.setFileId(newModel.getId()); - newModel1.setShapeId(mapNewUUID.get(oldModel.getShapeId())); - newModel1.setShapeText(oldModel.getShapeText()); - newModel1.setAttrId(oldModel.getAttrId()); - newModel1.setRelationFileId(newUUID); - newModel1.setRelationShapeId(oldModel.getRelationShapeId()); - newModel1.setRelationShapeText(oldModel.getRelationShapeText()); - dao.insert(newModel1); - } - } - } + for (DesignerShapeRelationModel oldModel : oldModelList) { + if (oldModel.getAttrId().equals("role")) { + String methodIds = "org.role"; + if (mapNewUUID.containsKey(oldModel.getShapeId())) { + //重新设置修订关联关系 + DesignerShapeRelationModel newModel1 = new DesignerShapeRelationModel(); + newModel1.setId(UUIDGener.getUUID()); + newModel1.setFileId(newModel.getId()); + newModel1.setShapeId(mapNewUUID.get(oldModel.getShapeId())); + newModel1.setShapeText(oldModel.getShapeText()); + newModel1.setAttrId(oldModel.getAttrId()); + newModel1.setRelationFileId(newUUID); + newModel1.setRelationShapeId(oldModel.getRelationShapeId()); + newModel1.setRelationShapeText(oldModel.getRelationShapeText()); + dao.insert(newModel1); + } + } + } - // 新版本文件 小组权限设置 - if (UtilString.isNotEmpty(teamId)){ - CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(_uc,teamId,lastplModel.getVersionId(),true,true); - } + // 新版本文件 小组权限设置 + if (UtilString.isNotEmpty(teamId)) { + CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(_uc, teamId, lastplModel.getVersionId(), true, true); + } - CoeProcessLevelUtil.copyRepositoryProperty(PALRepositoryCache.getCache().get(relationFileId), PALRepositoryCache.getCache().get(newUUID), mapNewUUID1, _uc); - ro = ResponseObject.newOkResponse("创建成功"); - ro.put("uuid", lastplModel.getId()); - } else { - ro = ResponseObject.newWarnResponse("创建失败"); - } - } catch (Exception e) { - ro = ResponseObject.newWarnResponse("创建失败," + e.getMessage()); - } + CoeProcessLevelUtil.copyRepositoryProperty(PALRepositoryCache.getCache().get(relationFileId), PALRepositoryCache.getCache().get(newUUID), mapNewUUID1, _uc); + ro = ResponseObject.newOkResponse("创建成功"); + ro.put("uuid", lastplModel.getId()); + } else { + ro = ResponseObject.newWarnResponse("创建失败"); + } + } catch (Exception e) { + ro = ResponseObject.newWarnResponse("创建失败," + e.getMessage()); + } /*if(oldModelList.size()>0){ @@ -4447,484 +4427,480 @@ public class CoeDesignerWeb extends ActionWeb { }else{ ro = ResponseObject.newWarnResponse("创建失败"); }*/ - return ro.toString(); + return ro.toString(); - } + } + /** + * 同步复制文件属性绩效属性数据 + * + * @param wsId + * @param teamId + * @param sourceIds + * @param targetId + * @return + */ + public String CreateRelevancePerformanceModel(boolean isLargeIteration, String olduuid, PALRepositoryModel newModel, Map mapNewUUID, Double tempVer) { + ResponseObject ro = ResponseObject.newOkResponse(); + // 校验 + PALRepositoryModel model = PALRepositoryCache.getCache().get(olduuid); + if (model == null) + throw new AWSException("没有找到文件:" + olduuid); + PALRepositoryPropertyDao repositoryPropertyDao = new PALRepositoryPropertyDao(); + List oldPropertyList = repositoryPropertyDao.getPropertysByPlid(olduuid, ""); + if (oldPropertyList != null && oldPropertyList.size() > 0) + for (PALRepositoryPropertyModel propertyModel : oldPropertyList) + //获取文件属性中流程绩效 + if (propertyModel.getPropertyId().equals("Process_performance_metrics")) { + String relationFileId = JSONObject.parseObject(propertyModel.getPropertyValue()).getString("relationFileId"); + String[] splitRelationFileId; + if (UtilString.isNotEmpty(relationFileId)) { - /** - * 同步复制文件属性绩效属性数据 - * @param wsId - * @param teamId - * @param sourceIds - * @param targetId - * @return - */ - public String CreateRelevancePerformanceModel(boolean isLargeIteration,String olduuid,PALRepositoryModel newModel,Map mapNewUUID,Double tempVer) { - ResponseObject ro = ResponseObject.newOkResponse(); - // 校验 - PALRepositoryModel model = PALRepositoryCache.getCache().get(olduuid); - if (model == null) - throw new AWSException("没有找到文件:" + olduuid); - PALRepositoryPropertyDao repositoryPropertyDao = new PALRepositoryPropertyDao(); - List oldPropertyList = repositoryPropertyDao.getPropertysByPlid(olduuid, ""); - if (oldPropertyList != null && oldPropertyList.size() > 0) - for (PALRepositoryPropertyModel propertyModel : oldPropertyList) - //获取文件属性中流程绩效 - if(propertyModel.getPropertyId().equals("Process_performance_metrics")){ - String relationFileId=JSONObject.parseObject(propertyModel.getPropertyValue()).getString("relationFileId"); - String[] splitRelationFileId; - if(UtilString.isNotEmpty(relationFileId)){ + if (relationFileId.contains(",")) { + relationFileId = relationFileId.split(",")[0]; + } + String srcPath = "";// 源文件路径 + String targetPath = "";// 目标文件路径 + PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); + PALRepositoryModelImpl lastplModel = (PALRepositoryModelImpl) coeProcessLevel.getInstance(relationFileId); + final String oldUUID = lastplModel.getId(); + lastplModel.setId(UUIDGener.getUUID()); + final String newUUID = lastplModel.getId(); + //大小版本号处理 + tempVer = isLargeIteration ? coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId()) : coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId(), lastplModel.getVersion()); + lastplModel.setHistoryMaxVersion("0"); + lastplModel.setVersion(VersionUtil.increaseVersionNo(tempVer, isLargeIteration)); + lastplModel.setUse(false); + srcPath = lastplModel.getFilePath(); + if (!"".equals(srcPath) && srcPath != null) { + targetPath = srcPath.replace(relationFileId, lastplModel.getId()); + } + lastplModel.setFilePath(targetPath); + lastplModel.setPublish(false); + lastplModel.setStop(false); + lastplModel.setApproval(false); + Timestamp nowTime = new Timestamp(System.currentTimeMillis()); + String uid = super.getContext().getUID(); + lastplModel.setCreateUser(uid); + lastplModel.setCreateDate(nowTime); + lastplModel.setModifyUser(uid); + lastplModel.setModifyDate(nowTime); + List data = new ArrayList<>(); + data.add(0, "control.kpi"); + data.add(1, newModel.getId()); + lastplModel.setExt2(data.toString()); + //密级 + lastplModel.setSecurityLevel(-1); + int store = 0; + try { + store = CoeProcessLevelDaoFacotory.createCoeProcessLevel().insert(lastplModel); + if (store == 1) { + // 修改设计器文件 + CoeFile fileUtil = new CoeFile(); + fileUtil.copyDefaultVersion(srcPath, relationFileId, targetPath, lastplModel.getId()); + + // 获取新旧节点关联关系 + final Map mapNewUUID1 = createShapeIdRelation(PALRepositoryCache.getCache().get(relationFileId), false); + // 处理流程属性 + String property = CoePropertyUtil.getPropertyValue(relationFileId + "_attr"); + if (!UtilString.isEmpty(property)) { + CoePropertyUtil.createProperty(newUUID + "_attr", property); + } - if(relationFileId.contains(",")){ - relationFileId=relationFileId.split(",")[0]; - } - String srcPath = "";// 源文件路径 - String targetPath = "";// 目标文件路径 - PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - PALRepositoryModelImpl lastplModel = (PALRepositoryModelImpl) coeProcessLevel.getInstance(relationFileId); - final String oldUUID = lastplModel.getId(); - lastplModel.setId(UUIDGener.getUUID()); - final String newUUID = lastplModel.getId(); - //大小版本号处理 - tempVer = isLargeIteration ? coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId()) : coeProcessLevel.getMaxVersionNum(lastplModel.getVersionId(),lastplModel.getVersion()); - lastplModel.setHistoryMaxVersion("0"); - lastplModel.setVersion(VersionUtil.increaseVersionNo(tempVer,isLargeIteration)); - lastplModel.setUse(false); - srcPath = lastplModel.getFilePath(); - if (!"".equals(srcPath) && srcPath != null) { - targetPath = srcPath.replace(relationFileId, lastplModel.getId()); - } - lastplModel.setFilePath(targetPath); - lastplModel.setPublish(false); - lastplModel.setStop(false); - lastplModel.setApproval(false); - Timestamp nowTime = new Timestamp(System.currentTimeMillis()); - String uid = super.getContext().getUID(); - lastplModel.setCreateUser(uid); - lastplModel.setCreateDate(nowTime); - lastplModel.setModifyUser(uid); - lastplModel.setModifyDate(nowTime); - List data=new ArrayList<>(); - data.add(0,"control.kpi"); - data.add(1,newModel.getId()); - lastplModel.setExt2(data.toString()); - //密级 - lastplModel.setSecurityLevel(-1); - int store = 0; - try { - store = CoeProcessLevelDaoFacotory.createCoeProcessLevel().insert(lastplModel); - if (store == 1) { - // 修改设计器文件 - CoeFile fileUtil = new CoeFile(); - fileUtil.copyDefaultVersion(srcPath, relationFileId, targetPath, lastplModel.getId()); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List oldModelList = dao.getModelListByFileId(olduuid); + for (DesignerShapeRelationModel oldModel : oldModelList) { - // 获取新旧节点关联关系 - final Map mapNewUUID1 = createShapeIdRelation(PALRepositoryCache.getCache().get(relationFileId), false); - // 处理流程属性 - String property = CoePropertyUtil.getPropertyValue(relationFileId + "_attr"); - if (!UtilString.isEmpty(property)) { - CoePropertyUtil.createProperty(newUUID + "_attr", property); - } - - - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List oldModelList = dao.getModelListByFileId(olduuid); - for (DesignerShapeRelationModel oldModel : oldModelList) { - - if(oldModel.getAttrId().equals("Process_performance_metrics")){ + if (oldModel.getAttrId().equals("Process_performance_metrics")) { //重新设置修订关联关系 - DesignerShapeRelationModel newModel1 = new DesignerShapeRelationModel(); - newModel1.setId(UUIDGener.getUUID()); - newModel1.setFileId(newModel.getId()); - newModel1.setShapeId(mapNewUUID.get(oldModel.getShapeId())); - newModel1.setShapeText(oldModel.getShapeText()); - newModel1.setAttrId(oldModel.getAttrId()); - newModel1.setRelationFileId(newUUID); - newModel1.setRelationShapeId(oldModel.getRelationShapeId()); - newModel1.setRelationShapeText(oldModel.getRelationShapeText()); - dao.insert(newModel1); - } + DesignerShapeRelationModel newModel1 = new DesignerShapeRelationModel(); + newModel1.setId(UUIDGener.getUUID()); + newModel1.setFileId(newModel.getId()); + newModel1.setShapeId(mapNewUUID.get(oldModel.getShapeId())); + newModel1.setShapeText(oldModel.getShapeText()); + newModel1.setAttrId(oldModel.getAttrId()); + newModel1.setRelationFileId(newUUID); + newModel1.setRelationShapeId(oldModel.getRelationShapeId()); + newModel1.setRelationShapeText(oldModel.getRelationShapeText()); + dao.insert(newModel1); + } + } - } + CoeProcessLevelUtil.copyRepositoryProperty(PALRepositoryCache.getCache().get(relationFileId), PALRepositoryCache.getCache().get(newUUID), mapNewUUID1, _uc); + ro = ResponseObject.newOkResponse("创建成功"); + ro.put("uuid", lastplModel.getId()); + } else { + ro = ResponseObject.newWarnResponse("创建失败"); + } + } catch (Exception e) { + ro = ResponseObject.newWarnResponse("创建失败," + e.getMessage()); + } - CoeProcessLevelUtil.copyRepositoryProperty(PALRepositoryCache.getCache().get(relationFileId), PALRepositoryCache.getCache().get(newUUID), mapNewUUID1, _uc); - ro = ResponseObject.newOkResponse("创建成功"); - ro.put("uuid", lastplModel.getId()); - }else{ - ro = ResponseObject.newWarnResponse("创建失败"); - } - } catch (Exception e) { - ro = ResponseObject.newWarnResponse("创建失败," + e.getMessage()); - } + } + + } - } - - } + return ro.toString(); + } + /** + * 设计器-删除某版本文件(放入回收站) + * + * @param wsId + * @param teamId + * @param id 模型文件id + * @return + */ + public String deletePalDesignerVersion(String wsId, String teamId, String id) { + ResponseObject ro; + PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(id); + List list = new ArrayList(); + list.add(plModel); + CoeProcessRecycleWeb recycleWeb = new CoeProcessRecycleWeb(_uc); + boolean insertFlag = recycleWeb.saveRecycleProcesses(plModel, list); // 流程信息存入回收站 + + if (insertFlag) { + CoeProcessLevelDaoFacotory.createCoeProcessLevel().deletePalRepositoryVersion(id); + CoeProcessLevelNoCache.getInstance().reloadInBackground(plModel.getWsId()); // 重新装载编号 + ro = ResponseObject.newOkResponse(); + ro.msg("已放入回收站"); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_DELETE, CoEOpLogConst.INFO_REPOSITORY_VERSION_DELETE); + } + deletePalCorrelationModel(wsId, teamId, id); + } else { + ro = ResponseObject.newErrResponse(); + ro.msg("删除失败"); + } + return ro.toString(); + } - return ro.toString(); - } + /** + * 同步删除关联绩效角色数据模型 + * + * @param wsId + * @param teamId + * @param id + * @return + */ + public String deletePalCorrelationModel(String wsId, String teamId, String id) { + ResponseObject ro = ResponseObject.newOkResponse(); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List oldModelList = dao.getModelListByFileId(id); + + if (oldModelList.size() > 0) { + DesignerShapeRelationModel oldModel = oldModelList.get(0); + //如果关联角色图,则同步复制角色图关联关系 + String methodIds = ""; + if (oldModel.getAttrId().equals("role")) { + PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(oldModel.getRelationFileId()); + List list = new ArrayList(); + list.add(plModel); + CoeProcessRecycleWeb recycleWeb = new CoeProcessRecycleWeb(_uc); + boolean insertFlag = recycleWeb.saveRecycleProcesses(plModel, list); // 流程信息存入回收站 + + if (insertFlag) { + CoeProcessLevelDaoFacotory.createCoeProcessLevel().deletePalRepositoryVersion(oldModel.getRelationFileId()); + CoeProcessLevelNoCache.getInstance().reloadInBackground(plModel.getWsId()); // 重新装载编号 + ro.msg("已放入回收站"); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_DELETE, CoEOpLogConst.INFO_REPOSITORY_VERSION_DELETE); + } + } else { + ro = ResponseObject.newErrResponse(); + ro.msg("删除失败"); + } + } + } + + return ro.toString(); + } + /** + * 设计器-切换版本状态为使用中 + * + * @param wsId + * @param teamId + * @param id + * @return + */ + public String changePalDesignerVersionUse(String wsId, String teamId, String id) { + int answer = 0; + PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); + PALRepositoryModel lastPlModel = repository.getInstance(id); + answer = repository.updateStateOfVersionUuid(lastPlModel.getVersionId());// 更新所有的为0 + answer = repository.updateUseStateOfVersionUuid(lastPlModel.getId());// 更新当前版本为使用状态 + CoeProcessLevelNoCache.getInstance().reloadInBackground(lastPlModel.getWsId()); + if (answer > 0) { + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("id", id); + + //将关联模型(角色、绩效)同步更改使用中状态 + changePalDesignerVersionUseBycorrelationRoleModel(wsId, teamId, id); + changePalDesignerVersionUseBycorrelationPerformanceModel(wsId, teamId, id); + + return ro.toString(); + } else { + return ResponseObject.newErrResponse("使用版本更新失败").toString(); + } + } - /** - * 设计器-删除某版本文件(放入回收站) - * @param wsId - * @param teamId - * @param id 模型文件id - * @return - */ - public String deletePalDesignerVersion(String wsId, String teamId, String id) { - ResponseObject ro; - PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(id); - List list = new ArrayList(); - list.add(plModel); - CoeProcessRecycleWeb recycleWeb = new CoeProcessRecycleWeb(_uc); - boolean insertFlag = recycleWeb.saveRecycleProcesses(plModel, list); // 流程信息存入回收站 + /** + * 将关联模型(角色、绩效)同步更改使用中状态 + * + * @param wsId + * @param teamId + * @param id + * @return + */ + public String changePalDesignerVersionUseBycorrelationRoleModel(String wsId, String teamId, String id) { + ResponseObject ro = ResponseObject.newOkResponse(); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List oldModelList = dao.getModelListByFileId(id); - if (insertFlag) { - CoeProcessLevelDaoFacotory.createCoeProcessLevel().deletePalRepositoryVersion(id); - CoeProcessLevelNoCache.getInstance().reloadInBackground(plModel.getWsId()); // 重新装载编号 - ro = ResponseObject.newOkResponse(); - ro.msg("已放入回收站"); - // 操作行为日志记录 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_DELETE, CoEOpLogConst.INFO_REPOSITORY_VERSION_DELETE); - } - deletePalCorrelationModel(wsId,teamId,id); - } else { - ro = ResponseObject.newErrResponse(); - ro.msg("删除失败"); - } - return ro.toString(); - } + if (oldModelList.size() > 0) { + DesignerShapeRelationModel oldModel = oldModelList.get(0); + + for (DesignerShapeRelationModel oneModel : oldModelList) { + //如果关联角色图,则同步复制角色图关联关系 + String methodIds = ""; + if (oldModel.getAttrId().equals("role")) { + int answer = 0; + PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); + PALRepositoryModel lastPlModel = repository.getInstance(oldModel.getRelationFileId()); + answer = repository.updateStateOfVersionUuid(lastPlModel.getVersionId());// 更新所有的为0 + answer = repository.updateUseStateOfVersionUuid(lastPlModel.getId());// 更新当前版本为使用状态 + CoeProcessLevelNoCache.getInstance().reloadInBackground(lastPlModel.getWsId()); + if (answer > 0) { + ro.put("id", id); + return ro.toString(); + } else { + return ResponseObject.newErrResponse("使用版本更新失败").toString(); + } + + } + } + + } + + return ro.toString(); + } - /** - * 同步删除关联绩效角色数据模型 - * @param wsId - * @param teamId - * @param id - * @return - */ - public String deletePalCorrelationModel (String wsId, String teamId, String id) { - ResponseObject ro=ResponseObject.newOkResponse(); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List oldModelList = dao.getModelListByFileId(id); + /** + * 将关联模型绩效同步更改使用中状态 + * + * @param wsId + * @param teamId + * @param id + * @return + */ + public String changePalDesignerVersionUseBycorrelationPerformanceModel(String wsId, String teamId, String id) { + ResponseObject ro = ResponseObject.newOkResponse(); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List oldModelList = dao.getModelListByFileId(id); + for (DesignerShapeRelationModel oldModel : oldModelList) { - if(oldModelList.size()>0){ - DesignerShapeRelationModel oldModel=oldModelList.get(0); - //如果关联角色图,则同步复制角色图关联关系 - String methodIds = ""; - if (oldModel.getAttrId().equals("role")) { - PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(oldModel.getRelationFileId()); - List list = new ArrayList(); - list.add(plModel); - CoeProcessRecycleWeb recycleWeb = new CoeProcessRecycleWeb(_uc); - boolean insertFlag = recycleWeb.saveRecycleProcesses(plModel, list); // 流程信息存入回收站 - - if (insertFlag) { - CoeProcessLevelDaoFacotory.createCoeProcessLevel().deletePalRepositoryVersion(oldModel.getRelationFileId()); - CoeProcessLevelNoCache.getInstance().reloadInBackground(plModel.getWsId()); // 重新装载编号 - ro.msg("已放入回收站"); - // 操作行为日志记录 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_DELETE, CoEOpLogConst.INFO_REPOSITORY_VERSION_DELETE); - } - } else { - ro = ResponseObject.newErrResponse(); - ro.msg("删除失败"); - } - } - } - - return ro.toString(); - } + //如果关联角色图,则同步复制角色图关联关系 + String methodIds = ""; + if (oldModel.getAttrId().equals("Process_performance_metrics")) { + int answer = 0; + PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); + PALRepositoryModel lastPlModel = repository.getInstance(oldModel.getRelationFileId()); + answer = repository.updateStateOfVersionUuid(lastPlModel.getVersionId());// 更新所有的为0 + answer = repository.updateUseStateOfVersionUuid(lastPlModel.getId());// 更新当前版本为使用状态 + CoeProcessLevelNoCache.getInstance().reloadInBackground(lastPlModel.getWsId()); + if (answer > 0) { + ro.put("id", id); + return ro.toString(); + } else { + return ResponseObject.newErrResponse("使用版本更新失败").toString(); + } - /** - * 设计器-切换版本状态为使用中 - * @param wsId - * @param teamId - * @param id - * @return - */ - public String changePalDesignerVersionUse(String wsId, String teamId, String id) { - int answer = 0; - PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - PALRepositoryModel lastPlModel = repository.getInstance(id); - answer = repository.updateStateOfVersionUuid(lastPlModel.getVersionId());// 更新所有的为0 - answer = repository.updateUseStateOfVersionUuid(lastPlModel.getId());// 更新当前版本为使用状态 - CoeProcessLevelNoCache.getInstance().reloadInBackground(lastPlModel.getWsId()); - if (answer > 0) { - ResponseObject ro = ResponseObject.newOkResponse(); - ro.put("id", id); - - //将关联模型(角色、绩效)同步更改使用中状态 - changePalDesignerVersionUseBycorrelationRoleModel(wsId,teamId,id); - changePalDesignerVersionUseBycorrelationPerformanceModel(wsId,teamId,id); - - return ro.toString(); - } else { - return ResponseObject.newErrResponse("使用版本更新失败").toString(); - } - } + } + } + return ro.toString(); + } - /** - * 将关联模型(角色、绩效)同步更改使用中状态 - * @param wsId - * @param teamId - * @param id - * @return - */ - public String changePalDesignerVersionUseBycorrelationRoleModel(String wsId, String teamId, String id) { - ResponseObject ro = ResponseObject.newOkResponse(); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List oldModelList = dao.getModelListByFileId(id); + // 生成更多特性的json串 + public String getMoreAttritbute(UserContext me, String type, String wsId, String uuid, String processDefId, String shapeName, String category, String defaultCategory) { + if (UtilString.isEmpty(category)) { + throw new AWSException("获取更多特性失败,category不允许为空"); + } + category = category.replace("_", "."); + if (category.equalsIgnoreCase("bpmn")) { + category = "process.bpmn2"; + } + if (shapeName.indexOf("_custom") > -1) { + shapeName = shapeName.substring(0, shapeName.indexOf("_")); + } + //对于泳道的处理(获取判断下面树数据的条件) + String tmpMethodId = ""; + if (StringUtils.isNotEmpty(uuid)) { + PALRepositoryModel tmpModel = PALRepositoryCache.getCache().get(uuid); + tmpMethodId = tmpModel.getMethodId(); + } - if(oldModelList.size()>0){ - DesignerShapeRelationModel oldModel=oldModelList.get(0); + List methodList = PALMethodCache.getPALMethodList(); + List> list = new ArrayList>(); + Set setGroup = new HashSet(); + Set setAttributes = new HashSet(); + for (String methodTemp : methodList) { + List methodIdList = PALMethodCache.getPALMethodModelListByMethod(methodTemp); + for (PALMethodModel methodObj : methodIdList) { + // if (tmpMethodId.equals(methodObj.getId())) { + if (category.equals(methodObj.getId()) || (category.equals("lane") && tmpMethodId.equals(methodObj.getId()))) { // update by sunlh 20200721 + String methodId = methodObj.getId(); + PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(methodId); + List group = palMethodModel.getGroup(); + Map groupMap = new HashMap(); + int count = 0; + if (group != null) { + for (PALMethodAttributeGroupModel groupModel : group) { + groupMap.put(groupModel.getName(), groupModel); + Map map = new HashMap(); + map.put("id", groupModel.getName()); + map.put("name", groupModel.getDesc()); + map.put("open", false); + map.put("iconFont", ""); + String parentName = groupModel.getParentName(); + if (parentName != null && !"".equals(parentName.trim())) { + map.put("pid", parentName); + } + if (count == 0) { + map.put("open", true); + } + count++; + setGroup.add(groupModel.getName()); + list.add(map); + } + } + //获取最新的属性设置 + CoeDesignerShapeAPIManager manager = CoeDesignerShapeAPIManager.getInstance(); + List attrLists = manager.getAllValidShapeAttributeModels(wsId, methodId); - for(DesignerShapeRelationModel oneModel :oldModelList){ - //如果关联角色图,则同步复制角色图关联关系 - String methodIds = ""; - if (oldModel.getAttrId().equals("role")) { - int answer = 0; - PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - PALRepositoryModel lastPlModel = repository.getInstance(oldModel.getRelationFileId()); - answer = repository.updateStateOfVersionUuid(lastPlModel.getVersionId());// 更新所有的为0 - answer = repository.updateUseStateOfVersionUuid(lastPlModel.getId());// 更新当前版本为使用状态 - CoeProcessLevelNoCache.getInstance().reloadInBackground(lastPlModel.getWsId()); - if (answer > 0) { - ro.put("id", id); - return ro.toString(); - } else { - return ResponseObject.newErrResponse("使用版本更新失败").toString(); - } + if (attrLists != null) { + for (PALMethodAttributeModel attributeModel : attrLists) { + //替换新名称 + String title = attributeModel.getNewTitle(); + String groupPath = attributeModel.getGroupPath(); + PALMethodAttributeGroupModel gm = groupMap.get(groupPath); + Map map = new HashMap(); + String scope = attributeModel.getScope(); + if (scope.contains(shapeName)) { + // 对属性的在图形上的作用域进行过虑 + map.put("id", attributeModel.getKey()); + map.put("name", title); + // map.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/icon/shape_attribute.png"); + map.put("iconFont", ""); + map.put("pid", gm.getName()); + map.put("key", attributeModel.getKey()); + map.put("value", attributeModel.getValue()); + map.put("type", attributeModel.getType()); + map.put("ref", attributeModel.getRef()); + map.put("readonly", attributeModel.getReadonly()); + map.put("groupPath", attributeModel.getGroupPath()); + map.put("scope", attributeModel.getScope()); + setAttributes.add(gm.getName()); + list.add(map); + } else if ("*".equals(scope) || scope.contains("*")) { + map.put("id", attributeModel.getKey()); + map.put("name", title); + // map.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/icon/shape_attribute.png"); + map.put("iconFont", ""); + map.put("pid", gm.getName()); + map.put("key", attributeModel.getKey()); + map.put("value", attributeModel.getValue()); + map.put("type", attributeModel.getType()); + map.put("ref", attributeModel.getRef()); + map.put("readonly", attributeModel.getReadonly()); + map.put("groupPath", attributeModel.getGroupPath()); + map.put("scope", attributeModel.getScope()); + setAttributes.add(gm.getName()); + list.add(map); + } - } - } + } + } - } + } + } + } + setGroup.removeAll(setAttributes); + List> list1 = new ArrayList>(); + for (int i = 0, size = list.size(); i < size; i++) { + if (!setGroup.contains(list.get(i).get("id"))) { + list1.add(list.get(i)); + } + } + //通过LANE_FORCE_REFRESH_SHAPE_ATTR_SCOPE参数来控制树数据显示 + if (category.equals("lane")) { + String[] attrScopes = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "LANE_FORCE_REFRESH_SHAPE_ATTR_SCOPE").split(","); + if (attrScopes != null && attrScopes.length > 0 && list1 != null && list1.size() > 0) { + List> list2 = Lists.newArrayList(); + List> list3 = Lists.newArrayList(); + Set pids = Sets.newHashSet(); + for (Map map : list1) { + String object = (String) map.get("key"); + if (object != null) { + for (String key : attrScopes) { + if (object.equals(key)) { + pids.add((String) map.get("pid")); + list3.add(map); + } + } + } + } + if (pids != null && pids.size() > 0) { + for (String pid : pids) { + for (Map map : list1) { + if (map.get("id").equals(pid)) { + list2.add(map); + } + } + } + } + list2.addAll(list3); + list1 = list2; + } + } - return ro.toString(); - } - - - /** - * 将关联模型绩效同步更改使用中状态 - * @param wsId - * @param teamId - * @param id - * @return - */ - public String changePalDesignerVersionUseBycorrelationPerformanceModel(String wsId, String teamId, String id) { - ResponseObject ro = ResponseObject.newOkResponse(); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List oldModelList = dao.getModelListByFileId(id); - for (DesignerShapeRelationModel oldModel : oldModelList) { - - //如果关联角色图,则同步复制角色图关联关系 - String methodIds = ""; - if (oldModel.getAttrId().equals("Process_performance_metrics")) { - int answer = 0; - PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - PALRepositoryModel lastPlModel = repository.getInstance(oldModel.getRelationFileId()); - answer = repository.updateStateOfVersionUuid(lastPlModel.getVersionId());// 更新所有的为0 - answer = repository.updateUseStateOfVersionUuid(lastPlModel.getId());// 更新当前版本为使用状态 - CoeProcessLevelNoCache.getInstance().reloadInBackground(lastPlModel.getWsId()); - if (answer > 0) { - ro.put("id", id); - return ro.toString(); - } else { - return ResponseObject.newErrResponse("使用版本更新失败").toString(); - } - - - } - } - return ro.toString(); - } - - - - - // 生成更多特性的json串 - public String getMoreAttritbute(UserContext me, String type, String wsId, String uuid, String processDefId, String shapeName, String category, String defaultCategory) { - if (UtilString.isEmpty(category)) { - throw new AWSException("获取更多特性失败,category不允许为空"); - } - category = category.replace("_", "."); - if (category.equalsIgnoreCase("bpmn")) { - category = "process.bpmn2"; - } - if (shapeName.indexOf("_custom") > -1) { - shapeName = shapeName.substring(0, shapeName.indexOf("_")); - } - //对于泳道的处理(获取判断下面树数据的条件) - String tmpMethodId = ""; - if (StringUtils.isNotEmpty(uuid)) { - PALRepositoryModel tmpModel = PALRepositoryCache.getCache().get(uuid); - tmpMethodId = tmpModel.getMethodId(); - } - - List methodList = PALMethodCache.getPALMethodList(); - List> list = new ArrayList>(); - Set setGroup = new HashSet(); - Set setAttributes = new HashSet(); - for (String methodTemp : methodList) { - List methodIdList = PALMethodCache.getPALMethodModelListByMethod(methodTemp); - for (PALMethodModel methodObj : methodIdList) { - // if (tmpMethodId.equals(methodObj.getId())) { - if (category.equals(methodObj.getId()) || (category.equals("lane") && tmpMethodId.equals(methodObj.getId()))) { // update by sunlh 20200721 - String methodId = methodObj.getId(); - PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(methodId); - List group = palMethodModel.getGroup(); - Map groupMap = new HashMap(); - int count = 0; - if (group != null) { - for (PALMethodAttributeGroupModel groupModel : group) { - groupMap.put(groupModel.getName(), groupModel); - Map map = new HashMap(); - map.put("id", groupModel.getName()); - map.put("name", groupModel.getDesc()); - map.put("open", false); - map.put("iconFont", ""); - String parentName = groupModel.getParentName(); - if (parentName != null && !"".equals(parentName.trim())) { - map.put("pid", parentName); - } - if (count == 0) { - map.put("open", true); - } - count++; - setGroup.add(groupModel.getName()); - list.add(map); - } - } - //获取最新的属性设置 - CoeDesignerShapeAPIManager manager = CoeDesignerShapeAPIManager.getInstance(); - List attrLists = manager.getAllValidShapeAttributeModels(wsId, methodId); - - if (attrLists != null) { - for (PALMethodAttributeModel attributeModel : attrLists) { - //替换新名称 - String title = attributeModel.getNewTitle(); - String groupPath = attributeModel.getGroupPath(); - PALMethodAttributeGroupModel gm = groupMap.get(groupPath); - Map map = new HashMap(); - String scope = attributeModel.getScope(); - if (scope.contains(shapeName)) { - // 对属性的在图形上的作用域进行过虑 - map.put("id", attributeModel.getKey()); - map.put("name", title); - // map.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/icon/shape_attribute.png"); - map.put("iconFont", ""); - map.put("pid", gm.getName()); - map.put("key", attributeModel.getKey()); - map.put("value", attributeModel.getValue()); - map.put("type", attributeModel.getType()); - map.put("ref", attributeModel.getRef()); - map.put("readonly", attributeModel.getReadonly()); - map.put("groupPath", attributeModel.getGroupPath()); - map.put("scope", attributeModel.getScope()); - setAttributes.add(gm.getName()); - list.add(map); - } else if ("*".equals(scope) || scope.contains("*")) { - map.put("id", attributeModel.getKey()); - map.put("name", title); - // map.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/icon/shape_attribute.png"); - map.put("iconFont", ""); - map.put("pid", gm.getName()); - map.put("key", attributeModel.getKey()); - map.put("value", attributeModel.getValue()); - map.put("type", attributeModel.getType()); - map.put("ref", attributeModel.getRef()); - map.put("readonly", attributeModel.getReadonly()); - map.put("groupPath", attributeModel.getGroupPath()); - map.put("scope", attributeModel.getScope()); - setAttributes.add(gm.getName()); - list.add(map); - } - - } - } - - } - } - } - setGroup.removeAll(setAttributes); - List> list1 = new ArrayList>(); - for (int i = 0, size = list.size(); i < size; i++) { - if (!setGroup.contains(list.get(i).get("id"))) { - list1.add(list.get(i)); - } - } - //通过LANE_FORCE_REFRESH_SHAPE_ATTR_SCOPE参数来控制树数据显示 - if (category.equals("lane")) { - String[] attrScopes = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "LANE_FORCE_REFRESH_SHAPE_ATTR_SCOPE").split(","); - if (attrScopes != null && attrScopes.length > 0 && list1 != null && list1.size() > 0) { - List> list2 = Lists.newArrayList(); - List> list3 = Lists.newArrayList(); - Set pids = Sets.newHashSet(); - for (Map map : list1) { - String object = (String)map.get("key"); - if (object != null) { - for (String key : attrScopes) { - if (object.equals(key)) { - pids.add((String)map.get("pid")); - list3.add(map); - } - } - } - } - if (pids != null && pids.size() > 0) { - for (String pid : pids) { - for (Map map : list1) { - if (map.get("id").equals(pid)) { - list2.add(map); - } - } - } - } - list2.addAll(list3); - list1 = list2; - } - } - - Map macroLibraries = new HashMap(); - JSONArray jsonarray = JSONArray.parseArray(JSON.toJSONString(list1)); - macroLibraries.put("sid", _uc.getSessionId()); - macroLibraries.put("data", jsonarray); - macroLibraries.put("attrType", "1"); - String template = "pal.pl.repository.designer.more.attribute.htm"; - List selectIds = Lists.newArrayList(); - if (type.equals("shapeConfigSelect")) { - template = "pal.pl.manage.shape.config.more.attribute.htm"; - if (StringUtils.isEmpty(defaultCategory)) { - defaultCategory = category; - } - List shapeAttributeList = PALRepositoryShapeAttributeCache.getAttributeListByShapeName(wsId, defaultCategory, shapeName); - if (shapeAttributeList.size() > 0) { - for (PALRepositoryShapeAttributeModel model : shapeAttributeList) { - selectIds.add(model.getAttrId()); - } - } - macroLibraries.put("selectIds", JSONArray.parseArray(JSON.toJSONString(selectIds))); - } - return HtmlPageTemplate.merge(CoEConstant.APP_ID, template, macroLibraries); - } + Map macroLibraries = new HashMap(); + JSONArray jsonarray = JSONArray.parseArray(JSON.toJSONString(list1)); + macroLibraries.put("sid", _uc.getSessionId()); + macroLibraries.put("data", jsonarray); + macroLibraries.put("attrType", "1"); + String template = "pal.pl.repository.designer.more.attribute.htm"; + List selectIds = Lists.newArrayList(); + if (type.equals("shapeConfigSelect")) { + template = "pal.pl.manage.shape.config.more.attribute.htm"; + if (StringUtils.isEmpty(defaultCategory)) { + defaultCategory = category; + } + List shapeAttributeList = PALRepositoryShapeAttributeCache.getAttributeListByShapeName(wsId, defaultCategory, shapeName); + if (shapeAttributeList.size() > 0) { + for (PALRepositoryShapeAttributeModel model : shapeAttributeList) { + selectIds.add(model.getAttrId()); + } + } + macroLibraries.put("selectIds", JSONArray.parseArray(JSON.toJSONString(selectIds))); + } + return HtmlPageTemplate.merge(CoEConstant.APP_ID, template, macroLibraries); + } } diff --git a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.html b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.html index 9b553ef3..562635a4 100755 --- a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.html +++ b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.html @@ -658,11 +658,11 @@ $(".suofang").hide(); $(".newadd_card .title").hide(); //$(".headerTab").css("margin-right" , "5%"); - changeUrl(); + changeUrl(); } - // else { - // $(".headerTab").css("margin-right" , "4%"); - // } + // else { + // $(".headerTab").css("margin-right" , "4%"); + // } }); @@ -697,7 +697,7 @@ //将文件预览页面嵌入流程模型页面 function changeUrl() { - $.ajax({ + $.ajax({ type : "POST", url : "./jd?sid=" + sid + "&cmd=com.actionsoft.apps.coe.pal_outputreport_output_process_preview", @@ -819,7 +819,6 @@ //隐藏评论div function hideLayerSide() { - debugger; $(".pinglun").animate({ "right": "-25%", "width": "25%", "height": "85%" }); $(".floatBtnDiv").animate({ "right":"-1%", "width": "69px", "height": "auto" }); } @@ -990,8 +989,8 @@ font-size: 16px; } .floatBtn:hover {cursor: pointer; - color: rgb(55,198,192); - background-color: #3771e0; + color: rgb(55,198,192); + background-color: #3771e0; } #x:hover {cursor: pointer;color: rgb(55,198,192);} @@ -1009,7 +1008,7 @@ box-shadow: 0 10px 30px rgb(0, 0, 0, .2); overflow: auto; } - + @@ -1090,13 +1089,13 @@ -->
    - -
    -
    相关/支持文件
    - - -
    + +
    +
    相关/支持文件
    + +
    +
    @@ -1162,104 +1161,104 @@
    -
    - - - + + + + + +
    +
    + + + +
    +
    + +
    + + + + + + - - - - -
    -
    - - - + -
    - - - - - -