feat: add client and cdr interface
This commit is contained in:
@@ -63,6 +63,7 @@ CREATE TABLE `u_cdr` (
|
|||||||
`rate_limit_profile_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'Rate limit profile ID. ',
|
`rate_limit_profile_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'Rate limit profile ID. ',
|
||||||
`up_time` bigint(20) NULL DEFAULT NULL COMMENT 'Up time (unit: s).',
|
`up_time` bigint(20) NULL DEFAULT NULL COMMENT 'Up time (unit: s).',
|
||||||
`last_seen_time` bigint(20) NULL DEFAULT NULL COMMENT 'Last found time, timestamp (ms). ',
|
`last_seen_time` bigint(20) NULL DEFAULT NULL COMMENT 'Last found time, timestamp (ms). ',
|
||||||
|
`activity` bigint(20) DEFAULT NULL COMMENT 'Activity download speed (Bytes/s)',
|
||||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '0' COMMENT 'delete flag',
|
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '0' COMMENT 'delete flag',
|
||||||
`create_by` bigint(20) NULL DEFAULT NULL COMMENT 'creater',
|
`create_by` bigint(20) NULL DEFAULT NULL COMMENT 'creater',
|
||||||
`create_time` datetime NULL DEFAULT NULL COMMENT 'create time',
|
`create_time` datetime NULL DEFAULT NULL COMMENT 'create time',
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.wfc.common.core.web.controller.BaseController;
|
|||||||
import org.wfc.common.core.web.page.TableDataInfo;
|
import org.wfc.common.core.web.page.TableDataInfo;
|
||||||
import org.wfc.user.domain.bo.UCdrClientBo;
|
import org.wfc.user.domain.bo.UCdrClientBo;
|
||||||
import org.wfc.user.domain.vo.UCdrClientVo;
|
import org.wfc.user.domain.vo.UCdrClientVo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrHistoryUserVo;
|
||||||
import org.wfc.user.domain.vo.UCdrUserVo;
|
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||||
import org.wfc.user.service.IUCdrService;
|
import org.wfc.user.service.IUCdrService;
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ public class UCdrController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getByUser")
|
@GetMapping("/getOne")
|
||||||
public R<UCdrUserVo> getByUser() {
|
public R<UCdrUserVo> getByUser() {
|
||||||
UCdrUserVo result = cdrService.getByUser();
|
UCdrUserVo result = cdrService.getByUser();
|
||||||
return R.ok(result);
|
return R.ok(result);
|
||||||
@@ -54,11 +55,23 @@ public class UCdrController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getByClient")
|
@GetMapping("/pageClient")
|
||||||
public TableDataInfo getByClient(UCdrClientBo clientBo) {
|
public TableDataInfo getByClient(UCdrClientBo clientBo) {
|
||||||
startPage();
|
startPage();
|
||||||
List<UCdrClientVo> result = cdrService.getByClient(clientBo);
|
List<UCdrClientVo> result = cdrService.getByClient(clientBo);
|
||||||
return getDataTable(result);
|
return getDataTable(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户查询cdr记录
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/pageHistory")
|
||||||
|
public TableDataInfo getHistoryByUser() {
|
||||||
|
startPage();
|
||||||
|
List<UCdrHistoryUserVo> result = cdrService.getHistoryByUser();
|
||||||
|
return getDataTable(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
package org.wfc.user.controller;
|
package org.wfc.user.controller;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.wfc.common.core.domain.R;
|
import org.wfc.common.core.domain.R;
|
||||||
|
import org.wfc.common.core.web.controller.BaseController;
|
||||||
|
import org.wfc.common.core.web.page.TableDataInfo;
|
||||||
import org.wfc.user.api.domain.bo.UClientBo;
|
import org.wfc.user.api.domain.bo.UClientBo;
|
||||||
|
import org.wfc.user.domain.vo.UClientCurrentVo;
|
||||||
|
import org.wfc.user.domain.vo.UClientHistoryUserVo;
|
||||||
import org.wfc.user.service.IUClientService;
|
import org.wfc.user.service.IUClientService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 用户平台_AP设备表 前端控制器
|
* 用户平台_AP设备表 前端控制器
|
||||||
@@ -18,8 +25,8 @@ import org.wfc.user.service.IUClientService;
|
|||||||
* @since 2024-12-09
|
* @since 2024-12-09
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user/uClient")
|
@RequestMapping("/client")
|
||||||
public class UClientController {
|
public class UClientController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUClientService clientService;
|
private IUClientService clientService;
|
||||||
@@ -33,4 +40,28 @@ public class UClientController {
|
|||||||
return R.ok(result);
|
return R.ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户查询当前接入设备
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/pageCurrentClient")
|
||||||
|
public TableDataInfo getCurrentClients() {
|
||||||
|
startPage();
|
||||||
|
List<UClientCurrentVo> result = clientService.getCurrentClients();
|
||||||
|
return getDataTable(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户查询历史设备
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/pageHistoryClient")
|
||||||
|
public TableDataInfo getHistoryByUser() {
|
||||||
|
startPage();
|
||||||
|
List<UClientHistoryUserVo> result = clientService.getHistoryByUser();
|
||||||
|
return getDataTable(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,4 +66,7 @@ public class UCdr extends BaseData {
|
|||||||
|
|
||||||
@Schema(description = "Last found time, timestamp (ms). ")
|
@Schema(description = "Last found time, timestamp (ms). ")
|
||||||
private Long lastSeenTime;
|
private Long lastSeenTime;
|
||||||
|
|
||||||
|
@Schema(description = "Activity download speed (Bytes/s)")
|
||||||
|
private Long activity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package org.wfc.user.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: cdr历史vo
|
||||||
|
* @author: cyc
|
||||||
|
* @since: 2024-12-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UCdrHistoryUserVo {
|
||||||
|
private Long id;
|
||||||
|
private String clientName;
|
||||||
|
private String clientMac;
|
||||||
|
private String clientDeviceType;
|
||||||
|
private Long startTime;
|
||||||
|
private Long endTime;
|
||||||
|
private Long duration;
|
||||||
|
private Long trafficDown;
|
||||||
|
private Long trafficUp;
|
||||||
|
}
|
||||||
@@ -15,4 +15,5 @@ public class UCdrUserVo {
|
|||||||
private Long duration;
|
private Long duration;
|
||||||
private Long trafficDown;
|
private Long trafficDown;
|
||||||
private Long trafficUp;
|
private Long trafficUp;
|
||||||
|
private Long activity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.wfc.user.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 当前接入设备Vo
|
||||||
|
* @author: cyc
|
||||||
|
* @since: 2024-12-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UClientCurrentVo {
|
||||||
|
private Long id;
|
||||||
|
private String clientName;
|
||||||
|
private String clientMac;
|
||||||
|
private String clientDeviceType;
|
||||||
|
private Long upTime;
|
||||||
|
private Long trafficDown;
|
||||||
|
private Long trafficUp;
|
||||||
|
private Long activity;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package org.wfc.user.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 历史设备vo
|
||||||
|
* @author: cyc
|
||||||
|
* @since: 2024-12-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UClientHistoryUserVo {
|
||||||
|
private Long id;
|
||||||
|
private String clientName;
|
||||||
|
private String clientMac;
|
||||||
|
private String clientDeviceType;
|
||||||
|
private Long startTime;
|
||||||
|
private Long endTime;
|
||||||
|
private Long duration;
|
||||||
|
private Long trafficDown;
|
||||||
|
private Long trafficUp;
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param;
|
|||||||
import org.wfc.user.domain.UCdr;
|
import org.wfc.user.domain.UCdr;
|
||||||
import org.wfc.user.domain.bo.UCdrClientBo;
|
import org.wfc.user.domain.bo.UCdrClientBo;
|
||||||
import org.wfc.user.domain.vo.UCdrClientVo;
|
import org.wfc.user.domain.vo.UCdrClientVo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrHistoryUserVo;
|
||||||
import org.wfc.user.domain.vo.UCdrUserVo;
|
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -23,4 +24,5 @@ public interface UCdrMapper extends BaseMapper<UCdr> {
|
|||||||
|
|
||||||
List<UCdrClientVo> getByClient(@Param("client") UCdrClientBo client);
|
List<UCdrClientVo> getByClient(@Param("client") UCdrClientBo client);
|
||||||
|
|
||||||
|
List<UCdrHistoryUserVo> getHistoryByUser(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package org.wfc.user.mapper;
|
package org.wfc.user.mapper;
|
||||||
|
|
||||||
import org.wfc.user.domain.UClient;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.wfc.user.domain.UClient;
|
||||||
|
import org.wfc.user.domain.vo.UClientHistoryUserVo;
|
||||||
|
import org.wfc.user.domain.vo.UClientCurrentVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -13,4 +18,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
*/
|
*/
|
||||||
public interface UClientMapper extends BaseMapper<UClient> {
|
public interface UClientMapper extends BaseMapper<UClient> {
|
||||||
|
|
||||||
|
List<UClientCurrentVo> getCurrentClients(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
List<UClientHistoryUserVo> getHistoryByUser(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import org.wfc.user.domain.UCdr;
|
import org.wfc.user.domain.UCdr;
|
||||||
import org.wfc.user.domain.bo.UCdrClientBo;
|
import org.wfc.user.domain.bo.UCdrClientBo;
|
||||||
import org.wfc.user.domain.vo.UCdrClientVo;
|
import org.wfc.user.domain.vo.UCdrClientVo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrHistoryUserVo;
|
||||||
import org.wfc.user.domain.vo.UCdrUserVo;
|
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,6 +23,8 @@ public interface IUCdrService extends IService<UCdr> {
|
|||||||
|
|
||||||
List<UCdrClientVo> getByClient(UCdrClientBo client);
|
List<UCdrClientVo> getByClient(UCdrClientBo client);
|
||||||
|
|
||||||
|
List<UCdrHistoryUserVo> getHistoryByUser();
|
||||||
|
|
||||||
void addCdrInfoByOmadaApi();
|
void addCdrInfoByOmadaApi();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ package org.wfc.user.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.wfc.user.api.domain.bo.UClientBo;
|
import org.wfc.user.api.domain.bo.UClientBo;
|
||||||
import org.wfc.user.domain.UClient;
|
import org.wfc.user.domain.UClient;
|
||||||
|
import org.wfc.user.domain.vo.UClientCurrentVo;
|
||||||
|
import org.wfc.user.domain.vo.UClientHistoryUserVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -16,4 +20,7 @@ public interface IUClientService extends IService<UClient> {
|
|||||||
|
|
||||||
boolean recordClientUser(UClientBo uClientBo);
|
boolean recordClientUser(UClientBo uClientBo);
|
||||||
|
|
||||||
|
List<UClientCurrentVo> getCurrentClients();
|
||||||
|
|
||||||
|
List<UClientHistoryUserVo> getHistoryByUser();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.wfc.user.domain.UClient;
|
|||||||
import org.wfc.user.domain.UDevice;
|
import org.wfc.user.domain.UDevice;
|
||||||
import org.wfc.user.domain.bo.UCdrClientBo;
|
import org.wfc.user.domain.bo.UCdrClientBo;
|
||||||
import org.wfc.user.domain.vo.UCdrClientVo;
|
import org.wfc.user.domain.vo.UCdrClientVo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrHistoryUserVo;
|
||||||
import org.wfc.user.domain.vo.UCdrUserVo;
|
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||||
import org.wfc.user.mapper.UCdrMapper;
|
import org.wfc.user.mapper.UCdrMapper;
|
||||||
import org.wfc.user.service.IUCdrHistoryService;
|
import org.wfc.user.service.IUCdrHistoryService;
|
||||||
@@ -79,6 +80,12 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
|
|||||||
return this.baseMapper.getByClient(client);
|
return this.baseMapper.getByClient(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UCdrHistoryUserVo> getHistoryByUser() {
|
||||||
|
LoginUser<Object> loginUser = SecurityUtils.getLoginUser();
|
||||||
|
return this.baseMapper.getHistoryByUser(loginUser.getUserid());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCdrInfoByOmadaApi() {
|
public void addCdrInfoByOmadaApi() {
|
||||||
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteResp = omadaSiteApi.getSiteList(1, 1000);
|
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteResp = omadaSiteApi.getSiteList(1, 1000);
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
package org.wfc.user.service.impl;
|
package org.wfc.user.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.wfc.common.core.domain.LoginUser;
|
||||||
|
import org.wfc.common.security.utils.SecurityUtils;
|
||||||
import org.wfc.user.api.domain.bo.UClientBo;
|
import org.wfc.user.api.domain.bo.UClientBo;
|
||||||
import org.wfc.user.domain.UClient;
|
import org.wfc.user.domain.UClient;
|
||||||
|
import org.wfc.user.domain.vo.UClientCurrentVo;
|
||||||
|
import org.wfc.user.domain.vo.UClientHistoryUserVo;
|
||||||
import org.wfc.user.mapper.UClientMapper;
|
import org.wfc.user.mapper.UClientMapper;
|
||||||
import org.wfc.user.service.IUClientService;
|
import org.wfc.user.service.IUClientService;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 用户平台_用户设备表 服务实现类
|
* 用户平台_用户设备表 服务实现类
|
||||||
@@ -35,4 +43,22 @@ public class UClientServiceImpl extends ServiceImpl<UClientMapper, UClient> impl
|
|||||||
}
|
}
|
||||||
return this.saveOrUpdate(uClient);
|
return this.saveOrUpdate(uClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UClientCurrentVo> getCurrentClients() {
|
||||||
|
LoginUser<Object> loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return this.baseMapper.getCurrentClients(loginUser.getUserid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UClientHistoryUserVo> getHistoryByUser() {
|
||||||
|
LoginUser<Object> loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return this.baseMapper.getHistoryByUser(loginUser.getUserid());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
cdr.user_id id,
|
cdr.user_id id,
|
||||||
min( ch.start_time ) start_time,
|
min( ch.start_time ) start_time,
|
||||||
max( cdr.last_seen_time ) end_time,
|
max( cdr.last_seen_time ) end_time,
|
||||||
|
max( cdr.activity ) activity,
|
||||||
sum(
|
sum(
|
||||||
ifnull( cdr.up_time, 0 ))+ sum(
|
ifnull( cdr.up_time, 0 ))+ sum(
|
||||||
ifnull( ch.duration, 0 )) duration,
|
ifnull( ch.duration, 0 )) duration,
|
||||||
@@ -72,4 +73,36 @@
|
|||||||
AND c.client_mac = like concat('%', #{client.clientMac}, '%')
|
AND c.client_mac = like concat('%', #{client.clientMac}, '%')
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getHistoryByUser" resultType="org.wfc.user.domain.vo.UCdrHistoryUserVo">
|
||||||
|
SELECT
|
||||||
|
cdr.client_id id,
|
||||||
|
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
|
||||||
|
FROM
|
||||||
|
u_cdr cdr
|
||||||
|
LEFT JOIN u_cdr_history ch ON cdr.id = ch.cdr_id
|
||||||
|
AND ch.del_flag = 0
|
||||||
|
LEFT JOIN u_client c ON cdr.client_id = c.id
|
||||||
|
AND c.del_flag = 0
|
||||||
|
WHERE
|
||||||
|
cdr.del_flag = 0
|
||||||
|
<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
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -2,4 +2,53 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="org.wfc.user.mapper.UClientMapper">
|
<mapper namespace="org.wfc.user.mapper.UClientMapper">
|
||||||
|
|
||||||
|
<select id="getCurrentClients" resultType="org.wfc.user.domain.vo.UClientCurrentVo">
|
||||||
|
SELECT
|
||||||
|
c.id,
|
||||||
|
c.client_mac,
|
||||||
|
c.client_name,
|
||||||
|
c.client_device_type,
|
||||||
|
cdr.traffic_up,
|
||||||
|
cdr.traffic_down,
|
||||||
|
cdr.up_time,
|
||||||
|
cdr.activity
|
||||||
|
FROM
|
||||||
|
u_cdr cdr
|
||||||
|
LEFT JOIN ( SELECT ch.cdr_id, max( ch.end_time ) end_time FROM u_cdr_history ch WHERE ch.del_flag = 0 GROUP BY ch.cdr_id ) ch ON cdr.id = ch.cdr_id
|
||||||
|
LEFT JOIN u_client c ON cdr.client_id = c.id
|
||||||
|
AND c.del_flag = 0
|
||||||
|
WHERE
|
||||||
|
cdr.del_flag = 0
|
||||||
|
<if test="userId != null and userId != ''">
|
||||||
|
AND cdr.user_id = #{userId}
|
||||||
|
</if>
|
||||||
|
AND cdr.last_seen_time > ch.end_time
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getHistoryByUser" resultType="org.wfc.user.domain.vo.UClientHistoryUserVo">
|
||||||
|
SELECT
|
||||||
|
cdr.client_id id,
|
||||||
|
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
|
||||||
|
FROM
|
||||||
|
u_cdr cdr
|
||||||
|
LEFT JOIN u_cdr_history ch ON cdr.id = ch.cdr_id
|
||||||
|
AND ch.del_flag = 0
|
||||||
|
LEFT JOIN u_client c ON cdr.client_id = c.id
|
||||||
|
AND c.del_flag = 0
|
||||||
|
WHERE
|
||||||
|
cdr.del_flag = 0
|
||||||
|
<if test="userId != null and userId != ''">
|
||||||
|
AND cdr.user_id = #{userId}
|
||||||
|
</if>
|
||||||
|
ORDER BY
|
||||||
|
ch.start_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="phonenumber != null and phonenumber != ''">
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="email != null and email != ''">
|
||||||
|
AND u.email like concat('%', #{email}, '%')
|
||||||
|
</if>
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d')
|
AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d')
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user