Commit d8b9fe8f authored by shaoan123's avatar shaoan123

对接新运维中任务调度接口

parent f2c099df
Pipeline #27334 passed with stages
in 23 minutes 4 seconds
......@@ -32,7 +32,6 @@ const AddModal = props => {
const { Item } = Form;
// 提交
const onSubmit = () => {
console.log('deviceList', deviceList);
form.validateFields().then(validate => {
if (validate) {
let obj = form.getFieldsValue();
......@@ -50,14 +49,13 @@ const AddModal = props => {
PredictDateTo: "",
PredictName: obj.PredictName,
Remarks: obj.Remarks,
DeviceDetails:card
DeviceDetails: card
}
// card.length ? query.DeviceDetails = card : delete query.DeviceDetails
type === 'edit' ? (query.ID = formObj.ID) && (api = editPredictOptions) : delete query.ID && (api = addPredictOptions)
setLoading(true);
api(query).then(res => {
setLoading(false);
console.log('res', res);
if (res.errMsg === '') {
form.resetFields();
callBackSubmit();
......@@ -352,20 +350,20 @@ const AddModal = props => {
<Row gutter='24' >
<Col span={12}>
<Item
label="最值"
name={'max' + index}
rules={[{ required: true, message: '请输入最值' }]}
label="最值"
name={'min' + index}
rules={[{ required: true, message: '请输入最值' }]}
>
<Input style={{width:'98%'}} placeholder="请输入最大值" onChange={(value) => inputMax(value, index)} index={index} allowClear />
<Input placeholder="请输入最小值" onChange={(value) => inputMin(value, index)} index={index} allowClear />
</Item>
</Col>
<Col span={12}>
<Item
label="最值"
name={'min' + index}
rules={[{ required: true, message: '请输入最值' }]}
label="最值"
name={'max' + index}
rules={[{ required: true, message: '请输入最值' }]}
>
<Input placeholder="请输入最小值" onChange={(value) => inputMin(value, index)} index={index} allowClear />
<Input style={{ width: '98%' }} placeholder="请输入最大值" onChange={(value) => inputMax(value, index)} index={index} allowClear />
</Item>
</Col>
</Row>
......
......@@ -257,7 +257,7 @@ const AddModal = props => {
return (
<Modal
title={`${type === 'add' ? '预测方案新增' : '编辑'}`}
title={`${type === 'add' ? '策略下发新增' : '编辑'}`}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '150px' }}
width="800px"
......
......@@ -2,7 +2,7 @@ import { Space, Table, Button, Popconfirm, notification ,Spin} from 'antd';
import React, { useState, useEffect } from 'react';
import styles from '../policiesIssued.less'
import {
taskOptionsList, getIotDeviceType, getStrategyInfo, deleteStrategyOptions
getIotDeviceType, getStrategyInfo, deleteStrategyOptions
} from '@/services/intelligence/api';
import AddModal from './AddModal'
const VectorData = props => {
......
......@@ -10,7 +10,7 @@ import locale from 'antd/lib/date-picker/locale/zh_CN'
import 'moment/locale/zh-cn'
moment.locale('zh-cn')
import {
getEquipmentInfo
addTaskOptions, getPredictInfo, getStrategyInfo, updateTaskOptions
} from '@/services/intelligence/api';
......@@ -20,65 +20,70 @@ const AddModal = props => {
const { callBackSubmit = () => { }, type, formObj, visible, deviceType } = props;
const [loading, setLoading] = useState(false);
const [isloading, setIsLoading] = useState(false);
const [deviceCodes, setDeviceCode] = useState([]); //设备编码列表
const [timeType, setTimeType] = useState(['分钟', '小时', '天']);
const [urlType, setUrlType] = useState('');
const [scenarioList, setScenarioList] = useState([]);
const [intervalType, setIntervalType] = useState('分钟')
const [Intervals, setIntervals] = useState('')
const [StrategyId, setStrategyId] = useState('')
const [form] = Form.useForm();
const { Item } = Form;
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
let obj = form.getFieldsValue();
let DateFrom = moment(obj.Date[0]).format('YYYY-MM-DD')
let DateTo = moment(obj.Date[1]).format('YYYY-MM-DD')
let apiUrl = type === 'add' ? addTaskOptions : updateTaskOptions
setLoading(true);
if (type === 'add') {
} else if (type === 'edit') {
handleEdit();
}
apiUrl([{
...obj, StrategyId
}]).then(res => {
setLoading(false);
if (res.errMsg === '') {
form.resetFields();
callBackSubmit();
prompt('success', `${type === 'add' ? "增加成功" : "编辑成功"}`)
}
else {
prompt('fail', res.errMsg)
}
}).catch(err => {
setLoading(false);
})
}
});
};
const prompt = (type, content) => {
if (type == 'success') {
notification.success({
message: '提示',
duration: 3,
description: content,
});
}
else {
notification.error({
message: '提示',
duration: 3,
description: content,
});
}
}
const handleEdit = () => {
// SetServiceConfig({
// servicename: serviceName,
// terminalType: 'base',
// isBaseMap: true,
// jsonCfg: JSON.stringify(query)
// })
// .then(res => {
// setLoading(false);
// if (res.success) {
// form.resetFields();
// callBackSubmit();
// notification.success({
// message: '提示',
// duration: 3,
// description: res.message || '编辑成功',
// });
// } else {
// notification.error({
// message: '提示',
// duration: 3,
// description: res.message || '编辑失败',
// });
// }
// })
// .catch(err => setLoading(false));
};
const onFinish = value => { };
useEffect(() => {
switch (type) {
case 'add':
form.setFieldsValue({ ...formObj });
setIntervals()
form.resetFields();
break;
case 'edit':
form.setFieldsValue({ ...formObj });
setUrlType(formObj.TaskType)
setStrategyId(formObj.AlgorithmId)
handleTaskType(formObj.TaskType)
setIntervals(formObj.Interval)
form.setFieldsValue({ ...formObj, AlgorithmName: formObj.Name });
break;
default:
break;
......@@ -87,8 +92,31 @@ const AddModal = props => {
const handleTaskType =(value)=>{
console.log(value,'value');
const handleTaskType = (value) => {
console.log('formObj', formObj);
switch (value) {
case '预测':
setUrlType('predict')
getPredictInfo().then(res => {
res.getMe.length && setScenarioList(res.getMe)
})
break;
case '控制':
setUrlType('control')
getStrategyInfo().then(res => {
res.getMe.length && setScenarioList(res.getMe)
})
break;
case 'http':
setUrlType('url')
break;
default:
setUrlType('predict')
}
}
const inputInterval = (e) => {
setIntervals(e.target.value)
}
const layout = {
layout: 'horizontal',
......@@ -100,12 +128,14 @@ const AddModal = props => {
},
};
const handleChange = (value, option) => {
setStrategyId(option.id)
}
return (
<Modal
title={`${type === 'add' ? '元数据发布' : '编辑'}`}
title={`${type === 'add' ? '任务新增' : '编辑'}`}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '150px' }}
width="700px"
......@@ -140,24 +170,29 @@ const AddModal = props => {
<Select.Option value='http'>http</Select.Option>
</Select>
</Item>
<Item
{urlType === 'predict' || urlType === 'control' || urlType === '' ? <Item
label="方案名称"
name="AlgorithmName"
>
<Select >
{/* {workList.length ? workList.map((item, index) => { return <Option key={index} value={item.name}>{item.name}</Option> }) : ''} */}
<Select onChange={(value, option) => handleChange(value, option)}>
{scenarioList.length ? scenarioList.map((item, index) => { return <Select.Option key={index} id={item.ID} value={urlType === 'predict' ? item.PredictName : item.StrategyName}>{urlType === 'predict' ? item.PredictName : item.StrategyName}</Select.Option> }) : ''}
</Select>
</Item>
</Item> : <Item
label="url"
name="url"
>
<Input placeholder="请输入URL" allowClear />
</Item>}
<Item
label="调度间隔(Cron)"
name="Interval"
rules={[{ required: true, message: '请输入间隔' }]}
>
<div className={styles.predict}>
<Input placeholder="请输入间隔" allowClear />
<Input placeholder="请输入间隔" allowClear onChange={(value) => inputInterval(value)} value={Intervals} />
<a className={styles.corn} target="view_window" href="https://cron.qqe2.com/">cron在线生成</a>
</div>
</Item>
</Item>
<Item
label="描述"
name="Describe"
......
......@@ -2,7 +2,7 @@ import { Space, Table, Button, Popconfirm, notification } from 'antd';
import React, { useState, useEffect } from 'react';
import styles from './taskScheduling.less'
import {
deleteTaskOptions, taskOptionsList, getIotDeviceType, algorithmList, getEquipmentInfo
deleteTaskOptions, taskOptionsList, getIotDeviceType
} from '@/services/intelligence/api';
import AddModal from './AddModal'
const VectorData = props => {
......@@ -17,7 +17,6 @@ const VectorData = props => {
const columns = [
{
title: '序号',
dataIndex: 'index',
align: 'center',
render: (text, record, index) => (
<Space>
......@@ -25,12 +24,6 @@ const VectorData = props => {
</Space>
)
},
{
title: '场景名称',
dataIndex: 'AlgorithmName',
key: 'AlgorithmName',
align: 'center'
},
{
title: '任务名称',
dataIndex: 'TaskName',
......@@ -61,12 +54,6 @@ const VectorData = props => {
key: 'Describe',
align: 'center'
},
{
title: '访问方式',
dataIndex: 'RequestType',
key: 'RequestType',
align: 'center'
},
{
title: '编辑',
align: 'center',
......@@ -83,7 +70,7 @@ const VectorData = props => {
</Button>
<div onClick={e => e.stopPropagation()}>
<Popconfirm
title="是否删除该矢量数据?"
title="是否删除该任务?"
okText="确认"
cancelText="取消"
onConfirm={() => {
......@@ -108,24 +95,19 @@ const VectorData = props => {
setFlag(flag + 1)
};
const delConfirm = (record) => {
let query = {
serviceName: record.serviceName,
_version: 9999,
solution: solutionNames
}
deleteTaskOptions(query).then(res => {
if (res.success) {
deleteTaskOptions([record]).then(res => {
if (res.errMsg === '') {
setFlag(flag + 1)
notification.success({
message: '提示',
duration: 3,
description: '删除元数据成功',
description: '删除成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: '删除元数据失败',
description: res.errMsg,
});
};
})
......@@ -147,12 +129,10 @@ const VectorData = props => {
const renderTile = () => {
setTreeLoading(true)
const getIotDevice = getIotDeviceType()
const algorithm = algorithmList()
const taskOption = taskOptionsList()
Promise.all([getIotDevice, algorithm, taskOption]).then(res => {
console.log('res', res);
Promise.all([getIotDevice, taskOption]).then(res => {
res[0].getMe && res[0].getMe.length && setDeviceType(res[0].getMe)
res[2].getMe && res[2].getMe.length && setTileData(res[2].getMe)
res[1].getMe && res[1].getMe.length && setTileData(res[1].getMe)
setTreeLoading(false)
}).catch(err => {
setTreeLoading(false)
......@@ -174,9 +154,10 @@ const VectorData = props => {
columns={columns}
dataSource={tileData}
bordered
rowKey="Id"
scroll={{ y: 400 }}
rowKey="TaskName"
scroll={{ y: 600 }}
pagination={{
pageSize: '10' ,
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`
......
......@@ -175,11 +175,15 @@ export const SetServiceConfig = query =>
// export const SetServiceConfig = query =>
// get(`${PUBLISH_SERVICE}/Maplayer/SetServiceConfig`, query);
//获取方矢量数据列表
// 获取方矢量数据列表
export const GetVectorService = () =>
get(`${CITY_SERVICE}/OMS.svc/D_GetVectorService`, { _version: 9999 });
//获取方矢量数据列表
// export const GetVectorService = () =>
// get(`${PUBLISH_SERVICE}/Maplayer/GetVectorService`, { _version: 9999 });
//获取元数据的工作空间列表
export const GetGISServerMapList = query =>
get(`${CITY_SERVICE}/OMS.svc/D_GetGISServerMapList`, query);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment