Commit 9a436d7b authored by shaoan123's avatar shaoan123

优化人工智能下的策略下发和预测方案

parent d8b9fe8f
Pipeline #27385 skipped with stages
......@@ -37,6 +37,8 @@ const AddModal = props => {
let obj = form.getFieldsValue();
let DateFrom = moment(obj.time[0]).format('YYYY-MM-DD')
let DateTo = moment(obj.time[1]).format('YYYY-MM-DD')
let PredictDateFrom = moment(obj.PredictTime[0]).format('YYYY-MM-DD')
let PredictDateTo = moment(obj.PredictTime[1]).format('YYYY-MM-DD')
let api = addPredictOptions
let query = {
SceneName: obj.SceneName,
......@@ -45,8 +47,8 @@ const AddModal = props => {
DateFrom: DateFrom,
DateTo: DateTo,
DeviceType: obj.DeviceType,
PredictDateFrom: "",
PredictDateTo: "",
PredictDateFrom,
PredictDateTo,
PredictName: obj.PredictName,
Remarks: obj.Remarks,
DeviceDetails: card
......@@ -102,13 +104,13 @@ const AddModal = props => {
if (type === 'add') {
form.resetFields();
setCycleValue('');
setIntervalType('');
setIntervalType('小时');
setCard([])
setDeviceList([])
}
else {
setDeviceList([])
form.setFieldsValue({ time: [moment(formObj.DateFrom, "YYYYMMDD"), moment(formObj.DateTo, "YYYYMMDD")], ...formObj });
form.setFieldsValue({ time: [moment(formObj.DateFrom, "YYYYMMDD"), moment(formObj.DateTo, "YYYYMMDD")], PredictTime: [moment(formObj.PredictDateFrom, "YYYYMMDD"), moment(formObj.PredictDateTo, "YYYYMMDD")], ...formObj });
setCycleValue(formObj.CycleValue);
setIntervalType(formObj.Cycle);
if (formObj.DeviceDetails.length) {
......@@ -148,13 +150,9 @@ const AddModal = props => {
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}`]: ''
})
clearInput(index)
})
setDeviceList(arr)
}
setLoading(false)
......@@ -232,10 +230,19 @@ const AddModal = props => {
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)
cardList.splice(index, 1);
arr.splice(index, 1);
clearInput(index)
setCard(cardList)
setDeviceList(arr)
}
const clearInput = (index) => {
form.setFieldsValue({
[`deviceCode${index}`]: undefined,
[`indextr${index}`]:undefined,
[`max${index}`]:undefined,
[`min${index}`]:undefined
})
}
//选择小时,分,天
const selectCycleValue = (e) => {
......@@ -294,15 +301,27 @@ const AddModal = props => {
<RangePicker locale={locale}
style={{ width: '100%' }} />
</Item>
<Item
label="首次计算时间"
name="PredictTime"
rules={[{ required: true, message: '请选择首次执行时间' }]}
>
<RangePicker locale={locale}
style={{ width: '100%' }} />
</Item>
<Item
label="预测间隔"
name="Cycle"
rules={[{ required: true, message: '请输入预测间隔' }]}
>
<div className={styles.predict}></div>
<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>
<div>
<div className={styles.predict}></div>
<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>
</div>
</Item>
<Item
......@@ -352,16 +371,14 @@ const AddModal = props => {
<Item
label="最小值"
name={'min' + index}
rules={[{ required: true, message: '请输入最小值' }]}
>
<Input placeholder="请输入最小值" onChange={(value) => inputMin(value, index)} index={index} allowClear />
<Input placeholder="请输入最小值" style={{width:'98%'}} onChange={(value) => inputMin(value, index)} index={index} allowClear />
</Item>
</Col>
<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>
......
......@@ -59,6 +59,12 @@ const VectorData = props => {
key: 'DateFrom',
align: 'center'
},
{
title: '首次计算时间',
dataIndex: 'PredictDateFrom',
key: 'PredictDateFrom',
align: 'center'
},
{
title: '描述',
dataIndex: 'Remarks',
......
......@@ -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, getQutaList, getSceneNameInfo, addStrategyOptions, editStrategyOptions, getPredictDevice, getPredictDevicePoint
getEquipmentInfo, getQutaList, addStrategyOptions, editStrategyOptions, getPredictDevice, getPredictDevicePoint, getPredictInfo
} from '@/services/intelligence/api';
import { DeleteOutlined } from '@ant-design/icons';
......@@ -25,7 +25,8 @@ const AddModal = props => {
const [predictCode, setPredictCode] = useState([]); //预测编码列表
const [deviceList, setDeviceList] = useState([]); //设备列表
const [card, setCard] = useState([]); //卡片列表值
const [sceneList, setSceneList] = useState([])
const [source, setSource] = useState([])
const [PredictID, setPredictID] = useState()
const [form] = Form.useForm();
const { Item } = Form;
// 提交
......@@ -40,7 +41,8 @@ const AddModal = props => {
StrategyName: obj.StrategyName,
StrategyType: obj.StrategyType,
DetailInfos: card,
CreateTime: moment(obj.time).format('YYYY-MM-DD HH:mm:ss')
CreateTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
PredictID
}
type === 'edit' ? (query.ID = formObj.ID) && (api = editStrategyOptions) : delete query.ID && (api = addStrategyOptions)
setLoading(true);
......@@ -91,6 +93,9 @@ const AddModal = props => {
//页面初始化
const initData = () => {
getPredictInfo().then(res => {
res.getMe && res.getMe.length && setSource(res.getMe)
})
if (type === 'add') {
form.resetFields();
setCard([])
......@@ -126,9 +131,6 @@ const AddModal = props => {
}
getSceneNameInfo().then(res => {
res.getMe.length && setSceneList(res.getMe)
})
}
//获取设备编码
const getDeviceCode = () => {
......@@ -146,12 +148,7 @@ const AddModal = props => {
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}`]: ''
})
clearInput(index)
})
setDeviceList(arr)
}
......@@ -214,20 +211,7 @@ const AddModal = props => {
cardList[+option.index].PredictPoint = 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) {
......@@ -245,14 +229,27 @@ const AddModal = props => {
setDeviceList(arr)
}
}
//清除卡片删除一项的值
const clearInput = (index) => {
form.setFieldsValue({
[`deviceCode${index}`]: undefined,
[`indextr${index}`]: undefined,
[`max${index}`]: undefined,
[`min${index}`]: undefined
})
}
//删除卡片
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)
cardList.splice(index, 1)
arr.splice(index, 1)
clearInput(index)
setCard(cardList)
setDeviceList(arr)
}
const handleOrgin =(value,option) =>{
setPredictID(option.id)
}
return (
......@@ -277,14 +274,14 @@ const AddModal = props => {
<Item
label="策略名称"
name="StrategyName"
rules={[{ required: true, message: '请输入方案名称' }]}
rules={[{ required: true, message: '请输入策略名称' }]}
>
<Input placeholder="请输入任务名称" allowClear />
</Item>
<Item
label="策略类型"
name="StrategyType"
rules={[{ required: true, message: '请输入算法名称' }]}
rules={[{ required: true, message: '请选择策略类型' }]}
>
<Select >
<Select.Option value='实时控制'>实时控制</Select.Option>
......@@ -292,6 +289,15 @@ const AddModal = props => {
</Select>
</Item>
<Item
label="数据来源"
name="PredictName"
rules={[{ required: true, message: '请选择数据来源' }]}
>
<Select onChange={(value, option) => handleOrgin(value, option)}>
{source.length ? source.map((item, index) => { return <Select.Option key={index} id={item.ID} value={item.PredictName}>{item.PredictName}</Select.Option> }) : ''}
</Select>
</Item>
<Item
label="设备类型"
name="DeviceType"
......@@ -300,18 +306,6 @@ const AddModal = props => {
{deviceType.length ? deviceType.map((item, index) => { return <Select.Option key={index} value={item.DeviceType}>{item.DeviceType}</Select.Option> }) : ''}
</Select>
</Item>
<Item
label="创建时间"
name="time"
rules={[{ required: true, message: '请选择创建时间' }]}
>
<DatePicker locale={locale}
showTime={{ format: 'HH:mm:ss' }}
format="YYYY-MM-DD HH:mm:ss"
style={{ width: '100%' }} />
</Item>
<Item
label="描述"
name="StrategyDes"
......
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