| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.google.gson.Gson; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.file.FileUploadDto; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.config.NginxConfigBean; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.config.RealtimeServerBean; |
| | | import com.sandu.ximon.admin.entity.*; |
| | | import com.sandu.ximon.admin.param.PoleBindingParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.Constant; |
| | | import com.sandu.ximon.admin.utils.FileUtil; |
| | | import com.sandu.ximon.admin.utils.HtmlTemplateUtils; |
| | | import com.sandu.ximon.admin.utils.LightemitUtils; |
| | | import com.sandu.ximon.admin.utils.request.SubTitleSet; |
| | | import com.sandu.ximon.admin.utils.*; |
| | | import com.sandu.ximon.admin.vo.EquipmentInfomation; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.domain.PoleLightemitEntity; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import com.sandu.ximon.dao.enums.PoleBindingEnums; |
| | | import com.sandu.ximon.dao.mapper.PoleLightemitEntityMapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.cache.annotation.EnableCaching; |
| | |
| | | private String port; |
| | | @Autowired |
| | | ApplicationContext applicationContext; |
| | | @Autowired |
| | | NginxConfigBean nginxConfigBean; |
| | | |
| | | @Autowired |
| | | PoleLightemitEntityMapper poleLightemitDao; |
| | |
| | | * @param isOnLine |
| | | * @return |
| | | */ |
| | | public List<PoleLightemitEntity> listLed(String keyword, boolean isOnLine) { |
| | | public List<PoleLightemitEntity> listLed(String keyword, Integer order, Integer seq, boolean isOnLine) { |
| | | List<PoleLightemitEntity> poleLightemitEntityList; |
| | | //排序字段 |
| | | String orderByResult = "id"; |
| | | //正序、倒叙 |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.LED_S_CODE.getCode(); |
| | | break; |
| | | case 2: |
| | | orderByResult = OrderByEnums.LED_S_NAME.getCode(); |
| | | break; |
| | | case 3: |
| | | orderByResult = OrderByEnums.LED_S_POLE_NAME.getCode(); |
| | | break; |
| | | case 4: |
| | | orderByResult = OrderByEnums.LED_S_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; |
| | | |
| | | //超管 |
| | | if (SecurityUtils.getClientId() == null) { |
| | | poleLightemitEntityList = poleLightemitDao.listLed(keyword, null); |
| | | poleLightemitEntityList = poleLightemitDao.listLed(keyword, null, orderBy); |
| | | } else { |
| | | poleLightemitEntityList = poleLightemitDao.listLed(keyword, SecurityUtils.getUserId()); |
| | | poleLightemitEntityList = poleLightemitDao.listLed(keyword, SecurityUtils.getUserId(), orderBy); |
| | | } |
| | | if (isOnLine) { |
| | | return ledOnline(poleLightemitEntityList); |
| | | } else { |
| | | ledOnlineCheck(poleLightemitEntityList); |
| | | return poleLightemitEntityList; |
| | | |
| | | List<PoleLightemitEntity> temp = new ArrayList<>(); |
| | | for (PoleLightemitEntity poleLightemitEntity : poleLightemitEntityList) { |
| | | //查询设备在线状态 |
| | | boolean onLine = lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode()); |
| | | //查询屏幕的开启状态 |
| | | String isOpen = lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()); |
| | | poleLightemitEntity.setIsOpen(String.valueOf(isOpen)); |
| | | poleLightemitEntity.setOnLine(onLine); |
| | | if (!isOnLine || onLine) { |
| | | temp.add(poleLightemitEntity); |
| | | } |
| | | } |
| | | return temp; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 绑定使用 |
| | | * |
| | | * @param keyword |
| | | * @return |
| | | */ |
| | | public List<PoleLightemitEntity> listLedOnBinding(String keyword) { |
| | | List<PoleLightemitEntity> poleLightemitEntityList; |
| | | |
| | | |
| | | //超管 |
| | | if (SecurityUtils.getClientId() == null) { |
| | | poleLightemitEntityList = poleLightemitDao.listLedOnBinding(keyword, null); |
| | | } else { |
| | | poleLightemitEntityList = poleLightemitDao.listLedOnBinding(keyword, SecurityUtils.getUserId()); |
| | | } |
| | | |
| | | for (PoleLightemitEntity poleLightemitEntity : poleLightemitEntityList) { |
| | | //查询设备在线状态 |
| | | boolean onLine = lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode()); |
| | | //查询屏幕的开启状态 |
| | | String isOpen = lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()); |
| | | poleLightemitEntity.setIsOpen(String.valueOf(isOpen)); |
| | | poleLightemitEntity.setOnLine(onLine); |
| | | } |
| | | return poleLightemitEntityList; |
| | | } |
| | | |
| | | /** |
| | | * 取出在线的熙讯 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public List<PoleLightemitEntity> ledOnline(List<PoleLightemitEntity> list) { |
| | | List<PoleLightemitEntity> onLineList = new ArrayList<>(); |
| | | for (PoleLightemitEntity poleLightemitEntity : list) { |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")); |
| | | if (poleLightemitEntity.getIsOpen()) { |
| | | // if(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")){ |
| | | // poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")); |
| | | // } |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode())); |
| | | boolean ledOnLine = lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode()); |
| | | if (ledOnLine) { |
| | | poleLightemitEntity.setOnLine(true); |
| | | onLineList.add(poleLightemitEntity); |
| | | } else { |
| | | poleLightemitEntity.setOnLine(false); |
| | | } |
| | | } |
| | | return onLineList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置在线状态 |
| | | * |
| | | * @param list |
| | | */ |
| | | public void ledOnlineCheck(List<PoleLightemitEntity> list) { |
| | | for (PoleLightemitEntity poleLightemitEntity : list) { |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")); |
| | | |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode())); |
| | | poleLightemitEntity.setOnLine(lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode())); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public PoleLightemitEntity getLedByLightControlCode(String lightControlCode) { |
| | | PoleLightemitEntity xiXun = getOne(Wrappers.lambdaQuery(PoleLightemitEntity.class).eq(PoleLightemitEntity::getLightemitControlCode, lightControlCode)); |
| | | Pole getpole = poleLightemitDao.getpole(lightControlCode); |
| | | if (xiXun == null) { |
| | | return null; |
| | | } |
| | | String isScreenOpen = lightemitUtils.getIsScreenOpen(xiXun.getLightemitControlCode()); |
| | | if (isScreenOpen.contains("true")) { |
| | | xiXun.setIsOpen(true); |
| | | } |
| | | xiXun.setIsOpen(false); |
| | | boolean isScreenOpen = lightemitUtils.getLedOnLine(xiXun.getLightemitControlCode()); |
| | | |
| | | xiXun.setIsOpen(lightemitUtils.getIsScreenOpen(lightControlCode)); |
| | | xiXun.setOnLine(isScreenOpen); |
| | | xiXun.setStreetlightName(getpole.getPoleName()); |
| | | xiXun.setStreetlightId(getpole.getId()); |
| | | |
| | | return xiXun; |
| | | } |
| | | |
| | | /** |
| | | * 首页灯杆绑定信息 |
| | | */ |
| | | public EquipmentInfomation getLedByLightControlCodeInfo(String lightControlCode) { |
| | | EquipmentInfomation equipmentInfo = new EquipmentInfomation(); |
| | | equipmentInfo.setEquipmentType("熙讯LED"); |
| | | if (lightControlCode == null || lightControlCode.trim().length() == 0) { |
| | | return equipmentInfo; |
| | | } |
| | | |
| | | PoleLightemitEntity xiXun = getOne(Wrappers.lambdaQuery(PoleLightemitEntity.class).eq(PoleLightemitEntity::getLightemitControlCode, lightControlCode)); |
| | | boolean isScreenOpen = false; |
| | | if (xiXun != null) { |
| | | equipmentInfo.setEquipmentCreateTime(xiXun.getCreateTime()); |
| | | equipmentInfo.setEquipmentMac(xiXun.getLightemitControlCode()); |
| | | equipmentInfo.setEquipmentName(xiXun.getLightemitName()); |
| | | isScreenOpen = lightemitUtils.getLedOnLine(xiXun.getLightemitControlCode()); |
| | | } |
| | | if (isScreenOpen) { |
| | | equipmentInfo.setEquipmentState("在线"); |
| | | } else { |
| | | equipmentInfo.setEquipmentState("离线"); |
| | | } |
| | | |
| | | return equipmentInfo; |
| | | } |
| | | |
| | | |
| | |
| | | poleBindingParam.setDeviceName(poleLightemit.getLightemitName()); |
| | | poleBindingService.bindPole(poleLightemit.getStreetlightId(), poleBindingParam); |
| | | } |
| | | |
| | | /** |
| | | * 熙汛led新增日志记录开始 |
| | | */ |
| | | List<String> listCode = new ArrayList<>(); |
| | | listCode.add(poleLightemit.getLightemitControlCode()); |
| | | String content = "{屏幕id:" + poleLightemit.getLightemitId() + ", 屏幕名称:" + poleLightemit.getLightemitName() + ", 屏幕编码:" + poleLightemit.getLightemitControlCode() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "熙汛LED新增", content); |
| | | /** |
| | | * 熙汛led新增日志记录结束 |
| | | */ |
| | | // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId()); |
| | | } |
| | | |
| | |
| | | PoleLightemitEntity byId = getById(ledId); |
| | | if (byId == null) { |
| | | throw new BusinessException("未找到LED屏"); |
| | | } |
| | | |
| | | if (SecurityUtils.getClientId() != null) { |
| | | boolean belong = SpringContextHolder.getBean(PoleBindingService.class).isBelong(byId.getLightemitControlCode(), PoleBindingEnums.XIXUN); |
| | | if (!belong) { |
| | | throw new BusinessException("该设备不属于您,不能修改设备信息"); |
| | | } |
| | | } |
| | | poleLightemit.setLightemitId(ledId); |
| | | boolean b = this.updateById(poleLightemit); |
| | |
| | | //再绑定 |
| | | PoleBindingParam poleBindingParam = new PoleBindingParam(); |
| | | poleBindingParam.setDeviceCode(poleLightemit.getLightemitControlCode()); |
| | | poleBindingParam.setDeviceType(1); |
| | | poleBindingParam.setDeviceType(10); |
| | | poleBindingParam.setDeviceName(poleLightemit.getLightemitName()); |
| | | poleBindingService.bindPole(poleLightemit.getStreetlightId(), poleBindingParam); |
| | | } |
| | | |
| | | /** |
| | | * 熙汛led编辑日志记录开始 |
| | | */ |
| | | List<String> listCode = new ArrayList<>(); |
| | | listCode.add(byId.getLightemitControlCode()); |
| | | String content = "{屏幕id:" + byId.getLightemitId() + ", 屏幕原名:" + byId.getLightemitName() + ", 屏幕名称:" + poleLightemit.getLightemitName() + ", 屏幕编码:" + byId.getLightemitControlCode() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "熙汛LED编辑", content); |
| | | /** |
| | | * 熙汛led编辑日志记录结束 |
| | | */ |
| | | // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId()); |
| | | } |
| | | |
| | | public boolean deletePoleLightemit(List<Long> ledIds) { |
| | | |
| | | List<PoleLightemitEntity> poleLightemitEntities = listByIds(ledIds); |
| | | if (poleLightemitEntities != null && poleLightemitEntities.size() != 0) { |
| | | throw new BusinessException("设备不存在"); |
| | | } |
| | | |
| | | List<String> listCode = new ArrayList<>(); |
| | | // 删除设备绑定 |
| | | if (poleLightemitEntities != null && poleLightemitEntities.size() != 0) { |
| | | for (PoleLightemitEntity poleLightemitEntitie : poleLightemitEntities) { |
| | | if (poleLightemitEntitie.getLightemitControlCode() != null) { |
| | | //删除绑定关系//先删除绑定关系 |
| | | listCode.add(poleLightemitEntitie.getLightemitControlCode()); |
| | | poleBindingService.unBindPole(poleLightemitEntitie.getLightemitControlCode()); |
| | | } |
| | | } |
| | | } |
| | | //删除设备 |
| | | boolean b = removeByIds(ledIds); |
| | | |
| | | /** |
| | | * 熙汛led删除日志记录开始 |
| | | */ |
| | | List<String> nameList = new ArrayList<>(); |
| | | for (PoleLightemitEntity poleLightemitEntitie : poleLightemitEntities) { |
| | | nameList.add(poleLightemitEntitie.getLightemitName()); |
| | | } |
| | | |
| | | String content = "{删除熙汛LED的设备信息:" + nameList.toString() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "熙汛LED删除", content); |
| | | /** |
| | | * 熙汛led删除日志记录结束 |
| | | */ |
| | | return b; |
| | | // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId()); |
| | | } |
| | |
| | | * led上传视频 |
| | | * |
| | | * @param lightemitControlCode |
| | | * @param filename |
| | | * @param path |
| | | * @param userName |
| | | * @throws IOException |
| | | */ |
| | | @Async("taskExecutor") |
| | | public void videoUpload(String lightemitControlCode, String filename, String path, String userName) throws IOException { |
| | | public String videoUpload(String lightemitControlCode, FileUploadDto fileUploadDto, Integer type) { |
| | | //获取屏幕宽 |
| | | String screenWidth = lightemitUtils.getScreenWidth(lightemitControlCode); |
| | | String screenHeight = lightemitUtils.getScreenHeight(lightemitControlCode); |
| | | |
| | | //发送视频至开发板并播放 |
| | | lightemitUtils.postVideo(screenWidth, screenHeight, filename, lightemitControlCode); |
| | | String fileUrl = fileUploadDto.getFileUrl(); |
| | | String[] split = fileUrl.split("/"); |
| | | String id = split[split.length - 1]; |
| | | String result = this.videoXixunPlayer(lightemitControlCode, id, fileUploadDto.getFileSize(), fileUploadDto.getMd5(), type, fileUploadDto.getFileType(), 999999); |
| | | |
| | | //清屏 |
| | | lightemitUtils.clear(lightemitControlCode); |
| | | |
| | | LogUtils.error("上传播放结果:" + result); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * LED上传单行字幕 |
| | | */ |
| | | @Async("taskExecutor") |
| | | public Boolean subTitleSet(SubTitleSetEntity subTitleSetEntity, String path, String userName) { |
| | | if (subTitleSetEntity == null) { |
| | | return false; |
| | | } |
| | | if (subTitleSetEntity.getDirection().equals(Constant.LEFT) || subTitleSetEntity.getDirection().equals(Constant.RIGHT)) { |
| | | //字幕横向滚动 |
| | | this.BuildHorizonSingSubTitleText(subTitleSetEntity); |
| | | } else if (subTitleSetEntity.getDirection().equals(Constant.UP) || subTitleSetEntity.getDirection().equals(Constant.DOWN)) { |
| | | //字幕纵向滚动 |
| | | try { |
| | | this.BuildVerticalSingSubTitleText(subTitleSetEntity, path, userName); |
| | | } catch (IOException e) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * LED上传多行字幕 |
| | | */ |
| | | @Async("taskExecutor") |
| | | public Boolean subMultiTitleSet(SubTitleSetEntity subTitleSetEntity, String path, String userName) { |
| | | try { |
| | | this.BuildVerticalMultiSubTitleText(subTitleSetEntity, path, userName); |
| | | return true; |
| | | } catch (IOException e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Async("taskExecutor") |
| | | public void videoXixunPlayer(String lightemitControlCode, String ip, String filename, Long filesize, Integer videoTime) { |
| | | public String videoXixunPlayer(String lightemitControlCode, String filename, Long filesize, String md5, Integer type, String fileType, Integer videoTime) { |
| | | //获取屏幕宽 |
| | | Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode)); |
| | | Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode)); |
| | |
| | | source.set_id(UUID.randomUUID().toString()); |
| | | //请求头拼接该ID为该资源的完整下载地址 |
| | | source.setId(filename); |
| | | //设置资源类型,其他资源类型请参考xixunplayer节目json说明文档 |
| | | source.set_type("Video"); |
| | | if (type == 1) { |
| | | //设置资源类型,其他资源类型请参考xixunplayer节目json说明文档 |
| | | source.set_type("Video"); |
| | | source.setMime("video/mp4"); |
| | | } else { |
| | | source.set_type("Image"); |
| | | source.setMime("image/jpeg"); |
| | | } |
| | | //资源后缀名 |
| | | source.setFileExt(".mp4"); |
| | | source.setFileExt(fileType); |
| | | //资源高度 |
| | | source.setHeight(screenHeight); |
| | | //资源宽度 |
| | | source.setWidth(screenWidth); |
| | | //距左 |
| | | source.setLeft(0); |
| | | source.setMd5("dd135d5d2d44d619a542db773ab529a4"); |
| | | source.setMime("video/mp4"); |
| | | source.setMd5(md5); |
| | | source.setName(filename); |
| | | source.setPlayTime(0); //播放起始时间 |
| | | source.setSize(filesize); //资源字节数,要精准 |
| | |
| | | List<Layer> list1 = new ArrayList<Layer>(); |
| | | list1.add(layer); |
| | | pro.setLayers(list1); |
| | | pro.setName("demo"); //节目名称 |
| | | pro.setName("文件上传播放"); //节目名称 |
| | | pro.setOthers(true);//如果为true,则该节目来自第三方接口,不是来自我们自己的web,二次开发请务必赋值为true |
| | | pro.setTotalSize(filesize); //所有资源总字节数 |
| | | pro.setVersion(0); //高级节目=0,简易节目=2 |
| | |
| | | task.setItems(list2); |
| | | command.setId(UUID.randomUUID().toString()); |
| | | //这里是下方的post回调地址,需要修改IP地址 |
| | | command.setNotificationURL("http://" + ip + ":" + port + "/machine-fast/serv/download/getJSON"); |
| | | command.setNotificationURL(""); |
| | | //资源下载链接的请求头 |
| | | command.setPreDownloadURL("http://" + ip + ":" + port + "/machine-fast/serv/download/downloadFile/"); |
| | | command.setPreDownloadURL("https://ximonsmart.oss-cn-shanghai.aliyuncs.com/"); |
| | | command.setTask(task); |
| | | xixun.set_id(UUID.randomUUID().toString()); |
| | | xixun.setCommand(command); |
| | | xixun.setType("commandXixunPlayer"); //命令固定类型,不可更改 |
| | | String jsondata = new Gson().toJson(xixun); |
| | | lightemitUtils.clear(lightemitControlCode); |
| | | poleLightemitDao.updateRequestBody(lightemitControlCode, jsondata); |
| | | lightemitUtils.post(realtimeServerBean.getCommand() + lightemitControlCode, jsondata); |
| | | String clearResult = lightemitUtils.clear(lightemitControlCode); |
| | | if (clearResult.contains("does not exist")) { |
| | | return "推送失败"; |
| | | } else { |
| | | poleLightemitDao.updateRequestBody(lightemitControlCode, jsondata); |
| | | String post = lightemitUtils.post(realtimeServerBean.getCommand() + lightemitControlCode, jsondata); |
| | | LogUtils.error("结果:" + post); |
| | | //{"_type":"success","_id":"ce8dc3ff-dc88-43b7-8f55-60abd8700f1a","timestamp":1653555160535} |
| | | if (post.startsWith("{") && post.endsWith("}") && post.contains("_type\":\"success")) { |
| | | return "推送成功"; |
| | | } else { |
| | | return "推送失败"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | public void updateRequestBody(String ledCode, String postBody) { |
| | | baseMapper.updateRequestBody(ledCode, postBody); |
| | | } |
| | | |
| | | // /** |
| | | // * 根据led屏编码获取灯杆所有信息 |
| | | // * |
| | | // * @param ledCode |
| | | // * @return |
| | | // */ |
| | | // public PoleStreetlightEntity getStreetlightByLedCode(String ledCode) { |
| | | // return baseMapper.getStreetlightByLedCode(ledCode); |
| | | // } |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据led屏编码设置音量 |
| | | * 根据led屏编码设置亮度 |
| | | * |
| | | * @param lightemitControlCode |
| | | * @param brightness |
| | |
| | | lightemitUtils.setBrightness(lightemitControlCode, brightness); |
| | | } |
| | | |
| | | /** |
| | | * 上传水平滚动单行字幕 |
| | | * |
| | | * @param subTitleSetEntity |
| | | */ |
| | | private void BuildHorizonSingSubTitleText(SubTitleSetEntity subTitleSetEntity) { |
| | | //拼装LED屏幕设置请求body |
| | | SubTitleSet subTitleSet = new SubTitleSet(); |
| | | subTitleSet.num = subTitleSetEntity.getNum() != null ? subTitleSetEntity.getNum() : subTitleSet.num; |
| | | subTitleSet.interval = subTitleSetEntity.getInterval() != null ? subTitleSetEntity.getInterval() : subTitleSet.interval; |
| | | subTitleSet.step = subTitleSetEntity.getStep() != null ? subTitleSetEntity.getStep() : subTitleSet.step; |
| | | subTitleSet.direction = subTitleSetEntity.getDirection() != null ? subTitleSetEntity.getDirection() : subTitleSet.direction; |
| | | subTitleSet.align = subTitleSetEntity.getAlign() != null ? subTitleSetEntity.getAlign() : subTitleSet.align; |
| | | //拼接html 背景默认显色为白色 |
| | | subTitleSet.html = "<head><style type=\"text/css\">body{background-color:" + |
| | | (subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor()) ? subTitleSetEntity.getColor() : "#000000") + |
| | | "}</style></head><i style=\"color:" + |
| | | (subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor()) ? subTitleSetEntity.getFontColor() : "#ffffff") |
| | | + "; font-size: " + |
| | | (subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize()) ? subTitleSetEntity.getFontSize() : "1") |
| | | + "em\">" + subTitleSetEntity.getContent() + "</i>"; |
| | | |
| | | //获取所有led数据 |
| | | Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId())); |
| | | if (!poleLightemitControllers.isEmpty()) { |
| | | Iterator iterator = poleLightemitControllers.iterator(); |
| | | while (iterator.hasNext()) { |
| | | PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next(); |
| | | //清屏操作 |
| | | lightemitUtils.clear(poleLightemitEntity.getLightemitControlCode()); |
| | | //清除播放列表 |
| | | lightemitUtils.clearVideoPlay(poleLightemitEntity.getLightemitControlCode()); |
| | | //清除节目列表 |
| | | lightemitUtils.clearPlayerTask(poleLightemitEntity.getLightemitControlCode()); |
| | | //发送字幕设置请求 |
| | | lightemitUtils.subTitleSet(subTitleSet, poleLightemitEntity.getLightemitControlCode(), true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上传垂直滚动单行字幕 |
| | | * |
| | | * @param subTitleSetEntity |
| | | * @param path |
| | | * @param userName |
| | | * @throws IOException |
| | | */ |
| | | private void BuildVerticalSingSubTitleText(SubTitleSetEntity subTitleSetEntity, String path, String userName) throws IOException { |
| | | //html地址 |
| | | //获取所有led数据 |
| | | Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId())); |
| | | if (!poleLightemitControllers.isEmpty()) { |
| | | Iterator iterator = poleLightemitControllers.iterator(); |
| | | while (iterator.hasNext()) { |
| | | PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next(); |
| | | |
| | | String lightemitControlCode = poleLightemitEntity.getLightemitControlCode(); |
| | | |
| | | //获取屏幕宽 |
| | | Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode)); |
| | | Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode)); |
| | | |
| | | String filenameTemp = path + userName + "_" + lightemitControlCode + ".html"; |
| | | File htmlFile = new File(filenameTemp); |
| | | if (!htmlFile.exists() || htmlFile.delete()) { |
| | | htmlFile.createNewFile(); |
| | | } |
| | | |
| | | //若向下滚动,文字顺序相反 |
| | | if (Constant.DOWN.equals(subTitleSetEntity.getDirection())) { |
| | | subTitleSetEntity.setContent(StringUtils.reverse(subTitleSetEntity.getContent())); |
| | | } |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("direction", subTitleSetEntity.getDirection()); |
| | | params.put("screenWidth", screenWidth); |
| | | params.put("screenHeight", screenHeight); |
| | | params.put("fontSize", subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize()) ? subTitleSetEntity.getFontSize() : "1"); |
| | | params.put("align", subTitleSetEntity.getAlign()); |
| | | params.put("fontColor", subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor()) ? subTitleSetEntity.getFontColor() : "#ffffff"); |
| | | params.put("backgroundColor", subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor()) ? subTitleSetEntity.getColor() : "#000000"); |
| | | params.put("interval", subTitleSetEntity.getInterval() != null ? subTitleSetEntity.getInterval() : 50); |
| | | params.put("step", subTitleSetEntity.getStep() != null ? subTitleSetEntity.getStep() : 1); |
| | | params.put("num", subTitleSetEntity.getNum() != null ? subTitleSetEntity.getNum() : -1); |
| | | params.put("contentArray", subTitleSetEntity.getContent().toCharArray()); |
| | | |
| | | String body = new HtmlTemplateUtils().renderPath("classpath:templates/lightemitTemplates/buildVerticalSingSubTitleTemplates.html", params); |
| | | |
| | | boolean flag = new FileUtil().writeToFile(body, filenameTemp); |
| | | |
| | | if (flag) { |
| | | //清屏操作 |
| | | lightemitUtils.clear(lightemitControlCode); |
| | | //清除播放列表 |
| | | lightemitUtils.clearVideoPlay(lightemitControlCode); |
| | | //清除节目列表 |
| | | lightemitUtils.clearPlayerTask(lightemitControlCode); |
| | | //推送 |
| | | lightemitUtils.postHtmlUseNginx(lightemitControlCode, userName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上传垂直滚动多行字幕 |
| | | * |
| | | * @param subTitleSetEntity |
| | | * @param path |
| | | * @param userName |
| | | * @throws IOException |
| | | */ |
| | | private void BuildVerticalMultiSubTitleText(SubTitleSetEntity subTitleSetEntity, String path, String userName) throws IOException { |
| | | //html地址 |
| | | //获取所有led数据 |
| | | Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId())); |
| | | if (!poleLightemitControllers.isEmpty()) { |
| | | Iterator iterator = poleLightemitControllers.iterator(); |
| | | while (iterator.hasNext()) { |
| | | PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next(); |
| | | |
| | | String lightemitControlCode = poleLightemitEntity.getLightemitControlCode(); |
| | | |
| | | //获取屏幕宽 |
| | | Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode)); |
| | | Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode)); |
| | | |
| | | String filenameTemp = path + userName + "_" + lightemitControlCode + ".html"; |
| | | File htmlFile = new File(filenameTemp); |
| | | if (!htmlFile.exists() || htmlFile.delete()) { |
| | | htmlFile.createNewFile(); |
| | | } |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("direction", subTitleSetEntity.getDirection()); |
| | | params.put("screenWidth", screenWidth); |
| | | params.put("screenHeight", screenHeight); |
| | | params.put("fontSize", subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize()) ? subTitleSetEntity.getFontSize() : "1"); |
| | | params.put("align", subTitleSetEntity.getAlign()); |
| | | params.put("fontColor", subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor()) ? subTitleSetEntity.getFontColor() : "#ffffff"); |
| | | params.put("backgroundColor", subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor()) ? subTitleSetEntity.getColor() : "#000000"); |
| | | params.put("interval", subTitleSetEntity.getInterval() != null ? subTitleSetEntity.getInterval() : 50); |
| | | params.put("step", subTitleSetEntity.getStep() != null ? subTitleSetEntity.getStep() : 1); |
| | | params.put("num", subTitleSetEntity.getNum() != null ? subTitleSetEntity.getNum() : -1); |
| | | params.put("contentArray", subTitleSetEntity.getContent().split("\n")); |
| | | |
| | | String body = new HtmlTemplateUtils().renderPath("classpath:templates/lightemitTemplates/buildVerticalSingSubTitleTemplates.html", params); |
| | | |
| | | boolean flag = new FileUtil().writeToFile(body, filenameTemp); |
| | | |
| | | if (flag) { |
| | | //清屏操作 |
| | | lightemitUtils.clear(lightemitControlCode); |
| | | //清除播放列表 |
| | | lightemitUtils.clearVideoPlay(lightemitControlCode); |
| | | //清除节目列表 |
| | | lightemitUtils.clearPlayerTask(lightemitControlCode); |
| | | //推送 |
| | | lightemitUtils.postHtmlUseNginx(lightemitControlCode, userName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |