Compare commits

45 Commits

Author SHA1 Message Date
libertyspy
29e17773af UPDATE: VERSION-20260314 2026-03-14 22:35:40 +08:00
libertyspy
db97d8a026 UPDATE: VERSION-20260314 2026-03-14 22:35:31 +08:00
libertyspy
2e55254412 UPDATE: VERSION-20260314 2026-03-14 22:35:21 +08:00
libertyspy
1504c3fc1b UPDATE: VERSION-20260314 2026-03-14 21:37:18 +08:00
libertyspy
0cf4c9b47e UPDATE: VERSION-20260314 2026-03-14 21:37:07 +08:00
libertyspy
fa0c93044c Merge remote-tracking branch 'origin/master' 2026-03-14 20:55:23 +08:00
libertyspy
33a77428db UPDATE: VERSION-20260314 2026-03-14 20:55:15 +08:00
MHW
26a89a66d1 Merge branch 'refs/heads/develop' 2026-03-14 20:47:07 +08:00
MHW
f72105134f 26-03-14-20:46 通过平台id获取平台下所有组件 2026-03-14 20:46:49 +08:00
libertyspy
2198e108a4 UPDATE: VERSION-20260314 2026-03-14 18:08:20 +08:00
libertyspy
fe94cec559 Merge remote-tracking branch 'origin/master' 2026-03-14 17:57:05 +08:00
MHW
af3a97175a Merge branch 'refs/heads/develop' 2026-03-14 14:31:12 +08:00
MHW
c1c67e826b 26-03-14-14:30 规则CRUD 2026-03-14 14:30:52 +08:00
MHW
8a946c4c84 Merge branch 'refs/heads/develop' 2026-03-14 11:18:23 +08:00
MHW
d9a55d0c95 26-03-14-11:17:行为树-保存场景配置 2026-03-14 11:17:55 +08:00
libertyspy
7b578f5d63 UPDATE: VERSION-20260313 2026-03-13 17:05:08 +08:00
MHW
dde470c9da 26-03-13-14:36:火力规则简单实现-删除重复模块 2026-03-13 14:52:29 +08:00
MHW
91adb9517e Merge remote-tracking branch 'origin/master'
# Conflicts:
#	auto-solution-admin/src/main/java/com/solution/web/controller/rule/RuleController.java
#	auto-solution-common/src/main/java/com/solution/common/constant/PlatformAndModuleConstants.java
#	pom.xml
2026-03-13 14:41:41 +08:00
MHW
99c100f2ac 26-03-13-14:36:火力规则简单实现 2026-03-13 14:36:31 +08:00
libertyspy
a2f2cbb185 UPDATE: VERSION-20260313 2026-03-13 10:51:19 +08:00
libertyspy
d96941ea9b UPDATE: VERSION-20260313 2026-03-13 10:45:46 +08:00
libertyspy
5a7b57d603 UPDATE: VERSION-20260313 2026-03-13 10:42:39 +08:00
libertyspy
27f8810401 Initial commit 2026-03-13 10:41:43 +08:00
libertyspy
4980ba2da4 Initial commit 2026-03-13 10:40:44 +08:00
libertyspy
3a086e9405 Initial commit 2026-03-13 10:15:14 +08:00
f2f8892276 Merge branch 'develop' 2026-03-12 16:04:39 +08:00
152a7b59af Merge branch 'liangyun' into develop 2026-03-12 16:04:30 +08:00
MHW
956d3f69ea 火力规则:返回平台以及组件 2026-03-12 16:01:04 +08:00
6fb020355b 配置前端动作分类 2026-03-12 10:16:56 +08:00
libertyspy
8b3fe9b548 UPDATE: fk 2026-02-09 21:05:07 +08:00
libertyspy
db30244cd1 Initial commit 2026-02-09 21:03:57 +08:00
libertyspy
c9bc62fb8c Initial commit 2026-02-09 20:10:24 +08:00
libertyspy
9d54395c29 Initial commit 2026-02-09 20:05:56 +08:00
libertyspy
35fd1c8937 Initial commit 2026-02-09 19:53:17 +08:00
libertyspy
579d0f2bd8 Initial commit 2026-02-09 15:35:20 +08:00
libertyspy
7f8abf2ff2 Initial commit 2026-02-09 15:26:21 +08:00
libertyspy
f1bcd3812d Initial commit 2026-02-09 15:06:04 +08:00
libertyspy
d3fda27bb0 Initial commit 2026-02-09 15:04:34 +08:00
libertyspy
538a43f597 Merge remote-tracking branch 'origin/master' 2026-02-09 14:53:43 +08:00
libertyspy
fcab8585c5 UPDATE: fk 2026-02-09 14:53:05 +08:00
libertyspy
0ffc42ab69 UPDATE: fk 2026-02-09 14:52:56 +08:00
libertyspy
46bead08a0 UPDATE: fk 2026-02-09 14:52:46 +08:00
zouju
e07b11ef95 修改部分规则代码 2026-02-09 11:15:26 +08:00
libertyspy
a78781782e Initial commit 2026-02-08 22:32:50 +08:00
libertyspy
0b55384442 Initial commit 2026-02-08 22:31:13 +08:00
119 changed files with 4894 additions and 381 deletions

View File

@@ -70,6 +70,12 @@
<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>
</dependencies> </dependencies>
<build> <build>

View File

@@ -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;
@@ -37,6 +43,51 @@ 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, "规则数据");

View File

@@ -3,6 +3,8 @@ package com.solution.web.controller.behaviour;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.solution.system.domain.AfsimScenario;
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;
@@ -38,6 +40,9 @@ public class BehaviortreeController extends BaseController
@Autowired @Autowired
private IBehaviortreeService behaviortreeService; private IBehaviortreeService behaviortreeService;
@Autowired
private BehaviortreeProcessor behaviortreeProcessor;
/** /**
* 查询行为树主列表 * 查询行为树主列表
*/ */
@@ -84,7 +89,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 +101,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 +115,16 @@ public class BehaviortreeController extends BaseController
{ {
return toAjax(behaviortreeService.deleteBehaviortreeByIds(ids)); return toAjax(behaviortreeService.deleteBehaviortreeByIds(ids));
} }
/**
* 保存场景配置
*/
@ApiOperation("保存场景配置")
@PostMapping("/saveSceneConfig")
@Log(title = "行为树主", businessType = BusinessType.INSERT)
public AjaxResult saveSceneConfig(@RequestBody AfsimScenario afsimScenario)
{
return toAjax(behaviortreeService.insert(afsimScenario));
}
} }

View File

@@ -103,15 +103,15 @@ 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.setTempleteType(template.getTempleteType()); 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);
}); });

View File

@@ -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;
} }
} }

View File

@@ -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() {

View File

@@ -0,0 +1,72 @@
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.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));
}
@GetMapping("/platforms/{scenarioId}")
@ApiOperation("获取通信组件的所有平台和组件")
public AjaxResult platforms(@PathVariable Integer scenarioId){
return success(ruleService.findPlatformComponents(scenarioId));
}
/**
* 根据平台id获取平台下所有组件
* @param platformId
* @return
*/
@GetMapping("/component/{platformId}")
@ApiOperation("根据平台id获取平台下所有组件")
public AjaxResult getComponents(@PathVariable Integer platformId){
return success(ruleService.getComponents(platformId));
}
}

View File

@@ -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));
}
}

View File

@@ -0,0 +1,174 @@
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 java.util.HashMap;
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()) {
// 插入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 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());
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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,152 @@
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 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 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;
}
}

View File

@@ -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;
}
}

View File

@@ -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:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭

View File

@@ -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:

View File

@@ -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);
}
}

View File

@@ -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();
} }

View File

@@ -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;
}
}

View File

@@ -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>

View File

@@ -0,0 +1,64 @@
package com.solution.system.domain;
/**
* 场景配置表
* 对应表 afsim_scenario
*/
public class AfsimScenario {
private Integer id;
private String name;
private String description;
private String scenarioPath;
private String communicationGraph; // 用于存储场景中的通讯关系
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;
}
public String getScenarioPath() {
return scenarioPath;
}
public void setScenarioPath(String scenarioPath) {
this.scenarioPath = scenarioPath;
}
public String getCommunicationGraph() {
return communicationGraph;
}
public void setCommunicationGraph(String communicationGraph) {
this.communicationGraph = communicationGraph;
}
@Override
public String toString() {
return "AfsimScenario{" +
"id=" + id +
", name='" + name + '\'' +
", description='" + description + '\'' +
", scenarioPath='" + scenarioPath + '\'' +
", communicationGraph='" + communicationGraph + '\'' +
'}';
}
}

View File

@@ -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;

View File

@@ -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;
@@ -40,6 +42,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;

View File

@@ -40,7 +40,7 @@ public class Nodetemplate extends BaseEntity
/** 模版类型节点模版或者条件判断例如“node”precondition“ */ /** 模版类型节点模版或者条件判断例如“node”precondition“ */
@Excel(name = "模版类型节点模版或者条件判断例如“node”precondition“") @Excel(name = "模版类型节点模版或者条件判断例如“node”precondition“")
private String templeteType; private String templateType;
public Nodetemplate() { public Nodetemplate() {
} }
@@ -52,7 +52,7 @@ public class Nodetemplate extends BaseEntity
this.logicHandler = template.logicHandler; this.logicHandler = template.logicHandler;
this.description = template.description; this.description = template.description;
this.englishName = template.englishName; this.englishName = template.englishName;
this.templeteType = template.templeteType; this.templateType = template.templateType;
} }
public void setId(Long id) public void setId(Long id)
@@ -115,14 +115,14 @@ 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;
} }
@Override @Override
@@ -134,7 +134,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();
} }
} }

View File

@@ -1,6 +1,8 @@
package com.solution.system.mapper; package com.solution.system.mapper;
import java.util.List; import java.util.List;
import com.solution.system.domain.AfsimScenario;
import com.solution.system.domain.Behaviortree; import com.solution.system.domain.Behaviortree;
/** /**
@@ -58,4 +60,11 @@ public interface BehaviortreeMapper
* @return 结果 * @return 结果
*/ */
public int deleteBehaviortreeByIds(Long[] ids); public int deleteBehaviortreeByIds(Long[] ids);
/**
* 保存场景配置
* @param afsimScenario
* @return
*/
int insert(AfsimScenario afsimScenario);
} }

View File

