| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | 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.param.VnnoxParam; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.service.LedPlayerEntityService; |
| | | import com.sandu.ximon.admin.service.PoleBindingService; |
| | | import com.sandu.ximon.admin.service.PoleService; |
| | | import com.sandu.ximon.admin.service.VnnoxService; |
| | | import com.sandu.ximon.admin.utils.VnnoxAPIUtil; |
| | | import com.sandu.ximon.admin.utils.response.VnnoxResult; |
| | | import com.sandu.ximon.admin.vo.NovaPushResultVO; |
| | | import com.sandu.ximon.admin.vo.NovaResultVO; |
| | | import com.sandu.ximon.dao.domain.LedPlayerEntity; |
| | | import com.sandu.ximon.dao.domain.LedV2RegisterResultEntity; |
| | | import com.sandu.ximon.dao.domain.PoleBinding; |
| | | import com.sandu.ximon.dao.enums.AdministratorEnums; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | * 诺瓦LED处理 |
| | | */ |
| | | @RestController |
| | | //@AllArgsConstructor |
| | | @RequestMapping("/v1/Vnnox") |
| | | public class VnnoxController { |
| | | @Autowired |
| | |
| | | private LedPlayerEntityService ledPlayerEntityService; |
| | | @Autowired |
| | | private VnnoxAPIUtil vnnoxAPIUtil; |
| | | @Autowired |
| | | private PoleBindingService bindingService; |
| | | @Autowired |
| | | private PoleService poleService; |
| | | |
| | | /** |
| | | * 截屏 |
| | |
| | | */ |
| | | @PostMapping("/screenShot") |
| | | public ResponseVO<Object> screenShot(@RequestBody VnnoxParam vnnoxWebRequest) { |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_SCREENSHOT.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | Map<String, String> map = vnnoxService.getScreenShotUrl(vnnoxWebRequest.getId()); |
| | | if (map.get("code").equals("500")) { |
| | | return ResponseUtil.fail(map.get("msg")); |
| | |
| | | /** |
| | | * 重启 |
| | | * |
| | | * @param vnnoxWebRequest |
| | | * @param |
| | | * @return |
| | | */ |
| | | @PostMapping("/reboot") |
| | | public ResponseVO<Object> reboot(@RequestBody VnnoxParam vnnoxWebRequest) { |
| | | VnnoxResult vnnoxResult = vnnoxService.reboot(vnnoxWebRequest.getPlayerList()); |
| | | return ResponseUtil.success(vnnoxResult); |
| | | public ResponseVO<Object> reboot(@RequestBody List<NovaPushResultVO> nova) { |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_RESTART.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(vnnoxService.reboot(nova)); |
| | | } |
| | | |
| | | /** |
| | | * 同步播放 |
| | | */ |
| | | @PostMapping("/syncPlay") |
| | | public ResponseVO<Object> syncPlay(@RequestBody NovaResultVO vo) { |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_SYNC_PLAY.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | List<NovaPushResultVO> playIdlist = vo.getPlayIdlist(); |
| | | Integer option = vo.getOption(); |
| | | if (option == null || vo.getOption() == null) { |
| | | throw new BusinessException("option不能为空"); |
| | | } |
| | | return ResponseUtil.success(vnnoxService.syncPlay(playIdlist, option)); |
| | | } |
| | | |
| | | /** |
| | | * ntp对时 |
| | | */ |
| | | @PostMapping("/ntp") |
| | | public ResponseVO<Object> ntp(@RequestBody NovaResultVO vo) { |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_NTP.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | boolean enable = vo.isEnable(); |
| | | List<NovaPushResultVO> playIdlist = vo.getPlayIdlist(); |
| | | return ResponseUtil.success(vnnoxService.ntpSync(playIdlist, enable)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/screenStatusChange") |
| | | public ResponseVO<Object> screenStatusChange(@RequestBody VnnoxParam vnnoxWebRequest) { |
| | | VnnoxResult vnnoxResult = vnnoxService.screenStatusChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getScreenStatus()); |
| | | return ResponseUtil.success(vnnoxResult); |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_ON_OFF.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(vnnoxService.screenStatusChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getScreenStatus())); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/volChange") |
| | | public ResponseVO<Object> volChange(@RequestBody VnnoxParam vnnoxWebRequest) { |
| | | VnnoxResult vnnoxResult = vnnoxService.volChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getVol()); |
| | | return ResponseUtil.success(vnnoxResult); |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_VOL_CHANGE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(vnnoxService.volChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getVol())); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/brightnessChange") |
| | | public ResponseVO<Object> brightnessChange(@RequestBody VnnoxParam vnnoxWebRequest) { |
| | | VnnoxResult vnnoxResult = vnnoxService.brightnessChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getBrightness()); |
| | | return ResponseUtil.success(vnnoxResult); |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_BRIGHTNESS_CHANGE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(vnnoxService.brightnessChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getBrightness())); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/validateSN") |
| | | public ResponseVO<Object> validateSN(@RequestBody Map map) throws URISyntaxException { |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_ADD.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String sn = (String) map.get("sn"); |
| | | String name = (String) map.get("name"); |
| | | LedV2RegisterResultEntity ledV2RegisterResultEntity = vnnoxService.validateSN(name, sn); |
| | |
| | | |
| | | @PostMapping("/updateLedName/{id}") |
| | | public ResponseVO<Object> updateLedName(@PathVariable Long id, @RequestBody Map map) { |
| | | if (!permissionConfig.check(MenuEnum.VNNOX_NAME_UPDATE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String name = (String) map.get("name"); |
| | | boolean b = vnnoxService.updateDataName(id, name); |
| | | if (b) { |
| | |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> list(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | public ResponseVO<Object> list(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq) { |
| | | if (!permissionConfig.check(MenuEnum.LED_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.successPage(ledPlayerEntityService.ledPlayerEntityList(baseConditionVO, keyword)); |
| | | return ResponseUtil.successPage(ledPlayerEntityService.ledPlayerEntityList(baseConditionVO, keyword, order, seq)); |
| | | } |
| | | |
| | | @GetMapping("/onLineList") |
| | | public ResponseVO<Object> onLineList(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | // public ResponseVO<Object> onLineList(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | LambdaQueryWrapper<LedPlayerEntity> wrapper = Wrappers.lambdaQuery(LedPlayerEntity.class); |
| | | |
| | | if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) { |
| | | //wrapper.eq(LedPlayerEntity::get) |
| | | return ResponseUtil.success(""); // todo |
| | | } else { |
| | | wrapper.like(LedPlayerEntity::getPlayerName, keyword); |
| | | List<LedPlayerEntity> list = ledPlayerEntityService.list(wrapper); |
| | | List<LedPlayerEntity> entities = vnnoxService.setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list)); |
| | | List<LedPlayerEntity> online = new ArrayList<>(); |
| | | for (LedPlayerEntity ledPlayer : entities) { |
| | | if (ledPlayer.getOnlineStatus() == 1) { |
| | | online.add(ledPlayer); |
| | | } |
| | | } |
| | | return ResponseUtil.success(online); |
| | | public ResponseVO<Object> onLineList(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq) { |
| | | if (!permissionConfig.check(MenuEnum.LED_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | List<LedPlayerEntity> list = ledPlayerEntityService.ledPlayerEntityList(baseConditionVO, keyword, order, seq); |
| | | List<LedPlayerEntity> entities = vnnoxService.setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list)); |
| | | List<LedPlayerEntity> online = new ArrayList<>(); |
| | | for (LedPlayerEntity ledPlayer : entities) { |
| | | if (ledPlayer.getOnlineStatus() == 1) { |
| | | online.add(ledPlayer); |
| | | } |
| | | } |
| | | return ResponseUtil.success(online); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 屏幕详情 //前端未发现调用 |
| | | * |
| | | * @param sn |
| | | * @return |
| | | */ |
| | | @GetMapping("/getVnnoxInfo/{sn}") |
| | | public ResponseVO<Object> getBySnAndPlayerId(@PathVariable String sn) { |
| | | return ResponseUtil.success(ledPlayerEntityService.getBySnAndPlayerSn(sn)); |