coolcare-lite-scada-component 2.0.34 → 2.0.36

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.
@@ -26,9 +26,10 @@ 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
- /** 刷新频率 */
30
- var RefreshFrequency = 10 * 1000;
29
+ import { GetTdIndicatorAggregateData } from "../../../services/gateway/Point";
30
+ import dayjs from 'dayjs';
31
31
  var Player = function Player(_ref) {
32
+ var _jsonConfig$pageConfi;
32
33
  var jsonConfig = _ref.jsonConfig,
33
34
  query = _ref.query,
34
35
  onEvent = _ref.onEvent;
@@ -63,6 +64,9 @@ var Player = function Player(_ref) {
63
64
  var mittMeta = useMemo(function () {
64
65
  return getMittMeta(query);
65
66
  }, [query]);
67
+
68
+ /** 刷新频率 */
69
+ var RefreshFrequency = ((jsonConfig === null || jsonConfig === void 0 ? void 0 : (_jsonConfig$pageConfi = jsonConfig.pageConfig) === null || _jsonConfig$pageConfi === void 0 ? void 0 : _jsonConfig$pageConfi.refreshFrequency) || 1.5 * 60) * 1000;
66
70
  useEffect(function () {
67
71
  window.scadaMode = 'player';
68
72
  return function () {
@@ -71,11 +75,11 @@ var Player = function Player(_ref) {
71
75
  }, []);
72
76
  useEffect(function () {
73
77
  if (jsonConfig) {
74
- var _jsonConfig$pageConfi, _window$parent;
78
+ var _jsonConfig$pageConfi2, _window$parent;
75
79
  var msg = {
76
80
  event: 'scada-config-loaded',
77
81
  payload: {
78
- dimensions: (jsonConfig === null || jsonConfig === void 0 ? void 0 : (_jsonConfig$pageConfi = jsonConfig.pageConfig) === null || _jsonConfig$pageConfi === void 0 ? void 0 : _jsonConfig$pageConfi.dimensions) || {
82
+ dimensions: (jsonConfig === null || jsonConfig === void 0 ? void 0 : (_jsonConfig$pageConfi2 = jsonConfig.pageConfig) === null || _jsonConfig$pageConfi2 === void 0 ? void 0 : _jsonConfig$pageConfi2.dimensions) || {
79
83
  width: 341,
80
84
  height: 500
81
85
  },
@@ -265,7 +269,13 @@ var Player = function Player(_ref) {
265
269
  scadaId: scadaId
266
270
  }
267
271
  });
268
- case 1:
272
+ console.log('[186]-index.tsx', onEvent, {
273
+ event: 'freedom-scene-switch',
274
+ payload: {
275
+ scadaId: scadaId
276
+ }
277
+ });
278
+ case 2:
269
279
  case "end":
270
280
  return _context4.stop();
271
281
  }
@@ -315,13 +325,13 @@ var Player = function Player(_ref) {
315
325
  });
316
326
  }, [query, mittMeta]);
317
327
  useEffect(function () {
318
- var _jsonConfig$pageConfi2, _graphRef$current3;
328
+ var _jsonConfig$pageConfi3, _graphRef$current3;
319
329
  if (!wrapSize || !jsonConfig || !query) return;
320
- if (query.zoomMode === 'width' && (jsonConfig === null || jsonConfig === void 0 ? void 0 : (_jsonConfig$pageConfi2 = jsonConfig.pageConfig) === null || _jsonConfig$pageConfi2 === void 0 ? void 0 : _jsonConfig$pageConfi2.dimensions)) {
330
+ if (query.zoomMode === 'width' && (jsonConfig === null || jsonConfig === void 0 ? void 0 : (_jsonConfig$pageConfi3 = jsonConfig.pageConfig) === null || _jsonConfig$pageConfi3 === void 0 ? void 0 : _jsonConfig$pageConfi3.dimensions)) {
321
331
  var _graphRef$current;
322
- var _jsonConfig$pageConfi3 = jsonConfig.pageConfig.dimensions,
323
- width = _jsonConfig$pageConfi3.width,
324
- height = _jsonConfig$pageConfi3.height;
332
+ var _jsonConfig$pageConfi4 = jsonConfig.pageConfig.dimensions,
333
+ width = _jsonConfig$pageConfi4.width,
334
+ height = _jsonConfig$pageConfi4.height;
325
335
  var scale = wrapSize.width / width;
326
336
  (_graphRef$current = graphRef.current) === null || _graphRef$current === void 0 ? void 0 : _graphRef$current.resize(width * scale, height * scale);
327
337
  } else {
@@ -386,7 +396,7 @@ var Player = function Player(_ref) {
386
396
  }
387
397
  };
388
398
  }, [query, jsonConfig, mittMeta]);
389
-
399
+ useEffect(function () {}, [query, jsonConfig, mittMeta]);
390
400
  // scene === 'freedom' 加载设备点位数据
391
401
  useEffect(function () {
392
402
  var fetchDevicePoints = /*#__PURE__*/function () {
@@ -422,15 +432,71 @@ var Player = function Player(_ref) {
422
432
  return _ref8.apply(this, arguments);
423
433
  };
424
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 GetTdIndicatorAggregateData(ids.map(function (v) {
443
+ var productNo = {
444
+ emqktt: 'energy',
445
+ mrwtn4: 'steamc',
446
+ kf78l3: 'waterc'
447
+ };
448
+ var str = v.split('_');
449
+ return {
450
+ indicatorNo: "".concat(str[0], "_").concat(str[1], "_").concat(productNo[str[0]]),
451
+ aggregateType: 3,
452
+ timeQuantumList: [{
453
+ startDate: dayjs().startOf(dateType == 0 ? "month" : "year").format('YYYY-MM-DD HH:mm:ss'),
454
+ endDate: dayjs().endOf(dateType == 0 ? "month" : "year").format('YYYY-MM-DD HH:mm:ss')
455
+ }]
456
+ };
457
+ }));
458
+ case 2:
459
+ res = _context7.sent;
460
+ if (res.success) {
461
+ _context7.next = 6;
462
+ break;
463
+ }
464
+ message.error('设备点位数据获取失败');
465
+ return _context7.abrupt("return");
466
+ case 6:
467
+ pointList = res.data || [];
468
+ pointList.forEach(function (v) {
469
+ var pointId = ids.find(function (id) {
470
+ return id.includes(v.deviceNo);
471
+ });
472
+ emitter.emit("point-update-".concat(pointId, "-").concat(mittMeta.namespace), v);
473
+ });
474
+ case 8:
475
+ case "end":
476
+ return _context7.stop();
477
+ }
478
+ }, _callee7);
479
+ }));
480
+ return function fetchDeviceSpecialPoint(_x7, _x8) {
481
+ return _ref9.apply(this, arguments);
482
+ };
483
+ }();
425
484
  var timer;
485
+ var specialPointTimer;
426
486
  if (query.scene === 'freedom' && jsonConfig) {
427
487
  var _jsonConfig$cells;
428
488
  var pointIds = [];
489
+ var specialPoint = [];
429
490
  jsonConfig === null || jsonConfig === void 0 ? void 0 : (_jsonConfig$cells = jsonConfig.cells) === null || _jsonConfig$cells === void 0 ? void 0 : _jsonConfig$cells.forEach(function (cell) {
430
- var _cell$data, _cell$data$pointList;
431
- 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) {
432
- pointIds.push(point.pointId);
433
- });
491
+ var _cell$data;
492
+ if ((cell === null || cell === void 0 ? void 0 : (_cell$data = cell.data) === null || _cell$data === void 0 ? void 0 : _cell$data.valueType) == 1) {
493
+ specialPoint.push(cell);
494
+ } else {
495
+ var _cell$data2, _cell$data2$pointList;
496
+ 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) {
497
+ pointIds.push(point.pointId);
498
+ });
499
+ }
434
500
 
435
501
  // ele-fan 元素单独处理
436
502
  if (cell.shape === 'ele-fan') {
@@ -458,6 +524,24 @@ var Player = function Player(_ref) {
458
524
  fetchDevicePoints(pointIds);
459
525
  }, RefreshFrequency);
460
526
  }
527
+ if (specialPoint.length) {
528
+ var monthPoint = specialPoint.filter(function (item) {
529
+ return item.data.valueDate == 0;
530
+ }).map(function (item) {
531
+ return item.data.pointList[0].pointId;
532
+ });
533
+ var yaerPoint = specialPoint.filter(function (item) {
534
+ return item.data.valueDate == 1;
535
+ }).map(function (item) {
536
+ return item.data.pointList[0].pointId;
537
+ });
538
+ monthPoint.length && fetchDeviceSpecialPoint(monthPoint, 0);
539
+ yaerPoint.length && fetchDeviceSpecialPoint(yaerPoint, 1);
540
+ specialPointTimer = setInterval(function () {
541
+ monthPoint.length && fetchDeviceSpecialPoint(monthPoint, 0);
542
+ yaerPoint.length && fetchDeviceSpecialPoint(yaerPoint, 1);
543
+ }, RefreshFrequency);
544
+ }
461
545
  }
462
546
  return function () {
463
547
  if (timer) {
@@ -502,7 +586,9 @@ var Player = function Player(_ref) {
502
586
  onCancel: function onCancel() {
503
587
  return setVisibleDialogHistory(false);
504
588
  },
505
- pointIdListProp: activePointIds
589
+ pointIdListProp: activePointIds,
590
+ companyId: query.companyId,
591
+ projectId: query.projectId
506
592
  }), /*#__PURE__*/React.createElement(DialogPointWrite, {
507
593
  visible: visibleDialogPointWrite,
508
594
  points: activePoints,
@@ -42,7 +42,8 @@ var LayerForm = function LayerForm() {
42
42
  backgroundColor = values.backgroundColor,
43
43
  borderRadius = values.borderRadius,
44
44
  backgroundImage = values.backgroundImage,
45
- dimensionsSelectValue = values.dimensionsSelectValue;
45
+ dimensionsSelectValue = values.dimensionsSelectValue,
46
+ refreshFrequency = values.refreshFrequency;
46
47
  var width = values.width,
47
48
  height = values.height;
48
49
  if (dimensionsSelectValue !== '自定义') {
@@ -64,7 +65,8 @@ var LayerForm = function LayerForm() {
64
65
  title: title,
65
66
  backgroundColor: backgroundColor,
66
67
  backgroundImage: backgroundImage,
67
- borderRadius: borderRadius
68
+ borderRadius: borderRadius,
69
+ refreshFrequency: refreshFrequency
68
70
  }));
69
71
  }, {
70
72
  leading: false,
@@ -138,6 +140,14 @@ var LayerForm = function LayerForm() {
138
140
  autoComplete: "off",
139
141
  onValuesChange: onFormChange
140
142
  }, /*#__PURE__*/React.createElement(Form.Item, {
143
+ name: "refreshFrequency",
144
+ label: "\u5237\u65B0\u9891\u7387"
145
+ }, /*#__PURE__*/React.createElement(InputNumber, {
146
+ min: 5,
147
+ max: 999,
148
+ defaultValue: 90,
149
+ addonBefore: "秒"
150
+ })), /*#__PURE__*/React.createElement(Form.Item, {
141
151
  name: "dimensionsSelectValue",
142
152
  label: "\u5206\u8FA8\u7387"
143
153
  }, /*#__PURE__*/React.createElement(Select, {
@@ -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
+ /** 获取点位历史数据 POST /api/GatewayMicro/Point/GetPointHistoryData */
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,53 @@ function _DownHistoryDataToExcelOrPdf() {
133
134
  }
134
135
  }, _callee5);
135
136
  }));
137
+ return _GetPointAggregationData.apply(this, arguments);
138
+ }
139
+ export function GetTdIndicatorAggregateData(_x11, _x12) {
140
+ return _GetTdIndicatorAggregateData.apply(this, arguments);
141
+ }
142
+
143
+ /** 历史数据导出xlsx货pdf(支持进度条) POST /api/GatewayMicro/Point/DownHistoryDataToExcelOrPdf */
144
+ function _GetTdIndicatorAggregateData() {
145
+ _GetTdIndicatorAggregateData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(body, options) {
146
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
147
+ while (1) switch (_context6.prev = _context6.next) {
148
+ case 0:
149
+ return _context6.abrupt("return", request('/api/GatewayMicro/DeviceIndicator/GetTdIndicatorAggregateData', _objectSpread({
150
+ method: 'POST',
151
+ headers: {
152
+ 'Content-Type': 'application/json-patch+json'
153
+ },
154
+ data: body
155
+ }, options || {})));
156
+ case 1:
157
+ case "end":
158
+ return _context6.stop();
159
+ }
160
+ }, _callee6);
161
+ }));
162
+ return _GetTdIndicatorAggregateData.apply(this, arguments);
163
+ }
164
+ export function DownHistoryDataToExcelOrPdf(_x13, _x14) {
165
+ return _DownHistoryDataToExcelOrPdf.apply(this, arguments);
166
+ }
167
+ function _DownHistoryDataToExcelOrPdf() {
168
+ _DownHistoryDataToExcelOrPdf = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(body, options) {
169
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
170
+ while (1) switch (_context7.prev = _context7.next) {
171
+ case 0:
172
+ return _context7.abrupt("return", request('/api/GatewayMicro/Point/DownHistoryDataToExcelOrPdf', _objectSpread({
173
+ method: 'POST',
174
+ headers: {
175
+ 'Content-Type': 'application/json-patch+json'
176
+ },
177
+ data: body
178
+ }, options || {})));
179
+ case 1:
180
+ case "end":
181
+ return _context7.stop();
182
+ }
183
+ }, _callee7);
184
+ }));
136
185
  return _DownHistoryDataToExcelOrPdf.apply(this, arguments);
137
186
  }
package/es/typings.d.ts CHANGED
@@ -29,30 +29,34 @@ type EditorQuery =
29
29
  scadaType: '0' | '1';
30
30
  /** 来源 */
31
31
  from?: string;
32
+ /** 公司 id */
33
+ companyId: string;
32
34
  /** 项目 id */
33
35
  projectId?: string;
34
36
  }
35
37
  | {
36
38
  scene: 'device';
39
+ /** 公司 id */
40
+ companyId: string;
41
+ /** 项目 id */
42
+ projectId?: string;
37
43
  /** scene = 'device' 时传设备 id */
38
44
  deviceId: string;
39
45
  /** 组态类型:web | app */
40
46
  scadaType: '0' | '1';
41
47
  /** 来源 */
42
48
  from?: string;
43
- /** 项目 id */
44
- projectId?: string;
45
49
  }
46
50
  | {
47
51
  scene: 'freedom';
48
52
  /** 组态 id */
49
53
  scadaId: string;
50
- /** 公司 id */
51
- companyId: string;
52
54
  /** 组态标题 */
53
55
  title: string;
54
56
  /** 来源 */
55
57
  from?: string;
58
+ /** 公司 id */
59
+ companyId: string;
56
60
  /** 项目 id */
57
61
  projectId?: string;
58
62
  };
@@ -84,6 +88,10 @@ type PlayerQuery =
84
88
  token?: string;
85
89
  /** 刷新token */
86
90
  xToken?: string;
91
+ /** 公司 id */
92
+ companyId: string;
93
+ /** 项目 id */
94
+ projectId?: string;
87
95
  }
88
96
  | {
89
97
  /** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "2.0.34",
3
+ "version": "2.0.36",
4
4
  "scripts": {
5
- "start": "umi dev",
5
+ "start": " umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",
7
7
  "build:generalfushi": "UMI_ENV=prod REACT_APP_PLATFORM=generalfushi umi build",
8
8
  "build:yimin": "UMI_ENV=prod REACT_APP_PLATFORM=yimin umi build",