parent
e9bb9ab48a
commit
cf4600f404
|
@ -1,12 +1,15 @@
|
|||
package com.example.liteflow.mysql;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.example.liteflow.mysql.model.BaseCenter;
|
||||
import com.example.liteflow.mysql.model.CostCenter;
|
||||
import com.example.liteflow.mysql.model.CostCenterContext;
|
||||
import com.example.liteflow.mysql.model.ProfitCenter;
|
||||
import com.googlecode.aviator.AviatorEvaluator;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import org.assertj.core.util.Lists;
|
||||
|
@ -20,7 +23,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class LiteFlowCommand {
|
||||
public class LiteFlowCommand
|
||||
// implements CommandLineRunner
|
||||
{
|
||||
|
||||
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> costCenterList = Lists.newArrayList("cost01AndCost02", "cost01", "cost02");
|
||||
|
||||
|
||||
// @Override
|
||||
public void run(String... args) throws Exception {
|
||||
public void run1(String... args) throws Exception {
|
||||
// 事实对象
|
||||
// CostCenter costCenter = new CostCenter();
|
||||
// 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;
|
||||
@Resource
|
||||
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";
|
||||
|
||||
|
@ -44,36 +43,41 @@ public class CostCenter01Cmp extends NodeIfComponent {
|
|||
log.info("requestData = {}", JSONUtil.toJsonStr(requestData));
|
||||
String droolStr = baseRoleService.getByName(baseRoleName);
|
||||
log.info("droolStr = {}", droolStr);
|
||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||
for (Field field : fields) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||
String name = field.getName();
|
||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.costCenter.getAttribution());
|
||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||
String content = baseDataEntity.getContent();
|
||||
String contentName = baseDataEntity.getContentName();
|
||||
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
||||
if (StrUtil.isNotBlank(droolStr)) {
|
||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||
for (Field field : fields) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||
String name = field.getName();
|
||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.costCenter.getAttribution());
|
||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||
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)) {
|
||||
filedValueStr = fieldValue.toString();
|
||||
}
|
||||
droolStr = StrUtil.replace(droolStr, name, filedValueStr, 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;
|
||||
} 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;
|
||||
|
||||
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.CostCenter;
|
||||
import com.example.liteflow.mysql.service.BaseDataService;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
* @date: 2022年12月05日 10:15
|
||||
|
@ -14,13 +19,18 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class CostCenter01SoutCmp extends NodeComponent {
|
||||
|
||||
private static final String costCenter01Code = "P350401028";
|
||||
private static final String costCenter01Name = "仓干配物流部利润中心";
|
||||
|
||||
// private static final String costCenter01Code = "P350401028";
|
||||
// private static final String costCenter01Name = "仓干配物流部利润中心";
|
||||
|
||||
@Resource
|
||||
private BaseDataService baseDataService;
|
||||
|
||||
@Override
|
||||
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.setCostCenterCode(costCenter01Code);
|
||||
baseCenter.setCostCenterName(costCenter01Name);
|
||||
|
|
|
@ -34,8 +34,6 @@ import java.util.Map;
|
|||
@Slf4j
|
||||
public class CostCenter02Cmp extends NodeIfComponent {
|
||||
|
||||
private static final String drool = "[{\"$or\": [{\"$or\": [{\"$and\": [{\"$contains\": [sectionClassification, sectionClassificationList]}, {\"$contains\": [salesman, salesmanList]}]}]}, {\"$or\": [{\"$contains\": [businessType, businessTypeList]}]}]}]";
|
||||
|
||||
@Resource
|
||||
private BaseDataService baseDataService;
|
||||
@Resource
|
||||
|
@ -45,38 +43,42 @@ public class CostCenter02Cmp extends NodeIfComponent {
|
|||
public boolean processIf() throws Exception {
|
||||
BaseCenter requestData = this.getRequestData();
|
||||
String droolStr = baseRoleService.getByName(baseRoleName);
|
||||
log.info("droolStr = {}", droolStr);
|
||||
log.info("CostCenter02Cmp-droolStr = {}", droolStr);
|
||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||
for (Field field : fields) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||
String name = field.getName();
|
||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.costCenter.getAttribution());
|
||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||
String content = baseDataEntity.getContent();
|
||||
String contentName = baseDataEntity.getContentName();
|
||||
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
||||
if (StrUtil.isNotBlank(droolStr)) {
|
||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||
for (Field field : fields) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||
String name = field.getName();
|
||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.costCenter.getAttribution());
|
||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||
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)) {
|
||||
filedValueStr = fieldValue.toString();
|
||||
}
|
||||
droolStr = StrUtil.replace(droolStr, name, filedValueStr, 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;
|
||||
} 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;
|
||||
|
||||
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.CostCenter;
|
||||
import com.example.liteflow.mysql.service.BaseDataService;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
* @date: 2022年12月05日 10:15
|
||||
|
@ -14,14 +19,19 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class CostCenter02SoutCmp extends NodeComponent {
|
||||
|
||||
private static final String costCenter02Code = "P350401026";
|
||||
private static final String costCenter02Name = "商品车物流部利润中心";
|
||||
|
||||
// private static final String costCenter02Code = "P350401026";
|
||||
// private static final String costCenter02Name = "商品车物流部利润中心";
|
||||
|
||||
@Resource
|
||||
private BaseDataService baseDataService;
|
||||
|
||||
@Override
|
||||
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();
|
||||
String costCenter02Code = codeBaseData.getContent();
|
||||
String costCenter02Name = nameBaseData.getContent();
|
||||
baseCenter.setCostCenterCode(costCenter02Code);
|
||||
baseCenter.setCostCenterName(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.model.BaseCenter;
|
||||
import com.example.liteflow.mysql.service.BaseDataService;
|
||||
import com.example.liteflow.mysql.service.BaseRoleService;
|
||||
import com.example.liteflow.mysql.util.ConditionParser;
|
||||
import com.googlecode.aviator.AviatorEvaluator;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
|
@ -28,44 +29,51 @@ import java.lang.reflect.Field;
|
|||
@Slf4j
|
||||
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
|
||||
private BaseDataService baseDataService;
|
||||
@Resource
|
||||
private BaseRoleService baseRoleService;
|
||||
private static final String baseRoleName = "profitCenter01Cmp";
|
||||
@Override
|
||||
public boolean processIf() throws Exception {
|
||||
BaseCenter requestData = this.getRequestData();
|
||||
String droolStr = drool;
|
||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||
for (Field field : fields) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||
String name = field.getName();
|
||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.profitCenter.getAttribution());
|
||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||
String content = baseDataEntity.getContent();
|
||||
String contentName = baseDataEntity.getContentName();
|
||||
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
||||
String droolStr = baseRoleService.getByName(baseRoleName);
|
||||
log.info("ProfitCenter01Cmp-droolStr = {}", droolStr);
|
||||
if (StrUtil.isNotBlank(droolStr)) {
|
||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||
for (Field field : fields) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||
String name = field.getName();
|
||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.profitCenter.getAttribution());
|
||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||
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)) {
|
||||
filedValueStr = fieldValue.toString();
|
||||
}
|
||||
droolStr = StrUtil.replace(droolStr, name, filedValueStr, 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;
|
||||
} 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;
|
||||
|
||||
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.service.BaseDataService;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
* @date: 2022年12月05日 10:15
|
||||
|
@ -13,13 +18,18 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class ProfitCenter01SoutCmp extends NodeComponent {
|
||||
|
||||
private static final String profitCenter01Code = "P350401029";
|
||||
private static final String profitCenter01Name = "仓干配物流部成本中心";
|
||||
|
||||
// private static final String profitCenter01Code = "P350401029";
|
||||
// private static final String profitCenter01Name = "仓干配物流部成本中心";
|
||||
|
||||
@Resource
|
||||
private BaseDataService baseDataService;
|
||||
@Override
|
||||
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();
|
||||
String profitCenter01Code = codeBaseData.getContent();
|
||||
String profitCenter01Name = nameBaseData.getContent();
|
||||
baseCenter.setProfitCenterCode(profitCenter01Code);
|
||||
baseCenter.setProfitCenterName(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.enums.BaseDataAttributionEnum;
|
||||
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.BaseRoleService;
|
||||
import com.example.liteflow.mysql.util.ConditionParser;
|
||||
import com.googlecode.aviator.AviatorEvaluator;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeIfComponent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.assertj.core.util.Lists;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
|
@ -34,44 +29,51 @@ import java.util.Map;
|
|||
@Slf4j
|
||||
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
|
||||
private BaseDataService baseDataService;
|
||||
@Resource
|
||||
private BaseRoleService baseRoleService;
|
||||
private static final String baseRoleName = "profitCenter02Cmp";
|
||||
@Override
|
||||
public boolean processIf() throws Exception {
|
||||
BaseCenter requestData = this.getRequestData();
|
||||
String droolStr = drool;
|
||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||
for (Field field : fields) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||
String name = field.getName();
|
||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.profitCenter.getAttribution());
|
||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||
String content = baseDataEntity.getContent();
|
||||
String contentName = baseDataEntity.getContentName();
|
||||
droolStr = StrUtil.replace(droolStr, contentName, content, false);
|
||||
String droolStr = baseRoleService.getByName(baseRoleName);
|
||||
log.info("ProfitCenter02Cmp-droolStr = {}", droolStr);
|
||||
if (StrUtil.isNotBlank(droolStr)) {
|
||||
Field[] fields = ReflectUtil.getFields(BaseCenter.class);
|
||||
for (Field field : fields) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(requestData, field);
|
||||
String name = field.getName();
|
||||
BaseDataEntity baseDataEntity = baseDataService.getByType(name, BaseDataAttributionEnum.profitCenter.getAttribution());
|
||||
if (ObjectUtil.isNotNull(baseDataEntity)) {
|
||||
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)) {
|
||||
filedValueStr = fieldValue.toString();
|
||||
}
|
||||
droolStr = StrUtil.replace(droolStr, name, filedValueStr, 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;
|
||||
} 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;
|
||||
|
||||
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.service.BaseDataService;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
* @date: 2022年12月05日 10:15
|
||||
|
@ -13,17 +19,24 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class ProfitCenter02SoutCmp extends NodeComponent {
|
||||
|
||||
private static final String profitCenter02Code = "P350401027";
|
||||
private static final String profitCenter02Name = "商品车物流部成本中心";
|
||||
|
||||
// private static final String profitCenter02Code = "P350401027";
|
||||
// private static final String profitCenter02Name = "商品车物流部成本中心";
|
||||
@Resource
|
||||
private BaseDataService baseDataService;
|
||||
|
||||
@Override
|
||||
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.setProfitCenterCode(profitCenter02Code);
|
||||
baseCenter.setProfitCenterName(profitCenter02Name);
|
||||
baseCenter.setProfitCenterGenerateCode(profitCenter02Code + profitCenter02Name);
|
||||
baseCenter.setGenerateCode(null);
|
||||
if (ObjectUtil.isNotNull(codeBaseData) && ObjectUtil.isNotNull(nameBaseData)) {
|
||||
String profitCenter02Code = codeBaseData.getContent();
|
||||
String profitCenter02Name = nameBaseData.getContent();
|
||||
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.flow.FlowBus;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
@ -30,8 +27,6 @@ public class BaseRoleController {
|
|||
|
||||
@Resource
|
||||
private BaseRoleService baseRoleService;
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
@PostMapping("/createRole")
|
||||
public void createRole(@RequestBody RoleForm roleForm) {
|
||||
baseRoleService.createRole(roleForm);
|
||||
|
@ -40,4 +35,9 @@ public class BaseRoleController {
|
|||
// System.out.println(JSONUtil.toJsonStr(collect));
|
||||
// flowExecutor.reloadRule();
|
||||
}
|
||||
|
||||
@GetMapping("/testCreateRole")
|
||||
public void testCreateRole() {
|
||||
baseRoleService.testCreateRole();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
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.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
|
@ -25,12 +27,17 @@ public class ChainController {
|
|||
}
|
||||
|
||||
@GetMapping("/executeChain/{chainName}")
|
||||
public void executeChain(@PathVariable("chainName") String chainName) {
|
||||
chainService.executeChain(chainName);
|
||||
public List<BaseCenter> executeChain(@PathVariable("chainName") String chainName) {
|
||||
return chainService.executeChain(chainName);
|
||||
}
|
||||
|
||||
@GetMapping("/getChainByName/{chainName}")
|
||||
public ChainEntity getChainByName(@PathVariable("chainName") String 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> {
|
||||
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 {
|
||||
void createRole(RoleForm roleForm);
|
||||
|
||||
void testCreateRole();
|
||||
|
||||
String getByName(String roleName);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.example.liteflow.mysql.service;
|
||||
|
||||
import com.example.liteflow.mysql.entity.ChainEntity;
|
||||
import com.example.liteflow.mysql.model.BaseCenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: 陈韦龙
|
||||
|
@ -9,7 +12,9 @@ import com.example.liteflow.mysql.entity.ChainEntity;
|
|||
public interface ChainService {
|
||||
void createChain(ChainEntity chainEntity);
|
||||
|
||||
void executeChain(String chainName);
|
||||
List<BaseCenter> executeChain(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 {
|
||||
@Override
|
||||
public BaseDataEntity getByType(String type, String attribution) {
|
||||
log.info("type = {}, attribution = {}", type, attribution);
|
||||
// log.info("type = {}, attribution = {}", type, attribution);
|
||||
LambdaQueryWrapper<BaseDataEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BaseDataEntity::getType, type)
|
||||
.eq(BaseDataEntity::getAttribution, attribution);
|
||||
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.extension.service.impl.ServiceImpl;
|
||||
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.model.role.Match;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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
|
||||
public String getByName(String roleName) {
|
||||
LambdaQueryWrapper<BaseRoleEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BaseRoleEntity::getRoleName, roleName);
|
||||
BaseRoleEntity baseRoleEntity = this.getOne(queryWrapper);
|
||||
String roleStr = baseRoleEntity.getRoleStr();
|
||||
log.info("roleStr = {}", roleStr);
|
||||
if (ObjectUtil.isNotNull(baseRoleEntity)) {
|
||||
String roleStr = baseRoleEntity.getRoleStr();
|
||||
log.info("roleStr = {}", roleStr);
|
||||
// JSONObject jsonObject = JSONUtil.parseObj(roleStr);
|
||||
List<Role> roles = JSONUtil.toList(JSONUtil.parseArray(roleStr), Role.class);
|
||||
List<Map<String, Object>> collect = roles.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
||||
return JSONUtil.toJsonStr(collect);
|
||||
List<Role> roles = JSONUtil.toList(JSONUtil.parseArray(roleStr), Role.class);
|
||||
List<Map<String, Object>> collect = roles.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
||||
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
|
||||
public void executeChain(String chainName) {
|
||||
public List<BaseCenter> executeChain(String chainName) {
|
||||
List<BaseCenter> list = this.generateCostCenterTestData();
|
||||
log.info("before-list = {}", JSONUtil.toJsonStr(list));
|
||||
list.forEach(item -> {
|
||||
|
@ -56,6 +56,7 @@ public class ChainServiceImpl extends ServiceImpl<ChainMapper, ChainEntity> imp
|
|||
}
|
||||
});
|
||||
log.info("after-list = {}", JSONUtil.toJsonStr(list));
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<BaseCenter> generateCostCenterTestData() {
|
||||
|
@ -90,4 +91,15 @@ public class ChainServiceImpl extends ServiceImpl<ChainMapper, ChainEntity> imp
|
|||
|
||||
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.util.RandomUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.example.liteflow.mysql.LiteflowMysqlApplication;
|
||||
import com.example.liteflow.mysql.enums.MathOperatorEnum;
|
||||
|
@ -24,8 +25,8 @@ import java.util.stream.Collectors;
|
|||
* @author: 陈韦龙
|
||||
* @date: 2022年12月07日 16:26
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = LiteflowMysqlApplication.class)
|
||||
//@RunWith(SpringRunner.class)
|
||||
//@SpringBootTest(classes = LiteflowMysqlApplication.class)
|
||||
public class MyTest {
|
||||
|
||||
@Resource
|
||||
|
@ -295,7 +296,6 @@ public class MyTest {
|
|||
|
||||
List<Match> matches2 = new ArrayList<>();
|
||||
Match match2 = new Match();
|
||||
match2 = new Match();
|
||||
match2.setConditionalOperators(MathOperatorEnum.contains.getOperator());
|
||||
match2.setMatchingValue("businessType");
|
||||
match2.setMatchingContent("businessTypeList");
|
||||
|
@ -313,6 +313,122 @@ public class MyTest {
|
|||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
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) {
|
||||
List<Match> matchList = role.getMatches();
|
||||
List<Role> roleChildren = role.getChildren();
|
||||
|
@ -372,4 +488,9 @@ public class MyTest {
|
|||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateId () {
|
||||
System.out.println(RandomUtil.randomNumbers(16));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue