coolcare-lite-scada-component 1.0.33 → 1.0.35

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.
@@ -400,7 +400,8 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
400
400
  rules: [{
401
401
  required: true,
402
402
  message: '请选择时间范围'
403
- }]
403
+ }],
404
+ className: "temperatureDateRange"
404
405
  }, /*#__PURE__*/React.createElement(RangePicker, {
405
406
  disabled: loading,
406
407
  style: {
@@ -415,7 +416,10 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
415
416
  近一周: [moment().subtract(7, 'day'), moment()],
416
417
  近一个月: [moment().subtract(30, 'day'), moment()]
417
418
  },
418
- format: "YYYY-MM-DD HH:mm"
419
+ format: "YYYY-MM-DD HH:mm",
420
+ getPopupContainer: function getPopupContainer() {
421
+ return document.querySelector(".temperatureDateRange") || document.body;
422
+ }
419
423
  })), /*#__PURE__*/React.createElement(Form.Item, {
420
424
  name: "interval",
421
425
  label: "\u95F4\u9694\uFF08\u5206\u949F\uFF09",
@@ -17,7 +17,7 @@ var directionClassNameMap = {
17
17
  bottom: 'flex-col-reverse'
18
18
  };
19
19
  var ElePointValueComponent = function ElePointValueComponent(_ref) {
20
- var _payload$pointList, _payload$label, _payload$unit, _payload$unit2, _payload$value, _payload$value2, _payload$mittMeta$nam, _payload$mittMeta, _payload$mittMeta2, _payload$label2, _pointValue, _payload$unit3;
20
+ var _payload$pointList, _payload$label, _payload$unit, _payload$unit2, _payload$value, _payload$value2, _payload$mittMeta$nam, _payload$mittMeta, _payload$mittMeta2, _pointData$pointDataL, _pointData$pointDataL2, _payload$label2, _pointValue, _payload$unit3;
21
21
  var node = _ref.node;
22
22
  var payload = node === null || node === void 0 ? void 0 : node.getData();
23
23
  var configPoint = payload === null || payload === void 0 ? void 0 : (_payload$pointList = payload.pointList) === null || _payload$pointList === void 0 ? void 0 : _payload$pointList[0];
@@ -36,23 +36,24 @@ var ElePointValueComponent = function ElePointValueComponent(_ref) {
36
36
  }
37
37
  });
38
38
  var pointData = usePointWatch(configPoint, payload === null || payload === void 0 ? void 0 : (_payload$mittMeta2 = payload.mittMeta) === null || _payload$mittMeta2 === void 0 ? void 0 : _payload$mittMeta2.namespace);
39
+ var value = (pointData === null || pointData === void 0 ? void 0 : pointData.value) || (pointData === null || pointData === void 0 ? void 0 : (_pointData$pointDataL = pointData.pointDataList) === null || _pointData$pointDataL === void 0 ? void 0 : (_pointData$pointDataL2 = _pointData$pointDataL[0]) === null || _pointData$pointDataL2 === void 0 ? void 0 : _pointData$pointDataL2.val) || '-';
39
40
  var tooltipTitle = null;
40
41
  if (!configPoint) {
41
42
  tooltipTitle = '未绑定点位';
42
43
  } else {
43
- var _pointData$value, _pointData$unit;
44
- tooltipTitle = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, "\u70B9\u4F4D\u540D\u79F0\uFF1A", (pointData === null || pointData === void 0 ? void 0 : pointData.pointName) || '-'), /*#__PURE__*/React.createElement("div", null, "\u70B9\u4F4D\u503C\uFF1A", (_pointData$value = pointData === null || pointData === void 0 ? void 0 : pointData.value) !== null && _pointData$value !== void 0 ? _pointData$value : '-', " ", (_pointData$unit = pointData === null || pointData === void 0 ? void 0 : pointData.unit) !== null && _pointData$unit !== void 0 ? _pointData$unit : '-'), /*#__PURE__*/React.createElement("div", null, "\u66F4\u65B0\u65F6\u95F4\uFF1A", (pointData === null || pointData === void 0 ? void 0 : pointData.updateTime) || '-'));
44
+ var _pointData$unit;
45
+ tooltipTitle = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, "\u70B9\u4F4D\u540D\u79F0\uFF1A", (pointData === null || pointData === void 0 ? void 0 : pointData.pointName) || '-'), /*#__PURE__*/React.createElement("div", null, "\u70B9\u4F4D\u503C\uFF1A", value, " ", (_pointData$unit = pointData === null || pointData === void 0 ? void 0 : pointData.unit) !== null && _pointData$unit !== void 0 ? _pointData$unit : '-'), /*#__PURE__*/React.createElement("div", null, "\u66F4\u65B0\u65F6\u95F4\uFF1A", (pointData === null || pointData === void 0 ? void 0 : pointData.updateTime) || '-'));
45
46
  }
46
47
  var pointValue = '';
47
48
  if (window.scadaMode === 'edit') {
48
49
  pointValue = '点位值';
49
50
  } else {
50
51
  if (configPoint === null || configPoint === void 0 ? void 0 : configPoint.expressions) {
51
- pointValue = getValueByExpression(pointData === null || pointData === void 0 ? void 0 : pointData.value, configPoint === null || configPoint === void 0 ? void 0 : configPoint.expressions);
52
+ pointValue = getValueByExpression(value, configPoint === null || configPoint === void 0 ? void 0 : configPoint.expressions);
52
53
  }
53
- pointValue = (pointData === null || pointData === void 0 ? void 0 : pointData.pointEnumItemKey) || (pointData === null || pointData === void 0 ? void 0 : pointData.value);
54
+ pointValue = (pointData === null || pointData === void 0 ? void 0 : pointData.pointEnumItemKey) || value;
54
55
  }
55
- var numberColor = getValueByExpression(pointData === null || pointData === void 0 ? void 0 : pointData.value, payload === null || payload === void 0 ? void 0 : payload.colorExpressions);
56
+ var numberColor = getValueByExpression(value, payload === null || payload === void 0 ? void 0 : payload.colorExpressions);
56
57
  return /*#__PURE__*/React.createElement("div", {
57
58
  onClick: function onClick(e) {
58
59
  return eventHandles.current.onClick(e);
@@ -0,0 +1,75 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
+ import React from "react";
14
+ import { Form, Select } from 'antd';
15
+ import { useModel } from 'umi';
16
+ import { useEffect } from 'react';
17
+ var StatisticsPropsSet = function StatisticsPropsSet() {
18
+ var _useModel = useModel('useEditor', function (model) {
19
+ return {
20
+ activeNode: model.activeNode
21
+ };
22
+ }),
23
+ activeNode = _useModel.activeNode;
24
+ var _Form$useForm = Form.useForm(),
25
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
26
+ StatisticsForm = _Form$useForm2[0];
27
+ useEffect(function () {
28
+ if (!activeNode) {
29
+ return;
30
+ }
31
+ var data = activeNode.getData();
32
+ StatisticsForm.setFieldsValue({
33
+ valueType: data.valueType || 0,
34
+ valueDate: data.valueDate || 0
35
+ });
36
+ }, [activeNode, StatisticsForm]);
37
+ var onUnitFormChange = function onUnitFormChange(changedValues, values) {
38
+ activeNode === null || activeNode === void 0 ? void 0 : activeNode.setData(_objectSpread({}, values), {
39
+ deep: false
40
+ });
41
+ };
42
+ return /*#__PURE__*/React.createElement(Form, {
43
+ form: StatisticsForm,
44
+ size: "small",
45
+ labelCol: {
46
+ span: 8
47
+ },
48
+ onValuesChange: onUnitFormChange
49
+ }, /*#__PURE__*/React.createElement(Form.Item, {
50
+ name: "valueType",
51
+ label: "\u7EDF\u8BA1\u65B9\u5F0F"
52
+ }, /*#__PURE__*/React.createElement(Select, {
53
+ defaultValue: 0,
54
+ options: [{
55
+ label: '当前值',
56
+ value: 0
57
+ }, {
58
+ label: '累计值',
59
+ value: 1
60
+ }]
61
+ })), /*#__PURE__*/React.createElement(Form.Item, {
62
+ name: "valueDate",
63
+ label: "\u7EDF\u8BA1\u65F6\u95F4"
64
+ }, /*#__PURE__*/React.createElement(Select, {
65
+ defaultValue: 0,
66
+ options: [{
67
+ label: '本月',
68
+ value: 0
69
+ }, {
70
+ label: '本年',
71
+ value: 1
72
+ }]
73
+ })));
74
+ };
75
+ export default StatisticsPropsSet;
@@ -7,6 +7,7 @@ import GlobalPropsSet from "./GlobalPropSet";
7
7
  import TitlePropsSet from "./TitlePropsSet";
8
8
  import UnitPropsSet from "./UnitPropsSet";
9
9
  import ValuePropsSet from "./ValuePropsSet";
10
+ import StatisticsPropsSet from "./StatisticsPropsSet";
10
11
  var Panel = Collapse.Panel;
11
12
  var PropsSet = function PropsSet() {
12
13
  var forceUpdate = useForceUpdate();
@@ -36,6 +37,9 @@ var PropsSet = function PropsSet() {
36
37
  }, /*#__PURE__*/React.createElement(TitlePropsSet, null)), /*#__PURE__*/React.createElement(Panel, {
37
38
  header: "\u540E\u7F00",
38
39
  key: "5"
39
- }, /*#__PURE__*/React.createElement(UnitPropsSet, null)));
40
+ }, /*#__PURE__*/React.createElement(UnitPropsSet, null)), /*#__PURE__*/React.createElement(Panel, {
41
+ header: "\u7EDF\u8BA1\u65B9\u5F0F",
42
+ key: "6"
43
+ }, /*#__PURE__*/React.createElement(StatisticsPropsSet, null)));
40
44
  };
