|
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xy.annotate.Runners;
|
|
|
import com.xy.annotate.Timer;
|
|
|
+import com.xy.collections.map.JHashMap;
|
|
|
+import com.xy.collections.map.JMap;
|
|
|
import com.xy.dto.AckMqttDto;
|
|
|
import com.xy.dto.CommandMqtt;
|
|
|
import com.xy.dto.MqttDto;
|
|
@@ -172,7 +174,17 @@ public class MqttServiceImpl extends ServiceImpl<MqttCommandMapper, MqttCommand>
|
|
|
String result = ackMqttDto.getResult().toString();
|
|
|
if (Emptys.check(ackMqttDto.getResult())) {
|
|
|
String key = String.format(keyStr, ackMqttDto.getSn());
|
|
|
- redisService.set(key, result, 300);
|
|
|
+ String backClientTime = DataTime.toString(ackMqttDto.getBackClientTime());
|
|
|
+ Map<String, String> map = redisService.getMap(key);
|
|
|
+ if (Emptys.check(map)) {
|
|
|
+ String time = map.get("time");
|
|
|
+ if (DataTime.stringContrast(time, backClientTime) < 0) {
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JMap<String, String> jmap = new JHashMap<String, String>().set("time", backClientTime).set("result", result);
|
|
|
+ redisService.setMap(key, jmap);
|
|
|
+ redisService.timeout(key, 300);
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -188,8 +200,12 @@ public class MqttServiceImpl extends ServiceImpl<MqttCommandMapper, MqttCommand>
|
|
|
public R<MqttDto.Vo3> snByCmdAndResult(@RequestBody MqttDto.SnByCmdAndResult snByCmdAndResult) {
|
|
|
MqttCommand mqttCommand = getById(snByCmdAndResult.getSn());
|
|
|
String key = String.format(keyStr, snByCmdAndResult.getSn());
|
|
|
- String result = redisService.get(key);
|
|
|
- MqttDto.Vo3 vo3 = copy(MqttDto.Vo3.class, mqttCommand).setResult(JSONUtil.parseObj(result));
|
|
|
+ Map<String, String> map = redisService.getMap(key);
|
|
|
+ MqttDto.Vo3 vo3 = copy(MqttDto.Vo3.class, mqttCommand);
|
|
|
+ if (Emptys.check(map)) {
|
|
|
+ String result = map.get("result");
|
|
|
+ vo3.setResult(JSONUtil.parseObj(result));
|
|
|
+ }
|
|
|
return R.ok(vo3);
|
|
|
}
|
|
|
|