update 导入流程 支持自定义类别
This commit is contained in:
parent
903b289591
commit
8333435770
@ -143,8 +143,8 @@ public class FlwDefinitionController extends BaseController {
|
|||||||
@Log(title = "流程定义", businessType = BusinessType.IMPORT)
|
@Log(title = "流程定义", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/importDef")
|
@PostMapping("/importDef")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public R<Boolean> importDef(MultipartFile file) {
|
public R<Boolean> importDef(MultipartFile file, String category) {
|
||||||
return R.ok(iFlwDefinitionService.importXml(file));
|
return R.ok(iFlwDefinitionService.importXml(file, category));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,7 @@ public interface IFlwDefinitionService {
|
|||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
boolean importXml(MultipartFile file);
|
boolean importXml(MultipartFile file, String category);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除流程定义
|
* 删除流程定义
|
||||||
|
@ -15,9 +15,15 @@ import org.dom4j.io.XMLWriter;
|
|||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.warm.flow.core.dto.FlowCombine;
|
||||||
|
import org.dromara.warm.flow.core.entity.Definition;
|
||||||
|
import org.dromara.warm.flow.core.entity.Node;
|
||||||
|
import org.dromara.warm.flow.core.entity.Skip;
|
||||||
import org.dromara.warm.flow.core.service.DefService;
|
import org.dromara.warm.flow.core.service.DefService;
|
||||||
|
import org.dromara.warm.flow.core.utils.FlowConfigUtil;
|
||||||
import org.dromara.warm.flow.orm.entity.FlowDefinition;
|
import org.dromara.warm.flow.orm.entity.FlowDefinition;
|
||||||
import org.dromara.warm.flow.orm.entity.FlowHisTask;
|
import org.dromara.warm.flow.orm.entity.FlowHisTask;
|
||||||
import org.dromara.warm.flow.orm.mapper.FlowDefinitionMapper;
|
import org.dromara.warm.flow.orm.mapper.FlowDefinitionMapper;
|
||||||
@ -85,9 +91,17 @@ public class FlwDefinitionServiceImpl implements IFlwDefinitionService {
|
|||||||
* @param file 文件
|
* @param file 文件
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean importXml(MultipartFile file) {
|
public boolean importXml(MultipartFile file, String category) {
|
||||||
try {
|
try {
|
||||||
defService.importXml(file.getInputStream());
|
FlowCombine combine = FlowConfigUtil.readConfig(file.getInputStream());
|
||||||
|
// 流程定义
|
||||||
|
Definition definition = combine.getDefinition();
|
||||||
|
definition.setCategory(category);
|
||||||
|
// 所有的流程节点
|
||||||
|
List<Node> allNodes = combine.getAllNodes();
|
||||||
|
// 所有的流程连线
|
||||||
|
List<Skip> allSkips = combine.getAllSkips();
|
||||||
|
ReflectUtils.invoke(defService, "insertFlow", definition, allNodes, allSkips);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导入流程定义错误: {}", e.getMessage(), e);
|
log.error("导入流程定义错误: {}", e.getMessage(), e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user