Compare commits
128 Commits
0daa1c19cf
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ce832fb16d | |||
| e9503358d3 | |||
| 3b3370c440 | |||
| d8719c30c6 | |||
| 9ff0e50bba | |||
|
|
2838938cfa | ||
| c4cc3cc30b | |||
|
|
d1f720f691 | ||
|
|
cb1019b7d7 | ||
| 18827cfbe7 | |||
| 3fe32e4ac3 | |||
|
|
168ced6b27 | ||
|
|
499734efe8 | ||
|
|
27c8fc13c6 | ||
|
|
505092bcf4 | ||
|
|
41ba11dc9b | ||
|
|
158512cd12 | ||
|
|
3a3ab0c9c6 | ||
|
|
b08c74260d | ||
|
|
02e9ca26a1 | ||
|
|
8958ecd6dc | ||
|
|
6656479327 | ||
|
|
18ccf490e4 | ||
| 4a0602ce4e | |||
| 8844830afc | |||
| bcc450141e | |||
| 25e6ac1cbe | |||
| 8b2f4dab89 | |||
| 4f60d68c4f | |||
| b63ad360d0 | |||
|
|
c724a7acf7 | ||
|
|
185e490560 | ||
|
|
d13359c803 | ||
|
|
65ea1cfd6b | ||
|
|
4455d38a61 | ||
|
|
6dd4392f0c | ||
|
|
974f403784 | ||
|
|
82bbfb83ca | ||
|
|
fc7b5e6c63 | ||
|
|
8dc867acb6 | ||
|
|
c17197d6e5 | ||
| 76022cf09a | |||
| 4ff5bf500c | |||
| be417189e0 | |||
| a88d74ea1d | |||
|
|
c2bfb43d41 | ||
|
|
c5d81a4c52 | ||
|
|
6d76cb8d5e | ||
|
|
b97837ec6a | ||
|
|
f2e81c6e5c | ||
|
|
83a38c6db8 | ||
|
|
22e71a24d3 | ||
|
|
6019738aca | ||
| 7847dbc89f | |||
| cc01c9ece8 | |||
| 8f29e230d0 | |||
| 711d7bf3da | |||
|
|
29e17773af | ||
|
|
db97d8a026 | ||
|
|
2e55254412 | ||
|
|
1504c3fc1b | ||
|
|
0cf4c9b47e | ||
|
|
fa0c93044c | ||
|
|
33a77428db | ||
| 26a89a66d1 | |||
| f72105134f | |||
|
|
2198e108a4 | ||
|
|
fe94cec559 | ||
| af3a97175a | |||
| c1c67e826b | |||
| 8a946c4c84 | |||
| d9a55d0c95 | |||
|
|
7b578f5d63 | ||
| dde470c9da | |||
| 91adb9517e | |||
| 99c100f2ac | |||
|
|
a2f2cbb185 | ||
|
|
d96941ea9b | ||
|
|
5a7b57d603 | ||
|
|
27f8810401 | ||
|
|
4980ba2da4 | ||
|
|
3a086e9405 | ||
| f2f8892276 | |||
| 152a7b59af | |||
| 956d3f69ea | |||
| 6fb020355b | |||
|
|
8b3fe9b548 | ||
|
|
db30244cd1 | ||
|
|
c9bc62fb8c | ||
|
|
9d54395c29 | ||
|
|
35fd1c8937 | ||
|
|
579d0f2bd8 | ||
|
|
7f8abf2ff2 | ||
|
|
f1bcd3812d | ||
|
|
d3fda27bb0 | ||
|
|
538a43f597 | ||
|
|
fcab8585c5 | ||
|
|
0ffc42ab69 | ||
|
|
46bead08a0 | ||
|
|
e07b11ef95 | ||
|
|
a78781782e | ||
|
|
0b55384442 | ||
|
|
43837901f3 | ||
|
|
8898cd2e6f | ||
|
|
f34274ea35 | ||
|
|
5ffdb5e508 | ||
|
|
a5a3c93135 | ||
|
|
af697e9304 | ||
|
|
e7abfca9f7 | ||
|
|
1058d666a0 | ||
|
|
58d36a3d6d | ||
|
|
b544391b5c | ||
|
|
e12c3c0302 | ||
|
|
d8c429d000 | ||
|
|
7909ea8acb | ||
|
|
444c31612d | ||
|
|
a3e34424d8 | ||
|
|
76065ed5c4 | ||
|
|
70de3c68a8 | ||
|
|
3bb9178399 | ||
|
|
82fcedfa97 | ||
|
|
294e5d687e | ||
|
|
a246c88341 | ||
|
|
c9d5c38b52 | ||
|
|
9ded6b757c | ||
|
|
015030d650 | ||
|
|
b67f493678 | ||
| e3be036bd3 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,6 +8,8 @@
|
|||||||
target/
|
target/
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
node_modules/
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# IDE
|
# IDE
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,17 @@
|
|||||||
<groupId>com.solution</groupId>
|
<groupId>com.solution</groupId>
|
||||||
<artifactId>solution-algo</artifactId>
|
<artifactId>solution-algo</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.solution</groupId>
|
||||||
|
<artifactId>solution-rule</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.solution</groupId>
|
||||||
|
<artifactId>solution-scene</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
package com.solution.web.controller.algo;
|
package com.solution.web.controller.algo;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -32,11 +38,56 @@ import com.solution.common.core.page.TableDataInfo;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@Api("规则模块")
|
@Api("规则模块")
|
||||||
@RequestMapping("/algo/algorithm")
|
@RequestMapping("/api/algo/algorithm")
|
||||||
public class AlgorithmController extends BaseController {
|
public class AlgorithmController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAlgorithmService algorithmService;
|
private IAlgorithmService algorithmService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出规则列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("运行python程序")
|
||||||
|
@PostMapping("/run")
|
||||||
|
public Object run(@RequestBody Algorithm algorithm) {
|
||||||
|
List<Algorithm> list = algorithmService.selectAlgorithmList(algorithm);
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
for (Algorithm al : list) {
|
||||||
|
String codePath = al.getCodePath();
|
||||||
|
|
||||||
|
try {
|
||||||
|
String jsonInput = objectMapper.writeValueAsString(al);
|
||||||
|
String pythonExe = "E:\\Apps\\anaconda3\\python.exe";
|
||||||
|
ProcessBuilder pb = new ProcessBuilder(pythonExe, codePath);
|
||||||
|
Process process = pb.start();
|
||||||
|
|
||||||
|
try (OutputStream os = process.getOutputStream()) {
|
||||||
|
os.write(jsonInput.getBytes(StandardCharsets.UTF_8));
|
||||||
|
os.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
String result;
|
||||||
|
// 修改你 Java 代码中的这一段
|
||||||
|
try (BufferedReader reader = new BufferedReader(
|
||||||
|
new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) {
|
||||||
|
result = reader.lines().collect(Collectors.joining("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int exitCode = process.waitFor();
|
||||||
|
if (exitCode != 0) {
|
||||||
|
return "Python执行失败,错误码:" + exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return objectMapper.readTree(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "执行异常: " + e.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "未找到算法";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询规则列表
|
* 查询规则列表
|
||||||
*/
|
*/
|
||||||
@@ -56,7 +107,7 @@ public class AlgorithmController extends BaseController {
|
|||||||
@PreAuthorize("@ss.hasPermi('algo:algorithm:export')")
|
@PreAuthorize("@ss.hasPermi('algo:algorithm:export')")
|
||||||
@Log(title = "规则", businessType = BusinessType.EXPORT)
|
@Log(title = "规则", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, Algorithm algorithm) {
|
public void export(HttpServletResponse response, @RequestBody Algorithm algorithm) {
|
||||||
List<Algorithm> list = algorithmService.selectAlgorithmList(algorithm);
|
List<Algorithm> list = algorithmService.selectAlgorithmList(algorithm);
|
||||||
ExcelUtil<Algorithm> util = new ExcelUtil<Algorithm>(Algorithm.class);
|
ExcelUtil<Algorithm> util = new ExcelUtil<Algorithm>(Algorithm.class);
|
||||||
util.exportExcel(response, list, "规则数据");
|
util.exportExcel(response, list, "规则数据");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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.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.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -32,12 +33,21 @@ import com.solution.common.core.page.TableDataInfo;
|
|||||||
*/
|
*/
|
||||||
@Api("行为树管理")
|
@Api("行为树管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/behaviortree")
|
@RequestMapping("/api/system/behaviortree")
|
||||||
public class BehaviortreeController extends BaseController
|
public class BehaviortreeController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBehaviortreeService behaviortreeService;
|
private IBehaviortreeService behaviortreeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BehaviortreeProcessor behaviortreeProcessor;
|
||||||
|
|
||||||
|
@GetMapping(value = "/platform/{id}")
|
||||||
|
public AjaxResult fromPlatform(@PathVariable("id") Integer id)
|
||||||
|
{
|
||||||
|
return success(behaviortreeService.findOneByPlatformId(id));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询行为树主列表
|
* 查询行为树主列表
|
||||||
*/
|
*/
|
||||||
@@ -84,7 +94,7 @@ public class BehaviortreeController extends BaseController
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody Behaviortree behaviortree)
|
public AjaxResult add(@RequestBody Behaviortree behaviortree)
|
||||||
{
|
{
|
||||||
return toAjax(behaviortreeService.insertBehaviortree(behaviortree));
|
return toAjax(behaviortreeProcessor.create(behaviortree));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +106,7 @@ public class BehaviortreeController extends BaseController
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody Behaviortree behaviortree)
|
public AjaxResult edit(@RequestBody Behaviortree behaviortree)
|
||||||
{
|
{
|
||||||
return toAjax(behaviortreeService.updateBehaviortree(behaviortree));
|
return toAjax(behaviortreeProcessor.update(behaviortree));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,4 +120,5 @@ public class BehaviortreeController extends BaseController
|
|||||||
{
|
{
|
||||||
return toAjax(behaviortreeService.deleteBehaviortreeByIds(ids));
|
return toAjax(behaviortreeService.deleteBehaviortreeByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import com.solution.common.core.page.TableDataInfo;
|
|||||||
*/
|
*/
|
||||||
@Api("节点连接管理")
|
@Api("节点连接管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/nodeconnection")
|
@RequestMapping("/api/system/nodeconnection")
|
||||||
public class NodeconnectionController extends BaseController
|
public class NodeconnectionController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import com.solution.common.core.page.TableDataInfo;
|
|||||||
*/
|
*/
|
||||||
@Api("节点参数管理")
|
@Api("节点参数管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/nodeparameter")
|
@RequestMapping("/api/system/nodeparameter")
|
||||||
public class NodeparameterController extends BaseController
|
public class NodeparameterController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ import java.util.stream.Collectors;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.solution.common.core.domain.R;
|
import com.solution.common.core.domain.R;
|
||||||
|
import com.solution.system.domain.NodeTemplateEntity;
|
||||||
|
import com.solution.system.domain.Nodeparameter;
|
||||||
|
import com.solution.system.domain.Templateparameterdef;
|
||||||
|
import com.solution.system.service.INodeparameterService;
|
||||||
|
import com.solution.system.service.ITemplateparameterdefService;
|
||||||
import com.solution.web.controller.behaviour.vo.NodetemplateDTO;
|
import com.solution.web.controller.behaviour.vo.NodetemplateDTO;
|
||||||
import com.solution.web.controller.behaviour.vo.NodetemplateVO;
|
import com.solution.web.controller.behaviour.vo.NodetemplateVO;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -14,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
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.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
@@ -39,11 +45,17 @@ import com.solution.common.core.page.TableDataInfo;
|
|||||||
*/
|
*/
|
||||||
@Api("节点模板管理")
|
@Api("节点模板管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/nodetemplate")
|
@RequestMapping("/api/system/nodetemplate")
|
||||||
public class NodetemplateController extends BaseController {
|
public class NodetemplateController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private INodetemplateService nodetemplateService;
|
private INodetemplateService nodetemplateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private INodeparameterService nodeparameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITemplateparameterdefService templateparameterdefService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询节点模板列表
|
* 查询节点模板列表
|
||||||
*/
|
*/
|
||||||
@@ -55,10 +67,29 @@ public class NodetemplateController extends BaseController {
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("节点模板列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:nodetemplate:all')")
|
||||||
|
@GetMapping("/all")
|
||||||
|
public R<List<NodeTemplateEntity>> all() {
|
||||||
|
Nodetemplate nodetemplate = new Nodetemplate();
|
||||||
|
List<Nodetemplate> list = nodetemplateService.selectNodetemplateList(nodetemplate);
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return R.ok(null);
|
||||||
|
}
|
||||||
|
List<NodeTemplateEntity> entities = new ArrayList<>();
|
||||||
|
for (Nodetemplate template : list) {
|
||||||
|
Templateparameterdef def = new Templateparameterdef();
|
||||||
|
def.setTemplateId(template.getId());
|
||||||
|
List<Templateparameterdef> parameters = templateparameterdefService.selectTemplateparameterdefList(def);
|
||||||
|
entities.add(new NodeTemplateEntity(template, parameters));
|
||||||
|
}
|
||||||
|
return R.ok(entities);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("节点模板列表")
|
@ApiOperation("节点模板列表")
|
||||||
@PreAuthorize("@ss.hasPermi('system:nodetemplate:list')")
|
@PreAuthorize("@ss.hasPermi('system:nodetemplate:list')")
|
||||||
@GetMapping("/listAll")
|
@GetMapping("/listAll")
|
||||||
public R<List<NodetemplateVO>> listAll() {
|
public R<List<Nodetemplate>> listAll() {
|
||||||
Nodetemplate nodetemplate = new Nodetemplate();
|
Nodetemplate nodetemplate = new Nodetemplate();
|
||||||
List<Nodetemplate> list = nodetemplateService.selectNodetemplateList(nodetemplate);
|
List<Nodetemplate> list = nodetemplateService.selectNodetemplateList(nodetemplate);
|
||||||
if (CollectionUtils.isEmpty(list)) {
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
@@ -72,18 +103,19 @@ public class NodetemplateController extends BaseController {
|
|||||||
dto.setDescription(template.getDescription());
|
dto.setDescription(template.getDescription());
|
||||||
dto.setEnglishName(template.getEnglishName());
|
dto.setEnglishName(template.getEnglishName());
|
||||||
dto.setLogicHandler(template.getLogicHandler());
|
dto.setLogicHandler(template.getLogicHandler());
|
||||||
|
dto.setTemplateType(template.getTemplateType());
|
||||||
return dto;
|
return dto;
|
||||||
})
|
})
|
||||||
.collect(Collectors.groupingBy(NodetemplateDTO::getTempleteType));
|
.collect(Collectors.groupingBy(NodetemplateDTO::getTemplateType));
|
||||||
List<NodetemplateVO> vos = new ArrayList<>();
|
List<NodetemplateVO> vos = new ArrayList<>();
|
||||||
groupedByTemplateType.forEach((key, value) -> {
|
groupedByTemplateType.forEach((key, value) -> {
|
||||||
// 处理逻辑
|
// 处理逻辑
|
||||||
NodetemplateVO vo = new NodetemplateVO();
|
NodetemplateVO vo = new NodetemplateVO();
|
||||||
vo.setTempleteType(key);
|
vo.setTemplateType(key);
|
||||||
vo.setDtoList(value);
|
vo.setDtoList(value);
|
||||||
vos.add(vo);
|
vos.add(vo);
|
||||||
});
|
});
|
||||||
return R.ok(vos);
|
return R.ok(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import com.solution.common.core.page.TableDataInfo;
|
|||||||
* @date 2026-02-05
|
* @date 2026-02-05
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/templateparameterdef")
|
@RequestMapping("/api/system/templateparameterdef")
|
||||||
public class TemplateparameterdefController extends BaseController
|
public class TemplateparameterdefController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import com.solution.common.core.page.TableDataInfo;
|
|||||||
*/
|
*/
|
||||||
@Api("行为树实例节点管理")
|
@Api("行为树实例节点管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/treenodeinstance")
|
@RequestMapping("/api/system/treenodeinstance")
|
||||||
public class TreenodeinstanceController extends BaseController {
|
public class TreenodeinstanceController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITreenodeinstanceService treenodeinstanceService;
|
private ITreenodeinstanceService treenodeinstanceService;
|
||||||
@@ -141,14 +141,15 @@ public class TreenodeinstanceController extends BaseController {
|
|||||||
@PreAuthorize("@ss.hasPermi('system:treenodeinstance:add')")
|
@PreAuthorize("@ss.hasPermi('system:treenodeinstance:add')")
|
||||||
@Log(title = "行为树实例节点", businessType = BusinessType.INSERT)
|
@Log(title = "行为树实例节点", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/saveOrUpdate")
|
@PostMapping("/saveOrUpdate")
|
||||||
public R<Integer> saveOrUpdate(@RequestBody Treenodeinstance treenodeinstance) {
|
public R<Long> saveOrUpdate(@RequestBody Treenodeinstance treenodeinstance) {
|
||||||
if (null == treenodeinstance.getId()) {
|
if (null == treenodeinstance.getId()) {
|
||||||
//新增
|
//新增
|
||||||
|
treenodeinstanceService.insertTreenodeinstance(treenodeinstance);
|
||||||
Templateparameterdef templateparameterdef = new Templateparameterdef();
|
Templateparameterdef templateparameterdef = new Templateparameterdef();
|
||||||
templateparameterdef.setTemplateId(treenodeinstance.getTemplateId());
|
templateparameterdef.setTemplateId(treenodeinstance.getTemplateId());
|
||||||
List<Templateparameterdef> templateparameterdefs = templateparameterdefService.selectTemplateparameterdefList(templateparameterdef);
|
List<Templateparameterdef> templateparameterdefs = templateparameterdefService.selectTemplateparameterdefList(templateparameterdef);
|
||||||
if (CollectionUtils.isEmpty(templateparameterdefs)) {
|
if (CollectionUtils.isEmpty(templateparameterdefs)) {
|
||||||
return R.ok(treenodeinstanceService.insertTreenodeinstance(treenodeinstance));
|
return R.ok(treenodeinstance.getId());
|
||||||
}
|
}
|
||||||
templateparameterdefs.forEach(t -> {
|
templateparameterdefs.forEach(t -> {
|
||||||
Nodeparameter nodeparameter = new Nodeparameter();
|
Nodeparameter nodeparameter = new Nodeparameter();
|
||||||
@@ -158,7 +159,8 @@ public class TreenodeinstanceController extends BaseController {
|
|||||||
nodeparameterService.insertNodeparameter(nodeparameter);
|
nodeparameterService.insertNodeparameter(nodeparameter);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return R.ok(treenodeinstanceService.updateTreenodeinstance(treenodeinstance));
|
treenodeinstanceService.updateTreenodeinstance(treenodeinstance);
|
||||||
|
return R.ok(treenodeinstance.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class NodetemplateDTO {
|
|||||||
@ApiModelProperty("afsim 中转换的节点名")
|
@ApiModelProperty("afsim 中转换的节点名")
|
||||||
private String englishName;
|
private String englishName;
|
||||||
|
|
||||||
private String templeteType;
|
private String templateType;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -65,11 +65,11 @@ public class NodetemplateDTO {
|
|||||||
this.englishName = englishName;
|
this.englishName = englishName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTempleteType() {
|
public String getTemplateType() {
|
||||||
return templeteType;
|
return templateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTempleteType(String templeteType) {
|
public void setTemplateType(String templateType) {
|
||||||
this.templeteType = templeteType;
|
this.templateType = templateType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,17 +9,17 @@ import java.util.List;
|
|||||||
public class NodetemplateVO {
|
public class NodetemplateVO {
|
||||||
/** 模版类型,节点模版或者条件判断,例如“node”,precondition“ */
|
/** 模版类型,节点模版或者条件判断,例如“node”,precondition“ */
|
||||||
@ApiModelProperty("模版类型,节点模版或者条件判断,例如“node”,precondition“")
|
@ApiModelProperty("模版类型,节点模版或者条件判断,例如“node”,precondition“")
|
||||||
private String templeteType;
|
private String templateType;
|
||||||
|
|
||||||
@ApiModelProperty("节点模板数据")
|
@ApiModelProperty("节点模板数据")
|
||||||
private List<NodetemplateDTO> dtoList;
|
private List<NodetemplateDTO> dtoList;
|
||||||
|
|
||||||
public String getTempleteType() {
|
public String getTemplateType() {
|
||||||
return templeteType;
|
return templateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTempleteType(String templeteType) {
|
public void setTemplateType(String templateType) {
|
||||||
this.templeteType = templeteType;
|
this.templateType = templateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<NodetemplateDTO> getDtoList() {
|
public List<NodetemplateDTO> getDtoList() {
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package com.solution.web.controller.rule;
|
||||||
|
|
||||||
|
import com.solution.common.core.controller.BaseController;
|
||||||
|
import com.solution.common.core.domain.AjaxResult;
|
||||||
|
import com.solution.rule.domain.FireRuleExecuteDTO;
|
||||||
|
import com.solution.rule.domain.simplerulepojo.Task;
|
||||||
|
import com.solution.rule.service.FireRuleService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Api("火力规则")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/system/firerule")
|
||||||
|
public class FireRuleController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FireRuleService ruleService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始执行规则匹配
|
||||||
|
* @param fireRuleExecuteDTO 敌方参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/start")
|
||||||
|
@ApiOperation("开始执行规则匹配")
|
||||||
|
public AjaxResult execute(@RequestBody FireRuleExecuteDTO fireRuleExecuteDTO){
|
||||||
|
return success(ruleService.execute(fireRuleExecuteDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有武器平台和组件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/weapon")
|
||||||
|
@ApiOperation("获取所有武器平台和组件")
|
||||||
|
public AjaxResult getPlatformComponentNames(){
|
||||||
|
return success(ruleService.getPlatformComponentNames());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取通信组件的所有平台和组件
|
||||||
|
* @param scenarioId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/comm")
|
||||||
|
@ApiOperation("获取通信组件的所有平台和组件")
|
||||||
|
public AjaxResult getCommPlatformComponentNames(Integer scenarioId){
|
||||||
|
return success(ruleService.getCommPlatformComponentNames(scenarioId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据场景id获取所有平台及其组件
|
||||||
|
* @param scenarioId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/platforms/{scenarioId}")
|
||||||
|
public AjaxResult platformsScenarioId(@PathVariable Integer scenarioId){
|
||||||
|
return success(ruleService.findPlatformComponents(scenarioId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/platforms")
|
||||||
|
public AjaxResult platforms(){
|
||||||
|
return success(ruleService.findAllPlatformComponents());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/platforms/basic")
|
||||||
|
public AjaxResult platformsBasic(){
|
||||||
|
return success(ruleService.findAllBasicPlatformComponents());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据平台id获取平台下所有组件
|
||||||
|
* @param platformId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/component/{platformId}")
|
||||||
|
@ApiOperation("根据平台id获取平台下所有组件")
|
||||||
|
public AjaxResult getComponents(@PathVariable Integer platformId){
|
||||||
|
return success(ruleService.getComponents(platformId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始执行规则匹配
|
||||||
|
* @param task 敌方参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/rule")
|
||||||
|
@ApiOperation("开始执行规则匹配")
|
||||||
|
public AjaxResult execute(@RequestBody Task task){
|
||||||
|
return success(ruleService.executeTask(task));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.solution.web.controller.rule;
|
||||||
|
|
||||||
|
import com.solution.common.annotation.Log;
|
||||||
|
import com.solution.common.core.controller.BaseController;
|
||||||
|
import com.solution.common.core.domain.AjaxResult;
|
||||||
|
import com.solution.common.core.page.TableDataInfo;
|
||||||
|
import com.solution.common.enums.BusinessType;
|
||||||
|
import com.solution.rule.domain.Rule;
|
||||||
|
import com.solution.rule.service.IRuleService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Api("红蓝对抗规则管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/system/rule")
|
||||||
|
public class RuleController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IRuleService ruleService;
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:rule:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation("查询规则列表")
|
||||||
|
public TableDataInfo list(Rule rule) {
|
||||||
|
startPage();
|
||||||
|
List<Rule> list = ruleService.selectRuleList(rule);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:rule:query')")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@ApiOperation("获取规则详情")
|
||||||
|
public AjaxResult getInfo(@PathVariable Integer id) {
|
||||||
|
return success(ruleService.selectRuleById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:rule:add')")
|
||||||
|
@Log(title = "规则管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("新增规则")
|
||||||
|
public AjaxResult add(@RequestBody Rule rule) {
|
||||||
|
return toAjax(ruleService.insertRule(rule));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:rule:edit')")
|
||||||
|
@Log(title = "规则管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
@ApiOperation("修改规则")
|
||||||
|
public AjaxResult edit(@RequestBody Rule rule) {
|
||||||
|
return toAjax(ruleService.updateRule(rule));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:rule:remove')")
|
||||||
|
@Log(title = "规则管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
@ApiOperation("删除规则")
|
||||||
|
public AjaxResult remove(@PathVariable Integer[] ids) {
|
||||||
|
return toAjax(ruleService.deleteRuleByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.solution.web.controller.scene;
|
||||||
|
|
||||||
|
import com.solution.common.annotation.Log;
|
||||||
|
import com.solution.common.core.controller.BaseController;
|
||||||
|
import com.solution.common.core.domain.AjaxResult;
|
||||||
|
import com.solution.common.core.page.TableDataInfo;
|
||||||
|
import com.solution.common.enums.BusinessType;
|
||||||
|
import com.solution.scene.domain.AfsimScenario;
|
||||||
|
import com.solution.scene.domain.AfsimScenarioForm;
|
||||||
|
import com.solution.scene.service.SceneService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场景管理
|
||||||
|
*/
|
||||||
|
@Api("场景管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/system/scene")
|
||||||
|
public class SceneController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SceneService sceneService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存场景配置
|
||||||
|
*/
|
||||||
|
@ApiOperation("保存场景配置")
|
||||||
|
@PostMapping("/saveSceneConfig")
|
||||||
|
@Log(title = "行为树主", businessType = BusinessType.INSERT)
|
||||||
|
public AjaxResult saveSceneConfig(@RequestBody AfsimScenario afsimScenario)
|
||||||
|
{
|
||||||
|
return toAjax(sceneService.saveOrUpdate(afsimScenario));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取场景列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation("获取场景列表")
|
||||||
|
public TableDataInfo list(){
|
||||||
|
startPage();
|
||||||
|
List<AfsimScenario> list = sceneService.selectSceneList();
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,226 @@
|
|||||||
|
package com.solution.web.core;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.solution.system.domain.*;
|
||||||
|
import com.solution.system.service.IBehaviortreeService;
|
||||||
|
import com.solution.system.service.INodeconnectionService;
|
||||||
|
import com.solution.system.service.INodeparameterService;
|
||||||
|
import com.solution.system.service.ITreenodeinstanceService;
|
||||||
|
import com.solution.web.core.graph.Graph;
|
||||||
|
import com.solution.web.core.graph.GraphEdge;
|
||||||
|
import com.solution.web.core.graph.GraphNode;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class BehaviortreeProcessor {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBehaviortreeService behaviortreeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITreenodeinstanceService treenodeinstanceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private INodeparameterService nodeparameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private INodeconnectionService nodeconnectionService;
|
||||||
|
|
||||||
|
private ObjectMapper objectMapper = createObjectMapper();
|
||||||
|
|
||||||
|
public static ObjectMapper createObjectMapper() {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
return objectMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int create(Behaviortree behaviortree) {
|
||||||
|
int result = behaviortreeService.insertBehaviortree(behaviortree);
|
||||||
|
processGraph(behaviortree);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int update(Behaviortree behaviortree) {
|
||||||
|
int result = behaviortreeService.updateBehaviortree(behaviortree);
|
||||||
|
|
||||||
|
// 删除节点实例
|
||||||
|
treenodeinstanceService.deleteByTreeId(behaviortree.getId());
|
||||||
|
|
||||||
|
// 删除参数
|
||||||
|
nodeparameterService.deleteByTreeId(behaviortree.getId());
|
||||||
|
|
||||||
|
// 删除连线
|
||||||
|
nodeconnectionService.deleteByTreeId(behaviortree.getId());
|
||||||
|
|
||||||
|
processGraph(behaviortree);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processGraph(Behaviortree behaviortree) {
|
||||||
|
|
||||||
|
Graph graph = null;
|
||||||
|
try {
|
||||||
|
graph = objectMapper.readValue(behaviortree.getXmlContent(), Graph.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// skip
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == graph) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入节点 treenodeinstance
|
||||||
|
Map<String, Treenodeinstance> instanceKeyMap = new HashMap<>();
|
||||||
|
Map<String, Long> nodeKeyIndexMap = new HashMap<>();
|
||||||
|
Map<String,GraphNode> nodesMap = new HashMap<>();
|
||||||
|
if (graph.hasNodes()) {
|
||||||
|
Long index = 0L;
|
||||||
|
for (GraphNode node : graph.getNodes()) {
|
||||||
|
nodesMap.put(node.getKey(), node);
|
||||||
|
|
||||||
|
Treenodeinstance instance = createNodeInstance(behaviortree, node);
|
||||||
|
treenodeinstanceService.insertTreenodeinstance(instance);
|
||||||
|
instanceKeyMap.put(node.getKey(), instance);
|
||||||
|
|
||||||
|
if (node.hasParameters()) {
|
||||||
|
if (node.isMultiable()) {
|
||||||
|
List<Nodeparameter> nodeparameters = createMultiableNodeparameter(behaviortree, node, instance);
|
||||||
|
for (Nodeparameter nodeparameter : nodeparameters) {
|
||||||
|
nodeparameterService.insertNodeparameter(nodeparameter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 插入parameter nodeparameter
|
||||||
|
for (Templateparameterdef parameter : node.getParameters()) {
|
||||||
|
Nodeparameter nodeparameter = createNodeParameter(behaviortree, parameter, instance);
|
||||||
|
nodeparameterService.insertNodeparameter(nodeparameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nodeKeyIndexMap.put(node.getKey(), index);
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入连线 nodeconnection
|
||||||
|
if (graph.hasEdges()) {
|
||||||
|
for (GraphEdge edge : graph.getEdges()) {
|
||||||
|
Nodeconnection connection = createConnection(behaviortree, edge, nodesMap, instanceKeyMap, nodeKeyIndexMap);
|
||||||
|
nodeconnectionService.insertNodeconnection(connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Nodeconnection createConnection(Behaviortree behaviortree, GraphEdge edge,
|
||||||
|
Map<String,GraphNode> nodesMap,
|
||||||
|
Map<String, Treenodeinstance> instanceKeyMap,
|
||||||
|
Map<String, Long> nodeKeyIndexMap) {
|
||||||
|
Nodeconnection connection = new Nodeconnection();
|
||||||
|
Long orderIndex = 0L;
|
||||||
|
connection.setTreeId(behaviortree.getId());
|
||||||
|
if (null != instanceKeyMap.get(edge.getSource().getCell())) {
|
||||||
|
Treenodeinstance parent = instanceKeyMap.get(edge.getSource().getCell());
|
||||||
|
connection.setParentNodeId(parent.getId());
|
||||||
|
}
|
||||||
|
if (null != instanceKeyMap.get(edge.getTarget().getCell())) {
|
||||||
|
Treenodeinstance children = instanceKeyMap.get(edge.getTarget().getCell());
|
||||||
|
connection.setChildNodeId(children.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != nodesMap.get(edge.getTarget().getCell())) {
|
||||||
|
orderIndex = nodesMap.get(edge.getTarget().getCell()).getOrder();
|
||||||
|
}
|
||||||
|
if(null == orderIndex){
|
||||||
|
orderIndex = 0L;
|
||||||
|
}
|
||||||
|
// if (null != nodeKeyIndexMap.get(edge.getSource().getCell())) {
|
||||||
|
// connection.setOrderIndex(nodeKeyIndexMap.get(edge.getSource().getCell()));
|
||||||
|
// }
|
||||||
|
connection.setOrderIndex(orderIndex);
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Nodeparameter> createMultiableNodeparameter(Behaviortree behaviortree, GraphNode node,
|
||||||
|
Treenodeinstance instance) {
|
||||||
|
|
||||||
|
List<Nodeparameter> nodeparameters = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<Long, List<String>> idValues = new HashMap<>();
|
||||||
|
List<String> tmpValues = null;
|
||||||
|
Map<Long, List<Templateparameterdef>> mappedValues = new HashMap<>();
|
||||||
|
List<Templateparameterdef> tmpDefs = null;
|
||||||
|
|
||||||
|
for (Templateparameterdef parameter : node.getParameters()) {
|
||||||
|
tmpDefs = mappedValues.get(parameter.getId() );
|
||||||
|
if (null == tmpDefs) {
|
||||||
|
tmpDefs = new ArrayList<>();
|
||||||
|
}
|
||||||
|
tmpDefs.add(parameter);
|
||||||
|
mappedValues.put(parameter.getId(), tmpDefs);
|
||||||
|
|
||||||
|
tmpValues = idValues.get(parameter.getId() );
|
||||||
|
if (null == tmpValues) {
|
||||||
|
tmpValues = new ArrayList<>();
|
||||||
|
}
|
||||||
|
tmpValues.add(parameter.getDefaultValue());
|
||||||
|
idValues.put(parameter.getId(), tmpValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for (Long id : idValues.keySet()) {
|
||||||
|
tmpValues = idValues.get(id);
|
||||||
|
Nodeparameter nodeparameter = new Nodeparameter();
|
||||||
|
nodeparameter.setTreeId(behaviortree.getId());
|
||||||
|
nodeparameter.setNodeInstanceId(instance.getId());
|
||||||
|
nodeparameter.setParamDefId(id);
|
||||||
|
nodeparameter.setValue(StringUtils.collectionToCommaDelimitedString(tmpValues));
|
||||||
|
nodeparameter.setGroupIndex(index);
|
||||||
|
nodeparameters.add(nodeparameter);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return nodeparameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Nodeparameter createNodeParameter(Behaviortree behaviortree, Templateparameterdef parameter,
|
||||||
|
Treenodeinstance instance) {
|
||||||
|
Nodeparameter nodeparameter = new Nodeparameter();
|
||||||
|
nodeparameter.setTreeId(behaviortree.getId());
|
||||||
|
nodeparameter.setNodeInstanceId(instance.getId());
|
||||||
|
nodeparameter.setParamDefId(parameter.getId());
|
||||||
|
nodeparameter.setValue(parameter.getDefaultValue());
|
||||||
|
nodeparameter.setGroupIndex(parameter.getGroupIndex());
|
||||||
|
return nodeparameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Treenodeinstance createNodeInstance(Behaviortree behaviortree, GraphNode node) {
|
||||||
|
Treenodeinstance instance = new Treenodeinstance();
|
||||||
|
instance.setTreeId(behaviortree.getId());
|
||||||
|
instance.setTemplateId((long) node.getTemplate());
|
||||||
|
instance.setInstanceName(node.getName());
|
||||||
|
instance.setIsRoot((long) (node.isRoot() ? 1 : 0));
|
||||||
|
if ("precondition".equalsIgnoreCase(node.getTemplateType())) {
|
||||||
|
instance.setPreconditionTempleteId((long) node.getTemplate());
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.solution.web.core.graph;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Graph implements Serializable {
|
||||||
|
|
||||||
|
private List<GraphNode> nodes;
|
||||||
|
|
||||||
|
private List<GraphEdge> edges;
|
||||||
|
|
||||||
|
public boolean hasNodes() {
|
||||||
|
return nodes != null && !nodes.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEdges() {
|
||||||
|
return edges != null && !edges.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Graph{" +
|
||||||
|
"nodes=" + nodes +
|
||||||
|
", edges=" + edges +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GraphNode> getNodes() {
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodes(List<GraphNode> nodes) {
|
||||||
|
this.nodes = nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GraphEdge> getEdges() {
|
||||||
|
return edges;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEdges(List<GraphEdge> edges) {
|
||||||
|
this.edges = edges;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package com.solution.web.core.graph;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class GraphEdge implements Serializable {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
private Line source;
|
||||||
|
|
||||||
|
private Line target;
|
||||||
|
|
||||||
|
public boolean hasSource() {
|
||||||
|
return source != null && StringUtils.hasText(source.cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasTarget() {
|
||||||
|
return target != null && StringUtils.hasText(target.cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Line implements Serializable {
|
||||||
|
|
||||||
|
private String cell;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Line{" +
|
||||||
|
"cell='" + cell + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCell() {
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCell(String cell) {
|
||||||
|
this.cell = cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GraphEdge{" +
|
||||||
|
"key='" + key + '\'' +
|
||||||
|
", source='" + source + '\'' +
|
||||||
|
", target='" + target + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Line getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(Line source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Line getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(Line target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package com.solution.web.core.graph;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.solution.system.domain.Templateparameterdef;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GraphNode implements Serializable {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int template;
|
||||||
|
|
||||||
|
private String templateType;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private Long order;
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
private boolean multiable;
|
||||||
|
|
||||||
|
private List<Templateparameterdef> parameters;
|
||||||
|
|
||||||
|
private List<GraphVariable> variables;
|
||||||
|
|
||||||
|
public boolean hasParameters() {
|
||||||
|
return parameters != null && !parameters.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasVariables() {
|
||||||
|
return variables != null && !variables.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRoot() {
|
||||||
|
return "root".equalsIgnoreCase(this.category);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GraphNode{" +
|
||||||
|
"id=" + id +
|
||||||
|
", key='" + key + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
|
", parameters=" + parameters +
|
||||||
|
", variables=" + variables +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMultiable() {
|
||||||
|
return multiable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultiable(boolean multiable) {
|
||||||
|
this.multiable = multiable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(String category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplateType() {
|
||||||
|
return templateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateType(String templateType) {
|
||||||
|
this.templateType = templateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTemplate() {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplate(int template) {
|
||||||
|
this.template = template;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Templateparameterdef> getParameters() {
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameters(List<Templateparameterdef> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GraphVariable> getVariables() {
|
||||||
|
return variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariables(List<GraphVariable> variables) {
|
||||||
|
this.variables = variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getOrder() {
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(Long order) {
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.solution.web.core.graph;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class GraphVariable implements Serializable {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private String defaults;
|
||||||
|
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GraphVariable{" +
|
||||||
|
"key='" + key + '\'' +
|
||||||
|
", value='" + value + '\'' +
|
||||||
|
", defaults='" + defaults + '\'' +
|
||||||
|
", unit='" + unit + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaults() {
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaults(String defaults) {
|
||||||
|
this.defaults = defaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,9 +6,11 @@ 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://192.168.166.71:3306/behaviortreedb?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: 123456
|
||||||
|
password: 1234
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
# 从数据源开关/默认关闭
|
# 从数据源开关/默认关闭
|
||||||
|
|||||||
@@ -67,13 +67,15 @@ spring:
|
|||||||
# redis 配置
|
# redis 配置
|
||||||
redis:
|
redis:
|
||||||
# 地址
|
# 地址
|
||||||
host: 192.168.166.71
|
# host: 192.168.166.71
|
||||||
|
host: 127.0.0.1
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 0
|
database: 0
|
||||||
# 密码
|
# 密码
|
||||||
password:
|
# password:
|
||||||
|
password: 123456
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
lettuce:
|
lettuce:
|
||||||
@@ -104,6 +106,8 @@ mybatis:
|
|||||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||||
# 加载全局的配置文件
|
# 加载全局的配置文件
|
||||||
configLocation: classpath:mybatis/mybatis-config.xml
|
configLocation: classpath:mybatis/mybatis-config.xml
|
||||||
|
configuration:
|
||||||
|
map-underscore-to-camel-case: true
|
||||||
|
|
||||||
# PageHelper分页插件
|
# PageHelper分页插件
|
||||||
pagehelper:
|
pagehelper:
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package com.solution.algo;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.type.CollectionType;
|
||||||
|
import com.solution.algo.domain.AlgorithmConfig;
|
||||||
|
import org.apache.ibatis.type.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@MappedTypes(List.class)
|
||||||
|
@MappedJdbcTypes({
|
||||||
|
JdbcType.VARCHAR,
|
||||||
|
JdbcType.BLOB
|
||||||
|
})
|
||||||
|
public class AlgorithmConfigTypeHandler extends BaseTypeHandler<List<AlgorithmConfig>>
|
||||||
|
implements TypeHandler<List<AlgorithmConfig>> {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
private final CollectionType collectionType = objectMapper.getTypeFactory()
|
||||||
|
.constructCollectionType(List.class, AlgorithmConfig.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNonNullParameter(PreparedStatement ps, int i, List<AlgorithmConfig> parameter, JdbcType jdbcType)
|
||||||
|
throws SQLException {
|
||||||
|
ps.setString(i, serialize(parameter));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String serialize(List<AlgorithmConfig> indicatorConfig) {
|
||||||
|
if (null != indicatorConfig) {
|
||||||
|
try {
|
||||||
|
return objectMapper.writeValueAsString(indicatorConfig);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Can not serialize", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AlgorithmConfig> deserialize(String config) throws SQLException {
|
||||||
|
if (StringUtils.hasText(config)) {
|
||||||
|
try {
|
||||||
|
return objectMapper.readValue(config, collectionType);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Can not deserialize", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AlgorithmConfig> getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||||
|
String jsonValue = rs.getString(columnName);
|
||||||
|
return deserialize(jsonValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AlgorithmConfig> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||||
|
String jsonValue = rs.getString(columnIndex);
|
||||||
|
return deserialize(jsonValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AlgorithmConfig> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||||
|
String jsonValue = cs.getString(columnIndex);
|
||||||
|
return deserialize(jsonValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -34,6 +34,13 @@ public class Algorithm
|
|||||||
@Excel(name = "算法描述")
|
@Excel(name = "算法描述")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
/** 算法配置 */
|
||||||
|
@Excel(name = "算法配置")
|
||||||
|
private String algoConfig;
|
||||||
|
|
||||||
|
/** 算法配置 */
|
||||||
|
private List<AlgorithmConfig> algoConfigList;
|
||||||
|
|
||||||
/** 算法参数定义信息 */
|
/** 算法参数定义信息 */
|
||||||
private List<AlgorithmParam> algorithmParamList;
|
private List<AlgorithmParam> algorithmParamList;
|
||||||
|
|
||||||
@@ -87,6 +94,16 @@ public class Algorithm
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAlgoConfig(String algoConfig)
|
||||||
|
{
|
||||||
|
this.algoConfig = algoConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlgoConfig()
|
||||||
|
{
|
||||||
|
return algoConfig;
|
||||||
|
}
|
||||||
|
|
||||||
public List<AlgorithmParam> getAlgorithmParamList()
|
public List<AlgorithmParam> getAlgorithmParamList()
|
||||||
{
|
{
|
||||||
return algorithmParamList;
|
return algorithmParamList;
|
||||||
@@ -97,6 +114,14 @@ public class Algorithm
|
|||||||
this.algorithmParamList = algorithmParamList;
|
this.algorithmParamList = algorithmParamList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<AlgorithmConfig> getAlgoConfigList() {
|
||||||
|
return algoConfigList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlgoConfigList(List<AlgorithmConfig> algoConfigList) {
|
||||||
|
this.algoConfigList = algoConfigList;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
@@ -105,6 +130,7 @@ public class Algorithm
|
|||||||
.append("type", getType())
|
.append("type", getType())
|
||||||
.append("codePath", getCodePath())
|
.append("codePath", getCodePath())
|
||||||
.append("description", getDescription())
|
.append("description", getDescription())
|
||||||
|
.append("algoConfig", getAlgoConfig())
|
||||||
.append("algorithmParamList", getAlgorithmParamList())
|
.append("algorithmParamList", getAlgorithmParamList())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.solution.algo.domain;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class AlgorithmConfig implements Serializable {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String operation;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperation() {
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperation(String operation) {
|
||||||
|
this.operation = operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="type" column="type" />
|
<result property="type" column="type" />
|
||||||
<result property="codePath" column="code_path" />
|
<result property="codePath" column="code_path" />
|
||||||
<result property="description" column="description" />
|
<result property="description" column="description" />
|
||||||
|
<result property="algoConfig" column="algo_config" />
|
||||||
|
<result property="algoConfigList" column="algo_config_list" typeHandler="com.solution.algo.AlgorithmConfigTypeHandler" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="AlgorithmAlgorithmParamResult" type="Algorithm" extends="AlgorithmResult">
|
<resultMap id="AlgorithmAlgorithmParamResult" type="Algorithm" extends="AlgorithmResult">
|
||||||
@@ -25,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectAlgorithmVo">
|
<sql id="selectAlgorithmVo">
|
||||||
select id, name, type, code_path, description from algorithm
|
select id, name, type, code_path, description, algo_config, algo_config_list from algorithm
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectAlgorithmList" parameterType="Algorithm" resultMap="AlgorithmAlgorithmParamResult">
|
<select id="selectAlgorithmList" parameterType="Algorithm" resultMap="AlgorithmAlgorithmParamResult">
|
||||||
@@ -35,11 +37,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||||
<if test="codePath != null and codePath != ''"> and code_path = #{codePath}</if>
|
<if test="codePath != null and codePath != ''"> and code_path = #{codePath}</if>
|
||||||
<if test="description != null and description != ''"> and description = #{description}</if>
|
<if test="description != null and description != ''"> and description = #{description}</if>
|
||||||
|
<if test="algoConfig != null and algoConfig != ''"> and algo_config = #{algoConfig}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAlgorithmById" parameterType="Long" resultMap="AlgorithmAlgorithmParamResult">
|
<select id="selectAlgorithmById" parameterType="Long" resultMap="AlgorithmAlgorithmParamResult">
|
||||||
select id, name, type, code_path, description
|
select id, name, type, code_path, description, algo_config
|
||||||
from algorithm
|
from algorithm
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
@@ -57,12 +60,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="type != null and type != ''">type,</if>
|
<if test="type != null and type != ''">type,</if>
|
||||||
<if test="codePath != null">code_path,</if>
|
<if test="codePath != null">code_path,</if>
|
||||||
<if test="description != null">description,</if>
|
<if test="description != null">description,</if>
|
||||||
|
<if test="algoConfig != null">algo_config,</if>
|
||||||
|
<if test="algoConfigList != null">algo_config_list,</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>
|
||||||
<if test="type != null and type != ''">#{type},</if>
|
<if test="type != null and type != ''">#{type},</if>
|
||||||
<if test="codePath != null">#{codePath},</if>
|
<if test="codePath != null">#{codePath},</if>
|
||||||
<if test="description != null">#{description},</if>
|
<if test="description != null">#{description},</if>
|
||||||
|
<if test="algoConfig != null">#{algoConfig},</if>
|
||||||
|
<if test="algoConfigList != null">#{algoConfigList,typeHandler=com.solution.algo.AlgorithmConfigTypeHandler},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -73,6 +80,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="type != null and type != ''">type = #{type},</if>
|
<if test="type != null and type != ''">type = #{type},</if>
|
||||||
<if test="codePath != null">code_path = #{codePath},</if>
|
<if test="codePath != null">code_path = #{codePath},</if>
|
||||||
<if test="description != null">description = #{description},</if>
|
<if test="description != null">description = #{description},</if>
|
||||||
|
<if test="algoConfig != null">algo_config = #{algoConfig},</if>
|
||||||
|
<if test="algoConfigList != null">algo_config_list = #{algoConfigList,typeHandler=com.solution.algo.AlgorithmConfigTypeHandler},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.solution.system.domain;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NodeTemplateEntity extends Nodetemplate {
|
||||||
|
|
||||||
|
private List<Templateparameterdef> parameters = new ArrayList<>();
|
||||||
|
|
||||||
|
public NodeTemplateEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeTemplateEntity(List<Templateparameterdef> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeTemplateEntity(NodeTemplateEntity entity) {
|
||||||
|
super(entity);
|
||||||
|
this.parameters = entity.getParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeTemplateEntity(Nodetemplate entity, List<Templateparameterdef> parameters) {
|
||||||
|
super(entity);
|
||||||
|
this.parameters = parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Templateparameterdef> getParameters() {
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameters(List<Templateparameterdef> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,6 +18,8 @@ public class Nodeconnection extends BaseEntity
|
|||||||
/** 连接ID (主键) */
|
/** 连接ID (主键) */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
private Long treeId;
|
||||||
|
|
||||||
/** 父节点 (外键: TreeInstanceNode.id) */
|
/** 父节点 (外键: TreeInstanceNode.id) */
|
||||||
@Excel(name = "父节点 (外键: TreeInstanceNode.id)")
|
@Excel(name = "父节点 (外键: TreeInstanceNode.id)")
|
||||||
private Long parentNodeId;
|
private Long parentNodeId;
|
||||||
@@ -40,6 +42,14 @@ public class Nodeconnection extends BaseEntity
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getTreeId() {
|
||||||
|
return treeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTreeId(Long treeId) {
|
||||||
|
this.treeId = treeId;
|
||||||
|
}
|
||||||
|
|
||||||
public void setParentNodeId(Long parentNodeId)
|
public void setParentNodeId(Long parentNodeId)
|
||||||
{
|
{
|
||||||
this.parentNodeId = parentNodeId;
|
this.parentNodeId = parentNodeId;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ public class Nodeparameter extends BaseEntity
|
|||||||
/** 节点参数ID (主键) */
|
/** 节点参数ID (主键) */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
private Long treeId;
|
||||||
|
|
||||||
/** 关联到哪个节点实例 (外键: TreeInstanceNode.id) */
|
/** 关联到哪个节点实例 (外键: TreeInstanceNode.id) */
|
||||||
@Excel(name = "关联到哪个节点实例 (外键: TreeInstanceNode.id)")
|
@Excel(name = "关联到哪个节点实例 (外键: TreeInstanceNode.id)")
|
||||||
private Long nodeInstanceId;
|
private Long nodeInstanceId;
|
||||||
@@ -30,6 +32,8 @@ public class Nodeparameter extends BaseEntity
|
|||||||
@Excel(name = "节点实例设置的具体参数值 (覆盖模板默认值)")
|
@Excel(name = "节点实例设置的具体参数值 (覆盖模板默认值)")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
private int groupIndex;
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -40,6 +44,14 @@ public class Nodeparameter extends BaseEntity
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getTreeId() {
|
||||||
|
return treeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTreeId(Long treeId) {
|
||||||
|
this.treeId = treeId;
|
||||||
|
}
|
||||||
|
|
||||||
public void setNodeInstanceId(Long nodeInstanceId)
|
public void setNodeInstanceId(Long nodeInstanceId)
|
||||||
{
|
{
|
||||||
this.nodeInstanceId = nodeInstanceId;
|
this.nodeInstanceId = nodeInstanceId;
|
||||||
@@ -70,6 +82,14 @@ 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() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|||||||
@@ -40,7 +40,23 @@ public class Nodetemplate extends BaseEntity
|
|||||||
|
|
||||||
/** 模版类型,节点模版或者条件判断,例如“node”,precondition“ */
|
/** 模版类型,节点模版或者条件判断,例如“node”,precondition“ */
|
||||||
@Excel(name = "模版类型,节点模版或者条件判断,例如“node”,precondition“")
|
@Excel(name = "模版类型,节点模版或者条件判断,例如“node”,precondition“")
|
||||||
private String templeteType;
|
private String templateType;
|
||||||
|
|
||||||
|
private boolean multiable;
|
||||||
|
|
||||||
|
public Nodetemplate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Nodetemplate(Nodetemplate template) {
|
||||||
|
this.id = template.id;
|
||||||
|
this.type = template.type;
|
||||||
|
this.name = template.name;
|
||||||
|
this.logicHandler = template.logicHandler;
|
||||||
|
this.description = template.description;
|
||||||
|
this.englishName = template.englishName;
|
||||||
|
this.templateType = template.templateType;
|
||||||
|
this.multiable = template.multiable;
|
||||||
|
}
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
@@ -102,14 +118,22 @@ public class Nodetemplate extends BaseEntity
|
|||||||
return englishName;
|
return englishName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTempleteType(String templeteType)
|
public void setTemplateType(String templateType)
|
||||||
{
|
{
|
||||||
this.templeteType = templeteType;
|
this.templateType = templateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTempleteType()
|
public String getTemplateType()
|
||||||
{
|
{
|
||||||
return templeteType;
|
return templateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMultiable() {
|
||||||
|
return multiable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultiable(boolean multiable) {
|
||||||
|
this.multiable = multiable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -121,7 +145,7 @@ public class Nodetemplate extends BaseEntity
|
|||||||
.append("logicHandler", getLogicHandler())
|
.append("logicHandler", getLogicHandler())
|
||||||
.append("description", getDescription())
|
.append("description", getDescription())
|
||||||
.append("englishName", getEnglishName())
|
.append("englishName", getEnglishName())
|
||||||
.append("templeteType", getTempleteType())
|
.append("templateType", getTemplateType())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public class Templateparameterdef extends BaseEntity
|
|||||||
@Excel(name = "判断参数模版是节点的参数模版还是条件的参数模版")
|
@Excel(name = "判断参数模版是节点的参数模版还是条件的参数模版")
|
||||||
private String templateType;
|
private String templateType;
|
||||||
|
|
||||||
|
private int groupIndex;
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -112,6 +114,14 @@ public class Templateparameterdef extends BaseEntity
|
|||||||
return templateType;
|
return templateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGroupIndex() {
|
||||||
|
return groupIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupIndex(int groupIndex) {
|
||||||
|
this.groupIndex = groupIndex;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.solution.system.mapper;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,6 +12,9 @@ import com.solution.system.domain.Behaviortree;
|
|||||||
*/
|
*/
|
||||||
public interface BehaviortreeMapper
|
public interface BehaviortreeMapper
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Behaviortree findOneByPlatformId(Integer platformId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询行为树主
|
* 查询行为树主
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.solution.system.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.solution.system.domain.Nodeconnection;
|
import com.solution.system.domain.Nodeconnection;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点连接Mapper接口
|
* 节点连接Mapper接口
|
||||||
@@ -11,6 +12,8 @@ import com.solution.system.domain.Nodeconnection;
|
|||||||
*/
|
*/
|
||||||
public interface NodeconnectionMapper
|
public interface NodeconnectionMapper
|
||||||
{
|
{
|
||||||
|
void deleteByTreeId(@Param("treeId") Long treeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询节点连接
|
* 查询节点连接
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.solution.system.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.solution.system.domain.Nodeparameter;
|
import com.solution.system.domain.Nodeparameter;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点参数Mapper接口
|
* 节点参数Mapper接口
|
||||||
@@ -11,6 +12,8 @@ import com.solution.system.domain.Nodeparameter;
|
|||||||
*/
|
*/
|
||||||
public interface NodeparameterMapper
|
public interface NodeparameterMapper
|
||||||
{
|
{
|
||||||
|
void deleteByTreeId(@Param("treeId") Long treeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询节点参数
|
* 查询节点参数
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.solution.system.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.solution.system.domain.Treenodeinstance;
|
import com.solution.system.domain.Treenodeinstance;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 行为树实例节点Mapper接口
|
* 行为树实例节点Mapper接口
|
||||||
@@ -11,6 +12,8 @@ import com.solution.system.domain.Treenodeinstance;
|
|||||||
*/
|
*/
|
||||||
public interface TreenodeinstanceMapper
|
public interface TreenodeinstanceMapper
|
||||||
{
|
{
|
||||||
|
void deleteByTreeId(@Param(value = "treeId") Long treeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询行为树实例节点
|
* 查询行为树实例节点
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.solution.system.service;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,6 +12,9 @@ import com.solution.system.domain.Behaviortree;
|
|||||||
*/
|
*/
|
||||||
public interface IBehaviortreeService
|
public interface IBehaviortreeService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Behaviortree findOneByPlatformId(Integer platformId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询行为树主
|
* 查询行为树主
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.solution.system.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.solution.system.domain.Nodeconnection;
|
import com.solution.system.domain.Nodeconnection;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点连接Service接口
|
* 节点连接Service接口
|
||||||
@@ -11,6 +12,9 @@ import com.solution.system.domain.Nodeconnection;
|
|||||||
*/
|
*/
|
||||||
public interface INodeconnectionService
|
public interface INodeconnectionService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
void deleteByTreeId(@Param("treeId") Long treeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询节点连接
|
* 查询节点连接
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import com.solution.system.domain.Nodeparameter;
|
|||||||
*/
|
*/
|
||||||
public interface INodeparameterService
|
public interface INodeparameterService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
void deleteByTreeId(Long treeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询节点参数
|
* 查询节点参数
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import com.solution.system.domain.Treenodeinstance;
|
|||||||
*/
|
*/
|
||||||
public interface ITreenodeinstanceService
|
public interface ITreenodeinstanceService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
void deleteByTreeId(Long treeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询行为树实例节点
|
* 查询行为树实例节点
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.solution.system.service.impl;
|
package com.solution.system.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.solution.common.constant.ExceptionConstants;
|
||||||
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;
|
||||||
@@ -19,6 +22,12 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BehaviortreeMapper behaviortreeMapper;
|
private BehaviortreeMapper behaviortreeMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Behaviortree findOneByPlatformId(Integer platformId)
|
||||||
|
{
|
||||||
|
return behaviortreeMapper.findOneByPlatformId(platformId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询行为树主
|
* 查询行为树主
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ public class NodeconnectionServiceImpl implements INodeconnectionService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private NodeconnectionMapper nodeconnectionMapper;
|
private NodeconnectionMapper nodeconnectionMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByTreeId(Long treeId) {
|
||||||
|
nodeconnectionMapper.deleteByTreeId(treeId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询节点连接
|
* 查询节点连接
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ public class NodeparameterServiceImpl implements INodeparameterService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private NodeparameterMapper nodeparameterMapper;
|
private NodeparameterMapper nodeparameterMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByTreeId(Long treeId) {
|
||||||
|
nodeparameterMapper.deleteByTreeId(treeId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询节点参数
|
* 查询节点参数
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ public class TreenodeinstanceServiceImpl implements ITreenodeinstanceService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TreenodeinstanceMapper treenodeinstanceMapper;
|
private TreenodeinstanceMapper treenodeinstanceMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByTreeId(Long treeId) {
|
||||||
|
treenodeinstanceMapper.deleteByTreeId(treeId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询行为树实例节点
|
* 查询行为树实例节点
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="xmlContent" column="xml_content" />
|
<result property="xmlContent" column="xml_content" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="findOneByPlatformId" resultMap="BehaviortreeResult">
|
||||||
|
select * from behaviortree
|
||||||
|
where platform_id=#{platformId}
|
||||||
|
limit 1
|
||||||
|
</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 from behaviortree
|
||||||
</sql>
|
</sql>
|
||||||
@@ -55,6 +61,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insert" parameterType="com.solution.scene.domain.AfsimScenario">
|
||||||
|
INSERT INTO afsim_scenario (name, description, scenario_path, communication_graph)
|
||||||
|
VALUES (#{name}, #{description}, #{scenarioPath}, #{communicationGraph})
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateBehaviortree" parameterType="Behaviortree">
|
<update id="updateBehaviortree" parameterType="Behaviortree">
|
||||||
update behaviortree
|
update behaviortree
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
|||||||
@@ -6,18 +6,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<resultMap type="Nodeconnection" id="NodeconnectionResult">
|
<resultMap type="Nodeconnection" id="NodeconnectionResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
|
<result property="treeId" column="tree_id" />
|
||||||
<result property="parentNodeId" column="parent_node_id" />
|
<result property="parentNodeId" column="parent_node_id" />
|
||||||
<result property="childNodeId" column="child_node_id" />
|
<result property="childNodeId" column="child_node_id" />
|
||||||
<result property="orderIndex" column="order_index" />
|
<result property="orderIndex" column="order_index" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<delete id="deleteByTreeId">
|
||||||
|
delete from nodeconnection where tree_id=#{treeId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
<sql id="selectNodeconnectionVo">
|
<sql id="selectNodeconnectionVo">
|
||||||
select id, parent_node_id, child_node_id, order_index from nodeconnection
|
select id, tree_id, parent_node_id, child_node_id, order_index from nodeconnection
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectNodeconnectionList" parameterType="Nodeconnection" resultMap="NodeconnectionResult">
|
<select id="selectNodeconnectionList" parameterType="Nodeconnection" resultMap="NodeconnectionResult">
|
||||||
<include refid="selectNodeconnectionVo"/>
|
<include refid="selectNodeconnectionVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
<if test="treeId != null "> and tree_id = #{treeId}</if>
|
||||||
<if test="parentNodeId != null "> and parent_node_id = #{parentNodeId}</if>
|
<if test="parentNodeId != null "> and parent_node_id = #{parentNodeId}</if>
|
||||||
<if test="childNodeId != null "> and child_node_id = #{childNodeId}</if>
|
<if test="childNodeId != null "> and child_node_id = #{childNodeId}</if>
|
||||||
<if test="orderIndex != null "> and order_index = #{orderIndex}</if>
|
<if test="orderIndex != null "> and order_index = #{orderIndex}</if>
|
||||||
@@ -32,11 +38,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<insert id="insertNodeconnection" parameterType="Nodeconnection" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertNodeconnection" parameterType="Nodeconnection" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into nodeconnection
|
insert into nodeconnection
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="treeId != null">tree_id,</if>
|
||||||
<if test="parentNodeId != null">parent_node_id,</if>
|
<if test="parentNodeId != null">parent_node_id,</if>
|
||||||
<if test="childNodeId != null">child_node_id,</if>
|
<if test="childNodeId != null">child_node_id,</if>
|
||||||
<if test="orderIndex != null">order_index,</if>
|
<if test="orderIndex != null">order_index,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="treeId != null">#{treeId},</if>
|
||||||
<if test="parentNodeId != null">#{parentNodeId},</if>
|
<if test="parentNodeId != null">#{parentNodeId},</if>
|
||||||
<if test="childNodeId != null">#{childNodeId},</if>
|
<if test="childNodeId != null">#{childNodeId},</if>
|
||||||
<if test="orderIndex != null">#{orderIndex},</if>
|
<if test="orderIndex != null">#{orderIndex},</if>
|
||||||
@@ -46,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<update id="updateNodeconnection" parameterType="Nodeconnection">
|
<update id="updateNodeconnection" parameterType="Nodeconnection">
|
||||||
update nodeconnection
|
update nodeconnection
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="treeId != null">tree_id = #{treeId},</if>
|
||||||
<if test="parentNodeId != null">parent_node_id = #{parentNodeId},</if>
|
<if test="parentNodeId != null">parent_node_id = #{parentNodeId},</if>
|
||||||
<if test="childNodeId != null">child_node_id = #{childNodeId},</if>
|
<if test="childNodeId != null">child_node_id = #{childNodeId},</if>
|
||||||
<if test="orderIndex != null">order_index = #{orderIndex},</if>
|
<if test="orderIndex != null">order_index = #{orderIndex},</if>
|
||||||
|
|||||||
@@ -6,13 +6,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<resultMap type="Nodeparameter" id="NodeparameterResult">
|
<resultMap type="Nodeparameter" id="NodeparameterResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
|
<result property="treeId" column="tree_id" />
|
||||||
<result property="nodeInstanceId" column="node_instance_id" />
|
<result property="nodeInstanceId" column="node_instance_id" />
|
||||||
<result property="paramDefId" column="param_def_id" />
|
<result property="paramDefId" column="param_def_id" />
|
||||||
<result property="value" column="value" />
|
<result property="value" column="value" />
|
||||||
|
<result property="groupIndex" column="group_index" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<delete id="deleteByTreeId">
|
||||||
|
delete from nodeparameter where tree_id=#{treeId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
<sql id="selectNodeparameterVo">
|
<sql id="selectNodeparameterVo">
|
||||||
select id, node_instance_id, param_def_id, value from nodeparameter
|
select id, treeId, 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">
|
||||||
@@ -32,23 +38,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<insert id="insertNodeparameter" parameterType="Nodeparameter" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertNodeparameter" parameterType="Nodeparameter" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into nodeparameter
|
insert into nodeparameter
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="treeId != null">tree_id,</if>
|
||||||
<if test="nodeInstanceId != null">node_instance_id,</if>
|
<if test="nodeInstanceId != null">node_instance_id,</if>
|
||||||
<if test="paramDefId != null">param_def_id,</if>
|
<if test="paramDefId != null">param_def_id,</if>
|
||||||
<if test="value != null">value,</if>
|
<if test="value != null">value,</if>
|
||||||
|
group_index
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="treeId != null">#{treeId},</if>
|
||||||
<if test="nodeInstanceId != null">#{nodeInstanceId},</if>
|
<if test="nodeInstanceId != null">#{nodeInstanceId},</if>
|
||||||
<if test="paramDefId != null">#{paramDefId},</if>
|
<if test="paramDefId != null">#{paramDefId},</if>
|
||||||
<if test="value != null">#{value},</if>
|
<if test="value != null">#{value},</if>
|
||||||
|
#{groupIndex}
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateNodeparameter" parameterType="Nodeparameter">
|
<update id="updateNodeparameter" parameterType="Nodeparameter">
|
||||||
update nodeparameter
|
update nodeparameter
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="treeId != null">tree_id = #{treeId},</if>
|
||||||
<if test="nodeInstanceId != null">node_instance_id = #{nodeInstanceId},</if>
|
<if test="nodeInstanceId != null">node_instance_id = #{nodeInstanceId},</if>
|
||||||
<if test="paramDefId != null">param_def_id = #{paramDefId},</if>
|
<if test="paramDefId != null">param_def_id = #{paramDefId},</if>
|
||||||
<if test="value != null">value = #{value},</if>
|
<if test="value != null">value = #{value},</if>
|
||||||
|
group_index=#{groupIndex}
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="logicHandler" column="logic_handler" />
|
<result property="logicHandler" column="logic_handler" />
|
||||||
<result property="description" column="description" />
|
<result property="description" column="description" />
|
||||||
<result property="englishName" column="english_name" />
|
<result property="englishName" column="english_name" />
|
||||||
<result property="templeteType" column="templete_type" />
|
<result property="templateType" column="templete_type" />
|
||||||
|
<result property="multiable" column="is_multiable" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectNodetemplateVo">
|
<sql id="selectNodetemplateVo">
|
||||||
select id, type, name, logic_handler, description, english_name, templete_type from nodetemplate
|
select id, type, name, logic_handler, description, english_name, templete_type, is_multiable from nodetemplate
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectNodetemplateList" parameterType="Nodetemplate" resultMap="NodetemplateResult">
|
<select id="selectNodetemplateList" parameterType="Nodetemplate" resultMap="NodetemplateResult">
|
||||||
@@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="logicHandler != null and logicHandler != ''"> and logic_handler = #{logicHandler}</if>
|
<if test="logicHandler != null and logicHandler != ''"> and logic_handler = #{logicHandler}</if>
|
||||||
<if test="description != null and description != ''"> and description = #{description}</if>
|
<if test="description != null and description != ''"> and description = #{description}</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="templeteType != null and templeteType != ''"> and templete_type = #{templeteType}</if>
|
<if test="templateType != null and templateType != ''"> and templete_type = #{templateType}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="logicHandler != null">logic_handler,</if>
|
<if test="logicHandler != null">logic_handler,</if>
|
||||||
<if test="description != null">description,</if>
|
<if test="description != null">description,</if>
|
||||||
<if test="englishName != null">english_name,</if>
|
<if test="englishName != null">english_name,</if>
|
||||||
<if test="templeteType != null and templeteType != ''">templete_type,</if>
|
<if test="templateType != null and templateType != ''">templete_type,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="type != null and type != ''">#{type},</if>
|
<if test="type != null and type != ''">#{type},</if>
|
||||||
@@ -51,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="logicHandler != null">#{logicHandler},</if>
|
<if test="logicHandler != null">#{logicHandler},</if>
|
||||||
<if test="description != null">#{description},</if>
|
<if test="description != null">#{description},</if>
|
||||||
<if test="englishName != null">#{englishName},</if>
|
<if test="englishName != null">#{englishName},</if>
|
||||||
<if test="templeteType != null and templeteType != ''">#{templeteType},</if>
|
<if test="templateType != null and templateType != ''">#{templateType},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="logicHandler != null">logic_handler = #{logicHandler},</if>
|
<if test="logicHandler != null">logic_handler = #{logicHandler},</if>
|
||||||
<if test="description != null">description = #{description},</if>
|
<if test="description != null">description = #{description},</if>
|
||||||
<if test="englishName != null">english_name = #{englishName},</if>
|
<if test="englishName != null">english_name = #{englishName},</if>
|
||||||
<if test="templeteType != null and templeteType != ''">templete_type = #{templeteType},</if>
|
<if test="templateType != null and templateType != ''">templete_type = #{templateType},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
select id, template_id, param_key, data_type, default_value, description, template_type from templateparameterdef
|
select id, template_id, param_key, data_type, default_value, description, template_type from templateparameterdef
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTemplateparameterdefList" parameterType="Templateparameterdef" resultMap="TemplateparameterdefResult">
|
<select id="selectTemplateparameterdefList" parameterType="templateparameterdef" resultMap="TemplateparameterdefResult">
|
||||||
<include refid="selectTemplateparameterdefVo"/>
|
<include refid="selectTemplateparameterdefVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="templateId != null "> and template_id = #{templateId}</if>
|
<if test="templateId != null "> and template_id = #{templateId}</if>
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="desciption" column="desciption" />
|
<result property="desciption" column="desciption" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<delete id="deleteByTreeId">
|
||||||
|
delete from treenodeinstance where tree_id=#{treeId}
|
||||||
|
</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, uuid,desciption from treenodeinstance
|
||||||
</sql>
|
</sql>
|
||||||
|
|||||||
@@ -113,6 +113,18 @@
|
|||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.34</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.8.25</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.solution.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 火力规则常量
|
||||||
|
*/
|
||||||
|
public class ExceptionConstants {
|
||||||
|
|
||||||
|
public static final String PARAMETER_EXCEPTION = "参数异常";
|
||||||
|
|
||||||
|
public static final String RESULT_EXCEPTION = "结果异常";
|
||||||
|
|
||||||
|
public static final String NOT_FOUND_CARRIAGE_CHAIN_HANDLER = "not found carriage chain handler!";
|
||||||
|
|
||||||
|
public static final String NOT_FOUND_F22_COMPONENT = "未找到 F-22 组件";
|
||||||
|
|
||||||
|
public static final String SCENE_CONFIG_NOT_NULL = "场景配置不能为空";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.solution.common.constant;
|
||||||
|
|
||||||
|
|
||||||
|
public class PlatformAndModuleConstants {
|
||||||
|
|
||||||
|
public static final String RED_NEBO_M_1 = "red_nebo_m_1";
|
||||||
|
|
||||||
|
public static final String RED_NEBO_M_2 = "red_nebo_m_2";
|
||||||
|
|
||||||
|
public static final String RED_TANK_1 = "red_tank_1";
|
||||||
|
}
|
||||||
82
auto-solution-rule/pom.xml
Normal file
82
auto-solution-rule/pom.xml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>solution</artifactId>
|
||||||
|
<groupId>com.solution</groupId>
|
||||||
|
<version>3.9.1</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>solution-rule</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
rule模块
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- Drools 版本,建议使用稳定版,如 7.74.1.Final 或 8.x 系列 -->
|
||||||
|
<drools.version>7.74.1.Final</drools.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- 1. Drools 核心引擎 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.drools</groupId>
|
||||||
|
<artifactId>drools-core</artifactId>
|
||||||
|
<version>${drools.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.drools</groupId>
|
||||||
|
<artifactId>drools-templates</artifactId>
|
||||||
|
<version>${drools.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 2. KIE API(Drools 属于 KIE 项目的一部分,此依赖提供核心 API) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.kie</groupId>
|
||||||
|
<artifactId>kie-api</artifactId>
|
||||||
|
<version>${drools.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 3. 规则编译器(用于编译 .drl 等规则文件) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.drools</groupId>
|
||||||
|
<artifactId>drools-compiler</artifactId>
|
||||||
|
<version>${drools.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 4. Spring 整合(如果需要和 Spring/Spring Boot 深度整合) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.kie</groupId>
|
||||||
|
<artifactId>kie-spring</artifactId>
|
||||||
|
<version>${drools.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 流式解析工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.15.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 通用工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.solution</groupId>
|
||||||
|
<artifactId>solution-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package com.solution.rule.config;
|
||||||
|
|
||||||
|
import org.kie.api.KieBase;
|
||||||
|
import org.kie.api.KieServices;
|
||||||
|
import org.kie.api.builder.KieBuilder;
|
||||||
|
import org.kie.api.builder.KieFileSystem;
|
||||||
|
import org.kie.api.builder.KieRepository;
|
||||||
|
import org.kie.api.builder.Message;
|
||||||
|
import org.kie.api.runtime.KieContainer;
|
||||||
|
import org.kie.api.runtime.KieSession;
|
||||||
|
import org.kie.internal.io.ResourceFactory;
|
||||||
|
import org.kie.spring.KModuleBeanFactoryPostProcessor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class DroolsConfig {
|
||||||
|
|
||||||
|
private static final String RULE_PATH = "classpath*:rules/**/*.drl";
|
||||||
|
|
||||||
|
private final KieServices kieServices = KieServices.Factory.get();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载规则文件
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public KieFileSystem kieFileSystem() throws IOException {
|
||||||
|
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
|
||||||
|
|
||||||
|
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
Resource[] resources = resolver.getResources(RULE_PATH);
|
||||||
|
|
||||||
|
for (Resource resource : resources) {
|
||||||
|
kieFileSystem.write(
|
||||||
|
ResourceFactory.newInputStreamResource(resource.getInputStream())
|
||||||
|
.setSourcePath("rules/" + resource.getFilename())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return kieFileSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 KieContainer
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public KieContainer kieContainer(KieFileSystem kieFileSystem) {
|
||||||
|
|
||||||
|
KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem);
|
||||||
|
kieBuilder.buildAll();
|
||||||
|
|
||||||
|
// 检查错误
|
||||||
|
if (kieBuilder.getResults().hasMessages(Message.Level.ERROR)) {
|
||||||
|
throw new RuntimeException("Drools规则编译错误:\n" +
|
||||||
|
kieBuilder.getResults().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
KieRepository repository = kieServices.getRepository();
|
||||||
|
|
||||||
|
return kieServices.newKieContainer(repository.getDefaultReleaseId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KieBase
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public KieBase kieBase(KieContainer kieContainer) {
|
||||||
|
return kieContainer.getKieBase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KieSession(推荐加)
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public KieSession kieSession(KieContainer kieContainer) {
|
||||||
|
return kieContainer.newKieSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必须是 static
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public static KModuleBeanFactoryPostProcessor kiePostProcessor() {
|
||||||
|
return new KModuleBeanFactoryPostProcessor();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.solution.rule.domain;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BasicPlatform implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.solution.rule.domain;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.dto.WeaponModelDTO;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FireRuleExecuteDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("场景类型")
|
||||||
|
private Integer sceneType;
|
||||||
|
|
||||||
|
@ApiModelProperty("武器模型数据")
|
||||||
|
private List<WeaponModelDTO> weaponModelDTOs;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.solution.rule.domain;
|
||||||
|
/*
|
||||||
|
* This file is part of the kernelstudio package.
|
||||||
|
*
|
||||||
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE file
|
||||||
|
* that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Platform extends BasicPlatform {
|
||||||
|
|
||||||
|
private List<PlatformComponent> components;
|
||||||
|
|
||||||
|
public List<PlatformComponent> getComponents() {
|
||||||
|
return components;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComponents(List<PlatformComponent> components) {
|
||||||
|
this.components = components;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.solution.rule.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台挂载的组件实体类
|
||||||
|
* 对应表 platform_component
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "平台组件对象", description = "平台所挂载的武器、雷达、通信等组件")
|
||||||
|
public class PlatformComponent {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件ID,主键自增")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件名称(具体型号)")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件类型:weapon(武器)、radar(雷达)、comm(通信)")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件描述信息")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "所属平台ID,关联platform表")
|
||||||
|
private Integer platformId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组件数量")
|
||||||
|
private Long num;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "平台参数(List<String>)")
|
||||||
|
private List<String> platformParams;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.solution.rule.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("红蓝对抗规则")
|
||||||
|
public class Rule {
|
||||||
|
@ApiModelProperty("规则ID")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("规则名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("场景类型:0-防御,1-空降,null表示通用")
|
||||||
|
private Integer sceneType;
|
||||||
|
|
||||||
|
@ApiModelProperty("触发条件(JSON格式)")
|
||||||
|
private String conditions;
|
||||||
|
|
||||||
|
@ApiModelProperty("响应动作(JSON格式)")
|
||||||
|
private String actions;
|
||||||
|
|
||||||
|
@ApiModelProperty("优先级(数值越小优先级越高)")
|
||||||
|
private Integer priority;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否启用(0禁用,1启用)")
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private Date createdTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private Date updatedTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.solution.rule.domain;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.dto.WeaponModelDTO;
|
||||||
|
import com.solution.rule.domain.vo.ComponentCountVO;
|
||||||
|
import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
|
||||||
|
import com.solution.rule.domain.vo.WeaponModelVO;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RuleParam {
|
||||||
|
|
||||||
|
private List<PlatformWeaponAggregateVO> resultWeapons;
|
||||||
|
|
||||||
|
private WeaponModelVO weaponModelVO;
|
||||||
|
|
||||||
|
private List<WeaponModelDTO> weaponModelDTOList;
|
||||||
|
|
||||||
|
private List<ComponentCountVO> databaseWeapons;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.solution.rule.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ComponentJsonDTO {
|
||||||
|
|
||||||
|
//组件类型
|
||||||
|
private String type;
|
||||||
|
//组件名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
//组件参数列表
|
||||||
|
private List<PlatformJsonDTO> parameters;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.solution.rule.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ComponentParamJsonDTO {
|
||||||
|
|
||||||
|
// 参数名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String def;
|
||||||
|
|
||||||
|
// 参数值
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
// 参数单位
|
||||||
|
private String unit;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.solution.rule.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PlatformJsonDTO {
|
||||||
|
// 装备ID
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
// 装备名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 平台类型 (Platform_type)
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
// 子组件列表(武器、传感器、通信等)
|
||||||
|
private List<ComponentJsonDTO> components;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.solution.rule.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.sound.midi.Track;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TaskJsonDTO {
|
||||||
|
|
||||||
|
//任务id
|
||||||
|
private Long attackId;
|
||||||
|
|
||||||
|
//任务名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
//任务类型
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
//任务下的平台
|
||||||
|
private List<PlatformJsonDTO> platforms;
|
||||||
|
|
||||||
|
//任务轨迹
|
||||||
|
private List<Track> tracks;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.solution.rule.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TrackJsonDTO {
|
||||||
|
|
||||||
|
// 轨迹ID
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
// 轨迹名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 轨迹点列表
|
||||||
|
private List<TrackPointJsonDTO> points;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.solution.rule.domain.dto;
|
||||||
|
|
||||||
|
public class TrackPointJsonDTO {
|
||||||
|
|
||||||
|
// 轨迹点索引
|
||||||
|
private int index;
|
||||||
|
|
||||||
|
// 经度
|
||||||
|
private double longitude;
|
||||||
|
|
||||||
|
// 纬度
|
||||||
|
private double latitude;
|
||||||
|
|
||||||
|
// 高度(米)
|
||||||
|
private double height;
|
||||||
|
|
||||||
|
// 速度(米/秒)
|
||||||
|
private double speed;
|
||||||
|
|
||||||
|
// 航向角(度)
|
||||||
|
private double heading;
|
||||||
|
|
||||||
|
// 时间点(秒)
|
||||||
|
private double time;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.solution.rule.domain.dto;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.PlatformComponent;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WeaponModelDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("平台id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("平台名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("平台描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@ApiModelProperty("平台组件")
|
||||||
|
private List<PlatformComponent> components;
|
||||||
|
|
||||||
|
@ApiModelProperty("平台参数(List<String>)")
|
||||||
|
private List<String> platformParams;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.solution.common.utils.sign.Md5Utils;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个属性的定义
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Attribute {
|
||||||
|
|
||||||
|
//uuid
|
||||||
|
@JsonProperty("_uuid")
|
||||||
|
private String uuid;
|
||||||
|
/** 属性数据类型(如:float、int、string、bool、enum) */
|
||||||
|
private String attDataType;
|
||||||
|
/** 属性定义(英文标识) */
|
||||||
|
private String attDef;
|
||||||
|
/** 属性默认值 */
|
||||||
|
private String attDefaultValue;
|
||||||
|
/** 属性详细信息 */
|
||||||
|
private Object attDetail;
|
||||||
|
/** 属性说明(中文描述) */
|
||||||
|
private String attExplain;
|
||||||
|
/** 属性ID */
|
||||||
|
private String attId;
|
||||||
|
/** 属性名称(中文) */
|
||||||
|
private String attName;
|
||||||
|
/** 属性取值范围(格式:最小值|最大值) */
|
||||||
|
private String attRange;
|
||||||
|
/** 属性单位 */
|
||||||
|
private String attUnit;
|
||||||
|
/** 是否为内置属性 */
|
||||||
|
private boolean builtIn;
|
||||||
|
/** 枚举信息 */
|
||||||
|
private String enumInfo;
|
||||||
|
/** 是否为关键属性 */
|
||||||
|
private boolean isKey;
|
||||||
|
/** 是否为公共属性 */
|
||||||
|
private boolean isPublic;
|
||||||
|
/** 是否可搜索 */
|
||||||
|
private boolean isSearch;
|
||||||
|
/** 是否为文本域 */
|
||||||
|
private boolean isTextarea;
|
||||||
|
/** 模型信息(可以是对象或数组,此处定义为具体对象) */
|
||||||
|
private List<ModelInfo> mdlInfo;
|
||||||
|
/** 是否只读(0-可编辑,1-只读) */
|
||||||
|
private int readOnly;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典项实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DictItem {
|
||||||
|
/** 编码 */
|
||||||
|
private String code;
|
||||||
|
/** 说明 */
|
||||||
|
private String explain;
|
||||||
|
/** 名称 */
|
||||||
|
private String name;
|
||||||
|
/** 唯一标识符 */
|
||||||
|
private String uuid;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Equipments {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Force {
|
||||||
|
|
||||||
|
//对象句柄
|
||||||
|
private String ObjectHandle;
|
||||||
|
|
||||||
|
//类型
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阵营实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ForceSides {
|
||||||
|
|
||||||
|
//分组类型
|
||||||
|
private String groupType;
|
||||||
|
|
||||||
|
private List<Force> postures;
|
||||||
|
|
||||||
|
//对象句柄
|
||||||
|
private String ObjectHandle;
|
||||||
|
|
||||||
|
//阵营名称
|
||||||
|
private String ForceSideName;
|
||||||
|
|
||||||
|
//作战目标
|
||||||
|
private String warGoal;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型信息实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ModelInfo {
|
||||||
|
/** 模型ID */
|
||||||
|
@JsonProperty("_id")
|
||||||
|
private String id;
|
||||||
|
/** 类别 */
|
||||||
|
private String category;
|
||||||
|
/** 分类ID */
|
||||||
|
private String classifyId;
|
||||||
|
/** 分类名称 */
|
||||||
|
private String classifyName;
|
||||||
|
/** 创建时间(时间戳) */
|
||||||
|
private long createTime;
|
||||||
|
/** 字典项列表 */
|
||||||
|
private List<DictItem> dict;
|
||||||
|
/** 模型系统ID */
|
||||||
|
private int mxSysId;
|
||||||
|
/** 名称 */
|
||||||
|
private String name;
|
||||||
|
/** 角色ID */
|
||||||
|
private int roleId;
|
||||||
|
/** 空间ID */
|
||||||
|
private int spaceId;
|
||||||
|
/** 更新时间(时间戳) */
|
||||||
|
private long updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引用属性对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RefAttributeObject {
|
||||||
|
|
||||||
|
//属性列表
|
||||||
|
private Map<String, List<Attribute>> attributes;
|
||||||
|
|
||||||
|
private TrackParam trackParam;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收智唐接口实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RequestDTO {
|
||||||
|
|
||||||
|
//引用属性对象(设备属性定义)
|
||||||
|
private RefAttributeObject refAttributeObject;
|
||||||
|
|
||||||
|
//阵营列表
|
||||||
|
private List<ForceSides> forceSides;
|
||||||
|
|
||||||
|
//装备列表
|
||||||
|
private List<Equipments> equipments;
|
||||||
|
|
||||||
|
//private List<Tasks> tasks;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Track {
|
||||||
|
//航迹名称
|
||||||
|
private String name;
|
||||||
|
//航迹开始时间
|
||||||
|
private int StartTime;
|
||||||
|
//航迹结束时间
|
||||||
|
private int EndTime;
|
||||||
|
//航迹类型
|
||||||
|
private String TrackType;
|
||||||
|
//航迹高度类型
|
||||||
|
private String HeightType;
|
||||||
|
//航迹海面类型
|
||||||
|
private String seaType;
|
||||||
|
//航迹点集合
|
||||||
|
private List<TrackPoint> TrackPoints;
|
||||||
|
//航迹所属阵营
|
||||||
|
private String Color;
|
||||||
|
//航迹总点数
|
||||||
|
private int PointCount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import javax.sound.midi.Track;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 航迹参数
|
||||||
|
*/
|
||||||
|
public class TrackParam {
|
||||||
|
|
||||||
|
private Map<String, List<Track>> tracks;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.solution.rule.domain.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 航迹节点实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TrackPoint {
|
||||||
|
//航迹索引
|
||||||
|
private String index;
|
||||||
|
//经度
|
||||||
|
private String longitude;
|
||||||
|
//纬度
|
||||||
|
private String latitude;
|
||||||
|
//高度
|
||||||
|
private String height;
|
||||||
|
//航速
|
||||||
|
private String speed;
|
||||||
|
//航向角
|
||||||
|
private String psia;
|
||||||
|
//时间
|
||||||
|
private String time;
|
||||||
|
//活动
|
||||||
|
private String active;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.solution.rule.domain.simplerulepojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ComponentParam {
|
||||||
|
|
||||||
|
//唯一标识符
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
|
//组件默认参数
|
||||||
|
private String attDefaultValue;
|
||||||
|
|
||||||
|
//参数单位
|
||||||
|
private String attExplain;
|
||||||
|
|
||||||
|
//组件数量
|
||||||
|
private Integer number;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.solution.rule.domain.simplerulepojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Coordinate {
|
||||||
|
|
||||||
|
//经度
|
||||||
|
private BigDecimal longitude;
|
||||||
|
|
||||||
|
//纬度
|
||||||
|
private BigDecimal latitude;
|
||||||
|
|
||||||
|
//高度
|
||||||
|
private Integer height;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.solution.rule.domain.simplerulepojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SubComponents {
|
||||||
|
|
||||||
|
//设备id
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
//设备名称
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
//设备组件参数
|
||||||
|
private List<ComponentParam> componentParams;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.solution.rule.domain.simplerulepojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简单任务实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Task {
|
||||||
|
|
||||||
|
//任务id
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
//任务名称
|
||||||
|
private String drawName;
|
||||||
|
|
||||||
|
//任务类型
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
//任务所属阵营
|
||||||
|
private String side;
|
||||||
|
|
||||||
|
//任务威胁等级(1-3)
|
||||||
|
private String threatLevel;
|
||||||
|
|
||||||
|
//任务航迹
|
||||||
|
private List<TrackPoints> trackPoints;
|
||||||
|
|
||||||
|
//任务武器
|
||||||
|
private List<Weapon> taskWeapons;
|
||||||
|
|
||||||
|
//任务目标id
|
||||||
|
private String targetId;
|
||||||
|
|
||||||
|
//作战区经纬高
|
||||||
|
private List<Coordinate> warZoneLocation;
|
||||||
|
|
||||||
|
//防区经纬高
|
||||||
|
private List<Coordinate> defZoneLocation;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.solution.rule.domain.simplerulepojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TrackPoints extends Coordinate{
|
||||||
|
|
||||||
|
// 轨迹索引
|
||||||
|
private Integer index;
|
||||||
|
|
||||||
|
// // 轨迹点经度
|
||||||
|
// private BigDecimal longitude;
|
||||||
|
//
|
||||||
|
// // 轨迹点纬度
|
||||||
|
// private BigDecimal latitude;
|
||||||
|
//
|
||||||
|
// // 轨迹点高度
|
||||||
|
// private Integer height;
|
||||||
|
|
||||||
|
//速度
|
||||||
|
private Integer speed;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.solution.rule.domain.simplerulepojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Weapon {
|
||||||
|
|
||||||
|
//装备id
|
||||||
|
private String equipmentId;
|
||||||
|
|
||||||
|
//装备名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
//装备类型
|
||||||
|
private String supportType;
|
||||||
|
|
||||||
|
//装备组件
|
||||||
|
private List<SubComponents> components;
|
||||||
|
|
||||||
|
//装备部署位置(经纬高)
|
||||||
|
private Coordinate coordinate;
|
||||||
|
|
||||||
|
//武器数量
|
||||||
|
private Integer number;
|
||||||
|
|
||||||
|
//目标id
|
||||||
|
private String targetId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.solution.rule.domain.simplerulepojo.fact;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.simplerulepojo.Task;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FactTask {
|
||||||
|
|
||||||
|
private Task blueTask;
|
||||||
|
|
||||||
|
private Task redTask;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.solution.rule.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
// 组件计数VO
|
||||||
|
@Data
|
||||||
|
@ApiModel("组件计数信息")
|
||||||
|
public class ComponentCountVO {
|
||||||
|
@ApiModelProperty("组件名称")
|
||||||
|
private String componentName;
|
||||||
|
|
||||||
|
@ApiModelProperty("组件数量")
|
||||||
|
private Long count;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.solution.rule.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("平台组件名称聚合")
|
||||||
|
public class PlatformComponentNamesVO {
|
||||||
|
@ApiModelProperty("平台名称")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
|
@ApiModelProperty("该平台下的组件名称列表(去重)")
|
||||||
|
private List<String> componentNames;
|
||||||
|
|
||||||
|
@ApiModelProperty("平台描述")
|
||||||
|
private String platformDescription;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.solution.rule.domain.vo;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.PlatformComponent;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
// 平台武器聚合VO
|
||||||
|
@Data
|
||||||
|
@ApiModel("平台武器聚合信息")
|
||||||
|
public class PlatformWeaponAggregateVO {
|
||||||
|
@ApiModelProperty("平台名称")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
|
@ApiModelProperty("该平台下的组件列表")
|
||||||
|
private List<PlatformComponent> components;
|
||||||
|
|
||||||
|
@ApiModelProperty("返回数据库数据")
|
||||||
|
private List<ComponentCountVO> componentCountVOS;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.solution.rule.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WeaponModelVO {
|
||||||
|
|
||||||
|
@ApiModelProperty("平台名称")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
|
@ApiModelProperty("组件名称")
|
||||||
|
private String componentName;
|
||||||
|
|
||||||
|
@ApiModelProperty("组件数量")
|
||||||
|
private Long count;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.solution.rule.enums;
|
||||||
|
|
||||||
|
public enum SceneType {
|
||||||
|
|
||||||
|
DEFENSE(0, "防御"),
|
||||||
|
AIRBORNE(1, "空降");
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
SceneType(int code, String description) {
|
||||||
|
this.code = code;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数字编码获取对应的枚举
|
||||||
|
* @param code 前端传递的数字
|
||||||
|
* @return 枚举实例
|
||||||
|
* @throws IllegalArgumentException 如果找不到对应枚举
|
||||||
|
*/
|
||||||
|
public static SceneType fromCode(int code) {
|
||||||
|
for (SceneType type : values()) {
|
||||||
|
if (type.code == code) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("未知的场景类型编码: " + code);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.solution.rule.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.solution.rule.domain.RuleParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则链抽象类
|
||||||
|
*/
|
||||||
|
public abstract class AbstractRuleChainHandler {
|
||||||
|
|
||||||
|
|
||||||
|
private AbstractRuleChainHandler nextHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行过滤方法
|
||||||
|
* @param ruleParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract RuleParam doHandler(RuleParam ruleParam);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行下一个处理器
|
||||||
|
* @param ruleParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RuleParam doNextHandler(RuleParam ruleParam){
|
||||||
|
if(ObjectUtil.isEmpty(nextHandler) || ObjectUtil.isNotEmpty(ruleParam)){
|
||||||
|
return ruleParam;
|
||||||
|
}
|
||||||
|
return nextHandler.doHandler(ruleParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置下游handler
|
||||||
|
* @param nextHandler
|
||||||
|
*/
|
||||||
|
public void setNextHandler(AbstractRuleChainHandler nextHandler) {
|
||||||
|
this.nextHandler = nextHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.solution.rule.handler;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.solution.common.constant.ExceptionConstants;
|
||||||
|
import com.solution.rule.domain.RuleParam;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装规则处理链
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RuleChainHandler {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private List<AbstractRuleChainHandler> chainHandlers;
|
||||||
|
|
||||||
|
private AbstractRuleChainHandler firstHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组装处理链
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
private void constructChain(){
|
||||||
|
if (CollUtil.isEmpty(chainHandlers)) {
|
||||||
|
throw new RuntimeException(ExceptionConstants.NOT_FOUND_CARRIAGE_CHAIN_HANDLER);
|
||||||
|
}
|
||||||
|
this.firstHandler = chainHandlers.get(0);
|
||||||
|
for (int i = 0; i < chainHandlers.size(); i++) {
|
||||||
|
if(i == (chainHandlers.size() - 1)){
|
||||||
|
chainHandlers.get(i).setNextHandler(null);
|
||||||
|
}else {
|
||||||
|
chainHandlers.get(i).setNextHandler(chainHandlers.get(i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuleParam findRuleParam(RuleParam ruleParam){
|
||||||
|
return firstHandler.doHandler(ruleParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package com.solution.rule.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.solution.common.constant.ExceptionConstants;
|
||||||
|
import com.solution.common.constant.PlatformAndModuleConstants;
|
||||||
|
import com.solution.rule.domain.PlatformComponent;
|
||||||
|
import com.solution.rule.domain.RuleParam;
|
||||||
|
import com.solution.rule.domain.dto.WeaponModelDTO;
|
||||||
|
import com.solution.rule.handler.opponent.OpponentParamChain;
|
||||||
|
import com.solution.rule.domain.vo.ComponentCountVO;
|
||||||
|
import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 战斗机处理链
|
||||||
|
* 规则:针对 F22 平台,后端返回的组件数量比前端传递的大1,
|
||||||
|
* 如果数据库中 F22 平台所有组件总数小于前端数量+1,则返回该总数。
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class WarplaneHandler extends AbstractRuleChainHandler {
|
||||||
|
|
||||||
|
// 组件数量增量常量
|
||||||
|
private static final long COMPONENT_COUNT_INCREMENT = 1;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OpponentParamChain opponentParamChain;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RuleParam doHandler(RuleParam ruleParam) {
|
||||||
|
// 1. 参数校验
|
||||||
|
if (ObjectUtil.isEmpty(ruleParam) || CollUtil.isEmpty(ruleParam.getWeaponModelDTOList())) {
|
||||||
|
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<WeaponModelDTO> dtoList = ruleParam.getWeaponModelDTOList();
|
||||||
|
List<ComponentCountVO> databaseWeapons = ruleParam.getDatabaseWeapons();
|
||||||
|
|
||||||
|
List<PlatformWeaponAggregateVO> resultWeapons = new ArrayList<>();
|
||||||
|
|
||||||
|
Iterator<WeaponModelDTO> iterator = dtoList.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
WeaponModelDTO dto = iterator.next();
|
||||||
|
if(PlatformAndModuleConstants.RED_NEBO_M_1.equals(dto.getName())){
|
||||||
|
List<PlatformComponent> components = dto.getComponents();
|
||||||
|
List<PlatformComponent> componentList = new ArrayList<>();
|
||||||
|
|
||||||
|
//遍历前端数据的组件
|
||||||
|
for (PlatformComponent component : components) {
|
||||||
|
//遍历数据库数据
|
||||||
|
for (ComponentCountVO databaseWeapon : databaseWeapons) {
|
||||||
|
if(component.getName().equals(databaseWeapon.getComponentName())){
|
||||||
|
PlatformComponent component1 = new PlatformComponent();
|
||||||
|
component1.setName(databaseWeapon.getComponentName());
|
||||||
|
// TODO
|
||||||
|
component1.setPlatformParams(CollUtil.isNotEmpty(component.getPlatformParams())
|
||||||
|
? component.getPlatformParams()
|
||||||
|
: dto.getPlatformParams());
|
||||||
|
opponentParamChain.apply(ruleParam, dto, componentList);
|
||||||
|
if(databaseWeapon.getCount() > component.getNum()){
|
||||||
|
component1.setNum(component.getNum() + COMPONENT_COUNT_INCREMENT);
|
||||||
|
}else {
|
||||||
|
component1.setNum(databaseWeapon.getCount());
|
||||||
|
}
|
||||||
|
componentList.add(component1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlatformWeaponAggregateVO platformVO = new PlatformWeaponAggregateVO();
|
||||||
|
platformVO.setPlatformName(dto.getName());
|
||||||
|
platformVO.setComponents(componentList);
|
||||||
|
resultWeapons.add(platformVO);
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ruleParam.setResultWeapons(resultWeapons);
|
||||||
|
return ruleParam;
|
||||||
|
|
||||||
|
// return super.doNextHandler(ruleParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.solution.rule.handler.opponent;
|
||||||
|
|
||||||
|
public abstract class AbstractOpponentParamHandler {
|
||||||
|
|
||||||
|
private AbstractOpponentParamHandler next;
|
||||||
|
|
||||||
|
public abstract void handle(OpponentParamContext context);
|
||||||
|
|
||||||
|
protected void doNext(OpponentParamContext context) {
|
||||||
|
if (next == null) return;
|
||||||
|
next.handle(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNext(AbstractOpponentParamHandler next) {
|
||||||
|
this.next = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.solution.rule.handler.opponent;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.PlatformComponent;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Order(2)
|
||||||
|
public class Ammo20Handler extends AbstractOpponentParamHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(OpponentParamContext context) {
|
||||||
|
Long ammo = context.getParamLong("ammo");
|
||||||
|
if (ammo != null && ammo <= 20) {
|
||||||
|
PlatformComponent reaction = new PlatformComponent();
|
||||||
|
reaction.setType("weapon");
|
||||||
|
reaction.setName("reaction_ammo_le_20");
|
||||||
|
reaction.setNum(1L);
|
||||||
|
context.addReactionComponent(reaction);
|
||||||
|
}
|
||||||
|
doNext(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.solution.rule.handler.opponent;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.PlatformComponent;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Order(3)
|
||||||
|
public class Distance50Handler extends AbstractOpponentParamHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(OpponentParamContext context) {
|
||||||
|
Long distance = context.getParamLong("distance");
|
||||||
|
if (distance != null && distance <= 50) {
|
||||||
|
PlatformComponent reaction = new PlatformComponent();
|
||||||
|
reaction.setType("weapon");
|
||||||
|
reaction.setName("reaction_distance_le_50");
|
||||||
|
reaction.setNum(1L);
|
||||||
|
context.addReactionComponent(reaction);
|
||||||
|
}
|
||||||
|
doNext(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.solution.rule.handler.opponent;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.PlatformComponent;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Order(4)
|
||||||
|
public class FallbackHandler extends AbstractOpponentParamHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(OpponentParamContext context) {
|
||||||
|
PlatformComponent reaction = new PlatformComponent();
|
||||||
|
reaction.setType("weapon");
|
||||||
|
reaction.setName("reaction_default");
|
||||||
|
reaction.setNum(0L);
|
||||||
|
context.addReactionComponent(reaction);
|
||||||
|
doNext(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.solution.rule.handler.opponent;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.solution.rule.domain.PlatformComponent;
|
||||||
|
import com.solution.rule.domain.RuleParam;
|
||||||
|
import com.solution.rule.domain.dto.WeaponModelDTO;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class OpponentParamChain {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private List<AbstractOpponentParamHandler> handlers;
|
||||||
|
|
||||||
|
private AbstractOpponentParamHandler first;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
private void construct() {
|
||||||
|
if (CollUtil.isEmpty(handlers)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.first = handlers.get(0);
|
||||||
|
for (int i = 0; i < handlers.size(); i++) {
|
||||||
|
AbstractOpponentParamHandler current = handlers.get(i);
|
||||||
|
AbstractOpponentParamHandler next = (i == handlers.size() - 1) ? null : handlers.get(i + 1);
|
||||||
|
current.setNext(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void apply(RuleParam ruleParam, WeaponModelDTO dto, List<PlatformComponent> resultComponents) {
|
||||||
|
if (first == null) return;
|
||||||
|
OpponentParamContext context = new OpponentParamContext(ruleParam, dto, resultComponents);
|
||||||
|
first.handle(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package com.solution.rule.handler.opponent;
|
||||||
|
|
||||||
|
import com.solution.rule.domain.PlatformComponent;
|
||||||
|
import com.solution.rule.domain.RuleParam;
|
||||||
|
import com.solution.rule.domain.dto.WeaponModelDTO;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class OpponentParamContext {
|
||||||
|
|
||||||
|
private static final Pattern NUMBER_PATTERN = Pattern.compile("(\\d+(?:\\.\\d+)?)");
|
||||||
|
|
||||||
|
private final RuleParam ruleParam;
|
||||||
|
private final WeaponModelDTO weaponModelDTO;
|
||||||
|
private final List<PlatformComponent> resultComponents;
|
||||||
|
private final Map<String, String> paramMap;
|
||||||
|
|
||||||
|
public OpponentParamContext(RuleParam ruleParam, WeaponModelDTO weaponModelDTO, List<PlatformComponent> resultComponents) {
|
||||||
|
this.ruleParam = ruleParam;
|
||||||
|
this.weaponModelDTO = weaponModelDTO;
|
||||||
|
this.resultComponents = resultComponents;
|
||||||
|
this.paramMap = parseParams(weaponModelDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParamRaw(String key) {
|
||||||
|
if (key == null) return null;
|
||||||
|
return paramMap.get(key.toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getParamLong(String key) {
|
||||||
|
String raw = getParamRaw(key);
|
||||||
|
if (raw == null) return null;
|
||||||
|
Matcher m = NUMBER_PATTERN.matcher(raw);
|
||||||
|
if (!m.find()) return null;
|
||||||
|
try {
|
||||||
|
return (long) Double.parseDouble(m.group(1));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addReactionComponent(PlatformComponent component) {
|
||||||
|
if (component == null || component.getName() == null) return;
|
||||||
|
for (PlatformComponent existing : resultComponents) {
|
||||||
|
if (component.getName().equals(existing.getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultComponents.add(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> parseParams(WeaponModelDTO dto) {
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
if (dto == null || dto.getPlatformParams() == null) return map;
|
||||||
|
for (String item : dto.getPlatformParams()) {
|
||||||
|
if (item == null) continue;
|
||||||
|
String s = item.trim();
|
||||||
|
if (s.isEmpty()) continue;
|
||||||
|
|
||||||
|
String[] parts;
|
||||||
|
if (s.contains("=")) {
|
||||||
|
parts = s.split("=", 2);
|
||||||
|
} else if (s.contains(":")) {
|
||||||
|
parts = s.split(":", 2);
|
||||||
|
} else if (s.contains(":")) {
|
||||||
|
parts = s.split(":", 2);
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (parts.length != 2) continue;
|
||||||
|
|
||||||
|
String key = parts[0].trim().toLowerCase(Locale.ROOT);
|
||||||
|
String val = parts[1].trim();
|
||||||
|
if (!key.isEmpty() && !val.isEmpty()) {
|
||||||
|
map.put(key, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
## opponent(对方参数嵌套责任链)说明
|
||||||
|
|
||||||
|
本目录新增了一套**“嵌套责任链”**,用于在已有规则链(`AbstractRuleChainHandler` / `RuleChainHandler`)执行过程中,再额外对“对方传入的平台参数”做二次判断,并把**我方的反应**写入到 `RuleParam.resultWeapons` 对应平台的 `components` 中。
|
||||||
|
|
||||||
|
> 你原本已经在用“规则链”处理 `RuleParam`;这里是在 `WarplaneHandler` 内部再次调用一条新的链,因此属于 **责任链嵌套责任链**。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 1. 改动点概览(这个目录配套的改动)
|
||||||
|
|
||||||
|
- **`WeaponModelDTO` 增加字段**
|
||||||
|
- `platformParams: List<String>`
|
||||||
|
- 用于接收平台维度的参数列表(例如对方速度、弹量、距离等)。
|
||||||
|
|
||||||
|
- **`PlatformComponent` 增加字段**
|
||||||
|
- `platformParams: List<String>`
|
||||||
|
- 用于在“组件维度”也能承载同样的参数(如果你希望参数挂在组件上)。
|
||||||
|
|
||||||
|
- **`WarplaneHandler`(第55行 `// TODO` 下方)接入嵌套链**
|
||||||
|
- 将平台参数透传到结果组件 `component1.platformParams`
|
||||||
|
- 优先取 `component.platformParams`
|
||||||
|
- 若组件没传,则取 `dto.platformParams`
|
||||||
|
- 调用 `OpponentParamChain.apply(ruleParam, dto, componentList)`:
|
||||||
|
- 读取 `dto.platformParams` 中的对方参数
|
||||||
|
- 按责任链规则生成“反应组件”
|
||||||
|
- 把反应组件加入当前平台的 `componentList`(最终进入 `RuleParam.resultWeapons`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 2. 对方参数的传参格式约定
|
||||||
|
|
||||||
|
目前解析逻辑位于 `OpponentParamContext`,支持以下分隔符:
|
||||||
|
|
||||||
|
- `key=value`
|
||||||
|
- `key:value`
|
||||||
|
- `key:value`(中文冒号)
|
||||||
|
|
||||||
|
并会从 `value` 中提取**第一个数字**作为判断依据(例如 `200km` 会提取为 `200`)。
|
||||||
|
|
||||||
|
建议前端/调用方传参示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
["speed=200km", "ammo=20", "distance=50km"]
|
||||||
|
```
|
||||||
|
|
||||||
|
目前内置识别的 key:
|
||||||
|
|
||||||
|
- `speed`:速度
|
||||||
|
- `ammo`:弹量
|
||||||
|
- `distance`:距离
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3. 目录结构与职责(类说明)
|
||||||
|
|
||||||
|
- **`OpponentParamChain`**
|
||||||
|
- 责任链的“组装与入口”。
|
||||||
|
- Spring `@Component` + `@PostConstruct`:自动获取容器中的 `AbstractOpponentParamHandler` 实现列表并按顺序串起来。
|
||||||
|
- `apply(ruleParam, dto, resultComponents)`:对外入口,创建上下文并触发链路执行。
|
||||||
|
|
||||||
|
- **`AbstractOpponentParamHandler`**
|
||||||
|
- 对方参数链的抽象 Handler。
|
||||||
|
- 只负责:
|
||||||
|
- `handle(context)`:当前节点处理
|
||||||
|
- `doNext(context)`:传递到下一个节点
|
||||||
|
|
||||||
|
- **`OpponentParamContext`**
|
||||||
|
- 链路执行上下文(把链执行需要的对象集中起来):
|
||||||
|
- `RuleParam ruleParam`:当前规则执行参数
|
||||||
|
- `WeaponModelDTO weaponModelDTO`:当前处理的平台 DTO(承载 `platformParams`)
|
||||||
|
- `List<PlatformComponent> resultComponents`:本平台最终要返回的组件列表(也就是要写入 `resultWeapons` 的列表)
|
||||||
|
- 关键能力:
|
||||||
|
- `getParamLong(key)`:从 `platformParams` 中按 key 取值并解析出数字
|
||||||
|
- `addReactionComponent(component)`:把“反应组件”加入 `resultComponents`(按 name 做简单去重,避免循环里重复加入)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 4. 当前内置的 4 个链节点(最少四个)
|
||||||
|
|
||||||
|
这 4 个节点都实现了 `AbstractOpponentParamHandler`,并通过 `@Order` 控制执行顺序:
|
||||||
|
|
||||||
|
- **`Speed200Handler`(@Order(1))**
|
||||||
|
- 条件:`speed >= 200`
|
||||||
|
- 反应:加入组件
|
||||||
|
- `name = reaction_speed_ge_200`
|
||||||
|
- `type = weapon`
|
||||||
|
- `num = 1`
|
||||||
|
|
||||||
|
- **`Ammo20Handler`(@Order(2))**
|
||||||
|
- 条件:`ammo <= 20`
|
||||||
|
- 反应:加入组件
|
||||||
|
- `name = reaction_ammo_le_20`
|
||||||
|
- `type = weapon`
|
||||||
|
- `num = 1`
|
||||||
|
|
||||||
|
- **`Distance50Handler`(@Order(3))**
|
||||||
|
- 条件:`distance <= 50`
|
||||||
|
- 反应:加入组件
|
||||||
|
- `name = reaction_distance_le_50`
|
||||||
|
- `type = weapon`
|
||||||
|
- `num = 1`
|
||||||
|
|
||||||
|
- **`FallbackHandler`(@Order(4))**
|
||||||
|
- 兜底:无论是否命中其它规则,都加入一个默认反应(便于你观察链是否运行)
|
||||||
|
- 反应:加入组件
|
||||||
|
- `name = reaction_default`
|
||||||
|
- `type = weapon`
|
||||||
|
- `num = 0`
|
||||||
|
|
||||||
|
> 注意:这些“反应组件”目前只是用 `PlatformComponent` 承载并加入到返回的 `components` 列表中,保证**一定能落到 `RuleParam.resultWeapons`**。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5. 如何扩展新规则(你后续要加更多链节点时)
|
||||||
|
|
||||||
|
按照下面步骤即可:
|
||||||
|
|
||||||
|
1. 在本目录新增一个类,继承 `AbstractOpponentParamHandler`
|
||||||
|
2. 加上 `@Component` 与 `@Order(n)`(n 决定执行顺序)
|
||||||
|
3. 在 `handle` 中从 `context.getParamLong("xxx")` 取值判断
|
||||||
|
4. 组装一个 `PlatformComponent` 作为“反应”,调用 `context.addReactionComponent(...)`
|
||||||
|
5. 最后 `doNext(context)` 传递到下一节点
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user