mm_os 4.3.6 → 5.0.0

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.
Files changed (234) hide show
  1. package/README.md +101 -504
  2. package/index.js +26 -19
  3. package/lib/loader.js +787 -0
  4. package/lib/os.js +369 -0
  5. package/package.json +55 -80
  6. package/LICENSE +0 -21
  7. package/README_EN.md +0 -505
  8. package/adapter/adapter.js +0 -484
  9. package/adapter/custom_persistence.js +0 -661
  10. package/adapter/mqtt.js +0 -254
  11. package/adapter/socket.js +0 -244
  12. package/adapter/web.js +0 -92
  13. package/adapter/websocket.js +0 -43
  14. package/ai.js +0 -130
  15. package/com/api/README.md +0 -3
  16. package/com/api/com.json +0 -5
  17. package/com/api/config.tpl.json +0 -41
  18. package/com/api/drive.js +0 -732
  19. package/com/api/index.js +0 -201
  20. package/com/api/oauth.js +0 -200
  21. package/com/api/script.tpl.js +0 -32
  22. package/com/cmd/README.md +0 -11
  23. package/com/cmd/com.json +0 -5
  24. package/com/cmd/config.tpl.json +0 -48
  25. package/com/cmd/drive.js +0 -176
  26. package/com/cmd/index.js +0 -287
  27. package/com/cmd/job/config.json +0 -66
  28. package/com/cmd/job/index.js +0 -241
  29. package/com/cmd/job/test.js +0 -188
  30. package/com/cmd/msg.json +0 -48
  31. package/com/cmd/script.tpl.js +0 -12
  32. package/com/db/README.md +0 -3
  33. package/com/db/com.json +0 -5
  34. package/com/db/drive.js +0 -2206
  35. package/com/db/index.js +0 -241
  36. package/com/event/README.md +0 -4
  37. package/com/event/com.json +0 -5
  38. package/com/event/config.tpl.json +0 -20
  39. package/com/event/drive.js +0 -61
  40. package/com/event/index.js +0 -438
  41. package/com/event/script.tpl.js +0 -23
  42. package/com/mqtt/README.md +0 -47
  43. package/com/mqtt/com.json +0 -5
  44. package/com/mqtt/config.tpl.json +0 -42
  45. package/com/mqtt/drive.js +0 -696
  46. package/com/mqtt/index.js +0 -1017
  47. package/com/mqtt/index.test.js +0 -503
  48. package/com/mqtt/mm_mqtt.js +0 -446
  49. package/com/mqtt/script.tpl.js +0 -719
  50. package/com/nav/README.md +0 -2
  51. package/com/nav/com.json +0 -5
  52. package/com/nav/config.tpl.json +0 -84
  53. package/com/nav/drive.js +0 -702
  54. package/com/nav/index.js +0 -228
  55. package/com/nav/tpl/admin_pc/page_channel.vue +0 -305
  56. package/com/nav/tpl/admin_pc/page_config.vue +0 -280
  57. package/com/nav/tpl/admin_pc/page_config_form.vue +0 -194
  58. package/com/nav/tpl/admin_pc/page_default.vue +0 -247
  59. package/com/nav/tpl/admin_pc/page_form.vue +0 -180
  60. package/com/nav/tpl/admin_pc/page_lang.vue +0 -264
  61. package/com/nav/tpl/admin_pc/page_nav.vue +0 -321
  62. package/com/nav/tpl/admin_pc/page_table.vue +0 -296
  63. package/com/nav/tpl/admin_pc/page_type.vue +0 -321
  64. package/com/nav/tpl/admin_pc/page_view.vue +0 -124
  65. package/com/nav/tpl/dev_pc/page_channel.vue +0 -253
  66. package/com/nav/tpl/dev_pc/page_config.vue +0 -253
  67. package/com/nav/tpl/dev_pc/page_default.vue +0 -247
  68. package/com/nav/tpl/dev_pc/page_form.vue +0 -162
  69. package/com/nav/tpl/dev_pc/page_nav.vue +0 -253
  70. package/com/nav/tpl/dev_pc/page_table.vue +0 -247
  71. package/com/nav/tpl/dev_pc/page_type.vue +0 -313
  72. package/com/nav/tpl/home_pc/page_channel.vue +0 -234
  73. package/com/nav/tpl/home_pc/page_default.vue +0 -234
  74. package/com/nav/tpl/home_pc/page_form.vue +0 -137
  75. package/com/nav/tpl/home_pc/page_list.vue +0 -234
  76. package/com/nav/tpl/home_pc/page_nav.vue +0 -221
  77. package/com/nav/tpl/home_pc/page_type.vue +0 -234
  78. package/com/nav/tpl/home_pc/page_view.vue +0 -125
  79. package/com/nav/tpl/home_phone/page_channel.vue +0 -234
  80. package/com/nav/tpl/home_phone/page_default.vue +0 -234
  81. package/com/nav/tpl/home_phone/page_form.vue +0 -137
  82. package/com/nav/tpl/home_phone/page_list.vue +0 -234
  83. package/com/nav/tpl/home_phone/page_nav.vue +0 -237
  84. package/com/nav/tpl/home_phone/page_type.vue +0 -234
  85. package/com/nav/tpl/home_phone/page_view.vue +0 -125
  86. package/com/nav/viewmodel.js +0 -446
  87. package/com/param/README.md +0 -2
  88. package/com/param/com.json +0 -5
  89. package/com/param/config.tpl.json +0 -136
  90. package/com/param/drive.js +0 -502
  91. package/com/param/index.js +0 -158
  92. package/com/param/script.tpl.js +0 -12
  93. package/com/pendant/README.md +0 -3
  94. package/com/pendant/com.json +0 -5
  95. package/com/pendant/config.tpl.json +0 -32
  96. package/com/pendant/drive.js +0 -204
  97. package/com/pendant/index.js +0 -467
  98. package/com/pendant/pendant.html +0 -16
  99. package/com/pendant/script.tpl.js +0 -18
  100. package/com/socket/README.md +0 -47
  101. package/com/socket/com.json +0 -5
  102. package/com/socket/config.tpl.json +0 -12
  103. package/com/socket/drive.js +0 -679
  104. package/com/socket/index.js +0 -402
  105. package/com/socket/script.tpl.js +0 -41
  106. package/com/sql/README.md +0 -3
  107. package/com/sql/com.json +0 -5
  108. package/com/sql/config.tpl.json +0 -74
  109. package/com/sql/drive.js +0 -1283
  110. package/com/sql/index.js +0 -152
  111. package/com/sql/script.tpl.js +0 -47
  112. package/com/static/README.md +0 -2
  113. package/com/static/com.json +0 -5
  114. package/com/static/config.tpl.json +0 -24
  115. package/com/static/drive.js +0 -194
  116. package/com/static/index.js +0 -237
  117. package/com/static/script.tpl.js +0 -28
  118. package/com/task/README.md +0 -3
  119. package/com/task/com.json +0 -5
  120. package/com/task/config.tpl.json +0 -24
  121. package/com/task/drive.js +0 -428
  122. package/com/task/index.js +0 -159
  123. package/com/task/script.tpl.js +0 -40
  124. package/com/template/com.json +0 -5
  125. package/com/template/config.tpl.json +0 -16
  126. package/com/template/drive.js +0 -81
  127. package/com/template/index.js +0 -141
  128. package/com.js +0 -237
  129. package/common/README.md +0 -2
  130. package/common/middleware/web_after/index.js +0 -26
  131. package/common/middleware/web_after/middleware.json +0 -9
  132. package/common/middleware/web_base/index.js +0 -113
  133. package/common/middleware/web_base/middleware.json +0 -19
  134. package/common/middleware/web_before/index.js +0 -33
  135. package/common/middleware/web_before/middleware.json +0 -9
  136. package/common/middleware/web_cors/index.js +0 -87
  137. package/common/middleware/web_cors/middleware.json +0 -24
  138. package/common/middleware/web_error/index.js +0 -131
  139. package/common/middleware/web_error/middleware.json +0 -19
  140. package/common/middleware/web_ip/index.js +0 -15
  141. package/common/middleware/web_ip/middleware.json +0 -14
  142. package/common/middleware/web_logger/index.js +0 -156
  143. package/common/middleware/web_logger/middleware.json +0 -14
  144. package/common/middleware/web_main/index.js +0 -26
  145. package/common/middleware/web_main/middleware.json +0 -9
  146. package/common/middleware/web_static/index.js +0 -73
  147. package/common/middleware/web_static/middleware.json +0 -54
  148. package/common/middleware/web_waf/index.js +0 -385
  149. package/common/middleware/web_waf/middleware.json +0 -13
  150. package/core/app/config.tpl.json +0 -67
  151. package/core/app/index.js +0 -710
  152. package/core/app/script.tpl.js +0 -52
  153. package/core/channel/index.js +0 -899
  154. package/core/channel/matcher.js +0 -585
  155. package/core/com/config.tpl.json +0 -16
  156. package/core/com/index.js +0 -77
  157. package/core/com/script.tpl.js +0 -5
  158. package/core/component/component.js +0 -42
  159. package/core/component/config.tpl.json +0 -63
  160. package/core/component/index.js +0 -273
  161. package/core/component/script.tpl.js +0 -19
  162. package/core/controller/config.tpl.json +0 -14
  163. package/core/controller/index.js +0 -371
  164. package/core/controller/script.tpl.js +0 -27
  165. package/core/factory/config.tpl.json +0 -14
  166. package/core/factory/entity.js +0 -275
  167. package/core/factory/index.js +0 -241
  168. package/core/factory/script.tpl.js +0 -16
  169. package/core/game/bat/index.js +0 -137
  170. package/core/game/bat/world.js +0 -622
  171. package/core/game/config.tpl.json +0 -16
  172. package/core/game/entity_admin.js +0 -230
  173. package/core/game/index.js +0 -186
  174. package/core/handler/config.tpl.json +0 -22
  175. package/core/handler/index.js +0 -181
  176. package/core/handler/script.tpl.js +0 -23
  177. package/core/logic/config.tpl.json +0 -14
  178. package/core/logic/index.js +0 -59
  179. package/core/logic/script.tpl.js +0 -19
  180. package/core/middleware/config.tpl.json +0 -16
  181. package/core/middleware/index.js +0 -117
  182. package/core/middleware/script.tpl.js +0 -37
  183. package/core/mod/config.tpl.json +0 -22
  184. package/core/mod/index.js +0 -136
  185. package/core/mod/script.tpl.js +0 -34
  186. package/core/model/config.tpl.json +0 -219
  187. package/core/model/index.js +0 -272
  188. package/core/model/model.js +0 -27
  189. package/core/model/script.tpl.js +0 -20
  190. package/core/notifier/config.tpl.json +0 -14
  191. package/core/notifier/index.js +0 -77
  192. package/core/notifier/script.tpl.js +0 -20
  193. package/core/plugin/config.tpl.json +0 -36
  194. package/core/plugin/index.js +0 -297
  195. package/core/plugin/script.tpl.js +0 -51
  196. package/core/pusher/config.tpl.json +0 -14
  197. package/core/pusher/index.js +0 -158
  198. package/core/pusher/script.tpl.js +0 -20
  199. package/core/room/bat/index.js +0 -170
  200. package/core/room/bat/room.js +0 -524
  201. package/core/room/config.tpl.json +0 -20
  202. package/core/room/index.js +0 -249
  203. package/core/room/room.js +0 -61
  204. package/core/scene/config.tpl.json +0 -14
  205. package/core/scene/index.js +0 -467
  206. package/core/scene/loop.js +0 -1306
  207. package/core/scene/map.js +0 -28
  208. package/core/scene/script.tpl.js +0 -22
  209. package/core/sender/config.tpl.json +0 -14
  210. package/core/sender/index.js +0 -79
  211. package/core/sender/script.tpl.js +0 -20
  212. package/core/service/config.tpl.json +0 -14
  213. package/core/service/index.js +0 -100
  214. package/core/service/script.tpl.js +0 -25
  215. package/core/store/config.tpl.json +0 -26
  216. package/core/store/index.js +0 -1794
  217. package/core/store/script.tpl.js +0 -22
  218. package/core/store/sql.js +0 -1488
  219. package/core/system/config.tpl.json +0 -18
  220. package/core/system/index.js +0 -312
  221. package/core/system/script.tpl.js +0 -77
  222. package/core/view/config.tpl.json +0 -14
  223. package/core/view/index.js +0 -91
  224. package/core/view/script.tpl.js +0 -20
  225. package/core/zone/bat/index.js +0 -744
  226. package/core/zone/config.tpl.json +0 -54
  227. package/core/zone/index.js +0 -655
  228. package/core/zone/script.tpl.js +0 -10
  229. package/core/zone/zone_bat.js +0 -136
  230. package/core//345/237/272/347/261/273/346/250/241/345/235/227/346/270/205/345/215/225.md +0 -24
  231. package/os.js +0 -53
  232. package/server.js +0 -595
  233. package/ulits/id_gen.js +0 -134
  234. package/ulits/word.js +0 -206
@@ -1,719 +0,0 @@
1
- /**
2
- * 查询个人记录
3
- * @param {string} clientid 客户端ID
4
- * @param {object} param 查询参数
5
- * @returns {object} 执行结果
6
- */
7
- exports.getLog = async function(clientid, param) {
8
- var res = await this.push('GetRecordsByPicOrID', clientid, param);
9
- return res;
10
- };
11
-
12
- /**
13
- * 考勤打卡
14
- * @param {string} clientid 客户端ID
15
- * @param {object} uuid 用户唯一标识
16
- * @param {string} avatar base64头像
17
- * @returns {object} 执行结果
18
- */
19
- exports.signIn = async function(clientid, uuid, avatar) {
20
- var res = await this.push('PullRecordOnlyPic', clientid, {
21
- 'personID': uuid,
22
- 'picinfo': avatar
23
- });
24
-
25
- if (!res || res.result == 'fail') {
26
- return '打卡失败!';
27
- }
28
- };
29
-
30
- /**
31
- * 下发二维码(没用到)
32
- * @param {string} clientid 客户端ID
33
- * @param {object} param 二维码参数
34
- * @returns {object} 执行结果
35
- */
36
- exports.pushQrcode = function(clientid, param) {
37
- return this.push('ShowQRCode', clientid, param);
38
- };
39
-
40
- /**
41
- * 以图搜人
42
- * @param {string} clientid 客户端ID
43
- * @param {object} avatar 人脸照片
44
- * @returns {object} 执行结果
45
- */
46
- exports.getMemberPic = async function(clientid, avatar) {
47
- var res = await this.push('GetPictureSearch', clientid, {
48
- 'facesluiceId': clientid,
49
- 'MaxSimilarity': 80,
50
- 'MaxNum': 1,
51
- 'picinfo': avatar
52
- });
53
- var user;
54
- if (res) {
55
- if (res.result == 'fail') {
56
-
57
- } else {
58
- var u = res.SearchInfo[0];
59
- var name = u.name || u.persionName;
60
- var custom_id = u.customId.trim();
61
- var phone = (u.telnum || '').trim();
62
- var idcard = (u.idCard || '').trim();
63
- user = {
64
- name,
65
- custom_id,
66
- phone,
67
- idcard
68
- };
69
- }
70
- }
71
- return user;
72
- };
73
-
74
- /**
75
- * 远程开门
76
- * @param {string} clientid 客户端ID
77
- * @param {string} uuid 用户唯一标识
78
- * @param {boolean} pass 是否可通行 true为是
79
- * @param {string} tip 提示信息
80
- * @returns {object} 执行结果
81
- */
82
- exports.unlock = async function(clientid, uuid = '0', pass = false, tip = '没有访问权限') {
83
- var res = await this.push('Unlock', clientid, {
84
- 'uid': uuid,
85
- // 0不开门,1开门
86
- 'openDoor': pass ? '1' : '0',
87
- 'showInfo': tip
88
- });
89
-
90
- if (!res || res.result == 'fail') {
91
- return '非内部人员!';
92
- }
93
- };
94
-
95
-
96
- /**
97
- * 远程锁门(没用到)
98
- * @param {string} clientid 客户端ID
99
- * @param {string} uuid 用户唯一标识
100
- * @param {boolean} pass 是否可通行 true为是
101
- * @param {string} tip 提示信息
102
- * @returns {object} 执行结果
103
- */
104
- exports.lock = async function(clientid, uuid = '0', pass = false, tip = '没有访问权限') {
105
- var res = await this.push('Lock', clientid, {
106
- 'uid': uuid,
107
- 'showInfo': tip
108
- });
109
-
110
- if (!res || res.result == 'fail') {
111
- return '已锁门!';
112
- }
113
- };
114
-
115
- /**
116
- * 删除成员
117
- * @param {string} clientid 客户端ID
118
- * @param {string} uuid 用户唯一标识
119
- * @returns {object} 执行结果
120
- */
121
- exports.delMember = async function(clientid, uuid) {
122
- var res = await this.push('DeletePersons', clientid, {
123
- 'customId': uuid
124
- });
125
-
126
- return res;
127
- };
128
-
129
- /**
130
- * 批量删除成员
131
- * @param {string} clientid 客户端ID
132
- * @param {object} arr 成员列表
133
- * @param {number} longtime 超时回馈
134
- * @returns {object} 执行结果
135
- */
136
- exports.delMemberBatch = async function(clientid, arr, longtime) {
137
- var res = await this.push('DeletePersons', clientid, {
138
- begin: 'BeginFlag',
139
- end: 'EndFlag',
140
- person_num: arr.length.toString(),
141
- customId: arr
142
- }, longtime);
143
-
144
- var result;
145
- var error = 0;
146
- var success = 0;
147
- var error_info = [];
148
- var success_info = [];
149
-
150
- if (res) {
151
- if (res.result == 'ok') {
152
- var now = new Date().toStr('yyyy-MM-dd hh:mm:ss');
153
- error = number(res.DelErrNum);
154
- success = number(res.DelSucNum);
155
- error_info = res.DelErrInfo.map((o) => {
156
- o.time_create = now;
157
- return o;
158
- });
159
- success_info = res.DelSucInfo.map((o) => {
160
- o.time_create = now;
161
- return o;
162
- });
163
- result = res.result;
164
- } else if (res.detail && res.detail.indexOf('busy') === -1) {
165
- result = 'fail';
166
- }
167
- }
168
- return {
169
- error,
170
- success,
171
- error_info,
172
- success_info,
173
- result
174
- };
175
-
176
- return;
177
- };
178
-
179
- /**
180
- * 重启设备
181
- * @param {string} clientid 设备sn
182
- * @returns {object} 执行结果
183
- */
184
- exports.rebootDevice = async function(clientid) {
185
- var res = await this.push('RebootDevice', clientid, {});
186
- if (!res || res.result == 'ok') {
187
- return;
188
- }
189
- return '重启设备失败';
190
- };
191
-
192
- /**
193
- * 设置设备时间
194
- * @param {string} clientid 设备sn
195
- * @param {string} datetime 日期时间 格式为yyyy-MM-dd hh:mm:ss
196
- * @returns {object} 执行结果
197
- */
198
- exports.setDeviceTime = async function(clientid, datetime) {
199
- var res = await this.push('SetSysTime', clientid, {
200
- 'SysTime': datetime.replace(' ', 'T')
201
- });
202
- if (!res || res.result == 'ok') {
203
- return;
204
- }
205
- return '重置时间失败';
206
- };
207
-
208
- /**
209
- * 恢复出厂设置
210
- * @param {string} clientid 设备sn
211
- * @param {boolean} record 是否恢复控制记录,true为恢复
212
- * @param {boolean} member 是否恢复成员,true为恢复
213
- * @param {boolean} log 是否恢复请求日志,true为恢复
214
- * @returns {object} 执行结果
215
- */
216
- exports.resetDevice = async function(clientid, record = true, member = false, log = true) {
217
- var res = await this.push('SetFactoryDefault', clientid, {
218
- defalt_record: record ? '1' : '0',
219
- defalt_person: member ? '1' : '0',
220
- defalt_log: log ? '1' : '0'
221
- });
222
-
223
- if (!res || res.result == 'ok') {
224
- return;
225
- }
226
- return '恢复出厂设置失败';
227
- };
228
-
229
- /**
230
- * 查询下发进度
231
- * @param {string} clientid 设备sn
232
- * @param {string} mode 查询方式 默认为更新
233
- * @returns {object} 执行结果
234
- */
235
- exports.getProgress = async function(clientid, mode = 'update') {
236
- var type = '';
237
- if (mode == 'update') {
238
- type = 'EditPersonsNew';
239
- } else {
240
- type = 'DeletePersons';
241
- }
242
- var res = await this.push('QueryProgress', clientid, {
243
- 'QueryType': type
244
- });
245
- if (res) {
246
- if (res.Status !== '0') {
247
- return 1;
248
- } else {
249
- return 0;
250
- }
251
- }
252
- return -1;
253
- };
254
-
255
- /**
256
- * 考勤补卡
257
- * @param {string} clientid 设备sn
258
- * @param {string} uuid 用户唯一标识
259
- * @param {string} time 时间
260
- * @param {string} avatar 头像
261
- * @returns {object} 执行结果
262
- */
263
- exports.replacement = async function(clientid, uuid, time, avatar) {
264
- var res = await this.push('PullRecordOnlyPic', clientid, {
265
- 'personID': uuid,
266
- 'time': time,
267
- 'picinfo': avatar
268
- });
269
-
270
- if (!res || res.result == 'fail') {
271
- return '补卡失败!';
272
- }
273
- return;
274
- };
275
-
276
- /**
277
- * 查询人员名单
278
- * @param {string} clientid 客户端ID
279
- * @param {number} longtime 超时回馈
280
- * @returns {object} 执行结果
281
- */
282
- exports.getMember = function(clientid, longtime = 0) {
283
- return this.push('QueryPerson', clientid, longtime);
284
- };
285
-
286
- /**
287
- * 查询人员名单
288
- * @param {string} clientid 客户端ID
289
- * @param {string} uuid 用户唯一标识
290
- * @param {number} longtime 超时回馈
291
- * @returns {object} 人员信息
292
- */
293
- exports.getMemberOne = function(clientid, uuid, longtime = 0) {
294
- return this.push('QueryPerson', clientid, {
295
- 'personId': uuid
296
- }, longtime);
297
- };
298
-
299
- /**
300
- * 格式化时间
301
- * @param {*} time 时间值
302
- * @returns {string} 格式化后的时间字符串
303
- */
304
- exports._formatTime = function(time) {
305
- if (typeof(time) == 'object') {
306
- return time.toStr('yyyy-MM-dd hh:mm:ss');
307
- } else {
308
- return time.toTime().toStr('yyyy-MM-dd hh:mm:ss');
309
- }
310
- };
311
-
312
- /**
313
- * 检查时间有效性
314
- * @param {*} time_end 结束时间
315
- * @returns {boolean} 是否有效
316
- */
317
- exports._isTimeValid = function(time_end) {
318
- if (!time_end) {
319
- return false;
320
- }
321
- var end_time = time_end.toTime();
322
- return end_time > '2021-01-01 00:00:00'.toTime() && end_time <= '2038-01-01 00:00:00'.toTime();
323
- };
324
-
325
- /**
326
- * 设置时间有效性
327
- * @param {object} obj 目标对象
328
- * @param {object} m 成员对象
329
- * @returns {object} 修改后的对象
330
- */
331
- exports._setTimeValidity = function(obj, m) {
332
- var result = { ...obj };
333
- if (this._isTimeValid(m.time_valid_end)) {
334
- result.cardValidBegin = this._formatTime(m.time_valid_start);
335
- result.cardValidEnd = this._formatTime(m.time_valid_end);
336
- result.tempCardType = 1;
337
- } else {
338
- result.tempCardType = 0;
339
- }
340
- return result;
341
- };
342
-
343
- /**
344
- * 创建基础成员对象
345
- * @param {object} m 原始的成员对象
346
- * @returns {object} 基础成员对象
347
- */
348
- exports._createBaseMember = function(m) {
349
- var nfc = m.nfc || '';
350
- return {
351
- 'customId': m.customId,
352
- 'name': m.name,
353
- 'native': m.place || '',
354
- 'nation': m.nation || '',
355
- 'address': m.address || '',
356
- 'idCard': m.idcard || '',
357
- 'gender': m.sex - 1,
358
- 'phone': m.phone,
359
- 'birthday': m.birthday,
360
- 'cardType2': 2,
361
- 'cardNum2': nfc,
362
- 'RFCardMode': 0,
363
- 'RFIDCard': nfc,
364
- 'notes': '',
365
- 'personType': m.state == 4 ? 1 : 0,
366
- 'cardType': 0,
367
- 'picURI': this.fullUrl(m.avatar)
368
- };
369
- };
370
-
371
- /**
372
- * 成员模型
373
- * @param {object} m 原始的成员对象
374
- * @returns {object} 转换后的成员对象
375
- */
376
- exports.memberModelOut = function(m) {
377
- var obj = this._createBaseMember(m);
378
- this._setTimeValidity(obj, m);
379
- return obj;
380
- };
381
-
382
- /**
383
- * 添加时间戳到信息列表
384
- * @param {Array} list 信息列表
385
- * @param {string} now 当前时间
386
- * @returns {Array} 处理后的列表
387
- */
388
- exports._addTimeToList = function(list, now) {
389
- return list.map((o) => {
390
- o.time_create = now;
391
- return o;
392
- });
393
- };
394
-
395
- /**
396
- * 解析批量操作结果
397
- * @param {object} res 响应结果
398
- * @returns {object} 解析后的结果
399
- */
400
- exports._parseBatch = function(res) {
401
- var result;
402
- var error = 0;
403
- var success = 0;
404
- var error_info = [];
405
- var success_info = [];
406
-
407
- if (res) {
408
- if (res.result == 'ok') {
409
- var now = new Date().toStr('yyyy-MM-dd hh:mm:ss');
410
- error = number(res.AddErrNum);
411
- success = number(res.AddSucNum);
412
- error_info = this._addTimeToList(res.AddErrInfo, now);
413
- success_info = this._addTimeToList(res.AddSucInfo, now);
414
- result = res.result;
415
- } else if (res.detail && res.detail.indexOf('busy') === -1) {
416
- result = 'fail';
417
- }
418
- }
419
-
420
- return {
421
- error,
422
- success,
423
- error_info,
424
- success_info,
425
- result
426
- };
427
- };
428
-
429
- /**
430
- * 批量下发人员名单
431
- * @param {string} clientid 客户端ID
432
- * @param {Array} list 人员名单
433
- * @param {number} longtime 超时回馈
434
- * @returns {object} 执行结果
435
- */
436
- exports.updateMemberBatch = async function(clientid, list, longtime = 180) {
437
- var res = await this.pushS(clientid, {
438
- 'messageId': this.getMsgId('EditPersonsNew'),
439
- 'DataBegin': 'BeginFlag',
440
- 'DataEnd': 'EndFlag',
441
- 'operator': 'EditPersonsNew',
442
- 'PersonNum': list.length,
443
- 'info': list.map((o) => {
444
- return this.memberModelOut(o);
445
- })
446
- }, longtime);
447
-
448
- return this._parseBatch(res);
449
- };
450
-
451
- /**
452
- * 下发人员名单
453
- * @param {string} clientid 设备ID
454
- * @param {object} user 人员信息
455
- * @param {number} longtime 超时回馈
456
- * @returns {object} 执行结果
457
- */
458
- exports.updateMember = function(clientid, user, longtime = 0) {
459
- return this.pushS(clientid, {
460
- 'messageId': this.getMsgId('EditPerson'),
461
- 'DataBegin': 'BeginFlag',
462
- 'DataEnd': 'EndFlag',
463
- 'method': 'EditPerson',
464
- 'info': this.memberModelOut(user)
465
- }, longtime);
466
- };
467
-
468
- /**
469
- * 初始化函数, 用于定义开放给前端的函数
470
- */
471
- exports.init = function() {
472
- var m = this.methods;
473
-
474
- _regBasicMethods(m, this);
475
- _regDeviceMethods(m, this);
476
- _regRecordMethods(m, this);
477
- };
478
-
479
- /**
480
- * 注册基本方法
481
- * @param {object} m 方法对象
482
- * @param {object} self 实例
483
- * @private
484
- */
485
- var _regBasicMethods = function(m, self) {
486
- m['HeartBeat'] = function(clientid, params) {
487
- if (!self.drives[clientid]) {
488
- self.drives[clientid] = {};
489
- }
490
- self.drives[clientid].online = 1;
491
- self.drives[clientid].time_last = new Date().getTime();
492
- };
493
-
494
- /**
495
- * 离线通知
496
- * @param {string} clientid 设备sn
497
- * @param {object} params 设备信息
498
- */
499
- m['Offline'] = async function(clientid, params) {
500
- self.updateOnline(clientid, 0);
501
- };
502
-
503
- /**
504
- * 在线通知
505
- * @param {string} clientid 设备sn
506
- * @param {object} params 设备信息
507
- * @returns {object} 执行结果
508
- */
509
- m['Online'] = async function(clientid, params) {
510
- await self.updateOnline(clientid, 1, params.ip);
511
- return {
512
- 'facesluiceId': clientid,
513
- 'result': 'ok',
514
- 'detail': ''
515
- };
516
- };
517
- };
518
-
519
- /**
520
- * 注册设备方法
521
- * @param {object} m 方法对象
522
- * @param {object} self 实例
523
- * @private
524
- */
525
- var _regDeviceMethods = function(m, self) {
526
- /**
527
- * 更新人体生命体征,如温度、湿度、位置、
528
- * @param {string} clientid 设备sn
529
- * @param {object} params 设备信息
530
- */
531
- m['life'] = async function(clientid, params) {
532
- self.updateLife(clientid, {
533
- // 心率
534
- heart_rate: 0,
535
- // 睡眠状态 是深度睡眠还是浅睡眠
536
- sleep: 0,
537
- // 血氧饱和度
538
- oxygen: 0,
539
- // 行走步数
540
- step: 0,
541
- // 压力
542
- pressure: 0,
543
- // 时间戳
544
- timestamp: 0,
545
- // GPS横坐标,保留生命体脱下设备时的最后位置
546
- gps_x: 0,
547
- // GPS纵坐标,保留生命体脱下设备时的最后位置
548
- gps_y: 0
549
- });
550
- };
551
-
552
- /**
553
- * 更新设备信息,如温度、湿度、位置
554
- * @param {string} clientid 设备sn
555
- * @param {object} params 设备信息
556
- */
557
- m['info'] = async function(clientid, params) {
558
- self.updateDeviceInfo(clientid, {
559
- // 温度
560
- temperature: 0,
561
- // 湿度
562
- humidity: 0,
563
- // 氧气
564
- oxygen: 0,
565
- // 二氧化碳
566
- carbon_dioxide: 0,
567
- // 光照强度
568
- light: 0,
569
- // 烟雾浓度
570
- smoke: 0,
571
- // 压力
572
- pressure: 0,
573
- // 光敏
574
- photosensitive: 0,
575
- // 声波
576
- acoustic_wave: 0,
577
- // 磁力
578
- magnetism: 0,
579
- // 火焰
580
- flame: 0,
581
- // 震动
582
- vibrate: 0,
583
- // 时间戳
584
- timestamp: 0,
585
- // GPS横坐标
586
- gps_x: 0,
587
- // GPS纵坐标
588
- gps_y: 0
589
- });
590
- };
591
- };
592
-
593
- /**
594
- * 获取记录类型
595
- * @param {string} otype 操作类型
596
- * @returns {number} 记录类型
597
- * @private
598
- */
599
- var _getRecordType = function(otype) {
600
- var typeMap = {
601
- '7': 2, '27': 2,
602
- '47': 3, '48': 3, '55': 3, '56': 3, '57': 3,
603
- '21': 4, '22': 4, '24': 4, '25': 4
604
- };
605
- return typeMap[otype] || 1;
606
- };
607
-
608
- /**
609
- * 发送确认消息
610
- * @param {string} clientid 设备sn
611
- * @param {string} record_id 记录ID
612
- * @param {object} self 实例
613
- * @private
614
- */
615
- var _sendAck = function(clientid, record_id, self) {
616
- self.send(`mqtt/face/${clientid}`, {
617
- 'messageId': self.getMsgId('PushAck'),
618
- 'operator': 'PushAck',
619
- 'info': {
620
- 'PushAckType': '2',
621
- 'SnapOrRecordID': record_id
622
- }
623
- });
624
- };
625
-
626
- /**
627
- * 获取 NFC
628
- * @param {object} params 上报参数
629
- * @returns {string} NFC
630
- * @private
631
- */
632
- var _getNfc = function(params) {
633
- var nfc = (params.cardNum2 || params.RFIDCard || '').trim();
634
- return nfc == '0' ? '' : nfc;
635
- };
636
-
637
- /**
638
- * 格式化时间
639
- * @param {string|object} time 时间
640
- * @returns {string} 格式化后的时间
641
- * @private
642
- */
643
- var _formatTime = function(time) {
644
- if (typeof(time) == 'object') {
645
- return time.toStr('yyyy-MM-dd hh:mm:ss');
646
- }
647
- return time.toTime().toStr('yyyy-MM-dd hh:mm:ss');
648
- };
649
-
650
- /**
651
- * 创建日志对象
652
- * @param {object} params 上报参数
653
- * @param {string} clientid 设备sn
654
- * @param {number} type 记录类型
655
- * @returns {object} 日志对象
656
- * @private
657
- */
658
- var _createLog = function(params, clientid, type) {
659
- var name = params.persionName || params.name;
660
- if (!name) {
661
- return null;
662
- }
663
- return {
664
- custom_id: params.customId.trim(),
665
- name,
666
- phone: (params.telnum || '').trim(),
667
- idcard: (params.idCard || '').trim(),
668
- nfc: _getNfc(params),
669
- clientid,
670
- type,
671
- person_type: params.PersonType == '1' ? 2 : 1,
672
- record_type: params.RecordType ? number(params.RecordType) + 1 : 1,
673
- action: '刷脸验证',
674
- time: _formatTime(params.time),
675
- avatar: params.pic || ''
676
- };
677
- };
678
-
679
- /**
680
- * 注册记录方法
681
- * @param {object} m 方法对象
682
- * @param {object} self 实例
683
- * @private
684
- */
685
- var _regRecordMethods = function(m, self) {
686
- /**
687
- * 上报
688
- * @param {string} clientid 设备sn
689
- * @param {object} params 上报参数
690
- * @param {object} msg 上报消息
691
- * @param {string} id 消息ID
692
- */
693
- m['RecPush'] = async function(clientid, params, msg, id) {
694
- _sendAck(clientid, params.RecordID, self);
695
-
696
- var type = _getRecordType(params.otype);
697
- if (type == 2) {
698
- return;
699
- }
700
-
701
- var log = _createLog(params, clientid, type);
702
- if (log) {
703
- $.server.execLog(clientid, log);
704
- }
705
- };
706
-
707
- m['QRCodePush'] = async function(clientid, params, msg, id) {
708
- var qrcode = params.QRCodeInfo;
709
- var {
710
- uuid,
711
- pass,
712
- tip,
713
- device
714
- } = await $.server.execQrcode(clientid, qrcode);
715
- if (device && device.online) {
716
- await self.unlock(clientid, uuid, pass, tip);
717
- }
718
- };
719
- };
package/com/nav/README.md DELETED
@@ -1,2 +0,0 @@
1
- ## 导航框架
2
- 用于生成前端所需的路由导航,配合vue路由使用,可以实现动态添加页面。
package/com/nav/com.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "name": "Nav",
3
- "title": "导航",
4
- "state": 1
5
- }