Merge branch 'main' into dyf-device

This commit is contained in:
2025-09-11 14:41:41 +08:00
29 changed files with 734 additions and 6 deletions

View File

@ -0,0 +1,160 @@
package com.fuyuanshen.web.controller.device;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.fuyuanshen.app.domain.bo.AppOperationVideoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.AppFileDto;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.web.domain.Dto.DeviceDebugEditDto;
import com.fuyuanshen.web.domain.Dto.DeviceDebugLogoUploadDto;
import com.fuyuanshen.web.domain.vo.DeviceInfoVo;
import com.fuyuanshen.web.service.device.DeviceBizService;
import com.fuyuanshen.web.service.device.DeviceDebugService;
import com.fuyuanshen.web.service.device.DeviceXinghanBizService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* 联调中心
*
* @author Lion Li
* @date 2025-08-28
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("api/device/debug")
public class DeviceDebugController extends BaseController {
private final DeviceBizService appDeviceService;
private final DeviceXinghanBizService deviceXinghanBizService;
private final DeviceDebugService deviceDebugService;
/**
* 查询设备列表
*/
@GetMapping("/list")
public TableDataInfo<WebDeviceVo> list(DeviceQueryCriteria bo, PageQuery pageQuery) {
return appDeviceService.queryWebDeviceList(bo, pageQuery);
}
/**
* 上传文件
*/
@Log(title = "批量上传文件")
@PostMapping("/addFile")
public R<Void> uploadFile(@Validated @ModelAttribute AppFileDto bo) throws IOException {
return toAjax(deviceDebugService.addFileHash(bo));
}
/**
* 操作视频添加
*/
@Log(title = "批量添加操作视频")
@PostMapping("/addVideo")
public R<Void> addOperationVideo(@RequestBody AppOperationVideoBo bo) {
return toAjax(deviceDebugService.addVideoList(bo));
}
/**
* 上传设备logo图片
*/
@Log(title = "批量上传设备logo图片")
@PostMapping("/addLogo")
@FunctionAccessAnnotation("uploadLogo")
public R<Void> uploadLogo670(@Validated @ModelAttribute DeviceDebugLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if(file.getSize()>1024*1024*2){
return R.warn("图片不能大于2M");
}
deviceXinghanBizService.uploadDeviceLogoBatch(bo);
return R.ok();
}
/**
* 设备详情
*/
@Operation(summary = "设备详情")
@GetMapping(value = "/detail/{id}")
public R<DeviceInfoVo> getDeviceInfo(@PathVariable Long id) {
return R.ok(deviceDebugService.getDeviceInfo(id));
}
/**
* 修改设备联调信息
*/
@Log(title = "修改设备联调信息")
@PostMapping("/editDebug")
public R<Void> editDeviceDebug(@Validated @ModelAttribute DeviceDebugEditDto bo) throws Exception {
// 1. 基础参数必填校验
validateDeviceDebugEdit(bo);
// 修改上传设备说明
if (bo.getExplanationFiles() != null) {
AppFileDto appFileDto = new AppFileDto();
appFileDto.setDeviceIds(new Long[]{ bo.getDeviceId() });
appFileDto.setFileType(1L);
appFileDto.setFiles(bo.getExplanationFiles());
deviceDebugService.addFileHash(appFileDto);
}
// 修改上传设备参数
if (bo.getParameterFiles() != null) {
AppFileDto appFileDto = new AppFileDto();
appFileDto.setDeviceIds(new Long[]{ bo.getDeviceId() });
appFileDto.setFileType(2L);
appFileDto.setFiles(bo.getParameterFiles());
deviceDebugService.addFileHash(appFileDto);
}
// 修改操作视频
if (bo.getVideoUrl().isEmpty()) {
AppOperationVideoBo appOperationVideoBo = new AppOperationVideoBo();
appOperationVideoBo.setDeviceIds(new Long[]{ bo.getDeviceId() });
appOperationVideoBo.setVideoUrl(bo.getVideoUrl());
deviceDebugService.addVideoList(appOperationVideoBo);
}
// 修改设备logo 每个型号设备走不同协议无法共用同一个上传
// if(bo.getLogoFile() != null){
// MultipartFile file = bo.getLogoFile();
// if(file.getSize()>1024*1024*2){
// return R.warn("图片不能大于2M");
// }
// AppDeviceLogoUploadDto bo1 = new AppDeviceLogoUploadDto();
// bo1.setDeviceId(bo.getDeviceId());
// bo1.setDeviceImei(bo.getDeviceImei());
// bo1.setFile(file);
// deviceXinghanBizService.uploadDeviceLogo(bo1);
// }
return R.ok();
}
/* ------------------ 私有复用 ------------------ */
private void validateDeviceDebugEdit(DeviceDebugEditDto bo) {
if (bo.getDeviceId() == null || bo.getDeviceId() == 0L) {
throw new ServiceException("请选择设备");
}
// if (bo.getDeviceImei().isEmpty()) {
// throw new ServiceException("设备 IMEI 不能为空");
// }
}
}

View File

@ -0,0 +1,106 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.web.service.device.DeviceXinghanBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* 设备控制类 HBY670
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/xinghan/device")
public class DeviceXinghanController extends BaseController {
private final DeviceXinghanBizService deviceXinghanBizService;
/**
* 人员信息登记
*/
@PostMapping(value = "/registerPersonInfo")
// @FunctionAccessAnnotation("registerPersonInfo")
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
return toAjax(deviceXinghanBizService.registerPersonInfo(bo));
}
/**
* 发送紧急通知
*/
@PostMapping(value = "/sendAlarmMessage")
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(deviceXinghanBizService.sendAlarmMessage(bo));
}
/**
* 上传设备logo图片
*/
@PostMapping("/uploadLogo")
@FunctionAccessAnnotation("uploadLogo")
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if(file.getSize()>1024*1024*2){
return R.warn("图片不能大于2M");
}
deviceXinghanBizService.uploadDeviceLogo(bo);
return R.ok();
}
/**
* 静电预警档位
* 3,2,1,0,分别表示高档/中档/低挡/关闭
*/
@PostMapping("/DetectGradeSettings")
public R<Void> DetectGradeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
deviceXinghanBizService.upDetectGradeSettings(params);
return R.ok();
}
/**
* 照明档位
* 照明档位2,1,0,分别表示弱光/强光/关闭
*/
@PostMapping("/LightGradeSettings")
public R<Void> LightGradeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
deviceXinghanBizService.upLightGradeSettings(params);
return R.ok();
}
/**
* SOS档位
* SOS档位2,1,0, 分别表示红蓝模式/爆闪模式/关闭
*/
@PostMapping("/SOSGradeSettings")
public R<Void> SOSGradeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
deviceXinghanBizService.upSOSGradeSettings(params);
return R.ok();
}
/**
* 静止报警状态
* 静止报警状态0-未静止报警1-正在静止报警。
*/
@PostMapping("/ShakeBitSettings")
public R<Void> ShakeBitSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
deviceXinghanBizService.upShakeBitSettings(params);
return R.ok();
}
}