Commit fa0bfc30 by YG8999

设备锁添加密码、删除密码操作接口

parent f7135dbd
...@@ -5,13 +5,14 @@ public enum OpTypeEnum { ...@@ -5,13 +5,14 @@ public enum OpTypeEnum {
OPEN_DOOR("10", "开门"), OPEN_DOOR("10", "开门"),
GET_ELECTRIC("20", "取电"), GET_ELECTRIC("20", "取电"),
LOCK_DOOR("30", "锁门"), LOCK_DOOR("30", "锁门"),
CUT_ELECTRIC("40", "断电"); CUT_ELECTRIC("40", "断电"),
OP_DEVICE_PASSWORD("10", "密码"),
OP_DEVICE_ICCARD("20", "卡片"),
OP_DEVICE_LEARN("30", "指纹")
;
private String code; private String code;
private String name; private String name;
OpTypeEnum() {
}
OpTypeEnum(String code, String name) { OpTypeEnum(String code, String name) {
this.code = code; this.code = code;
this.name = name; this.name = name;
......
...@@ -76,4 +76,26 @@ public interface DeviceOpService { ...@@ -76,4 +76,26 @@ public interface DeviceOpService {
*/ */
void openOrCloseDevice(Long roomId, String phone, String opType, boolean isAsync, long m); void openOrCloseDevice(Long roomId, String phone, String opType, boolean isAsync, long m);
/**
* 远程设置密码/卡片
* @param roomId 房间id
* @param param 设置参数:密码、卡号、指纹
* @param startTime 生效时间:2020-04-06 10:00:00(格式)
* @param endTime 失效时间:2020-04-06 12:00:00(格式)
* @param phone 操作用户
* @param opType 操作类型:10:密码,20:卡片,30:指纹
* @return
*/
void setDevicePassword(Long roomId, String param, String startTime, String endTime, String phone, String opType);
/**
* 远程删除密码/卡片
* @param roomId 房间id
* @param param 设置参数:密码、卡号、指纹
* @param phone 操作用户
* @param opType 操作类型:10:密码,20:卡片,30:指纹
* @return
*/
void deleteDevicePassword(Long roomId, String param, String phone, String opType);
} }
...@@ -276,5 +276,62 @@ public class DeviceOpServiceImpl implements DeviceOpService { ...@@ -276,5 +276,62 @@ public class DeviceOpServiceImpl implements DeviceOpService {
} }
} }
/**
* 远程设置密码/卡片
* @param roomId 房间id
* @param param 设置参数:密码、卡号、指纹
* @param startTime 生效时间:2020-04-06 10:00:00(格式)
* @param endTime 失效时间:2020-04-06 12:00:00(格式)
* @param phone 操作用户
* @param opType 操作类型:10:密码,20:卡片,30:指纹
* @return
*/
@Override
public void setDevicePassword(Long roomId, String param, String startTime, String endTime,
String phone, String opType) {
SRoom room = roomMapper.selectSRoomById(roomId);
if (room != null) {
Device queryParams = new Device();
queryParams.setRoomId(room.getId());
queryParams.setDevType(DeviceType.DEVICE_CCEE.getCode());
List<Device> list = deviceMapper.selectDeviceList(queryParams);
list.stream().forEach(device -> {
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.setOpenPassword(device.getDevId(), param, startTime, endTime, phone, opType);
// 发送mqtt消息
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
deviceLogService.addDeviceLog(mqttxVo, phone);
});
}
}
/**
* 远程删除密码/卡片
* @param roomId 房间id
* @param param 设置参数:密码、卡号、指纹
* @param phone 操作用户
* @param opType 操作类型:10:密码,20:卡片,30:指纹
* @return
*/
@Override
public void deleteDevicePassword(Long roomId, String param, String phone, String opType) {
SRoom room = roomMapper.selectSRoomById(roomId);
if (room != null) {
Device queryParams = new Device();
queryParams.setRoomId(room.getId());
queryParams.setDevType(DeviceType.DEVICE_CCEE.getCode());
List<Device> list = deviceMapper.selectDeviceList(queryParams);
list.stream().forEach(device -> {
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.deleteOpenPassword(device.getDevId(), param, null, null, phone, opType);
// 发送mqtt消息
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
deviceLogService.addDeviceLog(mqttxVo, phone);
});
}
}
} }
...@@ -240,19 +240,14 @@ public class MqttxServiceImpl implements MqttxService { ...@@ -240,19 +240,14 @@ public class MqttxServiceImpl implements MqttxService {
public MqttxVo setOpenPassword(String devId, String param, String startTime, String endTime, public MqttxVo setOpenPassword(String devId, String param, String startTime, String endTime,
String phone, String opType) { String phone, String opType) {
MqttxVo mqttxVo = null; MqttxVo mqttxVo = null;
switch (opType) { if (OpTypeEnum.OP_DEVICE_PASSWORD.getCode().equals(opType)) {
case "10":
// 密码设置 // 密码设置
mqttxVo = this.setOpenPasswordInit(devId,phone, MqttOpType.PASSWORD.getCode(), param, startTime, endTime, mqttxVo = this.setOpenPasswordInit(devId,phone, MqttOpType.PASSWORD.getCode(), param, startTime, endTime,
MqttConstants.MQTT_DESCRIBE_DEVICE_PASSWORD); MqttConstants.MQTT_DESCRIBE_DEVICE_PASSWORD);
break; } else if (OpTypeEnum.OP_DEVICE_ICCARD.getCode().equals(opType)) {
case "20":
// 卡片设置 // 卡片设置
mqttxVo = this.setOpenPasswordInit(devId,phone, MqttOpType.IDCARD.getCode(), param, startTime, endTime, mqttxVo = this.setOpenPasswordInit(devId,phone, MqttOpType.IDCARD.getCode(), param, startTime, endTime,
MqttConstants.MQTT_DESCRIBE_DEVICE_IDCARD); MqttConstants.MQTT_DESCRIBE_DEVICE_IDCARD);
break;
default:
break;
} }
return mqttxVo; return mqttxVo;
} }
...@@ -325,19 +320,14 @@ public class MqttxServiceImpl implements MqttxService { ...@@ -325,19 +320,14 @@ public class MqttxServiceImpl implements MqttxService {
public MqttxVo deleteOpenPassword(String devId, String param, String startTime, String endTime, public MqttxVo deleteOpenPassword(String devId, String param, String startTime, String endTime,
String phone, String opType) { String phone, String opType) {
MqttxVo mqttxVo = null; MqttxVo mqttxVo = null;
switch (opType) { if (OpTypeEnum.OP_DEVICE_PASSWORD.getCode().equals(opType)) {
case "10":
// 密码设置 // 密码设置
mqttxVo = this.deleteOpenPasswordInit(devId,phone, MqttOpType.PASSWORD.getCode(), param, startTime, endTime, mqttxVo = this.deleteOpenPasswordInit(devId,phone, MqttOpType.PASSWORD.getCode(), param, startTime, endTime,
MqttConstants.MQTT_DESCRIBE_DEVICE_PASSWORD); MqttConstants.MQTT_DESCRIBE_DEVICE_PASSWORD);
break; } else if (OpTypeEnum.OP_DEVICE_ICCARD.getCode().equals(opType)) {
case "20":
// 卡片设置 // 卡片设置
mqttxVo = this.deleteOpenPasswordInit(devId,phone, MqttOpType.IDCARD.getCode(), param, startTime, endTime, mqttxVo = this.deleteOpenPasswordInit(devId,phone, MqttOpType.IDCARD.getCode(), param, startTime, endTime,
MqttConstants.MQTT_DESCRIBE_DEVICE_IDCARD); MqttConstants.MQTT_DESCRIBE_DEVICE_IDCARD);
break;
default:
break;
} }
return mqttxVo; return mqttxVo;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment