Эх сурвалжийг харах

增加欠费消息卡包判断

李进 1 жил өмнө
parent
commit
dc3e7797f4

+ 12 - 20
device-api-service/src/main/java/com/xy/job/DeviceAlgorithmChargingJob.java

@@ -10,10 +10,12 @@ import com.xy.collections.list.JList;
 import com.xy.collections.map.JMap;
 import com.xy.dto.MercAccountDto;
 import com.xy.dto.MercArrearageConfigDto;
-import com.xy.dto.MercBalanceArrearageDto;
 import com.xy.entity.DeviceAlgorithmCharging;
 import com.xy.entity.DeviceInfo;
-import com.xy.service.*;
+import com.xy.service.DeviceAlgorithmChargingServiceImpl;
+import com.xy.service.DeviceInfoServiceImpl;
+import com.xy.service.MercAccountService;
+import com.xy.service.MercArrearageConfigService;
 import com.xy.sys.EnumMercCostMsgConfig;
 import com.xy.utils.Emptys;
 import com.xy.utils.SysDictUtils;
@@ -36,18 +38,12 @@ public class DeviceAlgorithmChargingJob {
 
     private MercAccountService mercAccountService;
 
-    private MercBalanceArrearageService mercBalanceArrearageService;
-
     private DeviceInfoServiceImpl deviceInfoService;
 
     private DeviceAlgorithmChargingServiceImpl deviceAlgorithmChargingService;
 
     private MercArrearageConfigService mercArrearageConfigService;
 
-    public static void main(String[] args) {
-
-    }
-
     /**
      * 算法费设备停机
      *
@@ -60,14 +56,10 @@ public class DeviceAlgorithmChargingJob {
         if (!Emptys.check(list)) {
             return ReturnT.SUCCESS;
         }
-        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)) {
+        JList<MercAccountDto.Vo> mercAccounts = new JArrayList<>(list).filter().ge(MercAccountDto.Vo::getArrearageDay, day).list();
+        if (!Emptys.check(mercAccounts)) {
             return ReturnT.SUCCESS;
         }
         //查询白名单
@@ -75,18 +67,18 @@ public class DeviceAlgorithmChargingJob {
         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 -> {
+        mercAccounts.forEach(vo -> {
             //验证白名单
-            MercArrearageConfigDto.Vo mercArrearageConfig = mercArrearageConfigJMaps.get(mercBalanceArrearage.getMercId());
+            MercArrearageConfigDto.Vo mercArrearageConfig = mercArrearageConfigJMaps.get(vo.getMercId());
             if (Emptys.check(mercArrearageConfig)) {
-                if (mercBalanceArrearage.getArrearageDay() < mercArrearageConfig.getArrearageDay()) {
+                if (vo.getArrearageDay() < mercArrearageConfig.getArrearageDay()) {
                     return;
                 }
             }
             //查询商户未冻结设备
             List<DeviceInfo> deviceInfos = deviceInfoService.list(new LambdaQueryWrapper<DeviceInfo>()
                     .in(DeviceInfo::getDeviceType, Arrays.asList(1, 2))
-                    .eq(DeviceInfo::getMercId, mercBalanceArrearage.getMercId())
+                    .eq(DeviceInfo::getMercId, vo.getMercId())
                     .eq(DeviceInfo::getActiveState, 1)
                     .eq(DeviceInfo::getFreezeStatus, 1)
             );
@@ -98,7 +90,7 @@ public class DeviceAlgorithmChargingJob {
             String algorithmDate = DateUtil.format(DateUtil.date(), DatePattern.PURE_DATE_PATTERN);
             LambdaQueryWrapper<DeviceAlgorithmCharging> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceAlgorithmCharging>()
                     .select(DeviceAlgorithmCharging::getDeviceId)
-                    .eq(DeviceAlgorithmCharging::getMercId, mercBalanceArrearage.getMercId())
+                    .eq(DeviceAlgorithmCharging::getMercId, vo.getMercId())
                     .gt(DeviceAlgorithmCharging::getUnusedSize, 0)
                     .in(DeviceAlgorithmCharging::getDeviceId, deviceInfosJMaps.getKeys())
                     .and(deviceAlgorithmChargingLambdaQueryWrapper -> deviceAlgorithmChargingLambdaQueryWrapper

+ 18 - 0
device-api-service/src/main/java/com/xy/service/DeviceAlgorithmChargingServiceImpl.java

@@ -65,6 +65,24 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
 
     private MercDeviceAlgorithmChargingService mercDeviceAlgorithmChargingService;
 
+    @Override
+    @ApiOperation("有效条数统计")
+    public R<Integer> validCount(@RequestBody @Validated DeviceAlgorithmChargingDto.ValidCount validCount) {
+        Integer time = Integer.valueOf(DataTime.getSring("yyyyMMdd"));
+        LambdaQueryWrapper<DeviceAlgorithmCharging> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceAlgorithmCharging>()
+                .select(DeviceAlgorithmCharging::getDeviceId)
+                .eq(DeviceAlgorithmCharging::getMercId, validCount.getMercId())
+                .gt(DeviceAlgorithmCharging::getUnusedSize, 0)
+                .le(DeviceAlgorithmCharging::getBeginTime, time)
+                .and(deviceAlgorithmChargingLambdaQueryWrapper -> deviceAlgorithmChargingLambdaQueryWrapper
+                        .eq(DeviceAlgorithmCharging::getTimeout, -1)
+                        .or()
+                        .ge(DeviceAlgorithmCharging::getTimeout, time)
+                ).groupBy(DeviceAlgorithmCharging::getDeviceId);
+        List<DeviceAlgorithmCharging> deviceAlgorithmChargings = list(lambdaQueryWrapper);
+        return R.ok(deviceAlgorithmChargings.size());
+    }
+
     @PostMapping("count")
     @ApiOperation("查询条数")
     public R<List<DeviceAlgorithmChargingDto.CountVo>> count(@RequestBody @Validated DeviceAlgorithmChargingDto.Count count) {

+ 1 - 1
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -570,7 +570,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
     public R<Integer> activationCount(DeviceInfoDto.ActivationCount activationCount) {
         LambdaQueryWrapper<DeviceInfo> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceInfo>()
                 .eq(DeviceInfo::getMercId, activationCount.getMercId())
-                .between(DeviceInfo::getActiveTime, activationCount.getBeginTime(), activationCount.getEndTime());
+                .between(Emptys.check(activationCount.getBeginTime()), DeviceInfo::getActiveTime, activationCount.getBeginTime(), activationCount.getEndTime());
         long count = count(lambdaQueryWrapper);
         return R.ok((int) count);
     }

+ 10 - 0
device-api/src/main/java/com/xy/dto/DeviceAlgorithmChargingDto.java

@@ -22,6 +22,16 @@ import java.util.List;
  */
 public class DeviceAlgorithmChargingDto {
 
+    @Data
+    @Accessors(chain = true)
+    public static class ValidCount {
+
+        @NotNull(message = "mercId不能为空")
+        @ApiModelProperty(value = "商户ID")
+        private Long mercId;
+
+    }
+
     @Data
     @Accessors(chain = true)
     public static class Count {

+ 9 - 0
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -38,6 +38,15 @@ public class DeviceInfoDto {
      */
     public final static String CLEAR = "clear";
 
+    @Data
+    @Accessors(chain = true)
+    public static class Count {
+
+        @NotNull(message = "mercId不能为空")
+        @ApiModelProperty(value = "商户ID", required = true)
+        private Long mercId;
+    }
+
 
     @Data
     @Accessors(chain = true)

+ 9 - 0
device-api/src/main/java/com/xy/service/DeviceAlgorithmChargingService.java

@@ -47,4 +47,13 @@ public interface DeviceAlgorithmChargingService {
      */
     @PostMapping("charging")
     R<Map<Long, Integer>> charging(@RequestBody List<DeviceAlgorithmChargingDto.Charging> chargings);
+
+    /**
+     * 有效条数统计
+     *
+     * @param validCount
+     * @return
+     */
+    @PostMapping("validCount")
+    R<Integer> validCount(@RequestBody @Validated DeviceAlgorithmChargingDto.ValidCount validCount);
 }