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