fix: 定时任务授权
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.wfc.user.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -20,6 +21,8 @@ import org.wfc.omada.api.device.model.OperationResponseGridVoDeviceInfo;
|
||||
import org.wfc.omada.api.organization.OmadaSiteApi;
|
||||
import org.wfc.omada.api.organization.model.OperationResponseGridVoSiteSummaryInfo;
|
||||
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
||||
import org.wfc.user.api.IWifiApi;
|
||||
import org.wfc.user.domain.UAccount;
|
||||
import org.wfc.user.domain.UCdr;
|
||||
import org.wfc.user.domain.UCdrHistory;
|
||||
import org.wfc.user.domain.UClient;
|
||||
@@ -34,8 +37,12 @@ import org.wfc.user.service.IUCdrHistoryService;
|
||||
import org.wfc.user.service.IUCdrService;
|
||||
import org.wfc.user.service.IUClientService;
|
||||
import org.wfc.user.service.IUDeviceService;
|
||||
import org.wfc.user.util.AccountUtil;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -72,6 +79,9 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
|
||||
@Autowired
|
||||
private IUAccountService accountService;
|
||||
|
||||
@Autowired
|
||||
private IWifiApi wifiApi;
|
||||
|
||||
|
||||
@Override
|
||||
public UCdrUserVo getByUser() {
|
||||
@@ -107,6 +117,8 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
|
||||
continue;
|
||||
}
|
||||
List<ClientInfo> clients = clientResp.getBody().getResult().getData();
|
||||
authClients(clients);
|
||||
|
||||
for (ClientInfo client : clients) {
|
||||
// 添加用户设备
|
||||
UClient hasClient = addClient(client);
|
||||
@@ -125,6 +137,30 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
|
||||
accountService.statAndCancelAuthUser();
|
||||
}
|
||||
|
||||
private void authClients(List<ClientInfo> clients) {
|
||||
List<String> clientMacs = clients.stream().filter(c -> ObjectUtil.isNotNull(c.getAuthStatus()) && c.getAuthStatus() != 2)
|
||||
.map(ClientInfo::getMac).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(clientMacs)) {
|
||||
return;
|
||||
}
|
||||
List<UClient> unAuthClients = clientService.list(Wrappers.<UClient>lambdaQuery().isNotNull(UClient::getUserId).in(UClient::getClientMac, clientMacs));
|
||||
List<Long> userIds = unAuthClients.stream().map(UClient::getUserId).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return;
|
||||
}
|
||||
List<UAccount> accounts = accountService.list(Wrappers.<UAccount>lambdaQuery().in(UAccount::getUserId, userIds));
|
||||
for (UClient unAuthClient : unAuthClients) {
|
||||
for (UAccount account : accounts) {
|
||||
if (Objects.equals(unAuthClient.getUserId(), account.getUserId())) {
|
||||
if (AccountUtil.isValid(account, new Date())) {
|
||||
wifiApi.authClient(unAuthClient.getSiteId(), unAuthClient.getClientMac());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addCdrHistory(SiteSummaryInfo site, String mac, Long cdrId) {
|
||||
// 话单历史
|
||||
ResponseEntity<OperationResponseGridVoClientHistoryInfo> pastConnResp = omadaClientInsightApi.getGridPastConnections(site.getSiteId(), 1, 1000, mac);
|
||||
|
||||
@@ -124,11 +124,11 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
List<UClient> clients = clientService.list(Wrappers.<UClient>lambdaQuery().eq(UClient::getUserId, order.getUserId()));
|
||||
for (UClient client : clients) {
|
||||
if (StrUtil.isNotBlank(client.getSiteId())) {
|
||||
wifiApi.authClient(client.getSiteId(), client.getClientMac());
|
||||
// 套餐生效已授权时,调reconnect重连接口,以便截取时间
|
||||
if (isValid) {
|
||||
wifiApi.reconnectClient(client.getSiteId(), client.getClientMac());
|
||||
}
|
||||
wifiApi.authClient(client.getSiteId(), client.getClientMac());
|
||||
// 带宽限速
|
||||
ClientRateLimitSettingDto clientRateLimitSetting = OmadaConvert.INSTANCE.toClientRateLimitSettingDto(account);
|
||||
wifiApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting);
|
||||
@@ -195,7 +195,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
// 测试
|
||||
if (billRule.getTraffic() == 1) {
|
||||
// 支付成功回调
|
||||
paySuccess(order.getId());
|
||||
// paySuccess(order.getId());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user