feat: 补充ap设备信息
This commit is contained in:
@@ -51,4 +51,7 @@ public interface RemoteUserService
|
|||||||
*/
|
*/
|
||||||
@PutMapping("/user/recordlogin")
|
@PutMapping("/user/recordlogin")
|
||||||
public R<Boolean> recordUserLogin(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
public R<Boolean> recordUserLogin(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
@PostMapping("/device/deviceJob")
|
||||||
|
public R<Boolean> deviceJob();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||||||
{
|
{
|
||||||
return R.fail("记录用户登录信息失败:" + throwable.getMessage());
|
return R.fail("记录用户登录信息失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<Boolean> deviceJob() {
|
||||||
|
return R.fail("记录设备信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.wfc.job.task;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.wfc.system.api.RemoteUserService;
|
||||||
import org.wfc.user.api.RemoteUUserService;
|
import org.wfc.user.api.RemoteUUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,9 +18,14 @@ public class CdrInfoTask {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RemoteUUserService remoteUUserService;
|
private RemoteUUserService remoteUUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
public void addCdrInfo() {
|
public void addCdrInfo() {
|
||||||
log.info("开始执行话单信息任务");
|
long startTime = System.currentTimeMillis();
|
||||||
remoteUUserService.addCdrInfoByOmadaApi();
|
remoteUUserService.addCdrInfoByOmadaApi();
|
||||||
log.info("话单信息任务执行成功");
|
remoteUserService.deviceJob();
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
log.info("wifi定时任务执行成功, 耗时:{} 毫秒", endTime - startTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.wfc.system.controller;
|
package org.wfc.system.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -13,57 +14,64 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import org.wfc.common.core.web.controller.BaseController;
|
import org.wfc.common.core.web.controller.BaseController;
|
||||||
import org.wfc.common.core.web.domain.AjaxResult;
|
import org.wfc.common.core.web.domain.AjaxResult;
|
||||||
import org.wfc.common.core.web.page.TableDataInfo;
|
import org.wfc.common.core.web.page.TableDataInfo;
|
||||||
import org.wfc.system.domain.UDevice;
|
import org.wfc.system.domain.SysDevice;
|
||||||
import org.wfc.system.service.IUDeviceService;
|
import org.wfc.system.service.ISysDeviceService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 用户平台_AP设备表 前端控制器
|
* 客户平台-设备表 前端控制器
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author sys
|
* @author sys
|
||||||
* @since 2025-01-03
|
* @since 2025-01-07
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/device")
|
@RequestMapping("/device")
|
||||||
public class UDeviceController extends BaseController {
|
public class SysDeviceController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUDeviceService uDeviceService;
|
private ISysDeviceService sysDeviceService;
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public TableDataInfo page(UDevice uDevice) {
|
public TableDataInfo page(SysDevice sysDevice) {
|
||||||
startPage();
|
startPage();
|
||||||
List<UDevice> list = uDeviceService.list();
|
List<SysDevice> list = sysDeviceService.list(Wrappers.<SysDevice>lambdaQuery()
|
||||||
|
.like(SysDevice::getName, sysDevice.getName())
|
||||||
|
.like(SysDevice::getMac, sysDevice.getMac()));
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(UDevice uDevice) {
|
public AjaxResult list(SysDevice sysDevice) {
|
||||||
List<UDevice> list = uDeviceService.list();
|
List<SysDevice> list = sysDeviceService.list();
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public AjaxResult getById(@PathVariable("id") Long id) {
|
public AjaxResult getById(@PathVariable("id") Long id) {
|
||||||
return success(uDeviceService.getById(id));
|
return success(sysDeviceService.getById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody UDevice uDevice) {
|
public AjaxResult add(@RequestBody SysDevice sysDevice) {
|
||||||
return toAjax(uDeviceService.save(uDevice));
|
return toAjax(sysDeviceService.save(sysDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody UDevice uDevice) {
|
public AjaxResult edit(@RequestBody SysDevice sysDevice) {
|
||||||
return toAjax(uDeviceService.updateById(uDevice));
|
return toAjax(sysDeviceService.updateById(sysDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
return toAjax(uDeviceService.removeByIds(CollUtil.newArrayList(ids)));
|
return toAjax(sysDeviceService.removeByIds(CollUtil.newArrayList(ids)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deviceJob")
|
||||||
|
public AjaxResult deviceJob() {
|
||||||
|
return toAjax(sysDeviceService.deviceJob());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package org.wfc.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import org.wfc.common.mybatis.domain.BaseData;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 客户平台-设备表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author sys
|
||||||
|
* @since 2025-01-07
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("sys_device")
|
||||||
|
@Schema(name = "SysDevice", description = "客户平台-设备表")
|
||||||
|
public class SysDevice extends BaseData {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "siteId")
|
||||||
|
private String siteId;
|
||||||
|
|
||||||
|
@Schema(description = "mac")
|
||||||
|
private String mac;
|
||||||
|
|
||||||
|
@Schema(description = "name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "type")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@Schema(description = "subtype")
|
||||||
|
private String subtype;
|
||||||
|
|
||||||
|
@Schema(description = "deviceSeriesType")
|
||||||
|
private String deviceSeriesType;
|
||||||
|
|
||||||
|
@Schema(description = "model")
|
||||||
|
private String model;
|
||||||
|
|
||||||
|
@Schema(description = "ip")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@Schema(description = "ipv6s")
|
||||||
|
private String ipv6s;
|
||||||
|
|
||||||
|
@Schema(description = "uptime")
|
||||||
|
private String uptime;
|
||||||
|
|
||||||
|
@Schema(description = "status")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "lastSeen")
|
||||||
|
private Long lastSeen;
|
||||||
|
|
||||||
|
@Schema(description = "cpuUtil")
|
||||||
|
private Integer cpuUtil;
|
||||||
|
|
||||||
|
@Schema(description = "memUtil")
|
||||||
|
private Integer memUtil;
|
||||||
|
|
||||||
|
@Schema(description = "sn")
|
||||||
|
private String sn;
|
||||||
|
|
||||||
|
@Schema(description = "licenseStatus")
|
||||||
|
private Integer licenseStatus;
|
||||||
|
|
||||||
|
@Schema(description = "tagName")
|
||||||
|
private String tagName;
|
||||||
|
|
||||||
|
@Schema(description = "uplinkDeviceMac")
|
||||||
|
private String uplinkDeviceMac;
|
||||||
|
|
||||||
|
@Schema(description = "uplink_device_name")
|
||||||
|
private String uplinkDeviceName;
|
||||||
|
|
||||||
|
@Schema(description = "uplinkDevicePort")
|
||||||
|
private String uplinkDevicePort;
|
||||||
|
|
||||||
|
@Schema(description = "linkSpeed")
|
||||||
|
private Integer linkSpeed;
|
||||||
|
|
||||||
|
@Schema(description = "duplex")
|
||||||
|
private Integer duplex;
|
||||||
|
|
||||||
|
@Schema(description = "switchConsistent")
|
||||||
|
private Boolean switchConsistent;
|
||||||
|
|
||||||
|
@Schema(description = "publicIp")
|
||||||
|
private String publicIp;
|
||||||
|
|
||||||
|
@Schema(description = "firmwareVersion")
|
||||||
|
private String firmwareVersion;
|
||||||
|
}
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package org.wfc.system.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import org.wfc.common.mybatis.domain.BaseData;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 用户平台_AP设备表
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author sys
|
|
||||||
* @since 2025-01-03
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@TableName("u_device")
|
|
||||||
@Schema(name = "UDevice", description = "用户平台_AP设备表")
|
|
||||||
public class UDevice extends BaseData {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Schema(description = "User ID link to u_user")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
@Schema(description = "Device Name")
|
|
||||||
private String deviceName;
|
|
||||||
|
|
||||||
@Schema(description = "Device ip")
|
|
||||||
private String deviceIp;
|
|
||||||
|
|
||||||
@Schema(description = "Device mac")
|
|
||||||
private String deviceMac;
|
|
||||||
|
|
||||||
@Schema(description = "Device model")
|
|
||||||
private String deviceModel;
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,13 @@ package org.wfc.system.domain.convert;
|
|||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
import org.wfc.omada.api.device.model.DeviceInfo;
|
||||||
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
||||||
|
import org.wfc.system.domain.SysDevice;
|
||||||
import org.wfc.system.domain.vo.SysDashboardSiteVo;
|
import org.wfc.system.domain.vo.SysDashboardSiteVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: OmadaMapping
|
* @description: OmadaMapping
|
||||||
* @author: cyc
|
* @author: cyc
|
||||||
@@ -17,4 +21,6 @@ public interface SysDashboardConvert {
|
|||||||
|
|
||||||
SysDashboardSiteVo toSysDashboardSiteVo(SiteSummaryInfo siteSummaryInfo);
|
SysDashboardSiteVo toSysDashboardSiteVo(SiteSummaryInfo siteSummaryInfo);
|
||||||
|
|
||||||
|
List<SysDevice> toSysDevices(List<DeviceInfo> deviceInfos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.wfc.system.mapper;
|
||||||
|
|
||||||
|
import org.wfc.system.domain.SysDevice;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 客户平台-设备表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author sys
|
||||||
|
* @since 2025-01-07
|
||||||
|
*/
|
||||||
|
public interface SysDeviceMapper extends BaseMapper<SysDevice> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package org.wfc.system.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
||||||
import org.wfc.system.domain.UDevice;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 用户平台_AP设备表 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author sys
|
|
||||||
* @since 2025-01-03
|
|
||||||
*/
|
|
||||||
@DS("user")
|
|
||||||
public interface UDeviceMapper extends BaseMapper<UDevice> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.wfc.system.service;
|
||||||
|
|
||||||
|
import org.wfc.system.domain.SysDevice;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 客户平台-设备表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author sys
|
||||||
|
* @since 2025-01-07
|
||||||
|
*/
|
||||||
|
public interface ISysDeviceService extends IService<SysDevice> {
|
||||||
|
|
||||||
|
boolean deviceJob();
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package org.wfc.system.service;
|
|
||||||
|
|
||||||
import org.wfc.system.domain.UDevice;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 用户平台_AP设备表 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author sys
|
|
||||||
* @since 2025-01-03
|
|
||||||
*/
|
|
||||||
public interface IUDeviceService extends IService<UDevice> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package org.wfc.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.wfc.omada.api.device.OmadaDeviceApi;
|
||||||
|
import org.wfc.omada.api.device.model.DeviceInfo;
|
||||||
|
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.system.domain.SysDevice;
|
||||||
|
import org.wfc.system.domain.convert.SysDashboardConvert;
|
||||||
|
import org.wfc.system.mapper.SysDeviceMapper;
|
||||||
|
import org.wfc.system.service.ISysDeviceService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 客户平台-设备表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author sys
|
||||||
|
* @since 2025-01-07
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice> implements ISysDeviceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OmadaSiteApi omadaSiteApi;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OmadaDeviceApi omadaDeviceApi;
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean deviceJob() {
|
||||||
|
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(1, 1000);
|
||||||
|
if (siteList.getBody() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
List<SiteSummaryInfo> sites = siteList.getBody().getResult().getData();
|
||||||
|
for (SiteSummaryInfo site : sites) {
|
||||||
|
ResponseEntity<OperationResponseGridVoDeviceInfo> deviceList = omadaDeviceApi.getDeviceList(site.getSiteId(), 1, 1000);
|
||||||
|
if (deviceList.getBody() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<DeviceInfo> devices = deviceList.getBody().getResult().getData();
|
||||||
|
if (CollUtil.isEmpty(devices)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<String> macs = devices.stream().map(DeviceInfo::getMac).collect(Collectors.toList());
|
||||||
|
List<SysDevice> sysDevices = SysDashboardConvert.INSTANCE.toSysDevices(devices);
|
||||||
|
List<SysDevice> sysDeviceList = this.list(Wrappers.<SysDevice>lambdaQuery().in(SysDevice::getMac, macs));
|
||||||
|
for (SysDevice device : sysDevices) {
|
||||||
|
device.setSiteId(site.getSiteId());
|
||||||
|
for (SysDevice sysDevice : sysDeviceList) {
|
||||||
|
if (Objects.equals(device.getMac(), sysDevice.getMac())) {
|
||||||
|
device.setId(sysDevice.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.saveOrUpdateBatch(sysDevices);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package org.wfc.system.service.impl;
|
|
||||||
|
|
||||||
import org.wfc.system.domain.UDevice;
|
|
||||||
import org.wfc.system.mapper.UDeviceMapper;
|
|
||||||
import org.wfc.system.service.IUDeviceService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 用户平台_AP设备表 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author sys
|
|
||||||
* @since 2025-01-03
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class UDeviceServiceImpl extends ServiceImpl<UDeviceMapper, UDevice> implements IUDeviceService {
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user