Compare commits
3 Commits
9d54395c29
...
8b3fe9b548
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b3fe9b548 | ||
|
|
db30244cd1 | ||
|
|
c9bc62fb8c |
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -38,6 +38,9 @@ public class Algorithm
|
|||||||
@Excel(name = "算法配置")
|
@Excel(name = "算法配置")
|
||||||
private String algoConfig;
|
private String algoConfig;
|
||||||
|
|
||||||
|
/** 算法配置 */
|
||||||
|
private List<AlgorithmConfig> algoConfigList;
|
||||||
|
|
||||||
/** 算法参数定义信息 */
|
/** 算法参数定义信息 */
|
||||||
private List<AlgorithmParam> algorithmParamList;
|
private List<AlgorithmParam> algorithmParamList;
|
||||||
|
|
||||||
@@ -111,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)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<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="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">
|
||||||
@@ -26,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, algo_config 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">
|
||||||
@@ -60,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<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="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>
|
||||||
@@ -67,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<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="algoConfig != null">#{algoConfig},</if>
|
||||||
|
<if test="algoConfigList != null">#{algoConfigList,typeHandler=com.solution.algo.AlgorithmConfigTypeHandler},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -78,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<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="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>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export const routes: RouteRecordRaw[] = [
|
|||||||
name: 'decision-algorithm-management',
|
name: 'decision-algorithm-management',
|
||||||
path: '/app/decision/algorithm/management',
|
path: '/app/decision/algorithm/management',
|
||||||
meta: {
|
meta: {
|
||||||
title: '规则管理',
|
title: '指挥决策规则库管理',
|
||||||
},
|
},
|
||||||
component: () => import('@/views/decision/algorithm/management.vue'),
|
component: () => import('@/views/decision/algorithm/management.vue'),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1370,11 +1370,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-btn-default {
|
|
||||||
background: #7dd3f9;
|
|
||||||
border-color: #7dd3f9;
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-field {
|
.btn-field {
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
@@ -1560,8 +1555,90 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.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-default {
|
||||||
&.ant-btn-dangerous{
|
&.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;
|
background: transparent;
|
||||||
|
border-color: #b5b39d;
|
||||||
|
color: #b5b39d;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,10 @@ export const createAlgorithm = (algorithm: Algorithm): Promise<BasicResponse> =>
|
|||||||
return req.postJson('/algo/algorithm', algorithm);
|
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> => {
|
export const updateAlgorithm = (algorithm: Algorithm): Promise<BasicResponse> => {
|
||||||
return req.putJson('/algo/algorithm', algorithm);
|
return req.putJson('/algo/algorithm', algorithm);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,3 +21,22 @@ export const algorithmTypes = [
|
|||||||
name: '队形',
|
name: '队形',
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const algorithmConfigOperations = [
|
||||||
|
{
|
||||||
|
type: '+',
|
||||||
|
name: '加',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '-',
|
||||||
|
name: '减',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '*',
|
||||||
|
name: '乘',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: '/',
|
||||||
|
name: '除',
|
||||||
|
},
|
||||||
|
]
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
:rules="[{ required: true, message: '请输入业务类型!', trigger: ['input', 'change'] }]"
|
:rules="[{ required: true, message: '请输入业务类型!', trigger: ['input', 'change'] }]"
|
||||||
:name="['type']"
|
:name="['type']"
|
||||||
>
|
>
|
||||||
<a-select allow-clear v-model:value="selectedAlgorithm.type" @change="(v: any)=> selectedAlgorithm.type = v">
|
<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-option v-for="a in algorithmTypes" :value="a.type">{{ a.name }}</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@@ -81,14 +81,6 @@
|
|||||||
<a-input v-model:value="selectedAlgorithm.codePath" placeholder="请输入算法文件路径" />
|
<a-input v-model:value="selectedAlgorithm.codePath" placeholder="请输入算法文件路径" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item
|
|
||||||
label="算法配置"
|
|
||||||
:rules="[{ required: true, message: '请输入算法配置', trigger: ['input', 'change'] }]"
|
|
||||||
:name="['algoConfig']"
|
|
||||||
>
|
|
||||||
<a-textarea v-model:value="selectedAlgorithm.algoConfig" placeholder="请输入算法配置" />
|
|
||||||
</a-form-item>
|
|
||||||
|
|
||||||
<a-form-item
|
<a-form-item
|
||||||
label="算法描述"
|
label="算法描述"
|
||||||
:rules="[{ required: false, message: '请输入算法描述', trigger: ['input', 'change'] }]"
|
:rules="[{ required: false, message: '请输入算法描述', trigger: ['input', 'change'] }]"
|
||||||
@@ -127,11 +119,51 @@
|
|||||||
</a-form-item-rest>
|
</a-form-item-rest>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item
|
||||||
|
label="算法配置"
|
||||||
|
:rules="[{ required: false, message: '请输入算法配置', trigger: ['input', 'change'] }]"
|
||||||
|
:name="['algoConfig']"
|
||||||
|
>
|
||||||
|
<a-form-item-rest>
|
||||||
|
<div class="ks-algorithm-param-list">
|
||||||
|
<div class="ks-algorithm-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-algorithm-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
|
<a-form-item
|
||||||
:wrapper-col="{offset: 6}"
|
:wrapper-col="{offset: 6}"
|
||||||
>
|
>
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-button @click="handleSave">保存规则</a-button>
|
<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
|
<a-popconfirm
|
||||||
v-if="selectedAlgorithm && selectedAlgorithm.id > 0"
|
v-if="selectedAlgorithm && selectedAlgorithm.id > 0"
|
||||||
title="确定删除?"
|
title="确定删除?"
|
||||||
@@ -159,10 +191,10 @@ import { onMounted, ref } from 'vue';
|
|||||||
import { type FormInstance, message } from 'ant-design-vue';
|
import { type FormInstance, message } from 'ant-design-vue';
|
||||||
import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
|
import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
|
||||||
import Layout from '../layout.vue';
|
import Layout from '../layout.vue';
|
||||||
import { createAlgorithm, deleteAlgorithm, findAlgorithmsByQuery, updateAlgorithm } from './api';
|
import { createAlgorithm, deleteAlgorithm, findAlgorithmsByQuery, updateAlgorithm, runAlgorithm } from './api';
|
||||||
import type { Algorithm, AlgorithmParam, AlgorithmRequest } from './types';
|
import type { Algorithm, AlgorithmParam, AlgorithmRequest } from './types';
|
||||||
import { substring } from '@/utils/strings';
|
import { substring } from '@/utils/strings';
|
||||||
import { algorithmTypes } from './config';
|
import { algorithmTypes,algorithmConfigOperations } from './config';
|
||||||
import type { NullableString } from '@/types';
|
import type { NullableString } from '@/types';
|
||||||
|
|
||||||
const query = ref<Partial<AlgorithmRequest>>({
|
const query = ref<Partial<AlgorithmRequest>>({
|
||||||
@@ -192,14 +224,46 @@ const defaultAlgorithm: Algorithm = {
|
|||||||
description: null,
|
description: null,
|
||||||
// 算法配置
|
// 算法配置
|
||||||
algoConfig: null,
|
algoConfig: null,
|
||||||
|
// 算法配置
|
||||||
|
algoConfigList: [],
|
||||||
// 算法参数定义信息
|
// 算法参数定义信息
|
||||||
algorithmParamList: [
|
algorithmParamList: [
|
||||||
{ ...defaultAlgorithmParam },
|
{ ...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 algorithms = ref<Algorithm[]>([]);
|
||||||
const algorithmsTotal = ref<number>(0);
|
const algorithmsTotal = ref<number>(0);
|
||||||
const selectedAlgorithm = ref<Algorithm>(JSON.parse(JSON.stringify(defaultAlgorithm)));
|
const selectedAlgorithm = ref<Algorithm>(resolveItem(defaultAlgorithm));
|
||||||
const formRef = ref<FormInstance | null>(null);
|
const formRef = ref<FormInstance | null>(null);
|
||||||
|
|
||||||
const getAlgorithmTypeName = (type: NullableString): NullableString => {
|
const getAlgorithmTypeName = (type: NullableString): NullableString => {
|
||||||
@@ -211,7 +275,7 @@ const load = () => {
|
|||||||
algorithms.value = [];
|
algorithms.value = [];
|
||||||
algorithmsTotal.value = 0;
|
algorithmsTotal.value = 0;
|
||||||
formRef.value?.resetFields();
|
formRef.value?.resetFields();
|
||||||
selectedAlgorithm.value = JSON.parse(JSON.stringify(defaultAlgorithm));
|
selectedAlgorithm.value = resolveItem(defaultAlgorithm);
|
||||||
|
|
||||||
findAlgorithmsByQuery(query.value).then(r => {
|
findAlgorithmsByQuery(query.value).then(r => {
|
||||||
algorithms.value = r.rows ?? [];
|
algorithms.value = r.rows ?? [];
|
||||||
@@ -219,19 +283,13 @@ const load = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleCreate = () => {
|
const handleCreate = () => {
|
||||||
selectedAlgorithm.value = JSON.parse(JSON.stringify(defaultAlgorithm));
|
selectedAlgorithm.value = resolveItem(defaultAlgorithm);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelect = (item: Algorithm) => {
|
const handleSelect = (item: Algorithm) => {
|
||||||
let newItem = JSON.parse(JSON.stringify(item))
|
selectedAlgorithm.value = resolveItem(item);
|
||||||
if (!newItem.algorithmParamList) {
|
|
||||||
newItem.algorithmParamList = [];
|
|
||||||
}
|
|
||||||
if (newItem.algorithmParamList.length === 0) {
|
|
||||||
newItem.algorithmParamList.push({ ...defaultAlgorithmParam });
|
|
||||||
}
|
|
||||||
selectedAlgorithm.value = newItem;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
@@ -248,6 +306,20 @@ const handleMinus = (index: number) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 = () => {
|
const handleDelete = () => {
|
||||||
if (selectedAlgorithm.value && selectedAlgorithm.value.id > 0) {
|
if (selectedAlgorithm.value && selectedAlgorithm.value.id > 0) {
|
||||||
deleteAlgorithm(selectedAlgorithm.value.id).then(r => {
|
deleteAlgorithm(selectedAlgorithm.value.id).then(r => {
|
||||||
@@ -265,11 +337,26 @@ const handleSave = () => {
|
|||||||
if (formRef.value) {
|
if (formRef.value) {
|
||||||
formRef.value.validate().then(() => {
|
formRef.value.validate().then(() => {
|
||||||
let res = null;
|
let res = null;
|
||||||
if (selectedAlgorithm.value.id > 0) {
|
let savedValue: Algorithm = JSON.parse(JSON.stringify(selectedAlgorithm.value)) as any as Algorithm;
|
||||||
res = updateAlgorithm(selectedAlgorithm.value);
|
let algoConfig = '';
|
||||||
} else {
|
if( savedValue.algoConfigList ){
|
||||||
res = createAlgorithm(selectedAlgorithm.value);
|
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) {
|
if (res) {
|
||||||
res.then(r => {
|
res.then(r => {
|
||||||
if (r.code === 200) {
|
if (r.code === 200) {
|
||||||
@@ -284,6 +371,20 @@ const handleSave = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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) => {
|
const handleChange = (page: number, pageSize: number) => {
|
||||||
query.value.pageNum = page;
|
query.value.pageNum = page;
|
||||||
query.value.pageSize = pageSize;
|
query.value.pageSize = pageSize;
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ export interface AlgorithmParam {
|
|||||||
description: NullableString,
|
description: NullableString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AlgorithmConfig {
|
||||||
|
name: NullableString,
|
||||||
|
operation: NullableString,
|
||||||
|
}
|
||||||
|
|
||||||
export interface Algorithm {
|
export interface Algorithm {
|
||||||
|
|
||||||
id: number,
|
id: number,
|
||||||
@@ -33,6 +38,8 @@ export interface Algorithm {
|
|||||||
description: NullableString,
|
description: NullableString,
|
||||||
// 算法配置
|
// 算法配置
|
||||||
algoConfig: NullableString,
|
algoConfig: NullableString,
|
||||||
|
// 算法配置
|
||||||
|
algoConfigList: AlgorithmConfig[],
|
||||||
// 算法参数定义信息
|
// 算法参数定义信息
|
||||||
algorithmParamList: AlgorithmParam[]
|
algorithmParamList: AlgorithmParam[]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user