更新岗位定时器/PAL打包
This commit is contained in:
parent
2ee86fdec3
commit
117e10145c
Binary file not shown.
@ -9,6 +9,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
@ -182,7 +183,7 @@ public class SynchronousPortJob implements IJob {
|
||||
coeProcessLevel.insert(model1);
|
||||
createPostData(model1.getId(), org.getString("ID"), model1, conn);
|
||||
return modelId = model1.getId();
|
||||
} else {
|
||||
}/* else {
|
||||
PALRepositoryModelImpl model = (PALRepositoryModelImpl) coeProcessLevel.getInstance(orgrowMap.getString("ID"));
|
||||
String plname = orgrowMap.getString("PLNAME");
|
||||
if (!plname.equals(org.getString("DEPARTMENTNAME"))) {
|
||||
@ -191,7 +192,7 @@ public class SynchronousPortJob implements IJob {
|
||||
}
|
||||
createPostData(model.getId(), org.getString("ID"), model, conn);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
@ -213,7 +214,7 @@ public class SynchronousPortJob implements IJob {
|
||||
|
||||
createPostData(model2.getId(), org.getString("ID"), model2, conn);
|
||||
return modelId = model2.getId();
|
||||
}else{
|
||||
}/*else{
|
||||
|
||||
PALRepositoryModelImpl model = (PALRepositoryModelImpl)coeProcessLevel.getInstance(orgrowMap.getString("ID"));
|
||||
String plname=orgrowMap.getString("PLNAME");
|
||||
@ -222,7 +223,7 @@ public class SynchronousPortJob implements IJob {
|
||||
DBSql.update(conn, String.format(updateSql, org.getString("DEPARTMENTNAME"), orgrowMap.getString("ID")));
|
||||
}
|
||||
createPostData(orgrowMap.getString("ID"), org.getString("ID"), model, conn);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@ -262,7 +263,7 @@ public class SynchronousPortJob implements IJob {
|
||||
|
||||
|
||||
|
||||
List<RowMap> orgdepartmentList = DBSql.getMaps(conn, "select DESCR,DEPTNAME from BO_EU_ORG_POSTS WHERE DEPTID=? AND DESCR IS NOT NULL ", departmentId);
|
||||
List<RowMap> orgdepartmentList = DBSql.getMaps(conn, "select distinct(DESCR),DEPTNAME from BO_EU_ORG_POSTS WHERE DEPTID=? AND DESCR IS NOT NULL ", departmentId);
|
||||
|
||||
|
||||
JSONArray shapes = new JSONArray();
|
||||
@ -279,11 +280,11 @@ public class SynchronousPortJob implements IJob {
|
||||
JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName("org.normal", "position");
|
||||
|
||||
|
||||
|
||||
//查询模型形状
|
||||
PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(uuid);
|
||||
|
||||
|
||||
System.out.println("name=============="+parentModel.getName());
|
||||
try {
|
||||
List<Map<String, Object>> fileElements = CoeDesignerUtil.getShapeMessageJson4(uuid);
|
||||
|
||||
|
||||
@ -0,0 +1,561 @@
|
||||
package com.actionsoft.apps.coe.pal.pal.repository.job;
|
||||
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
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.designer.manage.CoeDesignerAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeRepositoryImportUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.DiagramsUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.ShapeUtil;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.server.Quota;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import jodd.util.StringUtil;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* 定时同步部门、岗位数据从伊利集成-岗位接口数据进行同步
|
||||
*/
|
||||
public class SynchronousUpdatePortJob implements IJob {
|
||||
|
||||
|
||||
static List<RowMap> orgdepartmentList;
|
||||
static int orgindex = 0;
|
||||
static String parentModelId = "";
|
||||
static String wsId;
|
||||
|
||||
private UserContext _uc;
|
||||
|
||||
|
||||
/**
|
||||
* 同步组织、架构数据
|
||||
* 更新组织名称/数量,更新岗位名称/数量
|
||||
* @param jobExecutionContext
|
||||
* @throws JobExecutionException
|
||||
*/
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
String wsIdParams = SDK.getJobAPI().getJobParameter(jobExecutionContext);
|
||||
|
||||
|
||||
wsId=queryMaPublishGetWsId();
|
||||
|
||||
|
||||
//先执行新建操作产生plid
|
||||
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
|
||||
String parentId = "process";
|
||||
int orderIndex = getChildrenMaxOrderIndexByPidAndWsId(parentId, wsId) + 1;
|
||||
|
||||
String plRid1 = UUIDGener.getUUID();
|
||||
String id1 = UUIDGener.getUUID();
|
||||
|
||||
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
//判断如果methodID为角色图,则创建到对应角色模型文件夹中
|
||||
String modeldefaultId;
|
||||
RowMap rowMaprole=DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME='岗位模型' and PLCATEGORY='org' AND PLMETHODID='org.normal' ");
|
||||
if(rowMaprole==null){
|
||||
modeldefaultId = Createfolder(orderIndex);
|
||||
}else{
|
||||
modeldefaultId=rowMaprole.getString("id");
|
||||
}
|
||||
|
||||
Connection open = DBSql.open();
|
||||
try {
|
||||
orgdepartmentList = DBSql.getMaps(open, "select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID,ORDERINDEX from ORGDEPARTMENT where Closed=0 ");
|
||||
|
||||
|
||||
RowMap parentModel=DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME='内蒙古伊利实业集团股份有限公司' and PLMETHODID='org.normal'");
|
||||
String parentModelIds=null;
|
||||
if(parentModel==null){
|
||||
PALRepositoryModelImpl model= CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, wsId, "内蒙古伊利实业集团股份有限公司",
|
||||
"", orderIndex, modeldefaultId, "org", true, 1,
|
||||
id1, false, "org.normal", "0", 1, null,
|
||||
null, "admin", "admin", nowTime, "0", null,
|
||||
null, null, null, null, null, null, null, 1);
|
||||
coeProcessLevel.insert(model);
|
||||
parentModelIds=model.getId();
|
||||
}else{
|
||||
parentModelIds=parentModel.getString("ID");
|
||||
}
|
||||
parentModelId = parentModelIds;
|
||||
orgindex = 0;
|
||||
createTree(open);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
DBSql.close(open);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建岗位模型文件夹
|
||||
*
|
||||
* @param orderIndex
|
||||
* @return
|
||||
*/
|
||||
public String Createfolder(int orderIndex) {
|
||||
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
|
||||
String plRid1 = UUIDGener.getUUID();
|
||||
String id1 = UUIDGener.getUUID();
|
||||
|
||||
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
RowMap rowMapdefalut=DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME='岗位模型' AND PLMETHODID='default' ");
|
||||
|
||||
String rowMapdefalutId;
|
||||
if(rowMapdefalut==null){
|
||||
//新建文件夹
|
||||
PALRepositoryModelImpl modeldefault = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, wsId, "岗位模型",
|
||||
"", orderIndex, "org", "org", true, 1,
|
||||
id1, false, "default", "0", 1, null,
|
||||
null, "admin", "admin", nowTime, null, null,
|
||||
null, null, null, null, null, null, null, 1);
|
||||
coeProcessLevel.insert(modeldefault);
|
||||
rowMapdefalutId=modeldefault.getId();
|
||||
}else{
|
||||
rowMapdefalutId=rowMapdefalut.getString("ID");
|
||||
}
|
||||
|
||||
return rowMapdefalutId;
|
||||
}
|
||||
|
||||
public void createTree(Connection open) {
|
||||
|
||||
for (RowMap oneData : orgdepartmentList) {
|
||||
orgindex++;
|
||||
creatNode(oneData, open);
|
||||
}
|
||||
System.out.println("同步完成,数据" + orgindex);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String creatNode(RowMap org, Connection conn) {
|
||||
//先执行新建操作产生plid
|
||||
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
|
||||
|
||||
String modelId = "";
|
||||
String plRid1 = UUIDGener.getUUID();
|
||||
String id1 = UUIDGener.getUUID();
|
||||
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
|
||||
if (org.getString("PARENTDEPARTMENTID").equals("0")) {
|
||||
String sql1 = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE wsId='" + wsId + "' and EXT1='" + org.getString("ID") + "'";
|
||||
String parentPalOrgId1 = DBSql.getString(conn, sql1);
|
||||
if (StringUtil.isEmpty(parentPalOrgId1)) {
|
||||
|
||||
RowMap orgrowMap = DBSql.getMap("SELECT PLNAME,ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT1=? AND PLMETHODID='org.normal'", org.getString("ID"));
|
||||
if (orgrowMap == null) {
|
||||
PALRepositoryModelImpl model1 = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, wsId, org.getString("DEPARTMENTNAME"),
|
||||
"", 1, parentModelId, "org", true, 1,
|
||||
id1, false, "org.normal", "0", Integer.valueOf(org.getString("ORDERINDEX")), null,
|
||||
null, "admin", "admin", nowTime, org.getString("ID"), null,
|
||||
null, null, null, null, null, null, null, 1);
|
||||
coeProcessLevel.insert(model1);
|
||||
createPostData(model1.getId(), org.getString("ID"), model1, conn);
|
||||
return modelId = model1.getId();
|
||||
} else {
|
||||
PALRepositoryModelImpl model = (PALRepositoryModelImpl) coeProcessLevel.getInstance(orgrowMap.getString("ID"));
|
||||
/* String plname = orgrowMap.getString("PLNAME");
|
||||
if (!plname.equals(org.getString("DEPARTMENTNAME"))) {
|
||||
String updateSql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET PLNAME=? WHERE ID=? AND PLMETHODID='org.normal'";
|
||||
DBSql.update(conn, String.format(updateSql, org.getString("DEPARTMENTNAME"), orgrowMap.getString("ID")));
|
||||
}*/
|
||||
createPostData(model.getId(), org.getString("ID"), model, conn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
String parentPalOrgId = getParentPalOrgId(org, conn);
|
||||
|
||||
|
||||
if (StringUtil.isNotEmpty(parentPalOrgId)) {
|
||||
RowMap orgrowMap=DBSql.getMap("SELECT PLNAME,ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT1=? AND PLMETHODID='org.normal'",org.getString("ID"));
|
||||
if(orgrowMap==null) {
|
||||
PALRepositoryModelImpl model2 = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, wsId, org.getString("DEPARTMENTNAME"),
|
||||
"", 1, getParentPalOrgId(org, conn), "org", true, 1,
|
||||
id1, false, "org.normal", "0", Integer.valueOf(org.getString("ORDERINDEX")), null,
|
||||
null, "admin", "admin", nowTime, org.getString("ID"), null,
|
||||
null, null, null, null, null, null, null, 1);
|
||||
coeProcessLevel.insert(model2);
|
||||
|
||||
createPostData(model2.getId(), org.getString("ID"), model2, conn);
|
||||
return modelId = model2.getId();
|
||||
}else{
|
||||
|
||||
PALRepositoryModelImpl model = (PALRepositoryModelImpl)coeProcessLevel.getInstance(orgrowMap.getString("ID"));
|
||||
/*String plname=orgrowMap.getString("PLNAME");
|
||||
if(!plname.equals(org.getString("DEPARTMENTNAME"))){
|
||||
String updateSql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET PLNAME=? WHERE ID=? AND PLMETHODID='org.normal'";
|
||||
DBSql.update(conn, String.format(updateSql, org.getString("DEPARTMENTNAME"), orgrowMap.getString("ID")));
|
||||
}*/
|
||||
|
||||
createPostData(orgrowMap.getString("ID"), org.getString("ID"), model, conn);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return modelId;
|
||||
|
||||
}
|
||||
|
||||
public String getParentPalOrgId(RowMap org, Connection conn) {
|
||||
|
||||
String sql = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE wsId='" + wsId + "' and EXT1='" + org.getString("PARENTDEPARTMENTID") + "'";
|
||||
String parentPalOrgId = DBSql.getString(conn, sql);
|
||||
|
||||
if (parentPalOrgId.equals("0") || parentPalOrgId.equals("") || parentPalOrgId == null) {
|
||||
RowMap parentOrg = DBSql.getMap(conn, "select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID,ORDERINDEX from ORGDEPARTMENT where id = '" + org.getString("PARENTDEPARTMENTID") + "'");
|
||||
creatNode(parentOrg, conn);
|
||||
}
|
||||
|
||||
return parentPalOrgId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建岗位图形
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
public void createPostData(String uuid, String departmentId, PALRepositoryModelImpl model, Connection conn) {
|
||||
|
||||
Map<String, String> idRelationMap = new HashMap<>();
|
||||
|
||||
|
||||
List<RowMap> orgdepartmentList = DBSql.getMaps(conn, "select distinct(DESCR),DEPTNAME from BO_EU_ORG_POSTS WHERE DEPTID=? AND DESCR IS NOT NULL ", departmentId);
|
||||
|
||||
|
||||
JSONArray shapes = new JSONArray();
|
||||
if (orgdepartmentList.size() > 0) {
|
||||
//拿到基础结构
|
||||
JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName("org.normal", "position");
|
||||
|
||||
List<String> data2=new ArrayList();
|
||||
for (int i = 0; i < orgdepartmentList.size(); i++) {
|
||||
|
||||
String positionName = orgdepartmentList.get(i).getString("DESCR");
|
||||
String deptname = orgdepartmentList.get(i).getString("DEPTNAME");
|
||||
|
||||
|
||||
for(int l=0;l<orgdepartmentList.size();l++){
|
||||
data2.add(orgdepartmentList.get(l).getString("DESCR").toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<String> data=new ArrayList();
|
||||
List<Map<String, Object>> fileElements = CoeDesignerUtil.getShapeMessageJson4(uuid);
|
||||
|
||||
for (Map<String, Object> str : fileElements) {
|
||||
|
||||
if (!data2.contains(str.get("name").toString().trim())) {//如果存在这个数
|
||||
|
||||
RowMap rowMap=DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_SHAPE_RLAT t WHERE t.RELATIONFILEID='"+uuid+"' and t.RELATIONSHAPETEXT='"+str.get("name")+"'");
|
||||
if(rowMap==null){
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0);
|
||||
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
elements.remove(str.get("id"));
|
||||
|
||||
definition.put("elements",elements);
|
||||
|
||||
|
||||
defineModel.setDefinition(definition.toString());
|
||||
// 保存文件
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作*/
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
JSONObject newShape = JSONObject.parseObject(shape.toString());
|
||||
newShape.put("id", str.get("id"));
|
||||
newShape.put("text", str.get("name"));
|
||||
shapes.add(newShape);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(shapes.size()>0) {
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0);
|
||||
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
|
||||
JSONObject elements2 = definition.getJSONObject("elements");
|
||||
|
||||
/* int maxZIndex = getMaxPropsZIndex(elements2);// 层级
|
||||
int initY = getMaxPositionY(elements2);// 默认的纵向坐标
|
||||
JSONArray newShapes = getMethodElementsJSONArray(shapes, 6, maxZIndex, initY);*/
|
||||
|
||||
JSONArray newShapes = this.getMethodElementsJSONArray(shapes, 6);
|
||||
|
||||
JSONObject elementsJson = JSONObject.parseObject(definition.getString("elements"));
|
||||
for (int z = 0; z < newShapes.size(); z++) {
|
||||
JSONObject shapeObj = newShapes.getJSONObject(z);
|
||||
elementsJson.put(shapeObj.getString("id"), shapeObj);
|
||||
}
|
||||
|
||||
definition.put("elements", elementsJson);
|
||||
defineModel.setDefinition(definition.toString());
|
||||
|
||||
//DiagramsUtil.setDiagramHeightWidth(definition, elementsJson);
|
||||
|
||||
// 保存文件
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建具有合理位置的节点数据
|
||||
*
|
||||
* @param elements
|
||||
* @param shapeRowCount
|
||||
* @return
|
||||
*/
|
||||
private JSONArray getMethodElementsJSONArray(JSONArray elements, int shapeRowCount) {
|
||||
JSONArray result = new JSONArray();
|
||||
int zindex = 0;
|
||||
int initX = 0;
|
||||
int initY = 0;
|
||||
int pageEdge = 100;
|
||||
int count = 0;
|
||||
initX += pageEdge;
|
||||
initY += pageEdge;
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
JSONObject shape = elements.getJSONObject(i);
|
||||
count++;
|
||||
if (count % (shapeRowCount + 1) == 0) {
|
||||
count = 1;
|
||||
initY += 130;
|
||||
// 换行
|
||||
initX = 0;
|
||||
initX = pageEdge + initX;
|
||||
}
|
||||
zindex++;
|
||||
if (shape.containsKey("dataAttributes")) {
|
||||
JSONArray dataAttributes = JSONArray.parseArray(shape.getString("dataAttributes"));
|
||||
for (int index = 0; index < dataAttributes.size(); index++) {
|
||||
dataAttributes.getJSONObject(index).put("id", UUIDGener.getObjectId());
|
||||
}
|
||||
shape.put("dataAttributes", dataAttributes);
|
||||
}
|
||||
int totalWidth = 160;// 每个节点总宽度,空白+节点+空白
|
||||
int totalHeight = 200;// 每个节点总高度,空白+节点+空白
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = validateJson(shape.getJSONObject("props").getInteger("w"));
|
||||
int h = validateJson(shape.getJSONObject("props").getInteger("h"));
|
||||
int leftBlankWidth = (totalWidth - w) / 2;
|
||||
int topBlankHeight = (totalHeight - h) / 2;
|
||||
x = initX + leftBlankWidth;
|
||||
initX = x + w + leftBlankWidth;
|
||||
y = initY + topBlankHeight;
|
||||
|
||||
|
||||
|
||||
JSONObject props = shape.getJSONObject("props");
|
||||
props.put("x", x);
|
||||
props.put("y", y);
|
||||
props.put("zindex", zindex);
|
||||
shape.put("props", props);
|
||||
result.add(shape);
|
||||
|
||||
System.out.println("x========"+x);
|
||||
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 创建具有合理位置的节点数据
|
||||
*
|
||||
* @param elements
|
||||
* @param shapeRowCount
|
||||
* @return
|
||||
*/
|
||||
private JSONArray getMethodElementsJSONArray(JSONArray elements, int shapeRowCount, int maxZIndex, int initY) {
|
||||
JSONArray result = new JSONArray();
|
||||
int zindex = maxZIndex;
|
||||
int initX = 0;
|
||||
int pageEdge = 100;
|
||||
int count = 0;
|
||||
initX += pageEdge;
|
||||
initY += pageEdge;
|
||||
if (maxZIndex > 0) {// 在已有图的基础上增加的形状,缩小默认的纵轴距离高度
|
||||
initY = initY - pageEdge;
|
||||
}
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
JSONObject shape = elements.getJSONObject(i);
|
||||
count++;
|
||||
if (count % (shapeRowCount+1) == 0) {
|
||||
count = 1;
|
||||
initY += 90;
|
||||
// 换行
|
||||
initX = 0;
|
||||
initX = pageEdge + initX;
|
||||
}
|
||||
zindex++;
|
||||
if (shape.containsKey("dataAttributes")) {
|
||||
JSONArray dataAttributes = JSONArray.parseArray(shape.getString("dataAttributes"));
|
||||
for (int index = 0; index < dataAttributes.size(); index++) {
|
||||
dataAttributes.getJSONObject(index).put("id", UUIDGener.getObjectId());
|
||||
}
|
||||
shape.put("dataAttributes", dataAttributes);
|
||||
}
|
||||
int totalWidth = 160;// 每个节点总宽度,空白+节点+空白
|
||||
int totalHeight = 200;// 每个节点总高度,空白+节点+空白
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = validateJson(shape.getJSONObject("props").getInteger("w"));
|
||||
int h = validateJson(shape.getJSONObject("props").getInteger("h"));
|
||||
int leftBlankWidth = (totalWidth - w)/2;
|
||||
int topBlankHeight = (totalHeight - h)/2;
|
||||
x = initX + leftBlankWidth;
|
||||
initX = x + w + leftBlankWidth;
|
||||
y = initY + topBlankHeight;
|
||||
// y = pageEdge + initY;
|
||||
// if (y < 0) {
|
||||
// y = 100;
|
||||
// }
|
||||
JSONObject props = shape.getJSONObject("props");
|
||||
props.put("x", x);
|
||||
props.put("y", y);
|
||||
props.put("zindex", zindex);
|
||||
shape.put("props", props);
|
||||
result.add(shape);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String validateJson(String name) {
|
||||
return name == null ? "" : name;
|
||||
}
|
||||
|
||||
private int validateJson(Integer index) {
|
||||
return index == null ? 0 : index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件的下级文件的最大orderIndex
|
||||
* 在不同的资产库根节点(palId)都相同,增加资产库避免统计时错误
|
||||
*
|
||||
* @param palId
|
||||
* @param wsId
|
||||
* @return
|
||||
* @author sunlh
|
||||
*/
|
||||
public int getChildrenMaxOrderIndexByPidAndWsId(String palId, String wsId) {
|
||||
String sql = "SELECT MAX(PLORDERINDEX) AS orderIndex FROM APP_ACT_COE_PAL_REPOSITORY WHERE (PLPARENTID IN " + "(SELECT r1.id FROM APP_ACT_COE_PAL_REPOSITORY r1, APP_ACT_COE_PAL_REPOSITORY r2 WHERE r1.PLVERSIONID = r2.PLVERSIONID AND r2.id='" + palId + "')" + " OR PLPARENTID = '" + palId + "') AND wsid='" + wsId + "'";
|
||||
int maxOrderIndex = DBSql.getInt(sql, "orderIndex");
|
||||
return maxOrderIndex;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据当前许可环境获取当前wsid
|
||||
* @return
|
||||
*/
|
||||
public String queryMaPublishGetWsId(){
|
||||
String wsId = null;
|
||||
boolean dev = Quota.isDEV();
|
||||
if(dev==true){
|
||||
wsId="0285ff6a-e418-4d8b-a5b1-22240296f769";
|
||||
}
|
||||
boolean prd=Quota.isPRD();
|
||||
if(prd==true){
|
||||
wsId="7d3ca852-a0bd-42e6-80b1-3dcea6f55083";
|
||||
}
|
||||
boolean qas=Quota.isQAS();
|
||||
if(qas==true){
|
||||
wsId="7d3ca852-a0bd-42e6-80b1-3dcea6f55083";
|
||||
}
|
||||
return wsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取形状的最大层级zindex
|
||||
* @param elements
|
||||
* @return
|
||||
*/
|
||||
private int getMaxPropsZIndex(JSONObject elements) {
|
||||
int max = 0;
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
JSONObject props = shape.getJSONObject("props");
|
||||
int zindex = props.getIntValue("zindex");
|
||||
max = max > zindex ? max : zindex;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
/**
|
||||
* 获取已有形状的最大纵向高度
|
||||
* @param elements
|
||||
* @return
|
||||
*/
|
||||
private int getMaxPositionY(JSONObject elements) {
|
||||
int max = 0;
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
String shapeName = shape.getString("name");
|
||||
if(!"linker".equals(shapeName)) {
|
||||
JSONObject props = shape.getJSONObject("props");
|
||||
int y = props.getIntValue("y") + props.getIntValue("h");
|
||||
max = max > y ? max : y;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,306 @@
|
||||
package com.actionsoft.apps.coe.pal.pal.repository.job;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.web.DesignerRelationShapeWeb;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.DiagramsUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.ShapeUtil;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.login.constant.LoginConst;
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.server.SSOUtil;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class updatePostJob implements IJob {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
|
||||
List<RowMap> rowMaps=DBSql.getMaps("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLMETHODID='org.normal' and id='c0914e80-1cbe-45a0-908c-55cbe0a48dd5'");
|
||||
|
||||
for(int k=0;k<rowMaps.size();k++){
|
||||
|
||||
Connection conn = DBSql.open();
|
||||
List<Map<String, Object>> fileElements = CoeDesignerUtil.getShapeMessageJson4(rowMaps.get(k).getString("ID"));
|
||||
|
||||
if (fileElements.size() > 0) {
|
||||
List listdata = new ArrayList();
|
||||
|
||||
boolean flag=true;
|
||||
List<RowMap> orgpostslist = DBSql.getMaps(conn, "select DESCR,DEPTNAME,ID from BO_EU_ORG_POSTS WHERE DEPTID=? AND DESCR IS NOT NULL ", "ab6eb09f-a42b-43ab-a464-1e0a00bd1f04");
|
||||
|
||||
if(orgpostslist.size()>0){
|
||||
|
||||
JSONArray shapes = new JSONArray();
|
||||
//拿到基础结构
|
||||
JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName("org.normal", "position");
|
||||
|
||||
|
||||
List<String> data2=new ArrayList();
|
||||
for(int l=0;l<orgpostslist.size();l++){
|
||||
data2.add(orgpostslist.get(l).getString("DESCR").toString());
|
||||
}
|
||||
List result = new ArrayList();
|
||||
List<String> data=new ArrayList();
|
||||
for (Map<String, Object> str : fileElements) {
|
||||
|
||||
|
||||
if (!data2.contains(str.get("name").toString().trim())) {//如果存在这个数
|
||||
|
||||
RowMap rowMap=DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_SHAPE_RLAT t WHERE t.RELATIONFILEID='"+rowMaps.get(k).getString("ID")+"' and t.RELATIONSHAPETEXT='"+str.get("name")+"'");
|
||||
if(rowMap==null){
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(rowMaps.get(k).getString("ID"), 0);
|
||||
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
elements.remove(str.get("id"));
|
||||
|
||||
|
||||
definition.put("elements",elements);
|
||||
|
||||
// 设置画布大小
|
||||
DiagramsUtil.setDiagramHeightWidth(definition, elements);
|
||||
|
||||
defineModel.setDefinition(definition.toString());
|
||||
// 保存文件
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作*/
|
||||
}
|
||||
|
||||
}else{
|
||||
JSONObject newShape = JSONObject.parseObject(shape.toString());
|
||||
newShape.put("id", str.get("id"));
|
||||
newShape.put("text", str.get("name"));
|
||||
shapes.add(newShape);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(rowMaps.get(k).getString("ID"), 0);
|
||||
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
|
||||
JSONObject elements2 = definition.getJSONObject("elements");
|
||||
|
||||
|
||||
|
||||
int maxZIndex = getMaxPropsZIndex(elements2);// 层级
|
||||
int initY = getMaxPositionY(elements2);// 默认的纵向坐标
|
||||
JSONArray newShapes = getMethodElementsJSONArray(shapes, 6, maxZIndex, initY);
|
||||
JSONObject elementsJson = JSONObject.parseObject(definition.getString("elements"));
|
||||
for (int z = 0; z < newShapes.size(); z++) {
|
||||
JSONObject shapeObj = newShapes.getJSONObject(z);
|
||||
elementsJson.put(shapeObj.getString("id"), shapeObj);
|
||||
}
|
||||
|
||||
definition.put("elements",elementsJson);
|
||||
defineModel.setDefinition(definition.toString());
|
||||
// 保存文件
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private String validateJson(String name) {
|
||||
return name == null ? "" : name;
|
||||
}
|
||||
|
||||
private int validateJson(Integer index) {
|
||||
return index == null ? 0 : index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建具有合理位置的节点数据
|
||||
*
|
||||
* @param elements
|
||||
* @param shapeRowCount
|
||||
* @return
|
||||
*/
|
||||
private JSONArray getMethodElementsJSONArray(JSONArray elements, int shapeRowCount) {
|
||||
JSONArray result = new JSONArray();
|
||||
int zindex = 0;
|
||||
int initX = 0;
|
||||
int initY = 0;
|
||||
int pageEdge = 100;
|
||||
int count = 0;
|
||||
initX += pageEdge;
|
||||
initY += pageEdge;
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
JSONObject shape = elements.getJSONObject(i);
|
||||
count++;
|
||||
if (count % (shapeRowCount + 1) == 0) {
|
||||
count = 1;
|
||||
initY += 130;
|
||||
// 换行
|
||||
initX = 0;
|
||||
initX = pageEdge + initX;
|
||||
}
|
||||
zindex++;
|
||||
if (shape.containsKey("dataAttributes")) {
|
||||
JSONArray dataAttributes = JSONArray.parseArray(shape.getString("dataAttributes"));
|
||||
for (int index = 0; index < dataAttributes.size(); index++) {
|
||||
dataAttributes.getJSONObject(index).put("id", UUIDGener.getObjectId());
|
||||
}
|
||||
shape.put("dataAttributes", dataAttributes);
|
||||
}
|
||||
int totalWidth = 240;// 每个节点总宽度,空白+节点+空白
|
||||
int totalHeight = 200;// 每个节点总高度,空白+节点+空白
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = validateJson(shape.getJSONObject("props").getInteger("w"));
|
||||
int h = validateJson(shape.getJSONObject("props").getInteger("h"));
|
||||
int leftBlankWidth = (totalWidth - w) / 2;
|
||||
int topBlankHeight = (totalHeight - h) / 2;
|
||||
x = initX + leftBlankWidth;
|
||||
initX = x + w + leftBlankWidth;
|
||||
y = initY + topBlankHeight;
|
||||
|
||||
JSONObject props = shape.getJSONObject("props");
|
||||
props.put("x", x);
|
||||
props.put("y", y);
|
||||
props.put("zindex", zindex);
|
||||
shape.put("props", props);
|
||||
result.add(shape);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建具有合理位置的节点数据
|
||||
*
|
||||
* @param elements
|
||||
* @param shapeRowCount
|
||||
* @return
|
||||
*/
|
||||
private JSONArray getMethodElementsJSONArray(JSONArray elements, int shapeRowCount, int maxZIndex, int initY) {
|
||||
JSONArray result = new JSONArray();
|
||||
int zindex = maxZIndex;
|
||||
int initX = 0;
|
||||
int pageEdge = 100;
|
||||
int count = 0;
|
||||
initX += pageEdge;
|
||||
initY += pageEdge;
|
||||
if (maxZIndex > 0) {// 在已有图的基础上增加的形状,缩小默认的纵轴距离高度
|
||||
initY = initY - pageEdge;
|
||||
}
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
JSONObject shape = elements.getJSONObject(i);
|
||||
count++;
|
||||
if (count % (shapeRowCount+1) == 0) {
|
||||
count = 1;
|
||||
initY += 90;
|
||||
// 换行
|
||||
initX = 0;
|
||||
initX = pageEdge + initX;
|
||||
}
|
||||
zindex++;
|
||||
if (shape.containsKey("dataAttributes")) {
|
||||
JSONArray dataAttributes = JSONArray.parseArray(shape.getString("dataAttributes"));
|
||||
for (int index = 0; index < dataAttributes.size(); index++) {
|
||||
dataAttributes.getJSONObject(index).put("id", UUIDGener.getObjectId());
|
||||
}
|
||||
shape.put("dataAttributes", dataAttributes);
|
||||
}
|
||||
int totalWidth = 160;// 每个节点总宽度,空白+节点+空白
|
||||
int totalHeight = 200;// 每个节点总高度,空白+节点+空白
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = validateJson(shape.getJSONObject("props").getInteger("w"));
|
||||
int h = validateJson(shape.getJSONObject("props").getInteger("h"));
|
||||
int leftBlankWidth = (totalWidth - w)/2;
|
||||
int topBlankHeight = (totalHeight - h)/2;
|
||||
x = initX + leftBlankWidth;
|
||||
initX = x + w + leftBlankWidth;
|
||||
y = initY + topBlankHeight;
|
||||
// y = pageEdge + initY;
|
||||
// if (y < 0) {
|
||||
// y = 100;
|
||||
// }
|
||||
JSONObject props = shape.getJSONObject("props");
|
||||
props.put("x", x);
|
||||
props.put("y", y);
|
||||
props.put("zindex", zindex);
|
||||
shape.put("props", props);
|
||||
result.add(shape);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取形状的最大层级zindex
|
||||
* @param elements
|
||||
* @return
|
||||
*/
|
||||
private int getMaxPropsZIndex(JSONObject elements) {
|
||||
int max = 0;
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
JSONObject props = shape.getJSONObject("props");
|
||||
int zindex = props.getIntValue("zindex");
|
||||
max = max > zindex ? max : zindex;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
/**
|
||||
* 获取已有形状的最大纵向高度
|
||||
* @param elements
|
||||
* @return
|
||||
*/
|
||||
private int getMaxPositionY(JSONObject elements) {
|
||||
int max = 0;
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
String shapeName = shape.getString("name");
|
||||
if(!"linker".equals(shapeName)) {
|
||||
JSONObject props = shape.getJSONObject("props");
|
||||
int y = props.getIntValue("y") + props.getIntValue("h");
|
||||
max = max > y ? max : y;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -158,6 +158,7 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
for (CoeWorkSpaceModel coeWorkSpaceModel : list) {
|
||||
html.append("<option value='" + coeWorkSpaceModel.getUUId() + "'>").append(coeWorkSpaceModel.getWsName()).append("</option>");
|
||||
}
|
||||
|
||||
return html.toString();
|
||||
}
|
||||
|
||||
@ -8709,8 +8710,9 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
|
||||
}
|
||||
|
||||
//复制文件属性
|
||||
updateFileProperty(uuid,model.getId());
|
||||
|
||||
// 保存文件属性
|
||||
PALRepositoryAPIManager.getInstance().updateRepositoryProperty(model.getId());
|
||||
|
||||
shapes.add(shape);
|
||||
JSONArray newShapes = this.getMethodElementsJSONArray(shapes, 1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user