1.添加注释
This commit is contained in:
parent
1088252c7c
commit
fe788d90ab
|
@ -41,14 +41,21 @@ public class CostCenterCmp extends NodeIfComponent {
|
||||||
private BaseDataService baseDataService;
|
private BaseDataService baseDataService;
|
||||||
@Resource
|
@Resource
|
||||||
private BaseRoleService baseRoleService;
|
private BaseRoleService baseRoleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匹配规则
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean processIf() throws Exception {
|
public boolean processIf() {
|
||||||
BaseCenter requestData = this.getRequestData();
|
BaseCenter requestData = this.getRequestData();
|
||||||
String nodeId = this.getNodeId();
|
String nodeId = this.getNodeId();
|
||||||
String nodeName = this.getName();
|
String nodeName = this.getName();
|
||||||
log.info("nodeId = {}, nodeName = {}", nodeId, nodeName);
|
log.info("nodeId = {}, nodeName = {}", nodeId, nodeName);
|
||||||
|
// 根据节点名称获取对应规则
|
||||||
String droolStr = baseRoleService.getByName(nodeName);
|
String droolStr = baseRoleService.getByName(nodeName);
|
||||||
if (StrUtil.isNotBlank(droolStr)) {
|
if (StrUtil.isNotBlank(droolStr)) {
|
||||||
|
// 替换规则中的关键字
|
||||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||||
|
@ -69,7 +76,7 @@ public class CostCenterCmp extends NodeIfComponent {
|
||||||
log.info("after - droolStr = {}", droolStr);
|
log.info("after - droolStr = {}", droolStr);
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
||||||
log.info("jsonArray = {}", jsonArray);
|
log.info("jsonArray = {}", jsonArray);
|
||||||
|
// 解析成google能识别的结构
|
||||||
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
||||||
|
|
||||||
log.info("condition template = {}", conditionResult);
|
log.info("condition template = {}", conditionResult);
|
||||||
|
|
|
@ -37,14 +37,20 @@ public class ProfitCenterCmp extends NodeIfComponent {
|
||||||
@Resource
|
@Resource
|
||||||
private BaseRoleService baseRoleService;
|
private BaseRoleService baseRoleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匹配规则
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean processIf() throws Exception {
|
public boolean processIf() {
|
||||||
BaseCenter requestData = this.getRequestData();
|
BaseCenter requestData = this.getRequestData();
|
||||||
String nodeId = this.getNodeId();
|
String nodeId = this.getNodeId();
|
||||||
String nodeName = this.getName();
|
String nodeName = this.getName();
|
||||||
log.info("nodeId = {}, nodeName = {}", nodeId, nodeName);
|
log.info("nodeId = {}, nodeName = {}", nodeId, nodeName);
|
||||||
|
// 根据节点名称获取对应规则
|
||||||
String droolStr = baseRoleService.getByName(nodeName);
|
String droolStr = baseRoleService.getByName(nodeName);
|
||||||
if (StrUtil.isNotBlank(droolStr)) {
|
if (StrUtil.isNotBlank(droolStr)) {
|
||||||
|
// 替换规则中的关键字
|
||||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||||
|
@ -65,7 +71,7 @@ public class ProfitCenterCmp extends NodeIfComponent {
|
||||||
log.info("after - droolStr = {}", droolStr);
|
log.info("after - droolStr = {}", droolStr);
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
||||||
log.info("jsonArray = {}", jsonArray);
|
log.info("jsonArray = {}", jsonArray);
|
||||||
|
// 解析成google能识别的结构
|
||||||
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
||||||
|
|
||||||
log.info("condition template = {}", conditionResult);
|
log.info("condition template = {}", conditionResult);
|
||||||
|
|
|
@ -1,20 +1,11 @@
|
||||||
package com.example.liteflow.mysql.controller;
|
package com.example.liteflow.mysql.controller;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.example.liteflow.mysql.model.role.Role;
|
|
||||||
import com.example.liteflow.mysql.model.role.RoleForm;
|
import com.example.liteflow.mysql.model.role.RoleForm;
|
||||||
import com.example.liteflow.mysql.service.BaseRoleService;
|
import com.example.liteflow.mysql.service.BaseRoleService;
|
||||||
import com.example.liteflow.mysql.util.RoleUtil;
|
|
||||||
import com.yomahub.liteflow.core.FlowExecutor;
|
|
||||||
import com.yomahub.liteflow.enums.FlowParserTypeEnum;
|
|
||||||
import com.yomahub.liteflow.flow.FlowBus;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
|
@ -27,15 +18,20 @@ public class BaseRoleController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BaseRoleService baseRoleService;
|
private BaseRoleService baseRoleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建规则
|
||||||
|
*
|
||||||
|
* @param roleForm
|
||||||
|
*/
|
||||||
@PostMapping("/createRole")
|
@PostMapping("/createRole")
|
||||||
public void createRole(@RequestBody RoleForm roleForm) {
|
public void createRole(@RequestBody RoleForm roleForm) {
|
||||||
baseRoleService.createRole(roleForm);
|
baseRoleService.createRole(roleForm);
|
||||||
// List<Role> roles = roleForm.getRoles();
|
|
||||||
// List<Map<String, Object>> collect = roles.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
|
||||||
// System.out.println(JSONUtil.toJsonStr(collect));
|
|
||||||
// flowExecutor.reloadRule();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建测试用规则
|
||||||
|
*/
|
||||||
@GetMapping("/testCreateRole")
|
@GetMapping("/testCreateRole")
|
||||||
public void testCreateRole() {
|
public void testCreateRole() {
|
||||||
baseRoleService.testCreateRole();
|
baseRoleService.testCreateRole();
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.example.liteflow.mysql.controller;
|
||||||
|
|
||||||
import com.example.liteflow.mysql.entity.ChainEntity;
|
import com.example.liteflow.mysql.entity.ChainEntity;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
import com.example.liteflow.mysql.model.role.RoleForm;
|
|
||||||
import com.example.liteflow.mysql.service.ChainService;
|
import com.example.liteflow.mysql.service.ChainService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -21,31 +20,62 @@ public class ChainController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ChainService chainService;
|
private ChainService chainService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建链路实体
|
||||||
|
*
|
||||||
|
* @param chainEntity
|
||||||
|
*/
|
||||||
@PostMapping("/createChain")
|
@PostMapping("/createChain")
|
||||||
public void createChain(@RequestBody ChainEntity chainEntity) {
|
public void createChain(@RequestBody ChainEntity chainEntity) {
|
||||||
chainService.createChain(chainEntity);
|
chainService.createChain(chainEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建动态链路
|
||||||
|
*
|
||||||
|
* @param chainEntity
|
||||||
|
*/
|
||||||
@PostMapping("/dynamicGenerateChain")
|
@PostMapping("/dynamicGenerateChain")
|
||||||
public void dynamicGenerateChain(@RequestBody ChainEntity chainEntity) {
|
public void dynamicGenerateChain(@RequestBody ChainEntity chainEntity) {
|
||||||
chainService.dynamicGenerateChain(chainEntity);
|
chainService.dynamicGenerateChain(chainEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据链路名称执行链路
|
||||||
|
*
|
||||||
|
* @param chainName
|
||||||
|
*/
|
||||||
@GetMapping("/executeChain/{chainName}")
|
@GetMapping("/executeChain/{chainName}")
|
||||||
public List<BaseCenter> executeChain(@PathVariable("chainName") String chainName) {
|
public List<BaseCenter> executeChain(@PathVariable("chainName") String chainName) {
|
||||||
return chainService.executeChain(chainName);
|
return chainService.executeChain(chainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取链路
|
||||||
|
*
|
||||||
|
* @param chainName
|
||||||
|
*/
|
||||||
@GetMapping("/getChainByName/{chainName}")
|
@GetMapping("/getChainByName/{chainName}")
|
||||||
public ChainEntity getChainByName(@PathVariable("chainName") String chainName) {
|
public ChainEntity getChainByName(@PathVariable("chainName") String chainName) {
|
||||||
return chainService.getChainName(chainName);
|
return chainService.getChainName(chainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除链路
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
@DeleteMapping("/deleteChain/{id}")
|
@DeleteMapping("/deleteChain/{id}")
|
||||||
public String deleteChain(@PathVariable("id") String id) {
|
public String deleteChain(@PathVariable("id") String id) {
|
||||||
return chainService.deleteChain(id);
|
return chainService.deleteChain(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跟新链路
|
||||||
|
*
|
||||||
|
* @param chainEntity
|
||||||
|
*/
|
||||||
@PostMapping("/updateChain")
|
@PostMapping("/updateChain")
|
||||||
public String updateChain(@RequestBody ChainEntity chainEntity) {
|
public String updateChain(@RequestBody ChainEntity chainEntity) {
|
||||||
return chainService.updateChain(chainEntity);
|
return chainService.updateChain(chainEntity);
|
||||||
|
|
|
@ -19,41 +19,69 @@ public class NodeController {
|
||||||
@Resource
|
@Resource
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建成本中心判断节点
|
||||||
|
* @param createNodeFrom
|
||||||
|
*/
|
||||||
@PostMapping("/createCostCenterIfNode")
|
@PostMapping("/createCostCenterIfNode")
|
||||||
public void createCostCenterIfNode(@RequestBody CreateNodeFrom createNodeFrom) {
|
public void createCostCenterIfNode(@RequestBody CreateNodeFrom createNodeFrom) {
|
||||||
nodeService.createCostCenterIfNode(createNodeFrom);
|
nodeService.createCostCenterIfNode(createNodeFrom);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 批量创建成本中心判断节点
|
||||||
|
* @param createNodeFroms
|
||||||
|
*/
|
||||||
@PostMapping("/batchCreateCostCenterIfNode")
|
@PostMapping("/batchCreateCostCenterIfNode")
|
||||||
public void batchCreateCostCenterIfNode(@RequestBody List<CreateNodeFrom> createNodeFroms) {
|
public void batchCreateCostCenterIfNode(@RequestBody List<CreateNodeFrom> createNodeFroms) {
|
||||||
nodeService.batchCreateCostCenterIfNode(createNodeFroms);
|
nodeService.batchCreateCostCenterIfNode(createNodeFroms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建成本中心普通节点
|
||||||
|
* @param createNodeFrom
|
||||||
|
*/
|
||||||
@PostMapping("/createCostCenterNode")
|
@PostMapping("/createCostCenterNode")
|
||||||
public void createCostCenterNode(@RequestBody CreateNodeFrom createNodeFrom) {
|
public void createCostCenterNode(@RequestBody CreateNodeFrom createNodeFrom) {
|
||||||
nodeService.createCostCenterNode(createNodeFrom);
|
nodeService.createCostCenterNode(createNodeFrom);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 批量创建成本中心普通节点
|
||||||
|
* @param createNodeFroms
|
||||||
|
*/
|
||||||
@PostMapping("/batchCreateCostCenterNode")
|
@PostMapping("/batchCreateCostCenterNode")
|
||||||
public void batchCreateCostCenterNode(@RequestBody List<CreateNodeFrom> createNodeFroms) {
|
public void batchCreateCostCenterNode(@RequestBody List<CreateNodeFrom> createNodeFroms) {
|
||||||
nodeService.batchCreateCostCenterNode(createNodeFroms);
|
nodeService.batchCreateCostCenterNode(createNodeFroms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建利润中心判断节点
|
||||||
|
* @param createNodeFrom
|
||||||
|
*/
|
||||||
@PostMapping("/createProfitCenterIfNode")
|
@PostMapping("/createProfitCenterIfNode")
|
||||||
public void createProfitCenterIfNode(@RequestBody CreateNodeFrom createNodeFrom) {
|
public void createProfitCenterIfNode(@RequestBody CreateNodeFrom createNodeFrom) {
|
||||||
nodeService.createProfitCenterIfNode(createNodeFrom);
|
nodeService.createProfitCenterIfNode(createNodeFrom);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 批量创建利润中心判断节点
|
||||||
|
* @param createNodeFroms
|
||||||
|
*/
|
||||||
@PostMapping("/batchCreateProfitCenterIfNode")
|
@PostMapping("/batchCreateProfitCenterIfNode")
|
||||||
public void batchCreateProfitCenterIfNode(@RequestBody List<CreateNodeFrom> createNodeFroms) {
|
public void batchCreateProfitCenterIfNode(@RequestBody List<CreateNodeFrom> createNodeFroms) {
|
||||||
nodeService.batchCreateProfitCenterIfNode(createNodeFroms);
|
nodeService.batchCreateProfitCenterIfNode(createNodeFroms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建利润中心普通节点
|
||||||
|
* @param createNodeFrom
|
||||||
|
*/
|
||||||
@PostMapping("/createProfitCenterNode")
|
@PostMapping("/createProfitCenterNode")
|
||||||
public void createProfitCenterNode(@RequestBody CreateNodeFrom createNodeFrom) {
|
public void createProfitCenterNode(@RequestBody CreateNodeFrom createNodeFrom) {
|
||||||
nodeService.createProfitCenterNode(createNodeFrom);
|
nodeService.createProfitCenterNode(createNodeFrom);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 批量创建利润中心普通节点
|
||||||
|
* @param createNodeFroms
|
||||||
|
*/
|
||||||
@PostMapping("/batchCreateProfitCostCenterNode")
|
@PostMapping("/batchCreateProfitCostCenterNode")
|
||||||
public void batchCreateProfitCostCenterNode(@RequestBody List<CreateNodeFrom> createNodeFroms) {
|
public void batchCreateProfitCostCenterNode(@RequestBody List<CreateNodeFrom> createNodeFroms) {
|
||||||
nodeService.batchCreateProfitCostCenterNode(createNodeFroms);
|
nodeService.batchCreateProfitCostCenterNode(createNodeFroms);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class BaseDataServiceImpl extends ServiceImpl<BaseDataMapper, BaseDataEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseDataEntity getByTypeAndName(String type, String attribution, String contentName) {
|
public BaseDataEntity getByTypeAndName(String type, String attribution, String contentName) {
|
||||||
// log.info("type = {}, attribution = {}", type, attribution);
|
log.info("type = {}, attribution = {}", type, attribution);
|
||||||
LambdaQueryWrapper<BaseDataEntity> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BaseDataEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(BaseDataEntity::getType, type)
|
queryWrapper.eq(BaseDataEntity::getType, type)
|
||||||
.eq(BaseDataEntity::getAttribution, attribution)
|
.eq(BaseDataEntity::getAttribution, attribution)
|
||||||
|
|
Loading…
Reference in New Issue