提交 61de0ad1 编写于 作者: sq3536's avatar sq3536

工作流部署

上级 1e5706f1
......@@ -377,8 +377,6 @@ public class WFCoreService
String processDefinitionKey=system+"-"+booking+"-"+params[1];
WFProcessDefinition old=iwfProcessDefinitionService.get(processDefinitionKey);
if(md5.equals(old.getMd5check()))
continue;
WFProcessDefinition wfProcessDefinition=new WFProcessDefinition();
wfProcessDefinition.setDefinitionkey(processDefinitionKey);
wfProcessDefinition.setDeploykey(processDefinitionKey);
......@@ -402,6 +400,12 @@ public class WFCoreService
entitymodel.getProcesses().get(0).setId(processDefinitionKey);
byte[] bs= bpmnXMLConverter.convertToXML(entitymodel);
bmpmfileId=DigestUtils.md5DigestAsHex(bs);
if(bmpmfileId.equals(old.getMd5check()))
{
log.warn("部署流程没有变化,忽略 name:" + curProcess.getName() + " key " + processDefinitionKey + " deploy " + bmpmfileId);
continue;
}
fileFullPath = this.fileRoot+"ibizutil"+File.separator+bmpmfileId+File.separator+processDefinitionKey+".bpmn20.xml";
is = new ByteArrayInputStream(bs);
File file = new File(fileFullPath);
......
......@@ -20,6 +20,8 @@ import java.util.*;
public class WFModelService
{
@Autowired
private RepositoryService repositoryService;
......@@ -79,11 +81,11 @@ public class WFModelService
return userTasks;
}
public Map<String,Object> getProcessGlobalSetting(String definitionid)
public Map<String,Object> getProcessGlobalSetting(String definitionId)
{
LinkedHashMap<String,Object> setting = new LinkedHashMap();
Process process=repositoryService.getBpmnModel(definitionid).getMainProcess();
for(ExtensionElement field:repositoryService.getBpmnModel(definitionid).getMainProcess().getExtensionElements().get("field")) {
Process process=repositoryService.getBpmnModel(definitionId).getMainProcess();
for(ExtensionElement field:process.getExtensionElements().get("field")) {
if((!StringUtils.isEmpty(field.getAttributes().get("name").get(0).getValue()))&&(!StringUtils.isEmpty(field.getChildElements().get("string").get(0).getElementText())))
setting.put(field.getAttributes().get("name").get(0).getValue(),field.getChildElements().get("string").get(0).getElementText());
}
......
package cn.ibizlab.core.extensions.service.impl;
import cn.ibizlab.core.extensions.service.WFCoreService;
import cn.ibizlab.core.workflow.domain.WFProcessDefinition;
import cn.ibizlab.core.workflow.service.impl.WFProcessDefinitionServiceImpl;
import cn.ibizlab.util.domain.FileItem;
import cn.ibizlab.util.service.FileService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.io.File;
import java.util.List;
@Service
@Primary
public class WFProcessDefinitionServicePublishImpl extends WFProcessDefinitionServiceImpl
{
@Override
public boolean create(WFProcessDefinition et)
{
if(!super.create(et))
return false;
publish(et);
return true;
}
@Override
public boolean update(WFProcessDefinition et)
{
if(!super.update(et))
return false;
publish(et);
return true;
}
@Autowired
private FileService fileService;
@Autowired
@Lazy
private WFCoreService wfCoreService;
public void publish(WFProcessDefinition et)
{
if(StringUtils.isEmpty(et.getBpmnfile()))
return;
String oldMd5="";
if(!StringUtils.isEmpty(et.getMd5check()))
oldMd5=et.getMd5check();
List<FileItem> items= JSONArray.parseArray(et.getBpmnfile(),FileItem.class);
if(items.size()==0)
return;
FileItem item=items.get(items.size()-1);
if(item.getId().equals(oldMd5))
return;
File bpmnFile=fileService.getFile(item.getId());
if(!bpmnFile.exists())
return;
wfCoreService.wfdeploy(bpmnFile);
}
}
package cn.ibizlab.core.workflow.service.impl;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -11,6 +12,11 @@ import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import cn.ibizlab.core.extensions.service.WFCoreService;
import cn.ibizlab.core.workflow.domain.WFProcessDefinition;
import cn.ibizlab.util.domain.FileItem;
import cn.ibizlab.util.service.FileService;
import com.alibaba.fastjson.JSONArray;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -27,9 +33,7 @@ import cn.ibizlab.core.workflow.filter.WFREModelSearchContext;
import cn.ibizlab.core.workflow.service.IWFREModelService;
import cn.ibizlab.util.helper.CachedBeanCopier;
import org.springframework.util.StringUtils;
/**
* 实体[流程模型] 无存储服务对象接口实现
......@@ -67,9 +71,39 @@ public class WFREModelServiceImpl implements IWFREModelService {
@Override
public boolean create(WFREModel et) {
publish(et);
return true;
}
@Autowired
private FileService fileService;
@Autowired
@Lazy
private WFCoreService wfCoreService;
public void publish(WFREModel et)
{
if(StringUtils.isEmpty(et.getBpmnfile()))
return;
List<FileItem> items= JSONArray.parseArray(et.getBpmnfile(),FileItem.class);
if(items.size()==0)
return;
for(FileItem item:items)
{
File bpmnFile=fileService.getFile(item.getId());
if(!bpmnFile.exists())
return;
wfCoreService.wfdeploy(bpmnFile);
}
}
public void createBatch(List<WFREModel> list){
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册