Commit 528d33ac authored by shaoan123's avatar shaoan123

对接人工智能方案管理接口

parent e45a7f6d
Pipeline #27247 skipped with stages
# PUBLIC_PATH = reactOMS, 默认转发 /cityinterface
PROXY=/Cityinterface:http://192.168.10.150:8777;/Publish:http://192.168.10.150:8777;/Web4:http://192.168.10.150:8777;/CityTemp:http://192.168.10.150:8777
# PROXY=/Cityinterface:http://192.168.10.150:8777;/Publish:http://192.168.10.150:8777;/Web4:http://192.168.10.150:8777;/CityTemp:http://192.168.10.150:8777
PROXY=/Cityinterface:http://192.168.12.121:8082;/Publish:http://192.168.12.121:8082;/Web4:http://192.168.12.121:8082;/CityTemp:http://192.168.12.121:8082
# 可设置第二个代理,test为转发前缀,后面为代理转发的地址
# PROXY2 = test : http://localhost:8006/
......
......@@ -13,6 +13,9 @@
background-color: #ffffff;
color: #000000;
}
.ant-card-body{
padding-bottom: 0 !important;
}
}
.predict{
display: flex;
......@@ -31,4 +34,13 @@
margin-left:1rem;
text-decoration: underline;
width: 8rem;
}
.deviceList{
max-height: 20rem;
overflow-y: scroll;
}
.deleteItem{
position:relative;
right: -100%;
top: -8rem;
}
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, notification, DatePicker, Spin } from 'antd';
import { Form, Modal, Input, Select, notification, DatePicker, Spin, Button, Card, Row, Col } from 'antd';
import styles from '../policiesIssued.less'
// import moment from 'moment';
// import locale from 'antd/es/date-picker/locale/zh_CN';
......@@ -10,8 +10,9 @@ import locale from 'antd/lib/date-picker/locale/zh_CN'
import 'moment/locale/zh-cn'
moment.locale('zh-cn')
import {
getEquipmentInfo
getEquipmentInfo, getQutaList, addPredictOptions, getSceneNameInfo, editPredictOptions
} from '@/services/intelligence/api';
import { DeleteOutlined } from '@ant-design/icons';
const { RangePicker } = DatePicker;
......@@ -21,91 +22,150 @@ const AddModal = props => {
const [loading, setLoading] = useState(false);
const [isloading, setIsLoading] = useState(false);
const [deviceCodes, setDeviceCode] = useState([]); //设备编码列表
const [deviceList, setDeviceList] = useState([]); //设备列表
const [card, setCard] = useState([]); //卡片列表值
const [timeType, setTimeType] = useState(['分钟', '小时', '天']);
const [intervalType, setIntervalType] = useState('分钟')
const [CycleValue, setCycleValue] = useState('')
const [sceneList, setSceneList] = useState([])
const [form] = Form.useForm();
const { Item } = Form;
// 提交
const onSubmit = () => {
console.log('deviceList', deviceList);
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')
setLoading(true);
if (type === 'add') {
} else if (type === 'edit') {
handleEdit();
let DateFrom = moment(obj.time[0]).format('YYYY-MM-DD')
let DateTo = moment(obj.time[1]).format('YYYY-MM-DD')
let api = addPredictOptions
let query = {
SceneName: obj.SceneName,
Cycle: intervalType,
CycleValue: CycleValue,
DateFrom: DateFrom,
DateTo: DateTo,
DeviceType: obj.DeviceType,
PredictDateFrom: "",
PredictDateTo: "",
PredictName: obj.PredictName,
Remarks: obj.Remarks,
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();
prompt('success', `${type === 'add' ? "增加成功" : "编辑成功"}`)
} else {
prompt('fail', res.errMsg)
}
})
}
});
};
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 prompt = (type, content) => {
if (type == 'success') {
notification.success({
message: '提示',
duration: 3,
description: content,
});
}
else {
notification.error({
message: '提示',
duration: 3,
description: content,
});
}
}
const onFinish = value => { };
useEffect(() => {
switch (type) {
case 'add':
deviceType.length && getDeviceCode(deviceType[0].DeviceType)
initData()
break;
case 'edit':
form.setFieldsValue({ ...formObj });
initData()
break;
default:
break;
}
}, [visible]);
//页面初始化
const initData = () => {
if (type === 'add') {
form.resetFields();
setCycleValue('');
setIntervalType('');
setCard([])
setDeviceList([])
}
else {
setDeviceList([])
form.setFieldsValue({ time: [moment(formObj.DateFrom, "YYYYMMDD"), moment(formObj.DateTo, "YYYYMMDD")], ...formObj });
setCycleValue(formObj.CycleValue);
setIntervalType(formObj.Cycle);
if (formObj.DeviceDetails.length) {
getEquipmentInfo(formObj.DeviceType).then(respone => {
respone.getMe.length && respone.getMe[0].DeviceList.length && setDeviceCode(respone.getMe[0].DeviceList)
let arr = [...deviceList]
formObj.DeviceDetails.map((item, index) => {
arr[index] = {}
arr[index].code = respone.getMe.length ? respone.getMe[0].DeviceList : []
form.setFieldsValue({
[`deviceCode${index}`]: item.DeviceCode,
[`indextr${index}`]: item.PointAddress,
[`max${index}`]: item.MaxValue,
[`min${index}`]: item.MinValue
})
})
setCard(formObj.DeviceDetails)
setDeviceList(arr)
setLoading(false)
})
}
}
const getDeviceCode = (type) => {
getSceneNameInfo().then(res => {
res.getMe.length && setSceneList(res.getMe)
})
}
//获取设备编码
const getDeviceCode = () => {
setLoading(false)
getEquipmentInfo(type).then(respone => {
const divProps = [];
respone.getMe[0].DeviceList.map((item) => {
divProps.push({ disabled: false, value: item.Code, pid: item.PointAddressID })
})
console.log('respone', divProps);
respone.getMe[0].DeviceList.length && setDeviceCode(divProps)
form.setFieldsValue({
deviceType: deviceType[0].DeviceType
});
let obj = form.getFieldsValue();
getEquipmentInfo(obj.DeviceType).then(respone => {
respone.getMe.length && respone.getMe[0].DeviceList.length && setDeviceCode(respone.getMe[0].DeviceList)
if (deviceList.length) {
let arr = [...deviceList]
arr.map((item, index) => {
arr[index].code = respone.getMe.length ? respone.getMe[0].DeviceList : []
arr[index].indexStr = ''
form.setFieldsValue({
[`deviceCode${index}`]: '',
[`indextr${index}`]: '',
[`max${index}`]: '',
[`min${index}`]: ''
})
})
setDeviceList(arr)
}
setLoading(false)
})
}
const layout = {
layout: 'horizontal',
labelCol: {
span: 4,
span: 6,
},
wrapperCol: {
span: 16,
......@@ -113,24 +173,82 @@ const AddModal = props => {
};
//选择设备类型
const handleDeviceType = (value) => {
getDeviceCode(value)
getDeviceCode()
}
const handleIntervalType = (value) => {
setIntervalType(value)
}
const handleChange = (value) => {
console.log(value, 'value');
//选择设备编码
const handleChange = (value, option) => {
let cardList = [...card]
cardList[+option.index].DeviceCode = value
setCard(cardList)
let obj = form.getFieldsValue();
getQutaList({ accountName: obj.DeviceType, AddrSchemeID: option.pointid }).then(res => {
if (res.getMe && res.getMe.length) {
let arr = [...deviceList]
arr[+option.index].indexStr = res.getMe
setDeviceList(arr)
}
})
}
//选择设备指标
const handleChangeIndex = (value, option) => {
let cardList = [...card]
cardList[+option.index].PointAddress = value
setCard(cardList)
}
//最大值
const inputMax = (e, option) => {
e.persist();
let cardList = [...card]
cardList[option].MaxValue = e.target.value
setCard(cardList)
}
//最小值
const inputMin = (e, option) => {
e.persist();
let cardList = [...card]
cardList[option].MinValue = e.target.value
setCard(cardList)
}
const add = () => {
let obj = form.getFieldsValue();
if (!obj.DeviceType) {
notification.error({
message: '提示',
duration: 3,
description: '请选择设备类型',
});
} else {
let cardList = [...card]
let arr = [...deviceList]
cardList.push({})
setCard(cardList)
arr.push({ code: deviceCodes })
setDeviceList(arr)
}
}
//删除卡片
const deleteDevice = (index) => {
let cardList = [...card]
let arr = [...deviceList]
let newCardList = cardList.splice(0, 1)
let newArr = arr.splice(0, 1)
setCard(index == 0 ? [] : newCardList)
setDeviceList(index == 0 ? [] : newArr)
}
const handleChangeIndex = (value) => {
console.log(value, 'value');
//选择小时,分,天
const selectCycleValue = (e) => {
setCycleValue(e.target.value)
}
return (
<Modal
title={`${type === 'add' ? '预测方案新增' : '编辑'}`}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '150px' }}
width="700px"
width="800px"
destroyOnClose
maskClosable={false}
cancelText="取消"
......@@ -146,71 +264,32 @@ const AddModal = props => {
<Form form={form} {...layout} onFinish={onFinish}>
<Item
label="方案名称"
name="TaskName"
name="PredictName"
rules={[{ required: true, message: '请输入方案名称' }]}
>
<Input placeholder="请输入任务名称" allowClear />
</Item>
<Item
label="算法名称"
name="TaskName"
label="场景名称"
name="SceneName"
rules={[{ required: true, message: '请输入算法名称' }]}
>
<Select >
{sceneList.length ? sceneList.map((item, index) => { return <Select.Option key={index} value={item.scenename}>{item.scenename}</Select.Option> }) : ''}
</Select>
</Item>
<Item
label="设备类型"
name="deviceType"
name="DeviceType"
rules={[{ required: true, message: '请输入设备类型' }]}
>
<Select onChange={handleDeviceType} >
{deviceType.length ? deviceType.map((item, index) => { return <Select.Option key={index} value={item.DeviceType}>{item.DeviceType}</Select.Option> }) : ''}
</Select>
</Item>
<Item
label="设备编码"
rules={[{ required: true, message: '请选择设备编码' }]}
>
<Select
mode="multiple"
style={{ width: '100%' }}
placeholder="请选择设备编码"
options={deviceCodes}
defaultValue={[]}
onChange={handleChange}
/>
</Item>
<Item
label="指标名称"
rules={[{ required: true, message: '请选择指标名称' }]}
>
<Select
mode="multiple"
style={{ width: '100%' }}
placeholder="请选择指标"
options={deviceCodes}
defaultValue={[]}
onChange={handleChangeIndex}
/>
</Item>
{/* <Item
label="间隔(Cron)"
name="Interval"
rules={[{ required: true, message: '请输入间隔' }]}
>
<div className={styles.predict}>
<Input placeholder="请输入间隔" allowClear />
<a className={styles.corn} target="view_window" href="https://cron.qqe2.com/">cron在线生成</a>
</div>
</Item> */}
<Item
label="首次执行时间"
name="Date"
name="time"
rules={[{ required: true, message: '请选择首次执行时间' }]}
>
......@@ -222,7 +301,7 @@ const AddModal = props => {
rules={[{ required: true, message: '请输入预测间隔' }]}
>
<div className={styles.predict}></div>
<Input style={{ width: '70%' }} placeholder="请输入预测间隔" allowClear />
<Input style={{ width: '70%' }} placeholder="请输入预测间隔" value={CycleValue} onChange={(value) => selectCycleValue(value)} allowClear />
<Select style={{ marginLeft: '0.5rem', width: '28%' }} onChange={handleIntervalType} value={intervalType}>
{timeType.length ? timeType.map((item, index) => { return <Select.Option key={index} value={item}>{item}</Select.Option> }) : ''}
</Select>
......@@ -230,10 +309,74 @@ const AddModal = props => {
<Item
label="描述"
name="dec"
name="Remarks"
>
<TextArea placeholder="可输入描述信息" rows={4} allowClear />
</Item>
<Button size="small" onClick={() => { add() }}>
新增
</Button>
<div className={styles.deviceList}>
{deviceList.length ? deviceList.map((item, index) => {
return <Card key={index} style={{ marginTop: '0.5rem' }}>
<Row gutter='36' >
<Col span={12}>
<Item
label="设备编码"
name={'deviceCode' + index}
rules={[{ required: true, message: '请选择设备编码' }]}
>
<Select
placeholder="请选择设备编码"
onChange={(value, option) => handleChange(value, option)}
>
{item.code.length ? item.code.map((item, codeIndex) => { return <Select.Option index={index} key={codeIndex} value={item.Code} pointid={item.PointAddressID}>{item.Code}</Select.Option> }) : ''}
</Select>
</Item>
</Col>
<Col span={12}>
<Item
label="指标名称"
name={'indextr' + index}
rules={[{ required: true, message: '请选择指标名称' }]}
>
<Select
placeholder="请选择指标"
onChange={(value, option) => handleChangeIndex(value, option)}
>
{item.indexStr && item.indexStr.length ? item.indexStr.map((item, zindex) => { return <Select.Option key={zindex} index={index} value={item.Name}>{item.Name}</Select.Option> }) : ''}
</Select>
</Item>
</Col>
</Row>
<Row gutter='24' >
<Col span={12}>
<Item
label="最大值"
name={'max' + index}
rules={[{ required: true, message: '请输入最大值' }]}
>
<Input style={{width:'98%'}} placeholder="请输入最大值" onChange={(value) => inputMax(value, index)} index={index} allowClear />
</Item>
</Col>
<Col span={12}>
<Item
label="最小值"
name={'min' + index}
rules={[{ required: true, message: '请输入最小值' }]}
>
<Input placeholder="请输入最小值" onChange={(value) => inputMin(value, index)} index={index} allowClear />
</Item>
</Col>
</Row>
<DeleteOutlined
className={styles.deleteItem}
onClick={() => deleteDevice(index)}
style={{ fontSize: '16px', color: '#e86060' }}
/>
</Card>
}) : ''}
</div>
</Form>
)}
</Spin>
......
import { Space, Table, Button, Popconfirm, notification } from 'antd';
import { Space, Table, Button, Popconfirm, notification, Spin } from 'antd';
import React, { useState, useEffect } from 'react';
import styles from '../policiesIssued.less'
import {
deleteTaskOptions, taskOptionsList, getIotDeviceType, algorithmList, getEquipmentInfo
getIotDeviceType, getPredictInfo, deletePredictOptions
} from '@/services/intelligence/api';
import AddModal from './AddModal'
const VectorData = props => {
......@@ -18,56 +18,51 @@ const VectorData = props => {
const columns = [
{
title: '序号',
dataIndex: 'serviceName',
key: 'serviceName',
align: 'center'
align: 'center',
render: (text, record, index) => (
<Space>
<span>{(index + 1)}</span>
</Space>
)
},
{
title: '方案名称',
dataIndex: 'GISServerIP',
key: 'GISServerIP',
dataIndex: 'PredictName',
key: 'PredictName',
align: 'center'
},
{
title: '算法名称',
dataIndex: 'GISServerPort',
key: 'GISServerPort',
title: '场景名称',
dataIndex: 'SceneName',
key: 'SceneName',
align: 'center'
},
{
title: '设备类型',
dataIndex: 'GISServerProjectName',
key: 'GISServerProjectName',
align: 'center'
},
{
title: '设备编码',
dataIndex: 'publishTime',
key: 'publishTime',
align: 'center'
},
{
title: '指标名称',
dataIndex: 'publishTime',
key: 'publishTime',
dataIndex: 'DeviceType',
key: 'DeviceType',
align: 'center'
},
{
title: '预测间隔',
dataIndex: 'publishTime',
key: 'publishTime',
align: 'center'
align: 'center',
render: (record) => (
<Space>
{record.CycleValue + record.Cycle}
</Space>
)
},
{
title: '首次执行时间',
dataIndex: 'publishTime',
key: 'publishTime',
dataIndex: 'DateFrom',
key: 'DateFrom',
align: 'center'
},
{
title: '描述',
dataIndex: 'publishTime',
key: 'publishTime',
dataIndex: 'Remarks',
key: 'Remarks',
align: 'center'
},
{
......@@ -75,10 +70,18 @@ const VectorData = props => {
align: 'center',
render: (text, record, index) => (
<Space>
<Button
type="primary"
size="small"
onClick={() => {
changeRecord(record);
}}
>
编辑
</Button>
<div onClick={e => e.stopPropagation()}>
<Popconfirm
title="是否删除该矢量数据?"
title="是否删除该方案?"
okText="确认"
cancelText="取消"
onConfirm={() => {
......@@ -97,16 +100,33 @@ const VectorData = props => {
];
const onSubmit = prop => {
setVisible(false);
setFlag(flag+1)
setFlag(flag + 1)
};
const delConfirm = (record) => {
deletePredictOptions(record.ID).then(res => {
if (res.errMsg === '') {
setFlag(flag + 1)
notification.success({
message: '提示',
duration: 3,
description: '删除成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.errMsg,
});
};
})
}
const handleAdd = () => {
setFormObj({});
setType('add');
setVisible(true);
}
......@@ -115,51 +135,59 @@ const VectorData = props => {
}, [flag]);
// 获取瓦片数据配置数据
const renderTile = () => {
setTreeLoading(true)
const getIotDevice = getIotDeviceType()
const algorithm = algorithmList()
const taskOption = taskOptionsList()
Promise.all([getIotDevice, algorithm, taskOption]).then(res => {
const getPredictList = getPredictInfo()
Promise.all([getIotDevice, getPredictList]).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)
})
};
const changeRecord = (record) => {
setType('edit');
setFormObj(record);
setVisible(true);
}
return (
<>
<div className={styles.tileBtn}>
<Button type="primary" onClick={() => {
handleAdd();
}} >
新增
<Spin tip="loading..." spinning={treeLoading}>
<div className={styles.tileBtn}>
<Button type="primary" onClick={() => {
handleAdd();
}} >
新增
</Button>
</div>
<Table
columns={columns}
dataSource={tileData}
bordered
rowKey="createTime"
scroll={{ y: 400 }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`
</div>
<Table
columns={columns}
dataSource={tileData}
bordered
rowKey="ID"
scroll={{ y: 700 }}
pagination={{
pageSize: '10',
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`
}}
>
</Table>
<AddModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
deviceType={deviceType}
formObj={formObj}
/>
}}
>
</Table>
<AddModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
deviceType={deviceType}
formObj={formObj}
/>
</Spin>
</>
)
}
export default VectorData
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, notification, DatePicker, Spin } from 'antd';
import { Form, Modal, Input, Select, notification, DatePicker, Spin, Button, Card, Row, Col } from 'antd';
import styles from '../policiesIssued.less'
// import moment from 'moment';
// import locale from 'antd/es/date-picker/locale/zh_CN';
......@@ -10,19 +10,22 @@ import locale from 'antd/lib/date-picker/locale/zh_CN'
import 'moment/locale/zh-cn'
moment.locale('zh-cn')
import {
getEquipmentInfo
getEquipmentInfo, getQutaList, getSceneNameInfo, addStrategyOptions, editStrategyOptions, getPredictDevice, getPredictDevicePoint
} from '@/services/intelligence/api';
import { DeleteOutlined } from '@ant-design/icons';
const { RangePicker } = DatePicker;
const { TextArea } = Input;
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 [intervalType, setIntervalType] = useState('分钟')
const [predictCode, setPredictCode] = useState([]); //预测编码列表
const [deviceList, setDeviceList] = useState([]); //设备列表
const [card, setCard] = useState([]); //卡片列表值
const [sceneList, setSceneList] = useState([])
const [form] = Form.useForm();
const { Item } = Form;
// 提交
......@@ -30,78 +33,136 @@ const AddModal = props => {
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')
setLoading(true);
if (type === 'add') {
} else if (type === 'edit') {
handleEdit();
let api = addStrategyOptions
let query = {
DeviceType: obj.DeviceType,
StrategyDes: obj.StrategyDes,
StrategyName: obj.StrategyName,
StrategyType: obj.StrategyType,
DetailInfos: card,
CreateTime: moment(obj.time).format('YYYY-MM-DD HH:mm:ss')
}
type === 'edit' ? (query.ID = formObj.ID) && (api = editStrategyOptions) : delete query.ID && (api = addStrategyOptions)
setLoading(true);
api(query).then(res => {
setLoading(false);
if (res.errMsg === '') {
form.resetFields();
callBackSubmit();
prompt('success', `${type === 'add' ? "增加成功" : res.errMsg}`)
} else {
prompt('fail', `${type === 'add' ? "增加失败" : res.errMsg}`)
}
}).catch(e => {
setLoading(false);
})
}
});
};
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 prompt = (type, content) => {
if (type == 'success') {
notification.success({
message: '提示',
duration: 3,
description: content,
});
}
else {
notification.error({
message: '提示',
duration: 3,
description: content,
});
}
}
const onFinish = value => { };
useEffect(() => {
switch (type) {
case 'add':
deviceType.length && getDeviceCode(deviceType[0].DeviceType)
initData()
break;
case 'edit':
form.setFieldsValue({ ...formObj });
initData()
break;
default:
break;
}
}, [visible]);
//页面初始化
const initData = () => {
if (type === 'add') {
form.resetFields();
setCard([])
setDeviceList([])
}
else {
form.setFieldsValue({ time: moment(formObj.CreateTime, "YYYYMMDDHHmmss"), ...formObj });
if (formObj.DetailInfos.length) {
let req1 = getEquipmentInfo(formObj.DeviceType)
let req2 = getPredictDevice(formObj.DeviceType)
Promise.all([req1, req2]).then(respone => {
console.log('respone', respone);
respone[0].getMe.length && respone[0].getMe[0].DeviceList.length && setDeviceCode(respone[0].getMe[0].DeviceList)
respone[1].getMe.length && setPredictCode(respone[1].getMe)
let arr = []
formObj.DetailInfos.map((item, index) => {
console.log(1);
arr[index] = {}
arr[index].code = respone[0].getMe.length ? respone[0].getMe[0].DeviceList : []
arr[index].predictCode = respone[1].getMe.length ? respone[1].getMe : []
form.setFieldsValue({
[`deviceCode${index}`]: item.ControlCode,
[`indextr${index}`]: item.ControlPoint,
[`max${index}`]: item.PredictCode,
[`min${index}`]: item.PredictPoint
})
})
setCard(formObj.DetailInfos)
setDeviceList(arr)
setLoading(false)
})
}
}
const getDeviceCode = (type) => {
getSceneNameInfo().then(res => {
res.getMe.length && setSceneList(res.getMe)
})
}
//获取设备编码
const getDeviceCode = () => {
setLoading(false)
getEquipmentInfo(type).then(respone => {
respone.getMe[0].DeviceList.length && setDeviceCode(respone.getMe[0].DeviceList)
form.setFieldsValue({
deviceType: deviceType[0].DeviceType,
deviceCode: respone.getMe[0].DeviceList[0].Code
});
let obj = form.getFieldsValue();
let req1 = getEquipmentInfo(obj.DeviceType)
let req2 = getPredictDevice(obj.DeviceType)
Promise.all([req1, req2]).then(respone => {
respone[0].getMe.length && respone[0].getMe[0].DeviceList.length && setDeviceCode(respone[0].getMe[0].DeviceList)
respone[1].getMe.length && setPredictCode(respone[1].getMe)
if (deviceList.length) {
let arr = [...deviceList]
arr.map((item, index) => {
arr[index].code = respone[0].getMe.length ? respone[0].getMe[0].DeviceList : []
arr[index].predictCode = respone[1].getMe.length ? respone[1].getMe : []
arr[index].indexStr = ''
arr[index].predictStr = ''
form.setFieldsValue({
[`deviceCode${index}`]: '',
[`indextr${index}`]: '',
[`max${index}`]: '',
[`min${index}`]: ''
})
})
setDeviceList(arr)
}
setLoading(false)
})
}
const layout = {
layout: 'horizontal',
labelCol: {
span: 4,
span: 6,
},
wrapperCol: {
span: 16,
......@@ -109,19 +170,97 @@ const AddModal = props => {
};
//选择设备类型
const handleDeviceType = (value) => {
getDeviceCode(value)
getDeviceCode()
}
//选择设备编码
const handleChange = (value, option) => {
let cardList = [...card]
cardList[+option.index].ControlCode = value
setCard(cardList)
let obj = form.getFieldsValue();
getQutaList({ accountName: obj.DeviceType, AddrSchemeID: option.pointid }).then(res => {
if (res.getMe && res.getMe.length) {
let arr = [...deviceList]
arr[+option.index].indexStr = res.getMe
setDeviceList(arr)
}
})
}
//选择预测编码
const handleChange1 = (value, option) => {
let cardList = [...card]
cardList[+option.index].PredictCode = value
setCard(cardList)
let obj = form.getFieldsValue();
getPredictDevicePoint({ deviceType: obj.DeviceType, DeviceCode: value }).then(res => {
console.log('res', res);
if (res.getMe && res.getMe.length) {
let arr = [...deviceList]
arr[+option.index].predictStr = res.getMe
setDeviceList(arr)
}
})
}
//选择设备指标
const handleChangeIndex = (value, option) => {
let cardList = [...card]
cardList[+option.index].ControlPoint = value
setCard(cardList)
}
//选择预测指标
const handleChangeIndex1 = (value, option) => {
let cardList = [...card]
cardList[+option.index].PredictPoint = value
setCard(cardList)
}
const handleIntervalType = (value) => {
setIntervalType(value)
//最大值
const inputMax = (e, option) => {
e.persist();
let cardList = [...card]
cardList[option].MaxValue = e.target.value
setCard(cardList)
}
//最小值
const inputMin = (e, option) => {
e.persist();
let cardList = [...card]
cardList[option].MinValue = e.target.value
setCard(cardList)
}
const add = () => {
let obj = form.getFieldsValue();
if (!obj.DeviceType) {
notification.error({
message: '提示',
duration: 3,
description: '请选择设备类型',
});
} else {
let cardList = [...card]
let arr = [...deviceList]
cardList.push({})
setCard(cardList)
arr.push({ code: deviceCodes, predictCode })
setDeviceList(arr)
}
}
//删除卡片
const deleteDevice = (index) => {
let cardList = [...card]
let arr = [...deviceList]
let newCardList = cardList.splice(0, 1)
let newArr = arr.splice(0, 1)
setCard(index == 0 ? [] : newCardList)
setDeviceList(index == 0 ? [] : newArr)
}
return (
<Modal
title={`${type === 'add' ? '元数据发布' : '编辑'}`}
title={`${type === 'add' ? '预测方案新增' : '编辑'}`}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '150px' }}
width="700px"
width="800px"
destroyOnClose
maskClosable={false}
cancelText="取消"
......@@ -136,96 +275,124 @@ const AddModal = props => {
{visible && (
<Form form={form} {...layout} onFinish={onFinish}>
<Item
label="任务名称"
name="TaskName"
rules={[{ required: true, message: '请输入任务名称' }]}
label="策略名称"
name="StrategyName"
rules={[{ required: true, message: '请输入方案名称' }]}
>
<Input placeholder="请输入任务名称" allowClear />
</Item>
<Item
label="场景"
name="scene"
rules={[{ required: true, message: '请选择场景' }]}
label="策略类型"
name="StrategyType"
rules={[{ required: true, message: '请输入算法名称' }]}
>
<Select >
{/* {workList.length ? workList.map((item, index) => { return <Option key={index} value={item.name}>{item.name}</Option> }) : ''} */}
</Select>
</Item>
<Select.Option value='实时控制'>实时控制</Select.Option>
<Select.Option value='时段控制'>时段控制</Select.Option>
<Item
label="策略名称"
name="strategy"
// rules={[{ required: true, message: '请选择策略名称' }]}
>
<Select >
{/* {workList.length ? workList.map((item, index) => { return <Option key={index} value={item.name}>{item.name}</Option> }) : ''} */}
</Select>
</Item>
<Item
label="类型"
name="type"
rules={[{ required: true, message: '请选择类型' }]}
>
<Select>
<Select.Option value='水龄预测'>水龄预测</Select.Option>
<Select.Option value='二供泵房'>二供泵房</Select.Option>
</Select>
</Item>
<Item
label="设备类型"
name="deviceType"
rules={[{ required: true, message: '请输入设备类型' }]}
name="DeviceType"
>
<Select onChange={handleDeviceType} >
{deviceType.length ? deviceType.map((item, index) => { return <Select.Option key={index} value={item.DeviceType}>{item.DeviceType}</Select.Option> }) : ''}
</Select>
</Item>
<Item
label="设备编码"
name="deviceCode"
rules={[{ required: true, message: '请选择设备编码' }]}
>
<Select>
{deviceCodes.length ? deviceCodes.map((item, index) => { return <Select.Option key={index} value={item.PointAddressID}>{item.Code}</Select.Option> }) : ''}
</Select>
</Item>
<Item
label="间隔(Cron)"
name="Interval"
rules={[{ required: true, message: '请输入间隔' }]}
>
<div className={styles.predict}>
<Input placeholder="请输入间隔" allowClear />
<a className={styles.corn} target="view_window" href="https://cron.qqe2.com/">cron在线生成</a>
</div>
</Item>
<Item
label="首次预测时间"
name="Date"
rules={[{ required: true, message: '请选择首次预测时间' }]}
label="创建时间"
name="time"
rules={[{ required: true, message: '请选择创建时间' }]}
>
<RangePicker locale={locale}
<DatePicker locale={locale}
showTime={{ format: 'HH:mm:ss' }}
format="YYYY-MM-DD HH:mm:ss"
style={{ width: '100%' }} />
</Item>
<Item
label="预测间隔"
rules={[{ required: true, message: '请输入预测间隔' }]}
>
<div className={styles.predict}></div>
<Input style={{ width: '70%' }} placeholder="请输入预测间隔" allowClear />
<Select style={{ marginLeft: '0.5rem', width: '28%' }} onChange={handleIntervalType} value={intervalType}>
{timeType.length ? timeType.map((item, index) => { return <Select.Option key={index} value={item}>{item}</Select.Option> }) : ''}
</Select>
</Item>
<Item
label="描述"
name="dec"
name="StrategyDes"
>
<TextArea placeholder="可输入描述信息" rows={4} allowClear />
</Item>
<Button size="small" onClick={() => { add() }}>
新增
</Button>
<div className={styles.deviceList}>
{deviceList.length ? deviceList.map((item, index) => {
return <Card key={index} style={{ marginTop: '0.5rem' }}>
<Row gutter='36' justify='space-between'>
<Col span={12}>
<Item
label="控制编码"
name={'deviceCode' + index}
rules={[{ required: true, message: '请选择设备编码' }]}
>
<Select
placeholder="请选择控制编码"
onChange={(value, option) => handleChange(value, option)}
>
{item.code.length ? item.code.map((item, codeIndex) => { return <Select.Option index={index} key={codeIndex} value={item.Code} pointid={item.PointAddressID}>{item.Code}</Select.Option> }) : ''}
</Select>
</Item>
</Col>
<Col span={12}>
<Item
label="控制指标"
name={'indextr' + index}
rules={[{ required: true, message: '请选择指标名称' }]}
>
<Select
placeholder="请选择控制指标"
onChange={(value, option) => handleChangeIndex(value, option)}
>
{item.indexStr && item.indexStr.length ? item.indexStr.map((item, zindex) => { return <Select.Option key={zindex} index={index} value={item.Name}>{item.Name}</Select.Option> }) : ''}
</Select>
</Item>
</Col>
</Row>
<Row gutter='24' justify='space-between'>
<Col span={12}>
<Item
label="预测编码"
name={'max' + index}
rules={[{ required: true, message: '请输入预测编码' }]}
>
<Select
placeholder="请选择预测编码"
onChange={(value, option) => handleChange1(value, option)}
>
{item.predictCode.length ? item.predictCode.map((item, codeIndex) => { return <Select.Option index={index} key={codeIndex} value={item} >{item}</Select.Option> }) : ''}
</Select>
{/* <Input placeholder="请输入最大值" onChange={(value) => inputMax(value, index)} index={index} allowClear /> */}
</Item>
</Col>
<Col span={12}>
<Item
label="预测指标"
name={'min' + index}
rules={[{ required: true, message: '请输入预测指标' }]}
>
<Select
placeholder="请选择预测指标"
onChange={(value, option) => handleChangeIndex1(value, option)}
>
{item.predictStr && item.predictStr.length ? item.predictStr.map((item, zindex) => { return <Select.Option key={zindex} index={index} value={item}>{item}</Select.Option> }) : ''}
</Select>
</Item>
</Col>
</Row>
<DeleteOutlined
className={styles.deleteItem}
onClick={() => deleteDevice(index)}
style={{ fontSize: '16px', color: '#e86060' }}
/>
</Card>
}) : ''}
</div>
</Form>
)}
</Spin>
......
import { Space, Table, Button, Popconfirm, notification } from 'antd';
import { Space, Table, Button, Popconfirm, notification ,Spin} from 'antd';
import React, { useState, useEffect } from 'react';
import styles from '../policiesIssued.less'
import {
GetVectorService, deleteVectorService, getSolutionList, updatePublishedMetaData
} from '@/services/webConfig/api';
taskOptionsList, getIotDeviceType, getStrategyInfo, deleteStrategyOptions
} from '@/services/intelligence/api';
import AddModal from './AddModal'
const VectorData = props => {
const [treeLoading, setTreeLoading] = useState(false);// 弹窗显示
const [tileData, setTileData] = useState([]); // table表格数据
const [visible, setVisible] = useState(false); // 弹窗
const [previewVisible, setPreviewVisible] = useState(false); // 预览弹窗
const [flag, setFlag] = useState(0); // 更新list
const [loading, setLoading] = useState([]); // 更新状态
const [type, setType] = useState(''); // 弹窗类型
const [solutionNames, setSolutionNames] = useState('');
const [formObj, setFormObj] = useState({ user: 'admin', password: 'geoserver' });
const [currentMetaData,setCurrentMetaData] = useState(null)
const [tileData, setTileData] = useState([]); // table表格数据
const [visible, setVisible] = useState(false); // 弹窗
const [deviceType, setDeviceType] = useState([]); //设备类型列表
const columns = [
{
title: '序号',
dataIndex: 'serviceName',
key: 'serviceName',
align: 'center'
align: 'center',
render: (text, record, index) => (
<Space>
<span>{(index + 1)}</span>
</Space>
)
},
{
title: '方案名称',
dataIndex: 'GISServerIP',
key: 'GISServerIP',
title: '策略名称',
dataIndex: 'StrategyName',
key: 'StrategyName',
align: 'center'
},
{
title: '方案类型',
dataIndex: 'GISServerPort',
key: 'GISServerPort',
title: '策略类型',
dataIndex: 'StrategyType',
key: 'StrategyType',
align: 'center'
},
{
title: '任务名称',
dataIndex: 'GISServerProjectName',
key: 'GISServerProjectName',
title: '创建时间',
dataIndex: 'CreateTime',
key: 'CreateTime',
align: 'center'
},
{
title: '创建时间',
dataIndex: 'publishTime',
key: 'publishTime',
title: '设备类型',
dataIndex: 'DeviceType',
key: 'DeviceType',
align: 'center'
},
{
title: '描述',
dataIndex: 'publishTime',
key: 'publishTime',
dataIndex: 'StrategyDes',
key: 'StrategyDes',
align: 'center'
},
{
......@@ -58,10 +62,18 @@ const VectorData = props => {
align: 'center',
render: (text, record, index) => (
<Space>
<Button
type="primary"
size="small"
onClick={() => {
changeRecord(record);
}}
>
编辑
</Button>
<div onClick={e => e.stopPropagation()}>
<Popconfirm
title="是否删除该矢量数据?"
title="是否删除该方案?"
okText="确认"
cancelText="取消"
onConfirm={() => {
......@@ -80,50 +92,63 @@ const VectorData = props => {
];
const onSubmit = prop => {
setVisible(false);
setFlag(flag+1)
setFlag(flag + 1)
};
const delConfirm = (record) => {
let query = {
serviceName: record.serviceName,
_version: 9999,
solution: solutionNames
}
deleteVectorService(query).then(res => {
if (res.success) {
deleteStrategyOptions(record.ID).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,
});
};
})
}
const handleAdd = () => {
// setType('add');
// setVisible(true);
setFormObj({});
setType('add');
setVisible(true);
}
useEffect(() => {
renderTile();
}, [flag]);
// 获取瓦片数据配置数据
const renderTile = () => {
setTreeLoading(true)
const getIotDevice = getIotDeviceType()
const getStrategy = getStrategyInfo()
Promise.all([getIotDevice,getStrategy]).then(res => {
console.log('res[3].getMe',res[1].getMe);
res[0].getMe && res[0].getMe.length && setDeviceType(res[0].getMe)
res[1].getMe && res[1].getMe.length && setTileData(res[1].getMe)
setTreeLoading(false)
}).catch(err => {
setTreeLoading(false)
})
};
const changeRecord =(record)=>{
setType('edit');
setFormObj(record);
setVisible(true);
}
return (
<>
<Spin tip="loading..." spinning={treeLoading}>
<div className={styles.tileBtn}>
<Button type="primary" onClick={() => {
handleAdd();
......@@ -135,9 +160,10 @@ const VectorData = props => {
columns={columns}
dataSource={tileData}
bordered
rowKey="createTime"
scroll={{ y: 400 }}
rowKey="ID"
scroll={{ y: 700 }}
pagination={{
pageSize: '10' ,
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`
......@@ -149,10 +175,12 @@ const VectorData = props => {
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
deviceType={deviceType}
formObj={formObj}
solutionNames={solutionNames}
/>
</Spin>
</>
)
}
export default VectorData
\ No newline at end of file
......@@ -87,7 +87,9 @@ const AddModal = props => {
const handleTaskType =(value)=>{
console.log(value,'value');
}
const layout = {
layout: 'horizontal',
labelCol: {
......@@ -128,18 +130,19 @@ const AddModal = props => {
<Input placeholder="请输入任务名称" allowClear />
</Item>
<Item
label="方案类型"
name="type"
label="任务类型"
name="TaskType"
rules={[{ required: true, message: '请选择类型' }]}
>
<Select>
<Select.Option value='水龄预测'>水龄预测</Select.Option>
<Select.Option value='二供泵房'>二供泵房</Select.Option>
<Select onChange={handleTaskType}>
<Select.Option value='预测'>预测</Select.Option>
<Select.Option value='控制'>控制</Select.Option>
<Select.Option value='http'>http</Select.Option>
</Select>
</Item>
<Item
label="方案名称"
name="strategy"
name="AlgorithmName"
>
<Select >
{/* {workList.length ? workList.map((item, index) => { return <Option key={index} value={item.name}>{item.name}</Option> }) : ''} */}
......@@ -157,7 +160,7 @@ const AddModal = props => {
</Item>
<Item
label="描述"
name="dec"
name="Describe"
>
<TextArea placeholder="可输入描述信息" rows={4} allowClear />
</Item>
......
......@@ -18,8 +18,12 @@ const VectorData = props => {
{
title: '序号',
dataIndex: 'index',
key: 'serviceName',
align: 'center'
align: 'center',
render: (text, record, index) => (
<Space>
<span>{(index + 1)}</span>
</Space>
)
},
{
title: '场景名称',
......@@ -47,8 +51,8 @@ const VectorData = props => {
},
{
title: '间隔',
dataIndex: 'publishTime',
key: 'publishTime',
dataIndex: 'Interval',
key: 'Interval',
align: 'center'
},
{
......@@ -68,7 +72,15 @@ const VectorData = props => {
align: 'center',
render: (text, record, index) => (
<Space>
<Button
type="primary"
size="small"
onClick={() => {
changeRecord(record);
}}
>
编辑
</Button>
<div onClick={e => e.stopPropagation()}>
<Popconfirm
title="是否删除该矢量数据?"
......@@ -101,7 +113,7 @@ const VectorData = props => {
_version: 9999,
solution: solutionNames
}
deleteVectorService(query).then(res => {
deleteTaskOptions(query).then(res => {
if (res.success) {
setFlag(flag + 1)
notification.success({
......@@ -118,6 +130,12 @@ const VectorData = props => {
};
})
}
//编辑任务调度
const changeRecord = (record) => {
setType('edit');
setFormObj(record);
setVisible(true);
}
const handleAdd = () => {
setType('add');
setVisible(true);
......@@ -132,8 +150,9 @@ const VectorData = props => {
const algorithm = algorithmList()
const taskOption = taskOptionsList()
Promise.all([getIotDevice, algorithm, taskOption]).then(res => {
console.log('res', res);
res[0].getMe && res[0].getMe.length && setDeviceType(res[0].getMe)
res[2].getMe && res[2].getMe.length && setDeviceType(res[2].getMe)
res[2].getMe && res[2].getMe.length && setTileData(res[2].getMe)
setTreeLoading(false)
}).catch(err => {
setTreeLoading(false)
......@@ -143,35 +162,38 @@ const VectorData = props => {
return (
<>
<div className={styles.tileBtn}>
<Button type="primary" onClick={() => {
handleAdd();
}} >
新增
<div className={styles.container}>
<div className={styles.tileBtn}>
<Button type="primary" onClick={() => {
handleAdd();
}} >
新增
</Button>
</div>
<Table
columns={columns}
dataSource={tileData}
bordered
rowKey="Id"
scroll={{ y: 400 }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`
}}
>
</Table>
<AddModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
deviceType={deviceType}
formObj={formObj}
solutionNames={solutionNames}
/>
</div>
<Table
columns={columns}
dataSource={tileData}
bordered
rowKey="createTime"
scroll={{ y: 400 }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`
}}
>
</Table>
<AddModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
deviceType={deviceType}
formObj={formObj}
solutionNames={solutionNames}
/>
</>
)
}
......
.container{
width: 100%;
height: 100%;
background-color: #ffffff;
}
.predict{
display: flex;
align-items: flex-end;
......@@ -8,7 +13,7 @@
display: flex;
justify-content: flex-end;
width: 100%;
padding: 0 0 2rem
padding: 2rem 1rem 2rem 0;
}
.corn{
cursor: pointer;
......
......@@ -114,7 +114,6 @@ const TileData = props => {
})
}
const handleAdd = () => {
console.log('baseMap',baseMap);
if(baseMap.length){
setType('add');
setVisible(true);
......
......@@ -20,6 +20,13 @@ export const algorithmList = () =>
export const getEquipmentInfo = (query) =>
get(`${CITY_SERVICE}/IOTPlatform.svc/AcrossTable/GetEquipmentInfo?equipType=${query}`);
//获取指标列表
export const getQutaList = (query) =>
get(`${CITY_SERVICE}/IOTPlatform.svc/AcrossTable/GetQutaList?AcountName=${query.accountName}&&AddrSchemeID=${query.AddrSchemeID}`);
//获取场景列表
export const getSceneNameInfo = () =>
get(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/GetSceneNameInfo`);
//任务添加
export const addTaskOptions = (params) =>
......@@ -32,3 +39,44 @@ export const updateTaskOptions = (params) =>
//任务删除
export const deleteTaskOptions = (params) =>
post(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/DeleteTaskOptions`, params);
//预测列表
export const getPredictInfo = () =>
get(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/GetPredictInfo`);
//预测新增
export const addPredictOptions = (params) =>
post(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/AddPredictOptions`, params);
//预测编辑
export const editPredictOptions = (params) =>
post(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/EditPredictOptions`, params);
//预测删除
export const deletePredictOptions = (params) =>
post(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/DeletePredictOptions?PredictID=${params}`);
//策略下发列表
export const getStrategyInfo = () =>
get(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/GetStrategyInfo`);
//策略下发增加
export const addStrategyOptions = (params) =>
post(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/AddStrategyOptions`, params);
//策略下发编辑
export const editStrategyOptions = (params) =>
post(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/EditStrategyOptions`, params);
//策略下发删除
export const deleteStrategyOptions = (params) =>
post(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/DeleteStrategyOptions?StrategyId=${params}`);
//获取预测设备
export const getPredictDevice = (params) =>
get(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/GetPredictDevice?DeviceType=${params}`);
//获取预测指标
export const getPredictDevicePoint = (params) =>
get(`${CITY_SERVICE}/IOTPlatform.svc/WaterAge/GetPredictDevicePoint?DeviceType=${params.deviceType}&DeviceCode=${params.DeviceCode}`);
\ No newline at end of file
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