|
@@ -1,14 +1,19 @@
|
|
|
package com.xy.job;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import com.xy.collections.list.JArrayList;
|
|
|
import com.xy.collections.map.JHashMap;
|
|
|
import com.xy.collections.map.JMap;
|
|
|
import com.xy.dto.MercMsgInfoDto;
|
|
|
+import com.xy.entity.DeviceCharging;
|
|
|
+import com.xy.entity.DeviceInfo;
|
|
|
import com.xy.entity.SysDictRedis;
|
|
|
import com.xy.mapper.DeviceChargingMapper;
|
|
|
+import com.xy.service.DeviceInfoServiceImpl;
|
|
|
import com.xy.service.MercMsgInfoService;
|
|
|
import com.xy.sys.EnumMercCostMsgConfig;
|
|
|
import com.xy.utils.*;
|
|
@@ -31,6 +36,49 @@ public class DeviceChargingJob {
|
|
|
|
|
|
private MercMsgInfoService mercMsgInfoService;
|
|
|
|
|
|
+ private DeviceInfoServiceImpl deviceInfoService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 管理费设备停机
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @XxlJob("deviceChargingHalt")
|
|
|
+ public ReturnT<String> deviceChargingHalt() {
|
|
|
+ Map<String, SysDictRedis> stringSysDictRedisMap = SysDictUtils.get(EnumMercCostMsgConfig.Code.CODE.getCode());
|
|
|
+ int day = Integer.valueOf(stringSysDictRedisMap.get(EnumMercCostMsgConfig.ARREARAGE_DAY.getCode()).getValue());
|
|
|
+ String timeout = DataTime.getStringAround(0, 0, (~(day - 1)), 0, 0, 0);
|
|
|
+ LambdaQueryWrapper<DeviceCharging> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceCharging>()
|
|
|
+ .le(DeviceCharging::getTimeout, timeout);
|
|
|
+ RecursionUtils.recursion(current -> {
|
|
|
+ //查询已过期设备管理费
|
|
|
+ IPage<DeviceCharging> iPage = deviceChargingMapper.selectPage(Page.of(current, 200), lambdaQueryWrapper);
|
|
|
+ List<DeviceCharging> records = iPage.getRecords();
|
|
|
+ if (!Emptys.check(records)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //查询未冻结or未停运设备
|
|
|
+ LambdaQueryWrapper<DeviceInfo> deviceInfoLambdaQueryWrapper = new LambdaQueryWrapper<DeviceInfo>()
|
|
|
+ .in(DeviceInfo::getDeviceId, new JArrayList<>(records).getProperty(DeviceCharging::getDeviceId))
|
|
|
+ .and(deviceInfoLambdaQueryWrappers -> deviceInfoLambdaQueryWrappers
|
|
|
+ .eq(DeviceInfo::getFreezeStatus, 1)
|
|
|
+ .or()
|
|
|
+ .eq(DeviceInfo::getBusyState, 1)
|
|
|
+ );
|
|
|
+ List<DeviceInfo> deviceInfos = deviceInfoService.list(deviceInfoLambdaQueryWrapper);
|
|
|
+ //冻结and停运设备
|
|
|
+ if (Emptys.check(deviceInfos)) {
|
|
|
+ deviceInfos.forEach(deviceInfo -> deviceInfo
|
|
|
+ .setFreezeStatus(2)
|
|
|
+ .setBusyState(2)
|
|
|
+ );
|
|
|
+ deviceInfoService.updateBatchById(deviceInfos);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设备管理费过期消息
|
|
|
*
|