Commit a7c1e71d by YG8999

定时修改设备密码

parent e936015d
......@@ -17,7 +17,8 @@ public enum MqttOpType {
PASSWORD("password", "远程下发密码"),
IDCARD("iccard", "远程下发卡片"),
CONFIG("config", "配置从设备"),
VOICE("voice", "远程语音播报")
VOICE("voice", "远程语音播报"),
LOCKRSSI("lockrssi", "设备信息上报"),
;
private String code;
private String name;
......
......@@ -150,12 +150,21 @@ public class MqttxServiceImpl implements MqttxService {
boolean isSuccess = false;
System.out.println("cespayload: "+payload);
if (topic.endsWith(MqttReportType.getTopicStr("batch_report"))) {
JSONObject json = JSONUtil.parseObj(payload);
if (json.size() > 0) {
// 网关devId
String op = json.getStr("op");
if (MqttOpType.LOCKRSSI.getCode().equals(op)) {
// 修改设备状态、电量、信号值
isSuccess = this.updateDevice(topic, payload);
} else if (MqttOpType.PASSWORD.getCode().equals(op) || MqttOpType.IDCARD.getCode().equals(op)) {
isSuccess = this.updateDeviceLog(topic, payload, 2);
}
}
} else if (topic.endsWith(MqttReportType.getTopicStr("execute_response"))) {
isSuccess = this.updateDeviceLog(topic, payload);
isSuccess = this.updateDeviceLog(topic, payload, 1);
} else if (topic.endsWith(MqttReportType.getTopicStr("property_set_response"))) {
isSuccess = this.updateDeviceLog(topic, payload);
isSuccess = this.updateDeviceLog(topic, payload, 1);
}
return isSuccess;
}
......@@ -256,11 +265,11 @@ public class MqttxServiceImpl implements MqttxService {
MqttxVo mqttxVo = null;
if (OpTypeEnum.OP_DEVICE_PASSWORD.getCode().equals(opType)) {
// 密码设置
mqttxVo = this.setOpenPasswordInit(devId,phone, MqttOpType.PASSWORD.getCode(), param, startTime, endTime,
mqttxVo = this.setOpenPasswordInit(devId, param, startTime, endTime, phone, MqttOpType.PASSWORD.getCode(),
MqttConstants.MQTT_DESCRIBE_DEVICE_PASSWORD);
} else if (OpTypeEnum.OP_DEVICE_ICCARD.getCode().equals(opType)) {
// 卡片设置
mqttxVo = this.setOpenPasswordInit(devId,phone, MqttOpType.IDCARD.getCode(), param, startTime, endTime,
mqttxVo = this.setOpenPasswordInit(devId, param, startTime, endTime, phone, MqttOpType.IDCARD.getCode(),
MqttConstants.MQTT_DESCRIBE_DEVICE_IDCARD);
}
return mqttxVo;
......@@ -336,11 +345,11 @@ public class MqttxServiceImpl implements MqttxService {
MqttxVo mqttxVo = null;
if (OpTypeEnum.OP_DEVICE_PASSWORD.getCode().equals(opType)) {
// 密码设置
mqttxVo = this.deleteOpenPasswordInit(devId,phone, MqttOpType.PASSWORD.getCode(), param, startTime, endTime,
mqttxVo = this.deleteOpenPasswordInit(devId, param, startTime, endTime, phone, MqttOpType.PASSWORD.getCode(),
MqttConstants.MQTT_DESCRIBE_DEVICE_PASSWORD);
} else if (OpTypeEnum.OP_DEVICE_ICCARD.getCode().equals(opType)) {
// 卡片设置
mqttxVo = this.deleteOpenPasswordInit(devId,phone, MqttOpType.IDCARD.getCode(), param, startTime, endTime,
mqttxVo = this.deleteOpenPasswordInit(devId, param, startTime, endTime, phone, MqttOpType.IDCARD.getCode(),
MqttConstants.MQTT_DESCRIBE_DEVICE_IDCARD);
}
return mqttxVo;
......@@ -662,17 +671,18 @@ public class MqttxServiceImpl implements MqttxService {
/**
* 存储返回mqtt信息
* @param topic
* @param payload
* @param topic 消息主题
* @param payload 回复消息内容
* @param resultCode 返回消息状态位置
* @return
*/
private boolean updateDeviceLog(String topic, String payload) {
private boolean updateDeviceLog(String topic, String payload, Integer resultCode) {
JSONObject json = JSONUtil.parseObj(payload);
if (json.size() > 0) {
JSONArray array = json.getJSONArray("params");
if (array != null && array.size() > 0) {
String seq = json.getStr("seq");
String result = array.getStr(1);
String result = array.getStr(resultCode);
DeviceLog deviceLog = deviceLogMapper.selectDeviceLogOneBySeqMax(seq);
// 状态10代表网关接到消息响应,不做处理;另外还会有一条操作结果响应数据
if (deviceLog != null && !"10".equals(result)) {
......
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