@@ -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);
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -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);
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -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);
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -1,7 +1,10 @@
package com.solution.system.service; package com.solution.system.service;
import java.util.List; import java.util.List;
import com.solution.system.domain.AfsimScenario;
import com.solution.system.domain.Behaviortree; import com.solution.system.domain.Behaviortree;
import sun.management.spi.PlatformMBeanProvider;
/** /**
* 行为树主Service接口 * 行为树主Service接口
@@ -58,4 +61,11 @@ public interface IBehaviortreeService
* @return 结果 * @return 结果
*/ */
public int deleteBehaviortreeById(Long id); public int deleteBehaviortreeById(Long id);
/**
* 保存场景配置
* @param afsimScenario
* @return
*/
int insert(AfsimScenario afsimScenario);
} }

View File

@@ -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);
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -11,6 +11,9 @@ import com.solution.system.domain.Nodeparameter;
*/ */
public interface INodeparameterService public interface INodeparameterService
{ {
void deleteByTreeId(Long treeId);
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -11,6 +11,9 @@ import com.solution.system.domain.Treenodeinstance;
*/ */
public interface ITreenodeinstanceService public interface ITreenodeinstanceService
{ {
void deleteByTreeId(Long treeId);
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -1,6 +1,10 @@
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 com.solution.system.domain.AfsimScenario;
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;
@@ -90,4 +94,17 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService
{ {
return behaviortreeMapper.deleteBehaviortreeById(id); return behaviortreeMapper.deleteBehaviortreeById(id);
} }
/**
* 保存场景配置
* @param afsimScenario
* @return
*/
@Override
public int insert(AfsimScenario afsimScenario) {
if(ObjectUtil.isEmpty(afsimScenario) || ObjectUtil.isEmpty(afsimScenario.getCommunicationGraph())){
throw new RuntimeException(ExceptionConstants.SCENE_CONFIG_NOT_NULL);
}
return behaviortreeMapper.insert(afsimScenario);
}
} }

View File

@@ -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);
}
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -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);
}
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -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);
}
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -55,6 +55,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
</insert> </insert>
<insert id="insert" parameterType="com.solution.system.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=",">

View File

@@ -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>

View File

@@ -6,13 +6,18 @@ 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" />
</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 from nodeparameter
</sql> </sql>
<select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult"> <select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult">
@@ -32,11 +37,13 @@ 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>
</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>
@@ -46,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>

View File

@@ -11,7 +11,7 @@ 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" />
</resultMap> </resultMap>
<sql id="selectNodetemplateVo"> <sql id="selectNodetemplateVo">
@@ -26,7 +26,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 +43,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 +51,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 +63,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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -113,6 +113,12 @@
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.25</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -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 = "场景配置不能为空";
}

View File

@@ -0,0 +1,9 @@
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";
}

View File

@@ -0,0 +1,39 @@
<?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>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.solution</groupId>
<artifactId>solution-common</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -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;
}

View File

@@ -0,0 +1,56 @@
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 Platform implements Serializable {
private Integer id;
private String name;
private String description;
private List<PlatformComponent> components;
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;
}
public List<PlatformComponent> getComponents() {
return components;
}
public void setComponents(List<PlatformComponent> components) {
this.components = components;
}
}

View File

@@ -0,0 +1,32 @@
package com.solution.rule.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 平台挂载的组件实体类
* 对应表 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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,22 @@
package com.solution.rule.domain.dto;
import lombok.Data;
/**
* 规则请求参数
*/
@Data
public class RequestDTO {
//编队数量
private Long formationNum;
//武装直升机数量
private Long gunshipNum;
//无人机数量
private Long droneNum;
//单兵武器数量
private Long singleWeaponNum;
}

View File

@@ -0,0 +1,23 @@
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;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,17 @@
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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,80 @@
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.domain.vo.ComponentCountVO;
import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
import org.springframework.stereotype.Component;
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;
@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<>();
//TODO获取所有组件以及count
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());
if(databaseWeapon.getCount() > component.getNum()){
component1.setNum(component.getNum() + COMPONENT_COUNT_INCREMENT);
}else {
component1.setNum(databaseWeapon.getCount());
}
//TODO 补充基本信息 暂未完成
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);
}
}

View File

@@ -0,0 +1,45 @@
package com.solution.rule.mapper;
import com.solution.rule.domain.Platform;
import com.solution.rule.domain.PlatformComponent;
import com.solution.rule.domain.vo.ComponentCountVO;
import com.solution.rule.domain.vo.PlatformComponentNamesVO;
import com.solution.rule.domain.vo.WeaponModelVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface FireRuleMapper {
/**
* 获取所有武器平台和组件
* @return
*/
List<WeaponModelVO> getWeapon();
List<WeaponModelVO> getPlatformComponentNames();
/**
* 获取所有组件以及数量
* @return
*/
List<ComponentCountVO> getModuleAndCount();
/**
* 获取通信组件的所有平台和组件
* @param scenarioId
* @return
*/
List<PlatformComponentNamesVO> getCommPlatformComponentNames(Integer scenarioId);
/**
* 根据平台id获取平台下所有组件
* @param platformId
* @return
*/
List<PlatformComponent> getComponents(Integer platformId);
List<Platform> findPlatformComponents(Integer scenarioId);
}

View File

@@ -0,0 +1,9 @@
package com.solution.rule.mapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ModelDetailMapper {
}

View File

@@ -0,0 +1,38 @@
package com.solution.rule.mapper;
import com.solution.rule.domain.Rule;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface RuleMapper {
/**
* 根据ID查询规则
*/
Rule selectRuleById(Integer id);
/**
* 查询规则列表(支持分页)
*/
List<Rule> selectRuleList(Rule rule);
/**
* 新增规则
*/
int insertRule(Rule rule);
/**
* 修改规则
*/
int updateRule(Rule rule);
/**
* 删除规则
*/
int deleteRuleById(Integer id);
/**
* 批量删除规则
*/
int deleteRuleByIds(@Param("ids")Integer[] ids);
}

View File

@@ -0,0 +1,43 @@
package com.solution.rule.service;
import com.solution.rule.domain.FireRuleExecuteDTO;
import com.solution.rule.domain.Platform;
import com.solution.rule.domain.PlatformComponent;
import com.solution.rule.domain.vo.PlatformComponentNamesVO;
import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
import java.util.List;
public interface FireRuleService {
/**
* 开始执行规则匹配
* @param fireRuleExecuteDTO
* @return
*/
List<PlatformWeaponAggregateVO> execute(FireRuleExecuteDTO fireRuleExecuteDTO);
List<PlatformWeaponAggregateVO> getWeapon();
/**
* 获取所有武器平台和组件
* @return
*/
List<PlatformComponentNamesVO> getPlatformComponentNames();
/**
* 获取通信组件的所有平台和组件
* @param scenarioId
* @return
*/
List<PlatformComponentNamesVO> getCommPlatformComponentNames(Integer scenarioId);
/**
* 根据平台id获取平台下所有组件
* @param platformId
* @return
*/
List<PlatformComponent> getComponents(Integer platformId);
List<Platform> findPlatformComponents(Integer scenarioId);
}

View File

@@ -0,0 +1,36 @@
package com.solution.rule.service;
import com.solution.rule.domain.Rule;
import java.util.List;
public interface IRuleService {
/**
* 根据ID查询规则
*/
Rule selectRuleById(Integer id);
/**
* 查询规则列表
*/
List<Rule> selectRuleList(Rule rule);
/**
* 新增规则
*/
int insertRule(Rule rule);
/**
* 修改规则
*/
int updateRule(Rule rule);
/**
* 删除规则
*/
int deleteRuleById(Integer id);
/**
* 批量删除规则
*/
int deleteRuleByIds(Integer[] ids);
}

View File

