|
@@ -1,59 +0,0 @@
|
|
|
-package com.xy.job;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.xxl.job.core.biz.model.ReturnT;
|
|
|
-import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
-import com.xy.entity.DeviceAlgorithmCharging;
|
|
|
-import com.xy.service.DeviceAlgorithmChargingServiceImpl;
|
|
|
-import com.xy.utils.DataTime;
|
|
|
-import com.xy.utils.Emptys;
|
|
|
-import com.xy.utils.PageBean;
|
|
|
-import com.xy.utils.PlusBeans;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * 设备算法计费job
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Component
|
|
|
-@AllArgsConstructor
|
|
|
-public class DeviceAlgorithmChargingJob {
|
|
|
-
|
|
|
- private DeviceAlgorithmChargingServiceImpl deviceAlgorithmChargingService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 扣除设备算法计费过期时间
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @XxlJob("deviceAlgorithmChargingTimeout")
|
|
|
- public ReturnT<String> deviceAlgorithmChargingTimeout() {
|
|
|
- deviceAlgorithmCharging(1, 50, Integer.valueOf(DataTime.getSring("yyyyMM")));
|
|
|
- return ReturnT.SUCCESS;
|
|
|
- }
|
|
|
-
|
|
|
- public void deviceAlgorithmCharging(int current, int size, Integer beginTime) {
|
|
|
- log.info("扣除设备算法计费过期时间开始第{}页", current);
|
|
|
- LambdaQueryWrapper<DeviceAlgorithmCharging> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceAlgorithmCharging>()
|
|
|
- .gt(DeviceAlgorithmCharging::getTimeout, 0)
|
|
|
- .le(DeviceAlgorithmCharging::getBeginTime, beginTime);
|
|
|
- IPage<DeviceAlgorithmCharging> iPage = deviceAlgorithmChargingService.page(PlusBeans.toIPage(new PageBean().setCurrent(current).setSize(size)), lambdaQueryWrapper);
|
|
|
- List<DeviceAlgorithmCharging> records = iPage.getRecords();
|
|
|
- if (!Emptys.check(records)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- records.forEach(deviceAlgorithmCharging -> deviceAlgorithmCharging.setTimeout(deviceAlgorithmCharging.getTimeout() - 1));
|
|
|
- deviceAlgorithmChargingService.updateBatchById(records);
|
|
|
- //判断是否继续下一页
|
|
|
- if (iPage.getPages() <= current) {
|
|
|
- return;
|
|
|
- } else {
|
|
|
- deviceAlgorithmCharging(current + 1, size, beginTime);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|