Sfoglia il codice sorgente

Merge branch 'master' into test

李进 1 anno fa
parent
commit
91f2e8d6cc

+ 31 - 72
device-api-service/src/main/java/com/xy/job/DeviceChargingJob.java

@@ -91,6 +91,31 @@ public class DeviceChargingJob {
         Map<String, SysDictRedis> stringSysDictRedisMap = SysDictUtils.get(EnumMercCostMsgConfig.Code.CODE.getCode());
         String tel = stringSysDictRedisMap.get(EnumMercCostMsgConfig.CUSTOM_TEL.getCode()).getValue();
         String mmiTime = DataTime.getStringAround(0, -1, 0, 0, 0, 0, now);
+        //数据逻辑
+        FunctionUtils.ParamsResult<Tuple.Tuple4<Integer, JMap<String, Object>, JMap<String, Object>, Integer>, Boolean> datas = tuple -> {
+            Integer current = tuple.getV1();
+            JMap<String, Object> params = tuple.getV2();
+            JMap<String, Object> msg = tuple.getV3();
+            Integer workType = tuple.getV4();
+            //查询数据
+            IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(Page.of(current, 100), params);
+            List<Long> mercIds = longIPage.getRecords();
+            if (!Emptys.check(mercIds)) {
+                return false;
+            }
+            //发送消息
+            MsgUtils.sendMsg(17L, mercIds)
+                    .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), msg))
+                    .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), msg))
+                    .builder();
+            //写入记录
+            mercMsgInfoService.save(new MercMsgInfoDto.Save()
+                    .setMercId(mercIds)
+                    .setType(1)
+                    .setWorkType(workType)
+            );
+            return true;
+        };
         //即将过期
         FunctionUtils.NoParamsNoResult timeout1 = () -> {
             int day = Integer.valueOf(stringSysDictRedisMap.get(EnumMercCostMsgConfig.DEVICE_COST_DAY.getCode()).getValue());
@@ -100,7 +125,9 @@ public class DeviceChargingJob {
                     .set("workType", 1)
                     .set("begin", now)
                     .set("end", end);
-            deviceChargingTimeout1(map, 1, 100, tel);
+            JMap<String, Object> sendParams = new JHashMap<String, Object>()
+                    .set("content", String.format("尊敬的客户,您有%s即将到期,为避免设备停机,请及时续费,客服电话%s", "设备管理费", tel));
+            RecursionUtils.recursion(current -> datas.run(new Tuple.Tuple4<>(current, map, sendParams, 1)));
         };
         //欠费
         FunctionUtils.NoParamsNoResult timeout2 = () -> {
@@ -110,81 +137,13 @@ public class DeviceChargingJob {
                     .set("mmiTime", mmiTime)
                     .set("workType", 2)
                     .set("end", now);
-            deviceChargingTimeout2(map, now, time1, 1, 100, tel);
+            JMap<String, Object> sendParams = new JHashMap<String, Object>()
+                    .set("content", String.format("尊敬的客户,截止%s您的%s已欠费,如您在%s前未完成续费,您的设备将停止交易,客服电话%s", now, "设备管理费", time1, tel));
+            RecursionUtils.recursion(current -> datas.run(new Tuple.Tuple4<>(current, map, sendParams, 2)));
         };
         timeout1.run();
         timeout2.run();
         return ReturnT.SUCCESS;
     }
 
-    /**
-     * 即将过期
-     *
-     * @param map     sql参数
-     * @param current 当前页码
-     * @param size    显示行数
-     * @param tel     客服手机
-     */
-    private void deviceChargingTimeout1(JMap<String, Object> map, long current, long size, String tel) {
-        //查询数据
-        IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(Page.of(current, size), map);
-        List<Long> mercIds = longIPage.getRecords();
-        if (!Emptys.check(mercIds)) {
-            return;
-        }
-        //发送消息
-        JMap<String, Object> officialParams = new JHashMap<String, Object>()
-                .set("content", String.format("尊敬的客户,您有设备管理费即将到期,为避免设备停机,请及时续费,客服电话%s", tel));
-        JMap<String, Object> mxrParams = officialParams;
-        MsgUtils.sendMsg(17L, mercIds)
-                .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), officialParams))
-                .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), mxrParams))
-                .builder();
-        //写入记录
-        mercMsgInfoService.save(new MercMsgInfoDto.Save()
-                .setMercId(mercIds)
-                .setType(1)
-                .setWorkType(1)
-        );
-        //下一页
-        current++;
-        deviceChargingTimeout1(map, current, size, tel);
-    }
-
-    /**
-     * 已欠费
-     *
-     * @param map      sql参数
-     * @param thisTime 当前时间
-     * @param time1    过期后可用时间
-     * @param current  当前页码
-     * @param size     显示行数
-     * @param tel      客服手机
-     */
-    private void deviceChargingTimeout2(JMap<String, Object> map, String thisTime, String time1, long current, long size, String tel) {
-        //查询数据
-        IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(Page.of(current, size), map);
-        List<Long> mercIds = longIPage.getRecords();
-        if (!Emptys.check(mercIds)) {
-            return;
-        }
-        //发送消息
-        JMap<String, Object> officialParams = new JHashMap<String, Object>()
-                .set("content", String.format("尊敬的客户,截止%s您的%s已欠费,如您在%s前未完成续费,您的设备将停止交易,客服电话%s", thisTime, "设备管理费", time1, tel));
-        JMap<String, Object> mxrParams = officialParams;
-        MsgUtils.sendMsg(17L, mercIds)
-                .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), officialParams))
-                .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), mxrParams))
-                .builder();
-        //写入记录
-        mercMsgInfoService.save(new MercMsgInfoDto.Save()
-                .setMercId(mercIds)
-                .setType(1)
-                .setWorkType(2)
-        );
-        //下一页
-        current++;
-        deviceChargingTimeout2(map, thisTime, time1, current, size, tel);
-    }
-
 }

