|
@@ -25,7 +25,6 @@ import org.springframework.util.CollectionUtils;
|
|
import java.io.Serializable;
|
|
import java.io.Serializable;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 全局监听
|
|
* @Description: 全局监听
|
|
@@ -61,33 +60,35 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
if (activitiEntityEvent.getEntity() instanceof ResourceEntity) {
|
|
if (activitiEntityEvent.getEntity() instanceof ResourceEntity) {
|
|
ResourceEntity resourceEntity = (ResourceEntity) activitiEntityEvent.getEntity();
|
|
ResourceEntity resourceEntity = (ResourceEntity) activitiEntityEvent.getEntity();
|
|
log.info("ENTITY_CREATED,id:{},name:{},deploymentId:{},persistentState:{}", resourceEntity.getId(), resourceEntity.getName(), resourceEntity.getDeploymentId(), resourceEntity.getPersistentState());
|
|
log.info("ENTITY_CREATED,id:{},name:{},deploymentId:{},persistentState:{}", resourceEntity.getId(), resourceEntity.getName(), resourceEntity.getDeploymentId(), resourceEntity.getPersistentState());
|
|
|
|
+ String xml = new String(resourceEntity.getBytes(), StandardCharsets.UTF_8);
|
|
if (resourceEntity.getName().endsWith(SystemConstant.BPMN_PREFIX)) {
|
|
if (resourceEntity.getName().endsWith(SystemConstant.BPMN_PREFIX)) {
|
|
- String xml = new String(resourceEntity.getBytes(), StandardCharsets.UTF_8);
|
|
|
|
// log.info("ENTITY_CREATED,xml:{}", xml);
|
|
// log.info("ENTITY_CREATED,xml:{}", xml);
|
|
try {
|
|
try {
|
|
Document doc = DocumentHelper.parseText(xml);
|
|
Document doc = DocumentHelper.parseText(xml);
|
|
Element rootElement = doc.getRootElement();
|
|
Element rootElement = doc.getRootElement();
|
|
// 通过element对象的elementIterator方法获取迭代器
|
|
// 通过element对象的elementIterator方法获取迭代器
|
|
- AtomicInteger atomicInteger = new AtomicInteger(1);
|
|
|
|
Iterator iterator = rootElement.elementIterator();
|
|
Iterator iterator = rootElement.elementIterator();
|
|
Map<String, FlowTaskResult> setupMap = new LinkedHashMap<>();//流程审批步骤map
|
|
Map<String, FlowTaskResult> setupMap = new LinkedHashMap<>();//流程审批步骤map
|
|
|
|
+ TFCustomTypeEnum customTypeEnum = null;
|
|
while (iterator.hasNext()) {
|
|
while (iterator.hasNext()) {
|
|
Element element = (Element) iterator.next();
|
|
Element element = (Element) iterator.next();
|
|
List<Attribute> attributes = element.attributes();
|
|
List<Attribute> attributes = element.attributes();
|
|
-// for (Attribute attr : attributes) {
|
|
|
|
|
|
+ for (Attribute attr : attributes) {
|
|
// log.info("属性:{},---值:{}", attr.getName(), attr.getValue());
|
|
// log.info("属性:{},---值:{}", attr.getName(), attr.getValue());
|
|
-// }
|
|
|
|
|
|
+ if (Objects.equals(attr.getName(), SystemConstant.ID_FLOW) && Objects.equals(attr.getValue(), TFCustomTypeEnum.OFFICE_SOP_FLOW.name())) {
|
|
|
|
+ customTypeEnum = TFCustomTypeEnum.valueOf(attr.getValue());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
Iterator itt = element.elementIterator();
|
|
Iterator itt = element.elementIterator();
|
|
while (itt.hasNext()) {
|
|
while (itt.hasNext()) {
|
|
FlowTaskResult flowTaskResult = new FlowTaskResult();
|
|
FlowTaskResult flowTaskResult = new FlowTaskResult();
|
|
Element node = (Element) itt.next();
|
|
Element node = (Element) itt.next();
|
|
attributes = node.attributes();
|
|
attributes = node.attributes();
|
|
// log.info("节点:{},---值:{}", node.getName(), node.getStringValue());
|
|
// log.info("节点:{},---值:{}", node.getName(), node.getStringValue());
|
|
- if (Objects.equals(node.getName(), SystemConstant.START_EVENT) || Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
|
|
|
|
|
|
+ if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
|
|
if (Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
|
|
if (Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
|
|
- flowTaskResult.setSetup(0);
|
|
|
|
- } else {
|
|
|
|
- flowTaskResult.setSetup(atomicInteger.getAndIncrement());
|
|
|
|
|
|
+ flowTaskResult.setSetup(SystemConstant.END_TEMP_ID);
|
|
}
|
|
}
|
|
for (Attribute attr : attributes) {
|
|
for (Attribute attr : attributes) {
|
|
// log.info("节点属性:{},---节点值:{}", attr.getName(), attr.getValue());
|
|
// log.info("节点属性:{},---节点值:{}", attr.getName(), attr.getValue());
|
|
@@ -98,6 +99,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
flowTaskResult.setTaskName(attr.getValue());
|
|
flowTaskResult.setTaskName(attr.getValue());
|
|
} else if (Objects.equals(attr.getName(), SystemConstant.FORM_KEY) && SystemConstant.FLOW_MAP.containsKey(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + attr.getValue())) {
|
|
} else if (Objects.equals(attr.getName(), SystemConstant.FORM_KEY) && SystemConstant.FLOW_MAP.containsKey(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + attr.getValue())) {
|
|
flowTaskResult.setFormKey(attr.getValue());
|
|
flowTaskResult.setFormKey(attr.getValue());
|
|
|
|
+ flowTaskResult.setSetup(Integer.valueOf(attr.getValue().substring(attr.getValue().indexOf(".") - 1, attr.getValue().indexOf("."))));
|
|
List<String> list = SystemConstant.FLOW_MAP.get(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + attr.getValue());
|
|
List<String> list = SystemConstant.FLOW_MAP.get(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + attr.getValue());
|
|
String data = list.get(list.size() - 1);
|
|
String data = list.get(list.size() - 1);
|
|
List<FlowFormWidgetResult> listData = JSONArray.parseArray(data, FlowFormWidgetResult.class);
|
|
List<FlowFormWidgetResult> listData = JSONArray.parseArray(data, FlowFormWidgetResult.class);
|
|
@@ -117,14 +119,38 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ List<Map.Entry<String, FlowTaskResult>> entryList = new ArrayList<Map.Entry<String, FlowTaskResult>>(setupMap.entrySet());
|
|
|
|
+ //比较器
|
|
|
|
+ Collections.sort(entryList, new Comparator<Map.Entry<String, FlowTaskResult>>() {
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(Map.Entry<String, FlowTaskResult> o1, Map.Entry<String, FlowTaskResult> o2) {
|
|
|
|
+ if (o2.getValue().getSetup() < o1.getValue().getSetup()) {
|
|
|
|
+ return 1;
|
|
|
|
+ } else if (o2.getValue().getSetup() > o1.getValue().getSetup()) {
|
|
|
|
+ return -1;
|
|
|
|
+ } else {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ entryList.get(entryList.size() - 1).getValue().setSetup(0);
|
|
|
|
+ setupMap.clear();
|
|
|
|
+ Iterator<Map.Entry<String, FlowTaskResult>> iter = entryList.iterator();
|
|
|
|
+ Map.Entry<String, FlowTaskResult> tmpEntry = null;
|
|
|
|
+ while (iter.hasNext()) {
|
|
|
|
+ tmpEntry = iter.next();
|
|
|
|
+ setupMap.put(tmpEntry.getKey(), tmpEntry.getValue());
|
|
|
|
+ }
|
|
FlowResult flowResult = new FlowResult(resourceEntity.getDeploymentId(), resourceEntity.getName(), setupMap);
|
|
FlowResult flowResult = new FlowResult(resourceEntity.getDeploymentId(), resourceEntity.getName(), setupMap);
|
|
log.info("flowResult:{}", JacksonUtil.parseJson(flowResult));
|
|
log.info("flowResult:{}", JacksonUtil.parseJson(flowResult));
|
|
TFCustomFlowService tfCustomFlowService = SpringContextHolder.getBean(TFCustomFlowService.class);
|
|
TFCustomFlowService tfCustomFlowService = SpringContextHolder.getBean(TFCustomFlowService.class);
|
|
- TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, flowResult.getFlowName(), TFCustomTypeEnum.OFFICE_SOP_FLOW);
|
|
|
|
- TFCustomFlow tfCustomFlow = new TFCustomFlow(null, flowResult.getFlowName(), TFCustomTypeEnum.OFFICE_SOP_FLOW, flowResult.getDeploymentId(), TFCustomModelTypeEnum.USER_FIXED);
|
|
|
|
|
|
+ TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, flowResult.getFlowName(), customTypeEnum);
|
|
|
|
+ TFCustomFlow tfCustomFlow = new TFCustomFlow(null, flowResult.getFlowName(), customTypeEnum, flowResult.getDeploymentId(), TFCustomModelTypeEnum.USER_FIXED);
|
|
flowResult.setId(tfCustomFlow.getId());
|
|
flowResult.setId(tfCustomFlow.getId());
|
|
if (Objects.nonNull(maxTfCustomFlow)) {
|
|
if (Objects.nonNull(maxTfCustomFlow)) {
|
|
tfCustomFlow.setVersion(maxTfCustomFlow.getVersion() + 1);
|
|
tfCustomFlow.setVersion(maxTfCustomFlow.getVersion() + 1);
|
|
|
|
+ } else {
|
|
|
|
+ tfCustomFlow.setVersion(1);
|
|
}
|
|
}
|
|
flowResult.setVersion(tfCustomFlow.getVersion());
|
|
flowResult.setVersion(tfCustomFlow.getVersion());
|
|
tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
|
|
tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
|
|
@@ -133,9 +159,8 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- String data = new String(resourceEntity.getBytes(), StandardCharsets.UTF_8);
|
|
|
|
// log.info("ENTITY_CREATED,data:{}", data);
|
|
// log.info("ENTITY_CREATED,data:{}", data);
|
|
- SystemConstant.FLOW_MAP.add(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + resourceEntity.getName(), data);
|
|
|
|
|
|
+ SystemConstant.FLOW_MAP.add(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + resourceEntity.getName(), xml);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|