Skip to main content

快速开始

选择使用方式

1. 独立运行

准备环境:

  • docker-compose
  • git(或打开网址下载压缩包)
git clone https://gitee.com/codingchangtheworld/logic-ide-demo.git
docker-compose up -d

访问 http://localhost:4052/

2. 在现有项目集成

在现有spring boot 2/3中集成:

2.1 配置pom.xml

最新版本见:发布记录

<dependency>
<groupId>com.aims.logic</groupId>
<artifactId>logic-ide</artifactId>
<version>xxx</version>
</dependency>
<repositories>
<repository>
<id>nexus</id>
<name>科大智联镜像仓库</name>
<url>https://nexus.aimstek.cn/repository/maven-public</url>
</repository>
</repositories>

2.2 在入口添加包扫描路径

@SpringBootApplication(scanBasePackages = {"com.aims", "原项目的包名"})
@SpringBootConfiguration

2.3 执行脚本添加依赖表

数据库脚本变更记录

2.4 配置application.yaml

  • 设置配置文件夹目录和包扫描路径
logic:
config-dir: ./config/logic-configs
scan-package-names: com.aims.wms.infrastructure.service
  • 若项目未使用数据库链接,则添加配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.154.31:30010/logic_demo?useUnicode=true&characterEncoding=gbk&autoReconnect=true&failOverReadOnly=false
username: dbx
password: 1234@qwer

3. 开始使用

3.1 启动项目,打开/logic设计页

参照在线体验进行逻辑设计;

3.2 执行逻辑

  • 使用sdk方法
@Autowired
LogicRunnerService logic;

@PostMapping("/wms-agg/open/logic/{logicId}")
public LogicRunResult runLogic(@PathVariable String logicId, @RequestBody String body) {
return logic.runByJson(logicId, body);
}
  • 使用内置webapi sdk内置运行时服务,通过id定位逻辑。
post:/api/runtime/logic/v1/run-api/{id}
post:/api/runtime/logic/v1/run-biz/{id}/{bizId}

内置webapi实现源码:

@PostMapping("/api/runtime/logic/v1/run-api/{id}")
public ApiResult run(@RequestHeader Map<String, String> headers, @RequestBody(required = false) JSONObject body, @PathVariable String id, @RequestParam(value = "debug", required = false, defaultValue = "false") boolean debug) {
JSONObject customEnv = new JSONObject();
customEnv.put("HEADERS", headers);
var rep = runner.runByJson(id, body, customEnv);
var res = ApiResult.fromLogicRunResult(rep);
if (debug) {
res.setDebug(rep.getLogicLog());
}
return res;
}

3.3 相关类型

LogicRunResult:返回类型

//返回类型
public class LogicRunResult {
public LogicRunResult(){
}
boolean success=true;
String msg;
Object data;
//执行日志
LogicLog logicLog;
}