+ 33 - 73
device-api-service/src/main/java/com/xy/job/DeviceSimJob.java

@@ -43,98 +43,58 @@ public class DeviceSimJob {
         Map<String, SysDictRedis> stringSysDictRedisMap = SysDictUtils.get(EnumMercCostMsgConfig.Code.CODE.getCode());
         String tel = stringSysDictRedisMap.get(EnumMercCostMsgConfig.CUSTOM_TEL.getCode()).getValue();
         String mmiTime = DataTime.getStringAround(0, -1, 0, 0, 0, 0, now);
+        //数据逻辑
+        FunctionUtils.ParamsResult<Tuple.Tuple4<Integer, JMap<String, Object>, JMap<String, Object>, Integer>, Boolean> datas = tuple -> {
+            Integer current = tuple.getV1();
+            JMap<String, Object> params = tuple.getV2();
+            JMap<String, Object> msg = tuple.getV3();
+            Integer workType = tuple.getV4();
+            //查询数据
+            IPage<Long> longIPage = deviceSimMapper.deviceSimTimeout(Page.of(current, 100), params);
+            List<Long> mercIds = longIPage.getRecords();
+            if (!Emptys.check(mercIds)) {
+                return false;
+            }
+            //发送消息
+            MsgUtils.sendMsg(17L, mercIds)
+                    .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), msg))
+                    .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), msg))
+                    .builder();
+            //写入记录
+            mercMsgInfoService.save(new MercMsgInfoDto.Save()
+                    .setMercId(mercIds)
+                    .setType(2)
+                    .setWorkType(workType)
+            );
+            return true;
+        };
         //即将过期
         FunctionUtils.NoParamsNoResult timeout1 = () -> {
             int day = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_200.getCode(), Integer.class);
-            String end = DataTime.getStringAround(0, 0, day, 0, 0, 0);
+            String end = DataTime.getStringAround(0, 0, day, 0, 0, 0, now);
             JMap<String, Object> map = new JHashMap<String, Object>()
                     .set("mmiTime", mmiTime)
                     .set("workType", 1)
                     .set("begin", now)
                     .set("end", end);
-            deviceSimTimeout1(map, 1, 100, tel);
+            JMap<String, Object> sendParams = new JHashMap<String, Object>()
+                    .set("content", String.format("尊敬的客户,您有%s即将到期,为避免设备停机,请及时续费,客服电话%s", "设备流量卡", tel));
+            RecursionUtils.recursion(current -> datas.run(new Tuple.Tuple4<>(current, map, sendParams, 1)));
         };
         //欠费
         FunctionUtils.NoParamsNoResult timeout2 = () -> {
-            int day = Integer.valueOf(stringSysDictRedisMap.get(EnumMercCostMsgConfig.ARREARAGE_DAY.getCode()).getValue());
+            int day = Integer.parseInt(stringSysDictRedisMap.get(EnumMercCostMsgConfig.ARREARAGE_DAY.getCode()).getValue());
             String time1 = DataTime.getStringAround(0, 0, day, 0, 0, 0, now);
             JMap<String, Object> map = new JHashMap<String, Object>()
                     .set("mmiTime", mmiTime)
                     .set("workType", 2)
                     .set("end", now);
-            deviceSimTimeout2(map, now, time1, 1, 100, tel);
+            JMap<String, Object> sendParams = new JHashMap<String, Object>()
+                    .set("content", String.format("尊敬的客户,截止%s您的%s已欠费,如您在%s前未完成续费,您的设备将停止交易,客服电话%s", now, "设备流量卡", time1, tel));
+            RecursionUtils.recursion(current -> datas.run(new Tuple.Tuple4<>(current, map, sendParams, 2)));
         };
         timeout1.run();
         timeout2.run();
         return ReturnT.SUCCESS;
     }
-
-    /**
-     * 即将过期
-     *
-     * @param map
-     * @param current
-     * @param size
-     * @param tel
-     */
-    private void deviceSimTimeout1(JMap<String, Object> map, long current, long size, String tel) {
-        //查询数据
-        IPage<Long> longIPage = deviceSimMapper.deviceSimTimeout(Page.of(current, size), map);
-        List<Long> mercIds = longIPage.getRecords();
-        if (!Emptys.check(mercIds)) {
-            return;
-        }
-        //发送消息
-        JMap<String, Object> officialParams = new JHashMap<String, Object>()
-                .set("content", String.format("尊敬的客户,您有设备流量卡即将到期,为避免设备停机,请及时续费,客服电话%s", tel));
-        JMap<String, Object> mxrParams = officialParams;
-        MsgUtils.sendMsg(17L, mercIds)
-                .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), officialParams))
-                .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), mxrParams))
-                .builder();
-        //写入记录
-        mercMsgInfoService.save(new MercMsgInfoDto.Save()
-                .setMercId(mercIds)
-                .setType(2)
-                .setWorkType(1)
-        );
-        //下一页
-        current++;
-        deviceSimTimeout1(map, current, size, tel);
-    }
-
-    /**
-     * 已欠费
-     *
-     * @param map
-     * @param thisTime
-     * @param current
-     * @param size
-     * @param tel
-     */
-    private void deviceSimTimeout2(JMap<String, Object> map, String thisTime, String time1, long current, long size, String tel) {
-        //查询数据
-        IPage<Long> longIPage = deviceSimMapper.deviceSimTimeout(Page.of(current, size), map);
-        List<Long> mercIds = longIPage.getRecords();
-        if (!Emptys.check(mercIds)) {
-            return;
-        }
-        //发送消息
-        JMap<String, Object> officialParams = new JHashMap<String, Object>()
-                .set("content", String.format("尊敬的客户,截止%s您的%s已欠费,如您在%s前未完成续费,您的设备将停止交易,客服电话%s", thisTime, "设备流量卡", time1, tel));
-        JMap<String, Object> mxrParams = officialParams;
-        MsgUtils.sendMsg(17L, mercIds)
-                .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), officialParams))
-                .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), mxrParams))
-                .builder();
-        //写入记录
-        mercMsgInfoService.save(new MercMsgInfoDto.Save()
-                .setMercId(mercIds)
-                .setType(2)
-                .setWorkType(2)
-        );
-        //下一页
-        current++;
-        deviceSimTimeout2(map, thisTime, time1, current, size, tel);
-    }
 }