2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-05-12 f2b8a2fc1b360eb757cf9f8e2ed9f5d19f1f7f4c
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
@@ -7,6 +7,7 @@
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.entity.ProgramPro;
@@ -55,6 +56,9 @@
     */
    @PostMapping("/addProgram")
    public ResponseVO<Object> addProgram(@RequestBody ProgramPro programPro) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_ADD.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(xiXunPlayerService.insert(programPro));
    }
@@ -62,8 +66,10 @@
     * 修改
     */
    @PostMapping("/updateProgram")
    // @RequiresPermissions("pole:polexixunplayer:update")
    public ResponseVO<Object> update(@RequestBody ProgramPro programPro) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_UPDATE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        PoleXixunPlayerEntity byId = xiXunPlayerService.getById(programPro.getProgramId());
        if (byId == null) {
            throw new BusinessException("未选择LED屏");
@@ -86,6 +92,9 @@
     */
    @PostMapping("/deleteProgram/{pid}")
    public ResponseVO<Object> deleteProgram(@PathVariable Long pid) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_DELETE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(xiXunPlayerService.deleteProgram(pid));
    }
@@ -97,6 +106,9 @@
     */
    @GetMapping("/getByPid/{pid}")
    public ResponseVO<Object> getByPid(@PathVariable Long pid) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_DETAIL.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(xiXunPlayerService.getByPid(pid));
    }
@@ -128,6 +140,9 @@
     */
    @PostMapping("/pushToXixun/{pid}")
    public ResponseVO<Object> pushByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PUSH.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        xiXunPlayerService.videoXixunPlayer(pid, lightemitIds);
        return ResponseUtil.success("推送成功");
    }
@@ -135,6 +150,9 @@
    //执行中的节目
    @GetMapping("/getProgram/{lightemitId}")
    public ResponseVO<Object> getProgram(@PathVariable Long lightemitId) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PLAYING.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(xiXunPlayerService.getByPid(lightemitId));
    }
@@ -147,6 +165,9 @@
     */
    @PostMapping("/saveLed")
    public ResponseVO<Object> save(@RequestBody PoleLightemitEntity poleLightemit) {
        if (!permissionConfig.check(MenuEnum.XIXUN_LED_ADD.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        int count = poleLightemitService.count(new QueryWrapper<PoleLightemitEntity>().eq("lightemit_control_code", poleLightemit.getLightemitControlCode()));
        if (count != 0) {
            throw new BusinessException("LED控制卡编号不能重复");
@@ -173,6 +194,9 @@
     */
    @PostMapping("/updateLed/{ledId}")
    public ResponseVO<Object> updatePoleLightemit(@PathVariable Long ledId, @RequestBody PoleLightemitEntity poleLightemit) {
        if (!permissionConfig.check(MenuEnum.XIXUN_LED_UPDATE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        poleLightemitService.updatePoleLightemit(ledId, poleLightemit);
        return ResponseUtil.success("修改成功");
    }
@@ -185,6 +209,9 @@
     */
    @PostMapping("/deleteLed")
    public ResponseVO<Object> deleteLed(@RequestBody List<Long> ledIds) {
        if (!permissionConfig.check(MenuEnum.XIXUN_LED_DELETE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        boolean b = poleLightemitService.deletePoleLightemit(ledIds);
        if (b) {
            return ResponseUtil.success("删除成功");
@@ -207,12 +234,10 @@
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<PoleLightemitEntity> poleLightemitEntityList = poleLightemitService.listLed(keyword, isOnLine);
        poleLightemitEntityList.forEach(
                led -> {
                    led.setStreetlightId(led.getPoleId());
                    led.setStreetlightName(led.getPoleName());
                }
        );
        poleLightemitEntityList.forEach(led -> {
            led.setStreetlightId(led.getPoleId());
            led.setStreetlightName(led.getPoleName());
        });
        CommonPage commonPage = CommonPage.restPage(poleLightemitEntityList);
        int size = poleLightemitEntityList.size();
@@ -237,8 +262,12 @@
    设置屏幕开关
     */
    @AnonymousAccess
    @PostMapping("/setScreenOpen")
    public ResponseVO<Object> setScreenOpen(@RequestBody SetScreenOpenParam setScreenOpenEntity) {
        if (!permissionConfig.check(MenuEnum.XIXUN_ON_OFF.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        if (setScreenOpenEntity.getIds() == null || setScreenOpenEntity.getIds().length == 0 || setScreenOpenEntity.getBool() == null) {
            throw new BusinessException("未选择LED屏");
        }
@@ -272,6 +301,9 @@
   */
    @GetMapping("/getPicture/{id}")
    public ResponseVO<Object> getPicture(@PathVariable Long id) {
        if (!permissionConfig.check(MenuEnum.XIXUN_SCREENSHOT.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        if (id == null) {
            throw new BusinessException("未选择LED屏");
        }
@@ -289,6 +321,9 @@
   */
    @PostMapping("/getVolume/{id}")
    public ResponseVO<Object> getVolume(@PathVariable Long id) {
        if (!permissionConfig.check(MenuEnum.XIXUN_VOL_CHANGE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        if (id == null) {
            throw new BusinessException("未选择LED屏");
        }
@@ -302,12 +337,27 @@
    }
    /**
     * 测试
     *
     * @param
     * @return
     */
    @AnonymousAccess
    @PostMapping("/test/{str}")
    public ResponseVO<Object> setBrightness(@PathVariable String str) {
        return ResponseUtil.success(lightemitUtils.getIsScreenOpen(str));
    }
    /*
    设置亮度
   */
    @PostMapping("/setBrightness")
    public ResponseVO<Object> setBrightness(@RequestBody SetBrightnessParam setBrightnessParam) {
        if (!permissionConfig.check(MenuEnum.XIXUN_BRIGHTNESS_CHANGE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        if (setBrightnessParam == null || setBrightnessParam.getIds() == null || setBrightnessParam.getBrightness() > 255) {
            throw new BusinessException("参数错误为空或亮度不能超过255");
        }
@@ -330,7 +380,9 @@
  */
    @PostMapping("/setVolume")
    public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity) {
        if (!permissionConfig.check(MenuEnum.XIXUN_VOL_CHANGE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        if (setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15) {
            throw new BusinessException("音量范围为0---15");
        }
@@ -350,21 +402,33 @@
    @PostMapping("/addSchedule")
    public ResponseVO<Object> addSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_ADD.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(scheduleService.insert(ledEntity));
    }
    @PostMapping("/updateSchedule")
    public ResponseVO<Object> updateSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_UPDATE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(scheduleService.updateSchedule(ledEntity));
    }
    @PostMapping("/deleteSchedule")
    public ResponseVO<Object> deleteSchedule(@RequestBody List<Integer> ids) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_DELETE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(scheduleService.removeByIds(ids));
    }
    @GetMapping("/getSchedule/{id}")
    public ResponseVO<Object> getSchedule(@PathVariable Integer id) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_DETAIL.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(scheduleService.getSchedule(id));
    }
@@ -388,23 +452,30 @@
     */
    @PostMapping("/pushSchedule/{id}")
    public ResponseVO<Object> pushSchedule(@PathVariable Integer id, @RequestBody Long[] lightemitIds) {
        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_PUSH_SCHEDULE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        scheduleService.ledschedulepush(id, lightemitIds);
        return ResponseUtil.success("设置成功");
    }
    /**
     * 获取执行中的定时
     *
     * @param
     * @return
     */
    @GetMapping("/getPushSchedule")
    @PostMapping("/getPushSchedule")
    public ResponseVO<Object> getPushSchedule(@RequestBody List<Long> ids) {
        if(ids.isEmpty()){
        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_SCHEDULE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        if (ids.isEmpty()) {
            throw new BusinessException("未选择LED屏");
        }
        List<LedScheduleVO> list = new ArrayList<>();
        for(Long id : ids) {
        for (Long id : ids) {
            LedScheduleVO ledScheduleVO = scheduleService.getledschedules(id);
            list.add(ledScheduleVO);
        }
@@ -417,7 +488,10 @@
     */
    @GetMapping("/closeWeatherPush/{id}")
    public ResponseVO<Object> closeWeatherPush(@PathVariable Long id) {
        if(id==null){
        if (!permissionConfig.check(MenuEnum.XIXUN_CLOSE_AIR.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        if (id == null) {
            throw new BusinessException("未选择LED屏");
        }
        SpringContextHolder.getBean(PoleService.class).closeXiXunAirPush(id);
@@ -427,14 +501,17 @@
    /**
     * 清屏操作
     */
    @GetMapping("/clearScreen")
    public ResponseVO<Object> clearScreen(@RequestBody List<String> codes) {
        if(codes.isEmpty()){
    @PostMapping("/clearScreen")
    public ResponseVO<Object> clearScreen(@RequestBody List<Long> ids) {
        if (!permissionConfig.check(MenuEnum.XIXUN_CLEAN.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<PoleLightemitEntity> list = poleLightemitService.listByIds(ids);
        if (ids.isEmpty() && list.isEmpty()) {
            throw new BusinessException("未选择LED屏");
        }
        for(String playerId : codes) {
            lightemitUtils.clear(playerId);
        for (PoleLightemitEntity playerId : list) {
            lightemitUtils.clear(playerId.getLightemitControlCode());
        }
        return ResponseUtil.success("清屏成功");
    }