|
@@ -5,19 +5,14 @@ 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.map.JHashMap;
|
|
|
+import com.xy.collections.map.JMap;
|
|
|
import com.xy.device.EnumDeviceCharging;
|
|
|
-import com.xy.dto.be.MercDto;
|
|
|
-import com.xy.entity.DeviceCharging;
|
|
|
-import com.xy.enums.ChannelType;
|
|
|
import com.xy.mapper.DeviceChargingMapper;
|
|
|
-import com.xy.service.be.MercService;
|
|
|
import com.xy.utils.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -30,8 +25,6 @@ public class DeviceChargingJob {
|
|
|
|
|
|
private DeviceChargingMapper deviceChargingMapper;
|
|
|
|
|
|
- private MercService mercService;
|
|
|
-
|
|
|
/**
|
|
|
* 设备管理费过期消息
|
|
|
*
|
|
@@ -47,9 +40,7 @@ public class DeviceChargingJob {
|
|
|
deviceChargingTimeout(now, end, now, 1, 1000);
|
|
|
};
|
|
|
//欠费
|
|
|
- FunctionUtils.NoParamsNoResult timeout2 = () -> {
|
|
|
- deviceChargingTimeout(null, now, now, 1, 1000);
|
|
|
- };
|
|
|
+ FunctionUtils.NoParamsNoResult timeout2 = () -> deviceChargingTimeout(null, now, now, 1, 1000);
|
|
|
timeout1.run();
|
|
|
timeout2.run();
|
|
|
return ReturnT.SUCCESS;
|
|
@@ -57,32 +48,18 @@ public class DeviceChargingJob {
|
|
|
|
|
|
private void deviceChargingTimeout(String begin, String end, String thisTime, long current, long size) {
|
|
|
//查询数据
|
|
|
- IPage<DeviceCharging> iPage = Page.of(current, size);
|
|
|
- IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(iPage, begin, end);
|
|
|
- List<Long> records = longIPage.getRecords();
|
|
|
- if (!Emptys.check(records)) {
|
|
|
+ IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(Page.of(current, size), begin, end);
|
|
|
+ List<Long> mercIds = longIPage.getRecords();
|
|
|
+ if (!Emptys.check(mercIds)) {
|
|
|
return;
|
|
|
}
|
|
|
- List<MercDto.Vo> mercs = mercService.list(new MercDto.SelectList().setMercIds(records)).getData();
|
|
|
//发送消息
|
|
|
- MsgUtils.sendMsg(15L, () -> {
|
|
|
- List<MsgUtils.MsgInfo> msgInfos = new ArrayList<>(mercs.size());
|
|
|
- mercs.forEach(merc -> {
|
|
|
- String contactPhone = merc.getContactPhone();
|
|
|
- if (!Emptys.check(contactPhone)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- MsgUtils.MsgInfo msgInfo = new MsgUtils.MsgInfo()
|
|
|
- .setChannelType(ChannelType.SMS.getCode())
|
|
|
- .setMpOpenIds(Arrays.asList(contactPhone))
|
|
|
- .setParams(new JHashMap<String, Object>()
|
|
|
- .set("dateTime", thisTime)
|
|
|
- .set("code", 1234)
|
|
|
- );
|
|
|
- msgInfos.add(msgInfo);
|
|
|
- });
|
|
|
- return msgInfos;
|
|
|
- });
|
|
|
+ JMap<String, Object> params = new JHashMap<>();
|
|
|
+ MsgUtils.sendMsg(15L, mercIds)
|
|
|
+ .sms(merc -> new MsgUtils.MsgInfo(merc.getContactPhone(), params))
|
|
|
+ .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), params))
|
|
|
+ .mini(userInfo -> new MsgUtils.MsgInfo(userInfo.getWechatOpenid(), params))
|
|
|
+ .builder();
|
|
|
//下一页
|
|
|
current++;
|
|
|
deviceChargingTimeout(begin, end, thisTime, current, size);
|