132 Commits

Author SHA1 Message Date
e30884ee09 Merge remote-tracking branch 'origin/master' 2026-05-21 14:12:36 +08:00
aa1357cf13 添加 .DS_Store 到 .gitignore 文件 2026-05-21 14:12:30 +08:00
80e90cf87f 重构连接器逻辑,优化贝塞尔曲线绘制,增加 U 形绕行处理 2026-05-21 14:11:22 +08:00
MHW
b48c17821d Merge branch 'refs/heads/develop' 2026-05-13 14:00:23 +08:00
MHW
487fffc2d2 规则界面优化补充 2026-05-13 14:00:00 +08:00
MHW
1e7e639ee0 Merge branch 'refs/heads/develop' 2026-05-07 17:44:58 +08:00
MHW
4f71fc815b 规则界面优化 2026-05-07 17:44:43 +08:00
MHW
1cde930bb1 Merge branch 'refs/heads/develop' 2026-05-07 16:56:27 +08:00
MHW
c9125c8902 决策树 2026-05-07 16:56:16 +08:00
MHW
59bd191810 Merge branch 'refs/heads/develop' 2026-05-07 15:45:50 +08:00
MHW
7a16b0643e 界面优化 2026-05-07 15:45:32 +08:00
MHW
2509b30382 界面优化 2026-05-07 15:40:57 +08:00
MHW
ec716df946 解决节点参数int默认值sql执行错误问题 2026-04-21 11:26:26 +08:00
abe0315536 调整行为树挂载到平台的逻辑,修复发送平台变量未正确渲染
Co-authored-by: Copilot <copilot@github.com>
2026-04-20 20:06:08 +08:00
4252b3f514 Merge remote-tracking branch 'origin/master' 2026-04-20 19:05:44 +08:00
MHW
c597c3c01f PUT接口改json 2026-04-20 17:10:01 +08:00
MHW
4933c2c14e 智唐任务解析 2026-04-20 16:59:52 +08:00
3d0ba1d77c Merge remote-tracking branch 'origin/master' 2026-04-20 16:22:50 +08:00
MHW
0cd8455c9d 添加behaviortreeId字段返回 2026-04-20 16:02:54 +08:00
ced438c725 Merge remote-tracking branch 'origin/master' 2026-04-20 14:56:46 +08:00
9bea71e414 优化平台参数处理逻辑,支持逗号分隔值的独立分组
Co-authored-by: Copilot <copilot@github.com>
2026-04-20 14:54:21 +08:00
MHW
2ea04b98f8 修改平台关联的行为树id 2026-04-20 14:33:12 +08:00
MHW
8afd87b690 细节修改 2026-04-20 14:16:28 +08:00
MHW
71bb45f6a0 实体补充 2026-04-20 10:31:09 +08:00
MHW
931804555f Merge remote-tracking branch 'origin/master' 2026-04-20 09:39:58 +08:00
MHW
ae01a2aa01 旧接口字段更新BUG修复 2026-04-20 09:38:58 +08:00
c3a6661d2a 化行为树加载
Co-authored-by: Copilot <copilot@github.com>
2026-04-17 21:43:53 +08:00
1de4f9db8d 添加反向树加载功能,重构节点和树的选择逻辑
Co-authored-by: Copilot <copilot@github.com>
2026-04-17 19:30:19 +08:00
65d99bb7a8 Merge remote-tracking branch 'origin/master' 2026-04-17 17:59:12 +08:00
MHW
39b04d8b73 旧接口字段更新BUG修复 2026-04-17 17:55:26 +08:00
4d5f966b0a Merge remote-tracking branch 'origin/master' 2026-04-17 15:47:01 +08:00
MHW
0cd142bb82 旧接口字段更新 2026-04-17 15:45:44 +08:00
bcaaf1da4f Merge remote-tracking branch 'origin/master' 2026-04-17 15:24:08 +08:00
MHW
d310c5ae7b Merge remote-tracking branch 'origin/master' 2026-04-17 14:53:00 +08:00
MHW
1e38170420 接口新增,知识图谱 2026-04-17 14:52:10 +08:00
4330be8d0e 优化节点初始化逻辑 2026-04-16 15:52:36 +08:00
28cd9c131b 补充类型 2026-04-16 13:46:59 +08:00
27a5dc8e02 修复节点添加和删除时的报错 2026-04-16 12:48:25 +08:00
243a42ca5c 优化场景和行为树列表项的选中状态显示 2026-04-16 11:25:10 +08:00
b56d57af44 调整行为树保存信息 2026-04-16 10:44:46 +08:00
012939829c Merge remote-tracking branch 'origin/master' 2026-04-16 10:20:03 +08:00
82027fc6aa 默认收起行为树场景列表 2026-04-16 10:19:53 +08:00
MHW
6610e06991 Merge remote-tracking branch 'origin/master' 2026-04-16 09:59:45 +08:00
MHW
40655dd557 新增行为树增加场景id字段 2026-04-16 09:59:34 +08:00
5079f17df0 更新返回按钮逻辑,添加从场景页面跳转的状态管理 2026-04-15 19:34:19 +08:00
913dea7afa 添加行为树页面的场景选择 2026-04-15 19:24:25 +08:00
6f48a06438 Merge remote-tracking branch 'origin/master' 2026-04-15 17:56:50 +08:00
6941954e14 调整行为树命令位置参数,增加位置标题样式并调整布局 2026-04-15 17:56:02 +08:00
MHW
2c834b9b2f 复制行为树区分多次复制同一行为树 2026-04-15 17:32:38 +08:00
MHW
447aef0fe3 Merge remote-tracking branch 'origin/master' 2026-04-15 17:30:39 +08:00
MHW
873e31970f Merge branch 'refs/heads/develop' 2026-04-15 17:30:30 +08:00
MHW
b39a85a074 复制行为树区分多次复制同一行为树 2026-04-15 17:30:25 +08:00
d8c3429163 Merge remote-tracking branch 'origin/master' 2026-04-15 17:22:30 +08:00
dbbc8a27c3 完善阵位分配命令的变量数据加载 2026-04-15 17:22:22 +08:00
MHW
8e96285c0a Merge remote-tracking branch 'origin/master' 2026-04-15 17:17:54 +08:00
MHW
559a550157 根据平台id获取该行为树的下属:BUG修复 2026-04-15 17:17:23 +08:00
a08e061979 更新 .gitignore 文件以排除新的缓存文件和锁定文件,类型文件项目运行时自动生成 2026-04-15 16:34:20 +08:00
8975777cd5 Merge remote-tracking branch 'origin/master' 2026-04-15 16:32:38 +08:00
MHW
f51619526a 根据平台id获取该行为树的下属:BUG修复 2026-04-15 16:28:49 +08:00
MHW
0691fddbf1 Merge remote-tracking branch 'origin/master' 2026-04-15 16:27:01 +08:00
MHW
2d60a8b90f 根据平台id获取该行为树的下属 2026-04-15 16:26:49 +08:00
e92423ee54 Merge remote-tracking branch 'origin/master' 2026-04-15 15:53:37 +08:00
99dfb6f009 为参数设置标签添加样式,限制标签宽度并处理文本溢出 2026-04-15 15:46:44 +08:00
MHW
4404d0e411 规则展示,bug修复 2026-04-15 15:30:20 +08:00
MHW
a67e3e42ba 优化规则代码,行为树的pagelist请求添加场景id与平台id条件 2026-04-15 13:54:09 +08:00
44ff489c08 调整文件结构 2026-04-15 13:42:07 +08:00
3c06e77c6d Merge remote-tracking branch 'origin/master' 2026-04-15 11:21:32 +08:00
e555c95058 修复转换数据不完整问题 2026-04-15 10:50:02 +08:00
MHW
8839c65d7f Merge remote-tracking branch 'origin/master' 2026-04-15 09:38:37 +08:00
MHW
f9eb10c783 根据场景id获取总指挥的行为树的原数据 2026-04-15 09:38:15 +08:00
949e059c8f 恢复挂载行为树请求 2026-04-14 18:08:03 +08:00
9858787570 Merge branch 'feature-transform-node-data' 2026-04-14 17:30:54 +08:00
5a8c707340 添加行为决策树管理的场景数据到节点数据的自动转换逻辑 2026-04-14 17:27:31 +08:00
e1fe2cf7da Merge remote-tracking branch 'origin/master' into feature-transform-node-data 2026-04-14 17:03:50 +08:00
MHW
3ae6a693e1 BUG修复:字段映射不上 2026-04-14 17:00:49 +08:00
MHW
178bceabbb Merge remote-tracking branch 'origin/master' 2026-04-14 16:46:10 +08:00
MHW
6969fe5744 技术要求:规则展示表格接口 2026-04-14 16:45:49 +08:00
d43effe612 Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-14 16:45:10 +08:00
f66d707520 Merge remote-tracking branch 'origin/master' into feature-transform-node-data 2026-04-14 16:30:13 +08:00
MHW
e82455a220 获取场景关系 2026-04-14 15:10:24 +08:00
2b2a11831d 支持在通信节点右键菜单中挂载行为树 2026-04-14 15:09:50 +08:00
a10b16a0ff Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-14 13:35:50 +08:00
85b4a7dd2f feat: 增加通信关系图随机生成及后端数据加载功能
- 新增 data-converter.ts,实现通信记录到GraphContainer 的转换及自动布局算法
- 新增random-data-generator.ts,用于生成测试用的随机通信拓扑数据
- communication.vue中集成“随机生成”与“从后端加载”按钮及相关逻辑
- 支持多连通分量检测、层级布局计算及节点防重叠处理
2026-04-14 11:39:22 +08:00
MHW
835bb56851 Merge branch 'refs/heads/test-platform' 2026-04-14 09:34:42 +08:00
MHW
5c83b561cc 逻辑修改 2026-04-13 17:58:01 +08:00
bb45ff557b 新增根据行为树ID获取下属平台的接口 2026-04-13 17:33:28 +08:00
MHW
eff0b87da8 逻辑修改 2026-04-13 17:26:56 +08:00
254401d8f1 支持根据行为树加载下属平台并优化属性面板显示 2026-04-13 17:26:50 +08:00
d8c238a9bb Merge remote-tracking branch 'origin/master' 2026-04-13 17:15:51 +08:00
MHW
aefc2c688e 逻辑修改 2026-04-13 17:13:34 +08:00
MHW
5f1ba38c6b 逻辑修改 2026-04-13 17:10:52 +08:00
MHW
e57f0f19d5 根据场景id显示所有行为树 2026-04-13 17:02:08 +08:00
79364b951d 修复类型导入缺失及Props类型断言格式 2026-04-13 16:41:11 +08:00
1270bd7d02 Merge remote-tracking branch 'origin/master' 2026-04-13 16:40:51 +08:00
a277fe22a6 Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-13 16:34:30 +08:00
MHW
b424774f3b 实体重复修改bug修复 2026-04-13 16:34:05 +08:00
MHW
766425bae5 实体重复修改 2026-04-13 16:31:56 +08:00
836e42625e Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-13 16:29:49 +08:00
MHW
0e6b6d9f45 查询行为树所属平台的下属 2026-04-13 16:16:24 +08:00
50c1cc5bf2 修复行为树复制参数传递错误 2026-04-13 15:33:46 +08:00
69c01bc62b Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-13 15:30:50 +08:00
7c71a38f68 添加前端行为树复制接口 2026-04-13 15:24:59 +08:00
bd62efca3f Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-13 15:07:15 +08:00
3946bc561a 添加行为树复制功能 2026-04-13 14:25:50 +08:00
5179ab785c Merge commit '5276a6b16fdf0e345bd0a952abc998c1bf4e3725' 2026-04-13 14:22:14 +08:00
MHW
5276a6b16f 复制行为树 2026-04-13 14:19:18 +08:00
c0da7bd0d9 画布动态尺寸 2026-04-13 12:22:30 +08:00
MHW
dafd7115a8 Merge branch 'refs/heads/develop' 2026-04-13 10:39:47 +08:00
MHW
1061020791 复制行为树 2026-04-13 10:39:37 +08:00
MHW
045117011b docker-compose 2026-04-11 13:46:02 +08:00
ee019d3c0f Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-09 16:19:08 +08:00
MHW
8a0dfb1ab8 sql改 2026-04-09 16:10:15 +08:00
MHW
08030c77c2 sql改 2026-04-09 16:06:40 +08:00
MHW
230116bdd7 sql 2026-04-09 15:40:49 +08:00
MHW
a65d296421 sql 2026-04-09 15:36:28 +08:00
MHW
78e5833514 docker 2026-04-09 15:13:10 +08:00
MHW
6add28fdfb 火力规则:装备匹配规则实现,目标规则实现,阵位规则、航迹规则【初版】 2026-04-09 10:22:53 +08:00
80fa2de819 Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-01 11:33:31 +08:00
94b15ef412 Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-04-01 09:14:06 +08:00
4e28782d59 Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-31 14:33:13 +08:00
615eac3bfe Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-31 11:14:44 +08:00
e24920acf1 Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-31 11:11:50 +08:00
1c562c134c Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-27 13:29:42 +08:00
c6c38332d9 Merge branches 'master' and 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-27 10:06:41 +08:00
f51b27dc7c Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-27 09:33:59 +08:00
a6c6cf2427 Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-27 09:23:04 +08:00
373dc390fa Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-26 23:37:03 +08:00
2ed1129fe4 Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-20 16:06:00 +08:00
ce4c23eff8 save 2026-03-17 09:19:00 +08:00
9f4ef1ab94 save 2026-03-17 09:18:50 +08:00
c800811bed Merge branch 'master' of http://101.43.238.71:3000/zouju/auto-solution 2026-03-17 09:18:05 +08:00
235fd9b6e1 更新数据格式 2026-03-16 11:57:20 +08:00
152 changed files with 23020 additions and 682 deletions

9
.dockerignore Normal file
View File

@@ -0,0 +1,9 @@
**/target/
**/.git/
**/.idea/
**/*.iml
**/.vscode/
**/node_modules/
**/*.log
**/.DS_Store
**/uploadPath/

15
.env.example Normal file
View File

@@ -0,0 +1,15 @@
# 复制为 .env 后 docker compose 会自动加载
# copy .env.example .env
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=autosolution_db
MYSQL_PORT=3307
REDIS_PASSWORD=123456
REDIS_PORT=6379
APP_PORT=1777
APP_IMAGE_TAG=latest
# JVM 可选
# JAVA_OPTS=-Xms512m -Xmx1024m

19
.gitignore vendored
View File

@@ -38,6 +38,10 @@ dist/
nbdist/ nbdist/
.nb-gradle/ .nb-gradle/
######################################################################
# Docker / local secrets
.env
###################################################################### ######################################################################
# Others # Others
*.log *.log
@@ -47,3 +51,18 @@ nbdist/
!*/build/*.java !*/build/*.java
!*/build/*.html !*/build/*.html
!*/build/*.xml !*/build/*.xml
modeler/pnpm-lock.yaml
# Application configuration files (may contain sensitive info)
**/application.yml
**/application-*.yml
!**/application-example.yml
######################################################################
# Mock bundled cache files
**/*.bundled_*.mjs
**/__*.bundled_*.mjs
**/___*.bundled_*.mjs
modeler/types/components.d.ts
modeler/types/auto-imports.d.ts
.DS_Store

114
DEPLOY_OFFLINE.md Normal file
View File

@@ -0,0 +1,114 @@
# Docker 离线部署说明(方式 A)
执行 `docker compose up -d` 即可启动。
## 1. 交付清单
请将以下内容放在同一目录(示例:`app/`):
- `docker-compose.yml`
- `.env`(或将 `.env.example` 复制为 `.env` 后修改)
- `bundle-images.tar`(包含 `auto-solution-admin`、`mysql:8.0`、`redis:7-alpine`)
- `docker/mysql/init/01-ruoyi-table.sql`
- `docker/mysql/init/02-ruoyi-extra.sql`
- `docker/mysql/init/03-data.sql`
目录示例:
```text
app/
├─ docker-compose.yml
├─ .env
├─ bundle-images.tar
└─ docker/
└─ mysql/
└─ init/
├─ 00-create-db.sql
├─ 03-data.sql
```
## 2. 首次部署
在 `app` 目录执行:
```bash
docker load -i bundle-images.tar
docker compose down -v
docker compose up -d
```
说明:
- `down -v` 会删除旧数据卷,确保 MySQL 首次初始化时执行 `docker/mysql/init` 下的 SQL。
- SQL 执行顺序按文件名字典序,务必保持 `01 -> 02 -> 03`。
## 3. 启动验证
```bash
docker ps
docker inspect autosolution-mysql --format '{{.State.Health.Status}}'
docker logs --tail 100 autosolution-mysql
docker logs --tail 100 autosolution-app
```
期望结果:
- `autosolution-mysql` 状态为 `healthy`
- `autosolution-app` 状态为 `Up`
## 4. 访问地址
- 后端默认端口:`1777`
- 访问地址:`http://<服务器IP>:1777`
## 5. 常见问题
### 5.1 `Table 'autosolution_db.sys_config' doesn't exist`
原因:初始化 SQL 未执行或执行失败。
处理:
1. 确认 `docker/mysql/init` 下 SQL 文件存在且顺序正确
2. 执行:
```bash
docker compose down -v
docker compose up -d
```
3. 查看 MySQL 日志定位 SQL 报错:
```bash
docker logs --tail 300 autosolution-mysql
```
### 5.2 `dependency failed to start: container autosolution-mysql is unhealthy`
原因:MySQL 未通过健康检查(通常是 SQL 未执行完成或报错)。
处理:
```bash
docker logs --tail 300 autosolution-mysql
```
根据日志修复 SQL 后重新 `down -v` 再启动。
## 6. 版本升级
替换新的 `bundle-images.tar`(及必要 SQL)后执行:
```bash
docker load -i bundle-images.tar
docker compose down
docker compose up -d
```
如果本次升级包含库初始化变更并要求重建,请改用:
```bash
docker compose down -v
docker compose up -d
```

18
Dockerfile Normal file
View File

@@ -0,0 +1,18 @@
# 运行已打包的 JAR(不依赖源码目录)
# 要求构建上下文中存在 solution-admin.jar
# 构建:docker build -t auto-solution-admin:latest .
FROM eclipse-temurin:11-jre-jammy
LABEL org.opencontainers.image.title="auto-solution-admin"
WORKDIR /app
RUN mkdir -p /app/uploadPath
COPY solution-admin.jar /app/app.jar
ENV TZ=Asia/Shanghai \
JAVA_OPTS="-Xms512m -Xmx1024m"
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar --spring.profiles.active=druid,docker"]

View File

@@ -81,6 +81,21 @@
<artifactId>solution-scene</artifactId> <artifactId>solution-scene</artifactId>
</dependency> </dependency>
<!-- 单元测试依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Security 测试支持(如果接口有权限控制) -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -3,19 +3,14 @@ package com.solution.web.controller.behaviour;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.solution.system.domain.PlatFormDTO;
import com.solution.web.core.BehaviortreeProcessor; import com.solution.web.core.BehaviortreeProcessor;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.solution.common.annotation.Log; import com.solution.common.annotation.Log;
import com.solution.common.core.controller.BaseController; import com.solution.common.core.controller.BaseController;
import com.solution.common.core.domain.AjaxResult; import com.solution.common.core.domain.AjaxResult;
@@ -97,6 +92,19 @@ public class BehaviortreeController extends BaseController
return toAjax(behaviortreeProcessor.create(behaviortree)); return toAjax(behaviortreeProcessor.create(behaviortree));
} }
/**
* 复制行为树
*/
@ApiOperation("复制行为树")
@PreAuthorize("@ss.hasPermi('system:behaviortree:add')")
@Log(title = "行为树主", businessType = BusinessType.INSERT)
@PostMapping("/copy")
public AjaxResult copy(@RequestBody Behaviortree behaviortree)
{
//return toAjax(behaviortreeService.copy(behaviortree));
return toAjax(behaviortreeProcessor.copy(behaviortree));
}
/** /**
* 修改行为树主 * 修改行为树主
*/ */
@@ -121,4 +129,37 @@ public class BehaviortreeController extends BaseController
return toAjax(behaviortreeService.deleteBehaviortreeByIds(ids)); return toAjax(behaviortreeService.deleteBehaviortreeByIds(ids));
} }
/**
* 根据平台id获取该行为树的下属
* @param platformId
* @return
*/
@ApiOperation("根据平台id获取该行为树的下属")
@PreAuthorize("@ss.hasPermi('system:behaviortree:query')")
@GetMapping("/underling/{platformId}")
public AjaxResult getUnderling(@PathVariable Integer platformId)
{
return success(behaviortreeService.getUnderling(platformId));
}
/**
* 根据场景id获取总指挥的行为树的原数据
* @return
*/
@ApiOperation("根据场景id获取总指挥的行为树的原数据")
@GetMapping("/commander/{scenarioId}")
public AjaxResult getCommander(@PathVariable Integer scenarioId){
return success(behaviortreeService.getCommander(scenarioId));
}
/**
* 修改平台关联的行为树id
* @param platFormDTO
* @return
*/
@ApiOperation("修改平台关联的行为树id")
@PutMapping("/behaviortreeId")
public AjaxResult updateBehaviortreeId(@RequestBody PlatFormDTO platFormDTO){
return toAjax(behaviortreeService.updateBehaviortreeId(platFormDTO));
}
} }

View File

@@ -5,25 +5,38 @@ import com.solution.common.core.controller.BaseController;
import com.solution.common.core.domain.AjaxResult; import com.solution.common.core.domain.AjaxResult;
import com.solution.common.core.page.TableDataInfo; import com.solution.common.core.page.TableDataInfo;
import com.solution.common.enums.BusinessType; import com.solution.common.enums.BusinessType;
import com.solution.common.utils.poi.ExcelUtil;
import com.solution.rule.domain.Rule; import com.solution.rule.domain.Rule;
import com.solution.rule.domain.config.RuleConfig;
import com.solution.rule.domain.config.RuleConfigExcelRow;
import com.solution.rule.domain.config.RuleConfigQuery;
import com.solution.rule.domain.config.RuleParamMeta;
import com.solution.rule.domain.config.vo.RuleDecisionTreeVO;
import com.solution.rule.domain.config.vo.RuleFourBlocksGraphVO;
import com.solution.rule.domain.config.vo.RuleGraphVO;
import com.solution.rule.service.IRuleService; import com.solution.rule.service.IRuleService;
import com.solution.rule.service.IRuleConfigService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@Api("红蓝对抗规则管理") @Api("红蓝对抗规则管理")
@RestController @RestController
@RequestMapping("/api/system/rule") @RequestMapping("/api/system/rule")
public class RuleController extends BaseController { public class RuleController extends BaseController {
@Autowired @Autowired
private IRuleService ruleService; private IRuleService ruleService;
@Autowired
private IRuleConfigService ruleConfigService;
@PreAuthorize("@ss.hasPermi('system:rule:list')") /*@PreAuthorize("@ss.hasPermi('system:rule:list')")
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("查询规则列表") @ApiOperation("查询规则列表")
public TableDataInfo list(Rule rule) { public TableDataInfo list(Rule rule) {
@@ -61,5 +74,109 @@ public class RuleController extends BaseController {
@ApiOperation("删除规则") @ApiOperation("删除规则")
public AjaxResult remove(@PathVariable Integer[] ids) { public AjaxResult remove(@PathVariable Integer[] ids) {
return toAjax(ruleService.deleteRuleByIds(ids)); return toAjax(ruleService.deleteRuleByIds(ids));
}*/
@PreAuthorize("@ss.hasPermi('system:rule:list')")
@GetMapping("/config/list")
@ApiOperation("查询规则聚合列表")
public TableDataInfo configList(RuleConfigQuery query) {
startPage();
return getDataTable(ruleConfigService.selectRuleConfigList(query));
}
@PreAuthorize("@ss.hasPermi('system:rule:list')")
@GetMapping("/config/graph")
@ApiOperation("规则知识图谱(与列表相同的分页与筛选条件)")
public AjaxResult configGraph(RuleConfigQuery query) {
startPage();
List<RuleConfig> list = ruleConfigService.selectRuleConfigList(query);
RuleGraphVO graph = ruleConfigService.buildKnowledgeGraph(list);
return success(graph);
}
@PreAuthorize("@ss.hasPermi('system:rule:list')")
@GetMapping("/config/decision-tree")
@ApiOperation("规则决策树(围绕装备/目标/阵位/航迹四类规则,展示参数进入后的决策路径)")
public AjaxResult configDecisionTree(RuleConfigQuery query) {
startPage();
List<RuleConfig> list = ruleConfigService.selectRuleConfigList(query);
RuleDecisionTreeVO tree = ruleConfigService.buildDecisionTree(list);
return success(tree);
}
@PreAuthorize("@ss.hasPermi('system:rule:list')")
@GetMapping("/config/graph/four-blocks")
@ApiOperation("四块规则知识图谱(装备/目标/阵位/航迹;参数值与运行时 globalParams 一致)")
public AjaxResult configGraphFourBlocks() {
RuleFourBlocksGraphVO vo = ruleConfigService.buildFourBlocksKnowledgeGraph();
return success(vo);
}
@PreAuthorize("@ss.hasPermi('system:rule:query')")
@GetMapping("/config/{ruleCode}")
@ApiOperation("查询规则聚合详情")
public AjaxResult configInfo(@PathVariable String ruleCode) {
return success(ruleConfigService.selectRuleConfigByCode(ruleCode));
}
@PreAuthorize("@ss.hasPermi('system:rule:add')")
@Log(title = "规则聚合管理", businessType = BusinessType.INSERT)
@PostMapping("/config")
@ApiOperation("新增规则聚合")
public AjaxResult addConfig(@RequestBody RuleConfig ruleConfig) {
return toAjax(ruleConfigService.insertRuleConfig(ruleConfig));
}
@PreAuthorize("@ss.hasPermi('system:rule:edit')")
@Log(title = "规则聚合管理", businessType = BusinessType.UPDATE)
@PutMapping("/config")
@ApiOperation("修改规则聚合")
public AjaxResult editConfig(@RequestBody RuleConfig ruleConfig) {
return toAjax(ruleConfigService.updateRuleConfig(ruleConfig));
}
@PreAuthorize("@ss.hasPermi('system:rule:remove')")
@Log(title = "规则聚合管理", businessType = BusinessType.DELETE)
@DeleteMapping("/config/{ruleCodes}")
@ApiOperation("删除规则聚合")
public AjaxResult removeConfig(@PathVariable String[] ruleCodes) {
return toAjax(ruleConfigService.deleteRuleConfigByCodes(ruleCodes));
}
@PreAuthorize("@ss.hasPermi('system:rule:query')")
@GetMapping("/config/dict/{dictType}")
@ApiOperation("按类型查询规则字典")
public AjaxResult dict(@PathVariable String dictType) {
return success(ruleConfigService.selectDictByType(dictType));
}
@PreAuthorize("@ss.hasPermi('system:rule:query')")
@GetMapping("/config/param-meta")
@ApiOperation("查询参数元数据")
public AjaxResult paramMeta() {
List<RuleParamMeta> metas = ruleConfigService.selectParamMetaList();
return success(metas);
}
@PreAuthorize("@ss.hasPermi('system:rule:query')")
@Log(title = "Rule Config", businessType = BusinessType.EXPORT)
@PostMapping("/config/export")
@ApiOperation("Export rule config")
public void exportConfig(HttpServletResponse response, @RequestBody(required = false) RuleConfigQuery query) {
List<RuleConfigExcelRow> rows = ruleConfigService.exportRuleConfigRows(query == null ? new RuleConfigQuery() : query);
ExcelUtil<RuleConfigExcelRow> util = new ExcelUtil<>(RuleConfigExcelRow.class);
util.exportExcel(response, rows, "rule-config");
}
@PreAuthorize("@ss.hasPermi('system:rule:edit')")
@Log(title = "Rule Config", businessType = BusinessType.IMPORT)
@PostMapping("/config/importData")
@ApiOperation("Import rule config")
public AjaxResult importConfig(MultipartFile file,
@RequestParam(value = "updateSupport", defaultValue = "true") boolean updateSupport) throws Exception {
ExcelUtil<RuleConfigExcelRow> util = new ExcelUtil<>(RuleConfigExcelRow.class);
List<RuleConfigExcelRow> rows = util.importExcel(file.getInputStream());
String result = ruleConfigService.importRuleConfigRows(rows, updateSupport);
return success(result);
} }
} }

