提交 00b63a89 编写于 作者: sq3536's avatar sq3536

dep

上级 602efb45
......@@ -6,7 +6,6 @@ import cn.ibizlab.core.workflow.service.IWFProcessDefinitionService;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.security.AuthenticationUser;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.converter.BpmnXMLConverter;
import org.flowable.bpmn.model.*;
......@@ -19,11 +18,11 @@ import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.DeploymentBuilder;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.DigestUtils;
......@@ -31,9 +30,7 @@ import org.springframework.util.StringUtils;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.*;
import java.sql.Timestamp;
import java.util.*;
......@@ -145,7 +142,7 @@ public class WFCoreService
throw new BadRequestAlertException("未找到对应的工作流配置",entity,businessKey);
processDefinitionKey=definitionKeys.get(0);
}
String processInstanceBusinessKey=system+":"+entity+":srfkey-"+businessKey;
String processInstanceBusinessKey=system+":"+entity+":k-"+businessKey;
Map<String, Object> variables = new LinkedHashMap<>();
variables.put("businessKey",businessKey);
variables.put("activedata",instance.get("activedata"));
......@@ -169,7 +166,7 @@ public class WFCoreService
public List<WFTaskWay> getWFLink(String system,String appname,
String entity, String businessKey,String taskDefinitionKey) {
List<WFTaskWay> taskWays=new ArrayList<>();
String processInstanceBusinessKey=system+":"+entity+":srfkey-"+businessKey;
String processInstanceBusinessKey=system+":"+entity+":k-"+businessKey;
String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId))
return taskWays;
......@@ -187,6 +184,7 @@ public class WFCoreService
WFTaskWay way=new WFTaskWay();
way.setSequenceflowid(sequenceFlow.getId());
way.setSequenceflowname(sequenceFlow.getName());
if(task.getProcessDefinitionId().indexOf(":")>0)
way.setProcessdefinitionkey(task.getProcessDefinitionId().split(":")[0]);
way.setTaskid(task.getId());
way.setProcessinstanceid(task.getProcessInstanceId());
......@@ -201,7 +199,7 @@ public class WFCoreService
public List<WFTaskWay> getTaskLink(String system,String appname, String entity, String businessKey,String taskId) {
List<WFTaskWay> taskWays=new ArrayList<>();
String processInstanceBusinessKey=system+":"+entity+":srfkey-"+businessKey;
String processInstanceBusinessKey=system+":"+entity+":k-"+businessKey;
String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId))
return taskWays;
......@@ -217,6 +215,7 @@ public class WFCoreService
WFTaskWay way=new WFTaskWay();
way.setSequenceflowid(sequenceFlow.getId());
way.setSequenceflowname(sequenceFlow.getName());
if(task.getProcessDefinitionId().indexOf(":")>0)
way.setProcessdefinitionkey(task.getProcessDefinitionId().split(":")[0]);
way.setTaskid(task.getId());
way.setProcessinstanceid(task.getProcessInstanceId());
......@@ -233,7 +232,7 @@ public class WFCoreService
public List<String> getBusinessKeys(String system,String appname, String entity,String processDefinitionKey,String taskDefinitionKey)
{
List<String> businessKeys = new ArrayList<>();
String processInstanceBusinessKeyLike=system+":"+entity+":srfkey-";
String processInstanceBusinessKeyLike=system+":"+entity+":k-";
String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId))
return businessKeys;
......@@ -250,8 +249,8 @@ public class WFCoreService
Object key=task.getProcessVariables().get("businessKey");
if(key!=null) {
String str=key.toString();
if(str.indexOf(":srfkey-")>0)
str=str.split(":srfkey-")[1];
if(str.indexOf(":k-")>0)
str=str.split(":k-")[1];
businessKeys.add(str);
}
}
......@@ -267,7 +266,7 @@ public class WFCoreService
if(StringUtils.isEmpty(taskId)){
taskId=taskWay.getTaskid();
}
String processInstanceBusinessKey=system+":"+entity+":srfkey-"+businessKey;
String processInstanceBusinessKey=system+":"+entity+":k-"+businessKey;
Map<String, Object> variables = new LinkedHashMap<>();
variables.put("businessKey",businessKey);
variables.put("sequenceFlowId",taskWay.getSequenceflowid());
......@@ -286,6 +285,9 @@ public class WFCoreService
return instance;
}
@Value("${ibiz.filePath:/app/file/}")
private String fileRoot;
public synchronized boolean wfdeploy(File bpmnFile)
{
XMLStreamReader reader = null;
......@@ -366,18 +368,77 @@ public class WFCoreService
wfProcessDefinition.setModelenable(1);
wfProcessDefinition.setModelversion(version);
wfProcessDefinition.setDefinitionname(curProcess.getName());
wfProcessDefinition.setBpmnfile("[{\"id\":\""+md5+"\",\"name\":\""+bpmnFile.getName()+"\"}]");
wfProcessDefinition.setMd5check(md5);
iwfProcessDefinitionService.save(wfProcessDefinition);
inputStream=new FileInputStream(bpmnFile);
OutputStream out =null;
InputStream is = null;
XMLStreamReader reader2 = null;
InputStream inputStream2 = null;
String bmpmfileId="";
String fileFullPath ="";
try
{
inputStream2=new FileInputStream(bpmnFile);
reader2 = factory.createXMLStreamReader(inputStream2);
BpmnModel entitymodel=bpmnXMLConverter.convertToBpmnModel(reader2);
entitymodel.getProcesses().get(0).setId(processDefinitionKey);
byte[] bs= bpmnXMLConverter.convertToXML(entitymodel);
bmpmfileId=DigestUtils.md5DigestAsHex(bs);
fileFullPath = this.fileRoot+"ibizutil"+File.separator+bmpmfileId+File.separator+processDefinitionKey+".bpmn20.xml";
is = new ByteArrayInputStream(bs);
File file = new File(fileFullPath);
File parent = new File(file.getParent());
if(!parent.exists())
parent.mkdirs();
out= new FileOutputStream(fileFullPath);
byte[] buff = new byte[1024];
int len = 0;
while((len=is.read(buff))!=-1){
out.write(buff, 0, len);
}
}
catch(Exception ex){}
finally {
try {
if(reader2!=null)
reader2.close();
} catch (Exception e) {
}
try
{
if(is!=null)
is.close();
}catch (Exception exis){}
try
{
if(out!=null)
out.close();
}catch (Exception exis){}
}
inputStream=new FileInputStream(new File(fileFullPath));
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().name(curProcess.getName()).key(processDefinitionKey)
.addInputStream(bpmnFile.getPath(),inputStream);
.addInputStream(fileFullPath,inputStream);
Deployment deployment= deploymentBuilder.deploy();
wfProcessDefinition.setBpmnfile("[{\"id\":\""+bmpmfileId+"\",\"name\":\""+processDefinitionKey+".bpmn20.xml\"}]");
wfProcessDefinition.setMd5check(bmpmfileId);
iwfProcessDefinitionService.save(wfProcessDefinition);
// wfProcessDefinition.setMd5check(md5);
// iwfProcessDefinitionService.update(wfProcessDefinition);
log.warn("部署流程 name:"+curProcess.getName()+" key "+deployment.getKey() + " deploy "+deployment);
}
return true;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册