| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.sandu.common.execption.BusinessException; |
| | |
| | | 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.LogUtils; |
| | | import com.sandu.ximon.dao.domain.LEDProgram; |
| | | import com.sandu.ximon.dao.domain.LedSFile; |
| | | 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.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 熙讯节目 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class XiXunPlayerService extends BaseServiceImpl<PoleXixunPlayerEntityMapper, PoleXixunPlayerEntity> { |
| | |
| | | private final LightemitUtils lightemitUtils; |
| | | private final RealtimeServerBean realtimeServerBean; |
| | | private final PoleLightemitService poleLightemitService; |
| | | private final ClientService clientService; |
| | | private final LedSFileService xiXunFileService; |
| | | |
| | | //熙讯节目列表 |
| | | public LambdaQueryWrapper<PoleXixunPlayerEntity> XixunPlayerList(String keyword) { |
| | | if (SecurityUtils.getClientId() == null) { |
| | | if (keyword != null && keyword.isEmpty()) { |
| | | return Wrappers.lambdaQuery(PoleXixunPlayerEntity.class); |
| | | } else { |
| | | return Wrappers.lambdaQuery(PoleXixunPlayerEntity.class).like(PoleXixunPlayerEntity::getProgramName, keyword); |
| | | } |
| | | |
| | | } else { |
| | | if (keyword != null && keyword.isEmpty()) { |
| | | return Wrappers.lambdaQuery(PoleXixunPlayerEntity.class).eq(PoleXixunPlayerEntity::getCreateUserId, SecurityUtils.getUserId()) |
| | | .or(w -> { |
| | | w.eq(PoleXixunPlayerEntity::getClientId, SecurityUtils.getClientId()); |
| | | }); |
| | | } else { |
| | | return Wrappers.lambdaQuery(PoleXixunPlayerEntity.class).eq(PoleXixunPlayerEntity::getCreateUserId, SecurityUtils.getUserId()) |
| | | .or(w -> { |
| | | w.eq(PoleXixunPlayerEntity::getClientId, SecurityUtils.getClientId()); |
| | | }).like(PoleXixunPlayerEntity::getProgramName, keyword); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | String json = JsonUtil.jsonObj2Sting(programPro); |
| | | PoleXixunPlayerEntity poleXixunPlayer = new PoleXixunPlayerEntity(); |
| | | poleXixunPlayer.setProgramCode(programPro.get_id()); |
| | |
| | | poleXixunPlayer.setHeight(programPro.getHeight()); |
| | | poleXixunPlayer.setWidth(programPro.getWidth()); |
| | | poleXixunPlayer.setTotalSize((float) programPro.getTotalSize() / 1000000 + "MB"); |
| | | // poleXixunPlayer.setTotalSize( Long.parseLong(programPro.getTotalSize()) / 1000000 + "MB"); |
| | | // programPro.setProgramId(poleXixunPlayer.getProgramId()); |
| | | // System.out.println(poleXixunPlayer.getProgramId()); |
| | | poleXixunPlayer.setRequestBody(json); |
| | | poleXixunPlayer.setScreenShot(programPro.getScreenShot()); |
| | | // poleXixunPlayer.setCreatTime(sdf.format(date)); |
| | | poleXixunPlayer.setCreateUserId(SecurityUtils.getClientId()); |
| | | |
| | | poleXixunPlayer.setCreateUserId(SecurityUtils.getUserId()); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | poleXixunPlayer.setCreateUserId(SecurityUtils.getUserId()); |
| | | if (clientService.findClientId()) { |
| | | poleXixunPlayer.setClientId(clientService.getClientId()); |
| | | } |
| | | } |
| | | return this.save(poleXixunPlayer); |
| | | } |
| | | |
| | |
| | | |
| | | public Object getByPid(Long pid) { |
| | | PoleXixunPlayerEntity byId = getById(pid); |
| | | List<Long> fileIds = new ArrayList<>(); |
| | | List<LedSFile> file = new ArrayList<>(); |
| | | if (byId == null) { |
| | | throw new BusinessException("未找到该节目"); |
| | | } |
| | |
| | | ProgramPro programPro = new ProgramPro(); |
| | | try { |
| | | programPro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class); |
| | | programPro.setProgramId(pid); |
| | | programPro.setScreenShot(byId.getScreenShot()); |
| | | programPro.getLayers().forEach( |
| | | layerPro -> { |
| | | layerPro.getSources().forEach( |
| | | sourcePro -> { |
| | | long fileId = Long.parseLong(sourcePro.getId()); |
| | | file.add(xiXunFileService.getById(fileId)); |
| | | } |
| | | ); |
| | | } |
| | | ); |
| | | programPro.setFileList(file); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return programPro; |
| | | return programPro; |
| | | } |
| | | |
| | | |
| | | |
| | | // public Object getProgram(String json) { |
| | | //// PoleXixunPlayerEntity byId = getById(pid); |
| | | // List<Long> fileIds = new ArrayList<>(); |
| | | // List<LedSFile> file = new ArrayList<>(); |
| | | // if (json == null) { |
| | | // throw new BusinessException("未找到该节目"); |
| | | // } |
| | | // ProgramPro programPro = new ProgramPro(); |
| | | // try { |
| | | // programPro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class); |
| | | // programPro.setProgramId(pid); |
| | | // programPro.setScreenShot(byId.getScreenShot()); |
| | | // programPro.getLayers().forEach( |
| | | // layerPro -> { |
| | | // layerPro.getSources().forEach( |
| | | // sourcePro -> { |
| | | // long fileId = Long.parseLong(sourcePro.getId()); |
| | | // file.add(xiXunFileService.getById(fileId)); |
| | | // } |
| | | // ); |
| | | // } |
| | | // ); |
| | | // programPro.setFileList(file); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // return programPro; |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 推送节目 |
| | | * |
| | | * @param programId |
| | | * @param lightemitIds |
| | | */ |
| | | public void videoXixunPlayer(long programId, List<Long> lightemitIds) { |
| | | |
| | | ProgramPro pro = new ProgramPro(); |
| | |
| | | queryWrapper.eq("program_id", programId); |
| | | poleXixunPlayerEntity = this.getOne(queryWrapper); |
| | | String json = poleXixunPlayerEntity.getRequestBody(); |
| | | |
| | | // System.out.println( JSON.parseArray(json, ProgramPro.class)); |
| | | |
| | | try { |
| | | pro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class); |
| | | } catch (Exception e) { |
| | |
| | | |
| | | Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(lightemitIds); |
| | | |
| | | if(poleLightemitEntities != null){ |
| | | for (PoleLightemitEntity entity: poleLightemitEntities) { |
| | | if (poleLightemitEntities != null) { |
| | | for (PoleLightemitEntity entity : poleLightemitEntities) { |
| | | lightemitUtils.clear(entity.getLightemitControlCode()); |
| | | poleLightemitService.updateRequestBody(entity.getLightemitControlCode(), jsondata); |
| | | lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), jsondata); |
| | | String post = lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), jsondata); |
| | | LogUtils.error("结果:" + post); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送大气数据到熙讯LED |
| | | */ |
| | | |
| | | |
| | | |
| | | } |