2021与蓝度共同重构项目,服务端
liuhaonan
2022-03-16 e50188e29656c43a6b69b08694dd9ee6e3b6a2f0
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
@@ -15,15 +15,15 @@
import com.sandu.ximon.admin.param.SetScreenOpenParam;
import com.sandu.ximon.admin.param.SetVolumeParam;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.service.ClientService;
import com.sandu.ximon.admin.service.LedScheduleService;
import com.sandu.ximon.admin.service.PoleLightemitService;
import com.sandu.ximon.admin.service.XiXunPlayerService;
import com.sandu.ximon.admin.service.*;
import com.sandu.ximon.admin.utils.LightemitUtils;
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity;
import com.sandu.ximon.dao.enums.AdministratorEnums;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@@ -43,6 +43,8 @@
    private final PoleLightemitService poleLightemitService;
    private final LightemitUtils lightemitUtils;
    private final LedScheduleService scheduleService;
    private final PoleBindingService bindingService;
    private final PoleService poleService;
    // private final ListPageUtil listPageUtil;
    /**
@@ -61,10 +63,10 @@
     */
    @PostMapping("/updateProgram")
    // @RequiresPermissions("pole:polexixunplayer:update")
    public ResponseVO<Object> update(@RequestBody ProgramPro programPro) {
    public ResponseVO<Object> update(@RequestBody  ProgramPro programPro) {
        PoleXixunPlayerEntity byId = xiXunPlayerService.getById(programPro.getProgramId());
        if (byId == null) {
            throw new BusinessException("参数错误");
            throw new BusinessException("未选择LED屏");
        }
//        QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("program_code", programPro.get_id());
@@ -142,7 +144,7 @@
     * @param lightemitIds
     * @return
     */
    @GetMapping("/pushToXixun/{pid}")
    @PostMapping("/pushToXixun/{pid}")
    public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) {
        xiXunPlayerService.videoXixunPlayer(pid, lightemitIds);
        return ResponseUtil.success("推送成功");
@@ -225,9 +227,23 @@
                    }
            );
        }
        List<PoleBinding> bindings = bindingService.list(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceType, 1));
        List<PoleLightemitEntity> list = poleLightemitService.list(wrapper);
        if(isOnLine){
        if (isOnLine) {
            List<PoleLightemitEntity> results = poleLightemitService.ledOnline(list);
            results.forEach(
                    led -> {
                        bindings.forEach(
                                bind -> {
                                    if (bind.getDeviceCode() != null && led.getLightemitControlCode() == bind.getDeviceCode()) {
                                        led.setStreetlightId(bind.getPoleId());
                                        System.out.println("有没有运行到这里?---------------" + bind.getPoleId());
                                        led.setStreetlightName(poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, bind.getPoleId())).getPoleName());
                                    }
                                }
                        );
                    }
            );
            CommonPage commonPage = CommonPage.restPage(results);
            int size = results.size();
            commonPage.setTotal((long) size);
@@ -236,9 +252,30 @@
                commonPage.setTotalPage(size / baseConditionVO.getPageSize());
            }
            return ResponseUtil.success(commonPage);
        }else {
        } else {
            poleLightemitService.ledOnlineCheck(list);
            return ResponseUtil.success(list);
            list.forEach(
                    led -> {
                        bindings.forEach(
                                bind -> {
                                    if (bind.getDeviceCode() != null && led.getLightemitControlCode().equals(bind.getDeviceCode())) {
                                        led.setStreetlightId(bind.getPoleId());
                                        System.out.println("有没有运行到这里?---------------" + bind.getPoleId());
                                        led.setStreetlightName(poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, bind.getPoleId())).getPoleName());
                                    }
                                }
                        );
                    }
            );
            CommonPage commonPage = CommonPage.restPage(list);
            int size = list.size();
            commonPage.setTotal((long) size);
            commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1);
            if (size % baseConditionVO.getPageSize() == 0) {
                commonPage.setTotalPage(size / baseConditionVO.getPageSize());
            }
            return ResponseUtil.success(commonPage);
            // return ResponseUtil.success(list);
        }
//        return ResponseUtil.success(poleLightemitService.list(wrapper));
    }
@@ -248,8 +285,8 @@
     */
    @PostMapping("/setScreenOpen")
    public ResponseVO<Object> setScreenOpen(@RequestBody SetScreenOpenParam setScreenOpenEntity){
        if(setScreenOpenEntity.getIds() == null || setScreenOpenEntity.getIds().length == 0 || setScreenOpenEntity.getBool() == null){
    public ResponseVO<Object> setScreenOpen(@RequestBody SetScreenOpenParam setScreenOpenEntity) {
        if (setScreenOpenEntity.getIds() == null || setScreenOpenEntity.getIds().length == 0 || setScreenOpenEntity.getBool() == null) {
            throw new BusinessException("未选择LED屏");
        }
        Collection poleLightemitControllers = poleLightemitService.listByIds(Arrays.asList(setScreenOpenEntity.getIds()));
@@ -263,15 +300,15 @@
                //结果查询
                String result = lightemitUtils.setScreenOpen(poleLightemitEntity.getLightemitControlCode(), setScreenOpenEntity.getBool());
                System.out.println("result:---------------------"+result);
                if(result.isEmpty() || !"true".equals(result)){
                System.out.println("result:---------------------" + result);
                if (result.isEmpty() || !"true".equals(result)) {
                }
                map.put(poleLightemitEntity.getLightemitId(), result);
            }
            return ResponseUtil.success(map);
        }else {
        } else {
            throw new BusinessException("未正确选择LED屏");
        }
    }
@@ -319,7 +356,7 @@
    public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity) {
        if (setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15) {
            throw new BusinessException("参数错误");
            throw new BusinessException("音量范围为0---15");
        }
        Collection poleLightemitControllers = poleLightemitService.listByIds(Arrays.asList(setVolumeEntity.getIds()));
@@ -345,11 +382,31 @@
        return ResponseUtil.success(scheduleService.updateSchedule(ledEntity));
    }
    @PostMapping("/deleteSchedule")
    public ResponseVO<Object> deleteSchedule(@RequestBody List<Integer> ids) {
        return ResponseUtil.success(scheduleService.removeByIds(ids));
    }
    @GetMapping("/getSchedule/{id}")
    public ResponseVO<Object> getSchedule(@PathVariable Integer id) {
        return ResponseUtil.success(scheduleService.getSchedule(id));
    }
    @GetMapping("/listSchedule")
    public ResponseVO<Object> listSchedule(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        return ResponseUtil.success(scheduleService.listSchedule(baseConditionVO, keyword));
    }
    /**
     * 设置定时
     *
     * @param id
     * @param lightemitIds
     * @return
     */
    @PostMapping("/pushSchedule/{id}")
    public ResponseVO<Object> pushSchedule(@PathVariable Integer id, @RequestBody Long[] lightemitIds) {
        scheduleService.ledschedulepush(id, lightemitIds);