package com.sandu.ximon.admin.newnova.led;
|
|
import com.sandu.common.domain.ResponseVO;
|
import com.sandu.common.execption.BusinessException;
|
import com.sandu.common.object.BaseConditionVO;
|
import com.sandu.common.util.ResponseUtil;
|
import com.sandu.ximon.admin.newnova.grouping.NewNovaGroupService;
|
import com.sandu.ximon.admin.newnova.param.NewNovaLedParam;
|
import com.sandu.ximon.admin.newnova.param.NewNovaStatusParam;
|
import com.sandu.ximon.admin.newnova.program.LEDInfoParam;
|
import com.sandu.ximon.admin.newnova.utils.NovaAPIUtil;
|
import com.sandu.ximon.admin.security.PermissionConfig;
|
import com.sandu.ximon.admin.security.SecurityUtils;
|
import com.sandu.ximon.dao.domain.NewNovaGroup;
|
import com.sandu.ximon.dao.domain.NewNovaLed;
|
import com.sandu.ximon.dao.enums.MenuEnum;
|
import lombok.AllArgsConstructor;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
/**
|
* @author LiuHaoNan
|
* @date 2022/11/9
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/v1/nova/led")
|
public class NewNovaLedController {
|
private final PermissionConfig permissionConfig;
|
private final NewNovaLedService newNovaLedService;
|
private final NewNovaGroupService groupService;
|
|
|
/**
|
* 屏幕注册
|
*
|
* @param param
|
* @return
|
*/
|
@PostMapping("/validateSN")
|
public ResponseVO<Object> validateSN(@RequestBody @Validated NewNovaLedParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_ADD.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
boolean b = newNovaLedService.saveLed(param);
|
return ResponseUtil.success(b);
|
}
|
|
/**
|
* 编辑屏幕名称
|
*/
|
@PostMapping("/editLed")
|
public ResponseVO editLed(@RequestBody NewNovaLedParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_EDIT.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
return ResponseUtil.success(newNovaLedService.editLed(param));
|
}
|
|
/**
|
* 删除屏幕
|
*/
|
@PostMapping("/delLed")
|
public ResponseVO delLEd(@RequestBody List<Long> ids) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_DEL.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
return ResponseUtil.success(newNovaLedService.delLed(ids));
|
}
|
|
|
/**
|
* 屏幕列表
|
*/
|
@GetMapping("/listLed")
|
public ResponseVO listLed(BaseConditionVO baseConditionVO, @RequestParam(required = false, value = "keyword") String keyword,
|
@RequestParam(required = true, value = "onlineStatus", defaultValue = "false") boolean onlineStatus,
|
@RequestParam(required = false, value = "groupId") Long groupId) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_LIST.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
return ResponseUtil.success(newNovaLedService.listLed(baseConditionVO, keyword, groupId, onlineStatus));
|
}
|
|
|
/**
|
* 状态列表
|
*/
|
@PostMapping("/ledInfo")
|
public ResponseVO ledInfo(@RequestBody LEDInfoParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_LIST.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
return ResponseUtil.success(newNovaLedService.infoList(param));
|
}
|
|
/**
|
* 详细信息
|
*
|
* @param ledId
|
* @return
|
*/
|
@GetMapping("/getInfo")
|
public ResponseVO getInfo(@RequestParam(required = true, value = "ledId") Long ledId) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_INFO.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
return ResponseUtil.success(newNovaLedService.getInfo(ledId));
|
}
|
|
|
/**
|
* 设置亮度
|
*/
|
@PostMapping("/setBrightness")
|
public ResponseVO setScreenBrightness(@RequestBody @Validated NewNovaStatusParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_BRIGHTNESS.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
if (param.getBrightness() == null) {
|
return ResponseUtil.fail("亮度不能为空");
|
} else {
|
if (param.getBrightness() > 100 || param.getBrightness() < 0) {
|
return ResponseUtil.fail("亮度范围为: 0-100");
|
}
|
}
|
NewNovaLed byId = newNovaLedService.getById(param.getId());
|
if (byId == null) {
|
return ResponseUtil.fail("设备不存在");
|
} else {
|
if (!byId.getSn().equals(param.getSn())) {
|
return ResponseUtil.fail("sn与id不匹配");
|
}
|
}
|
return ResponseUtil.success(NovaAPIUtil.getInstanceUtil().setScreenBrightness(param));
|
}
|
|
|
/**
|
* 设置音量
|
*/
|
@PostMapping("/setVolume")
|
public ResponseVO setVolume(@RequestBody @Validated NewNovaStatusParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_VOL.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
if (param.getVolume() == null) {
|
return ResponseUtil.fail("音量不能为空");
|
} else {
|
if (param.getVolume() > 100 || param.getVolume() < 0) {
|
return ResponseUtil.fail("音量范围为: 0-100");
|
}
|
}
|
NewNovaLed byId = newNovaLedService.getById(param.getId());
|
if (byId == null) {
|
return ResponseUtil.fail("设备不存在");
|
} else {
|
if (!byId.getSn().equals(param.getSn())) {
|
return ResponseUtil.fail("sn与id不匹配");
|
}
|
}
|
return ResponseUtil.success(NovaAPIUtil.getInstanceUtil().setVolume(param));
|
}
|
|
/**
|
* 设置同步
|
*/
|
@PostMapping("/setSync")
|
public ResponseVO setSync(@RequestBody NewNovaStatusParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_SYNC.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
if (param.getNovaList() == null || param.getNovaList().isEmpty()) {
|
return ResponseUtil.fail("请选择设备");
|
}
|
return ResponseUtil.success(NovaAPIUtil.getInstanceUtil().setSync(param));
|
}
|
|
/**
|
* 设置屏幕开关
|
*/
|
@PostMapping("/setPowerStatus")
|
public ResponseVO setPowerStatus(@RequestBody NewNovaStatusParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_POWER.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
NewNovaLed byId = newNovaLedService.getById(param.getId());
|
if (byId == null) {
|
return ResponseUtil.fail("设备不存在");
|
} else {
|
if (!byId.getSn().equals(param.getSn())) {
|
return ResponseUtil.fail("sn与id不匹配");
|
}
|
}
|
return ResponseUtil.success(NovaAPIUtil.getInstanceUtil().setPowerStatus(param));
|
}
|
|
|
/**
|
* 重启
|
*/
|
@PostMapping("/reboot")
|
public ResponseVO reboot(@RequestBody NewNovaStatusParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_REBOOT.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
if (param.getNovaList() == null || param.getNovaList().isEmpty()) {
|
return ResponseUtil.fail("请选择设备");
|
}
|
return ResponseUtil.success(NovaAPIUtil.getInstanceUtil().reboot(param));
|
}
|
|
|
/**
|
* ntp
|
*/
|
@PostMapping("/ntp")
|
public ResponseVO ntp(@RequestBody NewNovaStatusParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_NTP.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
if (param.getNovaList() == null || param.getNovaList().isEmpty()) {
|
return ResponseUtil.fail("请选择设备");
|
}
|
return ResponseUtil.success(NovaAPIUtil.getInstanceUtil().ntp(param));
|
}
|
|
/**
|
* 截屏
|
*/
|
@PostMapping("/screenShot")
|
public ResponseVO screenShot(@RequestBody NewNovaStatusParam param) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_SCREENSHOT.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
if (param.getScreenShotList() == null || param.getScreenShotList().isEmpty()) {
|
return ResponseUtil.fail("请选择设备");
|
}
|
return ResponseUtil.success(NovaAPIUtil.getInstanceUtil().screenShot(param));
|
}
|
|
/**
|
* 根据分组id获取组内的屏幕
|
*/
|
@GetMapping("/getByGroupId")
|
public ResponseVO<Object> getByGroupId(@RequestParam(value = "groupId", required = true) Long groupId) {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_GROUB_INFO.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
if (groupId == null) {
|
throw new BusinessException("groupId不能为空");
|
}
|
NewNovaGroup byId = groupService.getById(groupId);
|
if (SecurityUtils.getClientId() != null && !SecurityUtils.getUserId().equals(byId.getUserId())) {
|
throw new BusinessException("不能查看不属于自己分组的内容!");
|
}
|
if (byId == null) {
|
throw new BusinessException("分组不存在");
|
}
|
return ResponseUtil.success(newNovaLedService.getListByGroupId(groupId));
|
}
|
|
/**
|
* 推送大气
|
*/
|
@GetMapping("/pushAirData")
|
public ResponseVO<Object> pushAirData(@RequestParam(value = "id", required = true) Long id
|
, @RequestParam(value = "duration", required = true) Long duration
|
, @RequestParam(value = "fontSize", required = true) Long fontSize) throws InterruptedException {
|
if (!permissionConfig.check(MenuEnum.LED_NEW_PUSH_AIR.getCode())) {
|
return ResponseUtil.fail("缺少对应用户权限");
|
}
|
return ResponseUtil.success(newNovaLedService.pushAirData(id, duration, fontSize));
|
}
|
|
|
// @PostMapping("/tranPro")
|
// public ResponseVO<Object> tranPro(@RequestBody Map pageInfo) throws InterruptedException {
|
// NovaAPIUtil a = NovaAPIUtil.getInstanceUtil();
|
// StatusVO login = a.login("MZVA51930N2113017308", 0);
|
// if (login.getStatusCode() != 0) {
|
// return ResponseUtil.fail("genVO");
|
// }
|
// StatusVO createPro = a.createPro(new ProWHVO("jiemu 1", 128, 256));
|
// System.out.println(createPro + "createPro");
|
// StatusVO editPro = a.editProgram(Integer.valueOf(createPro.getStatusData()), pageInfo);
|
// StatusVO genVO = a.genrateProgram(Integer.valueOf(createPro.getStatusData()));
|
// ProgramPrarm page = new ProgramPrarm();
|
// page.setInsertPlay(true);
|
// page.setProgramID(Integer.valueOf(createPro.getStatusData()));
|
// page.setStartPlayAfterTransferred(true);
|
// List<String> sns = new ArrayList<String>();
|
// sns.add("MZVA51930N2113017308");
|
// page.setSnList(sns);
|
// List<TrasfromStatusVO> trasfromStatusVOS = a.trasfromProgram(page);
|
// return ResponseUtil.success(trasfromStatusVOS);
|
// }
|
|
}
|