| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.config.RealtimeServerBean; |
| | | import com.sandu.ximon.admin.config.XiXunConfig; |
| | | import com.sandu.ximon.admin.entity.*; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | |
| | | @AllArgsConstructor |
| | | public class XiXunPlayerService extends BaseServiceImpl<PoleXixunPlayerEntityMapper, PoleXixunPlayerEntity> { |
| | | |
| | | private final PoleXixunPlayerEntityMapper poleXixunPlayerEntityMapper; |
| | | private final XiXunConfig config; |
| | | private final LightemitUtils lightemitUtils; |
| | | private final RealtimeServerBean realtimeServerBean; |
| | | private final PoleLightemitService poleLightemitService; |
| | |
| | | } |
| | | |
| | | public boolean insert(ProgramPro programPro) { |
| | | programPro.getLayers().forEach( |
| | | layerPro -> { |
| | | layerPro.getSources().forEach( |
| | | sourcePro -> { |
| | | long fileId = Long.parseLong(sourcePro.getId()); |
| | | LedSFile file = xiXunFileService.getById(fileId); |
| | | String fileUrl = file.getFileUrl(); |
| | | String[] split = fileUrl.split("/"); |
| | | sourcePro.setId(split[split.length - 1]); |
| | | sourcePro.setMd5(file.getMd5()); |
| | | } |
| | | ); |
| | | } |
| | | ); |
| | | String json = JsonUtil.jsonObj2Sting(programPro); |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create(); |
| | | String json = gson.toJson(programPro); |
| | | PoleXixunPlayerEntity poleXixunPlayer = new PoleXixunPlayerEntity(); |
| | | poleXixunPlayer.setProgramCode(programPro.get_id()); |
| | | poleXixunPlayer.setProgramName(programPro.getName()); |
| | |
| | | + ", 节目名称:" + poleXixunPlayer.getProgramName() |
| | | + ", 节目内容:" + json |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "熙汛节目更改", content); |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "熙汛节目添加", content); |
| | | /** |
| | | * 熙汛节目新增日志记录结束 |
| | | */ |
| | | return save; |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param programPro |
| | | * @return |
| | | */ |
| | | public boolean update(ProgramPro programPro) { |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create(); |
| | | String json = gson.toJson(programPro); |
| | | // String jsondata = JsonUtil.jsonObj2Sting(programPro); |
| | | PoleXixunPlayerEntity poleXixunPlayer = new PoleXixunPlayerEntity(); |
| | | poleXixunPlayer.setProgramCode(programPro.get_id()); |
| | | poleXixunPlayer.setProgramName(programPro.getName()); |
| | | poleXixunPlayer.setHeight(programPro.getHeight()); |
| | | poleXixunPlayer.setWidth(programPro.getWidth()); |
| | | poleXixunPlayer.setTotalSize((float) programPro.getTotalSize() / 1000000 + "MB"); |
| | | poleXixunPlayer.setRequestBody(json); |
| | | poleXixunPlayer.setScreenShot(programPro.getScreenShot()); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | poleXixunPlayer.setCreateUserId(SecurityUtils.getUserId()); |
| | | if (clientService.findClientId()) { |
| | | poleXixunPlayer.setClientId(clientService.getClientId()); |
| | | } |
| | | } |
| | | poleXixunPlayer.setProgramId(programPro.getProgramId()); |
| | | boolean updateResult = updateById(poleXixunPlayer); |
| | | /** |
| | | * 熙汛节目新增日志记录开始 |
| | | */ |
| | | String content = "{节目id:" + poleXixunPlayer.getProgramId() |
| | | + ", 节目名称:" + poleXixunPlayer.getProgramName() |
| | | + ", 节目内容:" + json |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "熙汛节目编辑", content); |
| | | /** |
| | | * 熙汛节目新增日志记录结束 |
| | | */ |
| | | return updateResult; |
| | | } |
| | | |
| | | public boolean deleteProgram(Long pid) { |
| | |
| | | String json = byId.getRequestBody(); |
| | | ProgramPro programPro = new ProgramPro(); |
| | | try { |
| | | programPro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class); |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create(); |
| | | // programPro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class); |
| | | programPro=gson.fromJson(json,ProgramPro.class); |
| | | programPro.setProgramId(pid); |
| | | programPro.setScreenShot(byId.getScreenShot()); |
| | | programPro.getLayers().forEach( |
| | |
| | | //记录操作结果 |
| | | List<Map> mapList = new ArrayList<>(); |
| | | |
| | | ProgramPro pro = new ProgramPro(); |
| | | |
| | | ItemPro items = new ItemPro(); |
| | | TaskPro taskPro = new TaskPro(); |
| | | CommandPro command = new CommandPro(); |
| | | XixunPlayerPro xixun = new XixunPlayerPro(); |
| | | PoleXixunPlayerEntity poleXixunPlayerEntity = new PoleXixunPlayerEntity(); |
| | | |
| | | PoleXixunPlayerEntity poleXixunPlayerEntity; |
| | | items.set_id(UUID.randomUUID().toString()); |
| | | QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("program_id", programId); |
| | | poleXixunPlayerEntity = this.getOne(queryWrapper); |
| | | if (poleXixunPlayerEntity == null) { |
| | | throw new BusinessException("节目数据异常!"); |
| | | } |
| | | |
| | | String json = poleXixunPlayerEntity.getRequestBody(); |
| | | if (StringUtils.isEmpty(json)) { |
| | | throw new BusinessException("节目数据异常!"); |
| | | } |
| | | |
| | | // System.out.println( JSON.parseArray(json, ProgramPro.class)); |
| | | |
| | | ProgramPro pro; |
| | | try { |
| | | pro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class); |
| | | pro.getLayers().forEach(layerPro -> { |
| | | layerPro.getSources().forEach(sourcePro -> { |
| | | long fileId = Long.parseLong(sourcePro.getId()); |
| | | LedSFile file = xiXunFileService.getById(fileId); |
| | | String fileUrl = file.getFileUrl(); |
| | | String[] split = fileUrl.split("/"); |
| | | sourcePro.setId(split[split.length - 1]); |
| | | sourcePro.setMd5(file.getMd5()); |
| | | }); |
| | | }); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new BusinessException("节目数据异常!"); |
| | | } |
| | | items.set_program(pro); |
| | | items.setRepeatTimes(1); |
| | | items.setSchedulePros(null);//定时段,不做定时可为null |
| | | //定时段,不做定时可为null |
| | | items.setSchedulePros(null); |
| | | |
| | | taskPro.set_id(UUID.randomUUID().toString()); |
| | | taskPro.setName(poleXixunPlayerEntity.getProgramName()); |
| | | |
| | | List<ItemPro> list2 = new ArrayList<>(); |
| | | list2.add(items); |
| | | taskPro.setItems(list2); |
| | | |
| | | command.setId(UUID.randomUUID().toString()); |
| | | // //这里是下方的post回调地址,需要修改IP地址 |
| | | //这里是下方的post回调地址,需要修改IP地址 |
| | | command.setNotificationURL(""); |
| | | //资源下载链接的请求头 |
| | | //资源下载链接的请求头,阿里云图片下载地址头 |
| | | command.setPreDownloadURL("https://ximonsmart.oss-cn-shanghai.aliyuncs.com/"); |
| | | command.setTask(taskPro); |
| | | |
| | | xixun.set_id(UUID.randomUUID().toString()); |
| | | xixun.setCommand(command); |
| | | xixun.setType("commandXixunPlayer"); //命令固定类型,不可更改 |
| | | //命令固定类型,不可更改 |
| | | xixun.setType("commandXixunPlayer"); |
| | | |
| | | |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create(); |
| | | // String jsondata = JSON.toJSONString(xixun); |
| | | String jsondata = gson.toJson(xixun); |
| | | |
| | | Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(lightemitIds); |