|
|
|
@ -615,9 +615,8 @@ public class DeviceController {
|
|
|
|
|
if (null == device1) {
|
|
|
|
|
return CommonResult.error(400, "设备编码编码不正确,命令不能下发!");
|
|
|
|
|
}
|
|
|
|
|
Object value = redisTool.getValue("online_" + deviceCode);
|
|
|
|
|
long expire = redisTool.getKeyExpire("online_" + deviceCode, TimeUnit.SECONDS);
|
|
|
|
|
if (value == null || expire <= 0) {
|
|
|
|
|
boolean exist = redisTool.existsKey("online_" + deviceCode);
|
|
|
|
|
if (!exist) {
|
|
|
|
|
return CommonResult.error(400, "设备不在线,命令不能下发!");
|
|
|
|
|
}
|
|
|
|
|
// Object value = redisTool.getValue(deviceCode);
|
|
|
|
@ -813,7 +812,7 @@ public class DeviceController {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
String key = "weight_" + weight.getDeviceCode() + "_" + weight.getBucketCode();
|
|
|
|
|
redisTool.setValue(key, JSONUtil.toJsonStr(weight), 1000 * 60L);//一分钟过期
|
|
|
|
|
redisTool.setValue(key, JSONUtil.toJsonStr(weight), 1000L * 60 * 3);//3分钟过期
|
|
|
|
|
return CommonResult.success("success");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -821,9 +820,8 @@ public class DeviceController {
|
|
|
|
|
@PostMapping("/getWeight")
|
|
|
|
|
public CommonResult<WeightVO> getWeight(@RequestBody DeviceBucketVO deviceBucketVO) {
|
|
|
|
|
String key = "weight_" + deviceBucketVO.getDeviceCode() + "_" + deviceBucketVO.getBucketCode();
|
|
|
|
|
long expire = redisTool.getKeyExpire(key, TimeUnit.SECONDS);
|
|
|
|
|
boolean exist = redisTool.existsKey(key);
|
|
|
|
|
if (!exist || expire <= 0) {
|
|
|
|
|
if (!exist) {
|
|
|
|
|
return CommonResult.error(400, "获取实时重量失败");
|
|
|
|
|
}
|
|
|
|
|
Object value = redisTool.getValue(key);
|
|
|
|
|