diff --git a/src/main/java/com/example/liteflow/mysql/cmp/costCenter/CostCenterCmp.java b/src/main/java/com/example/liteflow/mysql/cmp/costCenter/CostCenterCmp.java index 227819a..39b91ec 100644 --- a/src/main/java/com/example/liteflow/mysql/cmp/costCenter/CostCenterCmp.java +++ b/src/main/java/com/example/liteflow/mysql/cmp/costCenter/CostCenterCmp.java @@ -41,14 +41,21 @@ public class CostCenterCmp extends NodeIfComponent { private BaseDataService baseDataService; @Resource private BaseRoleService baseRoleService; + + /** + * 匹配规则 + * @return boolean + */ @Override - public boolean processIf() throws Exception { + public boolean processIf() { BaseCenter requestData = this.getRequestData(); String nodeId = this.getNodeId(); String nodeName = this.getName(); log.info("nodeId = {}, nodeName = {}", nodeId, nodeName); + // 根据节点名称获取对应规则 String droolStr = baseRoleService.getByName(nodeName); if (StrUtil.isNotBlank(droolStr)) { + // 替换规则中的关键字 Field[] fields = ReflectUtil.getFields(BaseCenter.class); for (Field field : fields) { Object fieldValue = ReflectUtil.getFieldValue(requestData, field); @@ -69,7 +76,7 @@ public class CostCenterCmp extends NodeIfComponent { log.info("after - droolStr = {}", droolStr); JSONArray jsonArray = JSONUtil.parseArray(droolStr); log.info("jsonArray = {}", jsonArray); - + // 解析成google能识别的结构 String conditionResult = ConditionParser.parseCondition(jsonArray); log.info("condition template = {}", conditionResult); diff --git a/src/main/java/com/example/liteflow/mysql/cmp/profitCenter/ProfitCenterCmp.java b/src/main/java/com/example/liteflow/mysql/cmp/profitCenter/ProfitCenterCmp.java index 6359557..1115152 100644 --- a/src/main/java/com/example/liteflow/mysql/cmp/profitCenter/ProfitCenterCmp.java +++ b/src/main/java/com/example/liteflow/mysql/cmp/profitCenter/ProfitCenterCmp.java @@ -37,14 +37,20 @@ public class ProfitCenterCmp extends NodeIfComponent { @Resource private BaseRoleService baseRoleService; + /** + * 匹配规则 + * @return boolean + */ @Override - public boolean processIf() throws Exception { + public boolean processIf() { BaseCenter requestData = this.getRequestData(); String nodeId = this.getNodeId(); String nodeName = this.getName(); log.info("nodeId = {}, nodeName = {}", nodeId, nodeName); + // 根据节点名称获取对应规则 String droolStr = baseRoleService.getByName(nodeName); if (StrUtil.isNotBlank(droolStr)) { + // 替换规则中的关键字 Field[] fields = ReflectUtil.getFields(BaseCenter.class); for (Field field : fields) { Object fieldValue = ReflectUtil.getFieldValue(requestData, field); @@ -65,7 +71,7 @@ public class ProfitCenterCmp extends NodeIfComponent { log.info("after - droolStr = {}", droolStr); JSONArray jsonArray = JSONUtil.parseArray(droolStr); log.info("jsonArray = {}", jsonArray); - + // 解析成google能识别的结构 String conditionResult = ConditionParser.parseCondition(jsonArray); log.info("condition template = {}", conditionResult); diff --git a/src/main/java/com/example/liteflow/mysql/controller/BaseRoleController.java b/src/main/java/com/example/liteflow/mysql/controller/BaseRoleController.java index 27859aa..ec7ac9f 100644 --- a/src/main/java/com/example/liteflow/mysql/controller/BaseRoleController.java +++ b/src/main/java/com/example/liteflow/mysql/controller/BaseRoleController.java @@ -1,20 +1,11 @@ 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.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 org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; /** * @author: 陈韦龙 @@ -27,15 +18,20 @@ public class BaseRoleController { @Resource private BaseRoleService baseRoleService; + + /** + * 创建规则 + * + * @param roleForm + */ @PostMapping("/createRole") public void createRole(@RequestBody RoleForm roleForm) { baseRoleService.createRole(roleForm); -// List roles = roleForm.getRoles(); -// List> collect = roles.stream().map(RoleUtil::parseRole).collect(Collectors.toList()); -// System.out.println(JSONUtil.toJsonStr(collect)); -// flowExecutor.reloadRule(); } + /** + * 创建测试用规则 + */ @GetMapping("/testCreateRole") public void testCreateRole() { baseRoleService.testCreateRole(); diff --git a/src/main/java/com/example/liteflow/mysql/controller/ChainController.java b/src/main/java/com/example/liteflow/mysql/controller/ChainController.java index e03413f..53fcb52 100644 --- a/src/main/java/com/example/liteflow/mysql/controller/ChainController.java +++ b/src/main/java/com/example/liteflow/mysql/controller/ChainController.java @@ -2,7 +2,6 @@ package com.example.liteflow.mysql.controller; import com.example.liteflow.mysql.entity.ChainEntity; import com.example.liteflow.mysql.model.BaseCenter; -import com.example.liteflow.mysql.model.role.RoleForm; import com.example.liteflow.mysql.service.ChainService; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; @@ -21,31 +20,62 @@ public class ChainController { @Resource private ChainService chainService; + + /** + * 创建链路实体 + * + * @param chainEntity + */ @PostMapping("/createChain") public void createChain(@RequestBody ChainEntity chainEntity) { chainService.createChain(chainEntity); } + /** + * 创建动态链路 + * + * @param chainEntity + */ @PostMapping("/dynamicGenerateChain") public void dynamicGenerateChain(@RequestBody ChainEntity chainEntity) { chainService.dynamicGenerateChain(chainEntity); } + /** + * 根据链路名称执行链路 + * + * @param chainName + */ @GetMapping("/executeChain/{chainName}") public List executeChain(@PathVariable("chainName") String chainName) { return chainService.executeChain(chainName); } + /** + * 获取链路 + * + * @param chainName + */ @GetMapping("/getChainByName/{chainName}") public ChainEntity getChainByName(@PathVariable("chainName") String chainName) { return chainService.getChainName(chainName); } + /** + * 删除链路 + * + * @param id + */ @DeleteMapping("/deleteChain/{id}") public String deleteChain(@PathVariable("id") String id) { return chainService.deleteChain(id); } + /** + * 跟新链路 + * + * @param chainEntity + */ @PostMapping("/updateChain") public String updateChain(@RequestBody ChainEntity chainEntity) { return chainService.updateChain(chainEntity); diff --git a/src/main/java/com/example/liteflow/mysql/controller/NodeController.java b/src/main/java/com/example/liteflow/mysql/controller/NodeController.java index 6f8997e..b7f76be 100644 --- a/src/main/java/com/example/liteflow/mysql/controller/NodeController.java +++ b/src/main/java/com/example/liteflow/mysql/controller/NodeController.java @@ -19,41 +19,69 @@ public class NodeController { @Resource private NodeService nodeService; + /** + * 创建成本中心判断节点 + * @param createNodeFrom + */ @PostMapping("/createCostCenterIfNode") public void createCostCenterIfNode(@RequestBody CreateNodeFrom createNodeFrom) { nodeService.createCostCenterIfNode(createNodeFrom); } - + /** + * 批量创建成本中心判断节点 + * @param createNodeFroms + */ @PostMapping("/batchCreateCostCenterIfNode") public void batchCreateCostCenterIfNode(@RequestBody List createNodeFroms) { nodeService.batchCreateCostCenterIfNode(createNodeFroms); } + /** + * 创建成本中心普通节点 + * @param createNodeFrom + */ @PostMapping("/createCostCenterNode") public void createCostCenterNode(@RequestBody CreateNodeFrom createNodeFrom) { nodeService.createCostCenterNode(createNodeFrom); } - + /** + * 批量创建成本中心普通节点 + * @param createNodeFroms + */ @PostMapping("/batchCreateCostCenterNode") public void batchCreateCostCenterNode(@RequestBody List createNodeFroms) { nodeService.batchCreateCostCenterNode(createNodeFroms); } + /** + * 创建利润中心判断节点 + * @param createNodeFrom + */ @PostMapping("/createProfitCenterIfNode") public void createProfitCenterIfNode(@RequestBody CreateNodeFrom createNodeFrom) { nodeService.createProfitCenterIfNode(createNodeFrom); } - + /** + * 批量创建利润中心判断节点 + * @param createNodeFroms + */ @PostMapping("/batchCreateProfitCenterIfNode") public void batchCreateProfitCenterIfNode(@RequestBody List createNodeFroms) { nodeService.batchCreateProfitCenterIfNode(createNodeFroms); } + /** + * 创建利润中心普通节点 + * @param createNodeFrom + */ @PostMapping("/createProfitCenterNode") public void createProfitCenterNode(@RequestBody CreateNodeFrom createNodeFrom) { nodeService.createProfitCenterNode(createNodeFrom); } - + /** + * 批量创建利润中心普通节点 + * @param createNodeFroms + */ @PostMapping("/batchCreateProfitCostCenterNode") public void batchCreateProfitCostCenterNode(@RequestBody List createNodeFroms) { nodeService.batchCreateProfitCostCenterNode(createNodeFroms); diff --git a/src/main/java/com/example/liteflow/mysql/service/impl/BaseDataServiceImpl.java b/src/main/java/com/example/liteflow/mysql/service/impl/BaseDataServiceImpl.java index 8708fb4..1938407 100644 --- a/src/main/java/com/example/liteflow/mysql/service/impl/BaseDataServiceImpl.java +++ b/src/main/java/com/example/liteflow/mysql/service/impl/BaseDataServiceImpl.java @@ -26,7 +26,7 @@ public class BaseDataServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(BaseDataEntity::getType, type) .eq(BaseDataEntity::getAttribution, attribution)