41
45
  export default PropsSet;
@@ -26,6 +26,8 @@ import ModalFanDevicePoint from "../../../components/ModalFanDevicePoint";
26
26
  import emitter from "../../../utils/events";
27
27
  import { GetDevicePoint } from "../../../services/gateway/Device";
28
28
  import "./index.css";
29
+ import { GetPointAggregationData } from "../../../services/gateway/Point";
30
+ import dayjs from 'dayjs';
29
31
  var Player = function Player(_ref) {
30
32
  var _jsonConfig$pageConfi;
31
33
  var jsonConfig = _ref.jsonConfig,
@@ -394,7 +396,7 @@ var Player = function Player(_ref) {
394
396
  }
395
397
  };
396
398
  }, [query, jsonConfig, mittMeta]);
397
-
399
+ useEffect(function () {}, [query, jsonConfig, mittMeta]);
398
400
  // scene === 'freedom' 加载设备点位数据
399
401
  useEffect(function () {
400
402
  var fetchDevicePoints = /*#__PURE__*/function () {
@@ -430,15 +432,64 @@ var Player = function Player(_ref) {
430
432
  return _ref8.apply(this, arguments);
431
433
  };
432
434
  }();
435
+ var fetchDeviceSpecialPoint = /*#__PURE__*/function () {
436
+ var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(ids, dateType) {
437
+ var res, pointList;
438
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
439
+ while (1) switch (_context7.prev = _context7.next) {
440
+ case 0:
441
+ _context7.next = 2;
442
+ return GetPointAggregationData({
443
+ pointQueryArg: {
444
+ pointIdList: ids
445
+ },
446
+ timeQuantum: {
447
+ startDate: dayjs().startOf(dateType == 0 ? "month" : "year").format('YYYY-MM-DD HH:mm:ss'),
448
+ endDate: dayjs().endOf(dateType == 0 ? "month" : "year").format('YYYY-MM-DD HH:mm:ss')
449
+ },
450
+ timeUnit: dateType == 0 ? 7 : 8,
451
+ interval: 1,
452
+ aggregationFunc: 5
453
+ });
454
+ case 2:
455
+ res = _context7.sent;
456
+ if (res.success) {
457
+ _context7.next = 6;
458
+ break;
459
+ }
460
+ message.error('设备点位数据获取失败');
461
+ return _context7.abrupt("return");
462
+ case 6:
463
+ pointList = res.data || [];
464
+ pointList.forEach(function (v) {
465
+ emitter.emit("point-update-".concat(v.pointId, "-").concat(mittMeta.namespace), v);
466
+ });
467
+ case 8:
468
+ case "end":
469
+ return _context7.stop();
470
+ }
471
+ }, _callee7);
472
+ }));
473
+ return function fetchDeviceSpecialPoint(_x7, _x8) {
474
+ return _ref9.apply(this, arguments);
475
+ };
476
+ }();
433
477
  var timer;
