组织同步代码调整
This commit is contained in:
parent
5f335f3424
commit
89d4e0e600
@ -1,10 +1,14 @@
|
|||||||
package com.actionsoft.apps.coe.pal.pal.repository.job;
|
package com.actionsoft.apps.coe.pal.pal.repository.job;
|
||||||
|
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
|
||||||
|
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.CoeProcessLevelDaoFacotory;
|
||||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
|
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
|
||||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
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.model.BaseModel;
|
||||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
|
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.model.impl.PALRepositoryModelImpl;
|
||||||
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
|
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
|
||||||
|
|
||||||
@ -15,6 +19,8 @@ import com.actionsoft.bpms.schedule.IJob;
|
|||||||
import com.actionsoft.bpms.util.DBSql;
|
import com.actionsoft.bpms.util.DBSql;
|
||||||
import com.actionsoft.bpms.util.UUIDGener;
|
import com.actionsoft.bpms.util.UUIDGener;
|
||||||
|
|
||||||
|
import com.actionsoft.sdk.local.SDK;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import jodd.util.StringUtil;
|
import jodd.util.StringUtil;
|
||||||
|
|
||||||
@ -39,22 +45,35 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
static int orgindex = 0;
|
static int orgindex = 0;
|
||||||
static String parentModelId = "";
|
static String parentModelId = "";
|
||||||
|
|
||||||
|
static String wsId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||||
|
|
||||||
|
|
||||||
|
String wsIdParams = SDK.getJobAPI().getJobParameter(jobExecutionContext);
|
||||||
|
wsId=wsIdParams;
|
||||||
|
|
||||||
|
|
||||||
//先执行新建操作产生plid
|
//先执行新建操作产生plid
|
||||||
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
|
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
|
||||||
|
String parentId="process";
|
||||||
|
int orderIndex = getChildrenMaxOrderIndexByPidAndWsId(parentId, wsId) + 1;
|
||||||
|
|
||||||
String plRid1 = UUIDGener.getUUID();
|
String plRid1 = UUIDGener.getUUID();
|
||||||
String id1 = UUIDGener.getUUID();
|
String id1 = UUIDGener.getUUID();
|
||||||
|
|
||||||
Connection open = DBSql.open();
|
|
||||||
orgdepartmentList = DBSql.getMaps(open,"select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID,ORDERINDEX from ORGDEPARTMENT ");
|
|
||||||
|
|
||||||
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
PALRepositoryModelImpl model = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, "6f4e292c-1b90-4dd2-8c20-7da159cb20a5", "内蒙古伊利实业集团股份有限公司",
|
String modeldefaultId=Createfolder(orderIndex);
|
||||||
"", 1, "org", "org", true, 1,
|
|
||||||
|
|
||||||
|
Connection open = DBSql.open();
|
||||||
|
orgdepartmentList = DBSql.getMaps(open,"select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID,ORDERINDEX from ORGDEPARTMENT");
|
||||||
|
|
||||||
|
|
||||||
|
PALRepositoryModelImpl model = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, wsId, "内蒙古伊利实业集团股份有限公司",
|
||||||
|
"", 1, modeldefaultId, "org", true, 1,
|
||||||
id1, false, "org.normal", "0", 1, null,
|
id1, false, "org.normal", "0", 1, null,
|
||||||
null, "admin", "admin", nowTime, "0", null,
|
null, "admin", "admin", nowTime, "0", null,
|
||||||
null, null, null, null, null, null, null, 1);
|
null, null, null, null, null, null, null, 1);
|
||||||
@ -68,6 +87,28 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建岗位模型文件夹
|
||||||
|
* @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());
|
||||||
|
|
||||||
|
//新建文件夹
|
||||||
|
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);
|
||||||
|
return modeldefault.getId();
|
||||||
|
}
|
||||||
|
|
||||||
public void createTree() {
|
public void createTree() {
|
||||||
|
|
||||||
for (RowMap oneData : orgdepartmentList) {
|
for (RowMap oneData : orgdepartmentList) {
|
||||||
@ -90,10 +131,10 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
|
|
||||||
|
|
||||||
if (org.getString("PARENTDEPARTMENTID").equals("0")) {
|
if (org.getString("PARENTDEPARTMENTID").equals("0")) {
|
||||||
String sql1 = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE WSID='6f4e292c-1b90-4dd2-8c20-7da159cb20a5' and EXT1='" + org.getString("ID") + "'";
|
String sql1 = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE wsId='"+wsId+"' and EXT1='" + org.getString("ID") + "'";
|
||||||
String parentPalOrgId1 = DBSql.getString(sql1);
|
String parentPalOrgId1 = DBSql.getString(sql1);
|
||||||
if(StringUtil.isEmpty(parentPalOrgId1)){
|
if(StringUtil.isEmpty(parentPalOrgId1)){
|
||||||
PALRepositoryModelImpl model1 = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, "6f4e292c-1b90-4dd2-8c20-7da159cb20a5", org.getString("DEPARTMENTNAME"),
|
PALRepositoryModelImpl model1 = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, wsId, org.getString("DEPARTMENTNAME"),
|
||||||
"", 1, parentModelId, "org", true, 1,
|
"", 1, parentModelId, "org", true, 1,
|
||||||
id1, false, "org.normal", "0", Integer.valueOf(org.getString("ORDERINDEX")), null,
|
id1, false, "org.normal", "0", Integer.valueOf(org.getString("ORDERINDEX")), null,
|
||||||
null, "admin", "admin", nowTime, org.getString("ID"), null,
|
null, "admin", "admin", nowTime, org.getString("ID"), null,
|
||||||
@ -109,7 +150,7 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
|
|
||||||
if(StringUtil.isNotEmpty(parentPalOrgId)){
|
if(StringUtil.isNotEmpty(parentPalOrgId)){
|
||||||
|
|
||||||
PALRepositoryModelImpl model2 = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, "6f4e292c-1b90-4dd2-8c20-7da159cb20a5", org.getString("DEPARTMENTNAME"),
|
PALRepositoryModelImpl model2 = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, wsId, org.getString("DEPARTMENTNAME"),
|
||||||
"", 1, getParentPalOrgId(org), "org", true, 1,
|
"", 1, getParentPalOrgId(org), "org", true, 1,
|
||||||
id1, false, "org.normal", "0", Integer.valueOf(org.getString("ORDERINDEX")), null,
|
id1, false, "org.normal", "0", Integer.valueOf(org.getString("ORDERINDEX")), null,
|
||||||
null, "admin", "admin", nowTime, org.getString("ID"), null,
|
null, "admin", "admin", nowTime, org.getString("ID"), null,
|
||||||
@ -131,7 +172,7 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
|
|
||||||
public String getParentPalOrgId(RowMap org) {
|
public String getParentPalOrgId(RowMap org) {
|
||||||
|
|
||||||
String sql = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE WSID='6f4e292c-1b90-4dd2-8c20-7da159cb20a5' and EXT1='" + org.getString("PARENTDEPARTMENTID") + "'";
|
String sql = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE wsId='"+wsId+"' and EXT1='" + org.getString("PARENTDEPARTMENTID") + "'";
|
||||||
String parentPalOrgId = DBSql.getString(sql);
|
String parentPalOrgId = DBSql.getString(sql);
|
||||||
|
|
||||||
if (parentPalOrgId.equals("0") || parentPalOrgId.equals("") || parentPalOrgId == null) {
|
if (parentPalOrgId.equals("0") || parentPalOrgId.equals("") || parentPalOrgId == null) {
|
||||||
@ -144,7 +185,7 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
|
|
||||||
|
|
||||||
public String getParentPallevel(RowMap org) {
|
public String getParentPallevel(RowMap org) {
|
||||||
String sql = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE WSID='6f4e292c-1b90-4dd2-8c20-7da159cb20a5' and EXT1='" + org.getString("PARENTDEPARTMENTID") + "'";
|
String sql = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE wsId='"+wsId+"' and EXT1='" + org.getString("PARENTDEPARTMENTID") + "'";
|
||||||
String parentPalOrgId = DBSql.getString(sql);
|
String parentPalOrgId = DBSql.getString(sql);
|
||||||
|
|
||||||
if (parentPalOrgId.equals("0") || parentPalOrgId.equals("") || parentPalOrgId == null) {
|
if (parentPalOrgId.equals("0") || parentPalOrgId.equals("") || parentPalOrgId == null) {
|
||||||
@ -188,8 +229,7 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
|
|
||||||
List<RowMap> orgdepartmentList=DBSql.getMaps("select POSITION_NO,POSITION_NAME from ORGUSER WHERE DEPARTMENTID=?",departmentId);
|
List<RowMap> orgdepartmentList=DBSql.getMaps("select POSITION_NO,POSITION_NAME from ORGUSER WHERE DEPARTMENTID=?",departmentId);
|
||||||
|
|
||||||
int zindex = 1;
|
JSONArray shapes = new JSONArray();
|
||||||
|
|
||||||
if(orgdepartmentList.size()>0){
|
if(orgdepartmentList.size()>0){
|
||||||
|
|
||||||
for(int i=0;i<orgdepartmentList.size();i++){
|
for(int i=0;i<orgdepartmentList.size();i++){
|
||||||
@ -200,27 +240,29 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
JSONObject shape1 = ShapeUtil.getProcessShapeDefinitionByName("org.normal", "position");
|
JSONObject shape1 = ShapeUtil.getProcessShapeDefinitionByName("org.normal", "position");
|
||||||
String positionName=orgdepartmentList.get(i).getString("POSITION_NAME");
|
String positionName=orgdepartmentList.get(i).getString("POSITION_NAME");
|
||||||
|
|
||||||
|
|
||||||
if(StringUtil.isNotEmpty(positionName)){
|
if(StringUtil.isNotEmpty(positionName)){
|
||||||
shape1.put("id", shapeId1);
|
|
||||||
|
|
||||||
shape1.put("text",positionName);
|
JSONObject newShape = JSONObject.parseObject(shape1.toString());
|
||||||
|
newShape.put("id", shapeId1);
|
||||||
|
newShape.put("text", positionName);
|
||||||
|
shapes.add(newShape);
|
||||||
|
|
||||||
JSONObject props1 = shape1.getJSONObject("props");// 位置大小
|
|
||||||
|
|
||||||
props1.put("x", 130*zindex);
|
|
||||||
props1.put("y", 277);
|
|
||||||
props1.put("w", 110);
|
|
||||||
props1.put("h", 50);
|
|
||||||
|
|
||||||
props1.put("zindex", zindex++);
|
|
||||||
|
|
||||||
elements.put(shapeId1, shape1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONArray newShapes = this.getMethodElementsJSONArray(shapes, 6);
|
||||||
|
JSONObject newElements = new JSONObject();
|
||||||
|
for (int i = 0; i < newShapes.size(); i++) {
|
||||||
|
JSONObject shapeObj = newShapes.getJSONObject(i);
|
||||||
|
newElements.put(shapeObj.getString("id"), shapeObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
definition.put("elements", newElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 设置画布大小
|
// 设置画布大小
|
||||||
DiagramsUtil.setDiagramHeightWidth(definition, elements);
|
DiagramsUtil.setDiagramHeightWidth(definition, elements);
|
||||||
defineModel.setDefinition(definition.toString());
|
defineModel.setDefinition(definition.toString());
|
||||||
@ -229,8 +271,91 @@ public class SynchronousOrgJob implements IJob {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建具有合理位置的节点数据
|
||||||
|
*
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user