| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | 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.entity.Plans; |
| | | import com.sandu.ximon.admin.param.PlayPlanParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | | import com.sandu.ximon.admin.utils.VnnoxAPIUtil; |
| | | import com.sandu.ximon.admin.utils.VnnoxProgramAPIUtil; |
| | | import com.sandu.ximon.admin.utils.response.VnnoxResultResponse; |
| | |
| | | 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; |
| | |
| | | SchedulesDTO openDto = new SchedulesDTO(); |
| | | |
| | | |
| | | |
| | | SchedulesDTO closeDto = new SchedulesDTO(); |
| | | |
| | | openDto.setStartDate(schedule.get("startDate").toString()); |
| | |
| | | /** |
| | | * 判断时间的先后 |
| | | */ |
| | | String startTime = openDto.getStartDate()+" " +plans.get(i).getStartTime(); |
| | | String endTime =openDto.getEndDate()+ " " +plans.get(i).getEndTime(); |
| | | String startTime = openDto.getStartDate() + " " + plans.get(i).getStartTime(); |
| | | String endTime = openDto.getEndDate() + " " + plans.get(i).getEndTime(); |
| | | |
| | | //转换成时间戳 |
| | | long startTimeStamp = DateUtil.parse(startTime, DatePattern.NORM_DATETIME_PATTERN).getTime(); |
| | | long endTimeStamp = DateUtil.parse(endTime, DatePattern.NORM_DATETIME_PATTERN).getTime(); |
| | | if(startTimeStamp>endTimeStamp){ |
| | | if (startTimeStamp > endTimeStamp) { |
| | | throw new BusinessException("开始时间不能大于结束时间"); |
| | | } |
| | | |
| | |
| | | playPlan.setEndTime(playPlanParam.getEndTime()); |
| | | // BeanUtils.copyProperties(playPlanParam, playPlan); |
| | | |
| | | /** |
| | | * 诺瓦定时任务/播放计划新增日志记录开始 |
| | | */ |
| | | boolean save = save(playPlan); |
| | | String content = "{播放计划:" + playPlan.getId() |
| | | + ", 节目名称:" + byId.getName() |
| | | + ", 播放计划计划名称:" |
| | | + playPlan.getName() |
| | | + ", 播放计划计划内容:" |
| | | + JSON.toJSONString(playPlan) |
| | | + ", 定时任务内容:" + playPlan.getSchedules() |
| | | + "}," + " 推送结果:" + save |
| | | + " }"; |
| | | if (playPlanParam.getId() == null) { |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "诺瓦定时任务/播放计划新增", content); |
| | | } else { |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "诺瓦定时任务/播放计划修改", content); |
| | | } |
| | | /** |
| | | * 诺瓦定时任务/播放计划新增日志记录结束 |
| | | */ |
| | | |
| | | return save(playPlan); |
| | | return save; |
| | | |
| | | } |
| | | |
| | |
| | | throw new BusinessException("操作对象不存在"); |
| | | } |
| | | if (removeById(id)) { |
| | | playPlanParam.setId(id); |
| | | return addPlan(playPlanParam); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | 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)); |
| | | PlayPlanNv byId = getById(planId); |
| | | if (pushToLed == null) { |
| | | throw new BusinessException("未找到该播放计划"); |
| | | } |
| | | List<String> playerIds = new ArrayList<>(); |
| | | nova.forEach( |
| | | n -> { |
| | | playerIds.add(n.getPlayerId()); |
| | | } |
| | | ); |
| | | nova.forEach(n -> { |
| | | playerIds.add(n.getPlayerId()); |
| | | }); |
| | | |
| | | PlayerProgram program = new PlayerProgram(); |
| | | program.setPlayerIds(playerIds); |
| | |
| | | Map map = JSON.parseObject(pushToLed.getSchedule(), Map.class); |
| | | map.get("plans"); |
| | | List<Plans> plans = JSON.parseArray(map.get("plans").toString(), Plans.class); |
| | | plans.forEach( |
| | | p -> { |
| | | //删除后两位字符串 |
| | | p.setStartTime(p.getStartTime().substring(0, p.getStartTime().length() - 3)); |
| | | p.setEndTime(p.getEndTime().substring(0, p.getEndTime().length() - 3)); |
| | | } |
| | | ); |
| | | plans.forEach(p -> { |
| | | //删除后两位字符串 |
| | | p.setStartTime(p.getStartTime().substring(0, p.getStartTime().length() - 3)); |
| | | p.setEndTime(p.getEndTime().substring(0, p.getEndTime().length() - 3)); |
| | | }); |
| | | System.out.println(plans + "plans11111"); |
| | | map.put("plans", plans); |
| | | program.setSchedule(map); |
| | | //获取定时开关屏幕 |
| | | // 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.normalProgram(program); |
| | | vnnoxAPIUtil.volChange(playerIds, Integer.valueOf(one.getVolume()).intValue()); |
| | | vnnoxAPIUtil.volChange(playerIds, Integer.valueOf(pushToLed.getVolume()).intValue()); |
| | | |
| | | List<String> success = new ArrayList<>(); |
| | | List<String> fail = 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); |
| | | } |
| | | } |
| | | |
| | | ); |
| | | 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); |
| | | |
| | | /** |
| | | * 诺瓦推送节目日志记录开始 |
| | | */ |
| | | List<LedPlayerEntity> list = SpringContextHolder.getBean(LedPlayerEntityService.class) |
| | | .list(Wrappers.lambdaQuery(LedPlayerEntity.class).in(LedPlayerEntity::getId, nova.stream().map(NovaPushResultVO::getPlayerId).toArray())); |
| | | List<String> listCode = new ArrayList<>(); |
| | | for (LedPlayerEntity temp : list) { |
| | | listCode.add(temp.getSn()); |
| | | } |
| | | |
| | | String content = "{节目ID:" + planId |
| | | + ", 节目名称:" + byId.getName() |
| | | + "}," + " 推送结果:" + result |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "诺瓦推送播放计划", content); |
| | | /** |
| | | * 诺瓦推送节目日志记录结束 |
| | | */ |
| | | |
| | | return result; |
| | | // return program; |
| | | } |
| | | |
| | | |
| | | //推送定时到LED |
| | | public Map<String, Object> pushSchedule(Long planId, List<NovaPushResultVO> nova) { |
| | | PlayPlanNv one = getOne(Wrappers.lambdaQuery(PlayPlanNv.class).eq(PlayPlanNv::getId, planId)); |
| | | if (one == null) { |
| | | throw new BusinessException("未找到节目"); |
| | | } |
| | | List<SchedulesDTO> schedulesDTOS = JSON.parseArray(one.getSchedules(), SchedulesDTO.class); |
| | | ProgramSchedule programSchedule = new ProgramSchedule(); |
| | | programSchedule.setSchedules(schedulesDTOS); |
| | |
| | | |
| | | result.put("success", successList); |
| | | result.put("fail", faileList); |
| | | |
| | | /** |
| | | * 诺瓦推送定时日志记录开始 |
| | | */ |
| | | List<LedPlayerEntity> list = SpringContextHolder.getBean(LedPlayerEntityService.class) |
| | | .list(Wrappers.lambdaQuery(LedPlayerEntity.class).in(LedPlayerEntity::getId, nova.stream().map(NovaPushResultVO::getPlayerId).toArray())); |
| | | List<String> listCode = new ArrayList<>(); |
| | | for (LedPlayerEntity temp : list) { |
| | | listCode.add(temp.getSn()); |
| | | } |
| | | |
| | | String content = "{节目ID:" + one.getId() |
| | | + ", 节目名称:" + one.getName() |
| | | + "}," + " 推送结果:" + result |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "诺瓦推送定时开关屏", content); |
| | | /** |
| | | * 诺瓦推送定时日志记录结束 |
| | | */ |
| | | return result; |
| | | } |
| | | |