coolcare-lite-scada-component 1.0.60 → 1.0.62

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.
@@ -50,8 +50,13 @@ var ElePointValueComponent = function ElePointValueComponent(_ref) {
50
50
  value = Number(value.toFixed(1));
51
51
  }
52
52
  } else if ('metricsList' in (pointData || {})) {
53
- var _pointData3, _pointData3$metricsLi, _pointData3$metricsLi2, _pointData4;
54
- value = (_pointData3 = pointData) === null || _pointData3 === void 0 ? void 0 : (_pointData3$metricsLi = _pointData3.metricsList) === null || _pointData3$metricsLi === void 0 ? void 0 : (_pointData3$metricsLi2 = _pointData3$metricsLi[0]) === null || _pointData3$metricsLi2 === void 0 ? void 0 : _pointData3$metricsLi2.val;
53
+ var _pointData3, _pointData3$metricsLi, _pointData4;
54
+ value = Number((_pointData3 = pointData) === null || _pointData3 === void 0 ? void 0 : (_pointData3$metricsLi = _pointData3.metricsList) === null || _pointData3$metricsLi === void 0 ? void 0 : _pointData3$metricsLi.reduce(function (a, b) {
55
+ // 将每个数字转换为字符串,然后乘以100,转为整数计算
56
+ var aNum = Math.round(Number(a) * 100);
57
+ var bNum = Math.round(Number(b.val) * 100);
58
+ return (aNum + bNum) / 100;
59
+ }, 0).toFixed(2));
55
60
  pointData = _objectSpread(_objectSpread({}, pointData), {}, {
56
61
  pointName: (_pointData4 = pointData) === null || _pointData4 === void 0 ? void 0 : _pointData4.name,
57
62
  unit: ['kWh', 't', 'm³', 't', 't'][pointData.type - 1]
@@ -77,7 +82,12 @@ var ElePointValueComponent = function ElePointValueComponent(_ref) {
77
82
  var numberColor = getValueByExpression(value, payload === null || payload === void 0 ? void 0 : payload.colorExpressions);
78
83
  return /*#__PURE__*/React.createElement("div", {
79
84
  onClick: function onClick(e) {
80
- return eventHandles.current.onClick(e);
85
+ debugger;
86
+ if ((payload === null || payload === void 0 ? void 0 : payload.pointList.length) && (payload === null || payload === void 0 ? void 0 : payload.pointList[0].deviceType) === 'device') {
87
+ eventHandles.current.onClick(e);
88
+ } else {
89
+ e.stopPropagation();
90
+ }
81
91
  },
82
92
  onContextMenu: function onContextMenu(e) {
83
93
  return eventHandles.current.onContextMenu(e);
@@ -455,8 +455,8 @@ var Player = function Player(_ref) {
455
455
  indicatorNo: "".concat(str[0], "_").concat(str[1], "_").concat(productNo[str[0]]),
456
456
  aggregateType: 3,
457
457
  timeQuantumList: [{
458
- startDate: dayjs().startOf(dateType == 0 ? 'month' : 'year').format('YYYY-MM-DD HH:mm:ss'),
459
- endDate: dayjs().endOf(dateType == 0 ? 'month' : 'year').format('YYYY-MM-DD HH:mm:ss')
458
+ startDate: dayjs().startOf(dateType == 0 ? 'month' : 'year').format('YYYY-MM-DD 00:00:00'),
459
+ endDate: dayjs().endOf(dateType == 0 ? 'month' : 'year').format('YYYY-MM-DD 23:59:59')
460
460
  }]
461
461
  };
462
462
  }));
@@ -486,25 +486,52 @@ var Player = function Player(_ref) {
486
486
  return _ref9.apply(this, arguments);
487
487
  };
488
488
  }();
489
+ var fetchEnergyByMeterList = /*#__PURE__*/function () {
490
+ var _ref0 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(type, ids, dateType) {
491
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
492
+ while (1) switch (_context8.prev = _context8.next) {
493
+ case 0:
494
+ GetEnergyByMeterList({
495
+ dataType: type,
496
+ meterIdList: ids,
497
+ startDateTime: dayjs().startOf(dateType == 0 ? 'month' : 'year').format('YYYY-MM-DD 00:00:00'),
498
+ endDateTime: dayjs().endOf(dateType == 0 ? 'month' : 'year').format('YYYY-MM-DD 23:59:59'),
499
+ dateType: 2
500
+ }).then(function (res) {
501
+ if (res.success) {
502
+ res.data.forEach(function (item) {
503
+ emitter.emit("point-update-".concat(item.id, "-").concat(mittMeta.namespace), item);
504
+ });
505
+ }
506
+ });
507
+ case 1:
508
+ case "end":
509
+ return _context8.stop();
510
+ }
511
+ }, _callee8);
512
+ }));
513
+ return function fetchEnergyByMeterList(_x9, _x0, _x1) {
514
+ return _ref0.apply(this, arguments);
515
+ };
516
+ }();
489
517
  var timer;
490
518
  var specialPointTimer;
519
+ var meterPointTimer;
491
520
  if (query.scene === 'freedom' && jsonConfig) {
492
521
  var _jsonConfig$cells;
493
522
  var pointIds = [];
494
523
  var specialPoint = [];
495
524
  var virtual = [];
496
525
  jsonConfig === null || jsonConfig === void 0 ? void 0 : (_jsonConfig$cells = jsonConfig.cells) === null || _jsonConfig$cells === void 0 ? void 0 : _jsonConfig$cells.forEach(function (cell) {
497
- var _cell$data;
498
- if ((cell === null || cell === void 0 ? void 0 : (_cell$data = cell.data) === null || _cell$data === void 0 ? void 0 : _cell$data.valueType) == 1) {
526
+ var _cell$data, _cell$data$pointList, _cell$data2, _cell$data3;
527
+ if ((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.length) > 0 && (cell === null || cell === void 0 ? void 0 : (_cell$data2 = cell.data) === null || _cell$data2 === void 0 ? void 0 : _cell$data2.pointList[0].deviceType) === 'virtual') {
528
+ virtual.push(cell);
529
+ } else if ((cell === null || cell === void 0 ? void 0 : (_cell$data3 = cell.data) === null || _cell$data3 === void 0 ? void 0 : _cell$data3.valueType) === 1) {
499
530
  specialPoint.push(cell);
500
531
  } else {
501
- var _cell$data2, _cell$data2$pointList;
502
- 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) {
503
- if ((point === null || point === void 0 ? void 0 : point.deviceType) == 'virtual') {
504
- virtual.push(point);
505
- } else {
506
- pointIds.push(point.pointId);
507
- }
532
+ var _cell$data4, _cell$data4$pointList;
533
+ cell === null || cell === void 0 ? void 0 : (_cell$data4 = cell.data) === null || _cell$data4 === void 0 ? void 0 : (_cell$data4$pointList = _cell$data4.pointList) === null || _cell$data4$pointList === void 0 ? void 0 : _cell$data4$pointList.forEach(function (point) {
534
+ pointIds.push(point.pointId);
508
535
  });
509
536
  }
510
537
 
@@ -554,25 +581,22 @@ var Player = function Player(_ref) {
554
581
  }
555
582
  if (virtual.length) {
556
583
  var dataType = _toConsumableArray(new Set(virtual.map(function (item) {
557
- return item.dataType;
584
+ return item.data.pointList[0].dataType;
585
+ })));
586
+ var valueDate = _toConsumableArray(new Set(virtual.map(function (item) {
587
+ return item.data.valueDate;
558
588
  })));
559
589
  dataType.forEach(function (type) {
560
- GetEnergyByMeterList({
561
- dataType: type,
562
- meterIdList: virtual.filter(function (item) {
563
- return item.dataType == type;
590
+ valueDate.forEach(function (date) {
591
+ var ids = virtual.filter(function (item) {
592
+ return item.data.pointList[0].dataType == type && item.data.valueDate == date;
564
593
  }).map(function (item) {
565
- return item.meterId;
566
- }),
567
- startDateTime: dayjs().format('YYYY-MM-DD 00:00:00'),
568
- endDateTime: dayjs().format('YYYY-MM-DD 23:59:59'),
569
- dateType: 2
570
- }).then(function (res) {
571
- if (res.success) {
572
- res.data.forEach(function (item) {
573
- emitter.emit("point-update-".concat(item.id, "-").concat(mittMeta.namespace), item);
574
- });
575
- }
594
+ return item.data.pointList[0].meterId;
595
+ });
596
+ ids.length && fetchEnergyByMeterList(type, ids, date);
597
+ meterPointTimer = setInterval(function () {
598
+ ids.length && fetchEnergyByMeterList(type, ids, date);
599
+ }, RefreshFrequency);
576
600
  });
577
601
  });
578
602
  }
@@ -581,6 +605,12 @@ var Player = function Player(_ref) {
581
605
  if (timer) {
582
606
  clearInterval(timer);
583
607
  }
608
+ if (specialPointTimer) {
609
+ clearInterval(specialPointTimer);
610
+ }
611
+ if (meterPointTimer) {
612
+ clearInterval(meterPointTimer);
613
+ }
584
614
  };
585
615
  }, [query, jsonConfig, mittMeta]);
586
616
  useEffect(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "scripts": {
5
5
  "start": " PORT=8000 UMI_ENV=prod umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",