| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.config.VnnoxConstant; |
| | | import com.sandu.ximon.admin.dto.PlanDto; |
| | | import com.sandu.ximon.admin.dto.SchedulesDTO; |
| | | import com.sandu.ximon.admin.param.PlayPlanParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.VnnoxAPIUtil; |
| | | import com.sandu.ximon.admin.utils.VnnoxProgramAPIUtil; |
| | | import com.sandu.ximon.admin.utils.request.PlayerProgram; |
| | | import com.sandu.ximon.admin.dto.nova.PlayerProgram; |
| | | import com.sandu.ximon.admin.utils.response.VnnoxResult; |
| | | import com.sandu.ximon.admin.utils.response.VnnoxResultResponse; |
| | | import com.sandu.ximon.admin.vo.NovaOpenVO; |
| | | import com.sandu.ximon.admin.vo.NovaPushResultVO; |
| | | import com.sandu.ximon.admin.vo.PlansVO; |
| | | import com.sandu.ximon.dao.domain.LEDProgram; |
| | | import com.sandu.ximon.dao.domain.LedPlayerEntity; |
| | | import com.sandu.ximon.dao.domain.PlayPlanNv; |
| | | import com.sandu.ximon.dao.domain.PushToLed; |
| | | import com.sandu.ximon.dao.mapper.PlayPlanNvMapper; |
| | |
| | | playPlan.setStartDate(playPlanParam.getStartDate()); |
| | | playPlan.setEndDate(playPlanParam.getEndDate()); |
| | | playPlan.setWeekDays(playPlanParam.getWeekDays()); |
| | | |
| | | |
| | | Map schedule = playPlanParam.getSchedule(); |
| | | |
| | | String s = JSON.toJSONString(schedule.get("plans")); |
| | | List<PlanDto> plans = JSON.parseArray(s, PlanDto.class); |
| | | System.out.println(plans.toString()+"plans"); |
| | | |
| | | // List<PlanDto> plans = (List<PlanDto>) schedule.get("plans"); |
| | | |
| | | List<SchedulesDTO> schedulesDTOS = new ArrayList<>(); |
| | | for (int i = 0; i < plans.size(); i++) { |
| | | SchedulesDTO openDto = new SchedulesDTO(); |
| | | // if (i % 2 == 0) { |
| | | // schedulesDTO.setExecTime(plans.get(i).getStartTime()); |
| | | // schedulesDTO.setStatus("OPEN"); |
| | | // } else { |
| | | // schedulesDTO.setWeekDays(plans.get(i).getWeekDays()); |
| | | // schedulesDTO.setExecTime(plans.get(i).getEndTime()); |
| | | // schedulesDTO.setStatus("CLOSE"); |
| | | // } |
| | | |
| | | SchedulesDTO closeDto = new SchedulesDTO(); |
| | | |
| | | openDto.setStartDate(schedule.get("startDate").toString()); |
| | | openDto.setEndDate(schedule.get("endDate").toString()); |
| | | openDto.setExecTime(plans.get(i).getStartTime()); |
| | | openDto.setStatus("OPEN"); |
| | | |
| | | closeDto.setStartDate(schedule.get("startDate").toString()); |
| | | closeDto.setEndDate(schedule.get("endDate").toString()); |
| | | closeDto.setWeekDays(plans.get(i).getWeekDays()); |
| | | closeDto.setExecTime(plans.get(i).getEndTime()); |
| | | closeDto.setStatus("CLOSE"); |
| | | |
| | | schedulesDTOS.add(closeDto); |
| | | schedulesDTOS.add(openDto); |
| | | } |
| | | |
| | | playPlan.setSchedule(JSON.toJSONString(playPlanParam.getSchedule())); |
| | | playPlan.setSchedules(JSON.toJSONString(schedulesDTOS)); |
| | | playPlan.setStartTime(playPlanParam.getStartTime()); |
| | | playPlan.setEndTime(playPlanParam.getEndTime()); |
| | | // BeanUtils.copyProperties(playPlanParam, playPlan); |
| | |
| | | if (byId == null) { |
| | | throw new BusinessException("操作对象不存在"); |
| | | } |
| | | PlayPlanNv playPlan = new PlayPlanNv(); |
| | | playPlan.setId(id); |
| | | playPlan.setName(playPlanParam.getName()); |
| | | playPlan.setLedProgramName(playPlanParam.getLedProgramName()); |
| | | playPlan.setLedProgramId(playPlanParam.getLedProgramId()); |
| | | playPlan.setVolume(playPlanParam.getVolume()); |
| | | playPlan.setApplySeries(playPlanParam.getApplySeries()); |
| | | playPlan.setStartDate(playPlanParam.getStartDate()); |
| | | playPlan.setEndDate(playPlanParam.getEndDate()); |
| | | playPlan.setWeekDays(playPlanParam.getWeekDays()); |
| | | playPlan.setSchedule(JSON.toJSONString(playPlanParam.getSchedule())); |
| | | playPlan.setStartTime(playPlanParam.getStartTime()); |
| | | playPlan.setEndTime(playPlanParam.getEndTime()); |
| | | if(removeById(id)){ |
| | | return addPlan(playPlanParam); |
| | | } |
| | | |
| | | return updateById(playPlan); |
| | | return false; |
| | | |
| | | } |
| | | |
| | |
| | | return removeByIds(ids); |
| | | } |
| | | |
| | | public Map<String, Object> pushToLed(Long planId, List<String> playerIds) { |
| | | public Map<String, Object> pushToLed(Long planId, List<NovaPushResultVO> nova) { |
| | | // public PlayerProgram pushToLed(Long planId){ |
| | | PushToLed pushToLed = playPlanMapper.pushToLed(planId); |
| | | PlayPlanNv one = getOne(Wrappers.lambdaQuery(PlayPlanNv.class).eq(PlayPlanNv::getId, planId)); |
| | | if (pushToLed == null) { |
| | | throw new BusinessException("未找到该播放计划"); |
| | | } |
| | | //List<String> playerIds=new ArrayList<>(); |
| | | // playerIds.add("872bb51ae0f06e70c21e913cf3dc9e4d"); |
| | | //List<Map<String,Object>> pages = JSON.parseObject(pushToLed.getPages(), List.class); |
| | | List<String> playerIds=new ArrayList<>(); |
| | | nova.forEach( |
| | | n->{ |
| | | playerIds.add(n.getPlayerId()); |
| | | } |
| | | ); |
| | | |
| | | PlayerProgram program = new PlayerProgram(); |
| | | program.setPlayerIds(playerIds); |
| | | System.out.println(pushToLed.getPages()); |
| | | |
| | | //获取节目实体 |
| | | program.setPages(JSON.parseObject(pushToLed.getPages(), List.class)); |
| | | program.setSchedules(JSON.parseObject(pushToLed.getSchedule(), List.class)); |
| | | Map map = JSON.parseObject(pushToLed.getSchedule(), Map.class); |
| | | |
| | | |
| | | //获取节目定时实体 |
| | | program.setSchedules((JSON.parseObject(pushToLed.getSchedules(), Map.class))); |
| | | //获取定时开关屏幕 |
| | | // program.setSchedules((JSON.parseArray(pushToLed.getSchedule(), SchedulesDTO.class))); |
| | | |
| | | |
| | | // Map map = JSON.parseObject(pushToLed.getSchedule(), Map.class); |
| | | |
| | | program.setNoticeUrl(VnnoxConstant.NOTIFY_URL); |
| | | VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.timeProgram(program); |
| | | // VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.timeProgram(program); |
| | | VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.normalProgram(program); |
| | | VnnoxResult vnnoxResult = vnnoxAPIUtil.volChange(playerIds, Integer.valueOf(one.getVolume()).intValue()); |
| | | |
| | | // VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.normalProgram(push); |
| | | List<String> success = new ArrayList<>(); |
| | | List<String> fail = new ArrayList<>(); |
| | | if (vnnoxResultResponse.getData() != null) { |
| | |
| | | fail = vnnoxResultResponse.getData().getFail(); |
| | | } |
| | | |
| | | |
| | | // fail.addAll(vnnoxResult.getFail()); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | List<LedPlayerEntity> successList = new ArrayList<>(); |
| | | List<LedPlayerEntity> faileList = new ArrayList<>(); |
| | | for (String playerId : success) { |
| | | successList.add(ledPlayerEntityService.getByPlayerId(playerId)); |
| | | } |
| | | for (String playerId : fail) { |
| | | faileList.add(ledPlayerEntityService.getByPlayerId(playerId)); |
| | | } |
| | | List<NovaPushResultVO> successList = new ArrayList<>(); |
| | | List<NovaPushResultVO> faileList = new ArrayList<>(); |
| | | List<String> finalSuccess = success; |
| | | List<String> finalFail = fail; |
| | | nova.forEach( |
| | | n->{ |
| | | if(finalSuccess.contains(n.getPlayerId())){ |
| | | successList.add(n); |
| | | }else if(finalFail.contains(n.getPlayerId())){ |
| | | faileList.add(n); |
| | | } |
| | | } |
| | | |
| | | ); |
| | | |
| | | result.put("success", successList); |
| | | result.put("fail", faileList); |
| | | result.put("program", program); |
| | | |
| | | return result; |
| | | // return program; |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | if (byId1 == null) { |
| | | throw new BusinessException("找不到该节目"); |
| | | } |
| | | Map schedule = JSON.parseObject(byId.getSchedule(), Map.class); |
| | | List schedule = JSON.parseObject(byId.getSchedule(), List.class); |
| | | List pages = JSON.parseObject(byId1.getPages(), List.class); |
| | | Map plan = new HashMap(); |
| | | plan.put("planId", byId.getId()); |