Commit c2834042 authored by 陈龙's avatar 陈龙

feat: 增加关联模式

parent 9c697d1c
...@@ -26,11 +26,11 @@ path: / ...@@ -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>' [//]: # '<code src="./demos/mobile.js"></code>'
......
...@@ -91,3 +91,11 @@ export function getSensorsRealName(data) { ...@@ -91,3 +91,11 @@ export function getSensorsRealName(data) {
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'; ...@@ -3,8 +3,8 @@ import HistoryView from '../index';
const deviceParams = [ const deviceParams = [
{ {
"deviceCode": "EGBF00000022", "deviceCode": "EGBF00000023",
"sensors": "出水瞬时流量,今日用电量,余氯", "sensors": "出水瞬时流量",
"deviceType": "二供泵房" "deviceType": "二供泵房"
} }
] ]
...@@ -13,8 +13,8 @@ const Demo = () => { ...@@ -13,8 +13,8 @@ const Demo = () => {
<> <>
<div> <div>
<div style={{height: 700}}> <div style={{height: 700}}>
{/*<HistoryView deviceParams={deviceParams} defaultModel="curve" />*/} <HistoryView deviceParams={deviceParams} defaultModel="curve" />
<HistoryView theme={'BI'} deviceParams={deviceParams} defaultModel="curve"/> {/*<HistoryView theme={'BI'} deviceParams={deviceParams} defaultModel="curve"/>*/}
</div> </div>
</div> </div>
</> </>
......
...@@ -35,7 +35,7 @@ import { ...@@ -35,7 +35,7 @@ import {
getExportDeviceHistoryUrl, getExportDeviceHistoryUrl,
getDictionaryInfoAll, getDictionaryInfoAll,
getPointAddress, getPointAddress,
getPointAddressEntry, getPredicateSensor, getPointAddressEntry, getPredicateSensor, getAccountList,
} from './apis'; } from './apis';
import SingleChart from './SingleChart'; import SingleChart from './SingleChart';
import GridChart from './GridChart'; import GridChart from './GridChart';
...@@ -327,13 +327,21 @@ const HistoryView = (props) => { ...@@ -327,13 +327,21 @@ const HistoryView = (props) => {
grid, grid,
defaultChecked, defaultChecked,
tableProps, tableProps,
deviceParams,
defaultModel, defaultModel,
showModels, showModels,
needMarkLine, needMarkLine,
defaultDate, defaultDate,
theme = "Normal" theme = "Normal"
} = props; } = 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 === 'Normal') import('./index.less');
if (theme === 'BI') import('./indexForBI.less'); if (theme === 'BI') import('./indexForBI.less');
const isBoxPlots = const isBoxPlots =
...@@ -881,7 +889,6 @@ const HistoryView = (props) => { ...@@ -881,7 +889,6 @@ const HistoryView = (props) => {
)}${moment(timeTo).format(dateFormat)}`; )}${moment(timeTo).format(dateFormat)}`;
let _quotas = i.sensors let _quotas = i.sensors
.split(',') .split(',')
.filter((item) => item !== '是否在线')
.join(','); .join(',');
getExportDeviceHistoryUrl({ getExportDeviceHistoryUrl({
deviceType: i.deviceType, deviceType: i.deviceType,
...@@ -955,8 +962,6 @@ const HistoryView = (props) => { ...@@ -955,8 +962,6 @@ const HistoryView = (props) => {
}; };
const handleTableData = useCallback( const handleTableData = useCallback(
(data) => { (data) => {
// eslint-disable-next-line no-param-reassign
// data = data.filter(item => item.sensorName !== '是否在线');
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked; const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
const dataIndexAccess = (dataItem, index) => { const dataIndexAccess = (dataItem, index) => {
const {stationCode, sensorName} = dataItem; const {stationCode, sensorName} = dataItem;
...@@ -1178,6 +1183,10 @@ const HistoryView = (props) => { ...@@ -1178,6 +1183,10 @@ const HistoryView = (props) => {
if (hasDiscreteDeviceType && ignoreOutliers) { if (hasDiscreteDeviceType && ignoreOutliers) {
_finalParams.algorithmName = "derivative"; _finalParams.algorithmName = "derivative";
} }
// 指标关联有值,表明是有关联指标的环境
if (combineSensors?.length && _finalParams?.acrossTables?.length === 1) {
_finalParams.acrossTables[0].sensors = combineSensors.join(',')
}
requestArr.push(getHistoryInfo(_finalParams)); requestArr.push(getHistoryInfo(_finalParams));
}); });
setLoading(true); setLoading(true);
...@@ -1219,11 +1228,11 @@ const HistoryView = (props) => { ...@@ -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(',') ?? []; const sensors = p.sensors?.split(',') ?? [];
if (sensors?.length) { if (sensors?.length) {
sensors.push('是否在线');
if (special1) { if (special1) {
sensors.push(special1.name); sensors.push(special1.name);
} }
...@@ -1460,16 +1469,27 @@ const HistoryView = (props) => { ...@@ -1460,16 +1469,27 @@ const HistoryView = (props) => {
// 以下请求为处理状态值、开关值的图表,只允许单曲线单指标情况下展示 // 以下请求为处理状态值、开关值的图表,只允许单曲线单指标情况下展示
let _request1 = getPointAddressEntry(_params); let _request1 = getPointAddressEntry(_params);
let _request2 = getSensorType(); let _request2 = getSensorType();
// 预测指标,暂时没有完善的方案
// let _request3 = getPredicateSensor({deviceCode, sensors}); // 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) { if (result) {
let _res0 = result[0]; let _res0 = result[0];
let _res1 = result[1]; let _res1 = result[1];
let _res2 = result[2]; let _res2 = result[2];
// let _res3 = result[3]; let _res3 = result[3];
// let _res4 = result[4];
let _checkboxData = [...checkboxData]; let _checkboxData = [...checkboxData];
// 单设备单曲线时,查询是否配置为预测点 // 单设备单曲线时,查询是否配置为预测点
/* if (_res3.code === 0 && _res3.data) { /* if (_res4.code === 0 && _res4.data) {
// 1. 如果是单曲线,并且配置了预测,那么默认开启预测; // 1. 如果是单曲线,并且配置了预测,那么默认开启预测;
// 2024年3月11日 物联预测功能支撑后,再开发这部分 // 2024年3月11日 物联预测功能支撑后,再开发这部分
_checkboxData.push({ _checkboxData.push({
...@@ -1524,6 +1544,12 @@ const HistoryView = (props) => { ...@@ -1524,6 +1544,12 @@ const HistoryView = (props) => {
let _isStatusSensor = ['状态值', '开关值'].includes(_sensor); let _isStatusSensor = ['状态值', '开关值'].includes(_sensor);
setIsSingleStatusSensor(_isStatusSensor); 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); 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