增加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.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();
String code = costCenterContext.getCode();
String name = costCenterContext.getName();

View File

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

View File

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