enhancement #ID8XF9 对QLExpress4的支持

This commit is contained in:
everywhere.z
2025-12-02 00:35:29 +08:00
parent 1b07db84c8
commit 3b43111f18
35 changed files with 477 additions and 12 deletions

View File

@@ -16,7 +16,7 @@
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-script-javax-pro</artifactId>
<version>${revision}</version>
<version>${liteflow-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -16,7 +16,7 @@
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-script-javax</artifactId>
<version>${revision}</version>
<version>${liteflow-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -11,11 +11,11 @@ public class CmpConfig {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "b")
public void processA(NodeComponent bindCmp, @LiteflowFact("name") String name) {
System.out.println(name);
// System.out.println(name);
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "c")
public void processB(NodeComponent bindCmp, @LiteflowFact("age") int age) {
System.out.println(age);
// System.out.println(age);
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>liteflow-benchmark</artifactId>
<groupId>com.yomahub</groupId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>liteflow-benchmark-compile</artifactId>
</project>

View File

@@ -0,0 +1,58 @@
package com.yomahub.liteflow.benchmark;
import cn.hutool.core.date.StopWatch;
import cn.hutool.core.util.StrUtil;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.Resource;
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:application.properties")
@SpringBootTest(classes = TestCompile.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.benchmark.cmp" })
public class TestCompile {
@Resource
private FlowExecutor flowExecutor;
@Test
public void test1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("channelSenderChain", null, BatchMessageResultContext.class);
BatchMessageResultContext context = response.getFirstContextBean();
if (response.isSuccess()){
System.out.println("执行成功,最终选择的渠道是:" + context.getFinalResultChannel());
}else{
System.out.println("执行失败:" + response.getCause());
}
}
@Test
public void test2() throws Exception {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
String el = "selectBestChannel = THEN(WHEN(channel1Query, channel2Query, channel3Query,channel4Query, channel5Query, channel6Query),channelSelector).id(\"branch1\");\n" +
" selectBizChannel = THEN(biz1,SWITCH(if_2).to(channel3,channel4,SWITCH(if_3).to(channel5, channel6).id(\"s3\")).id(\"s2\")).id(\"branch2\");\n" +
" THEN(packageData.tag(\"{}\"),SWITCH(if_1).to(channel1,channel2,selectBestChannel,selectBizChannel),batchSender);";
for (int i = 1; i <= 20000; i++) {
LiteFlowChainELBuilder.createChain().setChainId("chain_build_"+i).setEL(StrUtil.format(el,i)).build();
}
stopWatch.stop();
System.out.println(StrUtil.format("耗时:{}",stopWatch.getTotalTimeMillis()));
}
}

View File

@@ -0,0 +1,21 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.core.NodeComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Random;
@LiteflowComponent(id = "batchSender", name = "批量发送器")
public class BatchSenderCmp extends NodeComponent {
private static final Logger log = LoggerFactory.getLogger(BatchSenderCmp.class);
@Override
public void process() throws Exception {
BatchMessageResultContext context = this.getFirstContextBean();
log.info("最终获取到的渠道为:[{}]", context.getFinalResultChannel());
}
}

View File

@@ -0,0 +1,13 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.Random;
@LiteflowComponent(id = "biz1", name = "获取业务动态值")
public class Biz1Cmp extends NodeComponent {
@Override
public void process() throws Exception {
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent(id = "channel1", name = "返回渠道1")
public class Channel1Cmp extends NodeComponent {
@Override
public void process() throws Exception {
BatchMessageResultContext context = this.getFirstContextBean();
context.setFinalResultChannel("channel1");
}
}

View File

@@ -0,0 +1,18 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.vo.QueryVO;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.Random;
@LiteflowComponent(id = "channel1Query", name = "获取渠道1剩余量")
public class Channel1QueryCmp extends NodeComponent {
@Override
public void process() throws Exception {
//mock下渠道1有2w条剩余量
BatchMessageResultContext context = this.getFirstContextBean();
context.addQueryVO(new QueryVO("channel1", 20000));
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent(id = "channel2", name = "返回渠道2")
public class Channel2Cmp extends NodeComponent {
@Override
public void process() throws Exception {
BatchMessageResultContext context = this.getFirstContextBean();
context.setFinalResultChannel("channel2");
}
}

View File

@@ -0,0 +1,19 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.vo.QueryVO;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.Random;
@LiteflowComponent(id = "channel2Query", name = "获取渠道2剩余量")
public class Channel2QueryCmp extends NodeComponent {
@Override
public void process() throws Exception {
//mock下渠道2有1w条剩余量
BatchMessageResultContext context = this.getFirstContextBean();
context.addQueryVO(new QueryVO("channel2", 10000));
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent(id = "channel3", name = "返回渠道3")
public class Channel3Cmp extends NodeComponent {
@Override
public void process() throws Exception {
BatchMessageResultContext context = this.getFirstContextBean();
context.setFinalResultChannel("channel3");
}
}

View File

@@ -0,0 +1,19 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.vo.QueryVO;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.Random;
@LiteflowComponent(id = "channel3Query", name = "获取渠道3剩余量")
public class Channel3QueryCmp extends NodeComponent {
@Override
public void process() throws Exception {
//mock下渠道3有10w条剩余量
BatchMessageResultContext context = this.getFirstContextBean();
context.addQueryVO(new QueryVO("channel3", 100000));
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent(id = "channel4", name = "返回渠道4")
public class Channel4Cmp extends NodeComponent {
@Override
public void process() throws Exception {
BatchMessageResultContext context = this.getFirstContextBean();
context.setFinalResultChannel("channel4");
}
}

View File

@@ -0,0 +1,18 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.vo.QueryVO;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.Random;
@LiteflowComponent(id = "channel4Query", name = "获取渠道4剩余量")
public class Channel4QueryCmp extends NodeComponent {
@Override
public void process() throws Exception {
//mock下渠道4有7w条剩余量
BatchMessageResultContext context = this.getFirstContextBean();
context.addQueryVO(new QueryVO("channel4", 70000));
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent(id = "channel5", name = "返回渠道5")
public class Channel5Cmp extends NodeComponent {
@Override
public void process() throws Exception {
BatchMessageResultContext context = this.getFirstContextBean();
context.setFinalResultChannel("channel5");
}
}

View File

@@ -0,0 +1,18 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.vo.QueryVO;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.Random;
@LiteflowComponent(id = "channel5Query", name = "获取渠道5剩余量")
public class Channel5QueryCmp extends NodeComponent {
@Override
public void process() throws Exception {
//mock下渠道5有5000条剩余量
BatchMessageResultContext context = this.getFirstContextBean();
context.addQueryVO(new QueryVO("channel5", 5000));
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent(id = "channel6", name = "返回渠道6")
public class Channel6Cmp extends NodeComponent {
@Override
public void process() throws Exception {
BatchMessageResultContext context = this.getFirstContextBean();
context.setFinalResultChannel("channel6");
}
}

View File

@@ -0,0 +1,17 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.vo.QueryVO;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent(id = "channel6Query", name = "获取渠道6剩余量")
public class Channel6QueryCmp extends NodeComponent {
@Override
public void process() throws Exception {
//mock下渠道6有3w条剩余量
BatchMessageResultContext context = this.getFirstContextBean();
context.addQueryVO(new QueryVO("channel6", 30000));
}
}

View File

@@ -0,0 +1,24 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.benchmark.context.BatchMessageResultContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.benchmark.vo.QueryVO;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.List;
@LiteflowComponent(id = "channelSelector", name = "渠道余量最大选择器")
public class ChannelSelectorCmp extends NodeComponent {
@Override
public void process() throws Exception {
BatchMessageResultContext context = this.getFirstContextBean();
List<QueryVO> queryList = context.getQueryResultList();
//选择渠道余量最大的
QueryVO vo = queryList.stream().min((o1, o2) -> o2.getAvailCount() - o1.getAvailCount()).orElse(null);
assert vo != null;
context.setFinalResultChannel(vo.getChannel());
}
}

View File

@@ -0,0 +1,15 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeSwitchComponent;
import java.util.Random;
@LiteflowComponent(id = "if_1", name = "业务判断1")
public class IF1SwitchCmp extends NodeSwitchComponent {
@Override
public String processSwitch() throws Exception {
//这里写死跳到并行获取剩余量那条分支,你可以改成其他分支测试
return "branch1";
}
}

View File

@@ -0,0 +1,15 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeSwitchComponent;
import java.util.Random;
@LiteflowComponent(id = "if_2", name = "业务判断2")
public class IF2SwitchCmp extends NodeSwitchComponent {
@Override
public String processSwitch() throws Exception {
//这里写死,你可以改成其他分支
return "s3";
}
}

View File

@@ -0,0 +1,16 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeSwitchComponent;
import java.util.Random;
@LiteflowComponent(id = "if_3", name = "业务判断3")
public class IF3SwitchCmp extends NodeSwitchComponent {
@Override
public String processSwitch() throws Exception {
//这里写死,你可以改成其他
return "channel5";
}
}

View File

@@ -0,0 +1,13 @@
package com.yomahub.liteflow.benchmark.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.Random;
@LiteflowComponent(id = "packageData", name = "组装数据")
public class PackageDataCmp extends NodeComponent {
@Override
public void process() throws Exception {
}
}

View File

@@ -0,0 +1,37 @@
package com.yomahub.liteflow.benchmark.context;
import com.yomahub.liteflow.benchmark.vo.QueryVO;
import java.util.ArrayList;
import java.util.List;
public class BatchMessageResultContext {
private List<QueryVO> queryResultList;
private String finalResultChannel;
public List<QueryVO> getQueryResultList() {
return queryResultList;
}
public void setQueryResultList(List<QueryVO> queryResultList) {
this.queryResultList = queryResultList;
}
public String getFinalResultChannel() {
return finalResultChannel;
}
public void setFinalResultChannel(String finalResultChannel) {
this.finalResultChannel = finalResultChannel;
}
public void addQueryVO(QueryVO queryVO){
if (queryResultList == null){
queryResultList = new ArrayList<>();
}
queryResultList.add(queryVO);
}
}

View File

@@ -0,0 +1,31 @@
package com.yomahub.liteflow.benchmark.vo;
public class QueryVO {
//渠道名称
private String channel;
//剩余短信包数量
private int availCount;
public QueryVO(String channel, int availCount) {
this.channel = channel;
this.availCount = availCount;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public int getAvailCount() {
return availCount;
}
public void setAvailCount(int availCount) {
this.availCount = availCount;
}
}

View File

@@ -0,0 +1,2 @@
liteflow.rule-source=flow.xml
liteflow.fast-load=true

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="channelSenderChain">
selectBestChannel = THEN(WHEN(channel1Query, channel2Query, channel3Query,channel4Query, channel5Query, channel6Query),channelSelector).id("branch1");
selectBizChannel = THEN(biz1,SWITCH(if_2).to(channel3,channel4,SWITCH(if_3).to(channel5, channel6).id("s3")).id("s2")).id("branch2");
THEN(packageData,SWITCH(if_1).to(channel1,channel2,selectBestChannel,selectBizChannel),batchSender);
</chain>
</flow>

View File

@@ -16,7 +16,7 @@
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-script-groovy</artifactId>
<version>${revision}</version>
<version>${liteflow-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -16,7 +16,7 @@
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-script-java</artifactId>
<version>${revision}</version>
<version>${liteflow-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -16,7 +16,7 @@
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-script-javax-pro</artifactId>
<version>${revision}</version>
<version>${liteflow-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -16,7 +16,7 @@
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-script-javax</artifactId>
<version>${revision}</version>
<version>${liteflow-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -16,13 +16,14 @@
<properties>
<jmh.version>1.37</jmh.version>
<liteflow-version>2.15.2</liteflow-version>
</properties>
<dependencies>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-spring-boot-starter</artifactId>
<version>${revision}</version>
<version>${liteflow-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -48,5 +49,6 @@
<module>liteflow-benchmark-script-groovy</module>
<module>liteflow-benchmark-common</module>
<module>liteflow-benchmark-common-example</module>
<module>liteflow-benchmark-compile</module>
</modules>
</project>