You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

491 lines
14 KiB

1 year ago
  1. const WXAPI = require('./request')
  2. export default class ICINLocker {
  3. /**
  4. * *添加用户
  5. * @param {锁ID} _lockId
  6. * @param {门锁IMEI} _imei
  7. * @param {添加的用户ID} _userId
  8. * @param {用户的keyId} _keyId
  9. * @param {00普通用户 01管理员 FF超级管理员} _role
  10. * @param {操作类型 1: 添加 2 删除} _action
  11. * @param {回调} callback
  12. */
  13. static addUserToLock(_lockId, _imei, _userId, _role, _action, order, _cardName,_roomName, callback) {
  14. var data = {
  15. lockerId: _lockId,
  16. imei: _imei,
  17. lockerUserId: _userId,
  18. keyId: _userId,
  19. role: _role,
  20. action: _action,
  21. order: order,
  22. cardName: _cardName,
  23. roomName:_roomName
  24. };
  25. WXAPI.ZGduserOperation(data).then(res => {
  26. callback(res)
  27. })
  28. }
  29. /**
  30. * *添加指纹
  31. * @param {门锁ID} _lockId
  32. * @param {门锁IMEI} _imei
  33. * @param {用户ID 最多20字节} _userId
  34. * @param {指纹类型 0:普通指纹1胁迫指} _fingerType
  35. * @param {文件字节数组} _file
  36. * @param {设置开始时间-8位timestamp字符串,eg:'00000000'} _startTime
  37. * @param {设置结束时间-8位timestamp字符串,eg:'FFFFFFFF'} _endTime
  38. * @param {是否为报警指纹'00'为否'01'为是} _alarmFinger
  39. * @param {超管的commonKey} _commonKey
  40. * @param {回调方法} callback
  41. */
  42. static addFingerPrints(_lockId, _imei, _userId, _fingerType, _file, _startTime, _endTime, _cardName,
  43. _roomName, callback) {
  44. var data3 = {
  45. code: "zg/addFingerPrint",
  46. data: {
  47. lockerId: _lockId,
  48. imei: _imei,
  49. lockerUserId: _userId,
  50. keyId: _userId,
  51. fingerType: _fingerType,
  52. order: 6216,
  53. file: _file,
  54. startTime: _startTime,
  55. endTime: _endTime,
  56. cardName: _cardName,
  57. roomName: _roomName
  58. }
  59. };
  60. WXAPI.sendCommand(data3).then((res) => {
  61. callback(res)
  62. })
  63. }
  64. /**
  65. * *删除指纹
  66. * @param {门锁ID} _lockId
  67. * @param {门锁IMEI} _imei
  68. * @param {用户ID 最多20字节} _userId
  69. * @param {指纹类型 0:普通指纹1胁迫指} _fingerType
  70. * @param {2删除 3修改} _action
  71. * @param {指纹模板号} _fingerId
  72. * @param {设置开始时间-8位timestamp字符串,eg:'00000000'} _startTime
  73. * @param {设置结束时间-8位timestamp字符串,eg:'FFFFFFFF'} _endTime
  74. * @param {是否为报警指纹'00'为否'01'为是} _alarmFinger
  75. * @param {超管的commonKey} _commonKey
  76. * @param {回调方法} callback
  77. */
  78. static delFingerPrints(_lockId, _imei, _userId, _action, _fingerId, _fingerType, _startTime, _endTime, _cardName, _roomName, callback) {
  79. var data3 = {
  80. code: "zg/fpOperate",
  81. data: {
  82. lockerId: _lockId,
  83. imei: _imei,
  84. lockerUserId: _userId,
  85. keyId: _userId,
  86. fingerId: _fingerId,
  87. fingerType: _fingerType,
  88. order: 6218,
  89. action: _action,
  90. startTime: _startTime,
  91. endTime: _endTime,
  92. cardName: _cardName,
  93. roomName: _roomName
  94. }
  95. };
  96. WXAPI.sendCommand(data3).then((res) => {
  97. callback(res)
  98. })
  99. }
  100. /**
  101. * *修改指纹时间
  102. * @param {门锁ID} _lockId
  103. * @param {门锁IMEI} _imei
  104. * @param {用户ID 最多20字节} _userId
  105. * @param {指纹类型 0:普通指纹1胁迫指} _fingerType
  106. * @param {2删除 3修改} _action
  107. * @param {指纹模板号} _fingerId
  108. * @param {设置开始时间-8位timestamp字符串,eg:'00000000'} _startTime
  109. * @param {设置结束时间-8位timestamp字符串,eg:'FFFFFFFF'} _endTime
  110. * @param {是否为报警指纹'00'为否'01'为是} _alarmFinger
  111. * @param {超管的commonKey} _commonKey
  112. * @param {回调方法} callback
  113. */
  114. static modifyFingerPrints(_lockId, _imei, _userId, _action, _fingerId, _fingerType, _startTime, _endTime,
  115. _cardName, _roomName,
  116. callback) {
  117. var data3 = {
  118. code: "zg/fpOperate",
  119. data: {
  120. lockerId: _lockId,
  121. imei: _imei,
  122. lockerUserId: _userId,
  123. keyId: _userId,
  124. fingerId: _fingerId,
  125. fingerType: _fingerType,
  126. order: 6217,
  127. action: _action,
  128. startTime: _startTime,
  129. endTime: _endTime,
  130. cardName: _cardName,
  131. roomName: _roomName
  132. }
  133. };
  134. WXAPI.sendCommand(data3).then((res) => {
  135. callback(res)
  136. })
  137. }
  138. /**
  139. * *添加身份证
  140. * @param {门锁ID} _lockId
  141. * @param {门锁IMEI} _imei
  142. * @param {用户ID 最多20字节} _userId
  143. * @param {操作类型 1: 添加 2 删除 3:修改} _action
  144. * @param {文件字节数组} _taskStatus 任务状态 1提交任务
  145. * @param {文件字节数组} _cardNo 卡号 卡片唯一标识
  146. * @param {文件字节数组} _cardType 卡类型 16 进制 typeA 在线卡 0x21 Mifare 在线卡 0x22 typeB 在线卡 0x23 身份证在线0x24 typeA 离线卡 0x71 Mifare 离线卡 0x72 typeB 离线卡 0x73
  147. * @param {设置开始时间-8位timestamp字符串,eg:'00000000'} _startTime
  148. * @param {设置结束时间-8位timestamp字符串,eg:'FFFFFFFF'} _endTime
  149. * @param {回调方法} callback
  150. */
  151. static RfCardRegister(_lockId, _imei, _userId, _action, _taskStatus, _cardNo, _cardType, _startTime, _endTime,
  152. order, _cardName, _roomName, callback) {
  153. var data3 = {
  154. code: "zg/cardOperate",
  155. data: {
  156. lockerId: _lockId,
  157. imei: _imei,
  158. lockerUserId: _userId,
  159. keyId: _userId,
  160. action: _action,
  161. taskStatus: _taskStatus,
  162. order: order,
  163. startTime: _startTime,
  164. endTime: _endTime,
  165. cardType: _cardType,
  166. cardNo: _cardNo,
  167. cardName: _cardName,
  168. roomName: _roomName
  169. },
  170. };
  171. WXAPI.sendCommand(data3).then((res) => {
  172. callback(res)
  173. })
  174. }
  175. static delCardRegister(_lockId, _imei, _userId, _action, _taskStatus, _cardNo, _cardType, _startTime, _endTime,
  176. order, cardIndex, _cardName , _roomName, callback) {
  177. var data3 = {
  178. code: "zg/cardOperate",
  179. data: {
  180. lockerId: _lockId,
  181. imei: _imei,
  182. lockerUserId: _userId,
  183. keyId: _userId,
  184. action: _action,
  185. taskStatus: _taskStatus,
  186. order: order,
  187. startTime: _startTime,
  188. endTime: _endTime,
  189. cardType: _cardType,
  190. cardNo: _cardNo,
  191. cardIndex: cardIndex,
  192. cardName: _cardName,
  193. roomName: _roomName
  194. },
  195. };
  196. WXAPI.sendCommand(data3).then((res) => {
  197. callback(res)
  198. })
  199. }
  200. /**
  201. * *添加密码
  202. * @param {门锁ID} _lockId
  203. * @param {门锁IMEI} _imei
  204. * @param {用户ID 最多20字节} _userId
  205. * @param {r 操作类型 1: 添加 2: 删除 3} _action
  206. * @param {文件字节数组} password 密码长度为 6 建议不要采用同样数字组合和连续简单组合
  207. * @param {回调方法} callback
  208. */
  209. static addForeverPassword(_lockId, _imei, _userId, _action, _password, _passwordCount, _startTime, _endTime, order,
  210. _cardName, _roomName,
  211. callback) {
  212. var data3 = {
  213. code: "zg/tempPassword",
  214. data: {
  215. lockerId: _lockId,
  216. imei: _imei,
  217. order: order,
  218. lockerUserId: _userId,
  219. passwordCount: _passwordCount,
  220. keyId: _userId,
  221. passwordStartTime: _startTime,
  222. passwordEndTime: _endTime,
  223. action: _action,
  224. password: _password,
  225. cardName: _cardName,
  226. roomName: _roomName
  227. },
  228. };
  229. WXAPI.sendCommand(data3).then((res) => {
  230. callback(res)
  231. })
  232. }
  233. static delForeverPassword(_lockId, _imei, _userId, _action, _password, _passwordCount, _startTime, _endTime, order,
  234. passwordIndex, _cardName, _roomName, callback) {
  235. var data3 = {
  236. code: "zg/tempPassword",
  237. data: {
  238. lockerId: _lockId,
  239. imei: _imei,
  240. order: order,
  241. lockerUserId: _userId,
  242. passwordCount: _passwordCount,
  243. keyId: _userId,
  244. passwordStartTime: _startTime,
  245. passwordEndTime: _endTime,
  246. action: _action,
  247. password: _password,
  248. passwordIndex: passwordIndex,
  249. cardName: _cardName,
  250. roomName: _roomName
  251. },
  252. };
  253. WXAPI.sendCommand(data3).then((res) => {
  254. callback(res)
  255. })
  256. }
  257. /*
  258. LD下发函数
  259. */
  260. /**
  261. * *添加用户
  262. * @param {锁ID} _deviceNum
  263. * @param {门锁IMEI} _imei
  264. * @param {添加的用户ID} _userTelephone
  265. * @param {用户的keyId} _userPassword
  266. * @param {用户的蓝牙密码password} _pwd
  267. * @param {操作类型} _mode
  268. * @param {操作指令} _order
  269. * @param {锁用户有效期开始时间} _passwordStartTime
  270. * @param {锁用户有效期结束时间} _passwordEndTime
  271. * @param {回调} callback
  272. */
  273. static LDAddUser(_deviceNum, _imei, _userTelephone, _userPassword, _pwd, _passwordStartTime, _passwordEndTime,
  274. _mode, _order, _cardName,_roomName, callback) {
  275. var data = {
  276. imei: _imei,
  277. deviceNum: _deviceNum,
  278. userTelephone: _userTelephone,
  279. userPassword: _userPassword,
  280. password: _pwd,
  281. operateMode: _mode,
  282. order: _order,
  283. passwordStartTime: _passwordStartTime,
  284. passwordEndTime: _passwordEndTime,
  285. is: false,
  286. cardName: _cardName,
  287. roomName:_roomName
  288. };
  289. WXAPI.getDeviceOperateUserInfo(data).then((res) => {
  290. callback(res)
  291. })
  292. }
  293. /**
  294. * *删除用户
  295. * @param {锁ID} _deviceNum
  296. * @param {门锁IMEI} _imei
  297. * @param {添加的用户ID} _userTelephone
  298. * @param {用户的keyId} _userPassword
  299. * @param {用户的蓝牙密码password} _pwd
  300. * @param {操作类型} _mode
  301. * @param {操作指令} _order
  302. * @param {锁用户有效期开始时间} _passwordStartTime
  303. * @param {锁用户有效期结束时间} _passwordEndTime
  304. * @param {回调} callback
  305. */
  306. static LDDeleteUser(_deviceNum, _imei, _userTelephone, _userPassword, _cardName,_roomName, callback) {
  307. var data = {
  308. imei: _imei,
  309. deviceNum: _deviceNum,
  310. userTelephone: _userTelephone,
  311. userPassword: _userPassword,
  312. password: "20210816",
  313. passwordStartTime: "20210813010101",
  314. passwordEndTime: "20680813010101",
  315. operateMode: 3,
  316. order: 6203,
  317. is: false,
  318. cardName: _cardName,
  319. roomName: _roomName
  320. };
  321. WXAPI.getDeviceOperateUserInfo(data).then((res)=> {
  322. callback(res)
  323. })
  324. }
  325. /**
  326. * *添加指纹
  327. * @param {锁ID} _deviceNum
  328. * @param {门锁IMEI} _imei
  329. * @param {添加的用户ID} _userTelephone
  330. * @param {用户的keyId} _userPassword
  331. * @param {用户的蓝牙密码password} _pwd
  332. * @param {操作类型} _mode
  333. * @param {操作指令} _order
  334. * @param {锁用户有效期开始时间} _passwordStartTime
  335. * @param {锁用户有效期结束时间} _passwordEndTime
  336. * @param {指纹数据长度length} _length
  337. * @param {指纹fpTimeId} _fpTimeId
  338. * @param {指纹数据fingerprint} _fingerprint
  339. * @param {回调} callback
  340. */
  341. static LDAddFingerPrints(_deviceNum, _imei, _userTelephone, _userPassword, _pwd, _passwordStartTime,
  342. _passwordEndTime,
  343. _mode, _order, _length, _fpTimeId, _fingerprint, _cardName, _roomName, callback) {
  344. var data = {
  345. imei: _imei,
  346. deviceNum: _deviceNum,
  347. userTelephone: _userTelephone,
  348. userPassword: _userPassword,
  349. password: _pwd,
  350. operateMode: _mode,
  351. order: _order,
  352. fingerprintStartTime: _passwordStartTime,
  353. fingerprintEndTime: _passwordEndTime,
  354. length: _length,
  355. fpTimeId: _fpTimeId,
  356. fingerprint: _fingerprint,
  357. is: false,
  358. cardName: _cardName,
  359. roomName: _roomName
  360. };
  361. WXAPI.fingerprintTransfer(data).then((res)=> {
  362. callback(res)
  363. })
  364. }
  365. /**
  366. * *添加身份证
  367. * @param {锁ID} _deviceNum
  368. * @param {门锁IMEI} _imei
  369. * @param {添加的用户ID} _userTelephone
  370. * @param {用户的keyId} _userPassword
  371. * @param {用户的蓝牙密码password} _pwd
  372. * @param {操作类型} _mode
  373. * @param {操作指令} _order
  374. * @param {锁用户有效期开始时间} _passwordStartTime
  375. * @param {锁用户有效期结束时间} _passwordEndTime
  376. * @param {指纹数据长度length} _length
  377. * @param {指纹fpTimeId} _fpTimeId
  378. * @param {指纹数据fingerprint} _fingerprint
  379. * @param {回调} callback
  380. */
  381. static LDRfCardRegister(_deviceNum, _imei, _userTelephone, _userPassword, _pwd, _passwordStartTime,
  382. _passwordEndTime,
  383. _mode, _order, _cardName, _roomName, callback) {
  384. var data = {
  385. imei: _imei,
  386. deviceNum: _deviceNum,
  387. userTelephone: _userTelephone,
  388. userPassword: _userPassword,
  389. password: _pwd,
  390. operateMode: _mode,
  391. order: _order,
  392. passwordStartTime: _passwordStartTime,
  393. passwordEndTime: _passwordEndTime,
  394. is: false,
  395. cardName: _cardName,
  396. roomName: _roomName
  397. };
  398. WXAPI.getDeviceOperateUserInfo(data).then((res) => {
  399. callback(res)
  400. })
  401. }
  402. static resetInitialization(row, callback) {
  403. if (row.manufactureId == 201||row.manufactureId == 221) {
  404. var data3 = {
  405. code: "zg/deleteAllUsers",
  406. data: {
  407. lockerId: row.deviceNum,
  408. imei: row.imei,
  409. order: 6501,
  410. },
  411. };
  412. WXAPI.sendCommand(data3).then((res) => {
  413. if (res.success) {
  414. this.$message.success("重置成功");
  415. } else {
  416. callback(false)
  417. }
  418. });
  419. } else if (row.manufactureId == 101) {
  420. var data2 = {
  421. code: "isp/restoreSetting",
  422. data: {
  423. order: 6501,
  424. imei: row.imei,
  425. deviceNum: row.deviceNum,
  426. managerTelephone: "18270949468",
  427. managerPassword: "202108",
  428. },
  429. };
  430. WXAPI.sendCommand(data2).then((res2) => {
  431. if (res2.success) {
  432. var str = {
  433. deviceNum: row.deviceNum,
  434. imei: row.imei,
  435. order: 6101,
  436. };
  437. WXAPI.getDeviceRegisterManager(str).then((res1) => {
  438. var str1 = {
  439. imei: row.imei, //row.imsi,
  440. deviceNum: row.deviceNum, //row.deviceNum,
  441. operateMode: 7,
  442. is: true,
  443. order: 6207,
  444. passwordStartTime: "20210813010101",
  445. passwordEndTime: "20680813010101",
  446. };
  447. WXAPI.getDeviceOperateUserInfo(str1).then((res2) => {});
  448. var str2 = {
  449. imei: row.imei, //row.imsi,
  450. deviceNum: row.deviceNum, //row.deviceNum,
  451. operateMode: 4,
  452. is: true,
  453. order: 6204,
  454. passwordStartTime: "20210813010101",
  455. passwordEndTime: "20680813010101",
  456. };
  457. WXAPI.getDeviceOperateUserInfo(str2).then((res3) => {
  458. if (res3.success) {
  459. callback(true)
  460. }
  461. });
  462. });
  463. } else {
  464. callback(false)
  465. }
  466. });
  467. }
  468. }
  469. static getPersonCallback(person, alllist, callback) {
  470. var personlist = []
  471. person.map(li => {
  472. var obj = {
  473. person: li,
  474. data: alllist.filter((item) => {
  475. if (item.deviceNum && item.cardId == li.cardId) {
  476. return item
  477. }
  478. })
  479. }
  480. personlist.push(obj)
  481. })
  482. callback(personlist)
  483. }
  484. }