Commit c2834042 authored by 陈龙's avatar 陈龙

feat: 增加关联模式

parent 9c697d1c
......@@ -26,11 +26,11 @@ path: /
## 单图表-状态
<code src="./demos/indexForStatus.js"></code>
[//]: # (<code src="./demos/indexForStatus.js"></code>)
## 单图表-频率
<code src="./demos/indexForFrequency.js"></code>
[//]: # (<code src="./demos/indexForFrequency.js"></code>)
[//]: # '## 移动端'
[//]: # '<code src="./demos/mobile.js"></code>'
......
......@@ -91,3 +91,11 @@ export function getSensorsRealName(data) {
data,
})
}
export function getAccountList (data) {
return request({
url: `${baseUrl}/PandaWorkFlow/WorkFlow/AccountManage/GetAccountPageList`,
method: REQUEST_METHOD_POST,
data,
})
}
......@@ -3,8 +3,8 @@ import HistoryView from '../index';
const deviceParams = [
{
"deviceCode": "EGBF00000022",
"sensors": "出水瞬时流量,今日用电量,余氯",
"deviceCode": "EGBF00000023",
"sensors": "出水瞬时流量",
"deviceType": "二供泵房"
}
]
......@@ -13,8 +13,8 @@ const Demo = () => {
<>
<div>
<div style={{height: 700}}>
{/*<HistoryView deviceParams={deviceParams} defaultModel="curve" />*/}
<HistoryView theme={'BI'} deviceParams={deviceParams} defaultModel="curve"/>
<HistoryView deviceParams={deviceParams} defaultModel="curve" />
{/*<HistoryView theme={'BI'} deviceParams={deviceParams} defaultModel="curve"/>*/}
</div>
</div>
</>
......
......@@ -35,7 +35,7 @@ import {
getExportDeviceHistoryUrl,
getDictionaryInfoAll,
getPointAddress,
getPointAddressEntry, getPredicateSensor,
getPointAddressEntry, getPredicateSensor, getAccountList,
} from './apis';
import SingleChart from './SingleChart';
import GridChart from './GridChart';
......@@ -327,13 +327,21 @@ const HistoryView = (props) => {
grid,
defaultChecked,
tableProps,
deviceParams,
defaultModel,
showModels,
needMarkLine,
defaultDate,
theme = "Normal"
} = props;
// 关联指标
const [combineSensors, setCombineSensors] = useState([]);
const deviceParams = useMemo(() => {
let _deviceParams = _.cloneDeep(props.deviceParams);
if (combineSensors?.length && _deviceParams.length === 1) {
_deviceParams[0].sensors = combineSensors.join(',')
}
return _deviceParams;
}, [combineSensors]);
if (theme === 'Normal') import('./index.less');
if (theme === 'BI') import('./indexForBI.less');
const isBoxPlots =
......@@ -881,7 +889,6 @@ const HistoryView = (props) => {
)}${moment(timeTo).format(dateFormat)}`;
let _quotas = i.sensors
.split(',')
.filter((item) => item !== '是否在线')
.join(',');
getExportDeviceHistoryUrl({
deviceType: i.deviceType,
......@@ -955,8 +962,6 @@ const HistoryView = (props) => {
};
const handleTableData = useCallback(
(data) => {
// eslint-disable-next-line no-param-reassign
// data = data.filter(item => item.sensorName !== '是否在线');
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
const dataIndexAccess = (dataItem, index) => {
const {stationCode, sensorName} = dataItem;
......@@ -1178,6 +1183,10 @@ const HistoryView = (props) => {
if (hasDiscreteDeviceType && ignoreOutliers) {
_finalParams.algorithmName = "derivative";
}
// 指标关联有值,表明是有关联指标的环境
if (combineSensors?.length && _finalParams?.acrossTables?.length === 1) {
_finalParams.acrossTables[0].sensors = combineSensors.join(',')
}
requestArr.push(getHistoryInfo(_finalParams));
});
setLoading(true);
......@@ -1219,11 +1228,11 @@ const HistoryView = (props) => {
});
});
// 加入预测
(predicateDevice ? deviceParams.concat(predicateDevice) : deviceParams).forEach((p) => {
// (predicateDevice ? deviceParams.concat(predicateDevice) : deviceParams).forEach((p) => {
deviceParams.forEach((p) => {
// 返回数据按查询指标顺序排序
const sensors = p.sensors?.split(',') ?? [];
if (sensors?.length) {
sensors.push('是否在线');
if (special1) {
sensors.push(special1.name);
}
......@@ -1460,16 +1469,27 @@ const HistoryView = (props) => {
// 以下请求为处理状态值、开关值的图表,只允许单曲线单指标情况下展示
let _request1 = getPointAddressEntry(_params);
let _request2 = getSensorType();
// 预测指标,暂时没有完善的方案
// let _request3 = getPredicateSensor({deviceCode, sensors});
await Promise.all([_request0, _request1, _request2]).then((result) => {
// 邳州项目上,有定制需求:关联几个指标,选择后
let _request4 = getAccountList({
accountName: '关联指标台账',
pageIndex: 1, pageSize: 100,
info: deviceCode,
siteFilter: false,
siteLevel: true,
sortFields: "录入时间"
})
await Promise.all([_request0, _request1, _request2, _request4]).then((result) => {
if (result) {
let _res0 = result[0];
let _res1 = result[1];
let _res2 = result[2];
// let _res3 = result[3];
let _res3 = result[3];
// let _res4 = result[4];
let _checkboxData = [...checkboxData];
// 单设备单曲线时,查询是否配置为预测点
/* if (_res3.code === 0 && _res3.data) {
/* if (_res4.code === 0 && _res4.data) {
// 1. 如果是单曲线,并且配置了预测,那么默认开启预测;
// 2024年3月11日 物联预测功能支撑后,再开发这部分
_checkboxData.push({
......@@ -1524,6 +1544,12 @@ const HistoryView = (props) => {
let _isStatusSensor = ['状态值', '开关值'].includes(_sensor);
setIsSingleStatusSensor(_isStatusSensor);
}
// 关联指标
if (_res3.code === 0) {
let _jsonData = JSON.parse(_res3.data.jsonData);
let allSensors = _jsonData.find(item => item['关键指标'] === sensors)?.['关联指标']?.split(',') ?? [];
setCombineSensors([...new Set([...allSensors, sensors])]);
}
}
});
setCompleteInit(true);
......
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