| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | 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.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.JsonUtil; |
| | | import com.sandu.ximon.admin.utils.LightemitUtils; |
| | | import com.sandu.ximon.dao.domain.PoleLightemitEntity; |
| | | import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity; |
| | | import com.sandu.ximon.dao.mapper.PoleXixunPlayerEntityMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | |
| | | |
| | | private final PoleXixunPlayerEntityMapper poleXixunPlayerEntityMapper; |
| | | private final XiXunConfig config; |
| | | private final LightemitUtils lightemitUtils; |
| | | private final RealtimeServerBean realtimeServerBean; |
| | | private final PoleLightemitService poleLightemitService; |
| | | |
| | | |
| | | public void insert(ProgramPro programPro, Long userId) { |
| | | SimpleDateFormat sdf=new SimpleDateFormat("yy-MM-dd HH:mm:ss"); |
| | | Date date = new Date(); |
| | | public boolean insert(ProgramPro programPro) { |
| | | // SimpleDateFormat sdf=new SimpleDateFormat("yy-MM-dd HH:mm:ss"); |
| | | // Date date = new Date(); |
| | | // Program program = new Program(); |
| | | // try { |
| | | // program = JsonUtil.convertJsonStringToObject(json,Program.class); |
| | |
| | | poleXixunPlayer.setProgramName(programPro.getName()); |
| | | poleXixunPlayer.setHeight(programPro.getHeight()); |
| | | poleXixunPlayer.setWidth(programPro.getWidth()); |
| | | poleXixunPlayer.setTotalSize((float) programPro.getTotalSize()/1000000+"MB"); |
| | | poleXixunPlayer.setTotalSize((float) programPro.getTotalSize() / 1000000 + "MB"); |
| | | poleXixunPlayer.setRequestBody(json); |
| | | poleXixunPlayer.setCreatTime(sdf.format(date)); |
| | | // poleXixunPlayer.setCreatTime(sdf.format(date)); |
| | | poleXixunPlayer.setCreateUserId(SecurityUtils.getClientId()); |
| | | |
| | | this.save(poleXixunPlayer); |
| | | return this.save(poleXixunPlayer); |
| | | } |
| | | |
| | | public void videoXixunPlayer(long programId,Long[] lightemitIds) { |
| | | public boolean deleteProgram(Long pid) { |
| | | PoleXixunPlayerEntity byId = getById(pid); |
| | | if (byId == null) { |
| | | throw new BusinessException("未找到该节目"); |
| | | } |
| | | return removeById(pid); |
| | | } |
| | | |
| | | public Object getByPid(Long pid) { |
| | | PoleXixunPlayerEntity byId = getById(pid); |
| | | if (byId == null) { |
| | | throw new BusinessException("未找到该节目"); |
| | | } |
| | | String json = byId.getRequestBody(); |
| | | ProgramPro programPro = new ProgramPro(); |
| | | try { |
| | | programPro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return programPro; |
| | | } |
| | | |
| | | public void videoXixunPlayer(long programId, List<Long> lightemitIds) { |
| | | |
| | | ProgramPro pro = new ProgramPro(); |
| | | ItemPro items = new ItemPro(); |
| | |
| | | PoleXixunPlayerEntity poleXixunPlayerEntity = new PoleXixunPlayerEntity(); |
| | | items.set_id(UUID.randomUUID().toString()); |
| | | QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("program_id",programId); |
| | | queryWrapper.eq("program_id", programId); |
| | | poleXixunPlayerEntity = this.getOne(queryWrapper); |
| | | String json = poleXixunPlayerEntity.getRequestBody(); |
| | | try { |
| | |
| | | items.setSchedulePros(null);//定时段,不做定时可为null |
| | | taskPro.set_id(UUID.randomUUID().toString()); |
| | | taskPro.setName(poleXixunPlayerEntity.getProgramName()); |
| | | List<ItemPro> list2=new ArrayList<ItemPro>(); |
| | | List<ItemPro> list2 = new ArrayList<>(); |
| | | list2.add(items); |
| | | taskPro.setItems(list2); |
| | | command.setId(UUID.randomUUID().toString()); |
| | | //这里是下方的post回调地址,需要修改IP地址 |
| | | command.setNotificationURL("http://" + config.getIp() + ":" + config.getPort() + "/machine-fast/serv/download/getJSON"); |
| | | //资源下载链接的请求头 |
| | | // command.setPreDownloadURL("http://" + config.getIp() + ":" + config.getPort() + "/machine-fast/serv/download/downliadFileById/"); |
| | | // command.setTask(taskPro); |
| | | // xixun.set_id(UUID.randomUUID().toString()); |
| | | // xixun.setCommand(command); |
| | | // xixun.setType("commandXixunPlayer"); //命令固定类型,不可更改 |
| | | command.setPreDownloadURL("http://" + config.getIp() + ":" + config.getPort() + "/machine-fast/serv/download/downliadFileById/"); |
| | | command.setTask(taskPro); |
| | | xixun.set_id(UUID.randomUUID().toString()); |
| | | xixun.setCommand(command); |
| | | xixun.setType("commandXixunPlayer"); //命令固定类型,不可更改 |
| | | |
| | | |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create(); |
| | | // String jsondata = JSON.toJSONString(xixun); |
| | | String jsondata = gson.toJson(xixun); |
| | | |
| | | /* Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(Arrays.asList(lightemitIds)); |
| | | Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(lightemitIds); |
| | | |
| | | if(poleLightemitEntities != null){ |
| | | for (PoleLightemitEntity entity: poleLightemitEntities) { |
| | |
| | | poleLightemitService.updateRequestBody(entity.getLightemitControlCode(), jsondata); |
| | | lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), jsondata); |
| | | } |
| | | }*/ |
| | | } |
| | | } |
| | | |
| | | |
| | | } |