parent
e9bb9ab48a
commit
cf4600f404
|
@ -1,12 +1,15 @@
|
||||||
package com.example.liteflow.mysql;
|
package com.example.liteflow.mysql;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSON;
|
import cn.hutool.json.JSON;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
import com.example.liteflow.mysql.model.CostCenter;
|
import com.example.liteflow.mysql.model.CostCenter;
|
||||||
import com.example.liteflow.mysql.model.CostCenterContext;
|
import com.example.liteflow.mysql.model.CostCenterContext;
|
||||||
import com.example.liteflow.mysql.model.ProfitCenter;
|
import com.example.liteflow.mysql.model.ProfitCenter;
|
||||||
|
import com.googlecode.aviator.AviatorEvaluator;
|
||||||
import com.yomahub.liteflow.core.FlowExecutor;
|
import com.yomahub.liteflow.core.FlowExecutor;
|
||||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||||
import org.assertj.core.util.Lists;
|
import org.assertj.core.util.Lists;
|
||||||
|
@ -20,7 +23,9 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LiteFlowCommand {
|
public class LiteFlowCommand
|
||||||
|
// implements CommandLineRunner
|
||||||
|
{
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
|
@ -31,9 +36,8 @@ public class LiteFlowCommand {
|
||||||
private final List<String> profitCenterList = Lists.newArrayList("profit01AndProfit02", "profit01", "profit02");
|
private final List<String> profitCenterList = Lists.newArrayList("profit01AndProfit02", "profit01", "profit02");
|
||||||
private final List<String> costCenterList = Lists.newArrayList("cost01AndCost02", "cost01", "cost02");
|
private final List<String> costCenterList = Lists.newArrayList("cost01AndCost02", "cost01", "cost02");
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
public void run(String... args) throws Exception {
|
public void run1(String... args) throws Exception {
|
||||||
// 事实对象
|
// 事实对象
|
||||||
// CostCenter costCenter = new CostCenter();
|
// CostCenter costCenter = new CostCenter();
|
||||||
// costCenter.setSectionClassification("成本科目1");
|
// costCenter.setSectionClassification("成本科目1");
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.example.liteflow.mysql.bean;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.googlecode.aviator.AviatorEvaluator;
|
||||||
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 陈韦龙
|
||||||
|
* @date: 2022年12月09日 15:35
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class AviatorEvaluatorBean {
|
||||||
|
@Bean
|
||||||
|
public void aviatorEvaluatorInit() throws IllegalAccessException, NoSuchMethodException {
|
||||||
|
AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
||||||
|
AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,7 +34,6 @@ public class CostCenter01Cmp extends NodeIfComponent {
|
||||||
private BaseDataService baseDataService;
|
private BaseDataService baseDataService;
|
||||||
@Resource
|
@Resource
|
||||||
private BaseRoleService baseRoleService;
|
private BaseRoleService baseRoleService;
|
||||||
private static final String drool = "[{\"$or\": [{\"$and\": [{\"$contains\": [sectionClassification, sectionClassificationList]}, {\"$contains\": [businessType, businessTypeList]}, {\"$contains\": [salesman, salesmanList]}, {\"$contains\": [businessCategory, businessCategoryList]}]}]}]";
|
|
||||||
|
|
||||||
private static final String baseRoleName = "costCenter01Cmp";
|
private static final String baseRoleName = "costCenter01Cmp";
|
||||||
|
|
||||||
|
@ -44,36 +43,41 @@ public class CostCenter01Cmp extends NodeIfComponent {
|
||||||
log.info("requestData = {}", JSONUtil.toJsonStr(requestData));
|
log.info("requestData = {}", JSONUtil.toJsonStr(requestData));
|
||||||
String droolStr = baseRoleService.getByName(baseRoleName);
|
String droolStr = baseRoleService.getByName(baseRoleName);
|
||||||
log.info("droolStr = {}", droolStr);
|
log.info("droolStr = {}", droolStr);
|
||||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
if (StrUtil.isNotBlank(droolStr)) {
|
||||||
for (Field field : fields) {
|
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
for (Field field : fields) {
|
||||||
String name = field.getName();
|
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.costCenter.getAttribution());
|
String name = field.getName();
|
||||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.costCenter.getAttribution());
|
||||||
String content = baseDataEntity.getContent();
|
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||||
String contentName = baseDataEntity.getContentName();
|
String content = baseDataEntity.getContent();
|
||||||
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
String contentName = baseDataEntity.getContentName();
|
||||||
|
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
||||||
|
}
|
||||||
|
String filedValueStr = "";
|
||||||
|
if (ObjectUtil.isNotNull(fieldValue)) {
|
||||||
|
filedValueStr = fieldValue.toString();
|
||||||
|
}
|
||||||
|
droolStr = StrUtil.replace(droolStr, name, filedValueStr, false);
|
||||||
}
|
}
|
||||||
String filedValueStr = "";
|
|
||||||
if (ObjectUtil.isNotNull(fieldValue)) {
|
log.info("after - droolStr = {}", droolStr);
|
||||||
filedValueStr = fieldValue.toString();
|
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
||||||
}
|
log.info("jsonArray = {}", jsonArray);
|
||||||
droolStr = StrUtil.replace(droolStr, name, filedValueStr, false);
|
|
||||||
|
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
||||||
|
|
||||||
|
log.info("condition template = {}", conditionResult);
|
||||||
|
// AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
||||||
|
// AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
||||||
|
Object executeB = AviatorEvaluator.execute(conditionResult);
|
||||||
|
log.info("CostCenter01Cmp-{} = {}", conditionResult, executeB);
|
||||||
|
boolean aBoolean = BooleanUtil.toBoolean(executeB.toString());
|
||||||
|
log.info("CostCenter01Cmp-aBoolean = {}", aBoolean);
|
||||||
|
return aBoolean;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("after - droolStr = {}", droolStr);
|
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
|
||||||
log.info("jsonArray = {}", jsonArray);
|
|
||||||
|
|
||||||
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
|
||||||
|
|
||||||
log.info("condition template = {}", conditionResult);
|
|
||||||
AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
|
||||||
AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
|
||||||
Object executeB = AviatorEvaluator.execute(conditionResult);
|
|
||||||
log.info("CostCenter01Cmp-{} = {}", conditionResult, executeB);
|
|
||||||
boolean aBoolean = BooleanUtil.toBoolean(executeB.toString());
|
|
||||||
log.info("CostCenter01Cmp-aBoolean = {}", aBoolean);
|
|
||||||
return aBoolean;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package com.example.liteflow.mysql.cmp.costCenter;
|
package com.example.liteflow.mysql.cmp.costCenter;
|
||||||
|
|
||||||
|
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||||
|
import com.example.liteflow.mysql.enums.BaseDataAttributionEnum;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
import com.example.liteflow.mysql.model.CostCenter;
|
import com.example.liteflow.mysql.model.CostCenter;
|
||||||
|
import com.example.liteflow.mysql.service.BaseDataService;
|
||||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||||
import com.yomahub.liteflow.core.NodeComponent;
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
* @date: 2022年12月05日 10:15
|
* @date: 2022年12月05日 10:15
|
||||||
|
@ -14,13 +19,18 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CostCenter01SoutCmp extends NodeComponent {
|
public class CostCenter01SoutCmp extends NodeComponent {
|
||||||
|
|
||||||
private static final String costCenter01Code = "P350401028";
|
// private static final String costCenter01Code = "P350401028";
|
||||||
private static final String costCenter01Name = "仓干配物流部利润中心";
|
// private static final String costCenter01Name = "仓干配物流部利润中心";
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BaseDataService baseDataService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process() {
|
public void process() {
|
||||||
|
BaseDataEntity codeBaseData = baseDataService.getByTypeAndName("sout", BaseDataAttributionEnum.costCenter.getAttribution(), "costCenter01Code");
|
||||||
|
BaseDataEntity nameBaseData = baseDataService.getByTypeAndName("sout", BaseDataAttributionEnum.costCenter.getAttribution(), "costCenter01Name");
|
||||||
|
String costCenter01Code = codeBaseData.getContent();
|
||||||
|
String costCenter01Name = nameBaseData.getContent();
|
||||||
BaseCenter baseCenter = this.getRequestData();
|
BaseCenter baseCenter = this.getRequestData();
|
||||||
baseCenter.setCostCenterCode(costCenter01Code);
|
baseCenter.setCostCenterCode(costCenter01Code);
|
||||||
baseCenter.setCostCenterName(costCenter01Name);
|
baseCenter.setCostCenterName(costCenter01Name);
|
||||||
|
|
|
@ -34,8 +34,6 @@ import java.util.Map;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CostCenter02Cmp extends NodeIfComponent {
|
public class CostCenter02Cmp extends NodeIfComponent {
|
||||||
|
|
||||||
private static final String drool = "[{\"$or\": [{\"$or\": [{\"$and\": [{\"$contains\": [sectionClassification, sectionClassificationList]}, {\"$contains\": [salesman, salesmanList]}]}]}, {\"$or\": [{\"$contains\": [businessType, businessTypeList]}]}]}]";
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BaseDataService baseDataService;
|
private BaseDataService baseDataService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -45,38 +43,42 @@ public class CostCenter02Cmp extends NodeIfComponent {
|
||||||
public boolean processIf() throws Exception {
|
public boolean processIf() throws Exception {
|
||||||
BaseCenter requestData = this.getRequestData();
|
BaseCenter requestData = this.getRequestData();
|
||||||
String droolStr = baseRoleService.getByName(baseRoleName);
|
String droolStr = baseRoleService.getByName(baseRoleName);
|
||||||
log.info("droolStr = {}", droolStr);
|
|
||||||
log.info("CostCenter02Cmp-droolStr = {}", droolStr);
|
log.info("CostCenter02Cmp-droolStr = {}", droolStr);
|
||||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
if (StrUtil.isNotBlank(droolStr)) {
|
||||||
for (Field field : fields) {
|
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
for (Field field : fields) {
|
||||||
String name = field.getName();
|
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.costCenter.getAttribution());
|
String name = field.getName();
|
||||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.costCenter.getAttribution());
|
||||||
String content = baseDataEntity.getContent();
|
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||||
String contentName = baseDataEntity.getContentName();
|
String content = baseDataEntity.getContent();
|
||||||
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
String contentName = baseDataEntity.getContentName();
|
||||||
|
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
||||||
|
}
|
||||||
|
String filedValueStr = "";
|
||||||
|
if (ObjectUtil.isNotNull(fieldValue)) {
|
||||||
|
filedValueStr = fieldValue.toString();
|
||||||
|
}
|
||||||
|
droolStr = StrUtil.replace(droolStr, name, filedValueStr, false);
|
||||||
}
|
}
|
||||||
String filedValueStr = "";
|
|
||||||
if (ObjectUtil.isNotNull(fieldValue)) {
|
log.info("after - replace4 = {}", droolStr);
|
||||||
filedValueStr = fieldValue.toString();
|
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
||||||
}
|
log.info("jsonArray = {}", jsonArray);
|
||||||
droolStr = StrUtil.replace(droolStr, name, filedValueStr, false);
|
|
||||||
|
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
||||||
|
|
||||||
|
log.info("condition template = {}", conditionResult);
|
||||||
|
// AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
||||||
|
// AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
||||||
|
Object executeB = AviatorEvaluator.execute(conditionResult);
|
||||||
|
log.info("CostCenter02Cmp-{} = {}", conditionResult, executeB);
|
||||||
|
boolean aBoolean = BooleanUtil.toBoolean(executeB.toString());
|
||||||
|
log.info("CostCenter02Cmp-aBoolean = {}", aBoolean);
|
||||||
|
return aBoolean;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("after - replace4 = {}", droolStr);
|
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
|
||||||
log.info("jsonArray = {}", jsonArray);
|
|
||||||
|
|
||||||
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
|
||||||
|
|
||||||
log.info("condition template = {}", conditionResult);
|
|
||||||
AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
|
||||||
AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
|
||||||
Object executeB = AviatorEvaluator.execute(conditionResult);
|
|
||||||
log.info("CostCenter02Cmp-{} = {}", conditionResult, executeB);
|
|
||||||
boolean aBoolean = BooleanUtil.toBoolean(executeB.toString());
|
|
||||||
log.info("CostCenter02Cmp-aBoolean = {}", aBoolean);
|
|
||||||
return aBoolean;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package com.example.liteflow.mysql.cmp.costCenter;
|
package com.example.liteflow.mysql.cmp.costCenter;
|
||||||
|
|
||||||
|
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||||
|
import com.example.liteflow.mysql.enums.BaseDataAttributionEnum;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
import com.example.liteflow.mysql.model.CostCenter;
|
import com.example.liteflow.mysql.model.CostCenter;
|
||||||
|
import com.example.liteflow.mysql.service.BaseDataService;
|
||||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||||
import com.yomahub.liteflow.core.NodeComponent;
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
* @date: 2022年12月05日 10:15
|
* @date: 2022年12月05日 10:15
|
||||||
|
@ -14,14 +19,19 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CostCenter02SoutCmp extends NodeComponent {
|
public class CostCenter02SoutCmp extends NodeComponent {
|
||||||
|
|
||||||
private static final String costCenter02Code = "P350401026";
|
// private static final String costCenter02Code = "P350401026";
|
||||||
private static final String costCenter02Name = "商品车物流部利润中心";
|
// private static final String costCenter02Name = "商品车物流部利润中心";
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BaseDataService baseDataService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process() {
|
public void process() {
|
||||||
|
BaseDataEntity codeBaseData = baseDataService.getByTypeAndName("sout", BaseDataAttributionEnum.costCenter.getAttribution(), "costCenter02Code");
|
||||||
|
BaseDataEntity nameBaseData = baseDataService.getByTypeAndName("sout", BaseDataAttributionEnum.costCenter.getAttribution(), "costCenter02Name");
|
||||||
BaseCenter baseCenter = this.getRequestData();
|
BaseCenter baseCenter = this.getRequestData();
|
||||||
|
String costCenter02Code = codeBaseData.getContent();
|
||||||
|
String costCenter02Name = nameBaseData.getContent();
|
||||||
baseCenter.setCostCenterCode(costCenter02Code);
|
baseCenter.setCostCenterCode(costCenter02Code);
|
||||||
baseCenter.setCostCenterName(costCenter02Name);
|
baseCenter.setCostCenterName(costCenter02Name);
|
||||||
baseCenter.setCostCenterGenerateCode(costCenter02Code + costCenter02Name);
|
baseCenter.setCostCenterGenerateCode(costCenter02Code + costCenter02Name);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||||
import com.example.liteflow.mysql.enums.BaseDataAttributionEnum;
|
import com.example.liteflow.mysql.enums.BaseDataAttributionEnum;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
import com.example.liteflow.mysql.service.BaseDataService;
|
import com.example.liteflow.mysql.service.BaseDataService;
|
||||||
|
import com.example.liteflow.mysql.service.BaseRoleService;
|
||||||
import com.example.liteflow.mysql.util.ConditionParser;
|
import com.example.liteflow.mysql.util.ConditionParser;
|
||||||
import com.googlecode.aviator.AviatorEvaluator;
|
import com.googlecode.aviator.AviatorEvaluator;
|
||||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||||
|
@ -28,44 +29,51 @@ import java.lang.reflect.Field;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ProfitCenter01Cmp extends NodeIfComponent {
|
public class ProfitCenter01Cmp extends NodeIfComponent {
|
||||||
|
|
||||||
private static final String drool = "[{\"$or\": [{\"$and\": [{\"$contains\": [businessType, businessTypeList]}, {\"$contains\": [salesman, salesmanList]}, {\"$contains\": [businessCategory, businessCategoryList]}]}]}, {\"$or\": [{\"$and\": [{\"$contains\": [sectionClassification, sectionClassificationList]}, {\"$contains\": [businessType, businessTypeList]}]}]}]";
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BaseDataService baseDataService;
|
private BaseDataService baseDataService;
|
||||||
|
@Resource
|
||||||
|
private BaseRoleService baseRoleService;
|
||||||
|
private static final String baseRoleName = "profitCenter01Cmp";
|
||||||
@Override
|
@Override
|
||||||
public boolean processIf() throws Exception {
|
public boolean processIf() throws Exception {
|
||||||
BaseCenter requestData = this.getRequestData();
|
BaseCenter requestData = this.getRequestData();
|
||||||
String droolStr = drool;
|
String droolStr = baseRoleService.getByName(baseRoleName);
|
||||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
log.info("ProfitCenter01Cmp-droolStr = {}", droolStr);
|
||||||
for (Field field : fields) {
|
if (StrUtil.isNotBlank(droolStr)) {
|
||||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||||
String name = field.getName();
|
for (Field field : fields) {
|
||||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.profitCenter.getAttribution());
|
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
String name = field.getName();
|
||||||
String content = baseDataEntity.getContent();
|
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.profitCenter.getAttribution());
|
||||||
String contentName = baseDataEntity.getContentName();
|
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||||
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
String content = baseDataEntity.getContent();
|
||||||
|
String contentName = baseDataEntity.getContentName();
|
||||||
|
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
||||||
|
}
|
||||||
|
String filedValueStr = "";
|
||||||
|
if (ObjectUtil.isNotNull(fieldValue)) {
|
||||||
|
filedValueStr = fieldValue.toString();
|
||||||
|
}
|
||||||
|
droolStr = StrUtil.replace(droolStr, name, filedValueStr, false);
|
||||||
}
|
}
|
||||||
String filedValueStr = "";
|
|
||||||
if (ObjectUtil.isNotNull(fieldValue)) {
|
log.info("after - droolStr = {}", droolStr);
|
||||||
filedValueStr = fieldValue.toString();
|
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
||||||
}
|
log.info("jsonArray = {}", jsonArray);
|
||||||
droolStr = StrUtil.replace(droolStr, name, filedValueStr, false);
|
|
||||||
|
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
||||||
|
|
||||||
|
log.info("condition template = {}", conditionResult);
|
||||||
|
// AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
||||||
|
// AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
||||||
|
Object executeB = AviatorEvaluator.execute(conditionResult);
|
||||||
|
log.info("ProfitCenter01Cmp-{} = {}", conditionResult, executeB);
|
||||||
|
boolean aBoolean = BooleanUtil.toBoolean(executeB.toString());
|
||||||
|
log.info("ProfitCenter01Cmp-aBoolean = {}", aBoolean);
|
||||||
|
return aBoolean;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("after - droolStr = {}", droolStr);
|
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
|
||||||
log.info("jsonArray = {}", jsonArray);
|
|
||||||
|
|
||||||
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
|
||||||
|
|
||||||
log.info("condition template = {}", conditionResult);
|
|
||||||
AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
|
||||||
AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
|
||||||
Object executeB = AviatorEvaluator.execute(conditionResult);
|
|
||||||
log.info("ProfitCenter01Cmp-{} = {}", conditionResult, executeB);
|
|
||||||
boolean aBoolean = BooleanUtil.toBoolean(executeB.toString());
|
|
||||||
log.info("ProfitCenter01Cmp-aBoolean = {}", aBoolean);
|
|
||||||
return aBoolean;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package com.example.liteflow.mysql.cmp.profitCenter;
|
package com.example.liteflow.mysql.cmp.profitCenter;
|
||||||
|
|
||||||
|
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||||
|
import com.example.liteflow.mysql.enums.BaseDataAttributionEnum;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
|
import com.example.liteflow.mysql.service.BaseDataService;
|
||||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||||
import com.yomahub.liteflow.core.NodeComponent;
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
* @date: 2022年12月05日 10:15
|
* @date: 2022年12月05日 10:15
|
||||||
|
@ -13,13 +18,18 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ProfitCenter01SoutCmp extends NodeComponent {
|
public class ProfitCenter01SoutCmp extends NodeComponent {
|
||||||
|
|
||||||
private static final String profitCenter01Code = "P350401029";
|
// private static final String profitCenter01Code = "P350401029";
|
||||||
private static final String profitCenter01Name = "仓干配物流部成本中心";
|
// private static final String profitCenter01Name = "仓干配物流部成本中心";
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BaseDataService baseDataService;
|
||||||
@Override
|
@Override
|
||||||
public void process() {
|
public void process() {
|
||||||
|
BaseDataEntity codeBaseData = baseDataService.getByTypeAndName("sout", BaseDataAttributionEnum.profitCenter.getAttribution(), "profitCenter01Code");
|
||||||
|
BaseDataEntity nameBaseData = baseDataService.getByTypeAndName("sout", BaseDataAttributionEnum.profitCenter.getAttribution(), "profitCenter01Name");
|
||||||
BaseCenter baseCenter = this.getRequestData();
|
BaseCenter baseCenter = this.getRequestData();
|
||||||
|
String profitCenter01Code = codeBaseData.getContent();
|
||||||
|
String profitCenter01Name = nameBaseData.getContent();
|
||||||
baseCenter.setProfitCenterCode(profitCenter01Code);
|
baseCenter.setProfitCenterCode(profitCenter01Code);
|
||||||
baseCenter.setProfitCenterName(profitCenter01Name);
|
baseCenter.setProfitCenterName(profitCenter01Name);
|
||||||
baseCenter.setProfitCenterGenerateCode(profitCenter01Code + profitCenter01Name);
|
baseCenter.setProfitCenterGenerateCode(profitCenter01Code + profitCenter01Name);
|
||||||
|
|
|
@ -10,21 +10,16 @@ import cn.hutool.json.JSONUtil;
|
||||||
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||||
import com.example.liteflow.mysql.enums.BaseDataAttributionEnum;
|
import com.example.liteflow.mysql.enums.BaseDataAttributionEnum;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
import com.example.liteflow.mysql.model.CostCenter;
|
|
||||||
import com.example.liteflow.mysql.model.ProfitCenter;
|
|
||||||
import com.example.liteflow.mysql.service.BaseDataService;
|
import com.example.liteflow.mysql.service.BaseDataService;
|
||||||
|
import com.example.liteflow.mysql.service.BaseRoleService;
|
||||||
import com.example.liteflow.mysql.util.ConditionParser;
|
import com.example.liteflow.mysql.util.ConditionParser;
|
||||||
import com.googlecode.aviator.AviatorEvaluator;
|
import com.googlecode.aviator.AviatorEvaluator;
|
||||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||||
import com.yomahub.liteflow.core.NodeIfComponent;
|
import com.yomahub.liteflow.core.NodeIfComponent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.assertj.core.util.Lists;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
|
@ -34,44 +29,51 @@ import java.util.Map;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ProfitCenter02Cmp extends NodeIfComponent {
|
public class ProfitCenter02Cmp extends NodeIfComponent {
|
||||||
|
|
||||||
private static final String drool = "[{\"$or\": [{\"$and\": [{\"$contains\": [businessType, businessTypeList]}, {\"$contains\": [salesman, salesmanList]}]}]}, {\"$or\": [{\"$and\": [{\"$contains\":[sectionClassification, sectionClassificationList]}, {\"$contains\": [businessType, businessTypeList]}]}]}]";
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BaseDataService baseDataService;
|
private BaseDataService baseDataService;
|
||||||
|
@Resource
|
||||||
|
private BaseRoleService baseRoleService;
|
||||||
|
private static final String baseRoleName = "profitCenter02Cmp";
|
||||||
@Override
|
@Override
|
||||||
public boolean processIf() throws Exception {
|
public boolean processIf() throws Exception {
|
||||||
BaseCenter requestData = this.getRequestData();
|
BaseCenter requestData = this.getRequestData();
|
||||||
String droolStr = drool;
|
String droolStr = baseRoleService.getByName(baseRoleName);
|
||||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
log.info("ProfitCenter02Cmp-droolStr = {}", droolStr);
|
||||||
for (Field field : fields) {
|
if (StrUtil.isNotBlank(droolStr)) {
|
||||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||||
String name = field.getName();
|
for (Field field : fields) {
|
||||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.profitCenter.getAttribution());
|
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
String name = field.getName();
|
||||||
String content = baseDataEntity.getContent();
|
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.profitCenter.getAttribution());
|
||||||
String contentName = baseDataEntity.getContentName();
|
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||||
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
String content = baseDataEntity.getContent();
|
||||||
|
String contentName = baseDataEntity.getContentName();
|
||||||
|
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
||||||
|
}
|
||||||
|
String filedValueStr = "";
|
||||||
|
if (ObjectUtil.isNotNull(fieldValue)) {
|
||||||
|
filedValueStr = fieldValue.toString();
|
||||||
|
}
|
||||||
|
droolStr = StrUtil.replace(droolStr, name, filedValueStr, false);
|
||||||
}
|
}
|
||||||
String filedValueStr = "";
|
|
||||||
if (ObjectUtil.isNotNull(fieldValue)) {
|
log.info("after - droolStr = {}", droolStr);
|
||||||
filedValueStr = fieldValue.toString();
|
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
||||||
}
|
log.info("jsonArray = {}", jsonArray);
|
||||||
droolStr = StrUtil.replace(droolStr, name, filedValueStr, false);
|
|
||||||
|
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
||||||
|
|
||||||
|
log.info("condition template = {}", conditionResult);
|
||||||
|
// AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
||||||
|
// AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
||||||
|
Object executeB = AviatorEvaluator.execute(conditionResult);
|
||||||
|
log.info("CostCenter02Cmp-{} = {}", conditionResult, executeB);
|
||||||
|
boolean aBoolean = BooleanUtil.toBoolean(executeB.toString());
|
||||||
|
log.info("CostCenter02Cmp-aBoolean = {}", aBoolean);
|
||||||
|
return aBoolean;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("after - droolStr = {}", droolStr);
|
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(droolStr);
|
|
||||||
log.info("jsonArray = {}", jsonArray);
|
|
||||||
|
|
||||||
String conditionResult = ConditionParser.parseCondition(jsonArray);
|
|
||||||
|
|
||||||
log.info("condition template = {}", conditionResult);
|
|
||||||
AviatorEvaluator.addStaticFunctions("CollUtil", CollUtil.class);
|
|
||||||
AviatorEvaluator.addStaticFunctions("StrUtil", StrUtil.class);
|
|
||||||
Object executeB = AviatorEvaluator.execute(conditionResult);
|
|
||||||
log.info("CostCenter02Cmp-{} = {}", conditionResult, executeB);
|
|
||||||
boolean aBoolean = BooleanUtil.toBoolean(executeB.toString());
|
|
||||||
log.info("CostCenter02Cmp-aBoolean = {}", aBoolean);
|
|
||||||
return aBoolean;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
package com.example.liteflow.mysql.cmp.profitCenter;
|
package com.example.liteflow.mysql.cmp.profitCenter;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||||
|
import com.example.liteflow.mysql.enums.BaseDataAttributionEnum;
|
||||||
import com.example.liteflow.mysql.model.BaseCenter;
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
|
import com.example.liteflow.mysql.service.BaseDataService;
|
||||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||||
import com.yomahub.liteflow.core.NodeComponent;
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
* @date: 2022年12月05日 10:15
|
* @date: 2022年12月05日 10:15
|
||||||
|
@ -13,17 +19,24 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ProfitCenter02SoutCmp extends NodeComponent {
|
public class ProfitCenter02SoutCmp extends NodeComponent {
|
||||||
|
|
||||||
private static final String profitCenter02Code = "P350401027";
|
// private static final String profitCenter02Code = "P350401027";
|
||||||
private static final String profitCenter02Name = "商品车物流部成本中心";
|
// private static final String profitCenter02Name = "商品车物流部成本中心";
|
||||||
|
@Resource
|
||||||
|
private BaseDataService baseDataService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process() {
|
public void process() {
|
||||||
|
BaseDataEntity codeBaseData = baseDataService.getByTypeAndName("sout", BaseDataAttributionEnum.profitCenter.getAttribution(), "profitCenter02Code");
|
||||||
|
BaseDataEntity nameBaseData = baseDataService.getByTypeAndName("sout", BaseDataAttributionEnum.profitCenter.getAttribution(), "profitCenter02Name");
|
||||||
BaseCenter baseCenter = this.getRequestData();
|
BaseCenter baseCenter = this.getRequestData();
|
||||||
baseCenter.setProfitCenterCode(profitCenter02Code);
|
if (ObjectUtil.isNotNull(codeBaseData) && ObjectUtil.isNotNull(nameBaseData)) {
|
||||||
baseCenter.setProfitCenterName(profitCenter02Name);
|
String profitCenter02Code = codeBaseData.getContent();
|
||||||
baseCenter.setProfitCenterGenerateCode(profitCenter02Code + profitCenter02Name);
|
String profitCenter02Name = nameBaseData.getContent();
|
||||||
baseCenter.setGenerateCode(null);
|
baseCenter.setProfitCenterCode(profitCenter02Code);
|
||||||
|
baseCenter.setProfitCenterName(profitCenter02Name);
|
||||||
|
baseCenter.setProfitCenterGenerateCode(profitCenter02Code + profitCenter02Name);
|
||||||
|
baseCenter.setGenerateCode(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,7 @@ import com.yomahub.liteflow.core.FlowExecutor;
|
||||||
import com.yomahub.liteflow.enums.FlowParserTypeEnum;
|
import com.yomahub.liteflow.enums.FlowParserTypeEnum;
|
||||||
import com.yomahub.liteflow.flow.FlowBus;
|
import com.yomahub.liteflow.flow.FlowBus;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -30,8 +27,6 @@ public class BaseRoleController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BaseRoleService baseRoleService;
|
private BaseRoleService baseRoleService;
|
||||||
@Resource
|
|
||||||
private FlowExecutor flowExecutor;
|
|
||||||
@PostMapping("/createRole")
|
@PostMapping("/createRole")
|
||||||
public void createRole(@RequestBody RoleForm roleForm) {
|
public void createRole(@RequestBody RoleForm roleForm) {
|
||||||
baseRoleService.createRole(roleForm);
|
baseRoleService.createRole(roleForm);
|
||||||
|
@ -40,4 +35,9 @@ public class BaseRoleController {
|
||||||
// System.out.println(JSONUtil.toJsonStr(collect));
|
// System.out.println(JSONUtil.toJsonStr(collect));
|
||||||
// flowExecutor.reloadRule();
|
// flowExecutor.reloadRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/testCreateRole")
|
||||||
|
public void testCreateRole() {
|
||||||
|
baseRoleService.testCreateRole();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package com.example.liteflow.mysql.controller;
|
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.role.RoleForm;
|
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.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
|
@ -25,12 +27,17 @@ public class ChainController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/executeChain/{chainName}")
|
@GetMapping("/executeChain/{chainName}")
|
||||||
public void executeChain(@PathVariable("chainName") String chainName) {
|
public List<BaseCenter> executeChain(@PathVariable("chainName") String chainName) {
|
||||||
chainService.executeChain(chainName);
|
return chainService.executeChain(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/deleteChain/{id}")
|
||||||
|
public String deleteChain(@PathVariable("id") String id) {
|
||||||
|
return chainService.deleteChain(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,6 @@ import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||||
*/
|
*/
|
||||||
public interface BaseDataService extends IService<BaseDataEntity> {
|
public interface BaseDataService extends IService<BaseDataEntity> {
|
||||||
BaseDataEntity getByType(String type, String attribution);
|
BaseDataEntity getByType(String type, String attribution);
|
||||||
|
BaseDataEntity getByTypeAndName(String type, String attribution, String contentName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,7 @@ import com.example.liteflow.mysql.model.role.RoleForm;
|
||||||
public interface BaseRoleService {
|
public interface BaseRoleService {
|
||||||
void createRole(RoleForm roleForm);
|
void createRole(RoleForm roleForm);
|
||||||
|
|
||||||
|
void testCreateRole();
|
||||||
|
|
||||||
String getByName(String roleName);
|
String getByName(String roleName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.example.liteflow.mysql.service;
|
package com.example.liteflow.mysql.service;
|
||||||
|
|
||||||
import com.example.liteflow.mysql.entity.ChainEntity;
|
import com.example.liteflow.mysql.entity.ChainEntity;
|
||||||
|
import com.example.liteflow.mysql.model.BaseCenter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
|
@ -9,7 +12,9 @@ import com.example.liteflow.mysql.entity.ChainEntity;
|
||||||
public interface ChainService {
|
public interface ChainService {
|
||||||
void createChain(ChainEntity chainEntity);
|
void createChain(ChainEntity chainEntity);
|
||||||
|
|
||||||
void executeChain(String chainName);
|
List<BaseCenter> executeChain(String chainName);
|
||||||
|
|
||||||
ChainEntity getChainName(String chainName);
|
ChainEntity getChainName(String chainName);
|
||||||
|
|
||||||
|
String deleteChain(String id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,20 @@ import org.springframework.stereotype.Service;
|
||||||
public class BaseDataServiceImpl extends ServiceImpl<BaseDataMapper, BaseDataEntity> implements BaseDataService {
|
public class BaseDataServiceImpl extends ServiceImpl<BaseDataMapper, BaseDataEntity> implements BaseDataService {
|
||||||
@Override
|
@Override
|
||||||
public BaseDataEntity getByType(String type, String attribution) {
|
public BaseDataEntity getByType(String type, String attribution) {
|
||||||
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);
|
||||||
return this.getOne(queryWrapper);
|
return this.getOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseDataEntity getByTypeAndName(String type, String attribution, String contentName) {
|
||||||
|
// log.info("type = {}, attribution = {}", type, attribution);
|
||||||
|
LambdaQueryWrapper<BaseDataEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(BaseDataEntity::getType, type)
|
||||||
|
.eq(BaseDataEntity::getAttribution, attribution)
|
||||||
|
.eq(BaseDataEntity::getContentName, contentName);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,18 @@ import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.example.liteflow.mysql.entity.BaseRoleEntity;
|
import com.example.liteflow.mysql.entity.BaseRoleEntity;
|
||||||
|
import com.example.liteflow.mysql.enums.MathOperatorEnum;
|
||||||
import com.example.liteflow.mysql.mapper.BaseRoleMapper;
|
import com.example.liteflow.mysql.mapper.BaseRoleMapper;
|
||||||
|
import com.example.liteflow.mysql.model.role.Match;
|
||||||
import com.example.liteflow.mysql.model.role.Role;
|
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.example.liteflow.mysql.util.RoleUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.assertj.core.util.Lists;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -45,17 +49,261 @@ public class BaseRoleServiceImpl extends ServiceImpl<BaseRoleMapper, BaseRoleEnt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testCreateRole() {
|
||||||
|
List<RoleForm> roleForms =
|
||||||
|
Lists.newArrayList(
|
||||||
|
this.costCenter01Cmp(),
|
||||||
|
this.costCenter02Cmp(),
|
||||||
|
this.profitCenter01Cmp(),
|
||||||
|
this.profitCenter02Cmp()
|
||||||
|
);
|
||||||
|
roleForms.forEach(roleForm -> {
|
||||||
|
List<Role> roles = roleForm.getRoles();
|
||||||
|
String roleName = roleForm.getRoleName();
|
||||||
|
LambdaQueryWrapper<BaseRoleEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(BaseRoleEntity::getRoleName, roleName);
|
||||||
|
BaseRoleEntity baseRoleEntity = this.getOne(queryWrapper);
|
||||||
|
if(ObjectUtil.isNull(baseRoleEntity)) {
|
||||||
|
baseRoleEntity = new BaseRoleEntity();
|
||||||
|
baseRoleEntity.setRoleStr(JSONUtil.toJsonStr(roles));
|
||||||
|
baseRoleEntity.setRoleName(JSONUtil.toJsonStr(roleName));
|
||||||
|
this.save(baseRoleEntity);
|
||||||
|
} else {
|
||||||
|
baseRoleEntity.setRoleStr(JSONUtil.toJsonStr(roles));
|
||||||
|
this.updateById(baseRoleEntity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getByName(String roleName) {
|
public String getByName(String roleName) {
|
||||||
LambdaQueryWrapper<BaseRoleEntity> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BaseRoleEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(BaseRoleEntity::getRoleName, roleName);
|
queryWrapper.eq(BaseRoleEntity::getRoleName, roleName);
|
||||||
BaseRoleEntity baseRoleEntity = this.getOne(queryWrapper);
|
BaseRoleEntity baseRoleEntity = this.getOne(queryWrapper);
|
||||||
String roleStr = baseRoleEntity.getRoleStr();
|
if (ObjectUtil.isNotNull(baseRoleEntity)) {
|
||||||
log.info("roleStr = {}", roleStr);
|
String roleStr = baseRoleEntity.getRoleStr();
|
||||||
|
log.info("roleStr = {}", roleStr);
|
||||||
// JSONObject jsonObject = JSONUtil.parseObj(roleStr);
|
// JSONObject jsonObject = JSONUtil.parseObj(roleStr);
|
||||||
List<Role> roles = JSONUtil.toList(JSONUtil.parseArray(roleStr), Role.class);
|
List<Role> roles = JSONUtil.toList(JSONUtil.parseArray(roleStr), Role.class);
|
||||||
List<Map<String, Object>> collect = roles.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
List<Map<String, Object>> collect = roles.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
||||||
return JSONUtil.toJsonStr(collect);
|
return JSONUtil.toJsonStr(collect);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleForm costCenter01Cmp() {
|
||||||
|
Role role = new Role();
|
||||||
|
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
|
Role child = new Role();
|
||||||
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
List<Match> matches = new ArrayList<>();
|
||||||
|
Match match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("sectionClassification");
|
||||||
|
match.setMatchingContent("sectionClassificationList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("businessType");
|
||||||
|
match.setMatchingContent("businessTypeList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("salesman");
|
||||||
|
match.setMatchingContent("salesmanList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("businessCategory");
|
||||||
|
match.setMatchingContent("businessCategoryList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
child.setMatches(matches);
|
||||||
|
List<Role> children = Lists.newArrayList(child);
|
||||||
|
role.setChildren(children);
|
||||||
|
|
||||||
|
List<Role> roles = Lists.newArrayList(role);
|
||||||
|
RoleForm roleForm = new RoleForm();
|
||||||
|
roleForm.setRoles(roles);
|
||||||
|
roleForm.setRoleName("costCenter01Cmp");
|
||||||
|
return roleForm;
|
||||||
|
// System.out.println(JSONUtil.toJsonStr(roles));
|
||||||
|
// List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||||
|
// System.out.println(JSONUtil.toJsonStr(collect));
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleForm costCenter02Cmp() {
|
||||||
|
Role role = new Role();
|
||||||
|
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
|
Role child = new Role();
|
||||||
|
child.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
|
Role sun = new Role();
|
||||||
|
sun.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
List<Match> matches = new ArrayList<>();
|
||||||
|
Match match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("sectionClassification");
|
||||||
|
match.setMatchingContent("sectionClassificationList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("salesman");
|
||||||
|
match.setMatchingContent("salesmanList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
sun.setMatches(matches);
|
||||||
|
List<Role> sunList = Lists.newArrayList(sun);
|
||||||
|
child.setChildren(sunList);
|
||||||
|
List<Role> children = Lists.newArrayList(child);
|
||||||
|
role.setChildren(children);
|
||||||
|
|
||||||
|
|
||||||
|
List<Match> matches2 = new ArrayList<>();
|
||||||
|
Match match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("businessType");
|
||||||
|
match2.setMatchingContent("businessTypeList");
|
||||||
|
matches2.add(match2);
|
||||||
|
Role role2 = new Role();
|
||||||
|
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
role2.setMatches(matches2);
|
||||||
|
|
||||||
|
List<Role> roles = Lists.newArrayList(role, role2);
|
||||||
|
RoleForm roleForm = new RoleForm();
|
||||||
|
roleForm.setRoles(roles);
|
||||||
|
roleForm.setRoleName("costCenter02Cmp");
|
||||||
|
return roleForm;
|
||||||
|
// baseRoleService.createRole(roleForm);
|
||||||
|
// System.out.println(JSONUtil.toJsonStr(roles));
|
||||||
|
// List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||||
|
// System.out.println(JSONUtil.toJsonStr(collect));
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleForm profitCenter01Cmp() {
|
||||||
|
Role role = new Role();
|
||||||
|
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
|
Role child = new Role();
|
||||||
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
|
||||||
|
List<Match> matches = new ArrayList<>();
|
||||||
|
Match match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("businessType");
|
||||||
|
match.setMatchingContent("businessTypeList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("salesman");
|
||||||
|
match.setMatchingContent("salesmanList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("businessCategory");
|
||||||
|
match.setMatchingContent("businessCategoryList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
child.setMatches(matches);
|
||||||
|
List<Role> children = Lists.newArrayList(child);
|
||||||
|
role.setChildren(children);
|
||||||
|
|
||||||
|
Role role2 = new Role();
|
||||||
|
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
Role child2 = new Role();
|
||||||
|
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
List<Match> matches2 = new ArrayList<>();
|
||||||
|
Match match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("sectionClassification");
|
||||||
|
match2.setMatchingContent("sectionClassificationList");
|
||||||
|
matches2.add(match2);
|
||||||
|
|
||||||
|
match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("businessType");
|
||||||
|
match2.setMatchingContent("businessTypeList");
|
||||||
|
matches2.add(match2);
|
||||||
|
child2.setMatches(matches2);
|
||||||
|
List<Role> children2 = Lists.newArrayList(child2);
|
||||||
|
role2.setChildren(children2);
|
||||||
|
|
||||||
|
List<Role> roles = Lists.newArrayList(role, role2);
|
||||||
|
RoleForm roleForm = new RoleForm();
|
||||||
|
roleForm.setRoles(roles);
|
||||||
|
roleForm.setRoleName("profitCenter01Cmp");
|
||||||
|
return roleForm;
|
||||||
|
// baseRoleService.createRole(roleForm);
|
||||||
|
// System.out.println(JSONUtil.toJsonStr(roles));
|
||||||
|
// List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||||
|
// System.out.println(JSONUtil.toJsonStr(collect));
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleForm profitCenter02Cmp() {
|
||||||
|
Role role = new Role();
|
||||||
|
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
|
Role child = new Role();
|
||||||
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
|
||||||
|
List<Match> matches = new ArrayList<>();
|
||||||
|
Match match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("businessType");
|
||||||
|
match.setMatchingContent("businessTypeList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("salesman");
|
||||||
|
match.setMatchingContent("salesmanList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
child.setMatches(matches);
|
||||||
|
List<Role> children = Lists.newArrayList(child);
|
||||||
|
role.setChildren(children);
|
||||||
|
|
||||||
|
Role role2 = new Role();
|
||||||
|
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
Role child2 = new Role();
|
||||||
|
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
List<Match> matches2 = new ArrayList<>();
|
||||||
|
Match match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("sectionClassification");
|
||||||
|
match2.setMatchingContent("sectionClassificationList");
|
||||||
|
matches2.add(match2);
|
||||||
|
|
||||||
|
match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("businessType");
|
||||||
|
match2.setMatchingContent("businessTypeList");
|
||||||
|
matches2.add(match2);
|
||||||
|
child2.setMatches(matches2);
|
||||||
|
List<Role> children2 = Lists.newArrayList(child2);
|
||||||
|
role2.setChildren(children2);
|
||||||
|
|
||||||
|
List<Role> roles = Lists.newArrayList(role, role2);
|
||||||
|
RoleForm roleForm = new RoleForm();
|
||||||
|
roleForm.setRoles(roles);
|
||||||
|
roleForm.setRoleName("profitCenter02Cmp");
|
||||||
|
return roleForm;
|
||||||
|
// baseRoleService.createRole(roleForm);
|
||||||
|
// System.out.println(JSONUtil.toJsonStr(roles));
|
||||||
|
// List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||||
|
// System.out.println(JSONUtil.toJsonStr(collect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class ChainServiceImpl extends ServiceImpl<ChainMapper, ChainEntity> imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeChain(String chainName) {
|
public List<BaseCenter> executeChain(String chainName) {
|
||||||
List<BaseCenter> list = this.generateCostCenterTestData();
|
List<BaseCenter> list = this.generateCostCenterTestData();
|
||||||
log.info("before-list = {}", JSONUtil.toJsonStr(list));
|
log.info("before-list = {}", JSONUtil.toJsonStr(list));
|
||||||
list.forEach(item -> {
|
list.forEach(item -> {
|
||||||
|
@ -56,6 +56,7 @@ public class ChainServiceImpl extends ServiceImpl<ChainMapper, ChainEntity> imp
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
log.info("after-list = {}", JSONUtil.toJsonStr(list));
|
log.info("after-list = {}", JSONUtil.toJsonStr(list));
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BaseCenter> generateCostCenterTestData() {
|
private List<BaseCenter> generateCostCenterTestData() {
|
||||||
|
@ -90,4 +91,15 @@ public class ChainServiceImpl extends ServiceImpl<ChainMapper, ChainEntity> imp
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String deleteChain(String id) {
|
||||||
|
LambdaQueryWrapper<ChainEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(ChainEntity::getId, id);
|
||||||
|
if (this.remove(queryWrapper)) {
|
||||||
|
return "删除成功";
|
||||||
|
} else {
|
||||||
|
return "删除失败";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.example.liteflow.mysql.LiteflowMysqlApplication;
|
import com.example.liteflow.mysql.LiteflowMysqlApplication;
|
||||||
import com.example.liteflow.mysql.enums.MathOperatorEnum;
|
import com.example.liteflow.mysql.enums.MathOperatorEnum;
|
||||||
|
@ -24,8 +25,8 @@ import java.util.stream.Collectors;
|
||||||
* @author: 陈韦龙
|
* @author: 陈韦龙
|
||||||
* @date: 2022年12月07日 16:26
|
* @date: 2022年12月07日 16:26
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
//@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = LiteflowMysqlApplication.class)
|
//@SpringBootTest(classes = LiteflowMysqlApplication.class)
|
||||||
public class MyTest {
|
public class MyTest {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -295,7 +296,6 @@ public class MyTest {
|
||||||
|
|
||||||
List<Match> matches2 = new ArrayList<>();
|
List<Match> matches2 = new ArrayList<>();
|
||||||
Match match2 = new Match();
|
Match match2 = new Match();
|
||||||
match2 = new Match();
|
|
||||||
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
match2.setMatchingValue("businessType");
|
match2.setMatchingValue("businessType");
|
||||||
match2.setMatchingContent("businessTypeList");
|
match2.setMatchingContent("businessTypeList");
|
||||||
|
@ -313,6 +313,122 @@ public class MyTest {
|
||||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||||
System.out.println(JSONUtil.toJsonStr(collect));
|
System.out.println(JSONUtil.toJsonStr(collect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test09() {
|
||||||
|
Role role = new Role();
|
||||||
|
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
|
Role child = new Role();
|
||||||
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
|
||||||
|
List<Match> matches = new ArrayList<>();
|
||||||
|
Match match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("businessType");
|
||||||
|
match.setMatchingContent("businessTypeList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("salesman");
|
||||||
|
match.setMatchingContent("salesmanList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("businessCategory");
|
||||||
|
match.setMatchingContent("businessCategoryList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
child.setMatches(matches);
|
||||||
|
List<Role> children = Lists.newArrayList(child);
|
||||||
|
role.setChildren(children);
|
||||||
|
|
||||||
|
Role role2 = new Role();
|
||||||
|
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
Role child2 = new Role();
|
||||||
|
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
List<Match> matches2 = new ArrayList<>();
|
||||||
|
Match match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("sectionClassification");
|
||||||
|
match2.setMatchingContent("sectionClassificationList");
|
||||||
|
matches2.add(match2);
|
||||||
|
|
||||||
|
match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("businessType");
|
||||||
|
match2.setMatchingContent("businessTypeList");
|
||||||
|
matches2.add(match2);
|
||||||
|
child2.setMatches(matches2);
|
||||||
|
List<Role> children2 = Lists.newArrayList(child2);
|
||||||
|
role2.setChildren(children2);
|
||||||
|
|
||||||
|
List<Role> roles = Lists.newArrayList(role, role2);
|
||||||
|
RoleForm roleForm = new RoleForm();
|
||||||
|
roleForm.setRoles(roles);
|
||||||
|
roleForm.setRoleName("profitCenter01Cmp");
|
||||||
|
// baseRoleService.createRole(roleForm);
|
||||||
|
System.out.println(JSONUtil.toJsonStr(roles));
|
||||||
|
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||||
|
System.out.println(JSONUtil.toJsonStr(collect));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test10() {
|
||||||
|
Role role = new Role();
|
||||||
|
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
|
||||||
|
Role child = new Role();
|
||||||
|
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
|
||||||
|
List<Match> matches = new ArrayList<>();
|
||||||
|
Match match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("businessType");
|
||||||
|
match.setMatchingContent("businessTypeList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
match = new Match();
|
||||||
|
match.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match.setMatchingValue("salesman");
|
||||||
|
match.setMatchingContent("salesmanList");
|
||||||
|
matches.add(match);
|
||||||
|
|
||||||
|
child.setMatches(matches);
|
||||||
|
List<Role> children = Lists.newArrayList(child);
|
||||||
|
role.setChildren(children);
|
||||||
|
|
||||||
|
Role role2 = new Role();
|
||||||
|
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||||
|
Role child2 = new Role();
|
||||||
|
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||||
|
List<Match> matches2 = new ArrayList<>();
|
||||||
|
Match match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("sectionClassification");
|
||||||
|
match2.setMatchingContent("sectionClassificationList");
|
||||||
|
matches2.add(match2);
|
||||||
|
|
||||||
|
match2 = new Match();
|
||||||
|
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||||
|
match2.setMatchingValue("businessType");
|
||||||
|
match2.setMatchingContent("businessTypeList");
|
||||||
|
matches2.add(match2);
|
||||||
|
child2.setMatches(matches2);
|
||||||
|
List<Role> children2 = Lists.newArrayList(child2);
|
||||||
|
role2.setChildren(children2);
|
||||||
|
|
||||||
|
List<Role> roles = Lists.newArrayList(role, role2);
|
||||||
|
RoleForm roleForm = new RoleForm();
|
||||||
|
roleForm.setRoles(roles);
|
||||||
|
roleForm.setRoleName("profitCenter02Cmp");
|
||||||
|
// baseRoleService.createRole(roleForm);
|
||||||
|
System.out.println(JSONUtil.toJsonStr(roles));
|
||||||
|
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||||
|
System.out.println(JSONUtil.toJsonStr(collect));
|
||||||
|
}
|
||||||
private Map<String, Object> parseRole(Role role) {
|
private Map<String, Object> parseRole(Role role) {
|
||||||
List<Match> matchList = role.getMatches();
|
List<Match> matchList = role.getMatches();
|
||||||
List<Role> roleChildren = role.getChildren();
|
List<Role> roleChildren = role.getChildren();
|
||||||
|
@ -372,4 +488,9 @@ public class MyTest {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateId () {
|
||||||
|
System.out.println(RandomUtil.randomNumbers(16));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue