mm_os 2.9.1 → 2.9.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.
Files changed (241) hide show
  1. package/cache/route/main/config.json +1 -0
  2. package/cache/sys/app_admin/config.json +1 -0
  3. package/cache/sys/mqtt_engine/config.json +1 -0
  4. package/cache/sys/user/config.json +1 -0
  5. package/core/com/api/drive.js +9 -89
  6. package/core/com/api/index.js +3 -31
  7. package/core/com/cmd/drive.js +10 -1
  8. package/core/com/cmd/index.js +15 -1
  9. package/core/com/component/drive.js +1 -1
  10. package/core/com/component/index.js +16 -12
  11. package/core/com/db/drive.js +1 -1
  12. package/core/com/db/index.js +15 -17
  13. package/core/com/event/drive.js +3 -1
  14. package/core/com/event/index.js +74 -61
  15. package/core/com/eventer/com.js +2 -2
  16. package/core/com/middleware/com.js +41 -16
  17. package/core/com/mqtt/drive.js +4 -3
  18. package/core/com/mqtt/index.js +10 -8
  19. package/core/com/nav/drive.js +1 -19
  20. package/core/com/nav/index.js +1 -1
  21. package/core/com/param/drive.js +1 -1
  22. package/core/com/param/index.js +1 -27
  23. package/core/com/plugin/drive.js +18 -19
  24. package/core/com/plugin/index.js +16 -21
  25. package/core/com/plugin/script.js +109 -58
  26. package/core/com/rpc/com.json +4 -0
  27. package/core/com/rpc/drive.js +160 -0
  28. package/core/com/rpc/index.js +87 -0
  29. package/core/com/socket/drive.js +0 -1
  30. package/core/com/socket/index.js +5 -15
  31. package/core/com/sql/drive.js +1 -1
  32. package/core/com/sql/index.js +4 -31
  33. package/core/com/static/drive.js +13 -54
  34. package/core/com/static/index.js +14 -6
  35. package/core/com/task/drive.js +7 -2
  36. package/core/com/task/index.js +16 -36
  37. package/core/com/tpl/com.js +2 -2
  38. package/demo/app/dev/event_api/manage/event.json +19 -0
  39. package/demo/app/dev/event_api/manage/main.js +26 -0
  40. package/demo/app/dev/plugin/doc/static/api_list.html +144 -0
  41. package/demo/app/dev/plugin/doc/static/api_view.html +692 -0
  42. package/demo/app/dev/plugin/doc/static/index.html +138 -0
  43. package/demo/app/dev/plugin/doc/static/request_test.html +311 -0
  44. package/demo/app/dev/plugin/doc/static/static.js +28 -0
  45. package/demo/app/dev/plugin/doc/static/static.json +20 -0
  46. package/demo/app/dev/plugin/main/api_dev_client/app/api.json +13 -0
  47. package/demo/app/dev/plugin/main/api_dev_client/app/index.js +13 -0
  48. package/demo/app/dev/plugin/main/api_dev_client/app/param.json +147 -0
  49. package/demo/app/dev/plugin/main/api_dev_client/app/sql.json +28 -0
  50. package/demo/app/dev/plugin/main/api_dev_client/auto/api.json +37 -0
  51. package/demo/app/dev/plugin/main/api_dev_client/auto/auto_db.js +70 -0
  52. package/demo/app/dev/plugin/main/api_dev_client/auto/auto_file.js +32 -0
  53. package/demo/app/dev/plugin/main/api_dev_client/auto/index.js +51 -0
  54. package/demo/app/dev/plugin/main/api_dev_client/auto/param.json +51 -0
  55. package/demo/app/dev/plugin/main/api_dev_client/db/api.json +10 -0
  56. package/demo/app/dev/plugin/main/api_dev_client/db/index.js +69 -0
  57. package/demo/app/dev/plugin/main/api_dev_client/db/param.json +31 -0
  58. package/demo/app/dev/plugin/main/api_dev_client/dict/api.json +10 -0
  59. package/demo/app/dev/plugin/main/api_dev_client/dict/index.js +49 -0
  60. package/demo/app/dev/plugin/main/api_dev_client/dict/param.json +29 -0
  61. package/demo/app/dev/plugin/main/api_dev_client/help/api.json +10 -0
  62. package/demo/app/dev/plugin/main/api_dev_client/help/index.js +14 -0
  63. package/demo/app/dev/plugin/main/api_dev_client/help/param.json +31 -0
  64. package/demo/app/dev/plugin/main/api_dev_client/nav/api.json +10 -0
  65. package/demo/app/dev/plugin/main/api_dev_client/nav/index.js +36 -0
  66. package/demo/app/dev/plugin/main/api_dev_client/nav/param.json +36 -0
  67. package/demo/app/dev/plugin/main/api_dev_client/plugin/api.json +10 -0
  68. package/demo/app/dev/plugin/main/api_dev_client/plugin/index.js +13 -0
  69. package/demo/app/dev/plugin/main/api_dev_client/plugin/param.json +31 -0
  70. package/demo/app/dev/plugin/main/api_dev_client/source/api.json +10 -0
  71. package/demo/app/dev/plugin/main/api_dev_client/source/index.js +14 -0
  72. package/demo/app/dev/plugin/main/api_dev_client/source/param.json +31 -0
  73. package/demo/app/dev/plugin/main/api_dev_client/sql/api.json +10 -0
  74. package/demo/app/dev/plugin/main/api_dev_client/sql/index.js +13 -0
  75. package/demo/app/dev/plugin/main/api_dev_client/sql/param.json +31 -0
  76. package/demo/app/dev/plugin/main/api_dev_client/task/api.json +16 -0
  77. package/demo/app/dev/plugin/main/api_dev_client/task/index.js +13 -0
  78. package/demo/app/dev/plugin/main/api_dev_client/task/param.json +31 -0
  79. package/demo/app/dev/plugin/main/api_dev_client/translate/api.json +39 -0
  80. package/demo/app/dev/plugin/main/api_dev_client/translate/index.js +43 -0
  81. package/demo/app/dev/plugin/main/api_dev_client/translate/param.json +130 -0
  82. package/demo/app/dev/plugin/main/api_dev_client/translate/sql.json +62 -0
  83. package/demo/app/dev/plugin/main/api_dev_client/ui/api.json +10 -0
  84. package/demo/app/dev/plugin/main/api_dev_client/ui/index.js +146 -0
  85. package/demo/app/dev/plugin/main/api_dev_client/ui/param.json +31 -0
  86. package/demo/app/dev/plugin/main/api_dev_client/view/api.json +10 -0
  87. package/demo/app/dev/plugin/main/api_dev_client/view/index.js +100 -0
  88. package/demo/app/dev/plugin/main/api_dev_client/view/param.json +29 -0
  89. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/nav.vue +12 -0
  90. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/obj.vue +12 -0
  91. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/post.vue +12 -0
  92. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/query.vue +12 -0
  93. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/edit.vue +39 -0
  94. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/list.vue +12 -0
  95. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/search.vue +12 -0
  96. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/table.vue +12 -0
  97. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/type.vue +12 -0
  98. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/view.vue +56 -0
  99. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/view.json +48 -0
  100. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/api.json +37 -0
  101. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/auto_db.js +120 -0
  102. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy.js +101 -0
  103. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy_framework.js +118 -0
  104. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy_template.js +78 -0
  105. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy_file.js +97 -0
  106. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/common.js +198 -0
  107. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/django_server.js +104 -0
  108. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/helper.js +161 -0
  109. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/koa_art_server.js +102 -0
  110. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/mini_app_home.js +415 -0
  111. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/razor.js +0 -0
  112. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/springboot.js +0 -0
  113. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/thinkphp.js +0 -0
  114. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/uni_app_home.js +418 -0
  115. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/vue_cli_admin.js +78 -0
  116. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/vue_cli_home.js +112 -0
  117. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create_file.js +97 -0
  118. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/add_data.js +221 -0
  119. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/create_table.js +162 -0
  120. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/set_auth_table.js +86 -0
  121. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/index.js +524 -0
  122. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/param.json +37 -0
  123. package/demo/app/route/app.js +131 -0
  124. package/demo/app/route/app.json +11 -0
  125. package/demo/app/route/event_api/client/event.json +10 -0
  126. package/demo/app/route/event_api/client/main.js +19 -0
  127. package/demo/app/route/event_api/manage/event.json +18 -0
  128. package/demo/app/route/event_api/manage/main.js +70 -0
  129. package/demo/app/route/plugin/main/api_route_client/pass/api.json +37 -0
  130. package/demo/app/route/plugin/main/api_route_client/pass/index.js +33 -0
  131. package/demo/app/route/plugin/main/api_route_client/pass/param.json +50 -0
  132. package/demo/app/route/plugin/main/index.js +144 -0
  133. package/demo/app/route/plugin/main/plugin.json +20 -0
  134. package/demo/app/sys/event_api/api/event.json +1 -1
  135. package/demo/app/sys/event_api/doc/event.json +18 -0
  136. package/demo/app/sys/event_api/doc/main.js +67 -0
  137. package/demo/app/sys/event_api/img/event.json +11 -0
  138. package/demo/app/sys/event_api/img/main.js +90 -0
  139. package/demo/app/sys/event_api/web/event.json +4 -4
  140. package/demo/app/sys/plugin/app_admin/index.js +127 -0
  141. package/demo/app/sys/plugin/app_admin/plugin.json +20 -0
  142. package/demo/app/sys/plugin/main/api_client/config/sql.json +70 -0
  143. package/demo/app/sys/plugin/main/api_client/lang/api.json +37 -0
  144. package/demo/app/sys/plugin/main/api_client/lang/index.js +27 -0
  145. package/demo/app/sys/plugin/main/api_client/lang/param.json +22 -0
  146. package/demo/app/sys/plugin/main/api_client/translate/api.json +39 -0
  147. package/demo/app/sys/plugin/main/api_client/translate/index.js +21 -0
  148. package/demo/app/sys/plugin/main/api_client/translate/param.json +130 -0
  149. package/demo/app/sys/plugin/main/api_client/translate/sql.json +62 -0
  150. package/demo/app/sys/plugin/main/static/static.json +1 -1
  151. package/demo/app/sys/plugin/main/task/task_demo/index.js +37 -0
  152. package/demo/app/sys/plugin/main/task/task_demo/task.json +24 -0
  153. package/demo/app/sys/plugin/mqtt_engine/LICENSE +201 -0
  154. package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/api.json +33 -0
  155. package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/index.js +31 -0
  156. package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/param.json +130 -0
  157. package/demo/app/sys/plugin/mqtt_engine/index.js +51 -0
  158. package/demo/app/sys/plugin/mqtt_engine/mqtt/df/index.js +509 -0
  159. package/demo/app/sys/plugin/mqtt_engine/mqtt/df/mqtt.json +24 -0
  160. package/demo/app/sys/plugin/mqtt_engine/mqtt/zs/index.js +622 -0
  161. package/demo/app/sys/plugin/mqtt_engine/mqtt/zs/mqtt.json +36 -0
  162. package/demo/app/sys/plugin/mqtt_engine/plugin.json +21 -0
  163. package/demo/app/sys/plugin/mqtt_engine/static/img/logo.png +0 -0
  164. package/demo/app/sys/plugin/mqtt_engine/static/img/logo1.png +0 -0
  165. package/demo/app/sys/plugin/mqtt_engine/static/static.json +18 -0
  166. package/demo/app/sys/plugin/user/index.js +127 -0
  167. package/demo/app/sys/plugin/user/plugin.json +20 -0
  168. package/demo/app/sys/plugin/user/static/img/logo.png +0 -0
  169. package/demo/app/sys/plugin/user/static/static.js +28 -0
  170. package/demo/app/sys/plugin/user/static/static.json +20 -0
  171. package/demo/app/sys/static/img/avatar_1674484608066.png +0 -0
  172. package/demo/app/sys/static/img/avatar_1674633778171.jpeg +0 -0
  173. package/demo/app/sys/static/img/avatar_1674962702334.jpeg +0 -0
  174. package/demo/app/sys/static/img/avatar_1675075431736.jpeg +0 -0
  175. package/demo/app/sys/static/img/avatar_1675497065533.jpeg +0 -0
  176. package/demo/app/sys/static/img/avatar_1685352550990.jpeg +0 -0
  177. package/demo/app/sys/static/img/avatar_1685353685992.jpeg +0 -0
  178. package/demo/app/sys/static/img/avatar_1685353956587.jpeg +0 -0
  179. package/demo/app/sys/static/img/avatar_1685353971148.jpeg +0 -0
  180. package/demo/app/sys/static/img/avatar_1685353983723.jpeg +0 -0
  181. package/demo/app/sys/static/img/avatar_1685354014745.jpeg +0 -0
  182. package/demo/app/sys/static/img/avatar_1685354122355.jpeg +0 -0
  183. package/demo/app/sys/static/img/avatar_1685357983520.jpeg +0 -0
  184. package/demo/app/sys/static/img/avatar_1685358453383.jpeg +0 -0
  185. package/demo/app/sys/static/img/avatar_1685416570438.jpeg +0 -0
  186. package/demo/app/sys/static/img/avatar_1685512675830.png +0 -0
  187. package/demo/app/sys/static/img/avatar_1685939425608.jpeg +0 -0
  188. package/demo/app/sys/static/img/avatar_1685939886560.jpeg +0 -0
  189. package/demo/app/sys/static/img/avatar_1686106313194.png +0 -0
  190. package/demo/app/sys/static/img/avatar_1686371876175.png +0 -0
  191. package/demo/app/sys/static/img/avatar_1686372033596.png +0 -0
  192. package/demo/app/sys/static/img/avatar_1688215220669.png +0 -0
  193. package/demo/app/sys/static/img/avatar_1688531184690.png +0 -0
  194. package/demo/app/sys/static/img/avatar_1688531233080.png +0 -0
  195. package/demo/app/sys/static/img/avatar_1688548526909.png +0 -0
  196. package/demo/app/sys/static/img/avatar_1688549213411.png +0 -0
  197. package/demo/app/sys/static/img/avatar_1688549511977.png +0 -0
  198. package/demo/app/sys/static/img/avatar_1688549685464.png +0 -0
  199. package/demo/app/sys/static/img/avatar_1688608623049.png +0 -0
  200. package/demo/app/sys/static/img/avatar_1688638500476.png +0 -0
  201. package/demo/app/sys/static/img/avatar_1688638515195.png +0 -0
  202. package/demo/app/sys/static/img/avatar_1688638539928.png +0 -0
  203. package/demo/app/sys/static/img/avatar_1688638557960.png +0 -0
  204. package/demo/app/sys/static/img/avatar_1688638761798.png +0 -0
  205. package/demo/app/sys/static/img/avatar_1688638943140.png +0 -0
  206. package/demo/app/sys/static/img/avatar_1688639068330.png +0 -0
  207. package/demo/app/sys/static/img/image_1685357101273.jpeg +0 -0
  208. package/demo/app/sys/static/img/logo.png +0 -0
  209. package/demo/app/sys/static/static.js +28 -0
  210. package/demo/app/sys/static/static.json +20 -0
  211. package/demo/app/user/plugin/main/api_user_client/core/api.json +20 -0
  212. package/demo/app/user/plugin/main/api_user_client/core/forgot.js +14 -0
  213. package/demo/app/user/plugin/main/api_user_client/core/password.js +14 -0
  214. package/demo/app/user/plugin/main/api_user_client/core/sign_out.js +26 -0
  215. package/demo/app/user/plugin/main/api_user_client/core/state.js +21 -0
  216. package/demo/app/user/plugin/main/api_user_client/forgot/index - /345/211/257/346/234/254.jsbat" +41 -0
  217. package/demo/app/user/plugin/main/api_user_client/phone_code/index.js_ +230 -0
  218. package/demo/app/user/plugin/main/api_user_manage/account_base/api.json +37 -0
  219. package/demo/app/user/plugin/main/api_user_manage/account_base/index.js +40 -0
  220. package/demo/app/user/plugin/main/api_user_manage/account_base/param.json +130 -0
  221. package/demo/app/user/plugin/main/api_user_manage/invitation_code/api.json +37 -0
  222. package/demo/app/user/plugin/main/api_user_manage/invitation_code/index.js +106 -0
  223. package/demo/app/user/plugin/main/api_user_manage/invitation_code/param.json +130 -0
  224. package/demo/app/user/plugin/main/api_user_manage/update_team/api.json +35 -0
  225. package/demo/app/user/plugin/main/api_user_manage/update_team/index.js +218 -0
  226. package/demo/app/user/plugin/main/api_user_manage/update_team/param.json +130 -0
  227. package/demo/app/user/static/img/logo.png +0 -0
  228. package/demo/app/user/static/static.js +28 -0
  229. package/demo/app/user/static/static.json +20 -0
  230. package/demo/app/ws/app.js +122 -0
  231. package/demo/app/ws/app.json +11 -0
  232. package/demo/app/ws/event_api/client/event.json +10 -0
  233. package/demo/app/ws/event_api/client/main.js +17 -0
  234. package/demo/app/ws/socket/ws/index.js +43 -0
  235. package/demo/app/ws/socket/ws/socket.json +14 -0
  236. package/demo/config/face.sql +3824 -0
  237. package/demo/config/local.json +2 -2
  238. package/demo/config/test.json +2 -2
  239. package/index.js +2 -2
  240. package/package.json +2 -2
  241. /package/core/com/{api → rpc}/rpc.js +0 -0
@@ -0,0 +1,509 @@
1
+ /**
2
+ * 查询个人记录
3
+ * @param {String} clientid 客户端ID
4
+ * @param {Object} param
5
+ */
6
+ exports.get_log = function(clientid, param) {
7
+ return this.push("GetRecordsByPicOrID", clientid, param);
8
+ }
9
+
10
+ /**
11
+ * 考勤打卡
12
+ * @param {String} clientid 客户端ID
13
+ * @param {Object} uuid 用户唯一标识
14
+ * @param {String} avatar base64头像
15
+ * @param {Number} longtime 超时回馈
16
+ */
17
+ exports.sign_in = async function(clientid, uuid, avatar) {
18
+ var res = await this.push("PullRecordOnlyPic", clientid, {
19
+ "personID": uuid,
20
+ "picinfo": avatar
21
+ });
22
+
23
+ if (!res || res.result == "fail") {
24
+ return "打卡失败!";
25
+ }
26
+ }
27
+
28
+ /**
29
+ * 下发二维码(没用到)
30
+ * @param {String} clientid
31
+ * @param {Object} param
32
+ * @param {Number} longtime 超时回馈
33
+ */
34
+ exports.push_qrcode = function(clientid, param) {
35
+ return this.push("ShowQRCode", clientid, param);
36
+ }
37
+
38
+ /**
39
+ * 以图搜人
40
+ * @param {String} clientid 客户端ID
41
+ * @param {Object} avatar 人脸照片
42
+ * @param {Number} longtime 超时回馈
43
+ */
44
+ exports.get_member_pic = async function(clientid, avatar) {
45
+ var res = await this.push("GetPictureSearch", clientid, {
46
+ "facesluiceId": clientid,
47
+ "MaxSimilarity": 80,
48
+ "MaxNum": 1,
49
+ "picinfo": avatar
50
+ });
51
+ var user;
52
+ if (res) {
53
+ if (res.result == "fail") {
54
+
55
+ } else {
56
+ var u = res.SearchInfo[0];
57
+ var name = u.name || u.persionName;
58
+ var customId = u.customId.trim();
59
+ var phone = (u.telnum || "").trim();
60
+ var idcard = (u.idCard || "").trim();
61
+ user = {
62
+ name,
63
+ customId,
64
+ phone,
65
+ idcard
66
+ }
67
+ }
68
+ }
69
+ return user
70
+ }
71
+
72
+ /**
73
+ * 远程开门
74
+ * @param {String} clientid 客户端ID
75
+ * @param {String} uuid 用户唯一标识
76
+ * @param {Boolean} pass 是否可通行 true为是
77
+ * @param {String} tip 提示
78
+ */
79
+ exports.unlock = async function(clientid, uuid = '0', pass = false, tip = '没有访问权限') {
80
+ var res = await this.push("Unlock", clientid, {
81
+ "uid": uuid,
82
+ // 0不开门,1开门
83
+ "openDoor": pass ? "1" : "0",
84
+ "showInfo": tip
85
+ });
86
+
87
+ if (!res || res.result == "fail") {
88
+ return "非内部人员!";
89
+ }
90
+ }
91
+
92
+ /**
93
+ * 删除成员
94
+ * @param {String} clientid 客户端ID
95
+ * @param {String} uuid 用户唯一标识
96
+ * @param {Number} longtime 超时回馈
97
+ */
98
+ exports.delete_member = async function(clientid, uuid) {
99
+ var res = await this.push("DeletePersons", clientid, {
100
+ "customId": uuid
101
+ });
102
+
103
+ if (!res || res.result == "fail") {
104
+ return "删除失败!";
105
+ }
106
+ }
107
+
108
+ /**
109
+ * 批量删除成员
110
+ * @param {String} clientid 客户端ID
111
+ * @param {Object} arr 成员列表
112
+ * @param {Number} longtime 超时回馈
113
+ */
114
+ exports.delete_member_batch = async function(clientid, arr, longtime) {
115
+ var res = await this.push("DeletePersons", clientid, {
116
+ DataBegin: "BeginFlag",
117
+ DataEnd: "EndFlag",
118
+ PersonNum: arr.length.toString(),
119
+ customId: arr
120
+ }, longtime);
121
+
122
+ var result;
123
+ var error = 0;
124
+ var success = 0;
125
+ var error_info = [];
126
+ var success_info = [];
127
+
128
+ if (res) {
129
+ if (res.result == 'ok') {
130
+ var now = new Date().toStr("yyyy-MM-dd hh:mm:ss");
131
+ error = Number(res.DelErrNum);
132
+ success = Number(res.DelSucNum);
133
+ error_info = res.DelErrInfo.map((o) => {
134
+ o.time_create = now;
135
+ return o
136
+ });
137
+ success_info = res.DelSucInfo.map((o) => {
138
+ o.time_create = now;
139
+ return o
140
+ });
141
+ result = res.result;
142
+ } else if (res.detail && res.detail.indexOf('busy') === -1) {
143
+ result = 'fail';
144
+ }
145
+ }
146
+ return {
147
+ error,
148
+ success,
149
+ error_info,
150
+ success_info,
151
+ result
152
+ };
153
+ }
154
+
155
+ /**
156
+ * 重启设备
157
+ * @param {String} clientid 设备sn
158
+ */
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 "重启设备失败"
165
+ }
166
+
167
+ /**
168
+ * 设置设备时间
169
+ * @param {String} clientid 设备sn
170
+ * @param {String} datetime 日期时间
171
+ */
172
+ exports.set_device_time = async function(clientid, datetime) {
173
+ var res = await this.push("SetSysTime", clientid, {
174
+ "SysTime": datetime.replace(" ", "T")
175
+ });
176
+ if (!res || res.result == "ok") {
177
+ return
178
+ }
179
+ return "重置时间失败"
180
+ }
181
+
182
+ /**
183
+ * 恢复出厂设置
184
+ * @param {String} clientid 设备sn
185
+ * @param {Boolean} record 是否恢复控制记录,true为恢复
186
+ * @param {Boolean} member 是否恢复成员,true为恢复
187
+ * @param {Boolean} log 是否恢复请求日志,true为恢复
188
+ */
189
+ exports.reset_device = async function(clientid, record = true, member = false, log = true) {
190
+ var res = await this.push("SetFactoryDefault", clientid, {
191
+ DefaltRecord: record ? "1" : "0",
192
+ DefaltPerson: member ? "1" : "0",
193
+ DefaltLog: log ? "1" : "0"
194
+ });
195
+
196
+ if (!res || res.result == "ok") {
197
+ return
198
+ }
199
+ return "恢复出厂设置失败"
200
+ }
201
+
202
+ /**
203
+ * 查询下发进度
204
+ * @param {String} clientid 设备sn
205
+ * @param {String} mode 查询方式 默认为更新
206
+ */
207
+ exports.get_progress = async function(clientid, mode = 'update') {
208
+ var type = "";
209
+ if (mode == 'update') {
210
+ type = "EditPersonsNew";
211
+ } else {
212
+ type = "DeletePersons";
213
+ }
214
+ var res = await this.push("QueryProgress", clientid, {
215
+ "QueryType": type
216
+ });
217
+ if (res) {
218
+ if (res.Status !== "0") {
219
+ return 1;
220
+ } else {
221
+ return 0;
222
+ }
223
+ }
224
+ return -1;
225
+ }
226
+
227
+ /**
228
+ * 考勤补卡
229
+ * @param {String} clientid 设备sn
230
+ * @param {Object} param 其他信息
231
+ * @param {Number} longtime 超时回馈
232
+ */
233
+ exports.replacement = async function(clientid, uuid, time, avatar) {
234
+ var res = await this.push("PullRecordOnlyPic", clientid, {
235
+ "personID": uuid,
236
+ "time": time,
237
+ "picinfo": avatar
238
+ });
239
+
240
+ if (!res || res.result == "fail") {
241
+ return "补卡失败!";
242
+ }
243
+ return
244
+ }
245
+
246
+ /**
247
+ * 查询人员名单
248
+ * @param {String} clientid 客户端ID
249
+ * @param {Number} longtime 超时回馈
250
+ */
251
+ exports.get_member = function(clientid, longtime = 0) {
252
+ return this.push("QueryPerson", clientid, longtime);
253
+ }
254
+
255
+ /**
256
+ * 查询人员名单
257
+ * @param {String} clientid 客户端ID
258
+ * @param {String} uuid 用户唯一标识
259
+ * @param {Number} longtime 超时回馈
260
+ */
261
+ exports.get_member_one = function(clientid, uuid, longtime = 0) {
262
+ return this.push("QueryPerson", clientid, {
263
+ "personId": uuid
264
+ }, longtime);
265
+ }
266
+
267
+ /**
268
+ * 成员模型
269
+ * @param {Object} m 原始的成员
270
+ */
271
+ exports.member_model_out = function(m) {
272
+ var nfc = m.nfc || '';
273
+ var obj = {
274
+ "customId": m.customId,
275
+ "name": m.name,
276
+ "native": m.place || '',
277
+ "nation": m.nation || '',
278
+ "address": m.address || '',
279
+ "idCard": m.idcard || '',
280
+ "gender": m.sex - 1,
281
+ "phone": m.phone,
282
+ "birthday": m.birthday,
283
+ "cardType2": 2,
284
+ "cardNum2": nfc,
285
+ "RFCardMode": 0,
286
+ "RFIDCard": nfc,
287
+ "notes": "",
288
+ "personType": m.state == 4 ? 1 : 0,
289
+ "cardType": 0,
290
+ "picURI": this.fullUrl(m.avatar)
291
+ }
292
+
293
+ if (m.time_valid_end && m.time_valid_end.toTime() > "2021-01-01 00:00:00".toTime() && m.time_valid_end.toTime() <=
294
+ "2038-01-01 00:00:00".toTime()) {
295
+ if (typeof(m.time_valid_start) == "object") {
296
+ obj.cardValidBegin = m.time_valid_start.toStr("yyyy-MM-dd hh:mm:ss");
297
+ } else {
298
+ obj.cardValidBegin = m.time_valid_start.toTime().toStr("yyyy-MM-dd hh:mm:ss");
299
+ }
300
+ if (typeof(m.time_valid_end) == "object") {
301
+ obj.cardValidEnd = m.time_valid_end.toStr("yyyy-MM-dd hh:mm:ss");
302
+ } else {
303
+ obj.cardValidEnd = m.time_valid_end.toTime().toStr("yyyy-MM-dd hh:mm:ss");
304
+ }
305
+ obj.tempCardType = 1;
306
+ } else {
307
+ obj.tempCardType = 0;
308
+ }
309
+ return obj
310
+ }
311
+
312
+ /**
313
+ * 批量下发人员名单
314
+ * @param {String} clientid 客户端ID
315
+ * @param {Array} list 人员名单
316
+ * @param {Number} longtime 超时回馈
317
+ */
318
+ exports.update_member_batch = async function(clientid, list, longtime = 180) {
319
+ var res = await this.pushS(clientid, {
320
+ "messageId": this.get_msgid('EditPersonsNew'),
321
+ "DataBegin": "BeginFlag",
322
+ "DataEnd": "EndFlag",
323
+ "operator": "EditPersonsNew",
324
+ "PersonNum": list.length,
325
+ "info": list.map((o) => {
326
+ return this.member_model_out(o);
327
+ })
328
+ }, longtime);
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
+ };
360
+ }
361
+
362
+ /**
363
+ * 下发人员名单
364
+ * @param {String} clientid 设备ID
365
+ * @param {Object} user 人员信息
366
+ * @param {Number} longtime 超时回馈
367
+ */
368
+ exports.update_member = function(clientid, user, longtime = 0) {
369
+ return this.pushS(clientid, {
370
+ "messageId": this.get_msgid('EditPerson'),
371
+ "DataBegin": "BeginFlag",
372
+ "DataEnd": "EndFlag",
373
+ "method": "EditPerson",
374
+ "info": this.member_model_out(user)
375
+ }, longtime);
376
+ }
377
+
378
+ /**
379
+ * 初始化函数, 用于定义开放给前端的函数
380
+ */
381
+ exports.init = function() {
382
+ var m = this.methods;
383
+ var _this = this;
384
+
385
+ m["HeartBeat"] = function(clientid, params) {
386
+ if (!_this.drives[clientid]) {
387
+ _this.drives[clientid] = {};
388
+ }
389
+ _this.drives[clientid].online = 1;
390
+ _this.drives[clientid].time_last = new Date().getTime();
391
+ // console.log("心跳", clientid, _this.drives[clientid]);
392
+ }
393
+
394
+ /**
395
+ * 在线通知
396
+ * @param {String} clientid 设备sn
397
+ * @param {Object} param 其他信息
398
+ */
399
+ m["Offline"] = async function(clientid, params) {
400
+ _this.update_online(clientid, 0);
401
+ // console.log("离线", clientid, _this.drives[clientid]);
402
+ };
403
+
404
+ /**
405
+ * 在线通知
406
+ * @param {String} clientid 设备sn
407
+ * @param {Object} param 其他信息
408
+ */
409
+ m["Online"] = async function(clientid, params) {
410
+ await _this.update_online(clientid, 1, params.ip);
411
+ return {
412
+ "facesluiceId": clientid,
413
+ "result": "ok",
414
+ "detail": ""
415
+ };
416
+ console.log("上线", clientid, _this.drives[clientid]);
417
+ };
418
+
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
+ });
428
+ var type = 1;
429
+ switch (params.otype) {
430
+ // (1刷脸验证|2远程开门|3智码开门|4刷卡验证)
431
+ case "7":
432
+ case "27":
433
+ type = 2;
434
+ break;
435
+ case "47":
436
+ case "48":
437
+ case "55":
438
+ case "56":
439
+ case "57":
440
+ type = 3;
441
+ break;
442
+ case "21":
443
+ case "22":
444
+ case "24":
445
+ case "25":
446
+ type = 4;
447
+ break;
448
+ default:
449
+ break;
450
+ }
451
+ if (type == 2) {
452
+ return;
453
+ }
454
+ // 1白名单|2黑名单
455
+ var person_type = params.PersonType == "1" ? 2 : 1;
456
+ var record_type = params.RecordType ? Number(params.RecordType) + 1 : 1;
457
+
458
+ // 拿到打卡人的姓名
459
+ var name = params.persionName || params.name;
460
+ if (!name) {
461
+ return;
462
+ }
463
+ var customId = params.customId.trim();
464
+ var phone = (params.telnum || "").trim();
465
+ var idcard = (params.idCard || "").trim();
466
+ var nfc = (params.cardNum2 || params.RFIDCard || "").trim();
467
+ if (nfc == "0") {
468
+ ncf = ""
469
+ }
470
+ var time = params.time;
471
+ var avatar = "";
472
+ if (params.pic) {
473
+ avatar = params.pic;
474
+ }
475
+ if (typeof(time) == "object") {
476
+ time = time.toStr("yyyy-MM-dd hh:mm:ss");
477
+ } else {
478
+ time = time.toTime().toStr("yyyy-MM-dd hh:mm:ss");
479
+ }
480
+ var log = {
481
+ customId,
482
+ name,
483
+ phone,
484
+ idcard,
485
+ nfc,
486
+ clientid,
487
+ type,
488
+ person_type,
489
+ record_type,
490
+ action: "刷脸验证",
491
+ time,
492
+ avatar
493
+ }
494
+ $.server.exec_log(clientid, log);
495
+ }
496
+
497
+ m["QRCodePush"] = async function(clientid, params, msg, id) {
498
+ var qrcode = params.QRCodeInfo;
499
+ var {
500
+ uuid,
501
+ pass,
502
+ tip,
503
+ device
504
+ } = await $.server.exec_qrcode(clientid, qrcode);
505
+ if (device && device.online) {
506
+ await _this.unlock(clientid, uuid, pass, tip);
507
+ }
508
+ }
509
+ };
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "DF",
3
+ "title": "原设备",
4
+ "description": "",
5
+ "state": 1,
6
+ "topic": [
7
+ "mqtt/face/#"
8
+ ],
9
+ "topic_receive": [
10
+ "mqtt/face/${clientid}"
11
+ ],
12
+ "topic_push": "mqtt/face/${clientid}",
13
+ "qos": 1,
14
+ "qos_push": 0,
15
+ "retain": true,
16
+ "longtime": 10000,
17
+ "func_file": "./index.js",
18
+ "clientid": "facesluiceId",
19
+ "msgid": "messageId",
20
+ "method": "operator",
21
+ "params": "info",
22
+ "result": "info",
23
+ "method_receive": "${method}-Ack"
24
+ }