feat: 增加sn管理接口
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.youlai.boot.device.service;
|
||||
|
||||
import com.youlai.boot.device.model.req.ApkInstallInfoReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ApkInstallService {
|
||||
|
||||
boolean saveOrUpdateDeviceApkInfo(String sn, List<ApkInstallInfoReq> apkInfos);
|
||||
|
||||
List<ApkInstallInfoReq> getDeviceApkInfo(String sn);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.youlai.boot.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.device.model.entity.SnContact;
|
||||
import com.youlai.boot.device.model.form.ContactForm;
|
||||
import com.youlai.boot.device.model.query.ContactQuery;
|
||||
import com.youlai.boot.device.model.vo.ContactVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ContactService extends IService<SnContact> {
|
||||
|
||||
IPage<ContactVO> getContactPage(ContactQuery queryParams);
|
||||
|
||||
List<ContactVO> getAllContacts(String sn);
|
||||
|
||||
Long saveContact(String sn, ContactForm contactForm);
|
||||
|
||||
ContactForm getContactForm(Long id, String sn);
|
||||
|
||||
boolean updateContact(Long id, String sn, ContactForm contactForm);
|
||||
|
||||
boolean deleteContact(Long id, String sn);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.youlai.boot.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.device.model.entity.SnDeveloper;
|
||||
|
||||
/**
|
||||
* 设备开发者选项服务接口
|
||||
*/
|
||||
public interface DeveloperService extends IService<SnDeveloper> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.youlai.boot.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.device.model.entity.SnDeviceInfo;
|
||||
import com.youlai.boot.device.model.query.DeviceQuery;
|
||||
import com.youlai.boot.device.model.vo.DeviceHardwareVO;
|
||||
import com.youlai.boot.device.model.vo.DevicePageVO;
|
||||
|
||||
|
||||
public interface DeviceService extends IService<SnDeviceInfo> {
|
||||
|
||||
/**
|
||||
* 用户分页列表
|
||||
*
|
||||
* @return {@link IPage<DevicePageVO>} 用户分页列表
|
||||
*/
|
||||
IPage<DevicePageVO> getSnPage(DeviceQuery queryParams);
|
||||
|
||||
/**
|
||||
* 获取设备详情
|
||||
*
|
||||
* @param sn 设备序列号
|
||||
* @return 设备详情信息
|
||||
*/
|
||||
DevicePageVO getSnBindInfo(String sn);
|
||||
/**
|
||||
* 获取设备硬件信息
|
||||
*
|
||||
* @param sn 设备序列号
|
||||
* @return 设备硬件信息
|
||||
*/
|
||||
DeviceHardwareVO getSnHardwareInfo(String sn);
|
||||
|
||||
/**
|
||||
* 添加设备
|
||||
* @param device 设备信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean addSn(SnDeviceInfo device);
|
||||
|
||||
/**
|
||||
* 删除设备
|
||||
* @param sn 设备序列号
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteSn(String sn);
|
||||
|
||||
boolean deviceRefresh(String sn);
|
||||
/**
|
||||
* 截图
|
||||
* @param sn 序列号
|
||||
* @return 是否推送成功
|
||||
*/
|
||||
boolean screenSnapshot(String sn);
|
||||
|
||||
boolean deviceReboot(String sn);
|
||||
boolean deviceShutdown(String sn);
|
||||
boolean deviceLocate(String sn);
|
||||
|
||||
/**
|
||||
* 恢复出厂设置
|
||||
* @param sn 序列号
|
||||
* @return 是否推送成功
|
||||
*/
|
||||
boolean restore(String sn);
|
||||
|
||||
boolean setDeviceDeveloper(String sn);
|
||||
|
||||
/**
|
||||
* 新增开发者选项配置
|
||||
*
|
||||
* @param sn 设备序列号
|
||||
* @param developerOptions 开发者选项开关(0关闭,1开启)
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean addDeveloperConfig(String sn, Integer developerOptions);
|
||||
|
||||
/**
|
||||
* 删除开发者选项配置
|
||||
*
|
||||
* @param sn 设备序列号
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteDeveloperConfig(String sn);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.youlai.boot.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.device.model.entity.SnDeviceHardware;
|
||||
|
||||
public interface HardwareService extends IService<SnDeviceHardware> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.youlai.boot.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.device.model.entity.SnLocation;
|
||||
|
||||
/**
|
||||
* 设备定位服务接口
|
||||
*/
|
||||
public interface LocationService extends IService<SnLocation> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.youlai.boot.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.device.model.entity.SnScreenshot;
|
||||
|
||||
public interface ScreenshotService extends IService<SnScreenshot> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.youlai.boot.device.service;
|
||||
|
||||
public interface StorageService {
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.youlai.boot.device.service.impl;
|
||||
|
||||
import com.youlai.boot.device.model.document.ApkInstallDocument;
|
||||
import com.youlai.boot.device.model.req.ApkInstallInfoReq;
|
||||
import com.youlai.boot.device.repository.ApkInstallRepository;
|
||||
import com.youlai.boot.device.service.ApkInstallService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ApkInstallServiceImpl implements ApkInstallService {
|
||||
|
||||
private final ApkInstallRepository apkInstallRepository;
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdateDeviceApkInfo(String sn, List<ApkInstallInfoReq> apkInfos) {
|
||||
if (apkInfos == null || apkInfos.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<ApkInstallDocument> existingOpt = apkInstallRepository.findBySn(sn);
|
||||
ApkInstallDocument document;
|
||||
|
||||
if (existingOpt.isPresent()) {
|
||||
document = existingOpt.get();
|
||||
} else {
|
||||
document = new ApkInstallDocument();
|
||||
document.setSn(sn);
|
||||
document.setCreateTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
List<ApkInstallDocument.ApkInfo> apkInfoList = apkInfos.stream().map(req -> {
|
||||
ApkInstallDocument.ApkInfo apkInfo = new ApkInstallDocument.ApkInfo();
|
||||
BeanUtils.copyProperties(req, apkInfo);
|
||||
|
||||
if (req.getInstallTime() != null) {
|
||||
apkInfo.setInstallTime(LocalDateTime.ofInstant(
|
||||
req.getInstallTime().toInstant(), ZoneId.systemDefault()));
|
||||
}
|
||||
|
||||
if (req.getLastUpdateTime() != null) {
|
||||
apkInfo.setLastUpdateTime(LocalDateTime.ofInstant(
|
||||
req.getLastUpdateTime().toInstant(), ZoneId.systemDefault()));
|
||||
}
|
||||
|
||||
return apkInfo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
document.setApkList(apkInfoList);
|
||||
document.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
apkInstallRepository.save(document);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApkInstallInfoReq> getDeviceApkInfo(String sn) {
|
||||
Optional<ApkInstallDocument> documentOpt = apkInstallRepository.findBySn(sn);
|
||||
|
||||
if (!documentOpt.isPresent() || documentOpt.get().getApkList() == null) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
ApkInstallDocument document = documentOpt.get();
|
||||
List<ApkInstallDocument.ApkInfo> apkInfoList = document.getApkList();
|
||||
|
||||
return apkInfoList.stream().map(apkInfo -> {
|
||||
ApkInstallInfoReq req = new ApkInstallInfoReq();
|
||||
BeanUtils.copyProperties(apkInfo, req);
|
||||
|
||||
if (apkInfo.getInstallTime() != null) {
|
||||
req.setInstallTime(Date.from(apkInfo.getInstallTime().atZone(ZoneId.systemDefault()).toInstant()));
|
||||
}
|
||||
|
||||
if (apkInfo.getLastUpdateTime() != null) {
|
||||
req.setLastUpdateTime(Date.from(apkInfo.getLastUpdateTime().atZone(ZoneId.systemDefault()).toInstant()));
|
||||
}
|
||||
|
||||
return req;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.youlai.boot.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.device.converter.ContactConverter;
|
||||
import com.youlai.boot.device.mapper.ContactMapper;
|
||||
import com.youlai.boot.device.model.entity.SnContact;
|
||||
import com.youlai.boot.device.model.form.ContactForm;
|
||||
import com.youlai.boot.device.model.query.ContactQuery;
|
||||
import com.youlai.boot.device.model.vo.ContactVO;
|
||||
import com.youlai.boot.device.service.ContactService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ContactServiceImpl extends ServiceImpl<ContactMapper, SnContact> implements ContactService {
|
||||
|
||||
private final ContactConverter contactConverter;
|
||||
|
||||
@Override
|
||||
public IPage<ContactVO> getContactPage(ContactQuery queryParams) {
|
||||
int pageNum = queryParams.getPageNum();
|
||||
int pageSize = queryParams.getPageSize();
|
||||
Page<SnContact> page = new Page<>(pageNum, pageSize);
|
||||
|
||||
// String keywords = queryParams.getKeywords();
|
||||
// Boolean isEmergency = queryParams.getIsEmergency();
|
||||
// Boolean show = queryParams.getShow();
|
||||
String bindSn = queryParams.getBindSn();
|
||||
|
||||
LambdaQueryWrapper<SnContact> wrapper = new LambdaQueryWrapper<SnContact>()
|
||||
// .and(StringUtils.isNotBlank(keywords),
|
||||
// w -> w.like(SnContact::getName, keywords)
|
||||
// .or()
|
||||
// .like(SnContact::getNick_name, keywords)
|
||||
// .or()
|
||||
// .like(SnContact::getPhone_number, keywords)
|
||||
// )
|
||||
// .eq(isEmergency != null, SnContact::is_emergency, isEmergency)
|
||||
// .eq(show != null, SnContact::is_show, show)
|
||||
.eq(StringUtils.isNotBlank(bindSn), SnContact::getBindSn, bindSn)
|
||||
.orderByDesc(SnContact::getCreateTime);
|
||||
|
||||
Page<SnContact> contactPage = this.page(page, wrapper);
|
||||
return contactConverter.toPageVo(contactPage);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ContactVO> getAllContacts(String sn) {
|
||||
Assert.isTrue(sn != null && !sn.trim().isEmpty(), "设备序列号不能为空");
|
||||
|
||||
LambdaQueryWrapper<SnContact> wrapper = new LambdaQueryWrapper<SnContact>()
|
||||
.eq(SnContact::getBindSn, sn)
|
||||
.orderByDesc(SnContact::getUpdateTime);
|
||||
|
||||
List<SnContact> contacts = this.list(wrapper);
|
||||
return contactConverter.toVoList(contacts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long saveContact(String sn, ContactForm contactForm) {
|
||||
Assert.isTrue(sn != null && !sn.trim().isEmpty(), "设备序列号不能为空");
|
||||
|
||||
// 检查是否已存在相同的电话号码和设备SN组合
|
||||
LambdaQueryWrapper<SnContact> wrapper = new LambdaQueryWrapper<SnContact>()
|
||||
.eq(SnContact::getPhoneNumber, contactForm.getPhoneNumber())
|
||||
.eq(SnContact::getBindSn, sn);
|
||||
|
||||
long count = this.count(wrapper);
|
||||
if (count > 0) {
|
||||
// 如果存在重复,返回 null 表示失败
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
SnContact contact = contactConverter.toEntity(contactForm);
|
||||
if (contact.getId() < 0) {
|
||||
contact.setId(null);
|
||||
}
|
||||
contact.setBindSn(sn);
|
||||
|
||||
if (contact.getCreateTime() == null) {
|
||||
contact.setCreateTime(LocalDateTime.now());
|
||||
}
|
||||
if (contact.getUpdateTime() == null) {
|
||||
contact.setUpdateTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
if (contact.getPosition() == 0) {
|
||||
LambdaQueryWrapper<SnContact> positionWrapper = new LambdaQueryWrapper<SnContact>()
|
||||
.eq(SnContact::getBindSn, sn)
|
||||
.orderByDesc(SnContact::getPosition)
|
||||
.last("LIMIT 1");
|
||||
SnContact lastContact = this.getOne(positionWrapper);
|
||||
int newPosition = (lastContact != null) ? lastContact.getPosition() + 1 : 1;
|
||||
contact.setPosition(newPosition);
|
||||
}
|
||||
|
||||
// contact.setCreateBy(SecurityUtils.getUserId());
|
||||
if (this.save(contact)) {
|
||||
return contact.getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactForm getContactForm(Long id, String sn) {
|
||||
Assert.isTrue(sn != null && !sn.trim().isEmpty(), "设备序列号不能为空");
|
||||
|
||||
SnContact contact = this.getById(id);
|
||||
Assert.isTrue(contact != null, "联系人不存在");
|
||||
Assert.isTrue(sn.equals(contact.getBindSn()), "无权访问该联系人数据");
|
||||
|
||||
return contactConverter.toForm(contact);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateContact(Long id, String sn, ContactForm contactForm) {
|
||||
Assert.isTrue(sn != null && !sn.trim().isEmpty(), "设备序列号不能为空");
|
||||
|
||||
SnContact existingContact = this.getById(id);
|
||||
Assert.isTrue(existingContact != null, "联系人不存在");
|
||||
Assert.isTrue(sn.equals(existingContact.getBindSn()), "无权修改该联系人数据");
|
||||
|
||||
SnContact contact = contactConverter.toEntity(contactForm);
|
||||
contact.setId(id);
|
||||
contact.setBindSn(sn);
|
||||
// contact.setUpdateBy(SecurityUtils.getUserId());
|
||||
return this.updateById(contact);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteContact(Long id, String sn) {
|
||||
Assert.isTrue(sn != null && !sn.trim().isEmpty(), "设备序列号不能为空");
|
||||
|
||||
SnContact contact = this.getById(id);
|
||||
Assert.isTrue(contact != null, "联系人不存在");
|
||||
Assert.isTrue(sn.equals(contact.getBindSn()), "无权删除该联系人数据");
|
||||
|
||||
return this.removeById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.youlai.boot.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.device.mapper.DeveloperMapper;
|
||||
import com.youlai.boot.device.model.entity.SnDeveloper;
|
||||
import com.youlai.boot.device.service.DeveloperService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 设备开发者选项服务实现类
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeveloperServiceImpl extends ServiceImpl<DeveloperMapper, SnDeveloper> implements DeveloperService {
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
package com.youlai.boot.device.service.impl;
|
||||
|
||||
import cn.jiguang.sdk.api.PushApi;
|
||||
import cn.jiguang.sdk.bean.push.PushSendParam;
|
||||
import cn.jiguang.sdk.bean.push.PushSendResult;
|
||||
import cn.jiguang.sdk.bean.push.message.custom.CustomMessage;
|
||||
import cn.jiguang.sdk.exception.ApiErrorException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.framework.security.util.SecurityUtils;
|
||||
import com.youlai.boot.device.mapper.DeviceMapper;
|
||||
import com.youlai.boot.device.model.entity.SnDeviceInfo;
|
||||
import com.youlai.boot.device.model.entity.SnDeveloper;
|
||||
import com.youlai.boot.device.model.query.DeviceQuery;
|
||||
import com.youlai.boot.device.model.vo.DeviceHardwareVO;
|
||||
import com.youlai.boot.device.model.vo.DevicePageVO;
|
||||
import com.youlai.boot.device.service.DeveloperService;
|
||||
import com.youlai.boot.device.service.DeviceService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 设备控制实现类
|
||||
* @author TTSTD
|
||||
* @since 2026/04/06
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, SnDeviceInfo> implements DeviceService {
|
||||
PushApi pushApi = new PushApi.Builder()
|
||||
.setAppKey("d779178d9900d4fb5d633678")
|
||||
.setMasterSecret("be0e197d30fec7bec118a70d")
|
||||
.build();
|
||||
|
||||
private final DeveloperService developerService;
|
||||
|
||||
@Override
|
||||
public IPage<DevicePageVO> getSnPage(DeviceQuery queryParams) {
|
||||
// 参数构建
|
||||
int pageNum = queryParams.getPageNum();
|
||||
int pageSize = queryParams.getPageSize();
|
||||
Page<DevicePageVO> page = new Page<>(pageNum, pageSize);
|
||||
|
||||
boolean isRoot = SecurityUtils.isRoot();
|
||||
queryParams.setIsRoot(isRoot);
|
||||
|
||||
// 查询数据
|
||||
return this.baseMapper.getSnPage(page, queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePageVO getSnBindInfo(String sn) {
|
||||
// 根据SN查询设备详情
|
||||
LambdaQueryWrapper<SnDeviceInfo> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SnDeviceInfo::getSerialno, sn);
|
||||
|
||||
SnDeviceInfo device = this.getOne(wrapper);
|
||||
if (device == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 这里可以扩展查询更多详细信息,如部门、角色等
|
||||
DevicePageVO devicePageVO = new DevicePageVO();
|
||||
BeanUtils.copyProperties(device, devicePageVO);
|
||||
|
||||
return devicePageVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceHardwareVO getSnHardwareInfo(String sn) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addSn(SnDeviceInfo device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteSn(String sn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private PushSendParam getSinglePushSendParam(String sn, String type, String title, String content) {
|
||||
PushSendParam pushSendParam = new PushSendParam();
|
||||
pushSendParam.setPlatform("android");
|
||||
Map<String, Set<String>> aaudience = new HashMap<>();
|
||||
Set<String> aliasSet = new HashSet<>();
|
||||
aliasSet.add(sn);
|
||||
aaudience.put("alias", aliasSet);
|
||||
pushSendParam.setAudience(aaudience);
|
||||
CustomMessage customMessage = new CustomMessage();
|
||||
customMessage.setTitle(title);
|
||||
customMessage.setContentType(type);
|
||||
customMessage.setContent(content);
|
||||
customMessage.setExtras(new HashMap<>());
|
||||
pushSendParam.setCustom(customMessage);
|
||||
|
||||
return pushSendParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deviceRefresh(String sn) {
|
||||
PushSendParam pushSendParam = getSinglePushSendParam(sn, "1", "deviceRefresh", "refresh");
|
||||
try {
|
||||
PushSendResult result = pushApi.send(pushSendParam);
|
||||
log.info("send success:{}", result);
|
||||
return true;
|
||||
} catch (ApiErrorException e) {
|
||||
// 错误信息
|
||||
int httpStatus = e.getStats(); // HTTP状态码
|
||||
int errorCode = e.getApiError().getError().getCode(); // 错误码
|
||||
String errorMessage = e.getApiError().getError().getMessage(); // 错误信息
|
||||
log.error("send error, httpStatus:{} code:{}, message:{}", httpStatus, errorCode, errorMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean screenSnapshot(String sn) {
|
||||
PushSendParam pushSendParam = getSinglePushSendParam(sn, "2", "screenSnapshot", "screenshot");
|
||||
try {
|
||||
PushSendResult result = pushApi.send(pushSendParam);
|
||||
log.info("send success:{}", result);
|
||||
return true;
|
||||
} catch (ApiErrorException e) {
|
||||
// 错误信息
|
||||
int httpStatus = e.getStats(); // HTTP状态码
|
||||
int errorCode = e.getApiError().getError().getCode(); // 错误码
|
||||
String errorMessage = e.getApiError().getError().getMessage(); // 错误信息
|
||||
log.error("send error, httpStatus:{} code:{}, message:{}", httpStatus, errorCode, errorMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deviceReboot(String sn) {
|
||||
PushSendParam pushSendParam = getSinglePushSendParam(sn, "3", "deviceReboot", "reboot");
|
||||
try {
|
||||
PushSendResult result = pushApi.send(pushSendParam);
|
||||
log.info("send success:{}", result);
|
||||
return true;
|
||||
} catch (ApiErrorException e) {
|
||||
// 错误信息
|
||||
int httpStatus = e.getStats(); // HTTP状态码
|
||||
int errorCode = e.getApiError().getError().getCode(); // 错误码
|
||||
String errorMessage = e.getApiError().getError().getMessage(); // 错误信息
|
||||
log.error("send error, httpStatus:{} code:{}, message:{}", httpStatus, errorCode, errorMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deviceShutdown(String sn) {
|
||||
PushSendParam pushSendParam = getSinglePushSendParam(sn, "4", "deviceShutdown", "shutdown");
|
||||
try {
|
||||
PushSendResult result = pushApi.send(pushSendParam);
|
||||
log.info("send success:{}", result);
|
||||
return true;
|
||||
} catch (ApiErrorException e) {
|
||||
// 错误信息
|
||||
int httpStatus = e.getStats(); // HTTP状态码
|
||||
int errorCode = e.getApiError().getError().getCode(); // 错误码
|
||||
String errorMessage = e.getApiError().getError().getMessage(); // 错误信息
|
||||
log.error("send error, httpStatus:{} code:{}, message:{}", httpStatus, errorCode, errorMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deviceLocate(String sn) {
|
||||
PushSendParam pushSendParam = getSinglePushSendParam(sn, "5", "deviceLocate", "locate");
|
||||
try {
|
||||
PushSendResult result = pushApi.send(pushSendParam);
|
||||
log.info("send success:{}", result);
|
||||
return true;
|
||||
} catch (ApiErrorException e) {
|
||||
// 错误信息
|
||||
int httpStatus = e.getStats(); // HTTP状态码
|
||||
int errorCode = e.getApiError().getError().getCode(); // 错误码
|
||||
String errorMessage = e.getApiError().getError().getMessage(); // 错误信息
|
||||
log.error("send error, httpStatus:{} code:{}, message:{}", httpStatus, errorCode, errorMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restore(String sn) {
|
||||
PushSendParam pushSendParam = getSinglePushSendParam(sn, "6", "deviceRestore", "restore");
|
||||
try {
|
||||
PushSendResult result = pushApi.send(pushSendParam);
|
||||
log.info("send success:{}", result);
|
||||
return true;
|
||||
} catch (ApiErrorException e) {
|
||||
// 错误信息
|
||||
int httpStatus = e.getStats(); // HTTP状态码
|
||||
int errorCode = e.getApiError().getError().getCode(); // 错误码
|
||||
String errorMessage = e.getApiError().getError().getMessage(); // 错误信息
|
||||
log.error("send error, httpStatus:{} code:{}, message:{}", httpStatus, errorCode, errorMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setDeviceDeveloper(String sn) {
|
||||
PushSendParam pushSendParam = getSinglePushSendParam(sn, "7", "deviceDeveloper", "developer");
|
||||
try {
|
||||
PushSendResult result = pushApi.send(pushSendParam);
|
||||
log.info("send success:{}", result);
|
||||
return true;
|
||||
} catch (ApiErrorException e) {
|
||||
// 错误信息
|
||||
int httpStatus = e.getStats(); // HTTP状态码
|
||||
int errorCode = e.getApiError().getError().getCode(); // 错误码
|
||||
String errorMessage = e.getApiError().getError().getMessage(); // 错误信息
|
||||
log.error("send error, httpStatus:{} code:{}, message:{}", httpStatus, errorCode, errorMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDeveloperConfig(String sn, Integer developerOptions) {
|
||||
try {
|
||||
// 检查是否已存在该设备的配置
|
||||
SnDeveloper existingConfig = developerService.lambdaQuery()
|
||||
.eq(SnDeveloper::getSn, sn)
|
||||
.one();
|
||||
|
||||
SnDeveloper developerConfig = new SnDeveloper();
|
||||
developerConfig.setSn(sn);
|
||||
developerConfig.setDeveloperOptions(developerOptions);
|
||||
|
||||
boolean result;
|
||||
if (existingConfig != null) {
|
||||
// 如果已存在,则更新
|
||||
developerConfig.setId(existingConfig.getId());
|
||||
result = developerService.updateById(developerConfig);
|
||||
log.info("更新开发者选项配置成功, sn: {}, developerOptions: {}", sn, developerOptions);
|
||||
} else {
|
||||
// 如果不存在,则新增
|
||||
result = developerService.save(developerConfig);
|
||||
log.info("新增开发者选项配置成功, sn: {}, developerOptions: {}", sn, developerOptions);
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("新增开发者选项配置失败, sn: {}", sn, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDeveloperConfig(String sn) {
|
||||
try {
|
||||
boolean result = developerService.lambdaUpdate()
|
||||
.eq(SnDeveloper::getSn, sn)
|
||||
.remove();
|
||||
|
||||
if (result) {
|
||||
log.info("删除开发者选项配置成功, sn: {}", sn);
|
||||
} else {
|
||||
log.warn("删除开发者选项配置失败,记录不存在, sn: {}", sn);
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("删除开发者选项配置失败, sn: {}", sn, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.youlai.boot.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.device.mapper.HardwareMapper;
|
||||
import com.youlai.boot.device.model.entity.SnDeviceHardware;
|
||||
import com.youlai.boot.device.service.HardwareService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class HardwareServiceImpl extends ServiceImpl<HardwareMapper, SnDeviceHardware> implements HardwareService {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.youlai.boot.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.device.mapper.LocationMapper;
|
||||
import com.youlai.boot.device.model.entity.SnLocation;
|
||||
import com.youlai.boot.device.service.LocationService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 设备定位服务实现类
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LocationServiceImpl extends ServiceImpl<LocationMapper, SnLocation> implements LocationService {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.youlai.boot.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.device.mapper.ScreenshotMapper;
|
||||
import com.youlai.boot.device.model.entity.SnScreenshot;
|
||||
import com.youlai.boot.device.service.ScreenshotService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, SnScreenshot> implements ScreenshotService {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user