|
@@ -5,18 +5,23 @@ import cn.hutool.core.date.DateUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
|
+import com.xy.annotate.RestMappingController;
|
|
import com.xy.collections.list.JArrayList;
|
|
import com.xy.collections.list.JArrayList;
|
|
|
|
+import com.xy.collections.list.JList;
|
|
import com.xy.collections.map.JMap;
|
|
import com.xy.collections.map.JMap;
|
|
import com.xy.dto.MercAccountDto;
|
|
import com.xy.dto.MercAccountDto;
|
|
|
|
+import com.xy.dto.MercArrearageConfigDto;
|
|
|
|
+import com.xy.dto.MercBalanceArrearageDto;
|
|
import com.xy.entity.DeviceAlgorithmCharging;
|
|
import com.xy.entity.DeviceAlgorithmCharging;
|
|
import com.xy.entity.DeviceInfo;
|
|
import com.xy.entity.DeviceInfo;
|
|
-import com.xy.service.DeviceAlgorithmChargingServiceImpl;
|
|
|
|
-import com.xy.service.DeviceInfoServiceImpl;
|
|
|
|
-import com.xy.service.MercAccountService;
|
|
|
|
|
|
+import com.xy.service.*;
|
|
|
|
+import com.xy.sys.EnumMercCostMsgConfig;
|
|
import com.xy.utils.Emptys;
|
|
import com.xy.utils.Emptys;
|
|
|
|
+import com.xy.utils.SysDictUtils;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -29,32 +34,59 @@ import java.util.List;
|
|
@Slf4j
|
|
@Slf4j
|
|
@Component
|
|
@Component
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
|
+@RestMappingController("test")
|
|
public class DeviceAlgorithmChargingJob {
|
|
public class DeviceAlgorithmChargingJob {
|
|
|
|
|
|
private MercAccountService mercAccountService;
|
|
private MercAccountService mercAccountService;
|
|
|
|
|
|
|
|
+ private MercBalanceArrearageService mercBalanceArrearageService;
|
|
|
|
+
|
|
private DeviceInfoServiceImpl deviceInfoService;
|
|
private DeviceInfoServiceImpl deviceInfoService;
|
|
|
|
|
|
private DeviceAlgorithmChargingServiceImpl deviceAlgorithmChargingService;
|
|
private DeviceAlgorithmChargingServiceImpl deviceAlgorithmChargingService;
|
|
|
|
|
|
|
|
+ private MercArrearageConfigService mercArrearageConfigService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 算法费设备停机
|
|
* 算法费设备停机
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
|
|
+ @GetMapping("test")
|
|
@XxlJob("deviceAlgorithmChargingHalt")
|
|
@XxlJob("deviceAlgorithmChargingHalt")
|
|
public ReturnT<String> deviceAlgorithmChargingHalt() {
|
|
public ReturnT<String> deviceAlgorithmChargingHalt() {
|
|
//查询余额<=0商户
|
|
//查询余额<=0商户
|
|
- List<MercAccountDto.Vo> mercAccounts = mercAccountService.list(new MercAccountDto.SelectList().setEndBalance(0)).getData();
|
|
|
|
- if (!Emptys.check(mercAccounts)) {
|
|
|
|
|
|
+ List<MercAccountDto.Vo> list = mercAccountService.list(new MercAccountDto.SelectList().setEndBalance(0)).getData();
|
|
|
|
+ if (!Emptys.check(list)) {
|
|
return ReturnT.SUCCESS;
|
|
return ReturnT.SUCCESS;
|
|
}
|
|
}
|
|
- mercAccounts.forEach(mercAccount -> {
|
|
|
|
- List<DeviceInfo> updateDeviceInfos = new ArrayList<>();
|
|
|
|
|
|
+ JList<MercAccountDto.Vo> mercAccounts = new JArrayList<>(list);
|
|
|
|
+ //查询商户欠费天数
|
|
|
|
+ int day = SysDictUtils.getValue(EnumMercCostMsgConfig.Code.CODE.getCode(), EnumMercCostMsgConfig.ARREARAGE_DAY.getCode(), Integer.class);
|
|
|
|
+ List<MercBalanceArrearageDto.Vo> mercBalanceArrearages = mercBalanceArrearageService.list(new MercBalanceArrearageDto.SelectList()
|
|
|
|
+ .setMercId(mercAccounts.getProperty(MercAccountDto.Vo::getMercId))
|
|
|
|
+ .setBeginArrearageDay(day)
|
|
|
|
+ ).getData();
|
|
|
|
+ if (!Emptys.check(mercBalanceArrearages)) {
|
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ //查询白名单
|
|
|
|
+ MercArrearageConfigDto.SelectList selectList = new MercArrearageConfigDto.SelectList();
|
|
|
|
+ selectList.setType(2);
|
|
|
|
+ List<MercArrearageConfigDto.Vo> data = mercArrearageConfigService.list(selectList).getData();
|
|
|
|
+ JMap<Long, MercArrearageConfigDto.Vo> mercArrearageConfigJMaps = new JArrayList<>(data).toMap(MercArrearageConfigDto.Vo::getMercId).cover();
|
|
|
|
+ mercBalanceArrearages.forEach(mercBalanceArrearage -> {
|
|
|
|
+ //验证白名单
|
|
|
|
+ MercArrearageConfigDto.Vo mercArrearageConfig = mercArrearageConfigJMaps.get(mercBalanceArrearage.getMercId());
|
|
|
|
+ if (Emptys.check(mercArrearageConfig)) {
|
|
|
|
+ if (mercBalanceArrearage.getArrearageDay() < mercArrearageConfig.getArrearageDay()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//查询商户未冻结设备
|
|
//查询商户未冻结设备
|
|
List<DeviceInfo> deviceInfos = deviceInfoService.list(new LambdaQueryWrapper<DeviceInfo>()
|
|
List<DeviceInfo> deviceInfos = deviceInfoService.list(new LambdaQueryWrapper<DeviceInfo>()
|
|
.in(DeviceInfo::getDeviceType, Arrays.asList(1, 2))
|
|
.in(DeviceInfo::getDeviceType, Arrays.asList(1, 2))
|
|
- .eq(DeviceInfo::getMercId, mercAccount.getMercId())
|
|
|
|
|
|
+ .eq(DeviceInfo::getMercId, mercBalanceArrearage.getMercId())
|
|
.eq(DeviceInfo::getActiveState, 1)
|
|
.eq(DeviceInfo::getActiveState, 1)
|
|
.eq(DeviceInfo::getFreezeStatus, 1)
|
|
.eq(DeviceInfo::getFreezeStatus, 1)
|
|
);
|
|
);
|
|
@@ -66,7 +98,7 @@ public class DeviceAlgorithmChargingJob {
|
|
String algorithmDate = DateUtil.format(DateUtil.date(), DatePattern.PURE_DATE_PATTERN);
|
|
String algorithmDate = DateUtil.format(DateUtil.date(), DatePattern.PURE_DATE_PATTERN);
|
|
LambdaQueryWrapper<DeviceAlgorithmCharging> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceAlgorithmCharging>()
|
|
LambdaQueryWrapper<DeviceAlgorithmCharging> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceAlgorithmCharging>()
|
|
.select(DeviceAlgorithmCharging::getDeviceId)
|
|
.select(DeviceAlgorithmCharging::getDeviceId)
|
|
- .eq(DeviceAlgorithmCharging::getMercId, mercAccount.getMercId())
|
|
|
|
|
|
+ .eq(DeviceAlgorithmCharging::getMercId, mercBalanceArrearage.getMercId())
|
|
.gt(DeviceAlgorithmCharging::getUnusedSize, 0)
|
|
.gt(DeviceAlgorithmCharging::getUnusedSize, 0)
|
|
.in(DeviceAlgorithmCharging::getDeviceId, deviceInfosJMaps.getKeys())
|
|
.in(DeviceAlgorithmCharging::getDeviceId, deviceInfosJMaps.getKeys())
|
|
.and(deviceAlgorithmChargingLambdaQueryWrapper -> deviceAlgorithmChargingLambdaQueryWrapper
|
|
.and(deviceAlgorithmChargingLambdaQueryWrapper -> deviceAlgorithmChargingLambdaQueryWrapper
|
|
@@ -80,6 +112,7 @@ public class DeviceAlgorithmChargingJob {
|
|
List<DeviceAlgorithmCharging> deviceAlgorithmChargings = deviceAlgorithmChargingService.list(lambdaQueryWrapper);
|
|
List<DeviceAlgorithmCharging> deviceAlgorithmChargings = deviceAlgorithmChargingService.list(lambdaQueryWrapper);
|
|
JMap<Long, DeviceAlgorithmCharging> deviceAlgorithmChargingsJMaps = new JArrayList<>(deviceAlgorithmChargings).toMap(DeviceAlgorithmCharging::getDeviceId).cover();
|
|
JMap<Long, DeviceAlgorithmCharging> deviceAlgorithmChargingsJMaps = new JArrayList<>(deviceAlgorithmChargings).toMap(DeviceAlgorithmCharging::getDeviceId).cover();
|
|
//判断是否过期
|
|
//判断是否过期
|
|
|
|
+ List<DeviceInfo> updateDeviceInfos = new ArrayList<>();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
deviceInfosJMaps.forEach((deviceId, deviceInfo) -> {
|
|
deviceInfosJMaps.forEach((deviceId, deviceInfo) -> {
|
|
if (deviceAlgorithmChargingsJMaps.containsKey(deviceId)) {
|
|
if (deviceAlgorithmChargingsJMaps.containsKey(deviceId)) {
|