478
+ var specialPointTimer;
434
479
  if (query.scene === 'freedom' && jsonConfig) {
435
480
  var _jsonConfig$cells;
436
481
  var pointIds = [];
482
+ var specialPoint = [];
437
483
  jsonConfig === null || jsonConfig === void 0 ? void 0 : (_jsonConfig$cells = jsonConfig.cells) === null || _jsonConfig$cells === void 0 ? void 0 : _jsonConfig$cells.forEach(function (cell) {
438
- var _cell$data, _cell$data$pointList;
439
- cell === null || cell === void 0 ? void 0 : (_cell$data = cell.data) === null || _cell$data === void 0 ? void 0 : (_cell$data$pointList = _cell$data.pointList) === null || _cell$data$pointList === void 0 ? void 0 : _cell$data$pointList.forEach(function (point) {
440
- pointIds.push(point.pointId);
441
- });
484
+ var _cell$data;
485
+ if ((cell === null || cell === void 0 ? void 0 : (_cell$data = cell.data) === null || _cell$data === void 0 ? void 0 : _cell$data.valueType) == 1) {
486
+ specialPoint.push(cell);
487
+ } else {
488
+ var _cell$data2, _cell$data2$pointList;
489
+ cell === null || cell === void 0 ? void 0 : (_cell$data2 = cell.data) === null || _cell$data2 === void 0 ? void 0 : (_cell$data2$pointList = _cell$data2.pointList) === null || _cell$data2$pointList === void 0 ? void 0 : _cell$data2$pointList.forEach(function (point) {
490
+ pointIds.push(point.pointId);
491
+ });
492
+ }
442
493
 
443
494
  // ele-fan 元素单独处理
444
495
  if (cell.shape === 'ele-fan') {
@@ -466,6 +517,24 @@ var Player = function Player(_ref) {
466
517
  fetchDevicePoints(pointIds);
467
518
  }, RefreshFrequency);
468
519
  }
520
+ if (specialPoint.length) {
521
+ var monthPoint = specialPoint.filter(function (item) {
522
+ return item.data.valueDate == 0;
523
+ }).map(function (item) {
524
+ return item.data.pointList[0].pointId;
525
+ });
526
+ var yaerPoint = specialPoint.filter(function (item) {
527
+ return item.data.valueDate == 1;
528
+ }).map(function (item) {
529
+ return item.data.pointList[0].pointId;
530
+ });
531
+ monthPoint.length && fetchDeviceSpecialPoint(monthPoint, 0);
532
+ yaerPoint.length && fetchDeviceSpecialPoint(yaerPoint, 1);
533
+ specialPointTimer = setInterval(function () {
534
+ monthPoint.length && fetchDeviceSpecialPoint(monthPoint, 0);
535
+ yaerPoint.length && fetchDeviceSpecialPoint(yaerPoint, 1);
536
+ }, RefreshFrequency);
537
+ }
469
538
  }
470
539
  return function () {
471
540
  if (timer) {
@@ -90,8 +90,7 @@ function _GetPointPage() {
90
90
  export function GetPointHistoryData(_x7, _x8) {
91
91
  return _GetPointHistoryData.apply(this, arguments);
92
92
  }
93
-
94
- /** 历史数据导出xlsx货pdf(支持进度条) POST /api/GatewayMicro/Point/DownHistoryDataToExcelOrPdf */
93
+ /** 获取点位历史数据 POST /api/GatewayMicro/Point/GetPointHistoryData */
95
94
  function _GetPointHistoryData() {
96
95
  _GetPointHistoryData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(body, options) {
97
96
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -112,15 +111,17 @@ function _GetPointHistoryData() {
112
111
  }));
113
112
  return _GetPointHistoryData.apply(this, arguments);
114
113
  }
115
- export function DownHistoryDataToExcelOrPdf(_x9, _x10) {
116
- return _DownHistoryDataToExcelOrPdf.apply(this, arguments);
114
+ export function GetPointAggregationData(_x9, _x10) {
115
+ return _GetPointAggregationData.apply(this, arguments);
117
116
  }
118
- function _DownHistoryDataToExcelOrPdf() {
119
- _DownHistoryDataToExcelOrPdf = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(body, options) {
117
+
118
+ /** 历史数据导出xlsx货pdf(支持进度条) POST /api/GatewayMicro/Point/DownHistoryDataToExcelOrPdf */
119
+ function _GetPointAggregationData() {
120
+ _GetPointAggregationData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(body, options) {
120
121
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
121
122
  while (1) switch (_context5.prev = _context5.next) {
122
123
  case 0:
123
- return _context5.abrupt("return", request('/api/GatewayMicro/Point/DownHistoryDataToExcelOrPdf', _objectSpread({
124
+ return _context5.abrupt("return", request('/api/GatewayMicro/Point/GetPointAggregationData', _objectSpread({
124
125
  method: 'POST',
125
126
  headers: {
126
127
  'Content-Type': 'application/json-patch+json'
@@ -133,5 +134,28 @@ function _DownHistoryDataToExcelOrPdf() {
133
134
  }
134
135
  }, _callee5);
135
136
  }));
137
+ return _GetPointAggregationData.apply(this, arguments);
138
+ }
139
+ export function DownHistoryDataToExcelOrPdf(_x11, _x12) {
140
+ return _DownHistoryDataToExcelOrPdf.apply(this, arguments);
141
+ }
142
+ function _DownHistoryDataToExcelOrPdf() {
143
+ _DownHistoryDataToExcelOrPdf = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(body, options) {
144
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
145
+ while (1) switch (_context6.prev = _context6.next) {
146
+ case 0:
147
+ return _context6.abrupt("return", request('/api/GatewayMicro/Point/DownHistoryDataToExcelOrPdf', _objectSpread({
148
+ method: 'POST',
149
+ headers: {
150
+ 'Content-Type': 'application/json-patch+json'
151
+ },
152
+ data: body
153
+ }, options || {})));
154
+ case 1:
155
+ case "end":
156
+ return _context6.stop();
157
+ }
158
+ }, _callee6);
159
+ }));
136
160
  return _DownHistoryDataToExcelOrPdf.apply(this, arguments);
137
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "scripts": {
5
5
  "start": "umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",