mm_os 2.4.0 → 2.4.3

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.
@@ -14,11 +14,15 @@ exports.get_log = function(clientid, param) {
14
14
  * @param {String} avatar base64头像
15
15
  * @param {Number} longtime 超时回馈
16
16
  */
17
- exports.sign_in = function(clientid, uuid, avatar) {
18
- return this.push("PullRecordOnlyPic", clientid, {
17
+ exports.sign_in = async function(clientid, uuid, avatar) {
18
+ var res = await this.push("PullRecordOnlyPic", clientid, {
19
19
  "personID": uuid,
20
20
  "picinfo": avatar
21
21
  });
22
+
23
+ if (!res || res.result == "fail") {
24
+ return "打卡失败!";
25
+ }
22
26
  }
23
27
 
24
28
  /**
@@ -91,10 +95,12 @@ exports.unlock = async function(clientid, uuid = '0', pass = false, tip = '没
91
95
  * @param {String} uuid 用户唯一标识
92
96
  * @param {Number} longtime 超时回馈
93
97
  */
94
- exports.delete_member = function(clientid, uuid) {
95
- return this.push("DeletePersons", clientid, {
98
+ exports.delete_member = async function(clientid, uuid) {
99
+ var res = await this.push("DeletePersons", clientid, {
96
100
  "customId": uuid
97
101
  });
102
+
103
+ return
98
104
  }
99
105
 
100
106
  /**
@@ -103,21 +109,59 @@ exports.delete_member = function(clientid, uuid) {
103
109
  * @param {Object} arr 成员列表
104
110
  * @param {Number} longtime 超时回馈
105
111
  */
106
- exports.delete_member_batch = function(clientid, arr, longtime) {
107
- return this.push("DeletePersons", clientid, {
112
+ exports.delete_member_batch = async function(clientid, arr, longtime) {
113
+ var res = await this.push("DeletePersons", clientid, {
108
114
  DataBegin: "BeginFlag",
109
115
  DataEnd: "EndFlag",
110
116
  PersonNum: arr.length.toString(),
111
117
  customId: arr
112
118
  }, longtime);
119
+
120
+ var result;
121
+ var error = 0;
122
+ var success = 0;
123
+ var error_info = [];
124
+ var success_info = [];
125
+
126
+ if (res) {
127
+ if (res.result == 'ok') {
128
+ var now = new Date().toStr("yyyy-MM-dd hh:mm:ss");
129
+ error = Number(res.DelErrNum);
130
+ success = Number(res.DelSucNum);
131
+ error_info = res.DelErrInfo.map((o) => {
132
+ o.time_create = now;
133
+ return o
134
+ });
135
+ success_info = res.DelSucInfo.map((o) => {
136
+ o.time_create = now;
137
+ return o
138
+ });
139
+ result = res.result;
140
+ } else if (res.detail && res.detail.indexOf('busy') === -1) {
141
+ result = 'fail';
142
+ }
143
+ }
144
+ return {
145
+ error,
146
+ success,
147
+ error_info,
148
+ success_info,
149
+ result
150
+ };
151
+
152
+ return
113
153
  }
114
154
 
115
155
  /**
116
156
  * 重启设备
117
157
  * @param {String} clientid 设备sn
118
158
  */
119
- exports.reboot_device = function(clientid) {
120
- return this.push("RebootDevice", clientid, {});
159
+ exports.reboot_device = async function(clientid) {
160
+ var res = await this.push("RebootDevice", clientid, {});
161
+ if (!res || res.result == "ok") {
162
+ return
163
+ }
164
+ return "重启设备失败"
121
165
  }
122
166
 
123
167
  /**
@@ -186,12 +230,17 @@ exports.get_progress = async function(clientid, mode = 'update') {
186
230
  * @param {Object} param 其他信息
187
231
  * @param {Number} longtime 超时回馈
188
232
  */
189
- exports.replacement = function(clientid, uuid, time, avatar) {
190
- return this.push("PullRecordOnlyName", clientid, {
233
+ exports.replacement = async function(clientid, uuid, time, avatar) {
234
+ var res = await this.push("PullRecordOnlyPic", clientid, {
191
235
  "personID": uuid,
192
236
  "time": time,
193
237
  "picinfo": avatar
194
- }, longtime);
238
+ });
239
+
240
+ if (!res || res.result == "fail") {
241
+ return "补卡失败!";
242
+ }
243
+ return
195
244
  }
196
245
 
197
246
  /**
@@ -240,8 +289,8 @@ exports.member_model_out = function(m) {
240
289
  "cardType": 0,
241
290
  "picURI": this.fullUrl(m.avatar)
242
291
  }
243
-
244
- if (m.time_valid_end && m.time_valid_end > "2021-01-01 00:00:00".toTime() && m.time_valid_end <=
292
+
293
+ if (m.time_valid_end && m.time_valid_end.toTime() > "2021-01-01 00:00:00".toTime() && m.time_valid_end.toTime() <=
245
294
  "2038-01-01 00:00:00".toTime()) {
246
295
  if (typeof(m.time_valid_start) == "object") {
247
296
  obj.cardValidBegin = m.time_valid_start.toStr("yyyy-MM-dd hh:mm:ss");
@@ -277,7 +326,37 @@ exports.update_member_batch = async function(clientid, list, longtime = 180) {
277
326
  return this.member_model_out(o);
278
327
  })
279
328
  }, longtime);
280
- return res;
329
+
330
+ var result;
331
+ var error = 0;
332
+ var success = 0;
333
+ var error_info = [];
334
+ var success_info = [];
335
+ if (res) {
336
+ if (res.result == 'ok') {
337
+ var now = new Date().toStr("yyyy-MM-dd hh:mm:ss");
338
+ error = Number(res.AddErrNum);
339
+ success = Number(res.AddSucNum);
340
+ error_info = res.AddErrInfo.map((o) => {
341
+ o.time_create = now;
342
+ return o
343
+ });
344
+ success_info = res.AddSucInfo.map((o) => {
345
+ o.time_create = now;
346
+ return o
347
+ });
348
+ result = res.result;
349
+ } else if (res.detail && res.detail.indexOf('busy') === -1) {
350
+ result = 'fail';
351
+ }
352
+ }
353
+ return {
354
+ error,
355
+ success,
356
+ error_info,
357
+ success_info,
358
+ result
359
+ };
281
360
  }
282
361
 
283
362
  /**
@@ -309,7 +388,7 @@ exports.init = function() {
309
388
  }
310
389
  _this.drives[clientid].online = 1;
311
390
  _this.drives[clientid].time_last = new Date().getTime();
312
- // console.log("心跳", clientid, _this.drives[clientid]);
391
+ console.log("心跳", clientid, _this.drives[clientid]);
313
392
  }
314
393
 
315
394
  /**
@@ -338,9 +417,17 @@ exports.init = function() {
338
417
  };
339
418
 
340
419
  m["RecPush"] = async function(clientid, params, msg, id) {
420
+ _this.send(`mqtt/face/${clientid}`, {
421
+ "messageId": _this.get_msgid('PushAck'),
422
+ "operator": "PushAck",
423
+ "info": {
424
+ "PushAckType": "2",
425
+ "SnapOrRecordID": params.RecordID
426
+ }
427
+ });
341
428
  var type = 1;
342
429
  switch (params.otype) {
343
- // (1人脸验证|2远程开门|3智码开门|4刷卡验证)
430
+ // (1刷脸验证|2远程开门|3智码开门|4刷卡验证)
344
431
  case "7":
345
432
  case "27":
346
433
  type = 2;
@@ -377,6 +464,9 @@ exports.init = function() {
377
464
  var phone = (params.telnum || "").trim();
378
465
  var idcard = (params.idCard || "").trim();
379
466
  var nfc = (params.cardNum2 || params.RFIDCard || "").trim();
467
+ if (nfc == "0") {
468
+ ncf = ""
469
+ }
380
470
  var time = params.time;
381
471
  var avatar = "";
382
472
  if (params.pic) {
@@ -397,19 +487,11 @@ exports.init = function() {
397
487
  type,
398
488
  person_type,
399
489
  record_type,
490
+ action: "刷脸验证",
400
491
  time,
401
492
  avatar
402
493
  }
403
494
  $.server.exec_log(clientid, log);
404
-
405
- _this.send(`mqtt/face/${clientid}`, {
406
- "messageId": _this.get_msgid('PushAck'),
407
- "operator": "PushAck",
408
- "info": {
409
- "PushAckType": "2",
410
- "SnapOrRecordID": params.RecordID
411
- }
412
- });
413
495
  }
414
496
 
415
497
  m["QRCodePush"] = async function(clientid, params, msg, id) {