coolcare-lite-scada-component 4.0.10 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,10 +31,54 @@ import ModalFanDevicePoint from "../../../components/ModalFanDevicePoint";
|
|
|
31
31
|
import emitter from "../../../utils/events";
|
|
32
32
|
import { GetDeviceIndicator, GetDevicePoint } from "../../../services/gateway/Device";
|
|
33
33
|
import "./index.css";
|
|
34
|
-
import { GetTdIndicatorAggregateData } from "../../../services/gateway/Point";
|
|
34
|
+
import { GetTdIndicatorAggregateData, GetTdIndicatorHistoryData } from "../../../services/gateway/Point";
|
|
35
35
|
import dayjs from 'dayjs';
|
|
36
36
|
import { GetEnergyByMeterList } from "../../../services/energy";
|
|
37
37
|
import ModalChangePointValue from "../../../components/ModalChangePointValue";
|
|
38
|
+
var DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
|
39
|
+
var HISTORY_DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
|
|
40
|
+
var getIndicatorHistoryTotalValue = function getIndicatorHistoryTotalValue(indicatorDataList) {
|
|
41
|
+
var valueList = (indicatorDataList || []).filter(function (item) {
|
|
42
|
+
return Number.isFinite(item === null || item === void 0 ? void 0 : item.val);
|
|
43
|
+
});
|
|
44
|
+
if (!valueList.length) {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
return valueList.reduce(function (sum, item) {
|
|
48
|
+
return sum + Number(item.val);
|
|
49
|
+
}, 0);
|
|
50
|
+
};
|
|
51
|
+
var getStatisticsTimeRange = function getStatisticsTimeRange() {
|
|
52
|
+
var dateType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
53
|
+
var now = dayjs();
|
|
54
|
+
switch (dateType) {
|
|
55
|
+
case 2:
|
|
56
|
+
return {
|
|
57
|
+
startTime: now.startOf('day').format(DATE_TIME_FORMAT),
|
|
58
|
+
endTime: now.endOf('day').format(DATE_TIME_FORMAT)
|
|
59
|
+
};
|
|
60
|
+
case 3:
|
|
61
|
+
{
|
|
62
|
+
var dayOfWeek = now.day();
|
|
63
|
+
var startOfWeek = now.startOf('day').subtract(dayOfWeek === 0 ? 6 : dayOfWeek - 1, 'day');
|
|
64
|
+
return {
|
|
65
|
+
startTime: startOfWeek.format(DATE_TIME_FORMAT),
|
|
66
|
+
endTime: startOfWeek.add(6, 'day').endOf('day').format(DATE_TIME_FORMAT)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
case 1:
|
|
70
|
+
return {
|
|
71
|
+
startTime: now.startOf('year').format(DATE_TIME_FORMAT),
|
|
72
|
+
endTime: now.endOf('year').format(DATE_TIME_FORMAT)
|
|
73
|
+
};
|
|
74
|
+
case 0:
|
|
75
|
+
default:
|
|
76
|
+
return {
|
|
77
|
+
startTime: now.startOf('month').format(DATE_TIME_FORMAT),
|
|
78
|
+
endTime: now.endOf('month').format(DATE_TIME_FORMAT)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
38
82
|
var Player = function Player(_ref) {
|
|
39
83
|
var _jsonConfig$pageConfi;
|
|
40
84
|
var jsonConfig = _ref.jsonConfig,
|
|
@@ -354,12 +398,6 @@ var Player = function Player(_ref) {
|
|
|
354
398
|
scadaId: scadaId
|
|
355
399
|
}
|
|
356
400
|
});
|
|
357
|
-
console.log('[186]-index.tsx', onEvent, {
|
|
358
|
-
event: 'freedom-scene-switch',
|
|
359
|
-
payload: {
|
|
360
|
-
scadaId: scadaId
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
401
|
case 1:
|
|
364
402
|
return _context5.a(2);
|
|
365
403
|
}
|
|
@@ -478,7 +516,7 @@ var Player = function Player(_ref) {
|
|
|
478
516
|
clearInterval(timer);
|
|
479
517
|
}
|
|
480
518
|
};
|
|
481
|
-
}, [query, jsonConfig, mittMeta]);
|
|
519
|
+
}, [query, jsonConfig, mittMeta, RefreshFrequency]);
|
|
482
520
|
useEffect(function () {}, [query, jsonConfig, mittMeta]);
|
|
483
521
|
// scene === 'freedom' 加载设备点位数据
|
|
484
522
|
useEffect(function () {
|
|
@@ -549,10 +587,11 @@ var Player = function Player(_ref) {
|
|
|
549
587
|
}();
|
|
550
588
|
var fetchDeviceSpecialPoint = /*#__PURE__*/function () {
|
|
551
589
|
var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(ids, dateType) {
|
|
552
|
-
var res, pointList;
|
|
590
|
+
var _getStatisticsTimeRan, startTime, endTime, res, pointList;
|
|
553
591
|
return _regenerator().w(function (_context9) {
|
|
554
592
|
while (1) switch (_context9.n) {
|
|
555
593
|
case 0:
|
|
594
|
+
_getStatisticsTimeRan = getStatisticsTimeRange(dateType), startTime = _getStatisticsTimeRan.startTime, endTime = _getStatisticsTimeRan.endTime;
|
|
556
595
|
_context9.n = 1;
|
|
557
596
|
return GetTdIndicatorAggregateData(ids.map(function (v) {
|
|
558
597
|
var productNo = {
|
|
@@ -565,8 +604,8 @@ var Player = function Player(_ref) {
|
|
|
565
604
|
indicatorNo: "".concat(str[0], "_").concat(str[1], "_").concat(productNo[str[0]]),
|
|
566
605
|
aggregateType: 3,
|
|
567
606
|
timeQuantumList: [{
|
|
568
|
-
startDate:
|
|
569
|
-
endDate:
|
|
607
|
+
startDate: startTime,
|
|
608
|
+
endDate: endTime
|
|
570
609
|
}]
|
|
571
610
|
};
|
|
572
611
|
}));
|
|
@@ -595,16 +634,68 @@ var Player = function Player(_ref) {
|
|
|
595
634
|
return _ref1.apply(this, arguments);
|
|
596
635
|
};
|
|
597
636
|
}();
|
|
598
|
-
var
|
|
599
|
-
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(
|
|
637
|
+
var fetchIndicatorSpecialPoint = /*#__PURE__*/function () {
|
|
638
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(ids, dateType) {
|
|
639
|
+
var _getStatisticsTimeRan2, startTime, endTime, res, pointList;
|
|
600
640
|
return _regenerator().w(function (_context0) {
|
|
601
641
|
while (1) switch (_context0.n) {
|
|
602
642
|
case 0:
|
|
643
|
+
_getStatisticsTimeRan2 = getStatisticsTimeRange(dateType), startTime = _getStatisticsTimeRan2.startTime, endTime = _getStatisticsTimeRan2.endTime;
|
|
644
|
+
_context0.n = 1;
|
|
645
|
+
return GetTdIndicatorHistoryData({
|
|
646
|
+
indicatorNoList: ids,
|
|
647
|
+
timeQuantum: {
|
|
648
|
+
startDate: dayjs(startTime).format(HISTORY_DATE_TIME_FORMAT),
|
|
649
|
+
endDate: dayjs(endTime).format(HISTORY_DATE_TIME_FORMAT)
|
|
650
|
+
},
|
|
651
|
+
interval: 0
|
|
652
|
+
});
|
|
653
|
+
case 1:
|
|
654
|
+
res = _context0.v;
|
|
655
|
+
if (res.success) {
|
|
656
|
+
_context0.n = 2;
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
message.error('璁惧鐐逛綅鏁版嵁鑾峰彇澶辫触');
|
|
660
|
+
return _context0.a(2);
|
|
661
|
+
case 2:
|
|
662
|
+
pointList = res.data || [];
|
|
663
|
+
pointList.forEach(function (v, index) {
|
|
664
|
+
var indicatorNo = v.indicatorNo || ids[index];
|
|
665
|
+
var totalValue = getIndicatorHistoryTotalValue(v.indicatorDataList);
|
|
666
|
+
emitter.emit("point-update-".concat(indicatorNo, "-").concat(mittMeta.namespace), _objectSpread(_objectSpread({}, v), {}, {
|
|
667
|
+
aggregateDataList: [{
|
|
668
|
+
val: totalValue,
|
|
669
|
+
ts: endTime
|
|
670
|
+
}],
|
|
671
|
+
indicatorData: {
|
|
672
|
+
val: totalValue,
|
|
673
|
+
ts: endTime
|
|
674
|
+
},
|
|
675
|
+
updateTime: endTime
|
|
676
|
+
}));
|
|
677
|
+
});
|
|
678
|
+
case 3:
|
|
679
|
+
return _context0.a(2);
|
|
680
|
+
}
|
|
681
|
+
}, _callee0);
|
|
682
|
+
}));
|
|
683
|
+
return function fetchIndicatorSpecialPoint(_x1, _x10) {
|
|
684
|
+
return _ref10.apply(this, arguments);
|
|
685
|
+
};
|
|
686
|
+
}();
|
|
687
|
+
var fetchEnergyByMeterList = /*#__PURE__*/function () {
|
|
688
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(type, ids, dateType) {
|
|
689
|
+
var _getStatisticsTimeRan3, startTime, endTime;
|
|
690
|
+
return _regenerator().w(function (_context1) {
|
|
691
|
+
while (1) switch (_context1.n) {
|
|
692
|
+
case 0:
|
|
693
|
+
_getStatisticsTimeRan3 = getStatisticsTimeRange(dateType), startTime = _getStatisticsTimeRan3.startTime, endTime = _getStatisticsTimeRan3.endTime;
|
|
603
694
|
GetEnergyByMeterList({
|
|
604
695
|
dataType: type,
|
|
605
696
|
meterIdList: ids,
|
|
606
|
-
startDateTime:
|
|
607
|
-
endDateTime:
|
|
697
|
+
startDateTime: startTime,
|
|
698
|
+
endDateTime: endTime,
|
|
608
699
|
dateType: 2
|
|
609
700
|
}).then(function (res) {
|
|
610
701
|
if (res.success) {
|
|
@@ -614,15 +705,16 @@ var Player = function Player(_ref) {
|
|
|
614
705
|
}
|
|
615
706
|
});
|
|
616
707
|
case 1:
|
|
617
|
-
return
|
|
708
|
+
return _context1.a(2);
|
|
618
709
|
}
|
|
619
|
-
},
|
|
710
|
+
}, _callee1);
|
|
620
711
|
}));
|
|
621
|
-
return function fetchEnergyByMeterList(
|
|
622
|
-
return
|
|
712
|
+
return function fetchEnergyByMeterList(_x11, _x12, _x13) {
|
|
713
|
+
return _ref11.apply(this, arguments);
|
|
623
714
|
};
|
|
624
715
|
}();
|
|
625
|
-
var
|
|
716
|
+
var pointTimer;
|
|
717
|
+
var indicatorTimer;
|
|
626
718
|
var specialPointTimer;
|
|
627
719
|
var meterPointTimer;
|
|
628
720
|
if (query.scene === 'freedom' && jsonConfig) {
|
|
@@ -670,59 +762,89 @@ var Player = function Player(_ref) {
|
|
|
670
762
|
});
|
|
671
763
|
if (pointIds.length > 0) {
|
|
672
764
|
fetchDevicePoints(pointIds);
|
|
673
|
-
|
|
765
|
+
pointTimer = setInterval(function () {
|
|
674
766
|
fetchDevicePoints(pointIds);
|
|
675
767
|
}, RefreshFrequency);
|
|
676
768
|
}
|
|
677
769
|
if (indicator.length > 0) {
|
|
678
770
|
fetchDeviceIndicator(indicator);
|
|
679
|
-
|
|
771
|
+
indicatorTimer = setInterval(function () {
|
|
680
772
|
fetchDeviceIndicator(indicator);
|
|
681
773
|
}, RefreshFrequency);
|
|
682
774
|
}
|
|
683
775
|
if (specialPoint.length) {
|
|
684
|
-
var
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
776
|
+
var statisticsDateList = _toConsumableArray(new Set(specialPoint.map(function (item) {
|
|
777
|
+
var _item$data$valueDate;
|
|
778
|
+
return (_item$data$valueDate = item.data.valueDate) !== null && _item$data$valueDate !== void 0 ? _item$data$valueDate : 0;
|
|
779
|
+
})));
|
|
780
|
+
var fetchSpecialPoints = function fetchSpecialPoints() {
|
|
781
|
+
statisticsDateList.forEach(function (dateType) {
|
|
782
|
+
var pointIds = specialPoint.filter(function (item) {
|
|
783
|
+
var _item$data$valueDate2;
|
|
784
|
+
return ((_item$data$valueDate2 = item.data.valueDate) !== null && _item$data$valueDate2 !== void 0 ? _item$data$valueDate2 : 0) === dateType;
|
|
785
|
+
}).filter(function (item) {
|
|
786
|
+
var _item$data$pointList$;
|
|
787
|
+
return ((_item$data$pointList$ = item.data.pointList[0]) === null || _item$data$pointList$ === void 0 ? void 0 : _item$data$pointList$.valueType) !== 'indicator';
|
|
788
|
+
}).map(function (item) {
|
|
789
|
+
var _item$data$pointList$2;
|
|
790
|
+
return (_item$data$pointList$2 = item.data.pointList[0]) === null || _item$data$pointList$2 === void 0 ? void 0 : _item$data$pointList$2.pointId;
|
|
791
|
+
}).filter(Boolean);
|
|
792
|
+
var indicatorNos = specialPoint.filter(function (item) {
|
|
793
|
+
var _item$data$valueDate3;
|
|
794
|
+
return ((_item$data$valueDate3 = item.data.valueDate) !== null && _item$data$valueDate3 !== void 0 ? _item$data$valueDate3 : 0) === dateType;
|
|
795
|
+
}).filter(function (item) {
|
|
796
|
+
var _item$data$pointList$3;
|
|
797
|
+
return ((_item$data$pointList$3 = item.data.pointList[0]) === null || _item$data$pointList$3 === void 0 ? void 0 : _item$data$pointList$3.valueType) === 'indicator';
|
|
798
|
+
}).map(function (item) {
|
|
799
|
+
var _item$data$pointList$4;
|
|
800
|
+
return (_item$data$pointList$4 = item.data.pointList[0]) === null || _item$data$pointList$4 === void 0 ? void 0 : _item$data$pointList$4.indicatorNo;
|
|
801
|
+
}).filter(Boolean);
|
|
802
|
+
if (pointIds.length > 0) {
|
|
803
|
+
fetchDeviceSpecialPoint(pointIds, dateType);
|
|
804
|
+
}
|
|
805
|
+
if (indicatorNos.length > 0) {
|
|
806
|
+
fetchIndicatorSpecialPoint(indicatorNos, dateType);
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
fetchSpecialPoints();
|
|
811
|
+
specialPointTimer = setInterval(fetchSpecialPoints, RefreshFrequency);
|
|
700
812
|
}
|
|
701
813
|
if (virtual.length) {
|
|
702
814
|
var dataType = _toConsumableArray(new Set(virtual.map(function (item) {
|
|
703
|
-
|
|
704
|
-
|
|
815
|
+
var _item$data$pointList$5;
|
|
816
|
+
return (_item$data$pointList$5 = item.data.pointList[0]) === null || _item$data$pointList$5 === void 0 ? void 0 : _item$data$pointList$5.dataType;
|
|
817
|
+
}).filter(Boolean)));
|
|
705
818
|
var valueDate = _toConsumableArray(new Set(virtual.map(function (item) {
|
|
706
|
-
|
|
819
|
+
var _item$data$valueDate4;
|
|
820
|
+
return (_item$data$valueDate4 = item.data.valueDate) !== null && _item$data$valueDate4 !== void 0 ? _item$data$valueDate4 : 0;
|
|
707
821
|
})));
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
822
|
+
var fetchVirtualPoints = function fetchVirtualPoints() {
|
|
823
|
+
dataType.forEach(function (type) {
|
|
824
|
+
valueDate.forEach(function (date) {
|
|
825
|
+
var ids = virtual.filter(function (item) {
|
|
826
|
+
var _item$data$pointList$6, _item$data$valueDate5;
|
|
827
|
+
return ((_item$data$pointList$6 = item.data.pointList[0]) === null || _item$data$pointList$6 === void 0 ? void 0 : _item$data$pointList$6.dataType) == type && ((_item$data$valueDate5 = item.data.valueDate) !== null && _item$data$valueDate5 !== void 0 ? _item$data$valueDate5 : 0) === date;
|
|
828
|
+
}).map(function (item) {
|
|
829
|
+
var _item$data$pointList$7;
|
|
830
|
+
return (_item$data$pointList$7 = item.data.pointList[0]) === null || _item$data$pointList$7 === void 0 ? void 0 : _item$data$pointList$7.meterId;
|
|
831
|
+
}).filter(Boolean);
|
|
832
|
+
if (ids.length > 0) {
|
|
833
|
+
fetchEnergyByMeterList(type, ids, date);
|
|
834
|
+
}
|
|
714
835
|
});
|
|
715
|
-
ids.length && fetchEnergyByMeterList(type, ids, date);
|
|
716
|
-
meterPointTimer = setInterval(function () {
|
|
717
|
-
ids.length && fetchEnergyByMeterList(type, ids, date);
|
|
718
|
-
}, RefreshFrequency);
|
|
719
836
|
});
|
|
720
|
-
}
|
|
837
|
+
};
|
|
838
|
+
fetchVirtualPoints();
|
|
839
|
+
meterPointTimer = setInterval(fetchVirtualPoints, RefreshFrequency);
|
|
721
840
|
}
|
|
722
841
|
}
|
|
723
842
|
return function () {
|
|
724
|
-
if (
|
|
725
|
-
clearInterval(
|
|
843
|
+
if (pointTimer) {
|
|
844
|
+
clearInterval(pointTimer);
|
|
845
|
+
}
|
|
846
|
+
if (indicatorTimer) {
|
|
847
|
+
clearInterval(indicatorTimer);
|
|
726
848
|
}
|
|
727
849
|
if (specialPointTimer) {
|
|
728
850
|
clearInterval(specialPointTimer);
|
|
@@ -731,7 +853,7 @@ var Player = function Player(_ref) {
|
|
|
731
853
|
clearInterval(meterPointTimer);
|
|
732
854
|
}
|
|
733
855
|
};
|
|
734
|
-
}, [query, jsonConfig, mittMeta]);
|
|
856
|
+
}, [query, jsonConfig, mittMeta, RefreshFrequency]);
|
|
735
857
|
useEffect(function () {
|
|
736
858
|
var graph = graphRef.current;
|
|
737
859
|
if (jsonConfig && graph && query) {
|