| | |
| | | package com.sandu.ximon.admin.utils; |
| | | |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.Gson; |
| | | import com.sandu.common.file.FileUploadDto; |
| | | import com.sandu.ximon.admin.config.RealtimeServerBean; |
| | | import com.sandu.ximon.admin.service.PoleLightemitService; |
| | | import com.sandu.ximon.admin.utils.request.*; |
| | |
| | | private final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); |
| | | |
| | | private OkHttpClient client = new OkHttpClient(); |
| | | |
| | | @Autowired |
| | | private Snowflake snowflake; |
| | | |
| | | |
| | | public void init() { |
| | |
| | | * |
| | | * @param ledCode |
| | | */ |
| | | public void clear(String ledCode) { |
| | | public String clear(String ledCode) { |
| | | String postBody = new Gson().toJson(new Clear()); |
| | | //请求地址 |
| | | String url = realtimeServerBean.getCommand() + ledCode; |
| | | //请求 |
| | | String result = post(url, postBody); |
| | | LogUtils.error("清屏结果:" + result); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param screenWidth |
| | | * @param screenHeight |
| | | * @param filename |
| | | * @param ledCode |
| | | */ |
| | | public void postVideo(String screenWidth, String screenHeight, String filename, String ledCode) { |
| | | public String postFile(String screenWidth, String screenHeight, String ledCode, FileUploadDto fileUploadDto) { |
| | | |
| | | String fileUrl = fileUploadDto.getFileUrl(); |
| | | String[] split = fileUrl.split("/"); |
| | | String id = split[split.length - 1]; |
| | | |
| | | |
| | | //led开发板下载视频请求body |
| | | DownloadFileToLocal downloadFileToLocal = new DownloadFileToLocal(); |
| | | downloadFileToLocal.url = realtimeServerBean.getUrl() + filename; |
| | | downloadFileToLocal.path += filename; |
| | | downloadFileToLocal.url = realtimeServerBean.getUrl() + "https://ximonsmart.oss-cn-shanghai.aliyuncs.com/" + id; |
| | | downloadFileToLocal.path += fileUrl; |
| | | |
| | | //led开发板下载视频请求 |
| | | this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(downloadFileToLocal)); |
| | | |
| | | //led开发板视频列表请求body |
| | | SetPlayList setPlayList = new SetPlayList(); |
| | | setPlayList.list[0] = "/data/data/com.xixun.xy.conn/files/local/abc/" + filename; |
| | | // setPlayList.pathList[0] = ""; |
| | | setPlayList.list[0] = fileUrl; |
| | | setPlayList.pathList[0] = ledCode; |
| | | try { |
| | | setPlayList.width = Integer.valueOf(screenWidth); |
| | | setPlayList.height = Integer.valueOf(screenHeight); |
| | | } catch (Exception e) { |
| | | return; |
| | | return "推送失败"; |
| | | } |
| | | String postBody = new Gson().toJson(setPlayList); |
| | | //保存led数据 |
| | | poleLightemitService.updateRequestBody(ledCode, postBody); |
| | | |
| | | //led开发板视频列表请求 |
| | | this.post(realtimeServerBean.getCommand() + ledCode, postBody); |
| | | String post = this.post(realtimeServerBean.getCommand() + ledCode, postBody); |
| | | LogUtils.error("视频上传结果:----" + post); |
| | | if (post.contains("does not exist")) { |
| | | return "推送失败"; |
| | | } else { |
| | | //{"_type":"success","_id":"ce8dc3ff-dc88-43b7-8f55-60abd8700f1a","timestamp":1653555160535} |
| | | if (post.startsWith("{") && post.endsWith("}") && post.contains("_type\":\"success")) { |
| | | //保存led数据 |
| | | poleLightemitService.updateRequestBody(ledCode, postBody); |
| | | return "推送成功"; |
| | | } else { |
| | | return "推送失败"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * led屏字幕设置 |
| | | * |