View File

@@ -55,4 +55,24 @@ public class SceneController extends BaseController {
{ {
return success(sceneService.findOneById(id)); return success(sceneService.findOneById(id));
} }
/**
* 根据场景id获取场景下所有行为树
*/
@GetMapping("/getAllTree/{id}")
@ApiOperation("根据场景id获取场景下所有行为树")
public AjaxResult getAllTree(@PathVariable Integer id){
return success(sceneService.getAllTree(id));
}
/**
* 根据场景id获取场景下所有关系
* @param id
* @return
*/
@GetMapping("/getAllRelation/{id}")
@ApiOperation("根据场景id获取场景下所有关系")
public AjaxResult getAllRelation(@PathVariable Integer id){
return success(sceneService.getAllRelation(id));
}
} }

View File

@@ -8,8 +8,10 @@ package com.solution.web.core;
* that was distributed with this source code. * that was distributed with this source code.
*/ */
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.solution.common.constant.ExceptionConstants;
import com.solution.system.domain.*; import com.solution.system.domain.*;
import com.solution.system.service.IBehaviortreeService; import com.solution.system.service.IBehaviortreeService;
import com.solution.system.service.INodeconnectionService; import com.solution.system.service.INodeconnectionService;
@@ -20,6 +22,7 @@ import com.solution.web.core.graph.GraphEdge;
import com.solution.web.core.graph.GraphNode; import com.solution.web.core.graph.GraphNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
@@ -56,6 +59,7 @@ public class BehaviortreeProcessor {
return result; return result;
} }
@Transactional(rollbackFor = Exception.class)
public int update(Behaviortree behaviortree) { public int update(Behaviortree behaviortree) {
int result = behaviortreeService.updateBehaviortree(behaviortree); int result = behaviortreeService.updateBehaviortree(behaviortree);
@@ -74,7 +78,7 @@ public class BehaviortreeProcessor {
} }
private void processGraph(Behaviortree behaviortree) { private void processGraph(Behaviortree behaviortree) {
//代码丢失 原:libertyspy 改:MHW
Graph graph = null; Graph graph = null;
try { try {
graph = objectMapper.readValue(behaviortree.getXmlContent(), Graph.class); graph = objectMapper.readValue(behaviortree.getXmlContent(), Graph.class);
@@ -223,4 +227,44 @@ public class BehaviortreeProcessor {
} }
/**
* 复制行为树
* @param behaviortree
* @return
*/
public int copy(Behaviortree behaviortree) {
if(ObjectUtil.isEmpty(behaviortree)){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
String name = behaviortree.getName();
String newName = name + "_" + behaviortree.getId();
String englishName = behaviortree.getEnglishName();
String newEnglishName = englishName + "_" + behaviortree.getId();
behaviortree.setEnglishName(newEnglishName);
behaviortree.setName(newName);
//不做前置判断,必走数据库count
//获取行为树重复名称个数
Integer num = behaviortreeService.getCountName(newName);
if(num > 0){
// 从2开始尝试,因为基础名称已经存在
int count = 2;
String finalName;
String finalEnglishName;
do {
finalName = newName + "_" + count;
finalEnglishName = newEnglishName + "_" + count;
// 检查当前生成的名称是否存在
num = behaviortreeService.getCountName(finalName);
count++;
} while(num > 0);
behaviortree.setName(finalName);
behaviortree.setEnglishName(finalEnglishName);
} else {
behaviortree.setName(newName);
behaviortree.setEnglishName(newEnglishName);
}
return this.create(behaviortree);
}
} }

View File

@@ -0,0 +1,23 @@
# Docker / docker-compose 环境:与 application.yml 的 druid 配置叠加使用
# 启动:-Dspring.profiles.active=druid,docker
spring:
devtools:
restart:
enabled: false
redis:
host: ${REDIS_HOST:redis}
port: ${REDIS_PORT:6379}
password: ${REDIS_PASSWORD:}
database: ${REDIS_DB:0}
datasource:
druid:
master:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DATABASE:autosolution_db}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=GMT%2B8
username: ${MYSQL_USER:root}
password: ${MYSQL_PASSWORD:root}
server:
port: ${SERVER_PORT:8080}
solution:
profile: ${SOLUTION_UPLOAD_PATH:/app/uploadPath}

View File

@@ -6,10 +6,8 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
# url: jdbc:mysql://192.168.166.71:3306/behaviortreedb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://127.0.0.1:3306/autosolution_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3306/autosolution_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
# password: 123456
password: 1234 password: 1234
# 从库数据源 # 从库数据源
slave: slave:

View File

@@ -49,6 +49,17 @@ public class Behaviortree extends BaseEntity
@Excel(name = "平台ID") @Excel(name = "平台ID")
private Integer platformId; private Integer platformId;
@Excel(name = "场景ID")
private Integer scenarioId;
public Integer getScenarioId() {
return scenarioId;
}
public void setScenarioId(Integer scenarioId) {
this.scenarioId = scenarioId;
}
public Integer getPlatformId() { public Integer getPlatformId() {
return platformId; return platformId;
} }

View File

@@ -32,7 +32,7 @@ public class Nodeparameter extends BaseEntity
@Excel(name = "节点实例设置的具体参数值 (覆盖模板默认值)") @Excel(name = "节点实例设置的具体参数值 (覆盖模板默认值)")
private String value; private String value;
private int groupIndex; private Integer groupIndex;
public void setId(Long id) public void setId(Long id)
{ {
@@ -48,6 +48,14 @@ public class Nodeparameter extends BaseEntity
return treeId; return treeId;
} }
public Integer getGroupIndex() {
return groupIndex;
}
public void setGroupIndex(Integer groupIndex) {
this.groupIndex = groupIndex;
}
public void setTreeId(Long treeId) { public void setTreeId(Long treeId) {
this.treeId = treeId; this.treeId = treeId;
} }
@@ -82,13 +90,6 @@ public class Nodeparameter extends BaseEntity
return value; return value;
} }
public int getGroupIndex() {
return groupIndex;
}
public void setGroupIndex(int groupIndex) {
this.groupIndex = groupIndex;
}
@Override @Override
public String toString() { public String toString() {

View File

@@ -0,0 +1,12 @@
package com.solution.system.domain;
import lombok.Data;
@Data
public class PlatFormDTO {
private Integer id;
private Integer behaviortreeId;
}

View File

@@ -0,0 +1,46 @@
package com.solution.system.domain;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 收集数据用来生成总指挥官
*/
@Data
public class PlatformChiefCommander {
/**
* Primary Key 主键ID(自增)
*/
private Integer id;
/**
* Create Time 创建时间
*/
private LocalDateTime createTime;
/**
* 名称
*/
private String name;
/**
* 时间
*/
private Integer time;
/**
* 指令
*/
private String command;
/**
* 下属指挥官
*/
private String subordinateCommander;
/**
* 场景ID
*/
private Integer scenarioId;
}

View File

@@ -0,0 +1,31 @@
package com.solution.system.domain;
import lombok.Data;
/**
* 平台表
*/
@Data
public class PlatformTree {
/**
* 主键
*/
private Integer id;
/**
* 平台名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 平台出现在想定上的想定id
*/
private Integer scenarioId;
}

View File

@@ -0,0 +1,34 @@
package com.solution.system.domain;
import lombok.Data;
/**
* 平台视图对象 platform
*/
@Data
public class PlatformVO
{
/** 主键 */
private Integer id;
/** 名称 */
private String name;
/** 描述 */
private String description;
/** 平台出现在想定上的想定id */
private Integer scenarioId;
/** 经度 */
private String longitude;
/** 纬度 */
private String latitude;
/** 平台类型 */
private String platformType;
/** 海拔 */
private Float altitude;
}

View File

@@ -39,11 +39,11 @@ public class Treenodeinstance extends BaseEntity
private Long preconditionTempleteId; private Long preconditionTempleteId;
@Excel(name = "节点介绍") @Excel(name = "节点介绍")
private String desciption; private String nodeValue;
/** $column.columnComment */ /** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "是否外部节点", readConverterExp = "0=否,1=是")
private String uuid; private String isExtern;
public void setId(Long id) public void setId(Long id)
{ {
@@ -105,36 +105,33 @@ public class Treenodeinstance extends BaseEntity
return preconditionTempleteId; return preconditionTempleteId;
} }
public void setUuid(String uuid) public String getNodeValue() {
{ return nodeValue;
this.uuid = uuid;
} }
public String getUuid() public void setNodeValue(String nodeValue) {
{ this.nodeValue = nodeValue;
return uuid;
} }
public String getDesciption() { public String getIsExtern() {
return desciption; return isExtern;
} }
public void setDesciption(String desciption) { public void setIsExtern(String isExtern) {
this.desciption = desciption; this.isExtern = isExtern;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return "Treenodeinstance{" +
.append("id", getId()) "id=" + id +
.append("treeId", getTreeId()) ", treeId=" + treeId +
.append("templateId", getTemplateId()) ", templateId=" + templateId +
.append("instanceName", getInstanceName()) ", instanceName='" + instanceName + '\'' +
.append("isRoot", getIsRoot()) ", isRoot=" + isRoot +
.append("preconditionTempleteId", getPreconditionTempleteId()) ", preconditionTempleteId=" + preconditionTempleteId +
.append("uuid", getUuid()) ", nodeValue='" + nodeValue + '\'' +
.append("desciption", getDesciption()) ", isExtern='" + isExtern + '\'' +
.toString(); '}';
} }
} }

View File

@@ -3,6 +3,7 @@ package com.solution.system.mapper;
import java.util.List; import java.util.List;
import com.solution.system.domain.Behaviortree; import com.solution.system.domain.Behaviortree;
import com.solution.system.domain.PlatformChiefCommander;
/** /**
* 行为树主Mapper接口 * 行为树主Mapper接口
@@ -62,4 +63,18 @@ public interface BehaviortreeMapper
* @return 结果 * @return 结果
*/ */
public int deleteBehaviortreeByIds(Long[] ids); public int deleteBehaviortreeByIds(Long[] ids);
/**
* 根据场景id获取总指挥的行为树的原数据
* @param scenarioId
* @return
*/
List<PlatformChiefCommander> getCommander(Integer scenarioId);
/**
* 获取行为树重复名称个数
* @param newName
* @return
*/
Integer getCountName(String newName);
} }

View File

@@ -0,0 +1,16 @@
package com.solution.system.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface PlatformCommunicationMapper {
/**
* 根据平台name获取平台下属英文名
* @param name
* @return
*/
List<String> getUnderlingBytreeId(String name);
}

View File

@@ -0,0 +1,43 @@
package com.solution.system.mapper;
import com.solution.system.domain.PlatFormDTO;
import com.solution.system.domain.PlatformTree;
import com.solution.system.domain.PlatformVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface PlatformMapper {
/**
* 根据下属平台英文名获取中文名返回
* @param underlingEnglishName
* @return
*/
List<String> selectPlatformChineseName(@Param("underlingEnglishName") List<String> underlingEnglishName);
/**
* 根据平台id获取平台实体
* @param platformId
* @return
*/
PlatformTree getPlatformById(Integer platformId);
/**
* 根据平台英文名查询该平台实体
* @param underlingEnglishName
* @return
*/
List<PlatformVO> getPlatformByEnglishName(@Param("underlingEnglishName") List<String> underlingEnglishName);
/**
* 修改平台关联的行为树id
* @param platFormDTO
* @return
*/
Integer updateBehaviortreeId(PlatFormDTO platFormDTO);
}

View File

@@ -3,6 +3,9 @@ package com.solution.system.service;
import java.util.List; import java.util.List;
import com.solution.system.domain.Behaviortree; import com.solution.system.domain.Behaviortree;
import com.solution.system.domain.PlatFormDTO;
import com.solution.system.domain.PlatformChiefCommander;
import com.solution.system.domain.PlatformVO;
/** /**
* 行为树主Service接口 * 行为树主Service接口
@@ -33,7 +36,6 @@ public interface IBehaviortreeService
/** /**
* 新增行为树主 * 新增行为树主
*
* @param behaviortree 行为树主 * @param behaviortree 行为树主
* @return 结果 * @return 结果
*/ */
@@ -62,4 +64,32 @@ public interface IBehaviortreeService
* @return 结果 * @return 结果
*/ */
public int deleteBehaviortreeById(Long id); public int deleteBehaviortreeById(Long id);
/**
* 根据平台id获取该行为树的下属
* @param platformId
* @return
*/
List<PlatformVO> getUnderling(Integer platformId);
/**
* 根据场景id获取总指挥的行为树的原数据
* @param scenarioId
* @return
*/
List<PlatformChiefCommander> getCommander(Integer scenarioId);
/**
* 获取行为树重复名称个数
* @param newName
* @return
*/
Integer getCountName(String newName);
/**
* 修改平台关联的行为树id
* @param platFormDTO
* @return
*/
Integer updateBehaviortreeId(PlatFormDTO platFormDTO);
} }

View File

@@ -2,12 +2,15 @@ package com.solution.system.service.impl;
import java.util.List; import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.solution.common.constant.ExceptionConstants; import com.solution.common.constant.ExceptionConstants;
import com.solution.system.domain.*;
import com.solution.system.mapper.PlatformCommunicationMapper;
import com.solution.system.mapper.PlatformMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.solution.system.mapper.BehaviortreeMapper; import com.solution.system.mapper.BehaviortreeMapper;
import com.solution.system.domain.Behaviortree;
import com.solution.system.service.IBehaviortreeService; import com.solution.system.service.IBehaviortreeService;
/** /**
@@ -22,6 +25,12 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService
@Autowired @Autowired
private BehaviortreeMapper behaviortreeMapper; private BehaviortreeMapper behaviortreeMapper;
@Autowired
private PlatformCommunicationMapper platformCommunicationMapper;
@Autowired
private PlatformMapper platformMapper;
@Override @Override
public Behaviortree findOneByPlatformId(Integer platformId) public Behaviortree findOneByPlatformId(Integer platformId)
{ {
@@ -99,4 +108,62 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService
{ {
return behaviortreeMapper.deleteBehaviortreeById(id); return behaviortreeMapper.deleteBehaviortreeById(id);
} }
/**
* 根据平台id获取该行为树的下属
* @param platformId
* @return
*/
@Override
public List<PlatformVO> getUnderling(Integer platformId) {
if(null == platformId){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
//根据平台id获取平台实体
PlatformTree platform = platformMapper.getPlatformById(platformId);
//根据平台name获取平台下属英文名
List<String> underlingEnglishName = platformCommunicationMapper.getUnderlingBytreeId(platform.getName());
if(CollUtil.isEmpty(underlingEnglishName)){
throw new RuntimeException("该平台暂无下属");
}
//根据平台英文名查询该平台实体
List<PlatformVO> resultList = platformMapper.getPlatformByEnglishName(underlingEnglishName);
if(CollUtil.isEmpty(resultList)){
throw new RuntimeException("无法根据平台英文名获取平台实体");
}
return resultList;
}
/**
* 根据场景id获取总指挥的行为树的原数据
* @param scenarioId
* @return
*/
@Override
public List<PlatformChiefCommander> getCommander(Integer scenarioId) {
return behaviortreeMapper.getCommander(scenarioId);
}
/**
* 获取行为树重复名称个数
* @param newName
* @return
*/
@Override
public Integer getCountName(String newName) {
return behaviortreeMapper.getCountName(newName);
}
/**
* 修改平台关联的行为树id
* @param platFormDTO
* @return
*/
@Override
public Integer updateBehaviortreeId(PlatFormDTO platFormDTO) {
if(ObjectUtil.isEmpty(platFormDTO)){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
return platformMapper.updateBehaviortreeId(platFormDTO);
}
} }

View File

