活动清单修改为定时任务推送
This commit is contained in:
parent
3089023fd8
commit
2a9f325f74
@ -0,0 +1,151 @@
|
||||
package com.actionsoft.apps.coe.pal.datamigration;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
|
||||
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.model.PALRepositoryModel;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 这个定时任务是为了解决管理员加载全部的模型清单
|
||||
*/
|
||||
public class HdqdJob implements IJob {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
UserContext userContext = UserContext.fromUID("admin");
|
||||
List<PALRepositoryModel> palRepositoryModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getAllCoeProcessLevelByWsId("7d3ca852-a0bd-42e6-80b1-3dcea6f55083");
|
||||
for (PALRepositoryModel palRepositoryModel : palRepositoryModels) {
|
||||
String publishFileId = palRepositoryModel.getId();
|
||||
String fileName = palRepositoryModel.getName();
|
||||
String file_type = palRepositoryModel.getMethodId();
|
||||
System.out.println("file_type>>>>>>>>" + file_type);
|
||||
if (file_type.equals("process.epc") || file_type.equals("process.flowchart")) {
|
||||
|
||||
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(publishFileId, 0);
|
||||
if (defineModel == null) {
|
||||
continue;
|
||||
}
|
||||
String definition = defineModel.getDefinition().trim();
|
||||
JSONObject definitionJo = JSONObject.parseObject(definition);
|
||||
JSONObject elements = (JSONObject) definitionJo.get("elements");
|
||||
ArrayList<BO> bos = new ArrayList<>();
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
//流程架构等级
|
||||
List<RowMap> processLevel = DBSql.getMaps(String.format("select PROPERTYID,PROPERTYVALUE from APP_ACT_COE_PAL_PROP where PROPERTYID in ('Process_Architecture_L1','Process_Architecture_L2','Process_Architecture_L3','Process_Architecture_L4') AND PLID='%s' ORDER BY PROPERTYID", publishFileId));
|
||||
elements.forEach((k, v) -> {
|
||||
setShapeAttr(bos, publishFileId, (JSONObject) v, fileName, processLevel);
|
||||
});
|
||||
if (bos.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
ProcessInstance processInst = SDK.getProcessAPI().createBOProcessInstance("obj_f188537a313e4c6a9bb44eb65f2a0ecd", userContext.getUID(), "流程清单");
|
||||
List<RowMap> maps = DBSql.getMaps("select distinct BINDID from BO_ACT_PAL_PROCESS_MANIFEST where MODELID = '" + publishFileId + "'");
|
||||
if (maps != null) {
|
||||
for (RowMap rowMap:maps){
|
||||
SDK.getBOAPI().removeByBindId("BO_ACT_PAL_PROCESS_MANIFEST",rowMap.getString("BINDID"));
|
||||
}
|
||||
SDK.getBOAPI().create("BO_ACT_PAL_PROCESS_MANIFEST", bos, processInst, userContext);
|
||||
} else {
|
||||
SDK.getBOAPI().create("BO_ACT_PAL_PROCESS_MANIFEST", bos, processInst, userContext);
|
||||
}
|
||||
}else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将流程模型的形状属性封装到bo集合
|
||||
*
|
||||
* @param bos bos
|
||||
* @param publishFileId 发布文件id
|
||||
* @param shape 形状
|
||||
* @param fileName 文件名称
|
||||
*/
|
||||
private void setShapeAttr(ArrayList<BO> bos, String publishFileId, JSONObject shape, String fileName, List<RowMap> processLevel) {
|
||||
//只需要活动节点
|
||||
if (shape.containsKey("category") && !shape.getString("title").equals("开始/结束")) {
|
||||
BO bo = new BO();
|
||||
bo.set("MODELNAME", fileName);
|
||||
bo.set("MODELID", publishFileId);
|
||||
bo.set("MODELTYPE", shape.getString("category"));
|
||||
bo.set("SHAPETYPE", shape.getString("title"));
|
||||
bo.set("SHAPENAME", shape.getString("text"));
|
||||
//插入流程架构等级
|
||||
for (int i = 0; i < processLevel.size(); i++) {
|
||||
bo.set("L" + (i + 1), processLevel.get(i).getString("PROPERTYVALUE"));
|
||||
}
|
||||
if (shape.containsKey("dataAttributes")) {
|
||||
JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
|
||||
if (dataAttributes.size() > 0) {
|
||||
JSONObject attributesJson = dataAttributes.getJSONObject(dataAttributes.size() - 1);
|
||||
if (attributesJson.containsKey("attributesJsonArray")) {
|
||||
//形状的属性
|
||||
JSONArray attributesJsonArray = attributesJson.getJSONArray("attributesJsonArray");
|
||||
attributesJsonArray.stream()
|
||||
.filter(a -> a != null && !"null".equals(a.toString()) && ((JSONObject) a).size() > 0)
|
||||
.forEach(a -> {
|
||||
JSONObject shapeAttr = (JSONObject) a;
|
||||
if (shapeAttr.get("key").equals("activity_number")) {
|
||||
bo.set("SHAPENUMBER", shapeAttr.getString("value"));
|
||||
}
|
||||
if (shapeAttr.get("key").equals("output")) {
|
||||
bo.set("EXTOUTPUT", shapeAttr.getString("value"));
|
||||
}
|
||||
if (shapeAttr.get("key").equals("input")) {
|
||||
bo.set("EXTINPUT", shapeAttr.getString("value"));
|
||||
}
|
||||
if (shapeAttr.get("key").equals("activity_description")) {
|
||||
bo.set("EXTDESC", shapeAttr.getString("value"));
|
||||
}
|
||||
if (shapeAttr.get("key").equals("post")) {
|
||||
String post = "";
|
||||
List<RowMap> text = DBSql.getMaps("select * from APP_ACT_COE_PAL_SHAPE_RLAT where FILEID = '" + publishFileId + "' and attrid = 'post' and SHAPEID = '" + shape.getString("id") + "'");
|
||||
for (RowMap rowmaps:
|
||||
text) {
|
||||
post+=rowmaps.getString("RELATIONSHAPETEXT")+",";
|
||||
}
|
||||
bo.set("POST_NAME",post );
|
||||
}
|
||||
if (shapeAttr.get("key").equals("role")) {
|
||||
String role = "";
|
||||
List<RowMap> text = DBSql.getMaps("select * from APP_ACT_COE_PAL_SHAPE_RLAT where FILEID = '" + publishFileId + "' and attrid = 'role' and SHAPEID = '" + shape.getString("id") + "'");
|
||||
for (RowMap rowmaps:
|
||||
text) {
|
||||
role+=rowmaps.getString("RELATIONSHAPETEXT")+",";
|
||||
}
|
||||
bo.set("ROLE_NAME", role);
|
||||
}
|
||||
if (shapeAttr.get("key").equals("information_systems")){
|
||||
String role = "";
|
||||
List<RowMap> text = DBSql.getMaps("select * from APP_ACT_COE_PAL_SHAPE_RLAT where FILEID = '" + publishFileId + "' and attrid = 'information_systems' and SHAPEID = '" + shape.getString("id") + "'");
|
||||
for (RowMap rowmaps:
|
||||
text) {
|
||||
role+=rowmaps.getString("RELATIONSHAPETEXT")+",";
|
||||
}
|
||||
bo.set("IT_SYSTEM", role);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
bos.add(bo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user