diff --git a/auto-solution-admin/src/main/java/com/solution/web/controller/behaviour/BehaviortreeController.java b/auto-solution-admin/src/main/java/com/solution/web/controller/behaviour/BehaviortreeController.java index f3a2de5..be0323a 100644 --- a/auto-solution-admin/src/main/java/com/solution/web/controller/behaviour/BehaviortreeController.java +++ b/auto-solution-admin/src/main/java/com/solution/web/controller/behaviour/BehaviortreeController.java @@ -42,6 +42,12 @@ public class BehaviortreeController extends BaseController @Autowired private BehaviortreeProcessor behaviortreeProcessor; + @GetMapping(value = "/platform/{id}") + public AjaxResult fromPlatform(@PathVariable("id") Integer id) + { + return success(behaviortreeService.findOneByPlatformId(id)); + } + /** * 查询行为树主列表 */ diff --git a/auto-solution-admin/src/main/java/com/solution/web/controller/rule/FireRuleController.java b/auto-solution-admin/src/main/java/com/solution/web/controller/rule/FireRuleController.java index 0a0f7e2..8c4eac0 100644 --- a/auto-solution-admin/src/main/java/com/solution/web/controller/rule/FireRuleController.java +++ b/auto-solution-admin/src/main/java/com/solution/web/controller/rule/FireRuleController.java @@ -60,10 +60,20 @@ public class FireRuleController extends BaseController { * @return */ @GetMapping("/platforms/{scenarioId}") - public AjaxResult platforms(@PathVariable Integer scenarioId){ + public AjaxResult platformsScenarioId(@PathVariable Integer scenarioId){ return success(ruleService.findPlatformComponents(scenarioId)); } + @GetMapping("/platforms") + public AjaxResult platforms(){ + return success(ruleService.findAllPlatformComponents()); + } + + @GetMapping("/platforms/basic") + public AjaxResult platformsBasic(){ + return success(ruleService.findAllBasicPlatformComponents()); + } + /** * 根据平台id获取平台下所有组件 * @param platformId diff --git a/auto-solution-scene/src/main/java/com/solution/scene/controller/SceneController.java b/auto-solution-admin/src/main/java/com/solution/web/controller/scene/SceneController.java similarity index 93% rename from auto-solution-scene/src/main/java/com/solution/scene/controller/SceneController.java rename to auto-solution-admin/src/main/java/com/solution/web/controller/scene/SceneController.java index a255588..aacdd55 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/controller/SceneController.java +++ b/auto-solution-admin/src/main/java/com/solution/web/controller/scene/SceneController.java @@ -1,4 +1,4 @@ -package com.solution.scene.controller; +package com.solution.web.controller.scene; import com.solution.common.annotation.Log; import com.solution.common.core.controller.BaseController; @@ -6,6 +6,7 @@ import com.solution.common.core.domain.AjaxResult; import com.solution.common.core.page.TableDataInfo; import com.solution.common.enums.BusinessType; import com.solution.scene.domain.AfsimScenario; +import com.solution.scene.domain.AfsimScenarioForm; import com.solution.scene.service.SceneService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/auto-solution-admin/src/main/java/com/solution/web/core/BehaviortreeProcessor.java b/auto-solution-admin/src/main/java/com/solution/web/core/BehaviortreeProcessor.java index d51d846..2c41d49 100644 --- a/auto-solution-admin/src/main/java/com/solution/web/core/BehaviortreeProcessor.java +++ b/auto-solution-admin/src/main/java/com/solution/web/core/BehaviortreeProcessor.java @@ -20,8 +20,11 @@ import com.solution.web.core.graph.GraphEdge; import com.solution.web.core.graph.GraphNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @Component @@ -98,10 +101,17 @@ public class BehaviortreeProcessor { instanceKeyMap.put(node.getKey(), instance); if (node.hasParameters()) { - // 插入parameter nodeparameter - for (Templateparameterdef parameter : node.getParameters()) { - Nodeparameter nodeparameter = createNodeParameter(behaviortree, parameter, instance); - nodeparameterService.insertNodeparameter(nodeparameter); + if (node.isMultiable()) { + List nodeparameters = createMultiableNodeparameter(behaviortree, node, instance); + for (Nodeparameter nodeparameter : nodeparameters) { + nodeparameterService.insertNodeparameter(nodeparameter); + } + } else { + // 插入parameter nodeparameter + for (Templateparameterdef parameter : node.getParameters()) { + Nodeparameter nodeparameter = createNodeParameter(behaviortree, parameter, instance); + nodeparameterService.insertNodeparameter(nodeparameter); + } } } nodeKeyIndexMap.put(node.getKey(), index); @@ -148,6 +158,47 @@ public class BehaviortreeProcessor { return connection; } + private List createMultiableNodeparameter(Behaviortree behaviortree, GraphNode node, + Treenodeinstance instance) { + + List nodeparameters = new ArrayList<>(); + + Map> idValues = new HashMap<>(); + List tmpValues = null; + Map> mappedValues = new HashMap<>(); + List tmpDefs = null; + + for (Templateparameterdef parameter : node.getParameters()) { + tmpDefs = mappedValues.get(parameter.getId() ); + if (null == tmpDefs) { + tmpDefs = new ArrayList<>(); + } + tmpDefs.add(parameter); + mappedValues.put(parameter.getId(), tmpDefs); + + tmpValues = idValues.get(parameter.getId() ); + if (null == tmpValues) { + tmpValues = new ArrayList<>(); + } + tmpValues.add(parameter.getDefaultValue()); + idValues.put(parameter.getId(), tmpValues); + } + + int index = 0; + for (Long id : idValues.keySet()) { + tmpValues = idValues.get(id); + Nodeparameter nodeparameter = new Nodeparameter(); + nodeparameter.setTreeId(behaviortree.getId()); + nodeparameter.setNodeInstanceId(instance.getId()); + nodeparameter.setParamDefId(id); + nodeparameter.setValue(StringUtils.collectionToCommaDelimitedString(tmpValues)); + nodeparameter.setGroupIndex(index); + nodeparameters.add(nodeparameter); + index++; + } + return nodeparameters; + } + private Nodeparameter createNodeParameter(Behaviortree behaviortree, Templateparameterdef parameter, Treenodeinstance instance) { Nodeparameter nodeparameter = new Nodeparameter(); @@ -155,6 +206,7 @@ public class BehaviortreeProcessor { nodeparameter.setNodeInstanceId(instance.getId()); nodeparameter.setParamDefId(parameter.getId()); nodeparameter.setValue(parameter.getDefaultValue()); + nodeparameter.setGroupIndex(parameter.getGroupIndex()); return nodeparameter; } diff --git a/auto-solution-admin/src/main/java/com/solution/web/core/graph/GraphNode.java b/auto-solution-admin/src/main/java/com/solution/web/core/graph/GraphNode.java index 71f3d2a..fa3b643 100644 --- a/auto-solution-admin/src/main/java/com/solution/web/core/graph/GraphNode.java +++ b/auto-solution-admin/src/main/java/com/solution/web/core/graph/GraphNode.java @@ -33,6 +33,8 @@ public class GraphNode implements Serializable { private String category; + private boolean multiable; + private List parameters; private List variables; @@ -61,6 +63,14 @@ public class GraphNode implements Serializable { '}'; } + public boolean isMultiable() { + return multiable; + } + + public void setMultiable(boolean multiable) { + this.multiable = multiable; + } + public String getCategory() { return category; } diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/domain/Nodeparameter.java b/auto-solution-behaviour/src/main/java/com/solution/system/domain/Nodeparameter.java index 59acd0a..9c637d8 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/domain/Nodeparameter.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/domain/Nodeparameter.java @@ -32,6 +32,8 @@ public class Nodeparameter extends BaseEntity @Excel(name = "节点实例设置的具体参数值 (覆盖模板默认值)") private String value; + private int groupIndex; + public void setId(Long id) { this.id = id; @@ -80,6 +82,14 @@ public class Nodeparameter extends BaseEntity return value; } + public int getGroupIndex() { + return groupIndex; + } + + public void setGroupIndex(int groupIndex) { + this.groupIndex = groupIndex; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/domain/Nodetemplate.java b/auto-solution-behaviour/src/main/java/com/solution/system/domain/Nodetemplate.java index 2689757..d3eaee6 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/domain/Nodetemplate.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/domain/Nodetemplate.java @@ -42,6 +42,8 @@ public class Nodetemplate extends BaseEntity @Excel(name = "模版类型,节点模版或者条件判断,例如“node”,precondition“") private String templateType; + private boolean multiable; + public Nodetemplate() { } @@ -53,6 +55,7 @@ public class Nodetemplate extends BaseEntity this.description = template.description; this.englishName = template.englishName; this.templateType = template.templateType; + this.multiable = template.multiable; } public void setId(Long id) @@ -125,6 +128,14 @@ public class Nodetemplate extends BaseEntity return templateType; } + public boolean isMultiable() { + return multiable; + } + + public void setMultiable(boolean multiable) { + this.multiable = multiable; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/domain/Templateparameterdef.java b/auto-solution-behaviour/src/main/java/com/solution/system/domain/Templateparameterdef.java index b62ab7a..e830cd4 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/domain/Templateparameterdef.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/domain/Templateparameterdef.java @@ -42,6 +42,8 @@ public class Templateparameterdef extends BaseEntity @Excel(name = "判断参数模版是节点的参数模版还是条件的参数模版") private String templateType; + private int groupIndex; + public void setId(Long id) { this.id = id; @@ -112,6 +114,14 @@ public class Templateparameterdef extends BaseEntity return templateType; } + public int getGroupIndex() { + return groupIndex; + } + + public void setGroupIndex(int groupIndex) { + this.groupIndex = groupIndex; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/mapper/BehaviortreeMapper.java b/auto-solution-behaviour/src/main/java/com/solution/system/mapper/BehaviortreeMapper.java index da40ce5..6d69771 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/mapper/BehaviortreeMapper.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/mapper/BehaviortreeMapper.java @@ -12,6 +12,9 @@ import com.solution.system.domain.Behaviortree; */ public interface BehaviortreeMapper { + + Behaviortree findOneByPlatformId(Integer platformId); + /** * 查询行为树主 * diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/service/IBehaviortreeService.java b/auto-solution-behaviour/src/main/java/com/solution/system/service/IBehaviortreeService.java index f5b1ff9..583124e 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/service/IBehaviortreeService.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/service/IBehaviortreeService.java @@ -12,6 +12,9 @@ import com.solution.system.domain.Behaviortree; */ public interface IBehaviortreeService { + + Behaviortree findOneByPlatformId(Integer platformId); + /** * 查询行为树主 * diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/service/impl/BehaviortreeServiceImpl.java b/auto-solution-behaviour/src/main/java/com/solution/system/service/impl/BehaviortreeServiceImpl.java index e99e020..07b58ad 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/service/impl/BehaviortreeServiceImpl.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/service/impl/BehaviortreeServiceImpl.java @@ -22,6 +22,12 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService @Autowired private BehaviortreeMapper behaviortreeMapper; + @Override + public Behaviortree findOneByPlatformId(Integer platformId) + { + return behaviortreeMapper.findOneByPlatformId(platformId); + } + /** * 查询行为树主 * diff --git a/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml b/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml index 0507194..6dd534f 100644 --- a/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml +++ b/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml @@ -14,6 +14,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + select id, name, description, created_at, updated_at, english_name, xml_content from behaviortree diff --git a/auto-solution-behaviour/src/main/resources/mapper/system/NodeparameterMapper.xml b/auto-solution-behaviour/src/main/resources/mapper/system/NodeparameterMapper.xml index b0a4f20..1cddc6f 100644 --- a/auto-solution-behaviour/src/main/resources/mapper/system/NodeparameterMapper.xml +++ b/auto-solution-behaviour/src/main/resources/mapper/system/NodeparameterMapper.xml @@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -17,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, treeId, node_instance_id, param_def_id, value from nodeparameter + select id, treeId, node_instance_id, param_def_id,`value`, group_index from nodeparameter diff --git a/auto-solution-common/pom.xml b/auto-solution-common/pom.xml index 0b387a9..402b1e4 100644 --- a/auto-solution-common/pom.xml +++ b/auto-solution-common/pom.xml @@ -113,6 +113,12 @@ javax.servlet-api + + org.projectlombok + lombok + 1.18.34 + + cn.hutool hutool-all diff --git a/auto-solution-common/src/main/java/com/solution/common/constant/PlatformAndModuleConstants.java b/auto-solution-common/src/main/java/com/solution/common/constant/PlatformAndModuleConstants.java index 26181cf..ad01ca2 100644 --- a/auto-solution-common/src/main/java/com/solution/common/constant/PlatformAndModuleConstants.java +++ b/auto-solution-common/src/main/java/com/solution/common/constant/PlatformAndModuleConstants.java @@ -6,4 +6,6 @@ public class PlatformAndModuleConstants { public static final String RED_NEBO_M_1 = "red_nebo_m_1"; public static final String RED_NEBO_M_2 = "red_nebo_m_2"; + + public static final String RED_TANK_1 = "red_tank_1"; } diff --git a/auto-solution-rule/pom.xml b/auto-solution-rule/pom.xml index 05399c5..7f59e3b 100644 --- a/auto-solution-rule/pom.xml +++ b/auto-solution-rule/pom.xml @@ -71,10 +71,6 @@ solution-common - - org.projectlombok - lombok - io.springfox diff --git a/auto-solution-rule/src/main/java/com/solution/rule/domain/BasicPlatform.java b/auto-solution-rule/src/main/java/com/solution/rule/domain/BasicPlatform.java new file mode 100644 index 0000000..457f6a1 --- /dev/null +++ b/auto-solution-rule/src/main/java/com/solution/rule/domain/BasicPlatform.java @@ -0,0 +1,47 @@ +package com.solution.rule.domain; +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +import java.io.Serializable; +import java.util.List; + +public class BasicPlatform implements Serializable { + + + private Integer id; + + private String name; + + private String description; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/auto-solution-rule/src/main/java/com/solution/rule/domain/Platform.java b/auto-solution-rule/src/main/java/com/solution/rule/domain/Platform.java index 6a1b57a..00ed514 100644 --- a/auto-solution-rule/src/main/java/com/solution/rule/domain/Platform.java +++ b/auto-solution-rule/src/main/java/com/solution/rule/domain/Platform.java @@ -8,43 +8,12 @@ package com.solution.rule.domain; * 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; +public class Platform extends BasicPlatform { private List 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 getComponents() { return components; } @@ -52,5 +21,4 @@ public class Platform implements Serializable { public void setComponents(List components) { this.components = components; } - } diff --git a/auto-solution-rule/src/main/java/com/solution/rule/mapper/FireRuleMapper.java b/auto-solution-rule/src/main/java/com/solution/rule/mapper/FireRuleMapper.java index 8db0fde..7d35deb 100644 --- a/auto-solution-rule/src/main/java/com/solution/rule/mapper/FireRuleMapper.java +++ b/auto-solution-rule/src/main/java/com/solution/rule/mapper/FireRuleMapper.java @@ -1,5 +1,6 @@ package com.solution.rule.mapper; +import com.solution.rule.domain.BasicPlatform; import com.solution.rule.domain.Platform; import com.solution.rule.domain.PlatformComponent; import com.solution.rule.domain.vo.ComponentCountVO; @@ -42,4 +43,8 @@ public interface FireRuleMapper { List getComponents(Integer platformId); List findPlatformComponents(Integer scenarioId); + + List findAllPlatformComponents(); + + List findAllBasicPlatformComponents(); } diff --git a/auto-solution-rule/src/main/java/com/solution/rule/service/FireRuleService.java b/auto-solution-rule/src/main/java/com/solution/rule/service/FireRuleService.java index b02473a..8eb8536 100644 --- a/auto-solution-rule/src/main/java/com/solution/rule/service/FireRuleService.java +++ b/auto-solution-rule/src/main/java/com/solution/rule/service/FireRuleService.java @@ -1,6 +1,8 @@ package com.solution.rule.service; +import com.solution.rule.domain.BasicPlatform; 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; @@ -45,6 +47,10 @@ public interface FireRuleService { */ List findPlatformComponents(Integer scenarioId); + List findAllPlatformComponents(); + + List findAllBasicPlatformComponents(); + /** * 开始执行规则匹配 * @param task diff --git a/auto-solution-rule/src/main/java/com/solution/rule/service/impl/FireRuleServiceImpl.java b/auto-solution-rule/src/main/java/com/solution/rule/service/impl/FireRuleServiceImpl.java index fa76224..c6e2fb5 100644 --- a/auto-solution-rule/src/main/java/com/solution/rule/service/impl/FireRuleServiceImpl.java +++ b/auto-solution-rule/src/main/java/com/solution/rule/service/impl/FireRuleServiceImpl.java @@ -3,10 +3,7 @@ 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.*; import com.solution.rule.domain.dto.WeaponModelDTO; import com.solution.rule.domain.simplerulepojo.Task; import com.solution.rule.domain.simplerulepojo.Weapon; @@ -210,4 +207,14 @@ public class FireRuleServiceImpl implements FireRuleService { return new ArrayList<>(); } + @Override + public List findAllPlatformComponents() { + return ruleMapper.findAllPlatformComponents(); + } + + @Override + public List findAllBasicPlatformComponents() { + return ruleMapper.findAllBasicPlatformComponents(); + } + } diff --git a/auto-solution-rule/src/main/resources/mapper/rule/FireRuleMapper.xml b/auto-solution-rule/src/main/resources/mapper/rule/FireRuleMapper.xml index 34e95c8..8b45634 100644 --- a/auto-solution-rule/src/main/resources/mapper/rule/FireRuleMapper.xml +++ b/auto-solution-rule/src/main/resources/mapper/rule/FireRuleMapper.xml @@ -85,6 +85,16 @@ WHERE platform_id=#{platformId} + + + + + + + @@ -106,4 +116,9 @@ ORDER BY p.name,pc.name + + \ No newline at end of file diff --git a/auto-solution-scene/pom.xml b/auto-solution-scene/pom.xml index d494b0d..a06d4fe 100644 --- a/auto-solution-scene/pom.xml +++ b/auto-solution-scene/pom.xml @@ -18,16 +18,18 @@ + + + com.solution + solution-rule + + com.solution solution-common - - org.projectlombok - lombok - io.springfox diff --git a/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenario.java b/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenario.java index 0074f13..535b674 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenario.java +++ b/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenario.java @@ -1,5 +1,7 @@ package com.solution.scene.domain; +import java.util.List; + /** * 场景配置表 * 对应表 afsim_scenario @@ -11,6 +13,16 @@ public class AfsimScenario { private String scenarioPath; private String communicationGraph; // 用于存储场景中的通讯关系 + public List getRelations() { + return relations; + } + + public void setRelations(List relations) { + this.relations = relations; + } + + private List relations; + public Integer getId() { return id; } diff --git a/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenarioForm.java b/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenarioForm.java new file mode 100644 index 0000000..5d96fd5 --- /dev/null +++ b/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenarioForm.java @@ -0,0 +1,25 @@ +package com.solution.scene.domain; +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +import java.util.List; + +public class AfsimScenarioForm extends AfsimScenario { + + private List relations; + + public List getRelations() { + return relations; + } + + public void setRelations(List relations) { + this.relations = relations; + } + +} diff --git a/auto-solution-scene/src/main/java/com/solution/scene/domain/ScenarioRelation.java b/auto-solution-scene/src/main/java/com/solution/scene/domain/ScenarioRelation.java new file mode 100644 index 0000000..cd1ddb0 --- /dev/null +++ b/auto-solution-scene/src/main/java/com/solution/scene/domain/ScenarioRelation.java @@ -0,0 +1,108 @@ +package com.solution.scene.domain; +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +import com.solution.rule.domain.Platform; +import com.solution.rule.domain.PlatformComponent; + +import java.io.Serializable; + +public class ScenarioRelation implements Serializable { + + private String edgeId; + + private String sourceId; + + private String sourcePort; + + private Platform sourcePlatform; + + private PlatformComponent sourceComponent; + + private String targetId; + + private String targetPort; + + private Platform targetPlatform; + + private PlatformComponent targetComponent; + + public String getEdgeId() { + return edgeId; + } + + public void setEdgeId(String edgeId) { + this.edgeId = edgeId; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getSourcePort() { + return sourcePort; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public Platform getSourcePlatform() { + return sourcePlatform; + } + + public void setSourcePlatform(Platform sourcePlatform) { + this.sourcePlatform = sourcePlatform; + } + + public PlatformComponent getSourceComponent() { + return sourceComponent; + } + + public void setSourceComponent(PlatformComponent sourceComponent) { + this.sourceComponent = sourceComponent; + } + + public String getTargetId() { + return targetId; + } + + public void setTargetId(String targetId) { + this.targetId = targetId; + } + + public String getTargetPort() { + return targetPort; + } + + public void setTargetPort(String targetPort) { + this.targetPort = targetPort; + } + + public Platform getTargetPlatform() { + return targetPlatform; + } + + public void setTargetPlatform(Platform targetPlatform) { + this.targetPlatform = targetPlatform; + } + + public PlatformComponent getTargetComponent() { + return targetComponent; + } + + public void setTargetComponent(PlatformComponent targetComponent) { + this.targetComponent = targetComponent; + } + +} diff --git a/auto-solution-scene/src/main/java/com/solution/scene/mapper/PlatFormCommunicationMapper.java b/auto-solution-scene/src/main/java/com/solution/scene/mapper/PlatFormCommunicationMapper.java new file mode 100644 index 0000000..71e6aac --- /dev/null +++ b/auto-solution-scene/src/main/java/com/solution/scene/mapper/PlatFormCommunicationMapper.java @@ -0,0 +1,27 @@ +package com.solution.scene.mapper; + +import com.solution.scene.domain.AfsimScenarioForm; +import com.solution.scene.domain.ScenarioRelation; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface PlatFormCommunicationMapper { + + /** + * 存储通信关系 + * @param scenaryId,afsimScenarios + */ + int insert(@Param("scenaryId") Integer scenaryId, + @Param("afsimScenarios") List afsimScenarios); + + + /** + * 删除通信关系 + * @param scenaryId + * @return + */ + int delete(Integer scenaryId); +} diff --git a/auto-solution-scene/src/main/java/com/solution/scene/mapper/SceneMapper.java b/auto-solution-scene/src/main/java/com/solution/scene/mapper/SceneMapper.java index 4b6585d..d1c2569 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/mapper/SceneMapper.java +++ b/auto-solution-scene/src/main/java/com/solution/scene/mapper/SceneMapper.java @@ -1,6 +1,7 @@ package com.solution.scene.mapper; import com.solution.scene.domain.AfsimScenario; +import com.solution.scene.domain.AfsimScenarioForm; import org.apache.ibatis.annotations.Mapper; import java.util.List; diff --git a/auto-solution-scene/src/main/java/com/solution/scene/service/SceneService.java b/auto-solution-scene/src/main/java/com/solution/scene/service/SceneService.java index 67305b3..ea06aad 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/service/SceneService.java +++ b/auto-solution-scene/src/main/java/com/solution/scene/service/SceneService.java @@ -1,6 +1,7 @@ package com.solution.scene.service; import com.solution.scene.domain.AfsimScenario; +import com.solution.scene.domain.AfsimScenarioForm; import java.util.List; @@ -13,7 +14,7 @@ public interface SceneService { */ int insert(AfsimScenario afsimScenario); - int update(AfsimScenario afsimScenario); + int update(AfsimScenarioForm afsimScenario); int saveOrUpdate(AfsimScenario afsimScenario); diff --git a/auto-solution-scene/src/main/java/com/solution/scene/service/impl/SceneServiceImpl.java b/auto-solution-scene/src/main/java/com/solution/scene/service/impl/SceneServiceImpl.java index f1a43fa..7669444 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/service/impl/SceneServiceImpl.java +++ b/auto-solution-scene/src/main/java/com/solution/scene/service/impl/SceneServiceImpl.java @@ -1,10 +1,13 @@ package com.solution.scene.service.impl; import com.solution.scene.domain.AfsimScenario; +import com.solution.scene.domain.AfsimScenarioForm; +import com.solution.scene.mapper.PlatFormCommunicationMapper; import com.solution.scene.mapper.SceneMapper; import com.solution.scene.service.SceneService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -15,22 +18,42 @@ public class SceneServiceImpl implements SceneService { @Autowired private SceneMapper sceneMapper; + @Autowired + private PlatFormCommunicationMapper platFormCommunicationMapper; + @Override public int insert(AfsimScenario afsimScenario) { return sceneMapper.insert(afsimScenario); } @Override - public int update(AfsimScenario afsimScenario) { + public int update(AfsimScenarioForm afsimScenario) { return sceneMapper.update(afsimScenario); } + @Transactional(rollbackFor = Exception.class) @Override public int saveOrUpdate(AfsimScenario afsimScenario) { if (null != afsimScenario.getId() && afsimScenario.getId() > 0) { - return sceneMapper.update(afsimScenario); + // 更新场景 + int updated = sceneMapper.update(afsimScenario); + // 先删除通信关系 + platFormCommunicationMapper.delete(afsimScenario.getId()); + // 再插入通信关系 + if (afsimScenario.getRelations() != null && !afsimScenario.getRelations().isEmpty()) { + platFormCommunicationMapper.insert(afsimScenario.getId(), afsimScenario.getRelations()); + } + return updated; + } else { + // 新增场景 + int inserted = sceneMapper.insert(afsimScenario); + // 确保获取到生成的 ID + if (afsimScenario.getId() != null && afsimScenario.getRelations() != null && !afsimScenario.getRelations().isEmpty()) { + // 存储通信关系 + platFormCommunicationMapper.insert(afsimScenario.getId(), afsimScenario.getRelations()); + } + return inserted; } - return insert(afsimScenario); } /** diff --git a/auto-solution-scene/src/main/resources/mapper/scene/PlatFormCommunicationMapper.xml b/auto-solution-scene/src/main/resources/mapper/scene/PlatFormCommunicationMapper.xml new file mode 100644 index 0000000..d745257 --- /dev/null +++ b/auto-solution-scene/src/main/resources/mapper/scene/PlatFormCommunicationMapper.xml @@ -0,0 +1,19 @@ + + + + + + + INSERT INTO platform_communication (scenary_id, command_platform, subordinate_platform, command_comm, subordinate_comm) + VALUES + + (#{scenaryId}, #{item.sourcePlatform.name}, #{item.targetPlatform.name}, #{item.sourceComponent.name}, #{item.targetComponent.name}) + + + + DELETE FROM platform_communication + WHERE scenary_id = #{scenaryId} + + \ No newline at end of file diff --git a/auto-solution-scene/src/main/resources/mapper/scene/SceneMapper.xml b/auto-solution-scene/src/main/resources/mapper/scene/SceneMapper.xml index b21489a..9044c61 100644 --- a/auto-solution-scene/src/main/resources/mapper/scene/SceneMapper.xml +++ b/auto-solution-scene/src/main/resources/mapper/scene/SceneMapper.xml @@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + INSERT INTO afsim_scenario (name, description, scenario_path, communication_graph) VALUES (#{name}, #{description}, #{scenarioPath}, #{communicationGraph}) diff --git a/modeler/src/style.less b/modeler/src/style.less index f4aef21..b4c09aa 100644 --- a/modeler/src/style.less +++ b/modeler/src/style.less @@ -1291,6 +1291,10 @@ } } +.ant-select:not(.ant-select-customize-input) .ant-select-selector{ + border: 1px solid #475f71 +} + .ant-input-affix-wrapper.ant-input-password input:-webkit-autofill, .ant-input-affix-wrapper.ant-input-password input:-webkit-autofill:hover, .ant-input-affix-wrapper.ant-input-password input:-webkit-autofill:focus, @@ -1641,4 +1645,190 @@ 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; + } + } + } \ No newline at end of file diff --git a/modeler/src/utils/event.ts b/modeler/src/utils/event.ts index abb89e3..369f3a6 100644 --- a/modeler/src/utils/event.ts +++ b/modeler/src/utils/event.ts @@ -1,7 +1,7 @@ /* * This file is part of the kernelstudio package. * - * (c) 2014-2025 zlin + * (c) 2014-2026 zlin * * For the full copyright and license information, please view the LICENSE file * that was distributed with this source code. @@ -23,14 +23,14 @@ export class EventError { export class EventListener { - private readonly _listeners: Record; + private _listeners: Record; constructor(listeners: Record = {}) { this._listeners = listeners; } all(): Record { - return {...this._listeners}; // 返回副本,避免外部直接修改 + return { ...this._listeners }; // 返回副本,避免外部直接修改 } has(name: string): boolean { @@ -55,16 +55,24 @@ export class EventListener { [...listeners].forEach(f => f(options)); } } + + clear(){ + for (const key in this._listeners) { + if (this._listeners.hasOwnProperty(key)) { + delete this._listeners[key]; + } + } + } } export const safePreventDefault = (event: any) => { if (event && typeof event.preventDefault === 'function') { event.preventDefault(); } -} +}; export const safeStopPropagation = (event: any) => { if (event && typeof event.stopPropagation === 'function') { event.stopPropagation(); } -} \ No newline at end of file +}; diff --git a/modeler/src/views/decision/algorithm/management.vue b/modeler/src/views/decision/algorithm/management.vue index d47e326..193ec07 100644 --- a/modeler/src/views/decision/algorithm/management.vue +++ b/modeler/src/views/decision/algorithm/management.vue @@ -274,8 +274,11 @@ const getAlgorithmTypeName = (type: NullableString): NullableString => { const load = () => { algorithms.value = []; algorithmsTotal.value = 0; - formRef.value?.resetFields(); - selectedAlgorithm.value = resolveItem(defaultAlgorithm); + + if(selectedAlgorithm.value.id <= 0){ + formRef.value?.resetFields(); + selectedAlgorithm.value = resolveItem(defaultAlgorithm); + } findAlgorithmsByQuery(query.value).then(r => { algorithms.value = r.rows ?? []; diff --git a/modeler/src/views/decision/api.ts b/modeler/src/views/decision/api.ts new file mode 100644 index 0000000..b1a4096 --- /dev/null +++ b/modeler/src/views/decision/api.ts @@ -0,0 +1,21 @@ +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2025 zlin + * + * 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 { BasicResponse } from '@/types'; +import type { PlatformListableResponse } from './types'; + +const req = HttpRequestClient.create({ + baseURL: '/api', +}); + + +export const findAllBasicPlatforms = (): Promise => { + return req.get('/system/firerule/platforms/basic'); +}; \ No newline at end of file diff --git a/modeler/src/views/decision/communication/api.ts b/modeler/src/views/decision/communication/api.ts index 9bb20a1..9f41d12 100644 --- a/modeler/src/views/decision/communication/api.ts +++ b/modeler/src/views/decision/communication/api.ts @@ -8,7 +8,8 @@ */ import { HttpRequestClient } from '@/utils/request'; -import type { PlatformWithComponentsResponse, ScenarioPageableResponse, ScenarioRequest, Scenario } from './types'; +import type { Scenario, ScenarioPageableResponse, ScenarioRequest } from './types'; +import type { PlatformWithComponentsResponse } from '../types'; import type { BasicResponse } from '@/types'; const req = HttpRequestClient.create({ diff --git a/modeler/src/views/decision/communication/communication.vue b/modeler/src/views/decision/communication/communication.vue index 061844a..c4b3362 100644 --- a/modeler/src/views/decision/communication/communication.vue +++ b/modeler/src/views/decision/communication/communication.vue @@ -46,6 +46,7 @@ \ No newline at end of file diff --git a/modeler/src/views/decision/rule/api.ts b/modeler/src/views/decision/rule/api.ts index 30b1d34..d7d2ae3 100644 --- a/modeler/src/views/decision/rule/api.ts +++ b/modeler/src/views/decision/rule/api.ts @@ -9,6 +9,7 @@ import { HttpRequestClient } from '@/utils/request'; import type { FireRule, FireRulePageableResponse, FireRuleRequest } from './types'; +import type { PlatformWithComponentsResponse } from '../types'; import type { BasicResponse } from '@/types'; const req = HttpRequestClient.create({ @@ -31,5 +32,8 @@ export const deleteFireRule = (id: number): Promise => { return req.delete(`/system/rule/${id}`); }; +export const findAllPlatformWithComponents = (): Promise => { + return req.get(`/system/firerule/platforms`); +}; \ No newline at end of file diff --git a/modeler/src/views/decision/rule/management.vue b/modeler/src/views/decision/rule/management.vue index ab2d29a..c802453 100644 --- a/modeler/src/views/decision/rule/management.vue +++ b/modeler/src/views/decision/rule/management.vue @@ -32,9 +32,7 @@
- -
- 通用 @@ -73,43 +70,92 @@ + - + +
+
+ + + + + + + + + + + + +
+
+
+ - + +
+
+ + + + + + + + + + + + +
+
+
- + 保存规则 - 删除规则 - -
-
-
-
\ No newline at end of file diff --git a/modeler/src/views/decision/rule/store.ts b/modeler/src/views/decision/rule/store.ts new file mode 100644 index 0000000..5b688b9 --- /dev/null +++ b/modeler/src/views/decision/rule/store.ts @@ -0,0 +1,64 @@ +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +import { onMounted, ref, type Ref } from 'vue'; +import type { Platform, PlatformComponent, PlatformWithComponents, PlatformWithComponentsResponse } from '../types'; +import { findAllPlatformWithComponents } from './api'; + +const loading: Ref = ref(true); +const platforms: Ref = ref([]); +const platformMap: Ref> = ref>(new Map()); +const componentMap: Ref> = ref>(new Map()); +const loaded: Ref = ref(false); + +export interface UsePlatformComponentsReturn { + loading: Ref; + platforms: Ref; + platformMap: Ref>; + componentMap: Ref>; + loaded: Ref; +} + +export const usePlatformComponents = (): UsePlatformComponentsReturn => { + const load = () => { + if (!loaded.value) { + loading.value = true; + platformMap.value.clear(); + componentMap.value.clear(); + + findAllPlatformWithComponents() + .then((res: PlatformWithComponentsResponse) => { // 显式标注响应类型 + platforms.value = res.data || []; + platforms.value.forEach(platform => { + platformMap.value.set(platform.id, platform); + platform.components?.forEach(component => { + componentMap.value.set(component.id, component); + }); + }); + loaded.value = true; + }) + .catch((err: unknown) => { + console.error('加载平台组件失败:', err); + }) + .finally(() => { + loading.value = false; + }); + } + }; + + onMounted(() => load()); + + return { + loading, + platforms, + platformMap, + componentMap, + loaded, + }; +}; \ No newline at end of file diff --git a/modeler/src/views/decision/rule/types.ts b/modeler/src/views/decision/rule/types.ts index 37c80a1..721326b 100644 --- a/modeler/src/views/decision/rule/types.ts +++ b/modeler/src/views/decision/rule/types.ts @@ -8,6 +8,7 @@ */ import type { NullableString, PageableResponse } from '@/types'; +import type { PlatformComponentPayload } from '../types'; export interface FireRule { id: number, @@ -17,8 +18,10 @@ export interface FireRule { sceneType: Number | null, // 触发条件(JSON格式) conditions: NullableString, - // 响应动作(JSON格式) - actions: NullableString, + conditionsArray: PlatformComponentPayload[], + // 响应动作(JSON格式) + actions: NullableString, + actionsArray: PlatformComponentPayload[], // 优先级(数值越小优先级越高) priority: number, // 是否启用(0禁用,1启用) diff --git a/modeler/src/views/decision/types/index.ts b/modeler/src/views/decision/types/index.ts new file mode 100644 index 0000000..0a425d0 --- /dev/null +++ b/modeler/src/views/decision/types/index.ts @@ -0,0 +1,10 @@ +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +export * from './platform' \ No newline at end of file diff --git a/modeler/src/views/decision/types/platform.ts b/modeler/src/views/decision/types/platform.ts new file mode 100644 index 0000000..ab834a5 --- /dev/null +++ b/modeler/src/views/decision/types/platform.ts @@ -0,0 +1,47 @@ +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +import type { ApiDataResponse, NullableString } from '@/types'; + +export interface Platform { + id: number, + name: NullableString, + description: NullableString, + scenarioId: number, + + [key: string]: unknown; +} + +export interface PlatformListableResponse extends ApiDataResponse { + +} + +export interface PlatformComponent { + id: number, + name: NullableString, + type: NullableString, + description: NullableString, + platformId: number, + [key: string]: unknown; +} + +export interface PlatformWithComponents extends Platform { + components: PlatformComponent[], + [key: string]: unknown; +} + +export interface PlatformComponentPayload { + platform: Platform | null; + component: PlatformComponent | null; + [key: string]: unknown; +} + +export interface PlatformWithComponentsResponse extends ApiDataResponse { + +} diff --git a/modeler/types/components.d.ts b/modeler/types/components.d.ts index a3af590..2e9d007 100644 --- a/modeler/types/components.d.ts +++ b/modeler/types/components.d.ts @@ -44,6 +44,7 @@ declare module 'vue' { ASelect: typeof import('ant-design-vue/es')['Select'] ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] ASpace: typeof import('ant-design-vue/es')['Space'] + ASwitch: typeof import('ant-design-vue/es')['Switch'] ATabPane: typeof import('ant-design-vue/es')['TabPane'] ATabs: typeof import('ant-design-vue/es')['Tabs'] ATextarea: typeof import('ant-design-vue/es')['Textarea'] @@ -87,6 +88,7 @@ declare global { const ASelect: typeof import('ant-design-vue/es')['Select'] const ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] const ASpace: typeof import('ant-design-vue/es')['Space'] + const ASwitch: typeof import('ant-design-vue/es')['Switch'] const ATabPane: typeof import('ant-design-vue/es')['TabPane'] const ATabs: typeof import('ant-design-vue/es')['Tabs'] const ATextarea: typeof import('ant-design-vue/es')['Textarea'] diff --git a/pom.xml b/pom.xml index 9cd896a..c510c05 100644 --- a/pom.xml +++ b/pom.xml @@ -274,6 +274,29 @@ ${project.build.sourceEncoding} + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 11 + 11 + + + + org.projectlombok + lombok + 1.18.34 + + + org.mapstruct + mapstruct-processor + 1.5.5.Final + + + + +