|
@@ -7,7 +7,6 @@ import com.xy.collections.list.JArrayList;
|
|
|
import com.xy.collections.list.JList;
|
|
|
import com.xy.entity.MqttCommand;
|
|
|
import com.xy.entity.SysDictRedis;
|
|
|
-import com.xy.mapper.MqttCommandMapper;
|
|
|
import com.xy.service.MqttServiceImpl;
|
|
|
import com.xy.sys.EnumDataClearSize;
|
|
|
import com.xy.utils.DataTime;
|
|
@@ -31,8 +30,6 @@ public class MqttCommandJob {
|
|
|
|
|
|
private MqttServiceImpl mqttService;
|
|
|
|
|
|
- private MqttCommandMapper mqttCommandMapper;
|
|
|
-
|
|
|
/**
|
|
|
* 指令数据清除
|
|
|
*
|
|
@@ -42,18 +39,20 @@ public class MqttCommandJob {
|
|
|
public ReturnT<String> commandClean() {
|
|
|
//指令保留的天数
|
|
|
SysDictRedis sysDictRedis = SysDictUtils.get(EnumDataClearSize.Code.CODE.getCode(), EnumDataClearSize.MQTT_COMMAND_DAY.getCode());
|
|
|
- Integer jobParam = JobUtils.getPrams().gtInt();
|
|
|
- Integer saveDay = jobParam != null ? jobParam
|
|
|
- : sysDictRedis != null ? Integer.valueOf(sysDictRedis.getValue())
|
|
|
- : 30;
|
|
|
+ Integer saveDay = Integer.valueOf(sysDictRedis.getValue());
|
|
|
+ String beginTime = DataTime.getStringAround(0, 0, (~(saveDay - 1)), 0, 0, 0);
|
|
|
+ mqttCommand(beginTime);
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void mqttCommand(String beginTime) {
|
|
|
LambdaQueryWrapper<MqttCommand> lambdaQueryWrapper = new LambdaQueryWrapper<MqttCommand>()
|
|
|
- .le(MqttCommand::getSendTime, DataTime.getStringAround(0, 0, (~(saveDay - 1)), 0, 0, 0))
|
|
|
+ .le(MqttCommand::getSendTime, beginTime)
|
|
|
.last("limit 10000");
|
|
|
- Integer count = mqttCommandMapper.delete(lambdaQueryWrapper);
|
|
|
- if (count > 0) {
|
|
|
- log.info("已清除指令数据:{}条", count);
|
|
|
+ boolean remove = mqttService.remove(lambdaQueryWrapper);
|
|
|
+ if (remove) {
|
|
|
+ mqttCommand(beginTime);
|
|
|
}
|
|
|
- return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -72,7 +71,7 @@ public class MqttCommandJob {
|
|
|
LambdaQueryWrapper<MqttCommand> lambdaQueryWrapper = new LambdaQueryWrapper<MqttCommand>()
|
|
|
.in(MqttCommand::getStatus, Arrays.asList(MqttCommandStatusEnum.COMMAND_SEND.getKey()))
|
|
|
.le(MqttCommand::getSendTime, DataTime.getStringAround(0, 0, 0, 0, threshold, 0));
|
|
|
- List<MqttCommand> mqttCommands = mqttCommandMapper.selectList(lambdaQueryWrapper);
|
|
|
+ List<MqttCommand> mqttCommands = mqttService.list(lambdaQueryWrapper);
|
|
|
if (mqttCommands.size() == 0) {
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|