coolcare-lite-scada-component 4.1.4 → 4.1.6
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.
- package/README.md +3 -1
- package/es/components/DialogImagePicker/Gallery/index.js +7 -2
- package/es/element/ElePointValue/Component.js +1 -5
- package/es/integration/EditorGateway.js +85 -0
- package/es/integration/ThreeScene.js +315 -0
- package/es/integration/legacy-resource-adapter.js +819 -0
- package/es/integration/platform-resources.js +5 -0
- package/es/integration/platform-scenes.js +284 -0
- package/es/integration/platform-session.js +33 -0
- package/es/integration/platform-telemetry.js +436 -0
- package/es/integration/resource-adapter.js +1 -0
- package/es/integration/resource-groups.js +3 -0
- package/es/integration/resource-seed.json +3380 -0
- package/es/integration/scene-format.js +35 -0
- package/es/pages/display/Player/index.js +26 -10
- package/es/pages/display/index.js +75 -14
- package/es/pages/editor/PanelLeft/MineImgGroup/index.js +4 -1
- package/es/pages/editor/PanelLeft/SystemImgGroupList/index.js +4 -1
- package/es/pages/editor/PanelTop/Save/index.js +46 -33
- package/es/pages/editor/index.js +59 -35
- package/es/typings.d.ts +224 -223
- package/package.json +8 -5
|
@@ -0,0 +1,436 @@
|
|
|
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 _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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; } }
|
|
5
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
6
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
7
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
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); }
|
|
13
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
14
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
15
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
16
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
+
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; } }
|
|
18
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
19
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
20
|
+
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; }
|
|
21
|
+
import { GetDeviceInfo, GetDevicePoint, GetDevicePage } from "../services/gateway/Device";
|
|
22
|
+
import { GetProductPoint } from "../services/product/Product";
|
|
23
|
+
import { GetColdChainPermissionDevicePage } from "../services/project/ProjectUserPermission";
|
|
24
|
+
import { CommonMqttWritePointData, ModbusMqttWritePointData, GetPointHistoryData } from "../services/gateway/Point";
|
|
25
|
+
var positive = function positive(v) {
|
|
26
|
+
return Number.isSafeInteger(Number(v)) && Number(v) > 0;
|
|
27
|
+
};
|
|
28
|
+
var check = function check(result) {
|
|
29
|
+
if (!(result === null || result === void 0 ? void 0 : result.success)) throw new Error((result === null || result === void 0 ? void 0 : result.message) || '平台请求失败,请检查账号权限。');
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
function ids(value, limit) {
|
|
33
|
+
if (!Array.isArray(value) || !value.length || value.length > limit || value.some(function (id) {
|
|
34
|
+
return typeof id !== 'string' || !id.trim() || id.length > 120;
|
|
35
|
+
})) throw new Error('请选择有效点位。');
|
|
36
|
+
return _toConsumableArray(new Set(value));
|
|
37
|
+
}
|
|
38
|
+
export function platformDevices(_x, _x2) {
|
|
39
|
+
return _platformDevices.apply(this, arguments);
|
|
40
|
+
}
|
|
41
|
+
function _platformDevices() {
|
|
42
|
+
_platformDevices = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(q, body) {
|
|
43
|
+
var result, params, _t, _t2, _t3;
|
|
44
|
+
return _regenerator().w(function (_context) {
|
|
45
|
+
while (1) switch (_context.n) {
|
|
46
|
+
case 0:
|
|
47
|
+
if (!(q.scene === 'product')) {
|
|
48
|
+
_context.n = 1;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return _context.a(2, {
|
|
52
|
+
success: true,
|
|
53
|
+
data: {
|
|
54
|
+
list: [{
|
|
55
|
+
deviceId: Number(q.productId),
|
|
56
|
+
deviceName: '产品点位模板',
|
|
57
|
+
connectionStatus: -1
|
|
58
|
+
}],
|
|
59
|
+
pagingInfo: {
|
|
60
|
+
hasNext: false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
case 1:
|
|
65
|
+
if (!(q.scene === 'device')) {
|
|
66
|
+
_context.n = 3;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
_t = check;
|
|
70
|
+
_context.n = 2;
|
|
71
|
+
return GetDeviceInfo({
|
|
72
|
+
deviceId: Number(q.deviceId)
|
|
73
|
+
});
|
|
74
|
+
case 2:
|
|
75
|
+
result = _t(_context.v);
|
|
76
|
+
return _context.a(2, {
|
|
77
|
+
success: true,
|
|
78
|
+
data: {
|
|
79
|
+
list: [_objectSpread(_objectSpread({}, result.data), {}, {
|
|
80
|
+
deviceId: Number(q.deviceId)
|
|
81
|
+
})],
|
|
82
|
+
pagingInfo: {
|
|
83
|
+
hasNext: false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
case 3:
|
|
88
|
+
params = {
|
|
89
|
+
companyId: Number(q.companyId),
|
|
90
|
+
projectId: positive(q.projectId) ? Number(q.projectId) : undefined,
|
|
91
|
+
isPermission: true,
|
|
92
|
+
pageNumber: Math.min(100, Math.max(1, Number(body === null || body === void 0 ? void 0 : body.pageNumber) || 1)),
|
|
93
|
+
pageSize: 100
|
|
94
|
+
};
|
|
95
|
+
_t2 = check;
|
|
96
|
+
if (!(q.from === 'cold-chain' || positive(q.projectId))) {
|
|
97
|
+
_context.n = 5;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
_context.n = 4;
|
|
101
|
+
return GetColdChainPermissionDevicePage(params);
|
|
102
|
+
case 4:
|
|
103
|
+
_t3 = _context.v;
|
|
104
|
+
_context.n = 7;
|
|
105
|
+
break;
|
|
106
|
+
case 5:
|
|
107
|
+
_context.n = 6;
|
|
108
|
+
return GetDevicePage(params);
|
|
109
|
+
case 6:
|
|
110
|
+
_t3 = _context.v;
|
|
111
|
+
case 7:
|
|
112
|
+
return _context.a(2, _t2(_t3));
|
|
113
|
+
}
|
|
114
|
+
}, _callee);
|
|
115
|
+
}));
|
|
116
|
+
return _platformDevices.apply(this, arguments);
|
|
117
|
+
}
|
|
118
|
+
export function platformPoints(_x3, _x4) {
|
|
119
|
+
return _platformPoints.apply(this, arguments);
|
|
120
|
+
}
|
|
121
|
+
function _platformPoints() {
|
|
122
|
+
_platformPoints = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(q, body) {
|
|
123
|
+
var result, aliases, _result, others, extra, params, _t4, _t5, _t6, _t7;
|
|
124
|
+
return _regenerator().w(function (_context2) {
|
|
125
|
+
while (1) switch (_context2.n) {
|
|
126
|
+
case 0:
|
|
127
|
+
if (!(q.scene === 'product')) {
|
|
128
|
+
_context2.n = 2;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
_t4 = check;
|
|
132
|
+
_context2.n = 1;
|
|
133
|
+
return GetProductPoint({
|
|
134
|
+
productId: Number(q.productId),
|
|
135
|
+
productVersionId: Number(q.productVersionId) || undefined
|
|
136
|
+
});
|
|
137
|
+
case 1:
|
|
138
|
+
result = _t4(_context2.v);
|
|
139
|
+
return _context2.a(2, {
|
|
140
|
+
success: true,
|
|
141
|
+
data: (result.data || []).map(function (point) {
|
|
142
|
+
return _objectSpread(_objectSpread({}, point), {}, {
|
|
143
|
+
pointId: "PRODUCT:".concat(point.identifierName),
|
|
144
|
+
deviceId: Number(q.productId),
|
|
145
|
+
value: null
|
|
146
|
+
});
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
case 2:
|
|
150
|
+
aliases = Array.isArray(body.pointIdList) ? body.pointIdList.filter(function (id) {
|
|
151
|
+
return id.startsWith('PRODUCT:');
|
|
152
|
+
}) : [];
|
|
153
|
+
if (!aliases.length) {
|
|
154
|
+
_context2.n = 8;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (!(q.scene !== 'device')) {
|
|
158
|
+
_context2.n = 3;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
throw new Error('产品模板点位需要在单设备入口中解析。');
|
|
162
|
+
case 3:
|
|
163
|
+
_t5 = check;
|
|
164
|
+
_context2.n = 4;
|
|
165
|
+
return GetDevicePoint({
|
|
166
|
+
deviceIdList: [Number(q.deviceId)],
|
|
167
|
+
pointIdentifierNameList: ids(aliases, 500).map(function (id) {
|
|
168
|
+
return id.slice(8);
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
case 4:
|
|
172
|
+
_result = _t5(_context2.v);
|
|
173
|
+
others = body.pointIdList.filter(function (id) {
|
|
174
|
+
return !id.startsWith('PRODUCT:');
|
|
175
|
+
});
|
|
176
|
+
if (!others.length) {
|
|
177
|
+
_context2.n = 6;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
_context2.n = 5;
|
|
181
|
+
return platformPoints(q, {
|
|
182
|
+
pointIdList: others
|
|
183
|
+
});
|
|
184
|
+
case 5:
|
|
185
|
+
_t6 = _context2.v;
|
|
186
|
+
_context2.n = 7;
|
|
187
|
+
break;
|
|
188
|
+
case 6:
|
|
189
|
+
_t6 = {
|
|
190
|
+
data: []
|
|
191
|
+
};
|
|
192
|
+
case 7:
|
|
193
|
+
extra = _t6;
|
|
194
|
+
return _context2.a(2, _objectSpread(_objectSpread({}, _result), {}, {
|
|
195
|
+
data: [].concat(_toConsumableArray((_result.data || []).map(function (p) {
|
|
196
|
+
return _objectSpread(_objectSpread({}, p), {}, {
|
|
197
|
+
pointId: "PRODUCT:".concat(p.identifierName)
|
|
198
|
+
});
|
|
199
|
+
})), _toConsumableArray(extra.data))
|
|
200
|
+
}));
|
|
201
|
+
case 8:
|
|
202
|
+
params = {};
|
|
203
|
+
if (q.scene === 'device') params.deviceIdList = [Number(q.deviceId)];else if (Array.isArray(body.deviceIdList) && body.deviceIdList.length && body.deviceIdList.length <= 100 && body.deviceIdList.every(positive)) params.deviceIdList = body.deviceIdList.map(Number);
|
|
204
|
+
if (Array.isArray(body.pointIdList)) params.pointIdList = ids(body.pointIdList, 500);
|
|
205
|
+
if (!(!params.deviceIdList && !params.pointIdList)) {
|
|
206
|
+
_context2.n = 9;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
throw new Error('请先选择设备或点位。');
|
|
210
|
+
case 9:
|
|
211
|
+
_t7 = check;
|
|
212
|
+
_context2.n = 10;
|
|
213
|
+
return GetDevicePoint(params);
|
|
214
|
+
case 10:
|
|
215
|
+
return _context2.a(2, _t7(_context2.v));
|
|
216
|
+
}
|
|
217
|
+
}, _callee2);
|
|
218
|
+
}));
|
|
219
|
+
return _platformPoints.apply(this, arguments);
|
|
220
|
+
}
|
|
221
|
+
function resolvePoints(_x5, _x6) {
|
|
222
|
+
return _resolvePoints.apply(this, arguments);
|
|
223
|
+
}
|
|
224
|
+
function _resolvePoints() {
|
|
225
|
+
_resolvePoints = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(q, requested) {
|
|
226
|
+
var result, points, real, _t8;
|
|
227
|
+
return _regenerator().w(function (_context3) {
|
|
228
|
+
while (1) switch (_context3.n) {
|
|
229
|
+
case 0:
|
|
230
|
+
_context3.n = 1;
|
|
231
|
+
return platformPoints(q, {
|
|
232
|
+
pointIdList: requested
|
|
233
|
+
});
|
|
234
|
+
case 1:
|
|
235
|
+
result = _context3.v;
|
|
236
|
+
points = result.data || [];
|
|
237
|
+
if (!requested.some(function (id) {
|
|
238
|
+
return !points.some(function (p) {
|
|
239
|
+
return p.pointId === id;
|
|
240
|
+
});
|
|
241
|
+
})) {
|
|
242
|
+
_context3.n = 2;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
throw new Error('点位不存在或当前账号无权访问。');
|
|
246
|
+
case 2:
|
|
247
|
+
if (!(q.scene === 'device' && points.some(function (p) {
|
|
248
|
+
return Number(p.deviceId) !== Number(q.deviceId);
|
|
249
|
+
}))) {
|
|
250
|
+
_context3.n = 3;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
throw new Error('点位不属于当前设备。');
|
|
254
|
+
case 3:
|
|
255
|
+
if (!requested.some(function (id) {
|
|
256
|
+
return id.startsWith('PRODUCT:');
|
|
257
|
+
})) {
|
|
258
|
+
_context3.n = 5;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
_t8 = check;
|
|
262
|
+
_context3.n = 4;
|
|
263
|
+
return GetDevicePoint({
|
|
264
|
+
deviceIdList: [Number(q.deviceId)],
|
|
265
|
+
pointIdentifierNameList: requested.filter(function (id) {
|
|
266
|
+
return id.startsWith('PRODUCT:');
|
|
267
|
+
}).map(function (id) {
|
|
268
|
+
return id.slice(8);
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
case 4:
|
|
272
|
+
real = _t8(_context3.v);
|
|
273
|
+
return _context3.a(2, requested.map(function (id) {
|
|
274
|
+
var _real$data;
|
|
275
|
+
var p = id.startsWith('PRODUCT:') ? (_real$data = real.data) === null || _real$data === void 0 ? void 0 : _real$data.find(function (point) {
|
|
276
|
+
return point.identifierName === id.slice(8);
|
|
277
|
+
}) : points.find(function (point) {
|
|
278
|
+
return point.pointId === id;
|
|
279
|
+
});
|
|
280
|
+
if (!p) throw new Error('产品点位在当前设备中不存在。');
|
|
281
|
+
return _objectSpread(_objectSpread({}, p), {}, {
|
|
282
|
+
alias: id
|
|
283
|
+
});
|
|
284
|
+
}));
|
|
285
|
+
case 5:
|
|
286
|
+
return _context3.a(2, requested.map(function (id) {
|
|
287
|
+
return _objectSpread(_objectSpread({}, points.find(function (p) {
|
|
288
|
+
return p.pointId === id;
|
|
289
|
+
})), {}, {
|
|
290
|
+
alias: id
|
|
291
|
+
});
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
}, _callee3);
|
|
295
|
+
}));
|
|
296
|
+
return _resolvePoints.apply(this, arguments);
|
|
297
|
+
}
|
|
298
|
+
export function platformHistory(_x7, _x8) {
|
|
299
|
+
return _platformHistory.apply(this, arguments);
|
|
300
|
+
}
|
|
301
|
+
function _platformHistory() {
|
|
302
|
+
_platformHistory = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(q, body) {
|
|
303
|
+
var requested, start, end, points, date, result, _t9;
|
|
304
|
+
return _regenerator().w(function (_context4) {
|
|
305
|
+
while (1) switch (_context4.n) {
|
|
306
|
+
case 0:
|
|
307
|
+
if (!(q.scene === 'product')) {
|
|
308
|
+
_context4.n = 1;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
throw new Error('产品入口用于配置模板,请在设备入口查看实际历史数据。');
|
|
312
|
+
case 1:
|
|
313
|
+
requested = ids(body.pointIdList, 8), start = Date.parse(body.start), end = Date.parse(body.end);
|
|
314
|
+
if (!(!Number.isFinite(start) || !Number.isFinite(end) || start >= end || end - start > 366 * 86400000 || ![1, 2, 5, 15, 60].includes(body.interval))) {
|
|
315
|
+
_context4.n = 2;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
throw new Error('历史查询范围或采样间隔无效。');
|
|
319
|
+
case 2:
|
|
320
|
+
if (!((end - start) / (body.interval * 60000) > 20000)) {
|
|
321
|
+
_context4.n = 3;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
throw new Error('历史采样点过多,请缩短时间范围或增大采样间隔。');
|
|
325
|
+
case 3:
|
|
326
|
+
_context4.n = 4;
|
|
327
|
+
return resolvePoints(q, requested);
|
|
328
|
+
case 4:
|
|
329
|
+
points = _context4.v;
|
|
330
|
+
date = function date(time) {
|
|
331
|
+
return new Date(time + 8 * 3600000).toISOString().slice(0, 19).replace('T', ' ');
|
|
332
|
+
};
|
|
333
|
+
_t9 = check;
|
|
334
|
+
_context4.n = 5;
|
|
335
|
+
return GetPointHistoryData({
|
|
336
|
+
pointIdList: _toConsumableArray(new Set(points.map(function (p) {
|
|
337
|
+
return p.pointId;
|
|
338
|
+
}))),
|
|
339
|
+
timeQuantum: {
|
|
340
|
+
startDate: date(start),
|
|
341
|
+
endDate: date(end)
|
|
342
|
+
},
|
|
343
|
+
interval: body.interval
|
|
344
|
+
}, {
|
|
345
|
+
timeout: 60000
|
|
346
|
+
});
|
|
347
|
+
case 5:
|
|
348
|
+
result = _t9(_context4.v);
|
|
349
|
+
return _context4.a(2, _objectSpread(_objectSpread({}, result), {}, {
|
|
350
|
+
data: (result.data || []).flatMap(function (row) {
|
|
351
|
+
return points.filter(function (p) {
|
|
352
|
+
return p.pointId === row.pointId;
|
|
353
|
+
}).map(function (p) {
|
|
354
|
+
return _objectSpread(_objectSpread({}, row), {}, {
|
|
355
|
+
pointId: p.alias
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
})
|
|
359
|
+
}));
|
|
360
|
+
}
|
|
361
|
+
}, _callee4);
|
|
362
|
+
}));
|
|
363
|
+
return _platformHistory.apply(this, arguments);
|
|
364
|
+
}
|
|
365
|
+
export function platformControl(_x9, _x0) {
|
|
366
|
+
return _platformControl.apply(this, arguments);
|
|
367
|
+
}
|
|
368
|
+
function _platformControl() {
|
|
369
|
+
_platformControl = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(q, body) {
|
|
370
|
+
var _device$data;
|
|
371
|
+
var _yield$resolvePoints, _yield$resolvePoints2, point, device, result, _t0, _t1;
|
|
372
|
+
return _regenerator().w(function (_context5) {
|
|
373
|
+
while (1) switch (_context5.n) {
|
|
374
|
+
case 0:
|
|
375
|
+
if (!(q.scene === 'product')) {
|
|
376
|
+
_context5.n = 1;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
throw new Error('产品模板不允许下发设备指令。');
|
|
380
|
+
case 1:
|
|
381
|
+
if (String(q.premission || q.permission || '').split(',').includes('49')) {
|
|
382
|
+
_context5.n = 2;
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
throw new Error('当前业务入口没有设备控制权限(49)。');
|
|
386
|
+
case 2:
|
|
387
|
+
if (!(typeof body.value !== 'number' || !Number.isFinite(body.value) || body.confirmed !== true)) {
|
|
388
|
+
_context5.n = 3;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
throw new Error('请核对并确认控制值。');
|
|
392
|
+
case 3:
|
|
393
|
+
_context5.n = 4;
|
|
394
|
+
return resolvePoints(q, ids([body.pointId], 1));
|
|
395
|
+
case 4:
|
|
396
|
+
_yield$resolvePoints = _context5.v;
|
|
397
|
+
_yield$resolvePoints2 = _slicedToArray(_yield$resolvePoints, 1);
|
|
398
|
+
point = _yield$resolvePoints2[0];
|
|
399
|
+
if (!(point.isWrite !== true)) {
|
|
400
|
+
_context5.n = 5;
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
throw new Error('此点位为只读,不允许下发指令。');
|
|
404
|
+
case 5:
|
|
405
|
+
_t0 = check;
|
|
406
|
+
_context5.n = 6;
|
|
407
|
+
return GetDeviceInfo({
|
|
408
|
+
deviceId: point.deviceId
|
|
409
|
+
});
|
|
410
|
+
case 6:
|
|
411
|
+
device = _t0(_context5.v);
|
|
412
|
+
if ([0, 1].includes((_device$data = device.data) === null || _device$data === void 0 ? void 0 : _device$data.protocol)) {
|
|
413
|
+
_context5.n = 7;
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
throw new Error('当前设备协议不支持写入。');
|
|
417
|
+
case 7:
|
|
418
|
+
_t1 = check;
|
|
419
|
+
_context5.n = 8;
|
|
420
|
+
return (device.data.protocol === 0 ? ModbusMqttWritePointData : CommonMqttWritePointData)(_defineProperty({}, point.pointId, body.value));
|
|
421
|
+
case 8:
|
|
422
|
+
result = _t1(_context5.v);
|
|
423
|
+
if (!(result.data !== '指令已下发' && (!result.data || _typeof(result.data) !== 'object' || Object.keys(result.data).length))) {
|
|
424
|
+
_context5.n = 9;
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
throw new Error('平台未确认指令下发,请读取实际状态核对。');
|
|
428
|
+
case 9:
|
|
429
|
+
return _context5.a(2, {
|
|
430
|
+
message: '指令已下发,请等待设备实际状态刷新。'
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}, _callee5);
|
|
434
|
+
}));
|
|
435
|
+
return _platformControl.apply(this, arguments);
|
|
436
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createResourceAdapter } from "./legacy-resource-adapter";
|