feat: update cdr info
This commit is contained in:
@@ -75,14 +75,14 @@ CREATE TABLE `u_cdr` (
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for u_cdr_detail
|
-- Table structure for u_cdr_detail
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `u_cdr_detail`;
|
DROP TABLE IF EXISTS `u_cdr_history`;
|
||||||
CREATE TABLE `u_cdr_detail` (
|
CREATE TABLE `u_cdr_history` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'CDR Detail ID',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'CDR Detail ID',
|
||||||
`cdr_id` bigint(20) NULL DEFAULT NULL COMMENT 'CDR ID',
|
`cdr_id` bigint(20) NULL DEFAULT NULL COMMENT 'CDR ID',
|
||||||
`traffic_down` bigint(20) NULL DEFAULT NULL COMMENT 'Downstream traffic (Byte)',
|
`traffic_down` bigint(20) NULL DEFAULT NULL COMMENT 'Downstream traffic (Byte)',
|
||||||
`traffic_up` bigint(20) NULL DEFAULT NULL COMMENT 'Upstream traffic (Byte)',
|
`traffic_up` bigint(20) NULL DEFAULT NULL COMMENT 'Upstream traffic (Byte)',
|
||||||
`start_time` datetime NULL DEFAULT NULL COMMENT 'Start time',
|
`start_time` bigint(20) NULL DEFAULT NULL COMMENT 'Start time',
|
||||||
`end_time` datetime NULL DEFAULT NULL COMMENT 'End time',
|
`end_time` bigint(20) NULL DEFAULT NULL COMMENT 'End time',
|
||||||
`duration` bigint(20) NULL DEFAULT NULL COMMENT 'Duration(s)',
|
`duration` bigint(20) NULL DEFAULT NULL COMMENT 'Duration(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',
|
||||||
@@ -90,7 +90,7 @@ CREATE TABLE `u_cdr_detail` (
|
|||||||
`update_by` bigint(20) NULL DEFAULT NULL COMMENT 'updater',
|
`update_by` bigint(20) NULL DEFAULT NULL COMMENT 'updater',
|
||||||
`update_time` datetime NULL DEFAULT NULL COMMENT 'update time',
|
`update_time` datetime NULL DEFAULT NULL COMMENT 'update time',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户平台_话单明细表' ROW_FORMAT = DYNAMIC;
|
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户平台_话单历史表' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for u_client
|
-- Table structure for u_client
|
||||||
@@ -175,7 +175,6 @@ INSERT INTO `u_dept` VALUES (101, 100, '0,100', 'No.1', 1, 'system', '123456', '
|
|||||||
DROP TABLE IF EXISTS `u_device`;
|
DROP TABLE IF EXISTS `u_device`;
|
||||||
CREATE TABLE `u_device` (
|
CREATE TABLE `u_device` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Device ID',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Device ID',
|
||||||
`user_id` bigint(20) NULL DEFAULT NULL COMMENT 'User ID link to u_user',
|
|
||||||
`device_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'Device Name',
|
`device_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'Device Name',
|
||||||
`device_ip` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'Device ip',
|
`device_ip` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'Device ip',
|
||||||
`device_mac` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'Device mac',
|
`device_mac` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'Device mac',
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.wfc.common.core.domain.LoginUser;
|
|||||||
import org.wfc.common.core.domain.R;
|
import org.wfc.common.core.domain.R;
|
||||||
import org.wfc.common.core.web.page.TableDataInfo;
|
import org.wfc.common.core.web.page.TableDataInfo;
|
||||||
import org.wfc.user.api.domain.UUser;
|
import org.wfc.user.api.domain.UUser;
|
||||||
|
import org.wfc.user.api.domain.bo.UClientBo;
|
||||||
import org.wfc.user.api.factory.RemoteUUserFallbackFactory;
|
import org.wfc.user.api.factory.RemoteUUserFallbackFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,6 +76,12 @@ public interface RemoteUUserService
|
|||||||
/**
|
/**
|
||||||
* 添加话单信息通过OmadaApi
|
* 添加话单信息通过OmadaApi
|
||||||
*/
|
*/
|
||||||
@GetMapping("/user/uCdr/addCdrInfo")
|
@GetMapping("/cdr/addCdrInfo")
|
||||||
public R<Boolean> addCdrInfoByOmadaApi();
|
public R<Boolean> addCdrInfoByOmadaApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@GetMapping("/user/uClient/recordClientUser")
|
||||||
|
public R<Boolean> recordClientUser(@RequestBody UClientBo clientBo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.wfc.user.api.domain.bo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户平台_用户设备bo
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author cyc
|
||||||
|
* @since 2024-12-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class UClientBo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private String clientName;
|
||||||
|
|
||||||
|
private String clientDeviceType;
|
||||||
|
|
||||||
|
private String clientMac;
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import org.wfc.common.core.domain.R;
|
|||||||
import org.wfc.common.core.web.page.TableDataInfo;
|
import org.wfc.common.core.web.page.TableDataInfo;
|
||||||
import org.wfc.user.api.RemoteUUserService;
|
import org.wfc.user.api.RemoteUUserService;
|
||||||
import org.wfc.user.api.domain.UUser;
|
import org.wfc.user.api.domain.UUser;
|
||||||
|
import org.wfc.user.api.domain.bo.UClientBo;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
@@ -65,6 +66,11 @@ public class RemoteUUserFallbackFactory implements FallbackFactory<RemoteUUserSe
|
|||||||
public R<Boolean> addCdrInfoByOmadaApi() {
|
public R<Boolean> addCdrInfoByOmadaApi() {
|
||||||
return R.fail("添加话单信息失败:" + throwable.getMessage());
|
return R.fail("添加话单信息失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<Boolean> recordClientUser(UClientBo clientBo) {
|
||||||
|
return R.fail("根据设备mac保存或更新设备信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ import org.wfc.common.security.auth.AuthUtil;
|
|||||||
import org.wfc.common.security.service.TokenService;
|
import org.wfc.common.security.service.TokenService;
|
||||||
import org.wfc.common.security.utils.SecurityUtils;
|
import org.wfc.common.security.utils.SecurityUtils;
|
||||||
import org.wfc.system.api.domain.SysUser;
|
import org.wfc.system.api.domain.SysUser;
|
||||||
|
import org.wfc.user.api.RemoteUUserService;
|
||||||
import org.wfc.user.api.domain.UUser;
|
import org.wfc.user.api.domain.UUser;
|
||||||
|
import org.wfc.user.api.domain.bo.UClientBo;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@@ -38,6 +40,9 @@ public class TokenController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ULoginService uLoginService;
|
private ULoginService uLoginService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteUUserService remoteUUserService;
|
||||||
|
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
public R<?> login(@RequestBody LoginBody form) {
|
public R<?> login(@RequestBody LoginBody form) {
|
||||||
if ("u".equals(form.getAuthType())) {
|
if ("u".equals(form.getAuthType())) {
|
||||||
@@ -48,6 +53,10 @@ public class TokenController {
|
|||||||
// 用户登录
|
// 用户登录
|
||||||
LoginUser<UUser> userInfo = uLoginService.login(form.getUsername(), form.getPassword());
|
LoginUser<UUser> userInfo = uLoginService.login(form.getUsername(), form.getPassword());
|
||||||
userInfo.setWanFiRedirectParams(wanFiRedirectParams);
|
userInfo.setWanFiRedirectParams(wanFiRedirectParams);
|
||||||
|
// 记录设备所属用户信息
|
||||||
|
UClientBo uClientBo = UClientBo.builder().clientMac(wanFiRedirectParams.getClientMac())
|
||||||
|
.userId(userInfo.getUserid()).build();
|
||||||
|
remoteUUserService.recordClientUser(uClientBo);
|
||||||
// 获取登录token
|
// 获取登录token
|
||||||
return R.ok(tokenService.createToken(userInfo));
|
return R.ok(tokenService.createToken(userInfo));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,15 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
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.domain.bo.UCdrClientBo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrClientVo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||||
import org.wfc.user.service.IUCdrService;
|
import org.wfc.user.service.IUCdrService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 用户平台_用户话单表 前端控制器
|
* 用户平台_用户话单表 前端控制器
|
||||||
@@ -16,8 +23,8 @@ import org.wfc.user.service.IUCdrService;
|
|||||||
* @since 2024-12-09
|
* @since 2024-12-09
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user/uCdr")
|
@RequestMapping("/cdr")
|
||||||
public class UCdrController {
|
public class UCdrController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUCdrService cdrService;
|
private IUCdrService cdrService;
|
||||||
@@ -31,4 +38,27 @@ public class UCdrController {
|
|||||||
return R.ok(true);
|
return R.ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户查询话单
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/getByUser")
|
||||||
|
public R<UCdrUserVo> getByUser() {
|
||||||
|
UCdrUserVo result = cdrService.getByUser();
|
||||||
|
return R.ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备查询话单
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/getByClient")
|
||||||
|
public TableDataInfo getByClient(UCdrClientBo clientBo) {
|
||||||
|
startPage();
|
||||||
|
List<UCdrClientVo> result = cdrService.getByClient(clientBo);
|
||||||
|
return getDataTable(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author cyc
|
* @author cyc
|
||||||
* @since 2024-12-09
|
* @since 2024-12-12
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user/uCdrDetail")
|
@RequestMapping("/user/uCdrHistory")
|
||||||
public class UCdrDetailController {
|
public class UCdrHistoryController {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,13 @@
|
|||||||
package org.wfc.user.controller;
|
package org.wfc.user.controller;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
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.user.api.domain.bo.UClientBo;
|
||||||
|
import org.wfc.user.service.IUClientService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -15,4 +21,16 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RequestMapping("/user/uClient")
|
@RequestMapping("/user/uClient")
|
||||||
public class UClientController {
|
public class UClientController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IUClientService clientService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备mac保存或更新
|
||||||
|
*/
|
||||||
|
@PostMapping("/recordClientUser")
|
||||||
|
public R<Boolean> recordClientUser(@RequestBody UClientBo clientBo) {
|
||||||
|
boolean result = clientService.recordClientUser(clientBo);
|
||||||
|
return R.ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package org.wfc.user.domain;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import org.wfc.common.mybatis.domain.BaseData;
|
import org.wfc.common.mybatis.domain.BaseData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,6 +19,8 @@ import org.wfc.common.mybatis.domain.BaseData;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
@TableName("u_cdr")
|
@TableName("u_cdr")
|
||||||
@Schema(name = "UCdr", description = "用户平台_用户话单表")
|
@Schema(name = "UCdr", description = "用户平台_用户话单表")
|
||||||
|
|||||||
@@ -2,27 +2,29 @@ package org.wfc.user.domain;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import org.wfc.common.mybatis.domain.BaseData;
|
import org.wfc.common.mybatis.domain.BaseData;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 用户平台_话单明细表
|
* 用户平台_话单明细表
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author cyc
|
* @author cyc
|
||||||
* @since 2024-12-09
|
* @since 2024-12-12
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
@TableName("u_cdr_detail")
|
@TableName("u_cdr_history")
|
||||||
@Schema(name = "UCdrDetail", description = "用户平台_话单明细表")
|
@Schema(name = "UCdrHistory", description = "用户平台_话单明细表")
|
||||||
public class UCdrDetail extends BaseData {
|
public class UCdrHistory extends BaseData {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -36,10 +38,10 @@ public class UCdrDetail extends BaseData {
|
|||||||
private Long trafficUp;
|
private Long trafficUp;
|
||||||
|
|
||||||
@Schema(description = "Start time")
|
@Schema(description = "Start time")
|
||||||
private Date startTime;
|
private Long startTime;
|
||||||
|
|
||||||
@Schema(description = "End time")
|
@Schema(description = "End time")
|
||||||
private Date endTime;
|
private Long endTime;
|
||||||
|
|
||||||
@Schema(description = "Duration(s)")
|
@Schema(description = "Duration(s)")
|
||||||
private Long duration;
|
private Long duration;
|
||||||
@@ -2,9 +2,11 @@ package org.wfc.user.domain;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import org.wfc.common.mybatis.domain.BaseData;
|
import org.wfc.common.mybatis.domain.BaseData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,6 +19,8 @@ import org.wfc.common.mybatis.domain.BaseData;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
@TableName("u_client")
|
@TableName("u_client")
|
||||||
@Schema(name = "UClient", description = "用户平台_用户设备表")
|
@Schema(name = "UClient", description = "用户平台_用户设备表")
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package org.wfc.user.domain;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import org.wfc.common.mybatis.domain.BaseData;
|
import org.wfc.common.mybatis.domain.BaseData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,6 +19,8 @@ import org.wfc.common.mybatis.domain.BaseData;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
@TableName("u_device")
|
@TableName("u_device")
|
||||||
@Schema(name = "UDevice", description = "用户平台_AP设备表")
|
@Schema(name = "UDevice", description = "用户平台_AP设备表")
|
||||||
@@ -24,9 +28,6 @@ public class UDevice extends BaseData {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "User ID link to u_user")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
@Schema(description = "Device Name")
|
@Schema(description = "Device Name")
|
||||||
private String deviceName;
|
private String deviceName;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.wfc.user.domain.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 话单设备bo
|
||||||
|
* @author: cyc
|
||||||
|
* @since: 2024-12-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UCdrClientBo {
|
||||||
|
private String clientName;
|
||||||
|
private String clientMac;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.wfc.user.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 话单设备vo
|
||||||
|
* @author: cyc
|
||||||
|
* @since: 2024-12-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UCdrClientVo {
|
||||||
|
private Long id;
|
||||||
|
private String clientName;
|
||||||
|
private String clientMac;
|
||||||
|
private String clientDeviceType;
|
||||||
|
private Long userId;
|
||||||
|
private Long startTime;
|
||||||
|
private Long endTime;
|
||||||
|
private Long duration;
|
||||||
|
private Long trafficDown;
|
||||||
|
private Long trafficUp;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.wfc.user.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 话单用户vo
|
||||||
|
* @author: cyc
|
||||||
|
* @since: 2024-12-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UCdrUserVo {
|
||||||
|
private Long id;
|
||||||
|
private Long startTime;
|
||||||
|
private Long endTime;
|
||||||
|
private Long duration;
|
||||||
|
private Long trafficDown;
|
||||||
|
private Long trafficUp;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.wfc.user.mapper;
|
package org.wfc.user.mapper;
|
||||||
|
|
||||||
import org.wfc.user.domain.UCdrDetail;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.wfc.user.domain.UCdrHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author cyc
|
* @author cyc
|
||||||
* @since 2024-12-09
|
* @since 2024-12-12
|
||||||
*/
|
*/
|
||||||
public interface UCdrDetailMapper extends BaseMapper<UCdrDetail> {
|
public interface UCdrHistoryMapper extends BaseMapper<UCdrHistory> {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,13 @@
|
|||||||
package org.wfc.user.mapper;
|
package org.wfc.user.mapper;
|
||||||
|
|
||||||
import org.wfc.user.domain.UCdr;
|
|
||||||
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.UCdr;
|
||||||
|
import org.wfc.user.domain.bo.UCdrClientBo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrClientVo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -13,4 +19,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
*/
|
*/
|
||||||
public interface UCdrMapper extends BaseMapper<UCdr> {
|
public interface UCdrMapper extends BaseMapper<UCdr> {
|
||||||
|
|
||||||
|
List<UCdrUserVo> getByUser(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
List<UCdrClientVo> getByClient(@Param("client") UCdrClientBo client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.wfc.user.service;
|
package org.wfc.user.service;
|
||||||
|
|
||||||
import org.wfc.user.domain.UCdrDetail;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.wfc.user.domain.UCdrHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author cyc
|
* @author cyc
|
||||||
* @since 2024-12-09
|
* @since 2024-12-12
|
||||||
*/
|
*/
|
||||||
public interface IUCdrDetailService extends IService<UCdrDetail> {
|
public interface IUCdrHistoryService extends IService<UCdrHistory> {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
package org.wfc.user.service;
|
package org.wfc.user.service;
|
||||||
|
|
||||||
import org.wfc.user.domain.UCdr;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.wfc.user.domain.UCdr;
|
||||||
|
import org.wfc.user.domain.bo.UCdrClientBo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrClientVo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -13,6 +18,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface IUCdrService extends IService<UCdr> {
|
public interface IUCdrService extends IService<UCdr> {
|
||||||
|
|
||||||
|
UCdrUserVo getByUser();
|
||||||
|
|
||||||
|
List<UCdrClientVo> getByClient(UCdrClientBo client);
|
||||||
|
|
||||||
void addCdrInfoByOmadaApi();
|
void addCdrInfoByOmadaApi();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package org.wfc.user.service;
|
package org.wfc.user.service;
|
||||||
|
|
||||||
import org.wfc.user.domain.UClient;
|
|
||||||
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.domain.UClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -13,4 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface IUClientService extends IService<UClient> {
|
public interface IUClientService extends IService<UClient> {
|
||||||
|
|
||||||
|
boolean recordClientUser(UClientBo uClientBo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package org.wfc.user.service.impl;
|
|
||||||
|
|
||||||
import org.wfc.user.domain.UCdrDetail;
|
|
||||||
import org.wfc.user.mapper.UCdrDetailMapper;
|
|
||||||
import org.wfc.user.service.IUCdrDetailService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 用户平台_话单明细表 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author cyc
|
|
||||||
* @since 2024-12-09
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class UCdrDetailServiceImpl extends ServiceImpl<UCdrDetailMapper, UCdrDetail> implements IUCdrDetailService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.wfc.user.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.wfc.user.domain.UCdrHistory;
|
||||||
|
import org.wfc.user.mapper.UCdrHistoryMapper;
|
||||||
|
import org.wfc.user.service.IUCdrHistoryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户平台_话单明细表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author cyc
|
||||||
|
* @since 2024-12-12
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UCdrHistoryServiceImpl extends ServiceImpl<UCdrHistoryMapper, UCdrHistory> implements IUCdrHistoryService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
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.omada.api.client.OmadaClientApi;
|
import org.wfc.omada.api.client.OmadaClientApi;
|
||||||
import org.wfc.omada.api.client.OmadaClientInsightApi;
|
import org.wfc.omada.api.client.OmadaClientInsightApi;
|
||||||
import org.wfc.omada.api.client.model.ClientHistoryInfo;
|
import org.wfc.omada.api.client.model.ClientHistoryInfo;
|
||||||
@@ -19,16 +21,18 @@ import org.wfc.omada.api.organization.OmadaSiteApi;
|
|||||||
import org.wfc.omada.api.organization.model.OperationResponseGridVoSiteSummaryInfo;
|
import org.wfc.omada.api.organization.model.OperationResponseGridVoSiteSummaryInfo;
|
||||||
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
||||||
import org.wfc.user.domain.UCdr;
|
import org.wfc.user.domain.UCdr;
|
||||||
import org.wfc.user.domain.UCdrDetail;
|
import org.wfc.user.domain.UCdrHistory;
|
||||||
import org.wfc.user.domain.UClient;
|
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.vo.UCdrClientVo;
|
||||||
|
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||||
import org.wfc.user.mapper.UCdrMapper;
|
import org.wfc.user.mapper.UCdrMapper;
|
||||||
import org.wfc.user.service.IUCdrDetailService;
|
import org.wfc.user.service.IUCdrHistoryService;
|
||||||
import org.wfc.user.service.IUCdrService;
|
import org.wfc.user.service.IUCdrService;
|
||||||
import org.wfc.user.service.IUClientService;
|
import org.wfc.user.service.IUClientService;
|
||||||
import org.wfc.user.service.IUDeviceService;
|
import org.wfc.user.service.IUDeviceService;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +65,19 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
|
|||||||
private IUClientService clientService;
|
private IUClientService clientService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUCdrDetailService cdrDetailService;
|
private IUCdrHistoryService cdrHistoryService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UCdrUserVo getByUser() {
|
||||||
|
LoginUser<Object> loginUser = SecurityUtils.getLoginUser();
|
||||||
|
List<UCdrUserVo> cdrUsers = this.baseMapper.getByUser(loginUser.getUserid());
|
||||||
|
return cdrUsers.stream().findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UCdrClientVo> getByClient(UCdrClientBo client) {
|
||||||
|
return this.baseMapper.getByClient(client);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCdrInfoByOmadaApi() {
|
public void addCdrInfoByOmadaApi() {
|
||||||
@@ -80,78 +96,82 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
|
|||||||
List<ClientInfo> clients = clientResp.getBody().getResult().getData();
|
List<ClientInfo> clients = clientResp.getBody().getResult().getData();
|
||||||
for (ClientInfo client : clients) {
|
for (ClientInfo client : clients) {
|
||||||
// 添加用户设备
|
// 添加用户设备
|
||||||
Long clientId = addClient(client);
|
UClient hasClient = addClient(client);
|
||||||
// 添加话单
|
// 添加话单
|
||||||
Long cdrId = addCdr(client, clientId);
|
Long cdrId = addCdr(client, hasClient);
|
||||||
// 添加话单明细
|
// 添加话单历史
|
||||||
addCdrDetail(site, client, cdrId);
|
addCdrHistory(site, client, cdrId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCdrDetail(SiteSummaryInfo site, ClientInfo client, Long cdrId) {
|
private void addCdrHistory(SiteSummaryInfo site, ClientInfo client, Long cdrId) {
|
||||||
// 话单明细
|
// 话单历史
|
||||||
ResponseEntity<OperationResponseGridVoClientHistoryInfo> pastConnResp = omadaClientInsightApi.getGridPastConnections(site.getSiteId(), 1, 1000, client.getMac());
|
ResponseEntity<OperationResponseGridVoClientHistoryInfo> pastConnResp = omadaClientInsightApi.getGridPastConnections(site.getSiteId(), 1, 1000, client.getMac());
|
||||||
if (ObjectUtil.isNull(pastConnResp.getBody())) {
|
if (ObjectUtil.isNull(pastConnResp.getBody())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<ClientHistoryInfo> pastConns = pastConnResp.getBody().getResult().getData();
|
List<ClientHistoryInfo> pastConns = pastConnResp.getBody().getResult().getData();
|
||||||
for (ClientHistoryInfo pastConn : pastConns) {
|
for (ClientHistoryInfo pastConn : pastConns) {
|
||||||
UCdrDetail uCdrDetail = cdrDetailService.getOne(Wrappers.<UCdrDetail>lambdaQuery().eq(UCdrDetail::getCdrId, cdrId).eq(UCdrDetail::getStartTime, pastConn.getFirstSeen()), false);
|
UCdrHistory hasCdrHistory = cdrHistoryService.getOne(Wrappers.<UCdrHistory>lambdaQuery().eq(UCdrHistory::getCdrId, cdrId).eq(UCdrHistory::getStartTime, pastConn.getFirstSeen()), false);
|
||||||
if (ObjectUtil.isNotNull(uCdrDetail)) {
|
if (ObjectUtil.isNotNull(hasCdrHistory)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
UCdrDetail uCdrDetail1 = UCdrDetail.builder().cdrId(cdrId).startTime(new Date(pastConn.getFirstSeen()))
|
UCdrHistory uCdrHistory = UCdrHistory.builder().cdrId(cdrId).startTime(pastConn.getFirstSeen())
|
||||||
.endTime(new Date(pastConn.getLastSeen()))
|
.endTime(pastConn.getLastSeen())
|
||||||
.trafficUp(pastConn.getUpload())
|
.trafficUp(pastConn.getUpload())
|
||||||
.trafficDown(pastConn.getDownload())
|
.trafficDown(pastConn.getDownload())
|
||||||
.duration(pastConn.getDuration())
|
.duration(pastConn.getDuration())
|
||||||
.build();
|
.build();
|
||||||
cdrDetailService.save(uCdrDetail1);
|
cdrHistoryService.save(uCdrHistory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long addCdr(ClientInfo client, Long clientId) {
|
private Long addCdr(ClientInfo client, UClient hasClient) {
|
||||||
// 话单
|
// 话单
|
||||||
UCdr hasUCdr = this.getOne(Wrappers.<UCdr>lambdaQuery().eq(UCdr::getClientId, clientId), false);
|
UCdr hasUCdr = this.getOne(Wrappers.<UCdr>lambdaQuery()
|
||||||
Long cdrId;
|
.eq(ObjectUtil.isNotNull(hasClient.getUserId()), UCdr::getUserId, hasClient.getUserId())
|
||||||
if (ObjectUtil.isNull(hasUCdr)) {
|
.eq(UCdr::getClientId, hasClient.getId()), false);
|
||||||
UDevice hasDevice = deviceService.getOne(Wrappers.<UDevice>lambdaQuery().eq(UDevice::getDeviceMac, client.getApMac()), false);
|
Long cdrId = null;
|
||||||
UCdr uCdr = UCdr.builder().clientId(clientId)
|
if (ObjectUtil.isNotNull(hasUCdr)) {
|
||||||
.deviceId(hasDevice.getId())
|
|
||||||
.ssid(client.getSsid())
|
|
||||||
.rxRate(client.getRxRate())
|
|
||||||
.txRate(client.getTxRate())
|
|
||||||
.lastSeenTime(client.getLastSeen())
|
|
||||||
.upTime(client.getUptime())
|
|
||||||
.upPacket(client.getUpPacket())
|
|
||||||
.downPacket(client.getDownPacket())
|
|
||||||
.trafficDown(client.getTrafficDown())
|
|
||||||
.trafficUp(client.getTrafficUp())
|
|
||||||
.build();
|
|
||||||
this.save(uCdr);
|
|
||||||
cdrId = uCdr.getId();
|
|
||||||
} else {
|
|
||||||
cdrId = hasUCdr.getId();
|
cdrId = hasUCdr.getId();
|
||||||
}
|
}
|
||||||
return cdrId;
|
UDevice hasDevice = deviceService.getOne(Wrappers.<UDevice>lambdaQuery().eq(UDevice::getDeviceMac, client.getApMac()), false);
|
||||||
|
UCdr uCdr = UCdr.builder().clientId(hasClient.getId())
|
||||||
|
.userId(hasClient.getUserId())
|
||||||
|
.deviceId(hasDevice.getId())
|
||||||
|
.ssid(client.getSsid())
|
||||||
|
.rxRate(client.getRxRate())
|
||||||
|
.txRate(client.getTxRate())
|
||||||
|
.lastSeenTime(client.getLastSeen())
|
||||||
|
.upTime(client.getUptime())
|
||||||
|
.upPacket(client.getUpPacket())
|
||||||
|
.downPacket(client.getDownPacket())
|
||||||
|
.trafficDown(client.getTrafficDown())
|
||||||
|
.trafficUp(client.getTrafficUp())
|
||||||
|
.build();
|
||||||
|
uCdr.setId(cdrId);
|
||||||
|
this.saveOrUpdate(uCdr);
|
||||||
|
return uCdr.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long addClient(ClientInfo client) {
|
private UClient addClient(ClientInfo client) {
|
||||||
// 用户设备
|
// 用户设备
|
||||||
UClient hasClient = clientService.getOne(Wrappers.<UClient>lambdaQuery().eq(UClient::getClientMac, client.getMac()), false);
|
UClient hasClient = clientService.getOne(Wrappers.<UClient>lambdaQuery().eq(UClient::getClientMac, client.getMac()), false);
|
||||||
Long clientId;
|
Long clientId = null;
|
||||||
if (ObjectUtil.isNull(hasClient)) {
|
Long userId = null;
|
||||||
UClient uClient = UClient.builder().clientMac(client.getMac())
|
if (ObjectUtil.isNotNull(hasClient)) {
|
||||||
.clientName(client.getName())
|
|
||||||
.clientDeviceType(client.getDeviceType())
|
|
||||||
.build();
|
|
||||||
clientService.save(uClient);
|
|
||||||
clientId = uClient.getId();
|
|
||||||
} else {
|
|
||||||
clientId = hasClient.getId();
|
clientId = hasClient.getId();
|
||||||
|
userId = hasClient.getUserId();
|
||||||
}
|
}
|
||||||
return clientId;
|
UClient uClient = UClient.builder().clientMac(client.getMac())
|
||||||
|
.userId(userId)
|
||||||
|
.clientName(client.getName())
|
||||||
|
.clientDeviceType(client.getDeviceType())
|
||||||
|
.build();
|
||||||
|
uClient.setId(clientId);
|
||||||
|
clientService.saveOrUpdate(uClient);
|
||||||
|
return uClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDevices(List<SiteSummaryInfo> sites) {
|
private void addDevices(List<SiteSummaryInfo> sites) {
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package org.wfc.user.service.impl;
|
package org.wfc.user.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.wfc.user.api.domain.bo.UClientBo;
|
||||||
import org.wfc.user.domain.UClient;
|
import org.wfc.user.domain.UClient;
|
||||||
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -17,4 +21,18 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class UClientServiceImpl extends ServiceImpl<UClientMapper, UClient> implements IUClientService {
|
public class UClientServiceImpl extends ServiceImpl<UClientMapper, UClient> implements IUClientService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean recordClientUser(UClientBo uClientBo) {
|
||||||
|
if (StrUtil.isBlank(uClientBo.getClientMac())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
UClient hasUClient = this.getOne(Wrappers.<UClient>lambdaQuery()
|
||||||
|
.eq(UClient::getClientMac, uClientBo.getClientMac()), false);
|
||||||
|
UClient uClient = new UClient();
|
||||||
|
BeanUtils.copyProperties(uClientBo, uClient);
|
||||||
|
if (hasUClient != null) {
|
||||||
|
uClient.setId(hasUClient.getId());
|
||||||
|
}
|
||||||
|
return this.saveOrUpdate(uClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!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.UCdrDetailMapper">
|
<mapper namespace="org.wfc.user.mapper.UCdrHistoryMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -2,4 +2,74 @@
|
|||||||
<!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.UCdrMapper">
|
<mapper namespace="org.wfc.user.mapper.UCdrMapper">
|
||||||
|
|
||||||
|
<select id="getByUser" resultType="org.wfc.user.domain.vo.UCdrUserVo">
|
||||||
|
SELECT
|
||||||
|
cdr.user_id id,
|
||||||
|
min( ch.start_time ) start_time,
|
||||||
|
max( cdr.last_seen_time ) end_time,
|
||||||
|
sum(
|
||||||
|
ifnull( cdr.up_time, 0 ))+ sum(
|
||||||
|
ifnull( ch.duration, 0 )) duration,
|
||||||
|
sum(
|
||||||
|
ifnull( cdr.traffic_down, 0 )) + sum(
|
||||||
|
ifnull( ch.traffic_down, 0 )) traffic_down,
|
||||||
|
sum(
|
||||||
|
ifnull( cdr.traffic_up, 0 )) + 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
|
||||||
|
WHERE
|
||||||
|
cdr.del_flag = 0
|
||||||
|
AND cdr.last_seen_time != ifnull( ch.end_time, 0 )
|
||||||
|
<if test="userId != null and userId != ''">
|
||||||
|
AND cdr.user_id = #{userId}
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
cdr.user_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getByClient" resultType="org.wfc.user.domain.vo.UCdrClientVo">
|
||||||
|
SELECT
|
||||||
|
c.id,
|
||||||
|
c.client_mac,
|
||||||
|
c.client_name,
|
||||||
|
c.client_device_type,
|
||||||
|
h.*
|
||||||
|
FROM
|
||||||
|
u_client c
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
cdr.client_id,
|
||||||
|
min( ch.start_time ) start_time,
|
||||||
|
max( cdr.last_seen_time ) end_time,
|
||||||
|
sum(
|
||||||
|
ifnull( cdr.up_time, 0 ))+ sum(
|
||||||
|
ifnull( ch.duration, 0 )) duration,
|
||||||
|
sum(
|
||||||
|
ifnull( cdr.traffic_down, 0 )) + sum(
|
||||||
|
ifnull( ch.traffic_down, 0 )) traffic_down,
|
||||||
|
sum(
|
||||||
|
ifnull( cdr.traffic_up, 0 )) + 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
|
||||||
|
WHERE
|
||||||
|
cdr.del_flag = 0
|
||||||
|
AND cdr.last_seen_time != ifnull( ch.end_time, 0 )
|
||||||
|
GROUP BY
|
||||||
|
cdr.client_id
|
||||||
|
) h ON c.id = h.client_id
|
||||||
|
WHERE
|
||||||
|
c.del_flag = 0
|
||||||
|
<if test="client.clientName != null and client.clientName != ''">
|
||||||
|
AND c.client_name like concat('%', #{client.clientName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="client.clientMac != null and client.clientMac != ''">
|
||||||
|
AND c.client_mac = like concat('%', #{client.clientMac}, '%')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ public class UClientTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
|
cdrService.addCdrInfoByOmadaApi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user