2
0

fix: cdr record

This commit is contained in:
caiyuchao
2024-12-18 18:03:37 +08:00
parent df88bb2376
commit 129081ff60
3 changed files with 27 additions and 23 deletions

View File

@@ -93,6 +93,7 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
return;
}
List<SiteSummaryInfo> sites = siteResp.getBody().getResult().getData();
List<UClient> allClients = clientService.list(Wrappers.<UClient>lambdaQuery().isNotNull(UClient::getUserId));
// 添加AP设备
addDevices(sites);
for (SiteSummaryInfo site : sites) {
@@ -105,16 +106,19 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
// 添加用户设备
UClient hasClient = addClient(client);
// 添加话单
Long cdrId = addCdr(client, hasClient);
// 添加话单历史
addCdrHistory(site, client, cdrId);
addCdr(client, hasClient);
}
for (UClient client : allClients) {
UCdr uCdr = this.getOne(Wrappers.<UCdr>lambdaQuery().eq(UCdr::getUserId, client.getUserId())
.eq(UCdr::getClientId, client.getId()));
addCdrHistory(site, client.getClientMac(), uCdr.getId());
}
}
}
private void addCdrHistory(SiteSummaryInfo site, ClientInfo client, Long cdrId) {
private void addCdrHistory(SiteSummaryInfo site, String mac, Long cdrId) {
// 话单历史
ResponseEntity<OperationResponseGridVoClientHistoryInfo> pastConnResp = omadaClientInsightApi.getGridPastConnections(site.getSiteId(), 1, 1000, client.getMac());
ResponseEntity<OperationResponseGridVoClientHistoryInfo> pastConnResp = omadaClientInsightApi.getGridPastConnections(site.getSiteId(), 1, 1000, mac);
if (ObjectUtil.isNull(pastConnResp.getBody())) {
return;
}

View File

@@ -80,14 +80,11 @@
c.client_name,
c.client_mac,
c.client_device_type,
min( ch.start_time ) start_time,
max( ch.end_time ) end_time,
sum(
ifnull( ch.duration, 0 )) duration,
sum(
ifnull( ch.traffic_down, 0 )) traffic_down,
sum(
ifnull( ch.traffic_up, 0 )) traffic_up
ch.start_time,
ch.end_time,
ifnull( ch.duration, 0 ) duration,
ifnull( ch.traffic_down, 0 ) traffic_down,
ifnull( ch.traffic_up, 0 ) traffic_up
FROM
u_cdr cdr
LEFT JOIN u_cdr_history ch ON cdr.id = ch.cdr_id
@@ -100,10 +97,7 @@
<if test="userId != null and userId != ''">
AND cdr.user_id = #{userId}
</if>
GROUP BY
cdr.user_id,
cdr.client_id
ORDER BY
min( ch.start_time ) DESC
ch.start_time DESC
</select>
</mapper>

View File

@@ -31,11 +31,14 @@
c.client_name,
c.client_mac,
c.client_device_type,
ch.start_time,
ch.end_time,
ifnull( ch.duration, 0 ) duration,
ifnull( ch.traffic_down, 0 ) traffic_down,
ifnull( ch.traffic_up, 0 ) traffic_up
min( ch.start_time ) start_time,
max( ch.end_time ) end_time,
sum(
ifnull( ch.duration, 0 )) duration,
sum(
ifnull( ch.traffic_down, 0 )) traffic_down,
sum(
ifnull( ch.traffic_up, 0 )) traffic_up
FROM
u_cdr cdr
LEFT JOIN u_cdr_history ch ON cdr.id = ch.cdr_id
@@ -48,8 +51,11 @@
<if test="userId != null and userId != ''">
AND cdr.user_id = #{userId}
</if>
GROUP BY
cdr.user_id,
cdr.client_id
ORDER BY
ch.start_time DESC
min( ch.start_time ) DESC
</select>
</mapper>