@@ -0,0 +1,179 @@
package com.solution.rule.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.solution.common.constant.ExceptionConstants;
import com.solution.rule.domain.FireRuleExecuteDTO;
import com.solution.rule.domain.Platform;
import com.solution.rule.domain.PlatformComponent;
import com.solution.rule.domain.RuleParam;
import com.solution.rule.domain.dto.WeaponModelDTO;
import com.solution.rule.domain.vo.ComponentCountVO;
import com.solution.rule.domain.vo.PlatformComponentNamesVO;
import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
import com.solution.rule.domain.vo.WeaponModelVO;
import com.solution.rule.mapper.FireRuleMapper;
import com.solution.rule.service.FireRuleService;
import com.solution.rule.strategy.SceneStrategy;
import com.solution.rule.strategy.SceneStrategyFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class FireRuleServiceImpl implements FireRuleService {
private static final long COMPONENT_QUANTITY_THRESHOLD = 1;
@Autowired
private SceneStrategyFactory strategyFactory;
@Autowired
private FireRuleMapper ruleMapper;
/* @Override
public WeaponModelVO execute(Integer sceneType, WeaponModelDTO weaponModelDTO) {
if(ObjectUtil.isNull(sceneType) || ObjectUtil.isEmpty(weaponModelDTO)){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
//TODO 查数据库获取我方装备
List<PlatformWeaponAggregateVO> weapon = this.getWeapon();
SceneStrategy strategy = strategyFactory.getStrategy(sceneType);
WeaponModelVO result = strategy.execute(weaponModelDTO);
if(ObjectUtil.isEmpty(result)){
throw new RuntimeException(ExceptionConstants.RESULT_EXCEPTION);
}
return result;
}*/
@Override
public List<PlatformWeaponAggregateVO> execute(FireRuleExecuteDTO fireRuleExecuteDTO) {
if(ObjectUtil.isEmpty(fireRuleExecuteDTO)){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
List<WeaponModelDTO> weaponModelDTOs = fireRuleExecuteDTO.getWeaponModelDTOs();
Integer sceneType = fireRuleExecuteDTO.getSceneType();
// 查数据库获取我方装备
List<ComponentCountVO> weapon = this.getModuleAndCount();
// 创建RuleParam并设置数据
RuleParam ruleParam = new RuleParam();
ruleParam.setWeaponModelDTOList(weaponModelDTOs);
ruleParam.setDatabaseWeapons(weapon);
// 执行策略
SceneStrategy strategy = strategyFactory.getStrategy(sceneType);
List<PlatformWeaponAggregateVO> result = strategy.execute(ruleParam);
return result;
}
@Override
public List<PlatformWeaponAggregateVO> getWeapon() {
List<WeaponModelVO> flatList = ruleMapper.getWeapon();
if (CollUtil.isEmpty(flatList)) {
throw new RuntimeException(ExceptionConstants.RESULT_EXCEPTION);
}
Map<String, List<WeaponModelVO>> groupByPlatform = flatList.stream()
.collect(Collectors.groupingBy(WeaponModelVO::getPlatformName));
List<PlatformWeaponAggregateVO> result = new ArrayList<>();
for (Map.Entry<String, List<WeaponModelVO>> entry : groupByPlatform.entrySet()) {
PlatformWeaponAggregateVO platformVO = new PlatformWeaponAggregateVO();
platformVO.setPlatformName(entry.getKey());
List<ComponentCountVO> components = entry.getValue().stream()
.map(item -> {
ComponentCountVO comp = new ComponentCountVO();
comp.setComponentName(item.getComponentName());
comp.setCount(item.getCount());
return comp;
})
.collect(Collectors.toList());
platformVO.setComponentCountVOS(components);
result.add(platformVO);
}
return result;
}
/**
* 获取所有武器平台和组件
* @return
*/
@Override
public List<PlatformComponentNamesVO> getPlatformComponentNames() {
List<WeaponModelVO> flatList = ruleMapper.getPlatformComponentNames();
if (CollUtil.isEmpty(flatList)) {
throw new RuntimeException(ExceptionConstants.RESULT_EXCEPTION);
}
Map<String, List<String>> groupByPlatform = flatList.stream()
.collect(Collectors.groupingBy(
WeaponModelVO::getPlatformName,
Collectors.mapping(WeaponModelVO::getComponentName, Collectors.toList())
));
return groupByPlatform.entrySet().stream()
.map(entry -> {
PlatformComponentNamesVO vo = new PlatformComponentNamesVO();
vo.setPlatformName(entry.getKey());
vo.setComponentNames(entry.getValue());
return vo;
})
.collect(Collectors.toList());
}
/**
* 获取通信组件的所有平台和组件
* @param scenarioId
* @return
*/
@Override
public List<PlatformComponentNamesVO> getCommPlatformComponentNames(Integer scenarioId) {
return ruleMapper.getCommPlatformComponentNames(scenarioId);
}
/**
* 根据平台id获取平台下所有组件
* @param platformId
* @return
*/
@Override
public List<PlatformComponent> getComponents(Integer platformId) {
return ruleMapper.getComponents(platformId);
}
/**
* 获取所有组件以及数量
* @return
*/
private List<ComponentCountVO> getModuleAndCount(){
List<ComponentCountVO> componentCountVOS = ruleMapper.getModuleAndCount();
if(CollUtil.isEmpty(componentCountVOS)){
return new ArrayList<>();
}
return componentCountVOS;
}
@Override
public List<Platform> findPlatformComponents(Integer scenarioId) {
List<Platform> platforms = ruleMapper.findPlatformComponents(scenarioId);
if(!CollUtil.isEmpty(platforms)){
return platforms;
}
return new ArrayList<>();
}
}

View File

@@ -0,0 +1,46 @@
package com.solution.rule.service.impl;
import com.solution.rule.domain.Rule;
import com.solution.rule.mapper.RuleMapper;
import com.solution.rule.service.IRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class RuleServiceImpl implements IRuleService {
@Autowired
private RuleMapper ruleMapper;
@Override
public Rule selectRuleById(Integer id) {
return ruleMapper.selectRuleById(id);
}
@Override
public List<Rule> selectRuleList(Rule rule) {
return ruleMapper.selectRuleList(rule);
}
@Override
public int insertRule(Rule rule) {
return ruleMapper.insertRule(rule);
}
@Override
public int updateRule(Rule rule) {
return ruleMapper.updateRule(rule);
}
@Override
public int deleteRuleById(Integer id) {
return ruleMapper.deleteRuleById(id);
}
@Override
public int deleteRuleByIds(Integer[] ids) {
return ruleMapper.deleteRuleByIds(ids);
}
}

View File

@@ -0,0 +1,44 @@
package com.solution.rule.strategy;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.solution.common.constant.ExceptionConstants;
import com.solution.rule.domain.RuleParam;
import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
import com.solution.rule.enums.SceneType;
import com.solution.rule.handler.RuleChainHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class AirborneStrategy implements SceneStrategy{
@Autowired
private RuleChainHandler ruleChainHandler;
/**
* 空降场景处理
* @param ruleParam
* @return
*/
@Override
public List<PlatformWeaponAggregateVO> execute(RuleParam ruleParam) {
if(ObjectUtil.isEmpty(ruleParam) || CollUtil.isEmpty(ruleParam.getWeaponModelDTOList())){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
ruleParam = ruleChainHandler.findRuleParam(ruleParam);
return ruleParam.getResultWeapons();
}
@Override
public SceneType getSceneType() {
return SceneType.AIRBORNE;
}
}

View File

@@ -0,0 +1,44 @@
package com.solution.rule.strategy;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.solution.common.constant.ExceptionConstants;
import com.solution.rule.domain.RuleParam;
import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
import com.solution.rule.enums.SceneType;
import com.solution.rule.handler.RuleChainHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class DefenseStrategy implements SceneStrategy{
@Autowired
private RuleChainHandler ruleChainHandler;
/**
* 防御场景处理
* @param
* @return
*/
@Override
public List<PlatformWeaponAggregateVO> execute(RuleParam ruleParam) {
if(ObjectUtil.isEmpty(ruleParam) || CollUtil.isEmpty(ruleParam.getWeaponModelDTOList())){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
ruleParam = ruleChainHandler.findRuleParam(ruleParam);
return ruleParam.getResultWeapons();
}
@Override
public SceneType getSceneType() {
return SceneType.DEFENSE;
}
}

View File

@@ -0,0 +1,15 @@
package com.solution.rule.strategy;
import com.solution.rule.domain.RuleParam;
import com.solution.rule.domain.vo.PlatformWeaponAggregateVO;
import com.solution.rule.enums.SceneType;
import java.util.HashMap;
import java.util.List;
public interface SceneStrategy {
List<PlatformWeaponAggregateVO> execute(RuleParam ruleParam);
SceneType getSceneType();
}

View File

@@ -0,0 +1,45 @@
package com.solution.rule.strategy;
import com.solution.rule.enums.SceneType;
import com.solution.rule.strategy.SceneStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
@Component
public class SceneStrategyFactory {
@Autowired
private List<SceneStrategy> strategyList;
private final Map<SceneType, SceneStrategy> strategyMap = new EnumMap<>(SceneType.class);
@PostConstruct
public void init() {
for (SceneStrategy strategy : strategyList) {
SceneType type = strategy.getSceneType();
if (strategyMap.containsKey(type)) {
throw new IllegalStateException("重复的场景类型: " + type);
}
strategyMap.put(type, strategy);
}
}
/**
* 根据前端传递的数字编码获取对应的策略
* @param code 前端传递的数字
* @return 策略实现
* @throws IllegalArgumentException 如果编码无效或策略未注册
*/
public SceneStrategy getStrategy(int code) {
SceneType type = SceneType.fromCode(code);
SceneStrategy strategy = strategyMap.get(type);
if (strategy == null) {
throw new IllegalArgumentException("未找到编码 " + code + " 对应的策略实现");
}
return strategy;
}
}

View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.solution.rule.mapper.FireRuleMapper">
<resultMap id="platformComponentCountMap" type="com.solution.rule.domain.vo.WeaponModelVO">
<result property="platformName" column="platform_name"/>
<result property="componentName" column="component_name"/>
<result property="count" column="count"/>
</resultMap>
<resultMap id="PlatformComponentNamesVOResultMap" type="com.solution.rule.domain.vo.PlatformComponentNamesVO">
<result property="platformName" column="platformName"/>
<collection property="componentNames" ofType="java.lang.String">
<result column="componentName"/>
</collection>
</resultMap>
<select id="getWeapon" resultMap="platformComponentCountMap">
SELECT
p.name AS platform_name,
pc.name AS component_name,
COUNT(pc.name) AS count
FROM platform p
LEFT JOIN platform_component pc ON p.id = pc.platform_id
GROUP BY p.id, p.name, pc.name
ORDER BY p.id, pc.name
</select>
<select id="getPlatformComponentNames" resultType="com.solution.rule.domain.vo.WeaponModelVO">
SELECT DISTINCT
p.name AS platformName,
pc.name AS componentName
FROM platform p
INNER JOIN platform_component pc ON p.id = pc.platform_id
WHERE pc.name IS NOT NULL
ORDER BY p.name, pc.name
</select>
<select id="getModuleAndCount" resultType="com.solution.rule.domain.vo.ComponentCountVO">
SELECT
name AS componentName,
COUNT(*) AS count
FROM platform_component
WHERE name IS NOT NULL
GROUP BY name
ORDER BY count DESC;
</select>
<select id="getCommPlatformComponentNames" resultMap="PlatformComponentNamesVOResultMap"
parameterType="java.lang.Integer">
SELECT
p.name AS platformName,
pc.name AS componentName
FROM platform p
INNER JOIN platform_component pc ON p.id = pc.platform_id
WHERE pc.type = "comm"
AND p.scenario_id = #{scenarioId}
</select>
<select id="getComponents" resultType="com.solution.rule.domain.PlatformComponent"
parameterType="java.lang.Integer">
SELECT id,name,type,description,platform_id
FROM platform_component
WHERE platform_id = #{platformId}
</select>
<resultMap id="VPlatformComponentMap" type="com.solution.rule.domain.PlatformComponent">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="description" column="description"/>
<result property="platformId" column="platform_id"/>
<result property="num" column="num"/>
</resultMap>
<select id="findComponentsByPlatformId" resultMap="VPlatformComponentMap">
SELECT * FROM platform_component
WHERE platform_id=#{platformId}
</select>
<resultMap id="VPlatformMap" type="com.solution.rule.domain.Platform">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="description" column="description"/>
<collection property="components"
ofType="com.solution.rule.domain.PlatformComponent"
column="id"
select="findComponentsByPlatformId"/>
</resultMap>
<select id="findPlatformComponents" resultMap="VPlatformMap"
parameterType="java.lang.Integer">
SELECT
p.*,
pc.*
FROM platform p
LEFT JOIN platform_component pc ON p.id = pc.platform_id
WHERE pc.type = "comm"
AND p.scenario_id = #{scenarioId}
GROUP BY p.id;
</select>
</mapper>

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.solution.rule.mapper.RuleMapper">
<resultMap id="RuleResult" type="com.solution.rule.domain.Rule">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="sceneType" column="scene_type"/>
<result property="conditions" column="conditions"/>
<result property="actions" column="actions"/>
<result property="priority" column="priority"/>
<result property="enabled" column="enabled"/>
<result property="createdTime" column="created_time"/>
<result property="updatedTime" column="updated_time"/>
</resultMap>
<sql id="selectRuleVo">
select id, name, scene_type, conditions, actions, priority, enabled, created_time, updated_time
from rule
</sql>
<select id="selectRuleById" parameterType="Integer" resultMap="RuleResult">
<include refid="selectRuleVo"/>
where id = #{id}
</select>
<select id="selectRuleList" parameterType="com.solution.rule.domain.Rule" resultMap="RuleResult">
<include refid="selectRuleVo"/>
<where>
<if test="name != null and name != ''">
AND name like concat('%', #{name}, '%')
</if>
<if test="sceneType != null">
AND scene_type = #{sceneType}
</if>
<if test="enabled != null">
AND enabled = #{enabled}
</if>
</where>
</select>
<insert id="insertRule" parameterType="com.solution.rule.domain.Rule" useGeneratedKeys="true" keyProperty="id">
insert into rule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="sceneType != null">scene_type,</if>
<if test="conditions != null">conditions,</if>
<if test="actions != null">actions,</if>
<if test="priority != null">priority,</if>
<if test="enabled != null">enabled,</if>
created_time,
updated_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="sceneType != null">#{sceneType},</if>
<if test="conditions != null">#{conditions},</if>
<if test="actions != null">#{actions},</if>
<if test="priority != null">#{priority},</if>
<if test="enabled != null">#{enabled},</if>
now(),
now()
</trim>
</insert>
<update id="updateRule" parameterType="com.solution.rule.domain.Rule">
update rule
<set>
<if test="name != null and name != ''">name = #{name},</if>
<if test="sceneType != null">scene_type = #{sceneType},</if>
<if test="conditions != null">conditions = #{conditions},</if>
<if test="actions != null">actions = #{actions},</if>
<if test="priority != null">priority = #{priority},</if>
<if test="enabled != null">enabled = #{enabled},</if>
updated_time = now()
</set>
where id = #{id}
</update>
<delete id="deleteRuleById" parameterType="Integer">
delete from rule where id = #{id}
</delete>
<!--<delete id="deleteRuleByIds" parameterType="String">
delete from rule where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>-->
<delete id="deleteRuleByIds">
delete from rule where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1773366372468" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="13681" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M752.5888 714.0864a81.3568 81.3568 0 0 0-18.944 2.2016l-50.688-77.9776a160.3072 160.3072 0 0 0-13.3632-245.76l42.0352-82.9952a76.1856 76.1856 0 0 0 10.24 0.6656 81.92 81.92 0 1 0-59.2896-25.6L620.544 367.616a160.4608 160.4608 0 0 0-206.08 134.4l-93.2864 5.12a81.92 81.92 0 1 0 2.9184 54.8864l93.2864-5.12a160.4608 160.4608 0 0 0 219.4432 111.5136l50.688 77.8752a81.92 81.92 0 1 0 65.0752-32.1536z" fill="#ffffff" p-id="13682"></path></svg>

After

Width:  |  Height:  |  Size: 773 B

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1773366567190" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18046" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M303.146667 648.96A128.042667 128.042667 0 1 1 213.333333 647.253333V376.746667a128.042667 128.042667 0 1 1 85.333334 0V512c35.669333-26.794667 79.957333-42.666667 128-42.666667h170.666666a128.042667 128.042667 0 0 0 123.52-94.293333 128.042667 128.042667 0 1 1 86.698667 2.730667A213.418667 213.418667 0 0 1 597.333333 554.666667h-170.666666a128.042667 128.042667 0 0 0-123.52 94.293333zM256 725.333333a42.666667 42.666667 0 1 0 0 85.333334 42.666667 42.666667 0 0 0 0-85.333334zM256 213.333333a42.666667 42.666667 0 1 0 0 85.333334 42.666667 42.666667 0 0 0 0-85.333334z m512 0a42.666667 42.666667 0 1 0 0 85.333334 42.666667 42.666667 0 0 0 0-85.333334z" fill="#ffffff" p-id="18047"></path></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1773366469175" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="14793" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M298.666667 768h298.666666v-128a85.333333 85.333333 0 0 1 85.333334-85.333333h128V256a85.333333 85.333333 0 0 1-85.333334-85.333333h-298.666666v128a85.333333 85.333333 0 0 1-85.333334 85.333333H85.333333a85.333333 85.333333 0 0 1-85.333333-85.333333V128a85.333333 85.333333 0 0 1 85.333333-85.333333h256a85.333333 85.333333 0 0 1 85.333334 85.333333h310.101333A85.333333 85.333333 0 1 1 853.333333 244.565333V554.666667h85.333334a85.333333 85.333333 0 0 1 85.333333 85.333333v170.666667a85.333333 85.333333 0 0 1-85.333333 85.333333h-256a85.333333 85.333333 0 0 1-85.333334-85.333333H287.232A85.333333 85.333333 0 1 1 170.666667 694.101333V469.333333H106.666667a21.333333 21.333333 0 1 1 0-42.666666h213.333333a21.333333 21.333333 0 1 1 0 42.666666H213.333333v213.333334a85.333333 85.333333 0 0 1 85.333334 85.333333zM85.333333 85.333333a42.666667 42.666667 0 0 0-42.666666 42.666667v170.666667a42.666667 42.666667 0 0 0 42.666666 42.666666h256a42.666667 42.666667 0 0 0 42.666667-42.666666V128a42.666667 42.666667 0 0 0-42.666667-42.666667H85.333333z m597.333334 512a42.666667 42.666667 0 0 0-42.666667 42.666667v170.666667a42.666667 42.666667 0 0 0 42.666667 42.666666h256a42.666667 42.666667 0 0 0 42.666666-42.666666v-170.666667a42.666667 42.666667 0 0 0-42.666666-42.666667h-256z m21.333333 341.333334h213.333333a21.333333 21.333333 0 1 1 0 42.666666h-213.333333a21.333333 21.333333 0 1 1 0-42.666666zM810.666667 213.333333a42.666667 42.666667 0 1 0 0-85.333333 42.666667 42.666667 0 0 0 0 85.333333zM213.333333 810.666667a42.666667 42.666667 0 1 0 0-85.333334 42.666667 42.666667 0 0 0 0 85.333334z" fill="#e6e6e6" fill-opacity=".85" p-id="14794"></path></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1773366535929" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16891" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M535.104 719.168l-0.064-416.256c0-19.84-10.368-23.488-23.104-23.488-12.736 0-23.104 3.584-23.04 23.488v416.256c0 19.968 10.304 25.344 23.104 25.536 12.672-0.128 23.04-5.568 23.104-25.536z" p-id="16892" fill="#ffffff"></path><path d="M304.768 535.104l416.256-0.064c20.032 0.192 23.488-10.304 23.488-22.976 0-12.928-3.648-23.232-23.488-23.232h-416.256c-20.032 0-25.536 10.368-25.344 23.104 0 12.8 5.312 23.168 25.344 23.168z" p-id="16893" fill="#ffffff"></path><path d="M999.104 467.776l-442.88-442.88a63.68 63.68 0 0 0-90.112 0l-441.216 441.344a63.616 63.616 0 0 0 0 90.048l443.008 442.88a63.744 63.744 0 0 0 90.048 0l441.216-441.216a63.808 63.808 0 0 0-0.064-90.176z m-446.08 466.304a56.96 56.96 0 0 1-80.512 0l-382.592-382.592a56.832 56.832 0 0 1 0-80.384l380.928-381.12a57.088 57.088 0 0 1 80.576-0.064l382.72 382.784a56.832 56.832 0 0 1-0.064 80.32l-381.056 381.056z" fill="#ffffff" p-id="16894"></path></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1773366601535" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="19126" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M513.6 417.1c41.5-23 83.2-45.6 124.6-69 14.6-8.3 26.5-7.4 38.8 4.6 17.4 16.9 37.6 29.7 60.5 38.1 112.8 41.2 235.6-54.1 223.7-173.5-9.9-99-99.7-169.2-196.2-153.4C673 79 611.4 167.2 627.7 260.7c4.4 25.4 3.1 28.1-19.6 40.6-39.2 21.7-78.4 43.3-117.6 64.9-21.2 11.7-26.3 10.9-42.7-6.8-62.5-67.5-159.4-89.9-245-56.6-84.6 32.9-140.4 115-140.4 206.6 0 101.9 67.3 190.5 165.9 215.2 78.8 19.8 148.8 0.2 209-54.1 11.1-10 21.1-15.5 35.3-6.2 46.8 30.8 93.8 61.2 140.7 91.7 13.8 9 18.4 21.2 15.1 37.1-2.7 13-4.7 26.3-3.4 39.7 7.5 80.1 72.3 134.5 154.6 127.5 52.4-4.5 92-31.5 113.3-79.7 20.9-47.3 19-95.1-11.7-138.4-45.3-63.9-124.9-80.1-190.9-37.5-21.6 13.9-36.9 12.8-57.2-1.5-41.8-29.5-85.2-56.8-128.5-84.1-14.3-9-18-18.6-11.7-34.4 17-43 18.8-87.1 6.1-131.7-6.4-21.6-4.7-25.2 14.6-35.9z m280.1-298c62.4 0.5 111.6 50.1 111.5 112.2-0.1 62.5-49.2 111.4-111.9 111.4-63.2 0.1-113-49.7-112.6-112.6 0.4-61.6 51.2-111.5 113-111z m-28.1 618.6c46 0.8 84.7 40.2 84 85.6-0.7 45.1-39.6 82.8-85 82.4-46.5-0.4-84.5-39-83.8-85.1 0.7-44.9 40.4-83.7 84.8-82.9z" fill="#ffffff" p-id="19127"></path></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1773366502709" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="15837" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M0 0h1024v1024H0z" fill="#ffffff" fill-opacity="0" p-id="15838"></path><path d="M512 64a448 448 0 1 1 0 896A448 448 0 0 1 512 64z m0 64a384 384 0 1 0 0 768A384 384 0 0 0 512 128zM416.768 320c17.28 0 31.232 14.208 31.232 31.744v384.512a31.488 31.488 0 0 1-31.232 31.744 31.488 31.488 0 0 1-31.296-31.744l-0.064-311.04-76.032 77.12a30.912 30.912 0 0 1-44.16 0 32 32 0 0 1 0-44.8l126.272-128.256a30.976 30.976 0 0 1 19.136-9.152L416.768 320z m342.08 310.272l-127.36 128.192-2.56 2.304-3.008 2.176-4.8 2.56-5.44 1.728-5.376 0.768h-4.608l-5.504-0.96-4.288-1.408-4.8-2.432-2.24-1.536-3.648-3.2-3.008-3.392-3.072-5.12-1.92-5.184-0.64-2.752L576 738.368 576 351.744A32 32 0 0 1 608.32 320a32 32 0 0 1 32.32 31.744v306.56l71.872-72.32a32.768 32.768 0 0 1 45.76-0.576 31.36 31.36 0 0 1 0.576 44.864z" fill="#ffffff" p-id="15839"></path></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1773309534522" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11546" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M512 939.52c-14.848 0-28.672-5.632-38.912-15.872l-372.224-372.224c-21.504-21.504-21.504-56.32 0-77.824l372.224-372.224c10.24-10.24 24.064-15.872 38.912-15.872 14.848 0 28.672 5.632 38.912 15.872l372.224 372.224c21.504 21.504 21.504 56.32 0 77.824l-372.224 372.224c-10.24 9.728-24.064 15.872-38.912 15.872z m0-845.312c-12.288 0-23.552 4.608-32.256 13.312L107.52 479.744c-17.92 17.92-17.92 46.592 0 64L479.744 916.48c8.704 8.704 19.968 13.312 32.256 13.312s23.552-4.608 32.256-13.312l372.224-372.224c17.92-17.92 17.92-46.592 0-64L544.256 107.52c-8.704-8.704-19.968-13.312-32.256-13.312z" fill="#EEE" p-id="11547"></path></svg>

After

Width:  |  Height:  |  Size: 958 B

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1769565073187" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3675" width="200" height="200"> <svg t="1769565073187" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3675" width="200" height="200">
<path d="M514.048 128q79.872 0 149.504 30.208t121.856 82.432 82.432 122.368 30.208 150.016q0 78.848-30.208 148.48t-82.432 121.856-121.856 82.432-149.504 30.208-149.504-30.208-121.856-82.432-82.432-121.856-30.208-148.48q0-79.872 30.208-150.016t82.432-122.368 121.856-82.432 149.504-30.208z" <path d="M514.048 128q79.872 0 149.504 30.208t121.856 82.432 82.432 122.368 30.208 150.016q0 78.848-30.208 148.48t-82.432 121.856-121.856 82.432-149.504 30.208-149.504-30.208-121.856-82.432-82.432-121.856-30.208-148.48q0-79.872 30.208-150.016t82.432-122.368 121.856-82.432 149.504-30.208z"
p-id="3676" fill="#5da0df"></path> p-id="3676" fill="#3c82f6"></path>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 624 B

After

Width:  |  Height:  |  Size: 624 B

View File

@@ -32,6 +32,30 @@ export const routes: RouteRecordRaw[] = [
meta: { meta: {
title: '决策树', title: '决策树',
}, },
component: () => import('@/views/decision/designer.vue'), component: () => import('@/views/decision/designer/designer.vue'),
},
{
name: 'decision-communication',
path: '/app/decision/communication',
meta: {
title: '通信',
},
component: () => import('@/views/decision/communication/communication.vue'),
},
{
name: 'decision-algorithm-management',
path: '/app/decision/algorithm/management',
meta: {
title: '指挥决策规则库管理',
},
component: () => import('@/views/decision/algorithm/management.vue'),
},
{
name: 'decision-fire-rule',
path: '/app/decision/fire-rule',
meta: {
title: '活力规则',
},
component: () => import('@/views/decision/rule/management.vue'),
}, },
] ]

View File

@@ -270,20 +270,68 @@
border-radius: 0; border-radius: 0;
min-height: calc(100vh - 90px); min-height: calc(100vh - 90px);
background: transparent; background: transparent;
background: url('@/assets/icons/bg-fk.png') center / 100% 100%;
.ant-tabs .ant-tabs-ink-bar {
position: absolute;
background: transparent;
pointer-events: none;
}
.ant-steps-horizontal{
&.ant-steps.ant-steps-navigation .ant-steps-item.ant-steps-item-active::before {
width: 30%;
margin-left: 37%;
display: none;
}
.ant-steps-item-active{
.ant-steps-item-container{
&:after{
height: 1px;
content: '';
position: absolute;
bottom: 0;
background: #377ead;
display: block;
width: 100px;
}
}
}
}
.ant-card-head { .ant-card-head {
border: 0; border: 0;
color: #11aed7; color: #a2b1ba;
} }
& > .ant-card-head { & > .ant-card-head {
height: 50px; height: 40px;
min-height: 40px; min-height: 40px;
font-size: 16px; border-radius: 0;
padding: 5px 10px;
} }
& > .ant-card-head { & > .ant-card-head {
background: url('@/assets/icons/page-card-head.png') center / 100% 100%; background: url('@/assets/icons/page-card-head.png') center / 100% 100%;
background: url('@/assets/icons/bg-fk-title.png') center / 100% 100%;
color: #eee;
.point {
background: url('@/assets/icons/bg-fk-point.png') center / 100% 100%;
width: 25px;
height: 25px;
display: block;
margin-top: 5px;
}
.text {
margin-top: 5px;
display: block;
font-size: 16px;
}
} }
& > .ant-card-body { & > .ant-card-body {
@@ -979,6 +1027,8 @@
border-right: 1px solid #062850; border-right: 1px solid #062850;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
background: #081229;
} }
} }
@@ -1154,7 +1204,7 @@
.ant-tabs-content { .ant-tabs-content {
//padding: 15px; //padding: 15px;
padding: 4px; padding: 4px;
background: #041b36db; background: #041832;
} }
&.settings-tab, &.settings-tab,
@@ -1320,11 +1370,6 @@
} }
} }
.ant-btn-default {
background: #7dd3f9;
border-color: #7dd3f9;
color: #000;
}
.btn-field { .btn-field {
min-width: 120px; min-width: 120px;
@@ -1486,3 +1531,300 @@
.ant-divider { .ant-divider {
border-block-start: 1px solid rgb(255 255 255 / 17%); border-block-start: 1px solid rgb(255 255 255 / 17%);
} }
.ant-pagination {
position: absolute;
bottom: 10px;
width: 100%;
.ant-pagination-disabled .ant-pagination-item-link,
.ant-pagination-disabled:hover .ant-pagination-item-link,
.ant-pagination-prev .ant-pagination-item-link,
.ant-pagination-next .ant-pagination-item-link,
&.ant-pagination-mini .ant-pagination-total-text,
&.ant-pagination-mini .ant-pagination-simple-pager {
color: rgb(255 255 255 / 95%);
}
&.ant-pagination-simple .ant-pagination-simple-pager input {
background-color: transparent;
border: 1px solid #0f4a7c;
color: #eee;
}
}
.ant-empty-small {
margin-block: 8px;
color: rgb(207 207 207 / 66%);
}
.ant-btn >span {
display: inline-block;
float: inherit;
}
.ant-btn,
.ant-input {
border-radius: 2px;
}
.ant-btn-primary {
color: #eee;
//border-color: #1b5b7d;
//background: linear-gradient(90deg, #1e4c65 0%, #0b3a62 100%);
border-color: #29759c;
background: linear-gradient(0deg, #0f374c 0, #154c69 100%);
&.selected,
&:not(:disabled):hover,
&:hover,
&:active {
border-color: #166094;
background: linear-gradient(90deg, #3687bc 0%, #074375 100%);
color: #fff;
}
}
.ant-btn-default {
&.ant-btn-dangerous{
background: transparent!important;
}
color: #eee;
//border-color: #144087;
//background: linear-gradient(90deg, #0f4a7c 0%, #0a365b 100%);
border-color: #1c468b;
background: linear-gradient(0deg, #14223b 0, #1c468b 100%);
&.selected,
&:not(:disabled):hover,
&:hover,
&:active {
color: #fff;
border-color: #166094;
background: linear-gradient(90deg, #3687bc 0%, #074375 100%);
}
&:disabled,
&.disabled{
color: #a9a3a3;
&:hover{
color:#eee;
}
}
}
.btn-field {
min-width: 120px;
background: #5796b2;
text-align: center;
cursor: pointer;
border-radius: 2px;
color: #fff;
padding: 5px;
border: 1px solid #5796b2;
.anticon {
margin-left: 10px;
}
&:hover,
&.selected {
background: #19b0ff;
border-color: #19b0ff;
}
&.gold {
background: transparent;
border-color: #b5b39d;
color: #b5b39d;
cursor: pointer;
}
}
.ant-input-group-addon {
.anticon{
color: #eeeeee;
}
}
.ant-switch {
background: rgb(8 30 59);
}
.ks-algorithm-card {
.ant-card-head-title {
span.text {
display: block;
line-height: 30px;
}
}
}
.ks-sidebar-header {
line-height: 40px;
background: #081d36;
min-height: 40px;
background: url(@/assets/icons/card-head.png) left / 180% 100%;
padding: 0 10px;
.ks-sidebar-title {
color: #7ae8fc;
font-size: 16px;
.icon {
background: url(@/assets/icons/list.png) center / 100% 100%;
width: 25px;
height: 25px;
display: block;
margin-top: 7px;
}
.text{
margin-left: 40px;
font-size: 16px;
color: #eee;
}
}
.ks-sidebar-add {
position: absolute;
right: 7px;
top: 8px;
font-size: 12px;
.anticon {
display: block;
float: left;
line-height: 16px;
}
}
}
.ant-list {
&.ks-sidebar-list {
.ant-list-item {
cursor: pointer;
transition: all 0.5s;
border-left: 2px solid transparent;
position: relative;
&.selected,
&:hover {
background: #0a1b3c;
border-left: 2px solid #11377e;
}
}
.ks-sidebar-list-type {
position: absolute;
right: 10px;
.ant-badge {
.ant-badge-count {
color: #c3c2c2;
background: #333f7d;
box-shadow: 0 0 0 1px #325478;
}
}
}
.ant-list-item-meta {
.ant-list-item-meta-title {
color: #7ae8fc;
}
.ant-list-item-meta-description {
color: #4d8c98;
font-size: 13px;
}
}
}
}
.ks-sidebar-list-param-list {
padding: 15px;
border: 1px solid #475f71;
border-radius: 2px;
.ks-sidebar-list-param-item {
margin-bottom: 15px;
&:last-child {
margin-bottom: 0;
}
}
}
.ks-sidebar-list-param-actions {
.anticon {
color: #7ae8fc;
font-size: 20px;
display: block;
line-height: 26px;
cursor: pointer;
}
}
.ant-collapse {
.ant-list-sm {
.ant-list-item {
padding: 4px 15px;
cursor: pointer;
color: rgb(130 196 233);
position: relative;
.ks-tree-actions {
position: absolute;
right: 10px;
display: none;
}
&:hover {
background: #0d2d4e;
.ks-tree-actions {
display: block;
}
}
}
}
&.ks-trees-collapse {
.ant-collapse-content-box {
padding: 0;
height: 40vh;
position: relative;
}
}
}
.create-tree-icon {
cursor: pointer;
}
.ant-list-item {
padding: 3px 5px;
cursor: pointer;
color: rgb(130 196 233);
&:hover {
background: #0d2d4e;
}
}
.ks-model-builder-body .ks-model-builder-left .ant-collapse {
&.platform-collapse{
.ant-collapse-content-box{
max-height: 45.5vh;
}
}
}

View File

@@ -0,0 +1,36 @@
/*
* 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 { HttpRequestClient } from '@/utils/request';
import type { Algorithm, AlgorithmPageableResponse, AlgorithmRequest } from './types';
import type { BasicResponse } from '@/types';
const req = HttpRequestClient.create<BasicResponse>({
baseURL: '/api',
});
export const findAlgorithmsByQuery = (query: Partial<AlgorithmRequest> = {}): Promise<AlgorithmPageableResponse> => {
return req.get('/algo/algorithm/list', query);
};
export const createAlgorithm = (algorithm: Algorithm): Promise<BasicResponse> => {
return req.postJson('/algo/algorithm', algorithm);
};
export const runAlgorithm = (algorithm: Algorithm): Promise<BasicResponse> => {
return req.postJson('/algo/algorithm/run', algorithm);
};
export const updateAlgorithm = (algorithm: Algorithm): Promise<BasicResponse> => {
return req.putJson('/algo/algorithm', algorithm);
};
export const deleteAlgorithm = (id: number): Promise<BasicResponse> => {
return req.delete(`/algo/algorithm/${id}`);
};

View File

@@ -0,0 +1,42 @@
/*
* 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.
*/
export const algorithmTypes = [
{
type: 'defense',
name: '防守',
},
{
type: 'offense',
name: '进攻',
},
{
type: 'formation',
name: '队形',
}
]
export const algorithmConfigOperations = [
{
type: '+',
name: '加',
},
{
type: '-',
name: '减',
},
{
type: '*',
name: '乘',
},
{
type: '/',
name: '除',
},
]

View File

@@ -0,0 +1,397 @@
<template>
<Layout>
<template #sidebar>
<div class="ks-sidebar-header">
<a-flex class="ks-sidebar-title">
<span class="icon"></span>
<span class="text">指挥决策规则库管理</span>
</a-flex>
<a-button class="ks-sidebar-add" size="small" @click="handleCreate">
<PlusOutlined />
新增
</a-button>
</div>
<a-list item-layout="horizontal" :data-source="algorithms" class="ks-sidebar-list">
<template #renderItem="{ item }">
<a-list-item @click="()=> handleSelect(item)" :class="selectedAlgorithm?.id === item.id ? 'selected' : null">
<a-list-item-meta :description="substring(item.description,20)">
<template #title>
<span class="ks-algorithm-name">{{ substring(item.name, 20) }}</span>
<span class="ks-sidebar-list-type"><a-badge size="small" :count="getAlgorithmTypeName(item.type)"></a-badge></span>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
<a-pagination
v-model:current="query.pageNum"
:page-size="query.pageSize"
:total="algorithmsTotal"
simple size="small" @change="handleChange" />
</template>
<div class="w-full h-full">
<a-card class="ks-page-card ks-algorithm-card">
<template #title>
<a-space>
<span class="point"></span>
<span class="text">规则配置</span>
</a-space>
</template>
<div class="ks-scrollable" style="height: 80.5vh;overflow-y: auto;padding-right: 10px">
<a-row :gutter="15">
<a-col :span="16">
<a-form
ref="formRef"
:label-col="{span: 6}"
:model="selectedAlgorithm"
autocomplete="off"
layout="horizontal"
name="basic"
>
<a-form-item
label="规则名称"
:rules="[{ required: true, message: '请输入算法名称!', trigger: ['input', 'change'] }]"
:name="['name']"
>
<a-input v-model:value="selectedAlgorithm.name" placeholder="请输入算法名称" />
</a-form-item>
<a-form-item
label="业务类型"
:rules="[{ required: true, message: '请输入业务类型!', trigger: ['input', 'change'] }]"
:name="['type']"
>
<a-select placeholder="请选择业务类型" allow-clear v-model:value="selectedAlgorithm.type" @change="(v: any)=> selectedAlgorithm.type = v">
<a-select-option v-for="a in algorithmTypes" :value="a.type">{{ a.name }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item
label="算法文件路径"
:rules="[{ required: true, message: '请输入算法文件路径!', trigger: ['input', 'change'] }]"
:name="['codePath']"
>
<a-input v-model:value="selectedAlgorithm.codePath" placeholder="请输入算法文件路径" />
</a-form-item>
<a-form-item
label="算法描述"
:rules="[{ required: false, message: '请输入算法描述', trigger: ['input', 'change'] }]"
:name="['description']"
>
<a-textarea v-model:value="selectedAlgorithm.description" placeholder="请输入算法描述" />
</a-form-item>
<a-form-item
label="算法参数定义"
:rules="[{ required: true, message: '请输入算法参数定义', trigger: ['input', 'change'] }]"
:name="['algorithmParamList']"
>
<a-form-item-rest>
<div class="ks-sidebar-list-param-list">
<div class="ks-sidebar-list-param-item" v-for="(item,index) in selectedAlgorithm.algorithmParamList">
<a-row :gutter="15">
<a-col :span="7">
<a-input v-model:value="item.paramName" placeholder="请输入参数名" />
</a-col>
<a-col :span="7">
<a-input v-model:value="item.defaultValue" placeholder="请输入默认值" />
</a-col>
<a-col :span="7">
<a-input v-model:value="item.description" placeholder="请输入描述" />
</a-col>
<a-col :span="3">
<a-space class="ks-sidebar-list-param-actions">
<MinusCircleOutlined @click="()=> handleMinus(index)" />
<PlusCircleOutlined @click="handleAdd" v-if="index === 0" />
</a-space>
</a-col>
</a-row>
</div>
</div>
</a-form-item-rest>
</a-form-item>
<a-form-item
label="算法配置"
:rules="[{ required: false, message: '请输入算法配置', trigger: ['input', 'change'] }]"
:name="['algoConfig']"
>
<a-form-item-rest>
<div class="ks-sidebar-list-param-list">
<div class="ks-sidebar-list-param-item" v-for="(t,index) in selectedAlgorithm.algoConfigList">
<a-row :gutter="15">
<a-col :span="7">
<a-select placeholder="请选择参数" v-model:value="t.name" @change="(v: any)=> t.name = v">
<a-select-option :value="v.paramName" v-for="v in selectedAlgorithm.algorithmParamList">{{v.paramName}}</a-select-option>
</a-select>
</a-col>
<a-col :span="7">
<a-select placeholder="请选择操作" v-model:value="t.operation" @change="(v: any)=> t.operation = v">
<a-select-option :value="o.type" v-for="o in algorithmConfigOperations">{{o.name}} {{o.type}}</a-select-option>
</a-select>
</a-col>
<a-col :span="3">
<a-space class="ks-sidebar-list-param-actions">
<MinusCircleOutlined @click="()=> handleMinusConfig(index)" />
<PlusCircleOutlined @click="handleAddConfig" v-if="index === 0" />
</a-space>
</a-col>
</a-row>
</div>
</div>
</a-form-item-rest>
</a-form-item>
<a-form-item
:wrapper-col="{offset: 6}"
>
<a-space>
<a-button @click="handleSave" type="primary">保存规则</a-button>
<a-popconfirm
v-if="selectedAlgorithm && selectedAlgorithm.id > 0"
title="确定运行?"
@confirm="handleRun"
>
<a-button>运行规则</a-button>
</a-popconfirm>
<a-popconfirm
v-if="selectedAlgorithm && selectedAlgorithm.id > 0"
title="确定删除?"
@confirm="handleDelete"
>
<a-button danger>删除规则</a-button>
</a-popconfirm>
</a-space>
</a-form-item>
</a-form>
</a-col>
</a-row>
</div>
</a-card>
</div>
</Layout>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { type FormInstance, message } from 'ant-design-vue';
import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
import Layout from '../layout.vue';
import { createAlgorithm, deleteAlgorithm, findAlgorithmsByQuery, updateAlgorithm, runAlgorithm } from './api';
import type { Algorithm, AlgorithmParam, AlgorithmRequest } from './types';
import { substring } from '@/utils/strings';
import { algorithmTypes,algorithmConfigOperations } from './config';
import type { NullableString } from '@/types';
const query = ref<Partial<AlgorithmRequest>>({
pageNum: 1,
pageSize: 10,
});
const defaultAlgorithmParam: AlgorithmParam = {
id: 0,
algorithmId: 0,
// 参数名
paramName: null,
// 默认值
defaultValue: null,
// 描述
description: null,
};
const defaultAlgorithm: Algorithm = {
id: 0,
// 算法名称
name: null,
// 业务类型
type: undefined,
// 算法文件路径
codePath: null,
// 算法描述
description: null,
// 算法配置
algoConfig: null,
// 算法配置
algoConfigList: [],
// 算法参数定义信息
algorithmParamList: [
{ ...defaultAlgorithmParam },
],
};
const resolveItem = (item: Algorithm) => {
let newItem = JSON.parse(JSON.stringify(item))
if (!newItem.algorithmParamList) {
newItem.algorithmParamList = [];
}
if (newItem.algorithmParamList.length === 0) {
newItem.algorithmParamList.push({ ...defaultAlgorithmParam });
}
try{
newItem.algoConfigList = JSON.parse(newItem.algoConfigList)
} catch (e: any){
console.error(e);
}
if(!newItem.algoConfigList){
newItem.algoConfigList = []
}
if(newItem.algoConfigList.length === 0){
newItem.algoConfigList.push({
name: undefined,
operation: undefined,
})
}
return newItem;
};
const algorithms = ref<Algorithm[]>([]);
const algorithmsTotal = ref<number>(0);
const selectedAlgorithm = ref<Algorithm>(resolveItem(defaultAlgorithm));
const formRef = ref<FormInstance | null>(null);
const getAlgorithmTypeName = (type: NullableString): NullableString => {
let v = algorithmTypes.find(c => c.type === type);
return v && v.name ? v.name : type;
};
const load = () => {
algorithms.value = [];
algorithmsTotal.value = 0;
formRef.value?.resetFields();
selectedAlgorithm.value = resolveItem(defaultAlgorithm);
findAlgorithmsByQuery(query.value).then(r => {
algorithms.value = r.rows ?? [];
algorithmsTotal.value = r.total ?? 0;
});
};
const handleCreate = () => {
selectedAlgorithm.value = resolveItem(defaultAlgorithm);
};
const handleSelect = (item: Algorithm) => {
selectedAlgorithm.value = resolveItem(item);
formRef.value?.resetFields();
};
const handleAdd = () => {
selectedAlgorithm.value.algorithmParamList.push({ ...defaultAlgorithmParam });
};
const handleMinus = (index: number) => {
const paramList = selectedAlgorithm.value.algorithmParamList;
if (index === 0 && selectedAlgorithm.value.algorithmParamList.length === 1) {
selectedAlgorithm.value.algorithmParamList = [{ ...defaultAlgorithmParam }];
} else if (index >= 0 && index < paramList.length && paramList.length > 1) {
paramList.splice(index, 1);
selectedAlgorithm.value.algorithmParamList = [...paramList];
}
};
const handleAddConfig = () => {
selectedAlgorithm.value.algoConfigList.push({ name: null, operation: null });
};
const handleMinusConfig = (index: number) => {
const paramList = selectedAlgorithm.value.algoConfigList;
if (index === 0 && selectedAlgorithm.value.algoConfigList.length === 1) {
selectedAlgorithm.value.algoConfigList = [{ name: null, operation: null }];
} else if (index >= 0 && index < paramList.length && paramList.length > 1) {
paramList.splice(index, 1);
selectedAlgorithm.value.algoConfigList = [...paramList];
}
};
const handleDelete = () => {
if (selectedAlgorithm.value && selectedAlgorithm.value.id > 0) {
deleteAlgorithm(selectedAlgorithm.value.id).then(r => {
if (r.code === 200) {
load();
message.info(r.msg ?? '删除成功');
} else {
message.error(r.msg ?? '删除失败');
}
});
}
};
const handleSave = () => {
if (formRef.value) {
formRef.value.validate().then(() => {
let res = null;
let savedValue: Algorithm = JSON.parse(JSON.stringify(selectedAlgorithm.value)) as any as Algorithm;
let algoConfig = '';
if( savedValue.algoConfigList ){
savedValue.algoConfigList.forEach(o=> {
if(o.name){
algoConfig = algoConfig + o.name;
}
if(o.operation){
algoConfig = algoConfig + o.operation;
}
})
}
savedValue.algoConfig = algoConfig;
if (savedValue.id > 0) {
res = updateAlgorithm(savedValue);
} else {
res = createAlgorithm(savedValue);
}
if (res) {
res.then(r => {
if (r.code === 200) {
load();
message.info(r.msg ?? '操作成功');
} else {
message.error(r.msg ?? '操作失败');
}
});
}
});
}
};
const handleRun = ()=> {
if (formRef.value) {
formRef.value.validate().then(() => {
runAlgorithm(selectedAlgorithm.value).then(r => {
if (r.code === 200) {
message.info(r.msg ?? '运行成功');
} else {
message.error(r.msg ?? '运行失败');
}
});
});
}
}
const handleChange = (page: number, pageSize: number) => {
query.value.pageNum = page;
query.value.pageSize = pageSize;
load();
};
onMounted(() => load());
</script>

View File

@@ -0,0 +1,54 @@
/*
* 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 type { NullableString, PageableResponse } from '@/types';
export interface AlgorithmParam {
id: number,
algorithmId: number,
// 参数名
paramName: NullableString,
// 默认值
defaultValue: NullableString,
// 描述
description: NullableString,
}
export interface AlgorithmConfig {
name: NullableString,
operation: NullableString,
}
export interface Algorithm {
id: number,
// 算法名称
name: NullableString,
// 业务类型
type: NullableString | undefined,
// 算法文件路径
codePath: NullableString,
// 算法描述
description: NullableString,
// 算法配置
algoConfig: NullableString,
// 算法配置
algoConfigList: AlgorithmConfig[],
// 算法参数定义信息
algorithmParamList: AlgorithmParam[]
}
export interface AlgorithmRequest extends Algorithm {
pageNum: number,
pageSize: number,
}
export interface AlgorithmPageableResponse extends PageableResponse<Algorithm> {
}

View File

@@ -18,6 +18,7 @@ export interface DraggableElement {
draggable: boolean, draggable: boolean,
parent?: DraggableElement, parent?: DraggableElement,
children: DraggableElement[] children: DraggableElement[]
[key: string]: unknown; [key: string]: unknown;
} }
@@ -70,8 +71,10 @@ export interface BaseElement {
export interface GraphTaskElement extends BaseElement { export interface GraphTaskElement extends BaseElement {
template: number; template: number;
templateType: NullableString,
inputs: any; inputs: any;
outputs: any; outputs: any;
order: number;
variables: ElementVariable[]; variables: ElementVariable[];
parameters: ElementParameter[]; parameters: ElementParameter[];
children?: GraphTaskElement[], children?: GraphTaskElement[],

View File

@@ -10,7 +10,7 @@
import { Edge, Graph, Path, Selection } from '@antv/x6'; import { Edge, Graph, Path, Selection } from '@antv/x6';
import type { ModelElement } from './element'; import type { ModelElement } from './element';
import type { Connecting } from '@antv/x6/lib/graph/options'; import type { Connecting } from '@antv/x6/lib/graph/options';
import {createLineOptions} from './line' import { createLineOptions } from './line';
Graph.registerConnector( Graph.registerConnector(
'sequenceFlowConnector', 'sequenceFlowConnector',
@@ -52,10 +52,18 @@ export const createGraphConnectingAttributes = (): Partial<Connecting> => {
const edge: Edge = this.createEdge({ const edge: Edge = this.createEdge({
shape: 'edge', shape: 'edge',
...lineOptions, // 应用动画配置 ...lineOptions, // 应用动画配置
attrs: lineOptions.attrs, attrs: {
...lineOptions.attrs,
// 在创建边时覆盖箭头配置,确保移除箭头
line: {
...lineOptions.attrs?.line,
targetMarker: null,
sourceMarker: null,
}
},
animation: lineOptions.animation, animation: lineOptions.animation,
markup: lineOptions.markup, markup: lineOptions.markup,
}) });
return edge; return edge;
}, },
validateConnection(this: Graph, { sourceCell, targetCell }) { validateConnection(this: Graph, { sourceCell, targetCell }) {
@@ -71,7 +79,7 @@ export const createGraphConnectingAttributes = (): Partial<Connecting> => {
const targetData = targetCell.getData() as ModelElement; const targetData = targetCell.getData() as ModelElement;
// 根节点不能作为子节点 // 根节点不能作为子节点
if (targetData.type === 'startEvent') { if (targetData.category === 'root') {
return false; return false;
} }

View File

@@ -13,6 +13,7 @@ import type { NodeViewPositionEventArgs } from '@antv/x6/es/view/node/type';
import { createGraphCanvas } from './graph'; import { createGraphCanvas } from './graph';
import { EventListener } from '@/utils/event'; import { EventListener } from '@/utils/event';
import type { ModelElement } from './element'; import type { ModelElement } from './element';
// import {createLineOptions} from './line' // import {createLineOptions} from './line'
export interface UseGraphCanvas { export interface UseGraphCanvas {
@@ -163,7 +164,7 @@ export const useGraphCanvas = (readonly: boolean = false): UseGraphCanvas => {
router: {}, router: {},
attrs: {}, attrs: {},
target: targetNode.id, target: targetNode.id,
targetName: targetData.name targetName: targetData.name,
}); });
sourceNode.replaceData({ ...sourceData, edges: sourceEdges }); sourceNode.replaceData({ ...sourceData, edges: sourceEdges });
} }

View File

@@ -28,6 +28,10 @@ export const createLineOptions = (): any => {
strokeWidth: 2, strokeWidth: 2,
strokeDasharray: ' ', strokeDasharray: ' ',
strokeDashoffset: 0, strokeDashoffset: 0,
// 去掉箭头
targetMarker: null,
sourceMarker: null,
}, },
marker: { marker: {
fill: '#5da0df', fill: '#5da0df',
@@ -43,5 +47,5 @@ export const createLineOptions = (): any => {
}, },
], ],
], ],
} };
} };

View File

@@ -3,29 +3,34 @@
<a-card <a-card
:class="[ :class="[
'ks-designer-node', 'ks-designer-node',
`ks-designer-${element?.category ?? 'model'}-node` `ks-designer-${element?.category ?? 'model'}-node`,
`ks-designer-group-${element?.group ?? 'general'}`
]" ]"
hoverable hoverable
> >
<template #title> <template #title>
<a-space> <a-space>
<div class="port port-in" data-port="in-0" magnet="passive"></div> <!-- <span class="ks-designer-node-icon"></span>-->
<span class="ks-designer-node-title">{{ element?.name ?? '-' }}</span> <span class="ks-designer-node-title">{{ element?.name ?? '-' }}</span>
<div class="port port-out" data-port="out-0" magnet="active"></div>
</a-space> </a-space>
</template> </template>
<!-- 节点内容区域 --> <div class="port port-in" data-port="in-0" magnet="passive">
<div class="w-full"> <div class="triangle-left"></div>
<a-tooltip> </div>
<div class="w-full ks-designer-node-text">
<a-tooltip >
<template #title> <template #title>
{{element?.description ?? element?.name}} {{ element?.description ?? element?.name }}
</template> </template>
<p> <p class="ks-designer-node-label">
{{ substring(element?.description ?? (element?.name ?? '-') ,40) }} {{ substring(element?.name ?? (element?.name ?? '-'), 40) }}
</p> </p>
</a-tooltip> </a-tooltip>
</div> </div>
<div class="port port-out" data-port="out-0" magnet="active">
<div class="triangle-right" ></div>
</div>
</a-card> </a-card>
<template #overlay> <template #overlay>
@@ -47,7 +52,7 @@ import { elementProps } from './props';
import type { ModelElement } from './element'; import type { ModelElement } from './element';
import { DeleteOutlined, SettingOutlined } from '@ant-design/icons-vue'; import { DeleteOutlined, SettingOutlined } from '@ant-design/icons-vue';
import type { Graph } from '@antv/x6'; import type { Graph } from '@antv/x6';
import {substring} from '@/utils/strings' import { substring } from '@/utils/strings';
export default defineComponent({ export default defineComponent({
name: 'ModelElement', name: 'ModelElement',
@@ -127,23 +132,37 @@ export default defineComponent({
<style lang="less"> <style lang="less">
.ks-designer-node { .ks-designer-node {
background: linear-gradient(150deg, #093866 1%, #1f69b3 55%); background: linear-gradient(150deg, rgba(108, 99, 255) 1%, rgba(108, 99, 255) 100%);
border: 0;
border-radius: 8px; border-radius: 8px;
width: 100%; width: 100%;
height: 100%; height: 100%;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
background: #1e2533;
border: 1px solid #4a7aff;
border: 2px solid #000000;
&:hover {
border: 2px solid #4a7aff;
box-shadow: 0 0 10px rgba(74, 122, 255, 0.3);
}
.ant-card-head { .ant-card-head {
border: 0; border: 0;
height: 38px; height: 28px;
min-height: 38px; min-height: 25px;
border-radius: 0; border-radius: 0;
color: #ddd; color: #fff;
font-size: 12px; font-size: 12px;
font-weight: normal; font-weight: normal;
padding: 0 20px; padding: 0 20px;
//background: linear-gradient(to bottom, #3a4c70, #2d3a56);
border-top-left-radius: 8px;
border-top-right-radius: 8px;
background: linear-gradient(to bottom, rgba(108, 99, 255, 0.15), rgba(108, 99, 255, 0.05));
//background: url('@/assets/icons/bg-node-head.png') center / 100% 100%;
//background: linear-gradient(to bottom, rgb(234 234 234 / 20%), rgb(191 191 191 / 58%));
} }
.ks-designer-node-icon { .ks-designer-node-icon {
@@ -152,156 +171,258 @@ export default defineComponent({
display: block; display: block;
position: absolute; position: absolute;
left: 8px; left: 8px;
top: 13px; top: 6px;
background: url('@/assets/icons/model-4.svg') center / 100% 100%; background: url('@/assets/icons/icon-node.svg') center / 100% 100%;
} }
.ks-designer-node-title { .ks-designer-node-title {
font-size: 13px; font-size: 12px;
color: #fff;
margin-top: -7px;
display: block;
} }
.ant-card-body { .ant-card-body {
color: #fff; color: #f5f5f5;
height: calc(100% - 38px); height: calc(100% - 25px);
border-radius: 0; border-radius: 0;
font-size: 12px; font-size: 12px;
padding: 8px 15px; padding: 10px 30px !important;
border-top: 1px solid #195693; //border-top: 1px solid rgba(108, 99, 255, 0.5);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
box-shadow: 0 0 10px rgba(74, 122, 255, 0.3);
white-space: normal; // 恢复默认的换行行为
word-wrap: break-word; // 允许长单词换行
word-break: break-all; // 允许在任意字符处换行
line-height: 1.4; // 增加行高提升可读性
box-shadow: 0 0 10px rgba(74, 122, 255, 0.3);
} }
&.ks-designer-model-node,
&.ks-designer-task-node {
background: linear-gradient(150deg, #20421b 1%, #4a6646 55%);
.ant-card-body {
border-top: 1px solid #466741;
}
.ks-designer-node-icon {
background: url('@/assets/icons/m-02.png') center / 100% 100%;
}
}
&.ks-designer-input-node {
background: linear-gradient(150deg, #083058 1%, #1e5d9b 55%);
.ant-card-body {
border-top: 1px solid #105ca7;
}
.ks-designer-node-icon {
background: url('@/assets/icons/icon-model-input.png') center / 100% 100%;
}
}
&.ks-designer-action-node {
background: linear-gradient(150deg, #343207 1%, #485010 55%);
.ant-card-body {
border-top: 1px solid #59550e;
}
.ks-designer-node-icon {
background: url('@/assets/icons/bg-fk-point.png') center / 100% 100%;
}
}
&.ks-designer-precondition-node,
&.ks-designer-component-node {
background: linear-gradient(150deg, #06226b 1%, #1a43a7 55%);
.ant-card-body {
border-top: 1px solid #26448c;
}
}
&.ks-designer-select-node,
&.ks-designer-control-node {
background: linear-gradient(150deg, #1d4f32 1%, #326a5d 55%);
.ant-card-body {
border-top: 1px solid #326a5d;
}
.ks-designer-node-icon {
background: url('@/assets/icons/bg-model-builder-card-title.png') center / 100% 100%;
}
}
// 连接桩容器样式 // 连接桩容器样式
.ks-designer-node-content { .ks-designer-node-content {
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; // 每个child行之间的间距 gap: 4px;
} }
// 每个child行包含左右桩+文本)
.ks-designer-node-row { .ks-designer-node-row {
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
position: relative; position: relative;
min-height: 24px; // 固定行高,保证桩对齐 min-height: 24px;
} }
// 连接桩基础样式
.port { .port {
width: 12px; width: 12px;
height: 12px; height: 12px;
border-radius: 50%; border-radius: 50%;
cursor: crosshair; cursor: crosshair;
flex-shrink: 0; flex-shrink: 0;
box-shadow: 0 0 0 2px rgb(74 114 214 / 80%); box-shadow: 0 0 0 2px rgb(108, 99, 255, 0.8);
z-index: 10; // 确保桩在最上层 z-index: 10;
// X6 标记为可连线的磁体
magnet: true; magnet: true;
position: relative;
.triangle-left {
width: 0;
height: 0;
border-top: 4px solid transparent;
border-right: 5px solid #5da1df;
border-bottom: 4px solid transparent;
position: absolute;
left: -8px;
top: 0.5px;
magnet: passive;
}
/* 右三角形 */
.triangle-right {
width: 0;
height: 0;
border-top: 4px solid transparent;
border-left: 5px solid #5da1df;
border-bottom: 4px solid transparent;
position: absolute;
right: -8px;
top: 0.5px;
magnet: passive;
}
} }
// 左侧入桩样式 // 左侧入桩样式
.port-in { .port-in {
background-color: #093866; // 青色:入桩 //background-color: #3c82f6;
margin-right: 8px; // 与文本的间距 margin-right: 8px;
//border: 1px solid #093866; //border: 1px solid #093866;
// X6 只能作为连线目标(入)
magnet: passive; magnet: passive;
box-shadow: none; box-shadow: none;
width: 15px; width: 13px;
height: 15px; height: 13px;
display: block; display: block;
background: url('@/assets/icons/point.svg') center / 100% 100%; //background: url('@/assets/icons/point.svg') center / 100% 100%;
border: 2px solid #5da1df;
position: absolute; position: absolute;
left: 5px; //top: 7px;
top: 12px; left: 10px;
top: 50%;
} }
// 右侧出桩样式
.port-out { .port-out {
margin-left: 8px; // 与文本的间距 margin-left: 8px;
margin-right: 5px; margin-right: 5px;
// X6 只能作为连线源(出)
magnet: active; magnet: active;
box-shadow: none; box-shadow: none;
width: 15px; width: 13px;
height: 15px; height: 13px;
display: block; display: block;
background: url('@/assets/icons/point.svg') center / 100% 100%; //background: url('@/assets/icons/point.svg') center / 100% 100%;
border: 2px solid #5da1df;
background:#5da1df;
position: absolute; position: absolute;
right: 5px; //right: 8px;
top: 12px; //top: 7px;
top: 50%;
right: 6px;
} }
// 节点文本样式 // 节点文本样式
.ks-designer-node-name { .ks-designer-node-name {
flex: 1; // 占满中间空间 flex: 1;
line-height: 24px; line-height: 24px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
//white-space: nowrap; //white-space: nowrap;
} }
&.ks-designer-root-node{
.ks-designer-node-icon {
background: url('@/assets/icons/icon-root.svg') center / 100% 100%;
}
}
&.ks-designer-action-node{
.ant-card-head {
background: url('@/assets/icons/card-head-red.png') center / 100% 100%;
}
.ks-designer-node-icon {
background: url('@/assets/icons/icon-action.svg') center / 100% 100%;
}
}
&.ks-designer-sequence-node{
.ks-designer-node-icon {
background: url('@/assets/icons/icon-sequence.svg') center / 100% 100%;
}
}
&.ks-designer-parallel-node{
.ks-designer-node-icon {
background: url('@/assets/icons/icon-parallel.svg') center / 100% 100%;
}
}
&.ks-designer-precondition-node{
.ks-designer-node-icon {
background: url('@/assets/icons/icon-branch.svg') center / 100% 100%;
}
}
&.ks-designer-group-control,
&.ks-designer-group-condition {
.ant-card-head{
display:none;
}
.ant-card-body {
height: calc(100%);
border-radius: 8px;
background: url('@/assets/icons/card-head-gray.png') center / 100% 100%;
}
&.ks-designer-root-node{
.ant-card-body {
background: url('@/assets/icons/card-head-dark.png') center / 100% 100%;
}
}
&.ks-designer-sequence-node{
.ant-card-body {
background: url('@/assets/icons/card-head-green.png') center / 100% 100%;
}
}
&.ks-designer-parallel-node{
.ant-card-body {
background: url('@/assets/icons/card-head-blue.png') center / 100% 100%;
}
}
&.ks-designer-precondition-node{
.ant-card-body {
background: url('@/assets/icons/card-head-dark.png') center / 100% 100%;
}
}
.port-in,
.port-out {
top: 40%;
}
.ks-designer-node-text{
line-height: 38px;
}
}
//&.ks-designer-precondition-node{
// border:0;
// box-shadown:none;
// &:hover{
// border:0;
// box-shadown:none;
// }
// background: url('@/assets/icons/lx.svg') center / 100% 100%;
// //transform: rotate(45deg);
// .ant-card-body {
// border: 0;
// box-shadow: none;
// height: 95px;
// line-height: 80px;
// font-size: 10px;
// padding: 0 !important;
// }
// .ant-card-head {
// display: none;
// }
//
// .ks-designer-node-label {
// width: 40px; /* 保留原有宽度 */
// text-align: center; /* 保留文字居中 */
// /* 核心修改:取消固定行高,重置换行相关属性 */
// word-wrap: break-word;/* 强制换行(兼容老旧浏览器) */
// word-break: break-all;/* 截断长单词/字符确保在40px内换行 */
// white-space: normal; /* 恢复默认换行规则(避免文字不换行) */
// /* 可选:添加行间距,提升多行可读性 */
// line-height: 1.4; /* 多行时的行间距,可根据需求调整 */
// padding: 10px 0; /* 上下内边距替代原有line-height:98px的垂直居中效果 */
// margin: 31% auto;
// }
//
// .port-in {
// left: 12px;
// top: 42px;
// }
//
// .port-out {
// right: 6px;
// top: 42px;
// }
//}
} }
</style> </style>

View File

@@ -18,6 +18,9 @@ export const createGraphTaskElement = (element: GraphTaskElement, width: number
if (!realHeight) { if (!realHeight) {
realHeight = 120; realHeight = 120;
} }
if(element.group === 'condition' || element.group === 'control') {
realHeight = 60;
}
return { return {
shape: 'task', shape: 'task',
id: element.key, id: element.key,

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