| | |
| | | import com.sandu.ximon.admin.config.RealtimeServerBean; |
| | | import com.sandu.ximon.admin.param.LEDScheduleParam_xixun; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.JsonUtil; |
| | | import com.sandu.ximon.admin.utils.LightemitUtils; |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | | import com.sandu.ximon.admin.utils.request.Schedules; |
| | | import com.sandu.ximon.admin.utils.request.Task; |
| | | import com.sandu.ximon.admin.utils.request.TaskSchedules; |
| | | import com.sandu.ximon.admin.utils.request.requestbody.GetSchedules; |
| | | import com.sandu.ximon.admin.utils.request.requestbody.Task; |
| | | import com.sandu.ximon.admin.vo.LedScheduleVO; |
| | | import com.sandu.ximon.admin.vo.XiXunResultVO; |
| | | import com.sandu.ximon.dao.domain.LedScheduleEntity; |
| | | import com.sandu.ximon.dao.domain.PoleLightemitEntity; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import com.sandu.ximon.dao.mapper.LedScheduleEntityMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | ledScheduleEntity.setClientId(clientService.getClientId()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 熙汛定时更改 日志记录开始 |
| | | */ |
| | | String content = "{熙汛定时id:" + ledScheduleEntity.getId() + ",熙汛定时名称:" + ledScheduleEntity.getName() + "熙汛定时内容:" + JSON.toJSONString(ledScheduleEntity.getSchedule()) + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "熙汛定时任务更改", content); |
| | | /** |
| | | * 熙汛定时更改 日志记录结束 |
| | | */ |
| | | return this.save(ledScheduleEntity); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param scheduleId |
| | | * @param lightemitIds |
| | | * @return |
| | | */ |
| | | public void ledschedulepush(Integer scheduleId, Long[] lightemitIds) { |
| | | public Map<String, List<XiXunResultVO>> ledschedulepush(Integer scheduleId, Long[] lightemitIds) { |
| | | |
| | | LedScheduleEntity ledScheduleEntity = baseMapper.selectById(scheduleId); |
| | | // SendCommand sendCommand = new SendCommand(); |
| | | // sendCommand.setTask(ledScheduleEntity.getSchedule()); |
| | | // String json = new Gson().toJson(sendCommand); |
| | | // LedScheduleEntity ledScheduleEntity = baseMapper.selectById(scheduleId); |
| | | LedScheduleEntity ledScheduleEntity = getById(scheduleId); |
| | | if (ledScheduleEntity == null) { |
| | | throw new BusinessException("该定时任务不存在"); |
| | | } |
| | | Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(Arrays.asList(lightemitIds)); |
| | | Map<String, List<XiXunResultVO>> result=new HashMap<>(); |
| | | List<XiXunResultVO> success =new ArrayList<>(); |
| | | List<XiXunResultVO> fail =new ArrayList<>(); |
| | | |
| | | |
| | | if (poleLightemitEntities != null) { |
| | | for (PoleLightemitEntity entity : poleLightemitEntities) { |
| | | lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), ledScheduleEntity.getSchedule()); |
| | | String post = lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), ledScheduleEntity.getSchedule()); |
| | | XiXunResultVO vo=new XiXunResultVO(); |
| | | vo.setLightemitId(entity.getLightemitId()); |
| | | vo.setLightemitName(entity.getLightemitName()); |
| | | if(post.contains("{\"_type\":\"success\",\"_id\":")){ |
| | | success.add(vo); |
| | | }else { |
| | | fail.add(vo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 熙汛定时推送 日志记录开始 |
| | | */ |
| | | String message = ""; |
| | | List<String> listCode = new ArrayList<>(); |
| | | |
| | | for (PoleLightemitEntity entity : poleLightemitEntities) { |
| | | |
| | | listCode.add(entity.getLightemitControlCode()); |
| | | message += "[屏幕Code:" + entity.getLightemitControlCode() + "屏幕名称:" + entity.getLightemitName() + "],"; |
| | | } |
| | | String content = "{熙汛定时id:" + ledScheduleEntity.getId() + ",熙汛定时名称:" + ledScheduleEntity.getName() + "熙汛屏幕信息:" + message + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "推送熙汛定时任务", content); |
| | | /** |
| | | * 熙汛定时任务推送 日志记录结束 |
| | | */ |
| | | |
| | | result.put("success",success); |
| | | result.put("fail",fail); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 清空定时 |
| | | * |
| | | * @param |
| | | * @param lightemitIds |
| | | */ |
| | | public Map<String, List<XiXunResultVO>> deleteSchedulePush( Long[] lightemitIds) { |
| | | |
| | | Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(Arrays.asList(lightemitIds)); |
| | | |
| | | Map<String, List<XiXunResultVO>> result=new HashMap<>(); |
| | | List<XiXunResultVO> success =new ArrayList<>(); |
| | | List<XiXunResultVO> fail =new ArrayList<>(); |
| | | |
| | | if (poleLightemitEntities != null) { |
| | | for (PoleLightemitEntity entity : poleLightemitEntities) { |
| | | // lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), ledScheduleEntity.getSchedule()); |
| | | String post = lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), "{\"type\": \"timedScreening\",\"task\":{}}"); |
| | | |
| | | XiXunResultVO vo=new XiXunResultVO(); |
| | | vo.setLightemitId(entity.getLightemitId()); |
| | | vo.setLightemitName(entity.getLightemitName()); |
| | | if(post.contains("{\"_type\":\"success\",\"_id\":")){ |
| | | success.add(vo); |
| | | }else { |
| | | fail.add(vo); |
| | | } |
| | | |
| | | System.out.println(post+"---------"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清空熙汛定时任务 日志记录开始 |
| | | */ |
| | | String message = ""; |
| | | List<String> listCode = new ArrayList<>(); |
| | | |
| | | for (PoleLightemitEntity entity : poleLightemitEntities) { |
| | | |
| | | listCode.add(entity.getLightemitControlCode()); |
| | | message += "[屏幕Code:" + entity.getLightemitControlCode() + "屏幕名称:" + entity.getLightemitName() + "],"; |
| | | } |
| | | String content = "{熙汛屏幕信息:" + message + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "清空熙汛定时任务", content); |
| | | /** |
| | | * 清空熙汛定时任务 日志记录结束 |
| | | */ |
| | | result.put("success",success); |
| | | result.put("fail",fail); |
| | | return result; |
| | | } |
| | | |
| | | public boolean updateSchedule(LEDScheduleParam_xixun paramXixun) { |
| | |
| | | * @param keyword |
| | | * @return |
| | | */ |
| | | public List listSchedule(BaseConditionVO baseConditionVO, String keyword) { |
| | | public List listSchedule(BaseConditionVO baseConditionVO,Integer order,Integer seq, String keyword) { |
| | | LambdaQueryWrapper<LedScheduleEntity> eq = Wrappers.lambdaQuery(LedScheduleEntity.class); |
| | | //用户类型判断 |
| | | if (SecurityUtils.getClientId() != null) { |
| | |
| | | eq = eq.like(LedScheduleEntity::getName, keyword); |
| | | } |
| | | |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | //排序字段 |
| | | String orderByResult = "id"; |
| | | //正序、倒叙 |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.LED_S_PLAY_PLAN_CREATE_TIME.getCode(); |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | if (seq != null) { |
| | | switch (seq) { |
| | | case 1: |
| | | orderBySeq = " ASC"; |
| | | break; |
| | | case 2: |
| | | orderBySeq = " DESC"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | //排序方式 |
| | | String orderBy = orderByResult + " " + orderBySeq; |
| | | |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(),orderBy); |
| | | return list(eq); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时查询 |
| | | */ |
| | | public LedScheduleVO getledschedules(Long id) { |
| | | |
| | | PoleLightemitEntity poleLightemitEntity = poleLightemitService.getById(id); |
| | | |
| | | String result1 = lightemitUtils.getTimeSchedule(poleLightemitEntity.getLightemitControlCode()); |
| | | if (result1.indexOf("not open") != -1) { |
| | | LedScheduleVO notOpen = new LedScheduleVO(); |
| | | notOpen.setLedName(poleLightemitEntity.getLightemitName()); |
| | | notOpen.setScheduleName("设备未开启"); |
| | | return notOpen; |
| | | } |
| | | boolean flag = result1.contains("exist"); |
| | | if (flag != true) { |
| | | String result = lightemitUtils.getTimeSchedule(poleLightemitEntity.getLightemitControlCode()); |
| | | // if(result !=null){ |
| | | GetSchedules getSchedules = new GetSchedules(); |
| | | try { |
| | | getSchedules = JsonUtil.convertJsonStringToObject(result, GetSchedules.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | LedScheduleVO ledScheduleVO = new LedScheduleVO(); |
| | | ledScheduleVO.setLedName(poleLightemitEntity.getLightemitName()); |
| | | if (getSchedules.getTask().getName() != null) { |
| | | ledScheduleVO.setScheduleName(getSchedules.getTask().getName()); |
| | | List<Schedules> list = new ArrayList(); |
| | | list = getSchedules.getTask().getSchedules(); |
| | | for (Schedules schedules : list) { |
| | | |
| | | ledScheduleVO.setStartTime(schedules.getStartTime()); |
| | | ledScheduleVO.setEndTime(schedules.getEndTime()); |
| | | ledScheduleVO.setStartDate(schedules.getStartDate()); |
| | | ledScheduleVO.setEndDate(schedules.getEndDate()); |
| | | ledScheduleVO.setWeek(schedules.getWeekFilter()); |
| | | } |
| | | ; |
| | | } else { |
| | | ledScheduleVO.setScheduleName("无定时"); |
| | | } |
| | | return ledScheduleVO; |
| | | } else { |
| | | LedScheduleVO ledScheduleVO = new LedScheduleVO(); |
| | | ledScheduleVO.setLedName(poleLightemitEntity.getLightemitName()); |
| | | ledScheduleVO.setScheduleName("设备未开启"); |
| | | return ledScheduleVO; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |