parent
a0ce94a351
commit
62a12b37c1
|
@ -31,4 +31,8 @@ public class BaseChainController {
|
|||
return baseChainService.executeChain(chainName);
|
||||
}
|
||||
|
||||
@GetMapping("/getChainList")
|
||||
public CommonResult getChainList() {
|
||||
return baseChainService.getChainList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,7 @@ import com.example.liteflow.mysql.model.CommonResult;
|
|||
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
||||
import com.example.liteflow.mysql.service.BaseNodeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
@ -28,4 +25,9 @@ public class BaseNodeController {
|
|||
return baseNodeService.createNode(createNodeFrom);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getNodeList")
|
||||
public CommonResult getNodeList() {
|
||||
return baseNodeService.getNodeList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,9 @@ package com.example.liteflow.mysql.controller;
|
|||
|
||||
import com.example.liteflow.mysql.model.CommonResult;
|
||||
import com.example.liteflow.mysql.model.baseTemplate.CreateTemplateFrom;
|
||||
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
||||
import com.example.liteflow.mysql.service.BaseNodeService;
|
||||
import com.example.liteflow.mysql.service.BaseTemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
@ -30,4 +25,8 @@ public class BaseTemplateController {
|
|||
return baseTemplateService.createTemplate(createTemplateFrom);
|
||||
}
|
||||
|
||||
@GetMapping("/getTemplateList")
|
||||
public CommonResult getTemplateList() {
|
||||
return baseTemplateService.getTemplateList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,14 +16,12 @@ import java.time.LocalDateTime;
|
|||
public class MybatisHandler implements MetaObjectHandler {
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
log.info("start insert .. ");
|
||||
this.setFieldValByName("creatorTime", LocalDateTime.now(), metaObject);
|
||||
// this.setFieldValByName("lastModifyTime", LocalDateTime.now(), metaObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
log.info("start update .. ");
|
||||
this.setFieldValByName("lastModifyTime", LocalDateTime.now(), metaObject);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.example.liteflow.mysql.model.baseChain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
* @date: 2022年12月15日 09:12
|
||||
*/
|
||||
@Data
|
||||
public class BaseChainVO {
|
||||
private String id;
|
||||
|
||||
private String templateId;
|
||||
|
||||
private String templateName;
|
||||
|
||||
private String chainName;
|
||||
|
||||
private String elData;
|
||||
|
||||
private Integer enableMark = 1;
|
||||
|
||||
private LocalDateTime creatorTime;
|
||||
|
||||
private LocalDateTime lastModifyTime;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.example.liteflow.mysql.model.baseTemplate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
* @date: 2022年12月15日 09:28
|
||||
*/
|
||||
@Data
|
||||
public class BaseTemplateVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String templateName;
|
||||
|
||||
/**
|
||||
* 有效状态:1-有效;0无效
|
||||
*/
|
||||
private Integer enableMark = 1;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime creatorTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime lastModifyTime;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.example.liteflow.mysql.model.node;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
* @date: 2022年12月15日 09:23
|
||||
*/
|
||||
@Data
|
||||
public class BaseNodeVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 节点在规则引擎中的Id
|
||||
*/
|
||||
private String nodeId;
|
||||
/**
|
||||
* 所属模板id
|
||||
*/
|
||||
private String templateId;
|
||||
/**
|
||||
* 所属模板名称
|
||||
*/
|
||||
private String templateName;
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 节点对应类名
|
||||
*/
|
||||
private String nodeClass;
|
||||
|
||||
/**
|
||||
* 节点类型
|
||||
*/
|
||||
private String nodeType;
|
||||
|
||||
/**
|
||||
* 节点规则
|
||||
*/
|
||||
private String nodeRole;
|
||||
/**
|
||||
* 节点对应输出节点id
|
||||
*/
|
||||
private String nodeContentId;
|
||||
/**
|
||||
* 节点内容
|
||||
*/
|
||||
private String nodeContent;
|
||||
|
||||
/**
|
||||
* 有效状态:1-有效;0无效
|
||||
*/
|
||||
private Integer enableMark = 1;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime creatorTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime lastModifyTime;
|
||||
}
|
|
@ -20,4 +20,6 @@ public interface BaseChainService extends IService<BaseChainEntity> {
|
|||
void initMainChain();
|
||||
|
||||
CommonResult executeChain(String chainName);
|
||||
|
||||
CommonResult getChainList();
|
||||
}
|
||||
|
|
|
@ -18,4 +18,6 @@ public interface BaseNodeService extends IService<BaseNodeEntity> {
|
|||
CommonResult updateNode(UpdateNodeFrom updateNodeFrom);
|
||||
|
||||
BaseNodeEntity getByNodeId(String nodeId);
|
||||
|
||||
CommonResult getNodeList();
|
||||
}
|
||||
|
|
|
@ -20,4 +20,6 @@ public interface BaseTemplateService extends IService<BaseTemplateEntity> {
|
|||
boolean updateTemplate(UpdateTemplateFrom updateTemplateFrom);
|
||||
|
||||
List<BaseTemplateEntity> getNotExistsChain();
|
||||
|
||||
CommonResult getTemplateList();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.example.liteflow.mysql.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
|
@ -14,6 +16,7 @@ import com.example.liteflow.mysql.enums.NodeEnum;
|
|||
import com.example.liteflow.mysql.mapper.BaseChainMapper;
|
||||
import com.example.liteflow.mysql.model.BaseCenter;
|
||||
import com.example.liteflow.mysql.model.CommonResult;
|
||||
import com.example.liteflow.mysql.model.baseChain.BaseChainVO;
|
||||
import com.example.liteflow.mysql.service.BaseChainService;
|
||||
import com.example.liteflow.mysql.service.BaseNodeService;
|
||||
import com.example.liteflow.mysql.service.BaseTemplateService;
|
||||
|
@ -22,6 +25,7 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
|
|||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.element.Chain;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -138,6 +142,7 @@ public class BaseChainServiceImpl extends ServiceImpl<BaseChainMapper, BaseChain
|
|||
}
|
||||
}
|
||||
}
|
||||
this.initMainChain();
|
||||
return CommonResult.success("生成链路成功", this.list());
|
||||
}
|
||||
|
||||
|
@ -156,8 +161,11 @@ public class BaseChainServiceImpl extends ServiceImpl<BaseChainMapper, BaseChain
|
|||
nodeQueryWrapper.eq(BaseNodeEntity::getTemplateId, templateId)
|
||||
.eq(BaseNodeEntity::getEnableMark, EnableMarkEnum.Enable.getValue());
|
||||
List<BaseNodeEntity> nodeList = baseNodeService.list(nodeQueryWrapper);
|
||||
templateAndNodeMap.put(template, nodeList);
|
||||
if (CollUtil.isNotEmpty(nodeList)) {
|
||||
templateAndNodeMap.put(template, nodeList);
|
||||
}
|
||||
});
|
||||
log.info("templateAndNodeMap size = {}", templateAndNodeMap.size());
|
||||
for (Map.Entry<BaseTemplateEntity, List<BaseNodeEntity>> entry : templateAndNodeMap.entrySet()) {
|
||||
BaseTemplateEntity templateEntity = entry.getKey();
|
||||
String templateName = templateEntity.getTemplateName();
|
||||
|
@ -294,6 +302,10 @@ public class BaseChainServiceImpl extends ServiceImpl<BaseChainMapper, BaseChain
|
|||
private List<BaseCenter> generateCostCenterTestData() {
|
||||
List<BaseCenter> list = new ArrayList<>();
|
||||
BaseCenter costCenter = new BaseCenter();
|
||||
costCenter.setSectionClassification("测试无匹配项");
|
||||
list.add(costCenter);
|
||||
|
||||
costCenter = new BaseCenter();
|
||||
costCenter.setSectionClassification("成本科目");
|
||||
costCenter.setBusinessType("货代");
|
||||
costCenter.setSalesman("仓干配物流部(物流)");
|
||||
|
@ -323,6 +335,26 @@ public class BaseChainServiceImpl extends ServiceImpl<BaseChainMapper, BaseChain
|
|||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult getChainList() {
|
||||
List<String> chainNameList = FlowBus.getChainMap().values().stream()
|
||||
.map(Chain::getChainId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<BaseChainEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(BaseChainEntity::getChainName, chainNameList);
|
||||
List<BaseChainEntity> chainList = this.list(queryWrapper);
|
||||
List<BaseChainVO> baseChainVOList = chainList.stream().map(chain -> {
|
||||
BaseChainVO baseChainVO = BeanUtil.toBean(chain, BaseChainVO.class);
|
||||
String templateId = chain.getTemplateId();
|
||||
if (StrUtil.isNotBlank(templateId)) {
|
||||
BaseTemplateEntity template = baseTemplateService.getById(templateId);
|
||||
String templateName = template.getTemplateName();
|
||||
baseChainVO.setTemplateName(templateName);
|
||||
}
|
||||
return baseChainVO;
|
||||
}).collect(Collectors.toList());
|
||||
return CommonResult.success(baseChainVOList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.liteflow.mysql.entity.BaseNodeEntity;
|
||||
|
@ -14,17 +15,21 @@ import com.example.liteflow.mysql.enums.EnableMarkEnum;
|
|||
import com.example.liteflow.mysql.enums.NodeEnum;
|
||||
import com.example.liteflow.mysql.model.CommonResult;
|
||||
import com.example.liteflow.mysql.model.OutputFrom;
|
||||
import com.example.liteflow.mysql.model.node.BaseNodeVO;
|
||||
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
||||
import com.example.liteflow.mysql.model.node.UpdateNodeFrom;
|
||||
import com.example.liteflow.mysql.model.role.Role;
|
||||
import com.example.liteflow.mysql.service.BaseNodeService;
|
||||
import com.example.liteflow.mysql.mapper.BaseNodeMapper;
|
||||
import com.example.liteflow.mysql.service.BaseTemplateService;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 75349
|
||||
|
@ -64,7 +69,7 @@ public class BaseNodeServiceImpl extends ServiceImpl<BaseNodeMapper, BaseNodeEnt
|
|||
return CommonResult.fail("节点数据错误");
|
||||
}
|
||||
this.save(baseNodeEntity);
|
||||
return CommonResult.success("创建节点成功");
|
||||
return CommonResult.success("创建节点成功", baseNodeEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,6 +104,22 @@ public class BaseNodeServiceImpl extends ServiceImpl<BaseNodeMapper, BaseNodeEnt
|
|||
.eq(BaseNodeEntity::getEnableMark, EnableMarkEnum.Enable.getValue());
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
@Override
|
||||
public CommonResult getNodeList() {
|
||||
List<String> nodeIdList = FlowBus.getNodeMap().values().stream().map(Node::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<BaseNodeEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(BaseNodeEntity::getNodeId, nodeIdList);
|
||||
List<BaseNodeEntity> nodeList = this.list(queryWrapper);
|
||||
List<BaseNodeVO> baseNodeVOList = nodeList.stream().map(node -> {
|
||||
BaseNodeVO baseNodeVO = BeanUtil.toBean(node, BaseNodeVO.class);
|
||||
String templateId = node.getTemplateId();
|
||||
BaseTemplateEntity template = baseTemplateService.getById(templateId);
|
||||
String templateName = template.getTemplateName();
|
||||
baseNodeVO.setTemplateName(templateName);
|
||||
return baseNodeVO;
|
||||
}).collect(Collectors.toList());
|
||||
return CommonResult.success(baseNodeVOList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.example.liteflow.mysql.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.liteflow.mysql.entity.BaseTemplateEntity;
|
||||
import com.example.liteflow.mysql.model.CommonResult;
|
||||
import com.example.liteflow.mysql.model.baseTemplate.BaseTemplateVO;
|
||||
import com.example.liteflow.mysql.model.baseTemplate.CreateTemplateFrom;
|
||||
import com.example.liteflow.mysql.model.baseTemplate.UpdateTemplateFrom;
|
||||
import com.example.liteflow.mysql.service.BaseTemplateService;
|
||||
|
@ -14,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import javax.smartcardio.CommandAPDU;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 75349
|
||||
|
@ -51,6 +54,14 @@ public class BaseTemplateServiceImpl extends ServiceImpl<BaseTemplateMapper, Bas
|
|||
public List<BaseTemplateEntity> getNotExistsChain() {
|
||||
return this.baseMapper.getNotExistsChain();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult getTemplateList() {
|
||||
List<BaseTemplateEntity> templateList = this.list();
|
||||
List<BaseTemplateVO> baseTemplateVOS = templateList.stream()
|
||||
.map(template -> BeanUtil.toBean(template, BaseTemplateVO.class)).collect(Collectors.toList());
|
||||
return CommonResult.success(baseTemplateVOS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package com.example.liteflow.mysql.util;
|
||||
|
||||
public interface ConditionConstants {
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue