增加xml匹配

This commit is contained in:
chenweilong 2022-12-01 18:25:36 +08:00
parent a9a2dc2ce2
commit 8073f9f44f
4 changed files with 127 additions and 37 deletions

View File

@ -29,7 +29,11 @@ public class LiteFlowCommand implements CommandLineRunner {
costCenter.setSalesman("仓干配物流部(物流)"); costCenter.setSalesman("仓干配物流部(物流)");
costCenter.setBusinessCategory("全货船业务"); costCenter.setBusinessCategory("全货船业务");
LiteflowResponse response = flowExecutor.execute2Resp("costCenter", costCenter, CostCenterContext.class); // 数据库匹配
// LiteflowResponse response = flowExecutor.execute2Resp("costCenter", costCenter, CostCenterContext.class);
// xml匹配
LiteflowResponse response = flowExecutor.execute2Resp("mainChain", costCenter, CostCenterContext.class);
CostCenterContext costCenterContext = response.getFirstContextBean(); CostCenterContext costCenterContext = response.getFirstContextBean();
String code = costCenterContext.getCode(); String code = costCenterContext.getCode();
String name = costCenterContext.getName(); String name = costCenterContext.getName();

View File

@ -1,18 +1,18 @@
spring.application.name=liteflow-mysql #spring.application.name=liteflow-mysql
liteflow.rule-source-ext-data={\ #liteflow.rule-source-ext-data={\
"url":"jdbc:mysql://localhost:3306/test_db",\ # "url":"jdbc:mysql://localhost:3306/test_db",\
"driverClassName":"com.mysql.cj.jdbc.Driver",\ # "driverClassName":"com.mysql.cj.jdbc.Driver",\
"username":"root",\ # "username":"root",\
"password":"123456",\ # "password":"123456",\
"applicationName": "demo",\ # "applicationName": "demo",\
"chainTableName": "chain",\ # "chainTableName": "chain",\
"chainApplicationNameField": "application_name",\ # "chainApplicationNameField": "application_name",\
"chainNameField": "chain_name",\ # "chainNameField": "chain_name",\
"elDataField": "el_data",\ # "elDataField": "el_data",\
"scriptTableName": "script",\ # "scriptTableName": "script",\
"scriptApplicationNameField": "application_name",\ # "scriptApplicationNameField": "application_name",\
"scriptIdField": "script_id",\ # "scriptIdField": "script_id",\
"scriptNameField": "script_name",\ # "scriptNameField": "script_name",\
"scriptDataField": "script_data",\ # "scriptDataField": "script_data",\
"scriptTypeField": "script_type" # "scriptTypeField": "script_type"
} # }

View File

@ -3,21 +3,22 @@ spring:
name: liteflow-mysql name: liteflow-mysql
liteflow: liteflow:
rule-source-ext-data-map: rule-source: liteflow/*.el.xml
url: jdbc:mysql://localhost:3306/test_db # rule-source-ext-data-map:
driverClassName: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://localhost:3306/test_db
username: root # driverClassName: com.mysql.cj.jdbc.Driver
password: 123456 # username: root
applicationName: demo # password: 123456
#以下是chain表的配置这个一定得有 # applicationName: demo
chainTableName: chain # #以下是chain表的配置这个一定得有
chainApplicationNameField: application_name # chainTableName: chain
chainNameField: chain_name # chainApplicationNameField: application_name
elDataField: el_data # chainNameField: chain_name
#以下是script表的配置如果你没使用到脚本下面可以不配置 # elDataField: el_data
scriptTableName: script # #以下是script表的配置如果你没使用到脚本下面可以不配置
scriptApplicationNameField: application_name # scriptTableName: script
scriptIdField: script_id # scriptApplicationNameField: application_name
scriptNameField: script_name # scriptIdField: script_id
scriptDataField: script_data # scriptNameField: script_name
scriptTypeField: script_type # scriptDataField: script_data
# scriptTypeField: script_type

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="mainChain">
THEN(
s3, s4, s5, s6,
IF (sectionClassification,
IF (businessType,
IF (salesman,
IF (businessCategory,
s7,
s9
),
s9
),
s9
),
IF (businessType,
IF (salesman,
s8,
s9
),
IF (businessType,
s8,
s9
)
)
)
);
</chain>
<nodes>
<node id="s3" name="sectionClassification" type="script">
<![CDATA[
def globalSectionClassificationList = ["汇差","手续费","成本科目"]
globalSectionClassification.setGlobalSectionClassificationList(globalSectionClassificationList)
]]>
</node>
<node id="s4" name="globalBusinessType" type="script">
<![CDATA[
def globalBusinessTypeList = ["货代","报关","船代","散杂货"]
globalBusinessType.setGlobalBusinessTypeList(globalBusinessTypeList)
]]>
</node>
<node id="s5" name="salesman" type="script">
<![CDATA[
def globalSalesmanList = ["仓干配物流部(物流)"]
salesman.setGlobalSalesmanList(globalSalesmanList)
]]>
</node>
<node id="s6" name="businessCategory" type="script">
<![CDATA[
def globalBusinessCategoryList = ["全货船业务","进出岛仓干配"]
businessCategory.setGlobalBusinessCategoryList(globalBusinessCategoryList)
]]>
</node>
<node id="s7" name="costCenter01" type="script">
<![CDATA[
def costCenter01Code = "P350401028"
costCenterContext.setCode(costCenter01Code)
def costCenter01Name = "仓干配物流部利润中心"
costCenterContext.setName(costCenter01Name)
costCenterContext.setGenerateCode(costCenter01Code + costCenter01Name)
]]>
</node>
<node id="s8" name="costCenter02" type="script">
<![CDATA[
def costCenter02Code = "P350401026"
costCenterContext.setCode(costCenter02Code)
def costCenter02Name = "商品车物流部利润中心"
costCenterContext.setName(costCenter02Name)
costCenterContext.setGenerateCode(costCenter02Code + costCenter02Name)
]]>
</node>
<node id="s9" name="sout" type="script">
<![CDATA[
def defaultName = "无匹配项"
costCenterContext.setGenerateCode(defaultName)
]]>
</node>
</nodes>
</flow>