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

const WXAPI = require('./request')
export default class ICINLocker {
/**
* *添加用户
* @param {锁ID} _lockId
* @param {门锁IMEI} _imei
* @param {添加的用户ID} _userId
* @param {用户的keyId} _keyId
* @param {00普通用户 01管理员 FF超级管理员} _role
* @param {操作类型 1: 添加 2: 删除} _action
* @param {回调} callback
*/
static addUserToLock(_lockId, _imei, _userId, _role, _action, order, _cardName,_roomName, callback) {
var data = {
lockerId: _lockId,
imei: _imei,
lockerUserId: _userId,
keyId: _userId,
role: _role,
action: _action,
order: order,
cardName: _cardName,
roomName:_roomName
};
WXAPI.ZGduserOperation(data).then(res => {
callback(res)
})
}
/**
* *添加指纹
* @param {门锁ID} _lockId
* @param {门锁IMEI} _imei
* @param {用户ID – 最多20字节} _userId
* @param {指纹类型 0:普通指纹,1:胁迫指} _fingerType
* @param {文件字节数组} _file
* @param {设置开始时间-8位timestamp字符串,eg:'00000000'} _startTime
* @param {设置结束时间-8位timestamp字符串,eg:'FFFFFFFF'} _endTime
* @param {是否为报警指纹,'00'为否,'01'为是} _alarmFinger
* @param {超管的commonKey} _commonKey
* @param {回调方法} callback
*/
static addFingerPrints(_lockId, _imei, _userId, _fingerType, _file, _startTime, _endTime, _cardName,
_roomName, callback) {
var data3 = {
code: "zg/addFingerPrint",
data: {
lockerId: _lockId,
imei: _imei,
lockerUserId: _userId,
keyId: _userId,
fingerType: _fingerType,
order: 6216,
file: _file,
startTime: _startTime,
endTime: _endTime,
cardName: _cardName,
roomName: _roomName
}
};
WXAPI.sendCommand(data3).then((res) => {
callback(res)
})
}
/**
* *删除指纹
* @param {门锁ID} _lockId
* @param {门锁IMEI} _imei
* @param {用户ID – 最多20字节} _userId
* @param {指纹类型 0:普通指纹,1:胁迫指} _fingerType
* @param {2:删除 3:修改} _action
* @param {指纹模板号} _fingerId
* @param {设置开始时间-8位timestamp字符串,eg:'00000000'} _startTime
* @param {设置结束时间-8位timestamp字符串,eg:'FFFFFFFF'} _endTime
* @param {是否为报警指纹,'00'为否,'01'为是} _alarmFinger
* @param {超管的commonKey} _commonKey
* @param {回调方法} callback
*/
static delFingerPrints(_lockId, _imei, _userId, _action, _fingerId, _fingerType, _startTime, _endTime, _cardName, _roomName, callback) {
var data3 = {
code: "zg/fpOperate",
data: {
lockerId: _lockId,
imei: _imei,
lockerUserId: _userId,
keyId: _userId,
fingerId: _fingerId,
fingerType: _fingerType,
order: 6218,
action: _action,
startTime: _startTime,
endTime: _endTime,
cardName: _cardName,
roomName: _roomName
}
};
WXAPI.sendCommand(data3).then((res) => {
callback(res)
})
}
/**
* *修改指纹时间
* @param {门锁ID} _lockId
* @param {门锁IMEI} _imei
* @param {用户ID – 最多20字节} _userId
* @param {指纹类型 0:普通指纹,1:胁迫指} _fingerType
* @param {2:删除 3:修改} _action
* @param {指纹模板号} _fingerId
* @param {设置开始时间-8位timestamp字符串,eg:'00000000'} _startTime
* @param {设置结束时间-8位timestamp字符串,eg:'FFFFFFFF'} _endTime
* @param {是否为报警指纹,'00'为否,'01'为是} _alarmFinger
* @param {超管的commonKey} _commonKey
* @param {回调方法} callback
*/
static modifyFingerPrints(_lockId, _imei, _userId, _action, _fingerId, _fingerType, _startTime, _endTime,
_cardName, _roomName,
callback) {
var data3 = {
code: "zg/fpOperate",
data: {
lockerId: _lockId,
imei: _imei,
lockerUserId: _userId,
keyId: _userId,
fingerId: _fingerId,
fingerType: _fingerType,
order: 6217,
action: _action,
startTime: _startTime,
endTime: _endTime,
cardName: _cardName,
roomName: _roomName
}
};
WXAPI.sendCommand(data3).then((res) => {
callback(res)
})
}
/**
* *添加身份证
* @param {门锁ID} _lockId
* @param {门锁IMEI} _imei
* @param {用户ID – 最多20字节} _userId
* @param {操作类型 1: 添加 2: 删除 3:修改} _action
* @param {文件字节数组} _taskStatus 任务状态 1:提交任务
* @param {文件字节数组} _cardNo 卡号 卡片唯一标识
* @param {文件字节数组} _cardType 卡类型 (16 进制) :typeA 在线卡 0x21 Mifare 在线卡 0x22 typeB 在线卡 0x23 身份证(在线)0x24 typeA 离线卡 0x71 Mifare 离线卡 0x72 typeB 离线卡 0x73
* @param {设置开始时间-8位timestamp字符串,eg:'00000000'} _startTime
* @param {设置结束时间-8位timestamp字符串,eg:'FFFFFFFF'} _endTime
* @param {回调方法} callback
*/
static RfCardRegister(_lockId, _imei, _userId, _action, _taskStatus, _cardNo, _cardType, _startTime, _endTime,
order, _cardName, _roomName, callback) {
var data3 = {
code: "zg/cardOperate",
data: {
lockerId: _lockId,
imei: _imei,
lockerUserId: _userId,
keyId: _userId,
action: _action,
taskStatus: _taskStatus,
order: order,
startTime: _startTime,
endTime: _endTime,
cardType: _cardType,
cardNo: _cardNo,
cardName: _cardName,
roomName: _roomName
},
};
WXAPI.sendCommand(data3).then((res) => {
callback(res)
})
}
static delCardRegister(_lockId, _imei, _userId, _action, _taskStatus, _cardNo, _cardType, _startTime, _endTime,
order, cardIndex, _cardName , _roomName, callback) {
var data3 = {
code: "zg/cardOperate",
data: {
lockerId: _lockId,
imei: _imei,
lockerUserId: _userId,
keyId: _userId,
action: _action,
taskStatus: _taskStatus,
order: order,
startTime: _startTime,
endTime: _endTime,
cardType: _cardType,
cardNo: _cardNo,
cardIndex: cardIndex,
cardName: _cardName,
roomName: _roomName
},
};
WXAPI.sendCommand(data3).then((res) => {
callback(res)
})
}
/**
* *添加密码
* @param {门锁ID} _lockId
* @param {门锁IMEI} _imei
* @param {用户ID – 最多20字节} _userId
* @param {r 操作类型 1: 添加 2: 删除 3:修} _action
* @param {文件字节数组} password 密码长度为 6 位,建议不要采用同样数字组合和连续简单组合
* @param {回调方法} callback
*/
static addForeverPassword(_lockId, _imei, _userId, _action, _password, _passwordCount, _startTime, _endTime, order,
_cardName, _roomName,
callback) {
var data3 = {
code: "zg/tempPassword",
data: {
lockerId: _lockId,
imei: _imei,
order: order,
lockerUserId: _userId,
passwordCount: _passwordCount,
keyId: _userId,
passwordStartTime: _startTime,
passwordEndTime: _endTime,
action: _action,
password: _password,
cardName: _cardName,
roomName: _roomName
},
};
WXAPI.sendCommand(data3).then((res) => {
callback(res)
})
}
static delForeverPassword(_lockId, _imei, _userId, _action, _password, _passwordCount, _startTime, _endTime, order,
passwordIndex, _cardName, _roomName, callback) {
var data3 = {
code: "zg/tempPassword",
data: {
lockerId: _lockId,
imei: _imei,
order: order,
lockerUserId: _userId,
passwordCount: _passwordCount,
keyId: _userId,
passwordStartTime: _startTime,
passwordEndTime: _endTime,
action: _action,
password: _password,
passwordIndex: passwordIndex,
cardName: _cardName,
roomName: _roomName
},
};
WXAPI.sendCommand(data3).then((res) => {
callback(res)
})
}
/*
LD下发函数
*/
/**
* *添加用户
* @param {锁ID} _deviceNum
* @param {门锁IMEI} _imei
* @param {添加的用户ID} _userTelephone
* @param {用户的keyId} _userPassword
* @param {用户的蓝牙密码password} _pwd
* @param {操作类型} _mode
* @param {操作指令} _order
* @param {锁用户有效期开始时间} _passwordStartTime
* @param {锁用户有效期结束时间} _passwordEndTime
* @param {回调} callback
*/
static LDAddUser(_deviceNum, _imei, _userTelephone, _userPassword, _pwd, _passwordStartTime, _passwordEndTime,
_mode, _order, _cardName,_roomName, callback) {
var data = {
imei: _imei,
deviceNum: _deviceNum,
userTelephone: _userTelephone,
userPassword: _userPassword,
password: _pwd,
operateMode: _mode,
order: _order,
passwordStartTime: _passwordStartTime,
passwordEndTime: _passwordEndTime,
is: false,
cardName: _cardName,
roomName:_roomName
};
WXAPI.getDeviceOperateUserInfo(data).then((res) => {
callback(res)
})
}
/**
* *删除用户
* @param {锁ID} _deviceNum
* @param {门锁IMEI} _imei
* @param {添加的用户ID} _userTelephone
* @param {用户的keyId} _userPassword
* @param {用户的蓝牙密码password} _pwd
* @param {操作类型} _mode
* @param {操作指令} _order
* @param {锁用户有效期开始时间} _passwordStartTime
* @param {锁用户有效期结束时间} _passwordEndTime
* @param {回调} callback
*/
static LDDeleteUser(_deviceNum, _imei, _userTelephone, _userPassword, _cardName,_roomName, callback) {
var data = {
imei: _imei,
deviceNum: _deviceNum,
userTelephone: _userTelephone,
userPassword: _userPassword,
password: "20210816",
passwordStartTime: "20210813010101",
passwordEndTime: "20680813010101",
operateMode: 3,
order: 6203,
is: false,
cardName: _cardName,
roomName: _roomName
};
WXAPI.getDeviceOperateUserInfo(data).then((res)=> {
callback(res)
})
}
/**
* *添加指纹
* @param {锁ID} _deviceNum
* @param {门锁IMEI} _imei
* @param {添加的用户ID} _userTelephone
* @param {用户的keyId} _userPassword
* @param {用户的蓝牙密码password} _pwd
* @param {操作类型} _mode
* @param {操作指令} _order
* @param {锁用户有效期开始时间} _passwordStartTime
* @param {锁用户有效期结束时间} _passwordEndTime
* @param {指纹数据长度length} _length
* @param {指纹fpTimeId} _fpTimeId
* @param {指纹数据fingerprint} _fingerprint
* @param {回调} callback
*/
static LDAddFingerPrints(_deviceNum, _imei, _userTelephone, _userPassword, _pwd, _passwordStartTime,
_passwordEndTime,
_mode, _order, _length, _fpTimeId, _fingerprint, _cardName, _roomName, callback) {
var data = {
imei: _imei,
deviceNum: _deviceNum,
userTelephone: _userTelephone,
userPassword: _userPassword,
password: _pwd,
operateMode: _mode,
order: _order,
fingerprintStartTime: _passwordStartTime,
fingerprintEndTime: _passwordEndTime,
length: _length,
fpTimeId: _fpTimeId,
fingerprint: _fingerprint,
is: false,
cardName: _cardName,
roomName: _roomName
};
WXAPI.fingerprintTransfer(data).then((res)=> {
callback(res)
})
}
/**
* *添加身份证
* @param {锁ID} _deviceNum
* @param {门锁IMEI} _imei
* @param {添加的用户ID} _userTelephone
* @param {用户的keyId} _userPassword
* @param {用户的蓝牙密码password} _pwd
* @param {操作类型} _mode
* @param {操作指令} _order
* @param {锁用户有效期开始时间} _passwordStartTime
* @param {锁用户有效期结束时间} _passwordEndTime
* @param {指纹数据长度length} _length
* @param {指纹fpTimeId} _fpTimeId
* @param {指纹数据fingerprint} _fingerprint
* @param {回调} callback
*/
static LDRfCardRegister(_deviceNum, _imei, _userTelephone, _userPassword, _pwd, _passwordStartTime,
_passwordEndTime,
_mode, _order, _cardName, _roomName, callback) {
var data = {
imei: _imei,
deviceNum: _deviceNum,
userTelephone: _userTelephone,
userPassword: _userPassword,
password: _pwd,
operateMode: _mode,
order: _order,
passwordStartTime: _passwordStartTime,
passwordEndTime: _passwordEndTime,
is: false,
cardName: _cardName,
roomName: _roomName
};
WXAPI.getDeviceOperateUserInfo(data).then((res) => {
callback(res)
})
}
static resetInitialization(row, callback) {
if (row.manufactureId == 201||row.manufactureId == 221) {
var data3 = {
code: "zg/deleteAllUsers",
data: {
lockerId: row.deviceNum,
imei: row.imei,
order: 6501,
},
};
WXAPI.sendCommand(data3).then((res) => {
if (res.success) {
this.$message.success("重置成功");
} else {
callback(false)
}
});
} else if (row.manufactureId == 101) {
var data2 = {
code: "isp/restoreSetting",
data: {
order: 6501,
imei: row.imei,
deviceNum: row.deviceNum,
managerTelephone: "18270949468",
managerPassword: "202108",
},
};
WXAPI.sendCommand(data2).then((res2) => {
if (res2.success) {
var str = {
deviceNum: row.deviceNum,
imei: row.imei,
order: 6101,
};
WXAPI.getDeviceRegisterManager(str).then((res1) => {
var str1 = {
imei: row.imei, //row.imsi,
deviceNum: row.deviceNum, //row.deviceNum,
operateMode: 7,
is: true,
order: 6207,
passwordStartTime: "20210813010101",
passwordEndTime: "20680813010101",
};
WXAPI.getDeviceOperateUserInfo(str1).then((res2) => {});
var str2 = {
imei: row.imei, //row.imsi,
deviceNum: row.deviceNum, //row.deviceNum,
operateMode: 4,
is: true,
order: 6204,
passwordStartTime: "20210813010101",
passwordEndTime: "20680813010101",
};
WXAPI.getDeviceOperateUserInfo(str2).then((res3) => {
if (res3.success) {
callback(true)
}
});
});
} else {
callback(false)
}
});
}
}
static getPersonCallback(person, alllist, callback) {
var personlist = []
person.map(li => {
var obj = {
person: li,
data: alllist.filter((item) => {
if (item.deviceNum && item.cardId == li.cardId) {
return item
}
})
}
personlist.push(obj)
})
callback(personlist)
}
}