@@ -10,8 +10,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="description" column="description" /> <result property="description" column="description" />
<result property="createdAt" column="created_at" /> <result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" /> <result property="updatedAt" column="updated_at" />
<result property="englishName" column="english_name" /> <result property="englishName" column="english_name"/>
<result property="xmlContent" column="xml_content" /> <result property="xmlContent" column="xml_content" />
<result property="platformId" column="platform_id" />
<result property="scenarioId" column="scenario_id" />
</resultMap> </resultMap>
<select id="findOneByPlatformId" resultMap="BehaviortreeResult"> <select id="findOneByPlatformId" resultMap="BehaviortreeResult">
@@ -21,9 +23,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<sql id="selectBehaviortreeVo"> <sql id="selectBehaviortreeVo">
select id, name, description, created_at, updated_at, english_name, xml_content from behaviortree select id, name, description, created_at, updated_at, english_name, xml_content, platform_id, scenario_id from behaviortree
</sql> </sql>
<select id="selectBehaviortreeList" parameterType="Behaviortree" resultMap="BehaviortreeResult"> <select id="selectBehaviortreeList" parameterType="Behaviortree" resultMap="BehaviortreeResult">
<include refid="selectBehaviortreeVo"/> <include refid="selectBehaviortreeVo"/>
<where> <where>
@@ -33,13 +36,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
<if test="englishName != null and englishName != ''"> and english_name like concat('%', #{englishName}, '%')</if> <if test="englishName != null and englishName != ''"> and english_name like concat('%', #{englishName}, '%')</if>
<if test="xmlContent != null and xmlContent != ''"> and xml_content = #{xmlContent}</if> <if test="xmlContent != null and xmlContent != ''"> and xml_content = #{xmlContent}</if>
<if test="xmlContent != null and xmlContent != ''"> and xml_content = #{xmlContent}</if>
<if test="platformId != null">platform_id = #{platformId}</if>
<if test="scenarioId != null">scenario_id = #{scenarioId}</if>
</where> </where>
</select> </select>
<select id="selectBehaviortreeById" parameterType="Long" resultMap="BehaviortreeResult"> <select id="selectBehaviortreeById" parameterType="Long" resultMap="BehaviortreeResult">
<include refid="selectBehaviortreeVo"/> select id, name, description, created_at, updated_at, english_name,graph, xml_content ,platform_id, scenario_id from behaviortree
where id = #{id} where id = #{id}
</select> </select>
<select id="getCommander" resultType="com.solution.system.domain.PlatformChiefCommander"
parameterType="java.lang.Integer">
SELECT id,
create_time AS createTime,
name,time,command,
subordinate_commander AS subordinateCommander,
scenario_id AS scenarioId
FROM platform_chief_commander
WHERE scenario_id = #{scenarioId}
</select>
<select id="getCountName" resultType="java.lang.Integer" parameterType="java.lang.String">
SELECT count(*)
FROM behaviortree
WHERE name = #{name}
</select>
<insert id="insertBehaviortree" parameterType="Behaviortree" useGeneratedKeys="true" keyProperty="id"> <insert id="insertBehaviortree" parameterType="Behaviortree" useGeneratedKeys="true" keyProperty="id">
insert into behaviortree insert into behaviortree
@@ -51,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="englishName != null and englishName != ''">english_name,</if> <if test="englishName != null and englishName != ''">english_name,</if>
<if test="xmlContent != null">xml_content,</if> <if test="xmlContent != null">xml_content,</if>
<if test="platformId != null">platform_id,</if> <if test="platformId != null">platform_id,</if>
<if test="scenarioId != null">scenario_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if> <if test="name != null and name != ''">#{name},</if>
@@ -60,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="englishName != null and englishName != ''">#{englishName},</if> <if test="englishName != null and englishName != ''">#{englishName},</if>
<if test="xmlContent != null">#{xmlContent},</if> <if test="xmlContent != null">#{xmlContent},</if>
<if test="platformId != null">#{platformId},</if> <if test="platformId != null">#{platformId},</if>
<if test="scenarioId != null">#{scenarioId},</if>
</trim> </trim>
</insert> </insert>

View File

@@ -18,15 +18,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<sql id="selectNodeparameterVo"> <sql id="selectNodeparameterVo">
select id, treeId, node_instance_id, param_def_id,`value`, group_index from nodeparameter select id, tree_id, node_instance_id, param_def_id,`value`, group_index from nodeparameter
</sql> </sql>
<select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult"> <select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult">
<include refid="selectNodeparameterVo"/> <include refid="selectNodeparameterVo"/>
<where> <where>
<if test="id != null"> and id = #{id}</if>
<if test="treeId != null"> and tree_id = #{treeId}</if>
<if test="nodeInstanceId != null "> and node_instance_id = #{nodeInstanceId}</if> <if test="nodeInstanceId != null "> and node_instance_id = #{nodeInstanceId}</if>
<if test="paramDefId != null "> and param_def_id = #{paramDefId}</if> <if test="paramDefId != null "> and param_def_id = #{paramDefId}</if>
<if test="value != null and value != ''"> and value = #{value}</if> <if test="value != null and value != ''"> and `value` = #{value}</if>
<if test="groupIndex != null"> and group_index = #{groupIndex}</if>
</where> </where>
</select> </select>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.solution.system.mapper.PlatformCommunicationMapper">
<select id="getUnderlingBytreeId" resultType="java.lang.String" parameterType="java.lang.String">
SELECT subordinate_platform
FROM platform_communication
WHERE command_platform = #{name}
</select>
</mapper>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.solution.system.mapper.PlatformMapper">
<update id="updateBehaviortreeId">
UPDATE platform
SET behaviortree_id = #{behaviortreeId}
WHERE id = #{id}
</update>
<select id="selectPlatformChineseName" resultType="java.lang.String"
parameterType="java.util.List">
SELECT description
FROM platform
WHERE name IN
<foreach item="item" collection="underlingEnglishName" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getPlatformById" resultType="com.solution.system.domain.PlatformTree"
parameterType="java.lang.Integer">
SELECT id, name, description, scenario_id AS scenarioId
FROM platform
WHERE id = #{platformId}
</select>
<select id="getPlatformByEnglishName" resultType="com.solution.system.domain.PlatformVO">
SELECT id,name,description,
scenario_id AS scenarioId,
longitude,latitude,
platform_type AS platformType,
altitude
FROM platform
WHERE name IN
<foreach item="item" collection="underlingEnglishName" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -21,6 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTemplateparameterdefList" parameterType="templateparameterdef" resultMap="TemplateparameterdefResult"> <select id="selectTemplateparameterdefList" parameterType="templateparameterdef" resultMap="TemplateparameterdefResult">
<include refid="selectTemplateparameterdefVo"/> <include refid="selectTemplateparameterdefVo"/>
<where> <where>
<if test="id != null"> and id = #{id}</if>
<if test="templateId != null "> and template_id = #{templateId}</if> <if test="templateId != null "> and template_id = #{templateId}</if>
<if test="paramKey != null and paramKey != ''"> and param_key = #{paramKey}</if> <if test="paramKey != null and paramKey != ''"> and param_key = #{paramKey}</if>
<if test="dataType != null and dataType != ''"> and data_type = #{dataType}</if> <if test="dataType != null and dataType != ''"> and data_type = #{dataType}</if>

View File

@@ -11,16 +11,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="instanceName" column="instance_name" /> <result property="instanceName" column="instance_name" />
<result property="isRoot" column="is_root" /> <result property="isRoot" column="is_root" />
<result property="preconditionTempleteId" column="precondition_templete_id" /> <result property="preconditionTempleteId" column="precondition_templete_id" />
<result property="uuid" column="uuid" /> <result property="nodeValue" column="node_value" />
<result property="desciption" column="desciption" /> <result property="isExtern" column="is_extern" />
</resultMap> </resultMap>
<delete id="deleteByTreeId"> <delete id="deleteByTreeId">
delete from treenodeinstance where tree_id=#{treeId} delete from treenodeinstance where tree_id = #{treeId}
</delete> </delete>
<sql id="selectTreenodeinstanceVo"> <sql id="selectTreenodeinstanceVo">
select id, tree_id, template_id, instance_name, is_root, precondition_templete_id, uuid,desciption from treenodeinstance select id, tree_id, template_id, instance_name, is_root, precondition_templete_id, node_value,is_extern from treenodeinstance
</sql> </sql>
<select id="selectTreenodeinstanceList" parameterType="Treenodeinstance" resultMap="TreenodeinstanceResult"> <select id="selectTreenodeinstanceList" parameterType="Treenodeinstance" resultMap="TreenodeinstanceResult">
@@ -31,8 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="instanceName != null and instanceName != ''"> and instance_name like concat('%', #{instanceName}, '%')</if> <if test="instanceName != null and instanceName != ''"> and instance_name like concat('%', #{instanceName}, '%')</if>
<if test="isRoot != null "> and is_root = #{isRoot}</if> <if test="isRoot != null "> and is_root = #{isRoot}</if>
<if test="preconditionTempleteId != null "> and precondition_templete_id = #{preconditionTempleteId}</if> <if test="preconditionTempleteId != null "> and precondition_templete_id = #{preconditionTempleteId}</if>
<if test="uuid != null and uuid != ''"> and uuid = #{uuid}</if> <if test="nodeValue != null and nodeValue != ''"> and node_value = #{nodeValue}</if>
<if test="desciption != null and desciption != ''"> and desciption = #{desciption}</if> <if test="isExtern != null and isExtern != ''"> and is_extern = #{isExtern}</if>
</where> </where>
</select> </select>
@@ -49,8 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="instanceName != null">instance_name,</if> <if test="instanceName != null">instance_name,</if>
<if test="isRoot != null">is_root,</if> <if test="isRoot != null">is_root,</if>
<if test="preconditionTempleteId != null">precondition_templete_id,</if> <if test="preconditionTempleteId != null">precondition_templete_id,</if>
<if test="uuid != null">uuid,</if> <if test="nodeValue != null">node_value,</if>
<if test="desciption != null">desciption,</if> <if test="isExtern != null">is_extern,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="treeId != null">#{treeId},</if> <if test="treeId != null">#{treeId},</if>
@@ -58,8 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="instanceName != null">#{instanceName},</if> <if test="instanceName != null">#{instanceName},</if>
<if test="isRoot != null">#{isRoot},</if> <if test="isRoot != null">#{isRoot},</if>
<if test="preconditionTempleteId != null">#{preconditionTempleteId},</if> <if test="preconditionTempleteId != null">#{preconditionTempleteId},</if>
<if test="uuid != null">#{uuid},</if> <if test="nodeValue != null">#{node_value},</if>
<if test="desciption != null">#{desciption},</if> <if test="isExtern != null">#{is_extern},</if>
</trim> </trim>
</insert> </insert>
@@ -71,8 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="instanceName != null">instance_name = #{instanceName},</if> <if test="instanceName != null">instance_name = #{instanceName},</if>
<if test="isRoot != null">is_root = #{isRoot},</if> <if test="isRoot != null">is_root = #{isRoot},</if>
<if test="preconditionTempleteId != null">precondition_templete_id = #{preconditionTempleteId},</if> <if test="preconditionTempleteId != null">precondition_templete_id = #{preconditionTempleteId},</if>
<if test="uuid != null">uuid = #{uuid},</if> <if test="nodeValue != null">#{node_value},</if>
<if test="desciption != null">desciption = #{desciption},</if> <if test="isExtern != null">#{is_extern},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@@ -0,0 +1,28 @@
package com.solution.rule.controller;
import com.solution.rule.domain.tasks.Kj3PostResult;
import com.solution.rule.service.Kj3TaskDataService;
import org.springframework.beans.factory.annotation.Autowired;
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;
@RestController
@RequestMapping("/rule/kj3")
public class Kj3TaskDataController {
@Autowired
private Kj3TaskDataService kj3TaskDataService;
/**
* 接收外部传入的 kj-3 JSON,筛选红方任务并转换后 POST 到目标地址。
*
* @param kj3Json 外部请求体 JSON
* @return 处理结果
*/
@PostMapping("/parse-and-post")
public Kj3PostResult parseAndPost(@RequestBody String kj3Json) {
return kj3TaskDataService.parseAndPostRedTasks(kj3Json);
}
}

View File

@@ -20,6 +20,16 @@ public class BasicPlatform implements Serializable {
private String description; private String description;
private Integer behaviortreeId;
public Integer getBehaviortreeId() {
return behaviortreeId;
}
public void setBehaviortreeId(Integer behaviortreeId) {
this.behaviortreeId = behaviortreeId;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }

View File

@@ -0,0 +1,61 @@
package com.solution.rule.domain.config;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
@ApiModel("规则聚合对象")
public class RuleConfig {
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("规则编码")
private String ruleCode;
@ApiModelProperty("规则名称")
private String ruleName;
@ApiModelProperty("层级编码(task/action/platform)")
private String levelCode;
@ApiModelProperty("种类编码(select/assign/deploy/config/mode/spacetime/relation/limit)")
private String kindCode;
@ApiModelProperty("模块编码(equipment/target/position/track/group)")
private String moduleCode;
@ApiModelProperty("优先级(数字越小越先执行)")
private Integer priorityNo;
@ApiModelProperty("条件表达式")
private String conditionExpr;
@ApiModelProperty("动作表达式")
private String actionExpr;
@ApiModelProperty("版本号")
private Integer versionNo;
@ApiModelProperty("是否启用(1是0否)")
private Integer enabled;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建时间")
private Date createdAt;
@ApiModelProperty("更新时间")
private Date updatedAt;
@ApiModelProperty("参数列表")
private List<RuleConfigParam> params;
@ApiModelProperty("适用任务类型编码列表")
private List<String> taskTypes;
}

View File

@@ -0,0 +1,65 @@
package com.solution.rule.domain.config;
import com.solution.common.annotation.Excel;
import lombok.Data;
@Data
public class RuleConfigExcelRow {
@Excel(name = "规则编码")
private String ruleCode;
@Excel(name = "规则名称")
private String ruleName;
@Excel(name = "层级编码")
private String levelCode;
@Excel(name = "类别编码")
private String kindCode;
@Excel(name = "模块编码")
private String moduleCode;
@Excel(name = "优先级", cellType = Excel.ColumnType.NUMERIC)
private Integer priorityNo;
@Excel(name = "条件表达式", width = 24)
private String conditionExpr;
@Excel(name = "动作表达式", width = 24)
private String actionExpr;
@Excel(name = "版本号", cellType = Excel.ColumnType.NUMERIC)
private Integer versionNo;
@Excel(name = "规则启用", cellType = Excel.ColumnType.NUMERIC, prompt = "1=启用,0=停用")
private Integer enabled;
@Excel(name = "备注", width = 20)
private String remark;
@Excel(name = "任务类型列表", width = 20, prompt = "多个任务类型用英文逗号分隔")
private String taskTypesCsv;
@Excel(name = "参数名称")
private String paramName;
@Excel(name = "参数键")
private String paramKey;
@Excel(name = "参数值", width = 24)
private String paramVal;
@Excel(name = "参数值类型")
private String valType;
@Excel(name = "参数排序", cellType = Excel.ColumnType.NUMERIC)
private Integer sortNo;
@Excel(name = "参数启用", cellType = Excel.ColumnType.NUMERIC, prompt = "1=启用,0=停用")
private Integer paramEnabled;
@Excel(name = "参数备注", width = 20)
private String paramRemark;
}

View File

@@ -0,0 +1,34 @@
package com.solution.rule.domain.config;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("规则参数对象")
public class RuleConfigParam {
@ApiModelProperty("规则编码")
private String ruleCode;
@ApiModelProperty("参数键")
private String paramKey;
@ApiModelProperty("参数值")
private String paramVal;
@ApiModelProperty("值类型(string/number/bool/json)")
private String valType;
@ApiModelProperty("参数名称")
private String paramName;
@ApiModelProperty("排序号")
private Integer sortNo;
@ApiModelProperty("是否启用(1是0否)")
private Integer enabled;
@ApiModelProperty("备注")
private String remark;
}

View File

@@ -0,0 +1,28 @@
package com.solution.rule.domain.config;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("规则配置查询对象")
public class RuleConfigQuery {
@ApiModelProperty("规则编码")
private String ruleCode;
@ApiModelProperty("规则名称")
private String ruleName;
@ApiModelProperty("层级编码(task/action/platform)")
private String levelCode;
@ApiModelProperty("种类编码(select/assign/deploy/config/mode/spacetime/relation/limit)")
private String kindCode;
@ApiModelProperty("模块编码(equipment/target/position/track/group)")
private String moduleCode;
@ApiModelProperty("是否启用(1是0否)")
private Integer enabled;
}

View File

@@ -0,0 +1,16 @@
package com.solution.rule.domain.config;
import lombok.Data;
import java.io.Serializable;
/**
* rule_item_task_type 批量查询行
*/
@Data
public class RuleConfigTaskTypeRow implements Serializable {
private String ruleCode;
private String taskTypeCode;
}

View File

@@ -0,0 +1,28 @@
package com.solution.rule.domain.config;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("规则字典项")
public class RuleDictItem {
@ApiModelProperty("字典类型")
private String dictType;
@ApiModelProperty("字典编码")
private String dictCode;
@ApiModelProperty("字典名称")
private String dictName;
@ApiModelProperty("排序号")
private Integer sortNo;
@ApiModelProperty("是否启用(1是0否)")
private Integer enabled;
@ApiModelProperty("备注")
private String remark;
}

View File

@@ -0,0 +1,42 @@
package com.solution.rule.domain.config;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("规则参数元数据")
public class RuleParamMeta {
@ApiModelProperty("参数键")
private String paramKey;
@ApiModelProperty("参数名称")
private String label;
@ApiModelProperty("值类型(bool/number/enum/csv/string)")
private String valueType;
@ApiModelProperty("是否必填")
private Boolean required;
@ApiModelProperty("枚举可选值")
private List<String> enumOptions;
@ApiModelProperty("数值最小值")
private Double min;
@ApiModelProperty("数值最大值")
private Double max;
@ApiModelProperty("格式正则")
private String pattern;
@ApiModelProperty("示例值")
private String example;
@ApiModelProperty("说明")
private String description;
}

View File

@@ -0,0 +1,107 @@
package com.solution.rule.domain.config.graph;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* 与 {@code rules/rule.drl} 中「装备/目标/阵位/航迹」四个主规则一一对应,仅用于知识图谱分块展示(与 module_code 一致)。
*/
public enum RuleFourBlockDefinition {
EQUIPMENT(
"equipment",
"装备匹配",
100,
Arrays.asList(
"抽取蓝方任务与武器文案、红方装备类型与名称等,拼接为可对齐的蓝/红文本特征",
"规则槽关键词与兼容层叠加计分,再乘以全局权重得到每件红装的匹配总分",
"低于最低入选分则丢弃;并列最高分按既定策略决胜,并写入火力输入与任务名后缀"),
"DroolsFact(task != null)",
"mergeDefaultParams(globalParams); equipmentRule($fact, globalParams);"),
TARGET(
"target",
"目标匹配",
90,
Arrays.asList(
"根据命中率映射、射程解析与分配模式,确定每套红方可承载的目标数量与目标标识",
"向任务 execute 写入目标列表与默认行动类型等执行侧字段",
"命中率低于阈值时,在轮次与件数限制内补充选取装备并更新任务"),
"DroolsFact(task != null)",
"mergeDefaultParams(globalParams); target($fact, globalParams);"),
POSITION(
"position",
"阵位匹配",
80,
Arrays.asList(
"结合锚点模式、航向与部署距离区间、编队样式与间距,计算红方平台目标点位",
"按平台最小间距离散多个平台坐标,必要时叠加上述默认高度与跟随比例",
"若启用作战区约束,将越界阵位沿策略回拉到战争区内"),
"DroolsFact(task != null)",
"mergeDefaultParams(globalParams); position($fact, globalParams);"),
TRACK(
"track",
"航迹匹配",
70,
Arrays.asList(
"依据蓝方航迹与数据类型判定空中/地面航迹类别,选择对应变形算法生成航迹折线",
"生成航迹标识并与任务 execute 中的目标绑定移动路由",
"若启用航迹作战区约束,将航迹点约束在战争区多边形内"),
"DroolsFact(task != null)",
"mergeDefaultParams(globalParams); trackRoute($fact, globalParams);");

View File

@@ -0,0 +1,87 @@
package com.solution.rule.domain.config.graph;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
/**
* 冻结「参数键 → 四大展示块」归属(与 rule.drl / {@code 002_rule_seed_from_drl.sql} 中的 rule_item.module_code 一致)。
* 图谱优先按库表 rule_item_param.rule_code 所属模块归类;若某键仅存在于 globalParams 快照且无法关联模块时,再用本映射兜底。
*/
public final class RuleFourBlockParamMapping {
private static final Set<String> EQUIPMENT = set(
"weight", "minSelectedScore", "tieBreak", "outputDrawNameSuffix", "ruleSlotCount",
"blueRuleKeywords_1", "redRuleKeywords_1", "ruleScore_1",
"blueRuleKeywords_2", "redRuleKeywords_2", "ruleScore_2",
"blueRuleKeywords_3", "redRuleKeywords_3", "ruleScore_3",
"bluePlatformKeywords_air", "redPreferredWhenBlueAir", "airScore",
"airTaskKeywords", "airTaskScore",
"groundTaskKeywords", "redPreferredWhenGround", "groundScore",
"tankKeywords", "redMatchKeywords_tank", "tankScore",
"missileKeywords", "redMatchKeywords_missile", "missileScore");
private static final Set<String> TARGET = set(
"executeTypeDefault", "targetPickMode", "minTargetsPerRed", "maxTargetsPerRedCap",
"radToTargetsCsv", "rangeParseRegex", "rangeUnit", "minRangeToAllowAssignKm",
"redHitRateThreshold", "maxExtraWeaponsPerTask", "maxSupplementRounds", "extraPickMinScore");
private static final Set<String> POSITION = set(
"positionRuleEnabled", "positionAnchorMode", "trackPointDirectionMode",
"fallbackBearingDeg", "deployDistanceKmMin", "deployDistanceKmMax", "deployDistanceKmDefault",
"distanceByPlatformCsv", "formationType", "formationSpacingMeters", "formationHeadingOffsetDeg",
"defaultDeployHeight", "heightFollowBlueRatio", "enableWarZoneClamp", "warZoneClampMode",
"minInterPlatformDistanceMeters");
private static final Set<String> TRACK = set(
"trackRuleEnabled", "trackRouteAlgorithm", "trackRouteNameSuffix",
"trackAirDataTypeCsv", "trackAirKeywordsCsv", "trackGroundTrackType",
"trackFallbackBearingDeg", "enableTrackWarZoneClamp",
"trackExtraNodesMax", "trackShortPathSegments",
"trackFlankOffsetMeters", "trackFlankSideMode",
"trackJamWobbleMeters", "trackJamSegments");
private RuleFourBlockParamMapping() {
}
private static Set<String> set(String... keys) {
return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(keys)));
}
/**
* @param paramKey 参数键
* @param slotRuleKeys 形如 blueRuleKeywords_i / redRuleKeywords_i / ruleScore_i,视为装备块
*/
public static RuleFourBlockDefinition fallbackBlockForKey(String paramKey, boolean slotRuleKeys) {
if (paramKey == null || paramKey.isEmpty()) {
return RuleFourBlockDefinition.EQUIPMENT;
}
String k = paramKey.trim();
if (slotRuleKeys) {
return RuleFourBlockDefinition.EQUIPMENT;
}
if (EQUIPMENT.contains(k)) {
return RuleFourBlockDefinition.EQUIPMENT;
}
if (TARGET.contains(k)) {
return RuleFourBlockDefinition.TARGET;
}
if (POSITION.contains(k)) {
return RuleFourBlockDefinition.POSITION;
}
if (TRACK.contains(k)) {
return RuleFourBlockDefinition.TRACK;
}
String lower = k.toLowerCase(Locale.ROOT);
if (lower.startsWith("track")) {
return RuleFourBlockDefinition.TRACK;
}
if (lower.startsWith("position") || lower.startsWith("deploy") || lower.startsWith("formation")
|| lower.contains("warzone") || lower.contains("platform")) {
return RuleFourBlockDefinition.POSITION;
}
if (lower.contains("target") || lower.contains("execute") || lower.contains("assign") || lower.contains("supplement")) {
return RuleFourBlockDefinition.TARGET;
}
return RuleFourBlockDefinition.EQUIPMENT;
}
}

View File

@@ -0,0 +1,91 @@
package com.solution.rule.domain.config.graph;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 四块图谱展示用:每条 rule_item 对应的「运行时产出/写回」中文说明(静态目录,与 RuleFunction 行为一致即可)。
*/
public final class RuleFourBlockRuleOutputCatalog {
private static final Map<String, Map<String, List<String>>> BY_MODULE_AND_RULE = new HashMap<>();
static {
Map<String, List<String>> equipment = new HashMap<>();
equipment.put("R_TASK_SELECT_BASE", list(
"汇总匹配结果并写入火力规则输入(fireRuleInputs 等匹配行)",
"为任务名称追加输出后缀(outputDrawNameSuffix)"));
equipment.put("R_TASK_SELECT_SLOT_1", list(
"若槽1蓝红关键词同时命中,为当前候选装备累加 ruleScore_1×weight 分值"));
equipment.put("R_TASK_SELECT_SLOT_2", list(
"若槽2蓝红关键词同时命中,累加 ruleScore_2×weight 分值"));
equipment.put("R_TASK_SELECT_SLOT_3", list(
"若槽3蓝红关键词同时命中,累加 ruleScore_3×weight 分值"));
equipment.put("R_TASK_REL_AIR_PLATFORM", list(
"空中平台关键词命中时累加 airScore×weight 兼容层分值"));
equipment.put("R_TASK_REL_AIR_TASK", list(
"空中任务文案命中时累加 airTaskScore×weight 分值"));
equipment.put("R_TASK_REL_GROUND_TASK", list(
"地面任务与红方偏好同时命中时累加 groundScore×weight 分值"));
equipment.put("R_TASK_REL_TANK", list(
"坦克类关键词匹配时累加 tankScore×weight 分值"));
equipment.put("R_TASK_REL_MISSILE", list(
"导弹类关键词匹配时累加 missileScore×weight 分值"));
BY_MODULE_AND_RULE.put("equipment", Collections.unmodifiableMap(equipment));
Map<String, List<String>> target = new HashMap<>();
target.put("R_TASK_ASSIGN_TARGET", list(
"填充任务 execute 中目标列表与默认行动类型(executeTypeDefault 等)",
"按命中率映射与分配模式更新 targetId / 目标数量"));
target.put("R_TASK_LIMIT_SUPPLEMENT", list(
"命中率低于阈值时按轮次与件数上限补充选取装备并回写任务武器列表"));
BY_MODULE_AND_RULE.put("target", Collections.unmodifiableMap(target));
Map<String, List<String>> position = new HashMap<>();
position.put("R_PLATFORM_DEPLOY", list(
"计算并写回红方 SubComponents.platform[].positions(部署点、编队间距与高度)"));
position.put("R_PLATFORM_SPACETIME", list(
"在启用作战区约束时,将越界阵位回拉到 warZoneLocation 多边形内"));
BY_MODULE_AND_RULE.put("position", Collections.unmodifiableMap(position));
Map<String, List<String>> track = new HashMap<>();
track.put("R_ACTION_TRACK_ROUTE", list(
"生成/更新 TrackParam 中航迹节点,并为 execute 绑定 moveRouteId",
"按算法(followBlue 等)变形蓝方航迹并写航迹名称后缀"));
track.put("R_ACTION_TRACK_SPACETIME", list(
"在启用约束时将航迹点限制在作战区边界内"));
BY_MODULE_AND_RULE.put("track", Collections.unmodifiableMap(track));
}
private RuleFourBlockRuleOutputCatalog() {
}
private static List<String> list(String... lines) {
List<String> l = new ArrayList<>();
for (String s : lines) {
if (s != null && !s.isEmpty()) {
l.add(s);
}
}
return Collections.unmodifiableList(l);
}
/**
* @param moduleCode equipment / target / position / track
* @param ruleCode rule_item.rule_code
*/
public static List<String> outputsForRule(String moduleCode, String ruleCode) {
if (moduleCode == null || ruleCode == null) {
return Collections.emptyList();
}
Map<String, List<String>> m = BY_MODULE_AND_RULE.get(moduleCode);
if (m == null) {
return Collections.emptyList();
}
List<String> list = m.get(ruleCode);
return list != null ? list : Collections.emptyList();
}
}

View File

@@ -0,0 +1,72 @@
package com.solution.rule.domain.config.graph;
import cn.hutool.core.util.ObjectUtil;
/**
* 参数在「产出」列中的一行静态说明(与 globalParams 生效值拼接展示)。
*/
public final class RuleParamOutputHint {
private static final String GENERIC = "写入 globalParams 并由当前块对应 Java 算子读取";
private RuleParamOutputHint() {
}
public static String effectLine(String paramKey, String moduleCode) {
if (ObjectUtil.isEmpty(paramKey)) {
return GENERIC;
}
String k = paramKey.trim();
switch (k) {
case "weight":
return "参与装备/目标等环节的评分加权";
case "minSelectedScore":
return "低于该分则本规则对应环节不选中/不生效";
case "tieBreak":
return "同分时的决胜策略(如按装备 ID)";
case "outputDrawNameSuffix":
return "影响任务/输出名称后缀展示";
case "ruleSlotCount":
return "规则槽数量上限(装备匹配)";
case "executeTypeDefault":
return "写入任务 execute 的默认行动类型";
case "targetPickMode":
return "目标分配挑选模式(轮询/随机等)";
case "radToTargetsCsv":
return "命中率到目标数量的映射";
case "redHitRateThreshold":
return "命中率阈值,触发补拿等逻辑";
case "maxExtraWeaponsPerTask":
case "maxSupplementRounds":
case "extraPickMinScore":
return "补拿装备轮次与分数约束";
case "positionRuleEnabled":
case "trackRuleEnabled":
case "groupRuleEnabled":
return "控制对应环节是否执行";
case "deployDistanceKmMin":
case "deployDistanceKmMax":
case "deployDistanceKmDefault":
return "部署距离区间与默认值(阵位)";
case "formationType":
case "formationSpacingMeters":
return "编队几何与间距";
case "enableWarZoneClamp":
case "enableTrackWarZoneClamp":
return "作战区约束开关";
case "trackRouteAlgorithm":
return "航迹生成算法选择";
default:
if (k.startsWith("blueRuleKeywords_") || k.startsWith("redRuleKeywords_") || k.startsWith("ruleScore_")) {
return "规则槽关键词/分值,参与装备匹配打分";
}
if (ObjectUtil.isNotEmpty(moduleCode) && "track".equals(moduleCode) && k.toLowerCase().startsWith("track")) {
return "航迹生成与约束相关配置";
}
if (ObjectUtil.isNotEmpty(moduleCode) && "position".equals(moduleCode)) {
return "阵位/部署与空间约束相关配置";
}
return GENERIC;
}
}
}

View File

@@ -0,0 +1,39 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel("单个规则决策树分块")
public class RuleDecisionBlockVO implements Serializable {
@ApiModelProperty("分块标识:equipment/target/position/track")
private String blockId;
@ApiModelProperty("模块编码")
private String moduleCode;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("Drools 规则名")
private String droolsRuleName;
@ApiModelProperty("salience")
private Integer salience;
@ApiModelProperty("树节点")
private List<RuleDecisionNodeVO> nodes;
public List<RuleDecisionNodeVO> safeNodes() {
if (nodes == null) {
nodes = new ArrayList<>();
}
return nodes;
}
}

View File

@@ -0,0 +1,39 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel("规则决策树节点")
public class RuleDecisionNodeVO implements Serializable {
@ApiModelProperty("节点唯一键")
private String key;
@ApiModelProperty("节点标题")
private String title;
@ApiModelProperty("节点类型")
private String nodeType;
@ApiModelProperty("补充说明")
private String description;
@ApiModelProperty("右侧值文本")
private String valueText;
@ApiModelProperty("子节点")
private List<RuleDecisionNodeVO> children;
public List<RuleDecisionNodeVO> safeChildren() {
if (children == null) {
children = new ArrayList<>();
}
return children;
}
}

View File

@@ -0,0 +1,36 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Data
@ApiModel("规则决策树")
public class RuleDecisionTreeVO implements Serializable {
@ApiModelProperty("与运行时 globalParams 一致的参数快照")
private Map<String, Object> globalParamsPreview;
@ApiModelProperty("四大规则分块")
private List<RuleDecisionBlockVO> blocks;
public Map<String, Object> safeGlobalParamsPreview() {
if (globalParamsPreview == null) {
globalParamsPreview = new LinkedHashMap<>();
}
return globalParamsPreview;
}
public List<RuleDecisionBlockVO> safeBlocks() {
if (blocks == null) {
blocks = new ArrayList<>();
}
return blocks;
}
}

View File

@@ -0,0 +1,40 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel("单个分块(环形参数 + If/Then 中枢)")
public class RuleFourBlockClusterVO implements Serializable {
@ApiModelProperty("块标识:equipment/target/position/track")
private String blockId;
@ApiModelProperty("模块编码,对应 rule_item.module_code")
private String moduleCode;
@ApiModelProperty("界面标题(如 装备匹配)")
private String title;
@ApiModelProperty("Drools 规则名(如 装备匹配)")
private String droolsRuleName;
@ApiModelProperty("salience")
private Integer salience;
@ApiModelProperty("Drools when 表达式摘要")
private String whenExpr;
@ApiModelProperty("then 动作(含 mergeDefaultParams + Java 调用)")
private String thenAction;
@ApiModelProperty("中枢 + 环形参数节点与边")
private RuleGraphVO graph;
@ApiModelProperty("该块内每条规则的每个参数:When/Then/产出(表格)")
private List<RuleFourBlockParamRowVO> paramRows;
}

View File

@@ -0,0 +1,33 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("四块分区内单条参数展示行")
public class RuleFourBlockParamRowVO implements Serializable {
@ApiModelProperty("规则编码")
private String ruleCode;
@ApiModelProperty("规则名称")
private String ruleName;
@ApiModelProperty("参数键")
private String paramKey;
@ApiModelProperty("参数业务名")
private String paramName;
@ApiModelProperty("When(规则条件或块级回退)")
private String whenText;
@ApiModelProperty("Then(规则动作或块级回退)")
private String thenText;
@ApiModelProperty("产出说明(生效值 + 静态提示)")
private String outputText;
}

View File

@@ -0,0 +1,28 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Data
@ApiModel("四块规则知识图谱(装备/目标/阵位/航迹)")
public class RuleFourBlocksGraphVO implements Serializable {
@ApiModelProperty("与运行时 KieSession globalParams 一致的参数快照(启用规则与参数合并后)")
private Map<String, Object> globalParamsPreview;
@ApiModelProperty("四个分块,每块含中枢 If/Then 与子图节点边")
private List<RuleFourBlockClusterVO> blocks;
public Map<String, Object> safeGlobalParamsPreview() {
if (globalParamsPreview == null) {
globalParamsPreview = new LinkedHashMap<>();
}
return globalParamsPreview;
}
}

View File

@@ -0,0 +1,27 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("规则知识图谱边")
public class RuleGraphEdgeVO implements Serializable {
@ApiModelProperty("边 id")
private String id;
@ApiModelProperty("起点节点 id")
private String source;
@ApiModelProperty("终点节点 id")
private String target;
@ApiModelProperty("边类型")
private String edgeType;
@ApiModelProperty("边上展示文案")
private String label;
}

View File

@@ -0,0 +1,33 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Data
@ApiModel("规则知识图谱节点")
public class RuleGraphNodeVO implements Serializable {
@ApiModelProperty("全局唯一节点 id")
private String id;
@ApiModelProperty("展示标题")
private String label;
@ApiModelProperty("节点类型:level/kind/module/rule/param/taskType")
private String nodeType;
@ApiModelProperty("附加属性(如 ruleCode、paramKey、字典编码等)")
private Map<String, Object> payload;
public Map<String, Object> safePayload() {
if (payload == null) {
payload = new HashMap<>();
}
return payload;
}
}

View File

@@ -0,0 +1,40 @@
package com.solution.rule.domain.config.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel("规则知识图谱数据")
public class RuleGraphVO implements Serializable {
@ApiModelProperty("节点列表")
private List<RuleGraphNodeVO> nodes;
@ApiModelProperty("边列表")
private List<RuleGraphEdgeVO> edges;
@ApiModelProperty("前端布局提示:如 radial_hub 使用径向圆心布局")
private String layoutHint;
@ApiModelProperty("径向布局时的中心节点 id(通常为 drools_facade)")
private String focusNodeId;
public List<RuleGraphNodeVO> safeNodes() {
if (nodes == null) {
nodes = new ArrayList<>();
}
return nodes;
}
public List<RuleGraphEdgeVO> safeEdges() {
if (edges == null) {
edges = new ArrayList<>();
}
return edges;
}
}

View File

@@ -0,0 +1,16 @@
package com.solution.rule.domain.tasks;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class AssignTargetItem {
private String task;
private String type;
private List<String> target = new ArrayList<>();
}

View File

@@ -0,0 +1,16 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class DataOutput {
@JsonProperty("assign_target")
private List<AssignTargetItem> assignTarget = new ArrayList<>();
private List<TaskItem> task = new ArrayList<>();
}

View File

@@ -0,0 +1,13 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3ExecuteBlock {
private List<Kj3TargetItem> targetList;
}

View File

@@ -0,0 +1,16 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3ForceSide {
@JsonProperty("ObjectHandle")
private String objectHandle;
@JsonProperty("ForceSideName")
private String forceSideName;
}

View File

@@ -0,0 +1,25 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3MilitaryItem {
@JsonProperty("Name")
private String name;
@JsonProperty("OwnerForceSide")
private String ownerForceSide;
@JsonProperty("EquipmentID")
private String equipmentId;
@JsonProperty("Platform_type")
private String platformType;
@JsonProperty("SubComponents")
private Kj3SubComponents subComponents;
}

View File

@@ -0,0 +1,17 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3MilitaryPlatformComponent {
@JsonProperty("TrackParamId")
private String trackParamId;
private List<Double> positions;
}

View File

@@ -0,0 +1,24 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3MilitaryScenario {
@JsonProperty("Tasks")
private List<Kj3TaskNode> tasks;
@JsonProperty("ForceSides")
private List<Kj3ForceSide> forceSides;
@JsonProperty("Military")
private List<Kj3MilitaryItem> military;
@JsonProperty("RefAttributeObject")
private Kj3RefAttributeObject refAttributeObject;
}

View File

@@ -0,0 +1,15 @@
package com.solution.rule.domain.tasks;
import lombok.Data;
@Data
public class Kj3PostResult {
private boolean success;
private String statusMessage;
private String postUrl;
private int taskCount;
}

View File

@@ -0,0 +1,15 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.Map;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3RefAttributeObject {
@JsonProperty("TrackParam")
private Map<String, Kj3TrackParam> trackParam;
}

View File

@@ -0,0 +1,13 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3Root {
@JsonProperty("MilitaryScenario")
private Kj3MilitaryScenario militaryScenario;
}

View File

@@ -0,0 +1,13 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3SubComponents {
private List<Kj3MilitaryPlatformComponent> platform;
}

View File

@@ -0,0 +1,15 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3TargetItem {
private String targetId;
@JsonProperty("cruiseRouteId")
private String cruiseRouteId;
}

View File

@@ -0,0 +1,15 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3TaskNode {
private String name;
private String side;
private Kj3TaskPayload task;
}

View File

@@ -0,0 +1,23 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3TaskPayload {
private String name;
private String side;
private String type;
@JsonProperty("at_time")
private String atTime;
private List<Kj3ExecuteBlock> execute;
}

View File

@@ -0,0 +1,15 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3TrackParam {
@JsonProperty("TrackPoints")
private List<Kj3TrackPoint> trackPoints;
}

View File

@@ -0,0 +1,17 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Kj3TrackPoint {
private String longitude;
private String latitude;
private String height;
private String speed;
}

View File

@@ -0,0 +1,24 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class PlatformItem {
private String name;
@JsonProperty("platform_type")
private String platformType;
private String longitude;
private String latitude;
private Integer altitude;
private List<RoutePoint> route = new ArrayList<>();
}

View File

@@ -0,0 +1,15 @@
package com.solution.rule.domain.tasks;
import lombok.Data;
@Data
public class RoutePoint {
private String longitude;
private String latitude;
private Integer altitude;
private Integer speed;
}

View File

@@ -0,0 +1,18 @@
package com.solution.rule.domain.tasks;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class TaskItem {
@JsonProperty("task_name")
private String taskName;
private List<PlatformItem> platform = new ArrayList<>();
private TaskTime time;
}

View File

@@ -0,0 +1,11 @@
package com.solution.rule.domain.tasks;
import lombok.Data;
@Data
public class TaskTime {
private Integer begin;
private Integer end;
}

View File

@@ -45,6 +45,8 @@ public class FireRuleExecuteTargetItemVO {
private String cruiseRouteId; private String cruiseRouteId;
private String moveRouteId;
private List<FireRuleCruiseRouteOffsetItemVO> cruiseRouteOffset; private List<FireRuleCruiseRouteOffsetItemVO> cruiseRouteOffset;
private String fireType; private String fireType;

View File

@@ -1,42 +1,45 @@
package com.solution.rule.domain.ultimately.vo; package com.solution.rule.domain.ultimately.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
/**
* 火力规则输出根文档(与 {@code 火力规则输出.json} 字段一一对应)。
*/
@Data @Data
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class FireRuleOutputVO { public class FireRuleOutputVO {
/**
* 来源场景文件名
*/
private String sourceFile; private String sourceFile;
/**
* 火力规则任务列表(可含防区等输出字段)
*/
private List<FireRuleTaskInputVO> fireRuleInputs; private List<FireRuleTaskInputVO> fireRuleInputs;
/**
* 场景任务节点列表
*/
@JsonProperty("Tasks") @JsonProperty("Tasks")
private List<FireRuleSceneTaskNodeVO> tasks; private List<FireRuleSceneTaskNodeVO> tasks;
@JsonProperty("TrackParam")
private FireRuleTrackParamVO trackParam;
/** @JsonIgnore
* 编组列表 public List<FireRuleSceneGroupNodeVO> getGroups() {
*/ return trackParam == null ? null : trackParam.getGroups();
@JsonProperty("Groups") }
private List<FireRuleSceneGroupNodeVO> groups;
/** @JsonIgnore
* 红方装备列表 public void setGroups(List<FireRuleSceneGroupNodeVO> groups) {
*/ if (trackParam == null) {
private List<FireRuleRedWeaponEquipmentVO> redWeapons; trackParam = new FireRuleTrackParamVO();
}
trackParam.setGroups(groups);
}
@JsonIgnore
public List<FireRuleRedWeaponEquipmentVO> getRedWeapons() {
return trackParam == null ? null : trackParam.getRedWeapons();
}
@JsonIgnore
public void setRedWeapons(List<FireRuleRedWeaponEquipmentVO> redWeapons) {
if (trackParam == null) {
trackParam = new FireRuleTrackParamVO();
}
trackParam.setRedWeapons(redWeapons);
}
} }

View File

@@ -6,9 +6,6 @@ import lombok.Data;
import java.util.Map; import java.util.Map;
/**
* 火力规则输出中 redWeapons 数组的单项(红方装备/平台)
*/
@Data @Data
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class FireRuleRedWeaponEquipmentVO { public class FireRuleRedWeaponEquipmentVO {
@@ -23,15 +20,10 @@ public class FireRuleRedWeaponEquipmentVO {
private String platformType; private String platformType;
private Boolean isStrikeTarget; private Boolean isStrikeTarget;
private Boolean isReconTarget; private Boolean isReconTarget;
private Boolean isInterferenceTarget; private Boolean isInterferenceTarget;
private Boolean isDefendImportantPlace; private Boolean isDefendImportantPlace;
//命中率
private Double successTargetRad; private Double successTargetRad;
private String groupType; private String groupType;
@JsonProperty("EquipmentID") @JsonProperty("EquipmentID")

View File

@@ -0,0 +1,17 @@
package com.solution.rule.domain.ultimately.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FireRuleRouteTrackPointVO {
private String index;
private String longitude;
private String latitude;
private String height;
private String speed;
private String psia;
private Integer time;
private String active;
}

View File

@@ -0,0 +1,41 @@
package com.solution.rule.domain.ultimately.vo;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FireRuleTrackParamVO {
private static final ObjectMapper MAPPER = new ObjectMapper();
private Map<String, FireRuleTrackRouteVO> routeMap = new LinkedHashMap<>();
@JsonProperty("Groups")
private List<FireRuleSceneGroupNodeVO> groups;
@JsonProperty("redWeapons")
private List<FireRuleRedWeaponEquipmentVO> redWeapons;
@JsonAnySetter
public void putRoute(String key, JsonNode value) {
if ("Groups".equals(key) || "redWeapons".equals(key) || value == null) {
return;
}
routeMap.put(key, MAPPER.convertValue(value, FireRuleTrackRouteVO.class));
}
@JsonAnyGetter
public Map<String, FireRuleTrackRouteVO> getRouteMap() {
return routeMap;
}
}

View File

@@ -0,0 +1,28 @@
package com.solution.rule.domain.ultimately.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FireRuleTrackRouteVO {
private String name;
@JsonProperty("StartTime")
private Integer startTime;
@JsonProperty("EndTime")
private Integer endTime;
@JsonProperty("TrackType")
private String trackType;
@JsonProperty("HeightType")
private String heightType;
private String seaType;
@JsonProperty("TrackPoints")
private List<FireRuleRouteTrackPointVO> trackPoints;
@JsonProperty("Color")
private String color;
@JsonProperty("PointCount")
private Integer pointCount;
}

View File

@@ -0,0 +1,45 @@
package com.solution.rule.mapper;
import com.solution.rule.domain.config.RuleConfig;
import com.solution.rule.domain.config.RuleConfigParam;
import com.solution.rule.domain.config.RuleConfigQuery;
import com.solution.rule.domain.config.RuleConfigTaskTypeRow;
import com.solution.rule.domain.config.RuleDictItem;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface RuleConfigMapper {
List<RuleConfig> selectRuleConfigList(RuleConfigQuery query);
RuleConfig selectRuleConfigByCode(@Param("ruleCode") String ruleCode);
int countByRuleCode(@Param("ruleCode") String ruleCode);
int insertRuleConfig(RuleConfig ruleConfig);
int updateRuleConfig(RuleConfig ruleConfig);
int deleteRuleConfigByCodes(@Param("ruleCodes") String[] ruleCodes);
List<RuleConfigParam> selectParamsByRuleCode(@Param("ruleCode") String ruleCode);
List<RuleConfigParam> selectParamsByRuleCodes(@Param("ruleCodes") List<String> ruleCodes);
int deleteParamsByRuleCodes(@Param("ruleCodes") String[] ruleCodes);
int insertParamsBatch(@Param("params") List<RuleConfigParam> params);
List<String> selectTaskTypesByRuleCode(@Param("ruleCode") String ruleCode);
List<RuleConfigTaskTypeRow> selectTaskTypesByRuleCodes(@Param("ruleCodes") List<String> ruleCodes);
int deleteTaskTypesByRuleCodes(@Param("ruleCodes") String[] ruleCodes);
int insertTaskTypesBatch(@Param("ruleCode") String ruleCode, @Param("taskTypes") List<String> taskTypes);
List<RuleDictItem> selectDictByType(@Param("dictType") String dictType);
List<RuleConfigParam> selectEnabledParamsForGlobal();
}

View File

@@ -0,0 +1,48 @@
package com.solution.rule.service;
import com.solution.rule.domain.config.RuleConfig;
import com.solution.rule.domain.config.RuleConfigExcelRow;
import com.solution.rule.domain.config.RuleConfigQuery;
import com.solution.rule.domain.config.RuleDictItem;
import com.solution.rule.domain.config.RuleParamMeta;
import com.solution.rule.domain.config.vo.RuleDecisionTreeVO;
import com.solution.rule.domain.config.vo.RuleFourBlocksGraphVO;
import com.solution.rule.domain.config.vo.RuleGraphVO;
import java.util.List;
import java.util.Map;
public interface IRuleConfigService {
List<RuleConfig> selectRuleConfigList(RuleConfigQuery query);
RuleConfig selectRuleConfigByCode(String ruleCode);
int insertRuleConfig(RuleConfig ruleConfig);
int updateRuleConfig(RuleConfig ruleConfig);
int deleteRuleConfigByCodes(String[] ruleCodes);
List<RuleDictItem> selectDictByType(String dictType);
Map<String, Object> loadEnabledGlobalParams();
List<RuleParamMeta> selectParamMetaList();
List<RuleConfigExcelRow> exportRuleConfigRows(RuleConfigQuery query);
String importRuleConfigRows(List<RuleConfigExcelRow> rows, boolean updateSupport);
/**
* 根据当前页规则主数据构建知识图谱(节点与边),参数与任务类型从库批量加载。
*/
RuleGraphVO buildKnowledgeGraph(List<RuleConfig> ruleConfigs);
RuleDecisionTreeVO buildDecisionTree(List<RuleConfig> ruleConfigs);
/**
* 四块规则知识图谱(装备/目标/阵位/航迹):中枢 If/Then + 环形参数,参数值与 {@link #loadEnabledGlobalParams()} 一致。
*/
RuleFourBlocksGraphVO buildFourBlocksKnowledgeGraph();
}

View File

@@ -0,0 +1,23 @@
package com.solution.rule.service;
import com.solution.rule.domain.tasks.Kj3PostResult;
import com.solution.rule.domain.tasks.Kj3Root;
public interface Kj3TaskDataService {
/**
* 解析接口入参 JSON,仅提取红方任务,转换为 data 结构后发送 HTTP POST。
*
* @param kj3Json 传入的 kj-3 JSON 字符串
* @return 发送结果
*/
Kj3PostResult parseAndPostRedTasks(String kj3Json);
/**
* 解析接口入参对象,仅提取红方任务,转换为 data 结构后发送 HTTP POST。
*
* @param root 传入的 kj-3 对象
* @return 发送结果
*/
Kj3PostResult parseAndPostRedTasks(Kj3Root root);
}

View File

@@ -0,0 +1,6 @@
package com.solution.rule.service;
public interface RuleDrlSyncService {
void syncGlobalParamsToDrl();
}

View File

@@ -21,6 +21,7 @@ import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
import com.solution.rule.domain.vo.WeaponModelVO; import com.solution.rule.domain.vo.WeaponModelVO;
import com.solution.rule.mapper.FireRuleMapper; import com.solution.rule.mapper.FireRuleMapper;
import com.solution.rule.service.FireRuleService; import com.solution.rule.service.FireRuleService;
import com.solution.rule.service.IRuleConfigService;
import com.solution.rule.simpstrategy.FireRUleType; import com.solution.rule.simpstrategy.FireRUleType;
import com.solution.rule.simpstrategy.FireRuleStrategy; import com.solution.rule.simpstrategy.FireRuleStrategy;
import com.solution.rule.simpstrategy.FireRuleStrategyFactory; import com.solution.rule.simpstrategy.FireRuleStrategyFactory;
@@ -51,6 +52,8 @@ public class FireRuleServiceImpl implements FireRuleService {
@Autowired @Autowired
private KieBase kieBase; private KieBase kieBase;
@Autowired
private IRuleConfigService ruleConfigService;
/* @Override /* @Override
public WeaponModelVO execute(Integer sceneType, WeaponModelDTO weaponModelDTO) { public WeaponModelVO execute(Integer sceneType, WeaponModelDTO weaponModelDTO) {
@@ -209,7 +212,8 @@ public class FireRuleServiceImpl implements FireRuleService {
} }
//创建KieSession //创建KieSession
KieSession kieSession = kieBase.newKieSession(); KieSession kieSession = kieBase.newKieSession();
Map<String, Object> globalParams = new HashMap<>(); // Map<String, Object> globalParams = new HashMap<>();
Map<String, Object> globalParams = ruleConfigService.loadEnabledGlobalParams();
// globalParams.putAll(FireRuleMatchDefaultParams.defaults()); // globalParams.putAll(FireRuleMatchDefaultParams.defaults());
kieSession.setGlobal("globalParams", globalParams); kieSession.setGlobal("globalParams", globalParams);
//获取红方阵营id //获取红方阵营id

View File

@@ -0,0 +1,418 @@
package com.solution.rule.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.solution.rule.domain.tasks.AssignTargetItem;
import com.solution.rule.domain.tasks.DataOutput;
import com.solution.rule.domain.tasks.Kj3ExecuteBlock;
import com.solution.rule.domain.tasks.Kj3ForceSide;
import com.solution.rule.domain.tasks.Kj3MilitaryItem;
import com.solution.rule.domain.tasks.Kj3MilitaryPlatformComponent;
import com.solution.rule.domain.tasks.Kj3MilitaryScenario;
import com.solution.rule.domain.tasks.Kj3PostResult;
import com.solution.rule.domain.tasks.Kj3RefAttributeObject;
import com.solution.rule.domain.tasks.Kj3Root;
import com.solution.rule.domain.tasks.Kj3TaskNode;
import com.solution.rule.domain.tasks.Kj3TaskPayload;
import com.solution.rule.domain.tasks.Kj3TrackParam;
import com.solution.rule.domain.tasks.Kj3TrackPoint;
import com.solution.rule.domain.tasks.Kj3TargetItem;
import com.solution.rule.domain.tasks.PlatformItem;
import com.solution.rule.domain.tasks.RoutePoint;
import com.solution.rule.domain.tasks.TaskItem;
import com.solution.rule.domain.tasks.TaskTime;
import com.solution.rule.service.Kj3TaskDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.UnknownHostException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@Service
public class Kj3TaskDataServiceImpl implements Kj3TaskDataService {
private static final Logger log = LoggerFactory.getLogger(Kj3TaskDataServiceImpl.class);
private static final String DATA_POST_URL = "http://localhost:5000/bhtree/zhitangCompanyData";
private static final String URL_PLACEHOLDER = "http://TODO-REPLACE";
private static final String RED_SIDE = "红方";
private static final String DEFAULT_ASSIGN_TYPE = "fire";
private final ObjectMapper objectMapper = new ObjectMapper();
@Override
public Kj3PostResult parseAndPostRedTasks(String kj3Json) {
if (ObjectUtil.isEmpty(kj3Json)) {
throw new IllegalArgumentException("kj3Json 不能为空");
}
Kj3Root root = parseKj3Json(kj3Json);
return parseAndPostRedTasks(root);
}
@Override
public Kj3PostResult parseAndPostRedTasks(Kj3Root root) {
if (ObjectUtil.isEmpty(root)) {
throw new IllegalArgumentException("kj3 入参对象不能为空");
}
DataOutput output = transformToDataOutput(root);
String payload = writeJson(output);
log.info("kj3 转换后的 data 输出: {}", payload);
Kj3PostResult result = new Kj3PostResult();
result.setPostUrl(DATA_POST_URL);
result.setTaskCount(output.getTask().size());
if (!isPostUrlConfigured()) {
result.setSuccess(false);
result.setStatusMessage("POST URL 未配置,请将 DATA_POST_URL 从占位值替换为真实地址");
return result;
}
try {
String response = postJson(payload);
result.setSuccess(true);
result.setStatusMessage(response);
} catch (RuntimeException ex) {
result.setSuccess(false);
result.setStatusMessage(ex.getMessage());
}
return result;
}
private boolean isPostUrlConfigured() {
return ObjectUtil.isNotEmpty(DATA_POST_URL) && !URL_PLACEHOLDER.equalsIgnoreCase(DATA_POST_URL);
}
private Kj3Root parseKj3Json(String kj3Json) {
try {
return objectMapper.readValue(kj3Json, Kj3Root.class);
} catch (IOException e) {
throw new RuntimeException("解析接口入参 kj-3 JSON 失败", e);
}
}
private DataOutput transformToDataOutput(Kj3Root root) {
DataOutput output = new DataOutput();
Kj3MilitaryScenario scenario = root == null ? null : root.getMilitaryScenario();
List<Kj3TaskNode> tasks = scenario == null ? Collections.emptyList() : scenario.getTasks();
if (CollUtil.isEmpty(tasks)) {
return output;
}
String redForceSideId = getRedForceSideId(scenario);
List<Kj3TaskNode> redTasks = tasks.stream()
.filter(this::isRedTask)
.collect(Collectors.toList());
for (Kj3TaskNode redTask : redTasks) {
String taskName = resolveTaskName(redTask);
Kj3TaskPayload payload = redTask.getTask();
TaskItem taskItem = new TaskItem();
taskItem.setTaskName(taskName);
taskItem.setTime(buildTaskTime(payload));
taskItem.setPlatform(buildPlatformsForTask(scenario, redForceSideId, payload));
output.getTask().add(taskItem);
AssignTargetItem assignTargetItem = new AssignTargetItem();
assignTargetItem.setTask(taskName);
assignTargetItem.setType(resolveTaskType(payload));
assignTargetItem.setTarget(extractTargets(payload));
output.getAssignTarget().add(assignTargetItem);
}
return output;
}
private boolean isRedTask(Kj3TaskNode taskNode) {
if (taskNode == null) {
return false;
}
if (RED_SIDE.equals(taskNode.getSide())) {
return true;
}
Kj3TaskPayload payload = taskNode.getTask();
return payload != null && RED_SIDE.equals(payload.getSide());
}
private String resolveTaskName(Kj3TaskNode taskNode) {
Kj3TaskPayload payload = taskNode.getTask();
if (payload != null && ObjectUtil.isNotEmpty(payload.getName())) {
return payload.getName();
}
return taskNode.getName();
}
private String resolveTaskType(Kj3TaskPayload payload) {
if (payload != null && ObjectUtil.isNotEmpty(payload.getType())) {
return payload.getType();
}
return DEFAULT_ASSIGN_TYPE;
}
private String getRedForceSideId(Kj3MilitaryScenario scenario) {
if (scenario == null || CollUtil.isEmpty(scenario.getForceSides())) {
return "";
}
for (Kj3ForceSide forceSide : scenario.getForceSides()) {
if (forceSide != null && RED_SIDE.equals(forceSide.getForceSideName())) {
return forceSide.getObjectHandle();
}
}
return "";
}
private List<PlatformItem> buildRedPlatforms(Kj3MilitaryScenario scenario, String redForceSideId) {
if (scenario == null || CollUtil.isEmpty(scenario.getMilitary()) || ObjectUtil.isEmpty(redForceSideId)) {
return new ArrayList<>();
}
Map<String, Kj3TrackParam> trackParamMap = getTrackParamMap(scenario);
List<PlatformItem> platforms = new ArrayList<>();
for (Kj3MilitaryItem militaryItem : scenario.getMilitary()) {
if (militaryItem == null || !redForceSideId.equals(militaryItem.getOwnerForceSide())) {
continue;
}
PlatformItem platformItem = mapMilitaryToPlatform(militaryItem, trackParamMap);
platforms.add(platformItem);
}
return platforms;
}
private List<PlatformItem> buildPlatformsForTask(Kj3MilitaryScenario scenario, String redForceSideId, Kj3TaskPayload payload) {
List<PlatformItem> redPlatforms = buildRedPlatforms(scenario, redForceSideId);
if (CollUtil.isEmpty(redPlatforms)) {
return redPlatforms;
}
Map<String, Kj3TrackParam> trackParamMap = getTrackParamMap(scenario);
String fallbackRouteId = resolveFallbackRouteId(payload);
if (ObjectUtil.isEmpty(fallbackRouteId)) {
return redPlatforms;
}
for (PlatformItem platform : redPlatforms) {
if (CollUtil.isNotEmpty(platform.getRoute())) {
continue;
}
platform.setRoute(buildRoute(fallbackRouteId, trackParamMap));
}
return redPlatforms;
}
private Map<String, Kj3TrackParam> getTrackParamMap(Kj3MilitaryScenario scenario) {
Kj3RefAttributeObject refAttributeObject = scenario.getRefAttributeObject();
if (refAttributeObject == null || refAttributeObject.getTrackParam() == null) {
return new HashMap<>();
}
return refAttributeObject.getTrackParam();
}
private PlatformItem mapMilitaryToPlatform(Kj3MilitaryItem militaryItem, Map<String, Kj3TrackParam> trackParamMap) {
PlatformItem platformItem = new PlatformItem();
platformItem.setName(militaryItem.getName());
platformItem.setPlatformType(militaryItem.getPlatformType());
Kj3MilitaryPlatformComponent positionSourceComponent = resolvePositionSourceComponent(militaryItem);
fillPosition(platformItem, positionSourceComponent);
String trackParamId = resolveTrackParamId(militaryItem);
platformItem.setRoute(buildRoute(trackParamId, trackParamMap));
return platformItem;
}
private String resolveFallbackRouteId(Kj3TaskPayload payload) {
if (payload == null || CollUtil.isEmpty(payload.getExecute())) {
return "";
}
for (Kj3ExecuteBlock executeBlock : payload.getExecute()) {
if (executeBlock == null || CollUtil.isEmpty(executeBlock.getTargetList())) {
continue;
}
for (Kj3TargetItem targetItem : executeBlock.getTargetList()) {
if (targetItem != null && ObjectUtil.isNotEmpty(targetItem.getCruiseRouteId())) {
return targetItem.getCruiseRouteId();
}
}
}
return "";
}
private Kj3MilitaryPlatformComponent resolvePositionSourceComponent(Kj3MilitaryItem militaryItem) {
if (militaryItem.getSubComponents() == null || CollUtil.isEmpty(militaryItem.getSubComponents().getPlatform())) {
return null;
}
for (Kj3MilitaryPlatformComponent component : militaryItem.getSubComponents().getPlatform()) {
if (component != null && CollUtil.isNotEmpty(component.getPositions())) {
return component;
}
}
return militaryItem.getSubComponents().getPlatform().get(0);
}
private String resolveTrackParamId(Kj3MilitaryItem militaryItem) {
if (militaryItem.getSubComponents() == null || CollUtil.isEmpty(militaryItem.getSubComponents().getPlatform())) {
return "";
}
for (Kj3MilitaryPlatformComponent component : militaryItem.getSubComponents().getPlatform()) {
if (component != null && ObjectUtil.isNotEmpty(component.getTrackParamId())) {
return component.getTrackParamId();
}
}
return "";
}
private void fillPosition(PlatformItem platformItem, Kj3MilitaryPlatformComponent component) {
if (component == null || CollUtil.isEmpty(component.getPositions())) {
return;
}
List<Double> positions = component.getPositions();
if (positions.size() > 0 && positions.get(0) != null) {
platformItem.setLongitude(String.valueOf(positions.get(0)));
}
if (positions.size() > 1 && positions.get(1) != null) {
platformItem.setLatitude(String.valueOf(positions.get(1)));
}
if (positions.size() > 2 && positions.get(2) != null) {
platformItem.setAltitude((int) Math.round(positions.get(2)));
}
}
private List<RoutePoint> buildRoute(String trackParamId, Map<String, Kj3TrackParam> trackParamMap) {
if (ObjectUtil.isEmpty(trackParamId)) {
return new ArrayList<>();
}
Kj3TrackParam trackParam = trackParamMap.get(trackParamId);
if (trackParam == null || CollUtil.isEmpty(trackParam.getTrackPoints())) {
return new ArrayList<>();
}
List<RoutePoint> routes = new ArrayList<>();
for (Kj3TrackPoint trackPoint : trackParam.getTrackPoints()) {
if (trackPoint == null) {
continue;
}
RoutePoint routePoint = new RoutePoint();
routePoint.setLongitude(trackPoint.getLongitude());
routePoint.setLatitude(trackPoint.getLatitude());
routePoint.setAltitude(parseInteger(trackPoint.getHeight()));
routePoint.setSpeed(parseInteger(trackPoint.getSpeed()));
routes.add(routePoint);
}
return routes;
}
private TaskTime buildTaskTime(Kj3TaskPayload payload) {
int begin = parseAtTime(payload);
TaskTime taskTime = new TaskTime();
taskTime.setBegin(begin);
taskTime.setEnd(begin);
return taskTime;
}
private int parseAtTime(Kj3TaskPayload payload) {
if (payload == null || ObjectUtil.isEmpty(payload.getAtTime())) {
return 0;
}
try {
return Integer.parseInt(payload.getAtTime().trim());
} catch (NumberFormatException ex) {
return 0;
}
}
private Integer parseInteger(String value) {
if (ObjectUtil.isEmpty(value)) {
return null;
}
try {
return (int) Math.round(Double.parseDouble(value.trim()));
} catch (NumberFormatException ex) {
return null;
}
}
private List<String> extractTargets(Kj3TaskPayload payload) {
if (payload == null || CollUtil.isEmpty(payload.getExecute())) {
return new ArrayList<>();
}
Set<String> uniqueTargets = new LinkedHashSet<>();
for (Kj3ExecuteBlock executeBlock : payload.getExecute()) {
if (executeBlock == null || CollUtil.isEmpty(executeBlock.getTargetList())) {
continue;
}
for (Kj3TargetItem targetItem : executeBlock.getTargetList()) {
if (targetItem == null || ObjectUtil.isEmpty(targetItem.getTargetId())) {
continue;
}
uniqueTargets.add(targetItem.getTargetId());
}
}
return new ArrayList<>(uniqueTargets);
}
private String writeJson(DataOutput output) {
try {
return objectMapper.writeValueAsString(output);
} catch (Exception e) {
throw new RuntimeException("序列化 data 输出失败", e);
}
}
private String postJson(String payload) {
HttpURLConnection connection = null;
try {
URL url = new URL(DATA_POST_URL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connection.setConnectTimeout(10000);
connection.setReadTimeout(10000);
connection.setDoOutput(true);
try (OutputStream outputStream = connection.getOutputStream()) {
outputStream.write(payload.getBytes(StandardCharsets.UTF_8));
outputStream.flush();
}
int status = connection.getResponseCode();
try (InputStream responseStream = status >= 400 ? connection.getErrorStream() : connection.getInputStream()) {
String responseBody = readResponse(responseStream);
return "HTTP " + status + " " + responseBody;
}
} catch (IOException e) {
if (e instanceof UnknownHostException) {
throw new RuntimeException("POST data 输出失败: 无法解析主机,请检查 DATA_POST_URL=" + DATA_POST_URL, e);
}
throw new RuntimeException("POST data 输出失败: " + e.getMessage(), e);
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
private String readResponse(InputStream inputStream) throws IOException {
if (inputStream == null) {
return "";
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
return response.toString();
}
}
}

View File

@@ -0,0 +1,105 @@
package com.solution.rule.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.solution.rule.domain.config.RuleConfigParam;
import com.solution.rule.mapper.RuleConfigMapper;
import com.solution.rule.service.RuleDrlSyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
@Service
public class RuleDrlSyncServiceImpl implements RuleDrlSyncService {
@Autowired
private RuleConfigMapper ruleConfigMapper;
@Override
public void syncGlobalParamsToDrl() {
Path drlPath = resolveDrlPath();
try {
String content = Files.readString(drlPath, StandardCharsets.UTF_8);
String generated = generateParamPutLines(ruleConfigMapper.selectEnabledParamsForGlobal());
String newContent = replaceBuildParamBody(content, generated);
Files.writeString(drlPath, newContent, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException("同步 rule.drl 失败: " + e.getMessage(), e);
}
}
private Path resolveDrlPath() {
Path root = Paths.get(System.getProperty("user.dir"));
Path path = root.resolve("auto-solution-rule/src/main/resources/rules/rule.drl");
if (Files.exists(path)) {
return path;
}
Path fallback = root.resolve("src/main/resources/rules/rule.drl");
if (Files.exists(fallback)) {
return fallback;
}
throw new RuntimeException("未找到 rule.drl 文件路径");
}
private String generateParamPutLines(List<RuleConfigParam> params) {
StringBuilder sb = new StringBuilder();
sb.append(" // ===== 以下由规则配置表自动同步生成(请勿手改 param.put 段) =====\n");
if (CollUtil.isEmpty(params)) {
return sb.toString();
}
for (RuleConfigParam param : params) {
if (param == null || param.getParamKey() == null) {
continue;
}
String valueExpr = toDrlValueExpr(param.getParamVal(), param.getValType());
sb.append(" param.put(\"")
.append(escapeJavaString(param.getParamKey()))
.append("\", ")
.append(valueExpr)
.append(");\n");
}
return sb.toString();
}
private String toDrlValueExpr(String val, String valType) {
if ("bool".equalsIgnoreCase(valType) || "boolean".equalsIgnoreCase(valType)) {
return String.valueOf(Boolean.parseBoolean(val));
}
if ("number".equalsIgnoreCase(valType)) {
if (val == null || val.trim().isEmpty()) {
return "0";
}
return val.trim();
}
// string/json 统一按字符串写入,多个值用英文逗号分隔时保持原样,不做拆分
return "\"" + escapeJavaString(val == null ? "" : val) + "\"";
}
private String replaceBuildParamBody(String content, String generatedLines) {
String marker = " // ===== 以下由规则配置表自动同步生成(请勿手改 param.put 段) =====";
int buildParamStart = content.indexOf("function Map buildParam(){");
int returnPos = content.indexOf(" return param;", buildParamStart);
if (buildParamStart < 0 || returnPos < 0) {
throw new RuntimeException("rule.drl 中未找到 buildParam 函数结构");
}
int oldMarker = content.indexOf(marker, buildParamStart);
int insertFrom;
if (oldMarker > 0 && oldMarker < returnPos) {
insertFrom = oldMarker;
} else {
// 首次同步:保留原内容,追加自动生成段
insertFrom = returnPos;
}
return content.substring(0, insertFrom) + generatedLines + "\n" + content.substring(returnPos);
}
private String escapeJavaString(String s) {
return s.replace("\\", "\\\\").replace("\"", "\\\"");
}
}

View File

@@ -18,14 +18,23 @@ import com.solution.rule.domain.ultimately.vo.FireRuleRedSubComponentsVO;
import com.solution.rule.domain.ultimately.vo.FireRuleRedWeaponEquipmentVO; import com.solution.rule.domain.ultimately.vo.FireRuleRedWeaponEquipmentVO;
import com.solution.rule.domain.ultimately.vo.FireRuleRedPlatformSlotVO; import com.solution.rule.domain.ultimately.vo.FireRuleRedPlatformSlotVO;
import com.solution.rule.domain.ultimately.vo.FireRuleRedWeaponSlotVO; import com.solution.rule.domain.ultimately.vo.FireRuleRedWeaponSlotVO;
import com.solution.rule.domain.ultimately.vo.FireRuleOutputVO;
import com.solution.rule.domain.ultimately.vo.FireRuleRouteTrackPointVO;
import com.solution.rule.domain.ultimately.vo.FireRuleSceneGroupNodeVO;
import com.solution.rule.domain.ultimately.vo.FireRuleSceneTaskNodeVO; import com.solution.rule.domain.ultimately.vo.FireRuleSceneTaskNodeVO;
import com.solution.rule.domain.ultimately.vo.FireRuleSceneTaskPayloadVO; import com.solution.rule.domain.ultimately.vo.FireRuleSceneTaskPayloadVO;
import com.solution.rule.domain.ultimately.vo.FireRuleTrackParamVO;
import com.solution.rule.domain.ultimately.vo.FireRuleTrackRouteVO;
import com.solution.rule.domain.ultimately.vo.FireRuleWingmanDataVO;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -170,6 +179,634 @@ public final class FireRuleRedWeaponOutputFillHelper {
} }
} }
/**
* 航迹规则:按蓝方 trackPoints 生成 {@link FireRuleTrackParamVO#routeMap} 条目(JSON 顶层 key=航迹 id),
* 并将同一 id 写入对应红方任务 {@code execute[0].targetList[*].moveRouteId}。多蓝方任务循环时 merge,不覆盖已有 id。
*/
@SuppressWarnings("rawtypes")
public static void fillTrackParamAndBindMoveRoute(FireRuleOutputVO out, FireRuleTaskInputDTO blueTask, Map params) {
if (out == null || blueTask == null || out.getTasks() == null || out.getTasks().isEmpty()) {
return;
}
ensureTrackParam(out);
List<FireRuleSceneTaskNodeVO> tasks = out.getTasks();
List<FireRuleRedWeaponEquipmentVO> reds = out.getRedWeapons();
if (reds == null) {
reds = Collections.emptyList();
}
List<Coord> warPoly = toWarZonePolygon(blueTask.getWarZoneLocation());
Coord blueAnchor = computeBlueAnchor(blueTask);
Coord clampAnchor = resolveClampAnchor(blueAnchor, warPoly);
boolean zoneClamp = Boolean.parseBoolean(String.valueOf(params.getOrDefault("enableTrackWarZoneClamp", true)));
String dirMode = str(params, "trackPointDirectionMode", "head2next");
double fallbackBrg = readDouble(params, "trackFallbackBearingDeg", readDouble(params, "fallbackBearingDeg", 0d));
double mainBearing = computeTrackBearingDeg(blueTask, dirMode, fallbackBrg);
String algo = str(params, "trackRouteAlgorithm", "followBlue");
String nameSuffix = str(params, "trackRouteNameSuffix", "航迹");
String groundType = str(params, "trackGroundTrackType", "routeLineGround");
String blueIdSeg = sanitizeRouteIdSegment(nz(blueTask.getId()));
for (int i = 0; i < tasks.size(); i++) {
FireRuleSceneTaskNodeVO node = tasks.get(i);
if (node == null) {
continue;
}
FireRuleRedWeaponEquipmentVO red = i < reds.size() ? reds.get(i) : null;
List<TrackNode> nodes = extractSortedBlueTrackNodes(blueTask);
if (nodes.isEmpty()) {
continue;
}
List<TrackNode> transformed = applyTrackRouteAlgorithm(nodes, algo, params, mainBearing, i);
int extraMax = readInt(params, "trackExtraNodesMax", 0);
if (extraMax > 0) {
transformed = injectExtraTrackNodes(transformed, extraMax);
}
if (zoneClamp && warPoly.size() >= 3) {
transformed = clampTrackNodesToWarZone(transformed, warPoly, clampAnchor);
}
boolean air = resolveAirTrack(blueTask, red, params);
String routeName = nz(node.getDrawName()) + nameSuffix;
String routeId = buildUniqueRouteId(out.getTrackParam().getRouteMap(), blueIdSeg, sanitizeRouteIdSegment(nz(node.getId())), i);
FireRuleTrackRouteVO route = buildTrackRouteVo(transformed, routeName, air, groundType);
out.getTrackParam().getRouteMap().put(routeId, route);
bindMoveRouteIdToFirstExecute(node, routeId);
}
}
/**
* 编组规则:按红方装备列表分组,写入 {@link FireRuleTrackParamVO#getGroups}(JSON 键 Groups),
* groupType=addGroup,drawName=领队装备名+后缀;僚机 wingmanData 中 name 为红方 equipmentId。
* 多蓝方任务循环时与航迹一致:在已有 Groups 上追加,且 group id 与已有项冲突时自动加后缀。
*/
@SuppressWarnings("rawtypes")
public static void fillTrackParamGroups(FireRuleOutputVO out, FireRuleTaskInputDTO blueTask, Map params) {
if (out == null || blueTask == null) {
return;
}
boolean enabled = Boolean.parseBoolean(String.valueOf(params.getOrDefault("groupRuleEnabled", true)));
if (!enabled) {
return;
}
List<FireRuleRedWeaponEquipmentVO> reds = out.getRedWeapons();
if (reds == null || reds.isEmpty()) {
return;
}
ensureTrackParam(out);
String dirMode = str(params, "trackPointDirectionMode", "head2next");
double fallbackBrg = readDouble(params, "trackFallbackBearingDeg", readDouble(params, "fallbackBearingDeg", 0d));
double mainBearing = computeTrackBearingDeg(blueTask, dirMode, fallbackBrg);
String mode = str(params, "groupFormationMode", "onePerRed");
int clusterSize = readInt(params, "groupClusterSize", 3);
if (clusterSize < 1) {
clusterSize = 1;
}
int minWing = readInt(params, "groupMinMembersForWingman", 2);
List<List<FireRuleRedWeaponEquipmentVO>> buckets = splitRedsIntoGroups(reds, mode, clusterSize);
List<FireRuleSceneGroupNodeVO> batch = new ArrayList<>();
String blueSeg = sanitizeRouteIdSegment(nz(blueTask.getId()));
int gidx = 0;
for (List<FireRuleRedWeaponEquipmentVO> bucket : buckets) {
if (bucket == null || bucket.isEmpty()) {
continue;
}
FireRuleRedWeaponEquipmentVO leader = pickGroupLeader(bucket, params);
if (leader == null) {
continue;
}
FireRuleSceneGroupNodeVO node = new FireRuleSceneGroupNodeVO();
String baseId = "group_" + blueSeg + "_" + gidx;
node.setId(ensureUniqueGroupId(out.getTrackParam(), baseId));
String suffix = str(params, "groupDrawNameSuffix", "编组");
boolean withIndex = Boolean.parseBoolean(String.valueOf(params.getOrDefault("groupDrawNameWithIndex", false)));
String drawName = nz(leader.getName()) + suffix;
if (withIndex) {
drawName += (gidx + 1);
}
node.setDrawName(drawName);
node.setGroupType("addGroup");
node.setName("addGroup");
node.setLeader(nz(leader.getEquipmentId()));
node.setSort(System.currentTimeMillis() + gidx);
node.setWingmanData(buildWingmanData(bucket, leader, mainBearing, params, minWing));
batch.add(node);
gidx++;
}
mergeGroupsIntoTrackParam(out.getTrackParam(), batch);
}
private static List<List<FireRuleRedWeaponEquipmentVO>> splitRedsIntoGroups(
List<FireRuleRedWeaponEquipmentVO> reds, String mode, int clusterSize) {
List<FireRuleRedWeaponEquipmentVO> clean = new ArrayList<>();
for (FireRuleRedWeaponEquipmentVO r : reds) {
if (r != null) {
clean.add(r);
}
}
List<List<FireRuleRedWeaponEquipmentVO>> out = new ArrayList<>();
if (clean.isEmpty()) {
return out;
}
if ("singleGroup".equalsIgnoreCase(mode)) {
out.add(clean);
return out;
}
if ("clusterByCount".equalsIgnoreCase(mode)) {
for (int i = 0; i < clean.size(); i += clusterSize) {
int end = Math.min(i + clusterSize, clean.size());
out.add(new ArrayList<>(clean.subList(i, end)));
}
return out;
}
for (FireRuleRedWeaponEquipmentVO r : clean) {
out.add(Collections.singletonList(r));
}
return out;
}
private static FireRuleRedWeaponEquipmentVO pickGroupLeader(List<FireRuleRedWeaponEquipmentVO> bucket, Map params) {
if (bucket == null || bucket.isEmpty()) {
return null;
}
String mode = str(params, "groupLeaderPickMode", "byHitRateThenId");
FireRuleRedWeaponEquipmentVO best = bucket.get(0);
for (int i = 1; i < bucket.size(); i++) {
FireRuleRedWeaponEquipmentVO cur = bucket.get(i);
if ("byId".equalsIgnoreCase(mode)) {
if (compareEquipmentId(cur, best) < 0) {
best = cur;
}
} else {
if (isBetterLeaderByHitRateThenId(cur, best)) {
best = cur;
}
}
}
return best;
}
private static boolean isBetterLeaderByHitRateThenId(FireRuleRedWeaponEquipmentVO cand, FireRuleRedWeaponEquipmentVO inc) {
double rc = leaderRad(cand);
double ri = leaderRad(inc);
int c = Double.compare(rc, ri);
if (c > 0) {
return true;
}
if (c < 0) {
return false;
}
return compareEquipmentId(cand, inc) < 0;
}
private static double leaderRad(FireRuleRedWeaponEquipmentVO w) {
if (w == null || w.getSuccessTargetRad() == null) {
return -1d;
}
return w.getSuccessTargetRad().doubleValue();
}
private static int compareEquipmentId(FireRuleRedWeaponEquipmentVO a, FireRuleRedWeaponEquipmentVO b) {
String sa = a != null ? nz(a.getEquipmentId()) : "";
String sb = b != null ? nz(b.getEquipmentId()) : "";
return sa.compareTo(sb);
}
private static List<FireRuleWingmanDataVO> buildWingmanData(
List<FireRuleRedWeaponEquipmentVO> bucket,
FireRuleRedWeaponEquipmentVO leader,
double mainBearing,
Map params,
int minMembersForWingman) {
if (bucket == null || leader == null || bucket.size() < minMembersForWingman) {
return Collections.emptyList();
}
double distBase = readDouble(params, "wingmanDistanceBaseMeters", 100);
double distStep = readDouble(params, "wingmanDistanceStepMeters", 50);
double angBase = readDouble(params, "wingmanAngleBaseDeg", 50);
double angStep = readDouble(params, "wingmanAngleStepDeg", 15);
double altBase = readDouble(params, "wingmanAltBaseMeters", 40);
double altScale = readDouble(params, "wingmanAltScale", 1.0);
List<FireRuleWingmanDataVO> list = new ArrayList<>();
int wmIdx = 0;
for (FireRuleRedWeaponEquipmentVO r : bucket) {
if (r == null || r == leader) {
continue;
}
FireRuleWingmanDataVO w = new FireRuleWingmanDataVO();
w.setKey(wmIdx);
w.setName(nz(r.getEquipmentId()));
w.setDistance((int) Math.round(distBase + wmIdx * distStep));
double deg = normDeg(mainBearing + angBase + wmIdx * angStep);
w.setAngle(String.format(Locale.US, "%.1f", deg));
Double lh = extractFirstPlatformHeight(leader);
Double wh = extractFirstPlatformHeight(r);
double delta = 0d;
if (lh != null && wh != null) {
delta = wh - lh;
}
w.setAlt((int) Math.round(altBase + altScale * delta));
list.add(w);
wmIdx++;
}
return list;
}
private static Double extractFirstPlatformHeight(FireRuleRedWeaponEquipmentVO red) {
if (red == null || red.getSubComponents() == null || red.getSubComponents().getPlatform() == null) {
return null;
}
for (FireRuleRedPlatformSlotVO pl : red.getSubComponents().getPlatform()) {
if (pl == null || pl.getPositions() == null || pl.getPositions().size() < 3) {
continue;
}
return pl.getPositions().get(2);
}
return null;
}
private static double normDeg(double deg) {
double a = deg % 360d;
if (a < 0) {
a += 360d;
}
return a;
}
private static String ensureUniqueGroupId(FireRuleTrackParamVO tp, String baseId) {
Set<String> seen = new HashSet<>();
if (tp.getGroups() != null) {
for (FireRuleSceneGroupNodeVO g : tp.getGroups()) {
if (g != null && !isBlank(g.getId())) {
seen.add(g.getId());
}
}
}
if (!seen.contains(baseId)) {
return baseId;
}
int k = 1;
while (seen.contains(baseId + "_" + k)) {
k++;
}
return baseId + "_" + k;
}
private static void mergeGroupsIntoTrackParam(FireRuleTrackParamVO tp, List<FireRuleSceneGroupNodeVO> batch) {
if (tp == null || batch == null || batch.isEmpty()) {
return;
}
List<FireRuleSceneGroupNodeVO> cur = tp.getGroups();
if (cur == null) {
cur = new ArrayList<>();
} else {
cur = new ArrayList<>(cur);
}
cur.addAll(batch);
tp.setGroups(cur);
}
private static void ensureTrackParam(FireRuleOutputVO out) {
if (out.getTrackParam() == null) {
out.setTrackParam(new FireRuleTrackParamVO());
}
}
private static String buildUniqueRouteId(Map<String, FireRuleTrackRouteVO> existing, String blueSeg, String nodeSeg, int index) {
String base = "route_" + blueSeg + "_" + nodeSeg + "_" + index;
if (existing == null || !existing.containsKey(base)) {
return base;
}
int k = 1;
while (existing.containsKey(base + "_" + k)) {
k++;
}
return base + "_" + k;
}
private static void bindMoveRouteIdToFirstExecute(FireRuleSceneTaskNodeVO node, String routeId) {
if (node == null || isBlank(routeId)) {
return;
}
FireRuleSceneTaskPayloadVO payload = node.getTask();
if (payload == null || payload.getExecute() == null || payload.getExecute().isEmpty()) {
return;
}
FireRuleExecuteBlockVO block = payload.getExecute().get(0);
if (block == null || block.getTargetList() == null) {
return;
}
for (FireRuleExecuteTargetItemVO item : block.getTargetList()) {
if (item != null) {
item.setMoveRouteId(routeId);
}
}
}
private static FireRuleTrackRouteVO buildTrackRouteVo(List<TrackNode> nodes, String name, boolean air, String groundType) {
FireRuleTrackRouteVO vo = new FireRuleTrackRouteVO();
vo.setName(name);
vo.setStartTime(null);
vo.setEndTime(null);
vo.setTrackType(air ? "routeLineAir" : groundType);
vo.setHeightType("msl");
vo.setSeaType("seaLevel");
List<FireRuleRouteTrackPointVO> pts = new ArrayList<>(nodes.size());
for (int j = 0; j < nodes.size(); j++) {
TrackNode tn = nodes.get(j);
FireRuleRouteTrackPointVO p = new FireRuleRouteTrackPointVO();
p.setIndex(String.valueOf(j + 1));
p.setLongitude(formatCoordNumber(tn.coord.lon));
p.setLatitude(formatCoordNumber(tn.coord.lat));
p.setHeight(tn.coord.height != null ? formatCoordNumber(tn.coord.height) : "0");
p.setSpeed(tn.speed != null ? formatCoordNumber(tn.speed) : null);
pts.add(p);
}
vo.setTrackPoints(pts);
vo.setPointCount(pts.size());
return vo;
}
private static String formatCoordNumber(double v) {
return String.valueOf(v);
}
private static boolean resolveAirTrack(FireRuleTaskInputDTO blue, FireRuleRedWeaponEquipmentVO red, Map params) {
String dt = blue != null ? nz(blue.getDataType()) : "";
if (csvContainsAny(str(params, "trackAirDataTypeCsv", ""), dt, false)) {
return true;
}
String blob = nz(blue != null ? blue.getDrawName() : "");
if (red != null) {
blob += " " + nz(red.getName()) + " " + nz(red.getPlatformType());
}
return csvContainsAny(str(params, "trackAirKeywordsCsv", ""), blob, false);
}
private static boolean csvContainsAny(String csv, String text, boolean tokenAsEquals) {
if (isBlank(csv) || text == null) {
return false;
}
String t = text.toLowerCase();
for (String part : csv.split(",")) {
String k = part.trim();
if (k.isEmpty()) {
continue;
}
if (tokenAsEquals) {
if (t.equalsIgnoreCase(k)) {
return true;
}
} else if (text.contains(k) || t.contains(k.toLowerCase())) {
return true;
}
}
return false;
}
private static String sanitizeRouteIdSegment(String raw) {
if (raw == null || raw.isEmpty()) {
return "x";
}
String s = raw.replaceAll("[^a-zA-Z0-9_-]", "_");
return s.isEmpty() ? "x" : s;
}
private static class TrackNode {
Coord coord;
Double speed;
TrackNode(Coord coord, Double speed) {
this.coord = coord;
this.speed = speed;
}
}
private static List<TrackNode> extractSortedBlueTrackNodes(FireRuleTaskInputDTO blueTask) {
List<TrackNode> list = new ArrayList<>();
if (blueTask == null || blueTask.getTrackPoints() == null) {
return list;
}
List<FireRuleTrackPointDTO> pts = new ArrayList<>(blueTask.getTrackPoints());
pts.sort((a, b) -> {
int ia = a != null && a.getIndex() != null ? a.getIndex() : 0;
int ib = b != null && b.getIndex() != null ? b.getIndex() : 0;
return Integer.compare(ia, ib);
});
for (FireRuleTrackPointDTO p : pts) {
if (p == null || p.getLongitude() == null || p.getLatitude() == null) {
continue;
}
list.add(new TrackNode(new Coord(p.getLongitude(), p.getLatitude(), p.getHeight()), p.getSpeed()));
}
return list;
}
private static List<TrackNode> applyTrackRouteAlgorithm(List<TrackNode> nodes, String algo, Map params, double mainBearing, int taskIndex) {
if (nodes == null || nodes.isEmpty()) {
return nodes;
}
String a = algo == null ? "followBlue" : algo.trim();
if ("shortestPath".equalsIgnoreCase(a)) {
return applyShortestPath(nodes, params);
}
if ("flank".equalsIgnoreCase(a)) {
return applyFlank(nodes, params, taskIndex);
}
if ("jam".equalsIgnoreCase(a)) {
return applyJam(nodes, params, mainBearing);
}
return copyTrackNodes(nodes);
}
private static List<TrackNode> copyTrackNodes(List<TrackNode> nodes) {
List<TrackNode> out = new ArrayList<>(nodes.size());
for (TrackNode n : nodes) {
out.add(new TrackNode(new Coord(n.coord.lon, n.coord.lat, n.coord.height), n.speed));
}
return out;
}
private static List<TrackNode> applyShortestPath(List<TrackNode> nodes, Map params) {
int segN = readInt(params, "trackShortPathSegments", 3);
if (segN < 1) {
segN = 1;
}
List<TrackNode> out = new ArrayList<>();
for (int i = 0; i < nodes.size(); i++) {
if (i == 0) {
out.add(copyNode(nodes.get(i)));
continue;
}
Coord a = nodes.get(i - 1).coord;
Coord b = nodes.get(i).coord;
Double spPrev = nodes.get(i - 1).speed;
Double spNext = nodes.get(i).speed;
for (int s = 1; s < segN; s++) {
double t = (double) s / (double) segN;
double lon = a.lon + (b.lon - a.lon) * t;
double lat = a.lat + (b.lat - a.lat) * t;
Double h = null;
if (a.height != null && b.height != null) {
h = a.height + (b.height - a.height) * t;
} else if (b.height != null) {
h = b.height;
} else {
h = a.height;
}
Double spd = null;
if (spPrev != null && spNext != null) {
spd = spPrev + (spNext - spPrev) * t;
} else if (spNext != null) {
spd = spNext;
} else {
spd = spPrev;
}
out.add(new TrackNode(new Coord(lon, lat, h), spd));
}
out.add(copyNode(nodes.get(i)));
}
return out;
}
private static TrackNode copyNode(TrackNode n) {
return new TrackNode(new Coord(n.coord.lon, n.coord.lat, n.coord.height), n.speed);
}
private static List<TrackNode> applyFlank(List<TrackNode> nodes, Map params, int taskIndex) {
double offsetM = readDouble(params, "trackFlankOffsetMeters", 800d);
String sideMode = str(params, "trackFlankSideMode", "alternate");
List<TrackNode> out = new ArrayList<>(nodes.size());
for (int i = 0; i < nodes.size(); i++) {
Coord c = nodes.get(i).coord;
double brg;
if (i < nodes.size() - 1) {
Coord nxt = nodes.get(i + 1).coord;
brg = bearingDeg(c.lon, c.lat, nxt.lon, nxt.lat);
} else if (i > 0) {
Coord prev = nodes.get(i - 1).coord;
brg = bearingDeg(prev.lon, prev.lat, c.lon, c.lat);
} else {
brg = 0d;
}
int sign = flankSign(sideMode, i, taskIndex);
Coord moved = moveByMeters(c, sign * offsetM, brg + 90d);
out.add(new TrackNode(moved, nodes.get(i).speed));
}
return out;
}
private static int flankSign(String mode, int pointIndex, int taskIndex) {
if ("left".equalsIgnoreCase(mode)) {
return 1;
}
if ("right".equalsIgnoreCase(mode)) {
return -1;
}
return (pointIndex + taskIndex) % 2 == 0 ? 1 : -1;
}
private static List<TrackNode> applyJam(List<TrackNode> nodes, Map params, double mainBearing) {
double wobble = readDouble(params, "trackJamWobbleMeters", 400d);
double periods = readDouble(params, "trackJamSegments", 4d);
if (periods < 0.5d) {
periods = 0.5d;
}
int n = nodes.size();
List<TrackNode> out = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
double frac = n <= 1 ? 0d : (double) i / (double) (n - 1);
double lateral = wobble * Math.sin(2d * Math.PI * periods * frac);
Coord c = moveByMeters(nodes.get(i).coord, lateral, mainBearing + 90d);
out.add(new TrackNode(c, nodes.get(i).speed));
}
return out;
}
private static List<TrackNode> injectExtraTrackNodes(List<TrackNode> nodes, int extraMax) {
if (nodes == null || nodes.size() < 2 || extraMax <= 0) {
return nodes;
}
int segs = nodes.size() - 1;
List<Integer> perSeg = new ArrayList<>(Collections.nCopies(segs, 0));
int base = extraMax / segs;
int rem = extraMax % segs;
for (int s = 0; s < segs; s++) {
perSeg.set(s, base + (s < rem ? 1 : 0));
}
List<TrackNode> out = new ArrayList<>();
for (int i = 0; i < nodes.size(); i++) {
out.add(copyNode(nodes.get(i)));
if (i >= nodes.size() - 1) {
break;
}
int ins = perSeg.get(i);
Coord a = nodes.get(i).coord;
Coord b = nodes.get(i + 1).coord;
Double sa = nodes.get(i).speed;
Double sb = nodes.get(i + 1).speed;
for (int k = 1; k <= ins; k++) {
double t = (double) k / (double) (ins + 1);
double lon = a.lon + (b.lon - a.lon) * t;
double lat = a.lat + (b.lat - a.lat) * t;
Double h = null;
if (a.height != null && b.height != null) {
h = a.height + (b.height - a.height) * t;
} else if (b.height != null) {
h = b.height;
} else {
h = a.height;
}
Double spd = null;
if (sa != null && sb != null) {
spd = sa + (sb - sa) * t;
} else if (sb != null) {
spd = sb;
} else {
spd = sa;
}
out.add(new TrackNode(new Coord(lon, lat, h), spd));
}
}
return out;
}
private static List<TrackNode> clampTrackNodesToWarZone(List<TrackNode> nodes, List<Coord> poly, Coord anchor) {
List<TrackNode> out = new ArrayList<>(nodes.size());
for (TrackNode n : nodes) {
Coord c = n.coord;
if (!isPointInPolygon(c, poly)) {
c = projectInsidePolygon(c, anchor, poly);
}
out.add(new TrackNode(c, n.speed));
}
return out;
}
private static Coord resolveClampAnchor(Coord blueAnchor, List<Coord> poly) {
if (poly.size() >= 3) {
if (blueAnchor != null && isPointInPolygon(blueAnchor, poly)) {
return blueAnchor;
}
return polygonCentroid(poly);
}
return blueAnchor != null ? blueAnchor : new Coord(0d, 0d, null);
}
private static Coord polygonCentroid(List<Coord> poly) {
double sx = 0, sy = 0;
for (Coord c : poly) {
sx += c.lon;
sy += c.lat;
}
int n = poly.size();
return new Coord(sx / n, sy / n, null);
}
/** /**
* 目标分配:为每个红方 Tasks 节点写入 task.execute[0].targetList[*].targetId。\n * 目标分配:为每个红方 Tasks 节点写入 task.execute[0].targetList[*].targetId。\n
* targetId 来源:当前蓝方任务 {@link FireRuleTaskInputDTO#getTaskWeapons()} 下每条武器的 equipmentId。\n * targetId 来源:当前蓝方任务 {@link FireRuleTaskInputDTO#getTaskWeapons()} 下每条武器的 equipmentId。\n

View File

@@ -225,6 +225,42 @@ public final class RuleFunction {
FireRuleRedWeaponOutputFillHelper.fillPlatformPositions(out.getRedWeapons(), fact.getTask(), p); FireRuleRedWeaponOutputFillHelper.fillPlatformPositions(out.getRedWeapons(), fact.getTask(), p);
} }
/**
* 航迹规则:根据蓝方 trackPoints 与作战区生成 TrackParam 航迹,并绑定 execute.targetList.moveRouteId。
*/
@SuppressWarnings("rawtypes")
public static void trackRoute(DroolsFact fact, Map globalParams) {
if (fact == null || fact.getTask() == null || fact.getFireRuleOutputVO() == null) {
return;
}
Map<String, Object> p = castParams(globalParams);
boolean enabled = Boolean.parseBoolean(String.valueOf(p.getOrDefault("trackRuleEnabled", true)));
if (!enabled) {
return;
}
FireRuleOutputVO out = fact.getFireRuleOutputVO();
if (out.getTasks() == null || out.getTasks().isEmpty()) {
return;
}
FireRuleRedWeaponOutputFillHelper.fillTrackParamAndBindMoveRoute(out, fact.getTask(), p);
}
/**
* 编组规则:填充 {@link com.solution.rule.domain.ultimately.vo.FireRuleTrackParamVO#getGroups}(groupType=addGroup)与僚机 wingmanData。
*/
@SuppressWarnings("rawtypes")
public static void groupFormation(DroolsFact fact, Map globalParams) {
if (fact == null || fact.getTask() == null || fact.getFireRuleOutputVO() == null) {
return;
}
Map<String, Object> p = castParams(globalParams);
boolean enabled = Boolean.parseBoolean(String.valueOf(p.getOrDefault("groupRuleEnabled", true)));
if (!enabled) {
return;
}
FireRuleRedWeaponOutputFillHelper.fillTrackParamGroups(fact.getFireRuleOutputVO(), fact.getTask(), p);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static Map<String, Object> castParams(Map raw) { private static Map<String, Object> castParams(Map raw) {
return raw == null ? new java.util.HashMap<>() : (Map<String, Object>) raw; return raw == null ? new java.util.HashMap<>() : (Map<String, Object>) raw;

View File

@@ -0,0 +1,392 @@
{
"sourceFile": "区域防空31111_2026-04-02 15_29_03.json",
"fireRuleInputs": [
{
"taskWeapons": [
{
"equipmentId": "40b341f6-d60a-4a29-b84d-2973a3065124",
"name": "导弹",
"supportType": "2001",
"components": [
{
"deviceId": "81c7e7da-cb7b-4435-bba3-1648e946d2b2",
"deviceName": "导弹机动组件",
"componentParams": [
{
"uuid": "b47f34c2-3cba-4be3-a1d5-be0a986dff6f",
"attDefaultValue": "",
"attExplain": "",
"number": 1
}
]
},
{
"deviceId": "4cf26cd0-bd5b-4d4c-a2eb-bca6184be5a1",
"deviceName": "导弹平台",
"componentParams": [
{
"uuid": "32beea38-ffc2-445a-9687-e9bdb087727f",
"attDefaultValue": "",
"attExplain": "",
"number": 1
}
]
}
],
"coordinate": {
"longitude": 124.74107151788,
"latitude": 26.74143394432,
"height": -498.06469972014
},
"number": 10,
"targetId": "0c058874-0c12-4902-8fd0-2cde015965e1"
}
],
"targetId": "0c058874-0c12-4902-8fd0-2cde015965e1",
"warZoneLocation": [
{
"longitude": 122.18971775079,
"latitude": 28.64177652916,
"height": -99.95248993318
},
{
"longitude": 127.22874089381,
"latitude": 28.54075963352,
"height": -1063.0224849918
},
{
"longitude": 127.99831970891,
"latitude": 23.81306022325,
"height": -5900.62524601637
},
{
"longitude": 120.14866648107,
"latitude": 23.90272134296,
"height": -22.17614107099
}
],
"defZoneLocation": []
}
],
"TrackParam": {
"routeLine_220e5b3c-270d-4006-87f0-a0ab4b22deda": {
"name": "F-22航线1",
"StartTime": 0,
"EndTime": 1657,
"TrackType": "routeLineAir",
"HeightType": "msl",
"seaType": "seaLevel",
"TrackPoints": [
{
"index": "1",
"longitude": "124.69258218394617",
"latitude": "27.801527639000142",
"height": "6000",
"speed": "600",
"psia": "0",
"time": 0,
"active": "null"
},
{
"index": "2",
"longitude": "122.9223606765063",
"latitude": "27.585793910609084",
"height": "6000",
"speed": "600",
"psia": "0",
"time": 0,
"active": "null"
},
{
"index": "3",
"longitude": "121.59995205693548",
"latitude": "27.41556157737817",
"height": "6000",
"speed": "600",
"psia": "0",
"time": 0,
"active": "null"
},
{
"index": "4",
"longitude": "121.00161216798338",
"latitude": "27.07354384591234",
"height": "6000",
"speed": "600",
"psia": "0",
"time": 0,
"active": "null"
},
{
"index": "5",
"longitude": "121.0190476615353",
"latitude": "26.599336790536423",
"height": "6000",
"speed": "600",
"psia": "0",
"time": 0,
"active": "null"
},
{
"index": "6",
"longitude": "121.67869100949231",
"latitude": "26.183061747705537",
"height": "6000",
"speed": "600",
"psia": "0",
"time": 0,
"active": "null"
},
{
"index": "7",
"longitude": "123.7900051477299",
"latitude": "25.733670416880216",
"height": "6000",
"speed": "600",
"psia": "0",
"time": 0,
"active": "null"
},
{
"index": "8",
"longitude": "125.47545066085917",
"latitude": "26.136857380879235",
"height": "6000",
"speed": "600",
"psia": "0",
"time": 0,
"active": "null"
}
],
"Color": "rgb(4,161,246)",
"PointCount": 8
},
"Groups": [
{
"allAngle": 0,
"drawName": "J15编组1",
"editPermission": [],
"groupType": "addGroup",
"id": "5dea9ff7-5e45-4f8e-a67f-3ff4187c39ed",
"idKey": "id",
"isSelected": false,
"isShow": false,
"leader": "7a16c098-ceec-4c4d-8a24-8f44976a90ca",
"name": "addGroup",
"parentId": "56a96b1b-14a8-4daf-a2d0-47c7faa4b831_batFormation",
"permission": [
"14bc8ff9-3c93-4218-b01a-e144add196f9"
],
"show": false,
"sort": 1774271497726,
"wingmanData": [
{
"alt": 40,
"angle": "50",
"distance": 100,
"key": 0,
"name": "9aa9e5aa-9273-4c27-88e1-e582ff561685"
}
]
}
],
"redWeapons": [
{
"SupportType": "car",
"TroopsDetail": {},
"Platform_type": "HQ-9发射车",
"isStrikeTarget": false,
"isReconTarget": false,
"isInterferenceTarget": false,
"isDefendImportantPlace": false,
"groupType": "equipment",
"EquipmentID": "b3c6de29-2b27-4500-a9ce-95d0bebc5cb9",
"Name": "HQ-9发射车--5",
"OwnerForceSide": "56a96b1b-14a8-4daf-a2d0-47c7faa4b831",
"PlatID": "56a96b1b-14a8-4daf-a2d0-47c7faa4b831_equipmentPlane",
"SubComponents": {
"communication": [
{
"ObjectHandle": "3ed86636-a33a-41ac-aff2-0627eb1f9b28",
"arithmetic": {
"id": "66cd29fdce08f520f1d9bf0e",
"name": "短波电台"
},
"device": {
"id": "5e0e5b064f1fae2ee9fa1000",
"name": "3MHZ通信电台",
"refId": "5e0e5b064f1fae2ee9fa1000"
},
"deviceId": "0b700ca6-290e-422a-b4e3-73b222809938",
"deviceName": "3MHZ通信电台",
"employLabel": false,
"facilityName": "3MHZ通信电台",
"soleId": "3ed86636-a33a-41ac-aff2-0627eb1f9b28",
"twiceModified": {},
"zLists": [],
"ParentPlat": "04a96dbc-837a-48be-8c04-e4f53586c47e"
}
],
"motorized_assembly": [
{
"ObjectHandle": "83ea5d33-90f4-4fd8-9121-eced6c7a44ea",
"arithmetic": {},
"device": {},
"deviceId": "55915bc4-c825-43c4-93eb-6a76ab345e42",
"deviceName": "",
"soleId": "83ea5d33-90f4-4fd8-9121-eced6c7a44ea",
"ParentPlat": "04a96dbc-837a-48be-8c04-e4f53586c47e"
}
],
"platform": [
{
"ObjectHandle": "04a96dbc-837a-48be-8c04-e4f53586c47e",
"arithmetic": {
"id": "68876d0fd41989f086e905b8",
"name": "通用发射车算法"
},
"device": {
"id": "68876d2dd41989f086e905b9",
"name": "发射车平台",
"refId": "68876d2dd41989f086e905b9"
},
"deviceId": "164c75ec-6db5-48f9-8285-a7e726fd2a11",
"deviceName": "发射车平台",
"employLabel": false,
"facilityName": "发射车平台",
"soleId": "87905d6b-857a-4c5a-a922-5e2d191588d4",
"twiceModified": {},
"zLists": [],
"TrackParamId": "",
"positions": [
119.28585462691,
25.67974332623,
34.28352933882
]
}
],
"weapon": [
{
"ObjectHandle": "4e575d4d-2f36-436b-9939-0b96cde96b89",
"arithmetic": {
"id": "669dd6356bc286bd64e5d66c",
"name": "发射架算法"
},
"codedQueue": "weapon.launcher",
"configuration": {
"classifyName": "导弹平台",
"isMount": 1,
"mountedWeapon": {
"_id": "68f681794ddde62a52c7e569",
"name": "HQ-9"
},
"number": 4
},
"device": {
"id": "67ff279dafa7ea5aaa3a1236",
"name": "通用发射架",
"refId": "b9665788-9437-40fb-8a24-eff3d4d3b529"
},
"deviceId": "4e910ccf-d937-4a93-9b68-116167eda202",
"deviceName": "通用发射架",
"employLabel": false,
"facilityName": "通用发射架",
"serialNumber": "launcher",
"soleId": "4e575d4d-2f36-436b-9939-0b96cde96b89",
"twiceModified": {
"launcherType": "sam"
},
"zLists": [],
"ParentPlat": "04a96dbc-837a-48be-8c04-e4f53586c47e"
}
]
}
}
]
},
"Tasks": [
{
"color": "rgb(220,39,39)",
"dataType": "taskPlane",
"drawName": "HQ-9发射车--3打击任务",
"groupType": "tasks",
"id": "41d3c5ce-3fda-4dee-a38f-fd3ae7e15e69",
"idKey": "id",
"isSelected": false,
"name": "HQ-9发射车--3打击任务",
"parentId": "56a96b1b-14a8-4daf-a2d0-47c7faa4b831_taskPlane",
"permission": [
"14bc8ff9-3c93-4218-b01a-e144add196f9",
"56a96b1b-14a8-4daf-a2d0-47c7faa4b831"
],
"show": true,
"side": "红方",
"sort": 1774271151846,
"task": {
"at_time": "180",
"attackId": "267c5d87-bf36-42f2-b0a8-09c608d94b62",
"color": "rgb(220,39,39)",
"departureAirport": "",
"execute": [
{
"targetList": [
{
"ID": "fbddc49c-f7b0-4d07-8000-1b5a2633c461",
"arrayPositionId": 4,
"arrayPositionIdBak": "",
"at_time": {
"timeUp": true,
"value": 180
},
"attackType": "",
"boost": "",
"bootTime": "",
"companion": "",
"cruiseRouteId": "routeLine_f01be820-33ca-4843-8354-3f93a9986fe3",
"cruiseRouteOffset": [
{
"UpOrDown": true,
"value": 0
},
{
"BeforeOrAfter": true,
"value": 0
},
{
"LeftOrRight": true,
"value": 0
}
],
"moveRouteId": "routeLine_de092f0b-d8a3-4382-8e46-398efae3649c",
"fireType": "absolute",
"strategy": [],
"targetId": "dd20d7d9-7ce8-4531-aa0c-0b2056e7fbcd",
"times_interval": 1,
"weaponId": "HQ-9",
"weaponRelease": "",
"weaponType": "",
"weaponUseCount": 3
}
],
"type": "assault"
}
],
"landAirport": "",
"missionList": [
{
"label": "HQ-9(4)",
"launcherType": "sam",
"number": 4,
"value": "HQ-9"
}
],
"name": "HQ-9发射车--3打击任务",
"side": "红方",
"sideId": "56a96b1b-14a8-4daf-a2d0-47c7faa4b831",
"speed": 600,
"type": "assault",
"weaponId": ""
}
}
]
}

View File

@@ -82,12 +82,13 @@
</resultMap> </resultMap>
<select id="findComponentsByPlatformId" resultMap="VPlatformComponentMap"> <select id="findComponentsByPlatformId" resultMap="VPlatformComponentMap">
SELECT * FROM platform_component SELECT * FROM platform_component
WHERE platform_id=#{platformId} WHERE platform_id=#{platformId} AND platform_component.type = "comm"
</select> </select>
<resultMap id="VPBasicPlatformMap" type="com.solution.rule.domain.BasicPlatform"> <resultMap id="VPBasicPlatformMap" type="com.solution.rule.domain.BasicPlatform">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="name" column="name"/> <result property="name" column="name"/>
<result property="behaviortreeId" column="behaviortree_id"/>
<result property="description" column="description"/> <result property="description" column="description"/>
</resultMap> </resultMap>
<select id="findAllBasicPlatformComponents" resultMap="VPBasicPlatformMap"> <select id="findAllBasicPlatformComponents" resultMap="VPBasicPlatformMap">
@@ -114,11 +115,19 @@
WHERE pc.type = 'comm' WHERE pc.type = 'comm'
AND p.scenario_id = #{scenarioId} AND p.scenario_id = #{scenarioId}
ORDER BY p.name,pc.name ORDER BY p.name,pc.name
<!-- SELECT
p.id,
p.name,
p.description
FROM platform p
LEFT JOIN platform_component pc ON p.id = pc.platform_id
WHERE pc.type = 'comm'
AND p.scenario_id = #{scenarioId}
ORDER BY p.name,pc.name
</select> </select>
<select id="findAllPlatformComponents" resultMap="VPlatformMap"> <select id="findAllPlatformComponents" resultMap="VPlatformMap">
SELECT * SELECT *
FROM platform FROM platform-->
</select> </select>
</mapper>
</mapper>

View File

@@ -0,0 +1,222 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.solution.rule.mapper.RuleConfigMapper">
<resultMap id="RuleConfigMap" type="com.solution.rule.domain.config.RuleConfig">
<id property="id" column="id"/>
<result property="ruleCode" column="rule_code"/>
<result property="ruleName" column="rule_name"/>
<result property="levelCode" column="level_code"/>
<result property="kindCode" column="kind_code"/>
<result property="moduleCode" column="module_code"/>
<result property="priorityNo" column="priority_no"/>
<result property="conditionExpr" column="condition_expr"/>
<result property="actionExpr" column="action_expr"/>
<result property="versionNo" column="version_no"/>
<result property="enabled" column="enabled"/>
<result property="remark" column="remark"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
</resultMap>
<resultMap id="RuleConfigParamMap" type="com.solution.rule.domain.config.RuleConfigParam">
<result property="ruleCode" column="rule_code"/>
<result property="paramKey" column="param_key"/>
<result property="paramVal" column="param_val"/>
<result property="valType" column="val_type"/>
<result property="paramName" column="param_name"/>
<result property="sortNo" column="sort_no"/>
<result property="enabled" column="enabled"/>
<result property="remark" column="remark"/>
</resultMap>
<resultMap id="RuleDictItemMap" type="com.solution.rule.domain.config.RuleDictItem">
<result property="dictType" column="dict_type"/>
<result property="dictCode" column="dict_code"/>
<result property="dictName" column="dict_name"/>
<result property="sortNo" column="sort_no"/>
<result property="enabled" column="enabled"/>
<result property="remark" column="remark"/>
</resultMap>
<resultMap id="RuleConfigTaskTypeRowMap" type="com.solution.rule.domain.config.RuleConfigTaskTypeRow">
<result property="ruleCode" column="rule_code"/>
<result property="taskTypeCode" column="task_type_code"/>
</resultMap>
<select id="selectRuleConfigList" resultMap="RuleConfigMap">
SELECT id, rule_code, rule_name, level_code, kind_code, module_code, priority_no,
condition_expr, action_expr, version_no, enabled, remark, created_at, updated_at
FROM rule_item
<where>
<if test="ruleCode != null and ruleCode != ''">
AND rule_code = #{ruleCode}
</if>
<if test="ruleName != null and ruleName != ''">
AND rule_name LIKE CONCAT('%', #{ruleName}, '%')
</if>
<if test="levelCode != null and levelCode != ''">
AND level_code = #{levelCode}
</if>
<if test="kindCode != null and kindCode != ''">
AND kind_code = #{kindCode}
</if>
<if test="moduleCode != null and moduleCode != ''">
AND module_code = #{moduleCode}
</if>
<if test="enabled != null">
AND enabled = #{enabled}
</if>
</where>
ORDER BY priority_no ASC, updated_at DESC
</select>
<select id="selectRuleConfigByCode" resultMap="RuleConfigMap">
SELECT id, rule_code, rule_name, level_code, kind_code, module_code, priority_no,
condition_expr, action_expr, version_no, enabled, remark, created_at, updated_at
FROM rule_item
WHERE rule_code = #{ruleCode}
</select>
<select id="countByRuleCode" resultType="int">
SELECT COUNT(1)
FROM rule_item
WHERE rule_code = #{ruleCode}
</select>
<insert id="insertRuleConfig" parameterType="com.solution.rule.domain.config.RuleConfig">
INSERT INTO rule_item
(rule_code, rule_name, level_code, kind_code, module_code, priority_no, condition_expr,
action_expr, version_no, enabled, remark, created_at, updated_at)
VALUES
(#{ruleCode}, #{ruleName}, #{levelCode}, #{kindCode}, #{moduleCode}, #{priorityNo}, #{conditionExpr},
#{actionExpr}, #{versionNo}, #{enabled}, #{remark}, NOW(), NOW())
</insert>
<update id="updateRuleConfig" parameterType="com.solution.rule.domain.config.RuleConfig">
UPDATE rule_item
<set>
<if test="ruleName != null">rule_name = #{ruleName},</if>
<if test="levelCode != null">level_code = #{levelCode},</if>
<if test="kindCode != null">kind_code = #{kindCode},</if>
<if test="moduleCode != null">module_code = #{moduleCode},</if>
<if test="priorityNo != null">priority_no = #{priorityNo},</if>
<if test="conditionExpr != null">condition_expr = #{conditionExpr},</if>
<if test="actionExpr != null">action_expr = #{actionExpr},</if>
<if test="versionNo != null">version_no = #{versionNo},</if>
<if test="enabled != null">enabled = #{enabled},</if>
<if test="remark != null">remark = #{remark},</if>
updated_at = NOW()
</set>
WHERE rule_code = #{ruleCode}
</update>
<delete id="deleteRuleConfigByCodes">
DELETE FROM rule_item
WHERE rule_code IN
<foreach item="code" collection="ruleCodes" open="(" separator="," close=")">
#{code}
</foreach>
</delete>
<select id="selectParamsByRuleCode" resultMap="RuleConfigParamMap">
SELECT rule_code, param_key, param_val, val_type, param_name, sort_no, enabled, remark
FROM rule_item_param
WHERE rule_code = #{ruleCode}
ORDER BY sort_no ASC, id ASC
</select>
<select id="selectParamsByRuleCodes" resultMap="RuleConfigParamMap">
SELECT rule_code, param_key, param_val, val_type, param_name, sort_no, enabled, remark
FROM rule_item_param
<where>
<if test="ruleCodes != null and ruleCodes.size() &gt; 0">
rule_code IN
<foreach collection="ruleCodes" item="c" open="(" separator="," close=")">
#{c}
</foreach>
</if>
<if test="ruleCodes == null or ruleCodes.size() == 0">
1 = 0
</if>
</where>
ORDER BY rule_code ASC, sort_no ASC, id ASC
</select>
<delete id="deleteParamsByRuleCodes">
DELETE FROM rule_item_param
WHERE rule_code IN
<foreach item="code" collection="ruleCodes" open="(" separator="," close=")">
#{code}
</foreach>
</delete>
<insert id="insertParamsBatch">
INSERT INTO rule_item_param
(rule_code, param_key, param_val, val_type, param_name, sort_no, enabled, remark, created_at, updated_at)
VALUES
<foreach item="item" collection="params" separator=",">
(#{item.ruleCode}, #{item.paramKey}, #{item.paramVal}, #{item.valType}, #{item.paramName},
#{item.sortNo}, #{item.enabled}, #{item.remark}, NOW(), NOW())
</foreach>
</insert>
<select id="selectTaskTypesByRuleCode" resultType="string">
SELECT task_type_code
FROM rule_item_task_type
WHERE rule_code = #{ruleCode}
ORDER BY id ASC
</select>
<select id="selectTaskTypesByRuleCodes" resultMap="RuleConfigTaskTypeRowMap">
SELECT rule_code, task_type_code
FROM rule_item_task_type
<where>
<if test="ruleCodes != null and ruleCodes.size() &gt; 0">
rule_code IN
<foreach collection="ruleCodes" item="c" open="(" separator="," close=")">
#{c}
</foreach>
</if>
<if test="ruleCodes == null or ruleCodes.size() == 0">
1 = 0
</if>
</where>
ORDER BY rule_code ASC, id ASC
</select>
<delete id="deleteTaskTypesByRuleCodes">
DELETE FROM rule_item_task_type
WHERE rule_code IN
<foreach item="code" collection="ruleCodes" open="(" separator="," close=")">
#{code}
</foreach>
</delete>
<insert id="insertTaskTypesBatch">
INSERT INTO rule_item_task_type (rule_code, task_type_code, created_at)
VALUES
<foreach item="taskType" collection="taskTypes" separator=",">
(#{ruleCode}, #{taskType}, NOW())
</foreach>
</insert>
<select id="selectDictByType" resultMap="RuleDictItemMap">
SELECT dict_type, dict_code, dict_name, sort_no, enabled, remark
FROM rule_dict
WHERE dict_type = #{dictType}
ORDER BY sort_no ASC, id ASC
</select>
<select id="selectEnabledParamsForGlobal" resultMap="RuleConfigParamMap">
SELECT p.rule_code, p.param_key, p.param_val, p.val_type, p.param_name, p.sort_no, p.enabled, p.remark
FROM rule_item_param p
INNER JOIN rule_item r ON p.rule_code = r.rule_code
WHERE r.enabled = 1
AND p.enabled = 1
ORDER BY r.priority_no ASC, p.sort_no ASC, p.id ASC
</select>
</mapper>

View File

@@ -6,6 +6,8 @@ import java.util.Map;
import static com.solution.rule.utils.RuleFunction.equipmentRule; import static com.solution.rule.utils.RuleFunction.equipmentRule;
import static com.solution.rule.utils.RuleFunction.target; import static com.solution.rule.utils.RuleFunction.target;
import static com.solution.rule.utils.RuleFunction.position; import static com.solution.rule.utils.RuleFunction.position;
import static com.solution.rule.utils.RuleFunction.trackRoute;
import static com.solution.rule.utils.RuleFunction.groupFormation;
global java.util.Map globalParams; global java.util.Map globalParams;
@@ -77,7 +79,7 @@ function Map buildParam(){
param.put("missileScore", 1); param.put("missileScore", 1);
// ===================== 目标分配参数(写入 Tasks.task.execute) ===================== // ===================== 目标分配参数(写入 Tasks.task.execute) =====================
// executeTypeDefault:生成 execute[0] 的类型字段 // executeTypeDefault:生成 execute[0] 的类型字段 取值:strike_test/assault
param.put("executeTypeDefault", "assault"); param.put("executeTypeDefault", "assault");
// targetPickMode:roundRobin(稳定轮询) / random(伪随机但同输入稳定) // targetPickMode:roundRobin(稳定轮询) / random(伪随机但同输入稳定)
param.put("targetPickMode", "roundRobin"); param.put("targetPickMode", "roundRobin");
@@ -147,16 +149,162 @@ function Map buildParam(){
// minInterPlatformDistanceMeters:平台最小间距(米)下限,用于抑制平台点位过度重叠。 // minInterPlatformDistanceMeters:平台最小间距(米)下限,用于抑制平台点位过度重叠。
param.put("minInterPlatformDistanceMeters", 80); param.put("minInterPlatformDistanceMeters", 80);
// ===================== 航迹规则参数(写入 TrackParam 动态 key + execute.targetList.moveRouteId) =====================
// trackRuleEnabled:是否启用航迹生成与 moveRouteId 绑定。
param.put("trackRuleEnabled", true);
// trackRouteAlgorithm:航迹变形算法。followBlue(默认) / shortestPath / flank / jam
param.put("trackRouteAlgorithm", "followBlue");
// trackRouteNameSuffix:航迹名称 = 红方任务 drawName + 此后缀(默认「航迹」→ 如 xxx打击任务航迹)
param.put("trackRouteNameSuffix", "航迹");
// trackAirDataTypeCsv:蓝方 dataType 命中任一子串(忽略大小写)则 TrackType=routeLineAir
param.put("trackAirDataTypeCsv", "taskPlane,air,plane,flight");
// trackAirKeywordsCsv:蓝方 drawName 或红方 name/platformType 命中任一子串则视为飞行航迹
param.put("trackAirKeywordsCsv", "机,飞,空,J-,F-,无人机,直升机");
// trackGroundTrackType:非飞行类时 TrackType 取值(可先占位,后续再接地面路网)
param.put("trackGroundTrackType", "routeLineGround");
// 航迹侧向算法复用上方「阵位规则」中的 trackPointDirectionMode(head2next / tail2prev);缺省回退见 trackFallbackBearingDeg
param.put("trackFallbackBearingDeg", 0);
// enableTrackWarZoneClamp:航迹点是否约束在 warZoneLocation 多边形内
param.put("enableTrackWarZoneClamp", true);
// trackExtraNodesMax:在蓝方航迹点基础上最多额外插入的点数(0=与蓝方点数持平;>0 时在中段均匀插值)
param.put("trackExtraNodesMax", 0);
// shortestPath:相邻两点间直线插值分段数(>=1),越大折线越平滑(非真实路网最短路径)
param.put("trackShortPathSegments", 3);
// flank:侧向偏移距离(米);trackFlankSideMode:alternate / left / right
param.put("trackFlankOffsetMeters", 800);
param.put("trackFlankSideMode", "alternate");
// jam:正弦扰动振幅(米)、沿航迹起伏周期数(越大摆动越密)
param.put("trackJamWobbleMeters", 400);
param.put("trackJamSegments", 4);
// ===================== 编组规则参数(写入 TrackParam.Groups + wingmanData) =====================
// groupRuleEnabled:是否生成编组节点。
param.put("groupRuleEnabled", true);
// groupDrawNameSuffix:drawName = 领队装备 Name + 此后缀(默认「编组」)
param.put("groupDrawNameSuffix", "编组");
// groupDrawNameWithIndex:是否在 drawName 末尾追加序号(避免多组同名),如 J15编组1
param.put("groupDrawNameWithIndex", false);
// groupFormationMode:onePerRed(每件红装一组) / clusterByCount(按固定人数分组) / singleGroup(全部一组)
param.put("groupFormationMode", "onePerRed");
// groupClusterSize:clusterByCount 模式下每组人数上限(>=1)
param.put("groupClusterSize", 3);
// groupLeaderPickMode:byHitRateThenId(命中率高优先,平手 equipmentId 小) / byId(equipmentId 字典序最小)
param.put("groupLeaderPickMode", "byHitRateThenId");
// groupMinMembersForWingman:组内人数达到该值才生成 wingmanData(否则仅 leader 壳,僚机列表为空)
param.put("groupMinMembersForWingman", 2);
// wingman 几何参数(相对蓝方主航向 mainBearing 叠加)
param.put("wingmanDistanceBaseMeters", 100);
param.put("wingmanDistanceStepMeters", 50);
param.put("wingmanAngleBaseDeg", 50);
param.put("wingmanAngleStepDeg", 15);
param.put("wingmanAltBaseMeters", 40);
param.put("wingmanAltScale", 1.0);
// ===== 以下由规则配置表自动同步生成(请勿手改 param.put 段) =====
param.put("groupRuleEnabled", true);
param.put("groupDrawNameSuffix", "编组");
param.put("groupDrawNameWithIndex", false);
param.put("groupFormationMode", "onePerRed");
param.put("groupClusterSize", 3);
param.put("groupLeaderPickMode", "byHitRateThenId");
param.put("groupMinMembersForWingman", 2);
param.put("wingmanDistanceBaseMeters", 100);
param.put("wingmanDistanceStepMeters", 50);
param.put("wingmanAngleBaseDeg", 50);
param.put("wingmanAngleStepDeg", 15);
param.put("wingmanAltBaseMeters", 40);
param.put("wingmanAltScale", 1.0);
param.put("enableTrackWarZoneClamp", true);
param.put("trackRuleEnabled", true);
param.put("trackRouteAlgorithm", "followBlue");
param.put("trackRouteNameSuffix", "航迹");
param.put("trackAirDataTypeCsv", "taskPlane,air,plane,flight");
param.put("trackAirKeywordsCsv", "机,飞,空,J-,F-,无人机,直升机");
param.put("trackGroundTrackType", "routeLineGround");
param.put("trackFallbackBearingDeg", 0);
param.put("trackExtraNodesMax", 0);
param.put("trackShortPathSegments", 3);
param.put("trackFlankOffsetMeters", 800);
param.put("trackFlankSideMode", "alternate");
param.put("trackJamWobbleMeters", 400);
param.put("trackJamSegments", 4);
param.put("enableWarZoneClamp", true);
param.put("positionRuleEnabled", true);
param.put("positionAnchorMode", "hybrid");
param.put("trackPointDirectionMode", "head2next");
param.put("fallbackBearingDeg", 0);
param.put("deployDistanceKmMin", 8);
param.put("deployDistanceKmMax", 30);
param.put("deployDistanceKmDefault", 15);
param.put("distanceByPlatformCsv", "");
param.put("formationType", "line");
param.put("formationSpacingMeters", 300);
param.put("formationHeadingOffsetDeg", 15);
param.put("defaultDeployHeight", 30);
param.put("heightFollowBlueRatio", 0.0);
param.put("warZoneClampMode", "nearestInside");
param.put("minInterPlatformDistanceMeters", 80);
param.put("redHitRateThreshold", 0.6);
param.put("maxExtraWeaponsPerTask", 2);
param.put("maxSupplementRounds", 2);
param.put("extraPickMinScore", 1);
param.put("executeTypeDefault", "assault");
param.put("targetPickMode", "roundRobin");
param.put("minTargetsPerRed", 1);
param.put("maxTargetsPerRedCap", 3);
param.put("radToTargetsCsv", "0.8:1,0.5:2,0.2:3");
param.put("rangeParseRegex", "(\\\\d+(?:\\\\.\\\\d+)?)");
param.put("rangeUnit", "km");
param.put("minRangeToAllowAssignKm", 0);
param.put("weight", 1);
param.put("minSelectedScore", 1);
param.put("tieBreak", "equipmentId");
param.put("outputDrawNameSuffix", "打击任务");
param.put("ruleSlotCount", 3);
param.put("blueRuleKeywords_1", "F-16,F-35");
param.put("redRuleKeywords_1", "防空,导弹,无人机");
param.put("ruleScore_1", 5);
param.put("blueRuleKeywords_2", "坦克,装甲");
param.put("redRuleKeywords_2", "反坦克");
param.put("ruleScore_2", 4);
param.put("blueRuleKeywords_3", "地面,突击");
param.put("redRuleKeywords_3", "远火,榴弹,炮");
param.put("ruleScore_3", 2);
param.put("bluePlatformKeywords_air", "F-16,J-10,F-35");
param.put("redPreferredWhenBlueAir", "防空,导弹,无人机,直升机,空空");
param.put("airScore", 2);
param.put("airTaskKeywords", "空中,制空,拦截,空战");
param.put("airTaskScore", 10);
param.put("groundTaskKeywords", "地面,突击,登陆");
param.put("redPreferredWhenGround", "远火,榴弹,炮,火箭");
param.put("groundScore", 1);
param.put("tankKeywords", "坦克,装甲");
param.put("redMatchKeywords_tank", "反坦克");
param.put("tankScore", 1);
param.put("missileKeywords", "导弹,火箭弹,巡航");
param.put("redMatchKeywords_missile", "防空,导弹,导弹发射");
param.put("missileScore", 1);
return param; return param;
} }
function void mergeDefaultParams(Map current){
Map defaults = buildParam();
for (Object k : defaults.keySet()) {
if (!current.containsKey(k)) {
current.put(k, defaults.get(k));
}
}
}
rule "装备匹配" rule "装备匹配"
salience 100 salience 100
when when
$fact : DroolsFact(task != null) $fact : DroolsFact(task != null)
then then
// 以本文件 buildParam 为真源覆盖同名键,再执行 Java 侧匹配逻辑 // 以本文件 buildParam 为真源覆盖同名键,再执行 Java 侧匹配逻辑
globalParams.putAll(buildParam()); // globalParams.putAll(buildParam());
mergeDefaultParams(globalParams);
equipmentRule($fact, globalParams); equipmentRule($fact, globalParams);
end end
@@ -166,7 +314,8 @@ when
$fact : DroolsFact(task != null) $fact : DroolsFact(task != null)
then then
// 显式目标分配规则:填充 Tasks.task.execute.targetList[*].targetId // 显式目标分配规则:填充 Tasks.task.execute.targetList[*].targetId
globalParams.putAll(buildParam()); // globalParams.putAll(buildParam());
mergeDefaultParams(globalParams);
target($fact, globalParams); target($fact, globalParams);
end end
@@ -176,6 +325,29 @@ when
$fact : DroolsFact(task != null) $fact : DroolsFact(task != null)
then then
// 显式阵位规则:填充 redWeapons.SubComponents.platform[].positions // 显式阵位规则:填充 redWeapons.SubComponents.platform[].positions
globalParams.putAll(buildParam()); // globalParams.putAll(buildParam());
mergeDefaultParams(globalParams);
position($fact, globalParams); position($fact, globalParams);
end end
rule "航迹匹配"
salience 70
when
$fact : DroolsFact(task != null)
then
// 显式航迹规则:填充 TrackParam 下各航迹 id,并绑定 execute[0].targetList[*].moveRouteId
// globalParams.putAll(buildParam());
mergeDefaultParams(globalParams);
trackRoute($fact, globalParams);
end
rule "编组匹配"
salience 60
when
$fact : DroolsFact(task != null)
then
// 显式编组规则:填充 TrackParam.Groups(groupType=addGroup)与 wingmanData
// globalParams.putAll(buildParam());
mergeDefaultParams(globalParams);
groupFormation($fact, globalParams);
end

View File

@@ -0,0 +1,67 @@
-- 规则主数据表结构(MySQL 8+)
-- 说明:用于前端按“层级->种类->规则项”进行展示与增删改查。
CREATE TABLE IF NOT EXISTS `rule_dict` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`dict_type` VARCHAR(32) NOT NULL COMMENT '字典类型(level/kind/task_type/status)',
`dict_code` VARCHAR(64) NOT NULL COMMENT '字典编码',
`dict_name` VARCHAR(64) NOT NULL COMMENT '字典名称',
`sort_no` INT NOT NULL DEFAULT 0 COMMENT '排序号',
`enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用(1是0否)',
`remark` VARCHAR(255) DEFAULT NULL COMMENT '备注',
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_rule_dict_type_code` (`dict_type`, `dict_code`),
KEY `idx_rule_dict_type_enabled` (`dict_type`, `enabled`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='规则字典表';
CREATE TABLE IF NOT EXISTS `rule_item` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`rule_code` VARCHAR(64) NOT NULL COMMENT '规则编码',
`rule_name` VARCHAR(128) NOT NULL COMMENT '规则名称',
`level_code` VARCHAR(32) NOT NULL COMMENT '规则层级(task/action/platform)',
`kind_code` VARCHAR(32) NOT NULL COMMENT '规则种类(select/assign/deploy/config/mode/spacetime/relation/limit)',
`module_code` VARCHAR(32) NOT NULL COMMENT '规则模块(equipment/target/position/track/group)',
`priority_no` INT NOT NULL DEFAULT 100 COMMENT '优先级(数字越小越先执行)',
`condition_expr` VARCHAR(1024) DEFAULT NULL COMMENT '条件表达式(展示用)',
`action_expr` VARCHAR(1024) DEFAULT NULL COMMENT '动作表达式(展示用)',
`version_no` INT NOT NULL DEFAULT 1 COMMENT '版本号',
`enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用(1是0否)',
`remark` VARCHAR(255) DEFAULT NULL COMMENT '备注',
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_rule_item_code` (`rule_code`),
KEY `idx_rule_item_level_kind` (`level_code`, `kind_code`),
KEY `idx_rule_item_module_enabled` (`module_code`, `enabled`),
KEY `idx_rule_item_priority` (`priority_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='规则主表';
CREATE TABLE IF NOT EXISTS `rule_item_task_type` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`rule_code` VARCHAR(64) NOT NULL COMMENT '规则编码',
`task_type_code` VARCHAR(32) NOT NULL COMMENT '任务类型编码',
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_rule_task_type` (`rule_code`, `task_type_code`),
KEY `idx_rule_task_type` (`task_type_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='规则适用任务类型关联表';
CREATE TABLE IF NOT EXISTS `rule_item_param` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`rule_code` VARCHAR(64) NOT NULL COMMENT '规则编码',
`param_key` VARCHAR(128) NOT NULL COMMENT '参数键',
`param_val` TEXT NOT NULL COMMENT '参数值(统一文本存储)',
`val_type` VARCHAR(16) NOT NULL DEFAULT 'string' COMMENT '值类型(string/number/bool/json)',
`param_name` VARCHAR(128) DEFAULT NULL COMMENT '参数名称',
`sort_no` INT NOT NULL DEFAULT 0 COMMENT '排序号',
`enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用(1是0否)',
`remark` VARCHAR(255) DEFAULT NULL COMMENT '备注',
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_rule_param` (`rule_code`, `param_key`),
KEY `idx_rule_param_key` (`param_key`),
KEY `idx_rule_param_enabled` (`enabled`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='规则参数表';

View File

@@ -0,0 +1,211 @@
-- 从 rules/rule.drl 提取的初始化数据
-- 说明:本文件提供字典、规则主数据、规则参数与任务类型关联的初始记录。
-- 1) 字典数据
INSERT INTO `rule_dict` (`dict_type`, `dict_code`, `dict_name`, `sort_no`, `enabled`, `remark`) VALUES
('level', 'task', '任务级', 10, 1, '任务层面的选择/分配/限制'),
('level', 'action', '行动级', 20, 1, '行动层面的航迹/编组/模式'),
('level', 'platform', '平台级', 30, 1, '平台层面的部署/时空约束'),
('kind', 'select', '选择', 10, 1, '对象选择与评分'),
('kind', 'assign', '分配', 20, 1, '目标分配'),
('kind', 'deploy', '部署', 30, 1, '阵位与部署'),
('kind', 'config', '配置', 40, 1, '通用配置参数'),
('kind', 'mode', '工作模式', 50, 1, '算法与模式选择'),
('kind', 'spacetime', '时空约束', 60, 1, '空间和时间相关约束'),
('kind', 'relation', '关联关系', 70, 1, '蓝红关键词关联'),
('kind', 'limit', '限制条件', 80, 1, '阈值和边界'),
('task_type', 'strike', '打击任务', 10, 1, '典型任务类型'),
('task_type', 'recon', '侦察任务', 20, 1, '典型任务类型'),
('task_type', 'intercept', '拦截任务', 30, 1, '典型任务类型'),
('task_type', 'support', '支援任务', 40, 1, '典型任务类型'),
('task_type', 'jamming', '干扰任务', 50, 1, '典型任务类型'),
('status', 'enabled', '启用', 10, 1, '通用状态'),
('status', 'disabled', '停用', 20, 1, '通用状态')
ON DUPLICATE KEY UPDATE
`dict_name` = VALUES(`dict_name`),
`sort_no` = VALUES(`sort_no`),
`enabled` = VALUES(`enabled`),
`remark` = VALUES(`remark`);
-- 2) 规则主数据(层级->种类->规则项)
INSERT INTO `rule_item`
(`rule_code`, `rule_name`, `level_code`, `kind_code`, `module_code`, `priority_no`, `condition_expr`, `action_expr`, `version_no`, `enabled`, `remark`)
VALUES
('R_TASK_SELECT_BASE', '任务级-装备选择基础规则', 'task', 'select', 'equipment', 100, 'task!=null', 'equipmentRule(fact, params)', 1, 1, '来自装备匹配主流程'),
('R_TASK_SELECT_SLOT_1', '任务级-规则槽1', 'task', 'relation', 'equipment', 101, 'containsAny(blue,slot1Blue)&&containsAny(red,slot1Red)', 'score += ruleScore_1*weight', 1, 1, '蓝红关键词槽位匹配'),
('R_TASK_SELECT_SLOT_2', '任务级-规则槽2', 'task', 'relation', 'equipment', 102, 'containsAny(blue,slot2Blue)&&containsAny(red,slot2Red)', 'score += ruleScore_2*weight', 1, 1, '蓝红关键词槽位匹配'),
('R_TASK_SELECT_SLOT_3', '任务级-规则槽3', 'task', 'relation', 'equipment', 103, 'containsAny(blue,slot3Blue)&&containsAny(red,slot3Red)', 'score += ruleScore_3*weight', 1, 1, '蓝红关键词槽位匹配'),
('R_TASK_REL_AIR_PLATFORM', '任务级-关联关系-空中平台', 'task', 'relation', 'equipment', 104, 'bluePlatformKeywords_air && redPreferredWhenBlueAir', 'score += airScore*weight', 1, 1, '兼容层空中平台关联'),
('R_TASK_REL_AIR_TASK', '任务级-关联关系-空中任务', 'task', 'relation', 'equipment', 105, 'airTaskKeywords && redPreferredWhenBlueAir', 'score += airTaskScore*weight', 1, 1, '兼容层空中任务关联'),
('R_TASK_REL_GROUND_TASK', '任务级-关联关系-地面任务', 'task', 'relation', 'equipment', 106, 'groundTaskKeywords && redPreferredWhenGround', 'score += groundScore*weight', 1, 1, '兼容层地面任务关联'),
('R_TASK_REL_TANK', '任务级-关联关系-坦克装甲', 'task', 'relation', 'equipment', 107, 'tankKeywords && redMatchKeywords_tank', 'score += tankScore*weight', 1, 1, '兼容层坦克关联'),
('R_TASK_REL_MISSILE', '任务级-关联关系-导弹火箭', 'task', 'relation', 'equipment', 108, 'missileKeywords && redMatchKeywords_missile', 'score += missileScore*weight', 1, 1, '兼容层导弹关联'),
('R_TASK_ASSIGN_TARGET', '任务级-目标分配规则', 'task', 'assign', 'target', 90, 'task!=null', 'target(fact, params)', 1, 1, '目标分配与execute填充'),
('R_TASK_LIMIT_SUPPLEMENT', '任务级-低命中率补拿限制', 'task', 'limit', 'target', 89, 'hitRate<threshold', '补拿装备并更新任务', 1, 1, '补拿轮次和数量限制'),
('R_PLATFORM_DEPLOY', '平台级-阵位部署规则', 'platform', 'deploy', 'position', 80, 'positionRuleEnabled=true', 'position(fact, params)', 1, 1, '平台部署与编队参数'),
('R_PLATFORM_SPACETIME', '平台级-时空约束规则', 'platform', 'spacetime', 'position', 79, 'enableWarZoneClamp=true', '平台点位约束到作战区', 1, 1, '阵位空间约束'),
('R_ACTION_TRACK_ROUTE', '行动级-航迹生成规则', 'action', 'mode', 'track', 70, 'trackRuleEnabled=true', 'trackRoute(fact, params)', 1, 1, '航迹算法与路由绑定'),
('R_ACTION_TRACK_SPACETIME', '行动级-航迹时空约束', 'action', 'spacetime', 'track', 69, 'enableTrackWarZoneClamp=true', '航迹点约束到作战区', 1, 1, '航迹空间约束'),
('R_ACTION_GROUP_FORMATION', '行动级-编组规则', 'action', 'mode', 'group', 60, 'groupRuleEnabled=true', 'groupFormation(fact, params)', 1, 1, '编组与wingman规则')
ON DUPLICATE KEY UPDATE
`rule_name` = VALUES(`rule_name`),
`level_code` = VALUES(`level_code`),
`kind_code` = VALUES(`kind_code`),
`module_code` = VALUES(`module_code`),
`priority_no` = VALUES(`priority_no`),
`condition_expr` = VALUES(`condition_expr`),
`action_expr` = VALUES(`action_expr`),
`version_no` = VALUES(`version_no`),
`enabled` = VALUES(`enabled`),
`remark` = VALUES(`remark`);
-- 3) 规则参数(来自 rule.drl 的 buildParam)
INSERT INTO `rule_item_param`
(`rule_code`, `param_key`, `param_val`, `val_type`, `param_name`, `sort_no`, `enabled`, `remark`)
VALUES
-- R_TASK_SELECT_BASE
('R_TASK_SELECT_BASE','weight','1','number','全局权重',10,1,'评分乘数'),
('R_TASK_SELECT_BASE','minSelectedScore','1','number','最小选中分',20,1,'低于该分不选中'),
('R_TASK_SELECT_BASE','tieBreak','equipmentId','string','并列决策方式',30,1,'equipmentId字典序'),
('R_TASK_SELECT_BASE','outputDrawNameSuffix','打击任务','string','输出任务后缀',40,1,'匹配成功后缀'),
('R_TASK_SELECT_BASE','ruleSlotCount','3','number','规则槽数量',50,1,'槽位匹配条数'),
-- R_TASK_SELECT_SLOT_1~3
('R_TASK_SELECT_SLOT_1','blueRuleKeywords_1','F-16,F-35','string','蓝方关键词1',10,1,'规则槽1'),
('R_TASK_SELECT_SLOT_1','redRuleKeywords_1','防空,导弹,无人机','string','红方关键词1',20,1,'规则槽1'),
('R_TASK_SELECT_SLOT_1','ruleScore_1','5','number','规则槽1分值',30,1,'规则槽1'),
('R_TASK_SELECT_SLOT_2','blueRuleKeywords_2','坦克,装甲','string','蓝方关键词2',10,1,'规则槽2'),
('R_TASK_SELECT_SLOT_2','redRuleKeywords_2','反坦克','string','红方关键词2',20,1,'规则槽2'),
('R_TASK_SELECT_SLOT_2','ruleScore_2','4','number','规则槽2分值',30,1,'规则槽2'),
('R_TASK_SELECT_SLOT_3','blueRuleKeywords_3','地面,突击','string','蓝方关键词3',10,1,'规则槽3'),
('R_TASK_SELECT_SLOT_3','redRuleKeywords_3','远火,榴弹,炮','string','红方关键词3',20,1,'规则槽3'),
('R_TASK_SELECT_SLOT_3','ruleScore_3','2','number','规则槽3分值',30,1,'规则槽3'),
-- R_TASK_REL_AIR_PLATFORM
('R_TASK_REL_AIR_PLATFORM','bluePlatformKeywords_air','F-16,J-10,F-35','string','蓝方空中平台关键词',10,1,'兼容层'),
('R_TASK_REL_AIR_PLATFORM','redPreferredWhenBlueAir','防空,导弹,无人机,直升机,空空','string','红方空中偏好关键词',20,1,'兼容层'),
('R_TASK_REL_AIR_PLATFORM','airScore','2','number','空中平台分值',30,1,'兼容层'),
-- R_TASK_REL_AIR_TASK
('R_TASK_REL_AIR_TASK','airTaskKeywords','空中,制空,拦截,空战','string','空中任务关键词',10,1,'兼容层'),
('R_TASK_REL_AIR_TASK','airTaskScore','10','number','空中任务分值',20,1,'兼容层'),
-- R_TASK_REL_GROUND_TASK
('R_TASK_REL_GROUND_TASK','groundTaskKeywords','地面,突击,登陆','string','地面任务关键词',10,1,'兼容层'),
('R_TASK_REL_GROUND_TASK','redPreferredWhenGround','远火,榴弹,炮,火箭','string','红方地面偏好关键词',20,1,'兼容层'),
('R_TASK_REL_GROUND_TASK','groundScore','1','number','地面任务分值',30,1,'兼容层'),
-- R_TASK_REL_TANK
('R_TASK_REL_TANK','tankKeywords','坦克,装甲','string','坦克关键词',10,1,'兼容层'),
('R_TASK_REL_TANK','redMatchKeywords_tank','反坦克','string','红方反坦克关键词',20,1,'兼容层'),
('R_TASK_REL_TANK','tankScore','1','number','坦克分值',30,1,'兼容层'),
-- R_TASK_REL_MISSILE
('R_TASK_REL_MISSILE','missileKeywords','导弹,火箭弹,巡航','string','导弹关键词',10,1,'兼容层'),
('R_TASK_REL_MISSILE','redMatchKeywords_missile','防空,导弹,导弹发射','string','红方导弹匹配关键词',20,1,'兼容层'),
('R_TASK_REL_MISSILE','missileScore','1','number','导弹分值',30,1,'兼容层'),
-- R_TASK_ASSIGN_TARGET
('R_TASK_ASSIGN_TARGET','executeTypeDefault','assault','string','执行类型默认值',10,1,'目标分配'),
('R_TASK_ASSIGN_TARGET','targetPickMode','roundRobin','string','目标选择模式',20,1,'roundRobin/random'),
('R_TASK_ASSIGN_TARGET','minTargetsPerRed','1','number','每红装最少目标数',30,1,'目标分配'),
('R_TASK_ASSIGN_TARGET','maxTargetsPerRedCap','3','number','每红装最多目标数',40,1,'目标分配'),
('R_TASK_ASSIGN_TARGET','radToTargetsCsv','0.8:1,0.5:2,0.2:3','string','命中率映射目标数',50,1,'阈值映射'),
('R_TASK_ASSIGN_TARGET','rangeParseRegex','(\\\\d+(?:\\\\.\\\\d+)?)','string','射程提取正则',60,1,'提取首个数字'),
('R_TASK_ASSIGN_TARGET','rangeUnit','km','string','射程单位',70,1,'km/m'),
('R_TASK_ASSIGN_TARGET','minRangeToAllowAssignKm','0','number','允许分配最小射程',80,1,'射程过滤'),
-- R_TASK_LIMIT_SUPPLEMENT
('R_TASK_LIMIT_SUPPLEMENT','redHitRateThreshold','0.6','number','红装命中率阈值',10,1,'低于阈值触发补拿'),
('R_TASK_LIMIT_SUPPLEMENT','maxExtraWeaponsPerTask','2','number','每任务最大补拿装备数',20,1,'限制条件'),
('R_TASK_LIMIT_SUPPLEMENT','maxSupplementRounds','2','number','补拿最大轮次',30,1,'防止死循环'),
('R_TASK_LIMIT_SUPPLEMENT','extraPickMinScore','1','number','补拿最小匹配分',40,1,'限制条件'),
-- R_PLATFORM_DEPLOY
('R_PLATFORM_DEPLOY','positionRuleEnabled','true','bool','是否启用阵位规则',10,1,'部署开关'),
('R_PLATFORM_DEPLOY','positionAnchorMode','hybrid','string','阵位锚点模式',20,1,'当前使用hybrid'),
('R_PLATFORM_DEPLOY','trackPointDirectionMode','head2next','string','航向计算模式',30,1,'head2next/tail2prev'),
('R_PLATFORM_DEPLOY','fallbackBearingDeg','0','number','默认航向角',40,1,'无法计算时回退'),
('R_PLATFORM_DEPLOY','deployDistanceKmMin','8','number','部署距离最小值(km)',50,1,'部署约束'),
('R_PLATFORM_DEPLOY','deployDistanceKmMax','30','number','部署距离最大值(km)',60,1,'部署约束'),
('R_PLATFORM_DEPLOY','deployDistanceKmDefault','15','number','默认部署距离(km)',70,1,'部署距离'),
('R_PLATFORM_DEPLOY','distanceByPlatformCsv','','string','按平台覆盖部署距离',80,1,'关键词:距离'),
('R_PLATFORM_DEPLOY','formationType','line','string','编队样式',90,1,'line/wedge/circle'),
('R_PLATFORM_DEPLOY','formationSpacingMeters','300','number','编队间距(米)',100,1,'部署参数'),
('R_PLATFORM_DEPLOY','formationHeadingOffsetDeg','15','number','编队偏转角(度)',110,1,'部署参数'),
('R_PLATFORM_DEPLOY','defaultDeployHeight','30','number','默认部署高度(米)',120,1,'部署参数'),
('R_PLATFORM_DEPLOY','heightFollowBlueRatio','0.0','number','高度跟随比例',130,1,'部署参数'),
('R_PLATFORM_DEPLOY','warZoneClampMode','nearestInside','string','作战区约束模式',140,1,'部署约束'),
('R_PLATFORM_DEPLOY','minInterPlatformDistanceMeters','80','number','平台最小间距(米)',150,1,'部署约束'),
-- R_PLATFORM_SPACETIME
('R_PLATFORM_SPACETIME','enableWarZoneClamp','true','bool','是否启用作战区约束',10,1,'平台时空约束'),
-- R_ACTION_TRACK_ROUTE
('R_ACTION_TRACK_ROUTE','trackRuleEnabled','true','bool','是否启用航迹规则',10,1,'航迹开关'),
('R_ACTION_TRACK_ROUTE','trackRouteAlgorithm','followBlue','string','航迹算法',20,1,'followBlue/shortestPath/flank/jam'),
('R_ACTION_TRACK_ROUTE','trackRouteNameSuffix','航迹','string','航迹名称后缀',30,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackAirDataTypeCsv','taskPlane,air,plane,flight','string','空中航迹dataType关键词',40,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackAirKeywordsCsv','机,飞,空,J-,F-,无人机,直升机','string','空中航迹关键词',50,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackGroundTrackType','routeLineGround','string','地面航迹类型',60,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackFallbackBearingDeg','0','number','航迹默认回退航向角',70,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackExtraNodesMax','0','number','航迹额外插点上限',80,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackShortPathSegments','3','number','最短路径插值分段',90,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackFlankOffsetMeters','800','number','flank偏移距离(米)',100,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackFlankSideMode','alternate','string','flank侧向模式',110,1,'alternate/left/right'),
('R_ACTION_TRACK_ROUTE','trackJamWobbleMeters','400','number','jam摆动振幅(米)',120,1,'行动模式'),
('R_ACTION_TRACK_ROUTE','trackJamSegments','4','number','jam摆动周期数',130,1,'行动模式'),
-- R_ACTION_TRACK_SPACETIME
('R_ACTION_TRACK_SPACETIME','enableTrackWarZoneClamp','true','bool','是否启用航迹作战区约束',10,1,'行动时空约束'),
-- R_ACTION_GROUP_FORMATION
('R_ACTION_GROUP_FORMATION','groupRuleEnabled','true','bool','是否启用编组规则',10,1,'编组开关'),
('R_ACTION_GROUP_FORMATION','groupDrawNameSuffix','编组','string','编组名称后缀',20,1,'编组规则'),
('R_ACTION_GROUP_FORMATION','groupDrawNameWithIndex','false','bool','编组名称是否加序号',30,1,'编组规则'),
('R_ACTION_GROUP_FORMATION','groupFormationMode','onePerRed','string','编组模式',40,1,'onePerRed/clusterByCount/singleGroup'),
('R_ACTION_GROUP_FORMATION','groupClusterSize','3','number','按人数编组的每组上限',50,1,'编组规则'),
('R_ACTION_GROUP_FORMATION','groupLeaderPickMode','byHitRateThenId','string','领队选择模式',60,1,'byHitRateThenId/byId'),
('R_ACTION_GROUP_FORMATION','groupMinMembersForWingman','2','number','生成僚机的最小人数',70,1,'编组规则'),
('R_ACTION_GROUP_FORMATION','wingmanDistanceBaseMeters','100','number','僚机基础距离(米)',80,1,'编组几何'),
('R_ACTION_GROUP_FORMATION','wingmanDistanceStepMeters','50','number','僚机距离步长(米)',90,1,'编组几何'),
('R_ACTION_GROUP_FORMATION','wingmanAngleBaseDeg','50','number','僚机基础角度(度)',100,1,'编组几何'),
('R_ACTION_GROUP_FORMATION','wingmanAngleStepDeg','15','number','僚机角度步长(度)',110,1,'编组几何'),
('R_ACTION_GROUP_FORMATION','wingmanAltBaseMeters','40','number','僚机基础高度(米)',120,1,'编组几何'),
('R_ACTION_GROUP_FORMATION','wingmanAltScale','1.0','number','僚机高度缩放系数',130,1,'编组几何')
ON DUPLICATE KEY UPDATE
`param_val` = VALUES(`param_val`),
`val_type` = VALUES(`val_type`),
`param_name` = VALUES(`param_name`),
`sort_no` = VALUES(`sort_no`),
`enabled` = VALUES(`enabled`),
`remark` = VALUES(`remark`);
-- 4) 规则适用任务类型(默认全部规则覆盖五类任务,后续可在前端按需调整)
INSERT IGNORE INTO `rule_item_task_type` (`rule_code`, `task_type_code`)
SELECT r.rule_code, t.task_type_code
FROM (
SELECT 'R_TASK_SELECT_BASE' AS rule_code
UNION ALL SELECT 'R_TASK_SELECT_SLOT_1'
UNION ALL SELECT 'R_TASK_SELECT_SLOT_2'
UNION ALL SELECT 'R_TASK_SELECT_SLOT_3'
UNION ALL SELECT 'R_TASK_REL_AIR_PLATFORM'
UNION ALL SELECT 'R_TASK_REL_AIR_TASK'
UNION ALL SELECT 'R_TASK_REL_GROUND_TASK'
UNION ALL SELECT 'R_TASK_REL_TANK'
UNION ALL SELECT 'R_TASK_REL_MISSILE'
UNION ALL SELECT 'R_TASK_ASSIGN_TARGET'
UNION ALL SELECT 'R_TASK_LIMIT_SUPPLEMENT'
UNION ALL SELECT 'R_PLATFORM_DEPLOY'
UNION ALL SELECT 'R_PLATFORM_SPACETIME'
UNION ALL SELECT 'R_ACTION_TRACK_ROUTE'
UNION ALL SELECT 'R_ACTION_TRACK_SPACETIME'
UNION ALL SELECT 'R_ACTION_GROUP_FORMATION'
) r
CROSS JOIN (
SELECT 'strike' AS task_type_code
UNION ALL SELECT 'recon'
UNION ALL SELECT 'intercept'
UNION ALL SELECT 'support'
UNION ALL SELECT 'jamming'
) t;

View File

@@ -0,0 +1,204 @@
{
"assign_target": [
{
"task": "task1",
"type": "fire",
"target": [
"enemy_p1",
"enemyp2"
]
},
{
"task": "task2",
"type": "fire",
"target": [
"enemy_p1333",
"enemyp2333"
]
},
{
"task": "task3",
"type": "radar",
"target": [
"enemy_p1444",
"enemyp2444"
]
}
],
"task": [
{
"task_name": "task1",
"platform": [
{
"name": "platform1",
"platform_type": "WSF_PLATFORM",
"longitude": "120:49:24.79e",
"latitude": "23:47:26.60n",
"altitude": 0,
"route": [
{
"longitude": "120:49:24.79e",
"latitude": "23:47:26.60n",
"altitude": 0,
"speed": 100
},
{
"longitude": "120:49:42.46e",
"latitude": "23:47:42.80n",
"altitude": 0,
"speed": 100
},
{
"longitude": "120:50:19.01e",
"latitude": "23:47:51.84n",
"altitude": 0,
"speed": 100
},
{
"longitude": "120:50:42.73e",
"latitude": "23:48:09.86n",
"altitude": 0,
"speed": 100
}
]
},
{
"name": "platform2",
"platform_type": "WSF_PLATFORM",
"longitude": "120:50:19.01e",
"latitude": "23:47:51.84n",
"altitude": 0,
"route": [
{
"longitude": "120:50:19.01e",
"latitude": "23:47:51.84n",
"altitude": 0,
"speed": 100
},
{
"longitude": "120:50:42.73e",
"latitude": "23:48:09.86n",
"altitude": 0,
"speed": 100
},
{
"longitude": "120:50:42.73e",
"latitude": "23:48:09.86n",
"altitude": 0,
"speed": 100
}
]
}
],
"time": {
"begin": 50,
"end": 300
}
},
{
"task_name": "task2",
"platform": [
{
"name": "platform3",
"platform_type": "SENSOR_TYPE",
"longitude": "120:50:19.01e",
"latitude": "23:47:51.84n",
"altitude": 0,
"route": [
{
"longitude": "120:50:19.01e",
"latitude": "23:47:51.84n",
"altitude": 0,
"speed": 100
},
{
"longitude": "120:50:42.73e",
"latitude": "23:48:09.86n",
"altitude": 0,
"speed": 100
},
{
"longitude": "120:50:42.73e",
"latitude": "23:48:09.86n",
"altitude": 0,
"speed": 100
}
]
},
{
"name": "platform5",
"platform_type": "SENSOR_TYPE",
"longitude": "120:50:42.73e",
"latitude": "23:48:09.86n",
"altitude": 0,
"route": [
{
"longitude": "120:50:42.73e",
"latitude": "23:48:09.86n",
"altitude": 0,
"speed": 100
}
]
},
{
"name": "platform4",
"platform_type": "JAM_TYPE",
"longitude": "120:49:55.28e",
"latitude": "23:48:38.68n",
"altitude": 0,
"route": [
{
"longitude": "120:49:55.28e",
"latitude": "23:48:38.68n",
"altitude": 0,
"speed": 100
}
]
},
{
"name": "platform9",
"platform_type": "JAM_TYPE",
"longitude": "120:49:55.28e",
"latitude": "23:48:38.68n",
"altitude": 0,
"route": [
{
"longitude": "120:49:55.28e",
"latitude": "23:48:38.68n",
"altitude": 0,
"speed": 100
}
]
}
],
"time": {
"begin": 110,
"end": 300
}
},
{
"task_name": "task3",
"platform": [
{
"name": "platform6",
"platform_type": "WSF_PLATFORM",
"longitude": "120:49:45.11e",
"latitude": "23:48:53.09n",
"altitude": 0,
"route": [
{
"longitude": "120:49:45.11e",
"latitude": "23:48:53.09n",
"altitude": 0,
"speed": 100
}
]
}
],
"time": {
"begin": 50,
"end": 300
}
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,11 @@
<artifactId>springfox-boot-starter</artifactId> <artifactId>springfox-boot-starter</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.solution</groupId>
<artifactId>solution-behaviour</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -0,0 +1,40 @@
package com.solution.scene.domain;
import lombok.Data;
/**
* 平台通信关系表
*/
@Data
public class PlatformCommunication {
/**
* 主键ID
*/
private Integer id;
/**
* 指挥平台名称/ID
*/
private String commandPlatform;
/**
* 下属平台名称/ID
*/
private String subordinatePlatform;
/**
* 指挥通信方式/内容
*/
private String commandComm;
/**
* 下属通信方式/内容
*/
private String subordinateComm;
/**
* 想定ID
*/
private Integer scenaryId;
}

View File

@@ -2,6 +2,8 @@ package com.solution.scene.mapper;
import com.solution.scene.domain.AfsimScenario; import com.solution.scene.domain.AfsimScenario;
import com.solution.scene.domain.AfsimScenarioForm; import com.solution.scene.domain.AfsimScenarioForm;
import com.solution.scene.domain.PlatformCommunication;
import com.solution.system.domain.Behaviortree;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@@ -26,4 +28,18 @@ public interface SceneMapper {
List<AfsimScenario> selectSceneList(); List<AfsimScenario> selectSceneList();
AfsimScenario findOneById(Long id); AfsimScenario findOneById(Long id);
/**
* 根据场景id获取场景下所有行为树
* @param id
* @return
*/
List<Behaviortree> selectAllTreeBySceneId(Integer id);
/**
* 根据场景id获取场景下所有关系
* @param id
* @return
*/
List<PlatformCommunication> selectAllRelationBySceneId(Integer id);
} }

View File

@@ -2,6 +2,8 @@ package com.solution.scene.service;
import com.solution.scene.domain.AfsimScenario; import com.solution.scene.domain.AfsimScenario;
import com.solution.scene.domain.AfsimScenarioForm; import com.solution.scene.domain.AfsimScenarioForm;
import com.solution.scene.domain.PlatformCommunication;
import com.solution.system.domain.Behaviortree;
import java.util.List; import java.util.List;
@@ -25,4 +27,18 @@ public interface SceneService {
List<AfsimScenario> selectSceneList(); List<AfsimScenario> selectSceneList();
AfsimScenario findOneById(Long id); AfsimScenario findOneById(Long id);
/**
* 根据场景id获取场景下所有行为树
* @param id
* @return
*/
List<Behaviortree> getAllTree(Integer id);
/**
* 根据场景id获取场景下所有关系
* @param id
* @return
*/
List<PlatformCommunication> getAllRelation(Integer id);
} }

Some files were not shown because too many files have changed in this diff Show More