From a98ab7f009865d113b75708a69ef1a0a8e3d8d3b Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期四, 24 二月 2022 16:33:37 +0800
Subject: [PATCH] 功能完善

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java |  744 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 378 insertions(+), 366 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java
index 0fb8c5b..1c9e8ac 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java
@@ -1,308 +1,318 @@
-//package com.sandu.ximon.admin.utils;
-//
-//import com.alibaba.fastjson.JSONObject;
-//import com.google.gson.Gson;
-//import com.sandu.ximon.admin.config.NginxConfigBean;
-//import com.sandu.ximon.admin.config.RealtimeServerBean;
-//import com.sandu.ximon.admin.service.PoleLightemitService;
-//import com.sandu.ximon.admin.utils.request.*;
-//import com.sandu.ximon.dao.domain.PoleLightemitEntity;
-//import com.squareup.okhttp.*;
-//import org.apache.commons.lang.StringEscapeUtils;
-//import org.apache.commons.lang.StringUtils;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.context.ApplicationContext;
-//import org.springframework.stereotype.Component;
-//
-//import java.io.IOException;
-//
-//@Component
-//public class LightemitUtils {
-//    @Autowired
-//    RealtimeServerBean realtimeServerBean;
-//
-//    PoleLightemitService poleLightemitService;
-//    @Autowired
-//    ApplicationContext applicationContext;
-//    @Autowired
-//    NginxConfigBean nginxConfigBean;
-//    //body灏佽缂栫爜
-//    private final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
-//
-//    private OkHttpClient client = new OkHttpClient();
-//
-//
+package com.sandu.ximon.admin.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.sandu.ximon.admin.config.NginxConfigBean;
+import com.sandu.ximon.admin.config.RealtimeServerBean;
+import com.sandu.ximon.admin.service.PoleLightemitService;
+import com.sandu.ximon.admin.utils.request.*;
+import com.squareup.okhttp.*;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+
+@Component
+public class LightemitUtils {
+    @Autowired
+    RealtimeServerBean realtimeServerBean;
+
+    @Autowired
+    PoleLightemitService poleLightemitService;
+    @Autowired
+    ApplicationContext applicationContext;
+    @Autowired
+    NginxConfigBean nginxConfigBean;
+    //body灏佽缂栫爜
+    private final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
+
+    private OkHttpClient client = new OkHttpClient();
+
+
 //    public void init(){
 //        //閲嶆柊鑾峰彇鍗曚緥
 //        poleLightemitService = applicationContext.getBean(PoleLightemitService.class);
 //    }
-//    /**
-//     * post璇锋眰灏佽鏂规硶
-//     * @param url url
-//     * @param json body
-//     * @return
-//     */
-//    public String post(String url, String json){
-//        RequestBody body = RequestBody.create(JSON, json);
-//        Request request = new Request.Builder()
-//                .url(url)
-//                .post(body)
-//                .build();
-//        try {
-//            Response response = client.newCall(request).execute();
-//            return response.body().string();
-//        } catch (IOException e) {
-//            LogUtils.error(e.getMessage());
-//            return "";
-//        }
-//    }
-//
-//    /**
-//     * 鑾峰彇led灞忓搴�
-//     * @param ledCode led灞忕紪鍙�
-//     * @return
-//     */
-//    public String getScreenWidth(String ledCode){
-//        String postBody = new Gson().toJson(new GetScreenWidth());
-//        //璇锋眰鍦板潃
-//        String url = realtimeServerBean.getCommand() + ledCode;
-//        //璇锋眰
-//        String result =  post(url,postBody);
-//        if(StringUtils.isNotBlank(result)){
-//            try{
-//                return JSONObject.parseObject(result).get("result").toString();
-//            }catch (Exception e){
-//                return "64";
-//            }
-//        }else{
-//            return "64";
-//        }
-//    }
-//
-//    /**
-//     * 鑾峰彇led灞忛珮搴�
-//     * @param ledCode led灞忕紪鍙�
-//     * @return
-//     */
-//    public String getScreenHeight(String ledCode){
-//        String postBody = new Gson().toJson(new GetScreenHeight());
-//        //璇锋眰鍦板潃
-//        String url = realtimeServerBean.getCommand() + ledCode;
-//        //璇锋眰
-//        String result =  post(url,postBody);
-//        if(StringUtils.isNotBlank(result)){
-//            try{
-//                return JSONObject.parseObject(result).get("result").toString();
-//            }catch (Exception e){
-//                return "64";
-//            }
-//        }else{
-//            return "64";
-//        }
-//    }
-//
-//    /**
-//     * 娓呭睆鎿嶄綔
-//     * @param ledCode
-//     */
-//    public void clear(String ledCode){
-//        String postBody = new Gson().toJson(new Clear());
-//        //璇锋眰鍦板潃
-//        String url = realtimeServerBean.getCommand() + ledCode;
-//        //璇锋眰
-////        poleLightemitService.updateRequestBody(ledCode, "");
-//        String result =  post(url,postBody);
-//    }
-//
-//    /**
-//     * html浼犺緭鑷砽ed灞�
-//     * @param ledCode
-//     * @param username
-//     */
-//    public void postHtml(String ledCode, String username){
-//
-//        PostHtml postHtml = new PostHtml(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
-//        String postBody = new Gson().toJson(postHtml);
-//
-//        //璇锋眰鍦板潃
-//        String url = realtimeServerBean.getCommand() + ledCode;
-//        //淇濆瓨led鏁版嵁
-//        poleLightemitService.updateRequestBody(ledCode, postBody);
-//        //璇锋眰
-//        String result =  post(url,postBody);
-//    }
-//    /**
-//     * html浼犺緭鑷砽ed灞�, 閫氳繃url鑾峰彇html
-//     * @param ledCode
-//     * @param username
-//     */
-//    public void postHtmlUseNginx(String ledCode, String username){
-//
-//        PostHtml postHtml = new PostHtml(nginxConfigBean.getUrl() + username + "_" + ledCode + ".html");
-//        String postBody = new Gson().toJson(postHtml);
-//
-//        //璇锋眰鍦板潃
-//        String url = realtimeServerBean.getCommand() + ledCode;
-//        //淇濆瓨led鏁版嵁
-//        poleLightemitService.updateRequestBody(ledCode, postBody);
-//        //璇锋眰
-//        String result =  post(url,postBody);
-//    }
-//
-//    /**
-//     * 瑙嗛浼犺緭鑷砽ed灞�
-//     * @param screenWidth
-//     * @param screenHeight
-//     * @param filename
-//     * @param ledCode
-//     */
-//    public void postVideo(String screenWidth, String screenHeight, String filename, String ledCode) {
-//
-//        //led寮�鍙戞澘涓嬭浇瑙嗛璇锋眰body
-//        DownloadFileToLocal downloadFileToLocal = new DownloadFileToLocal();
-//        downloadFileToLocal.url = realtimeServerBean.getUrl() + filename;
-//        downloadFileToLocal.path += filename;
-//
-//        //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] = "";
-//        try{
-//            setPlayList.width = Integer.valueOf(screenWidth);
-//            setPlayList.height = Integer.valueOf(screenHeight);
-//        }catch (Exception e){
-//            return;
-//        }
-//        String postBody = new Gson().toJson(setPlayList);
-//        //淇濆瓨led鏁版嵁
-//        poleLightemitService.updateRequestBody(ledCode, postBody);
-//        //led寮�鍙戞澘瑙嗛鍒楄〃璇锋眰
-//        this.post(realtimeServerBean.getCommand() + ledCode, postBody);
-//    }
-//
-//    /**
-//     * led灞忓瓧骞曡缃�
-//     * @param subTitleSet
-//     * @param ledCode
-//     */
-//    public void subTitleSet(SubTitleSet subTitleSet, String ledCode, Boolean isSave){
-//        String postBody =  new Gson().toJson(subTitleSet);
-//        if(isSave == true){
-//            poleLightemitService.updateRequestBody(ledCode, postBody);
-//        }
-//        this.post(realtimeServerBean.getCommand() + ledCode, postBody);
-//    }
-//
-//    /**
-//     * 娓呴櫎鎾斁鍒楄〃
-//     * @param ledCode
-//     */
-//    public void clearVideoPlay(String ledCode) {
-////        poleLightemitService.updateRequestBody(ledCode, "");
-//        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearVideoPlay()));
-//    }
-//
-//    /**
-//     * 娓呴櫎鑺傜洰鍒楄〃
-//     * @param ledCode
-//     */
-//    public void clearPlayerTask(String ledCode) {
-////        poleLightemitService.updateRequestBody(ledCode, "");
-//        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearPlayerTask()));
-//    }
-//
-//    /**
-//     * 鑾峰彇led灞忕敾闈�
-//     * @param ledCode
-//     */
-//    public String getPicture(String ledCode) {
-//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new GetPicture()));
-//        //鑾峰彇base64鍥剧墖鏁版嵁
-//        if(StringUtils.isBlank(result)){
-//            return "";
-//        }
-//        String re;
-//
-//        try{
-//            re = JSONObject.parseObject(result).get("result").toString();
-//        }catch (Exception e){
-//            re = "0";
-//        }
-//
-//        if(StringUtils.isBlank(re)){
-//            return "";
-//        }
-//        //鍘婚櫎鎹㈣绗�
-//        re.replaceAll("\r|\n*","");
-//        return re;
-//    }
-//
-//    /**
-//     * 鍒ゆ柇led灞忔槸鍚﹀紑鍚�
-//     * @param ledCode
-//     * @return
-//     */
-//    public String getIsScreenOpen(String ledCode){
-//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen()));
-//        //鑾峰彇base64鍥剧墖鏁版嵁
-//        if(StringUtils.isNotBlank(result)){
-//            String re;
-//            try{
-//                re = JSONObject.parseObject(result).get("result").toString();
-//            }catch (Exception e){
-//                re = "false";
-//            }
-//            return re;
-//        }else{
-//            return "";
-//        }
-//    }
-//
-//    /*
-//    鍚姩xwalk
-//     */
-//    /*public void startActivity(String ledCode){
-//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new StartActivity()));
-//    }*/
-//
-//    /*
-//    浣跨敤xwalk鍔犺浇缃戦〉
-//     */
-//    /*public void callXwalkFn(String ledCode,String username){
-//
-//        CallXwalkFn callXwalkFn = new CallXwalkFn();
-//
-//        callXwalkFn.setArgUrl(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
-//        String postBody = new Gson().toJson(callXwalkFn);
-//
-//        //璇锋眰鍦板潃
-//        String url = realtimeServerBean.getCommand() + ledCode;
-//        //璇锋眰
-//        String result =  post(url,postBody);
-//    }*/
-//
-//    /*
-//   鎺у埗灞忓箷寮�鍏�
-//    */
-//    public String setScreenOpen(String ledCode, Boolean bool) {
-//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new setScreenOpen(bool)));
-//        //鑾峰彇base64鍥剧墖鏁版嵁
-//        if(StringUtils.isNotBlank(result)){
-//            String re = "";
-//            try{
-//                re = JSONObject.parseObject(result).get("result").toString();
-//            }catch (Exception e){
-//                re = "false";
-//            }
-//            return re;
-//        }else{
-//            return "";
-//        }
-//    }
-//
+
+    /**
+     * post璇锋眰灏佽鏂规硶
+     *
+     * @param url  url
+     * @param json body
+     * @return
+     */
+    public String post(String url, String json) {
+        RequestBody body = RequestBody.create(JSON, json);
+        Request request = new Request.Builder()
+                .url(url)
+                .post(body)
+                .build();
+        try {
+            Response response = client.newCall(request).execute();
+            return response.body().string();
+        } catch (IOException e) {
+            LogUtils.error(e.getMessage());
+            return "";
+        }
+    }
+
+    /**
+     * 鑾峰彇led灞忓搴�
+     *
+     * @param ledCode led灞忕紪鍙�
+     * @return
+     */
+    public String getScreenWidth(String ledCode) {
+        String postBody = new Gson().toJson(new GetScreenWidth());
+        //璇锋眰鍦板潃
+        String url = realtimeServerBean.getCommand() + ledCode;
+        //璇锋眰
+        String result = post(url, postBody);
+        if (StringUtils.isNotBlank(result)) {
+            try {
+                return JSONObject.parseObject(result).get("result").toString();
+            } catch (Exception e) {
+                return "64";
+            }
+        } else {
+            return "64";
+        }
+    }
+
+    /**
+     * 鑾峰彇led灞忛珮搴�
+     *
+     * @param ledCode led灞忕紪鍙�
+     * @return
+     */
+    public String getScreenHeight(String ledCode) {
+        String postBody = new Gson().toJson(new GetScreenHeight());
+        //璇锋眰鍦板潃
+        String url = realtimeServerBean.getCommand() + ledCode;
+        //璇锋眰
+        String result = post(url, postBody);
+        if (StringUtils.isNotBlank(result)) {
+            try {
+                return JSONObject.parseObject(result).get("result").toString();
+            } catch (Exception e) {
+                return "64";
+            }
+        } else {
+            return "64";
+        }
+    }
+
+    /**
+     * 娓呭睆鎿嶄綔
+     *
+     * @param ledCode
+     */
+    public void clear(String ledCode) {
+        String postBody = new Gson().toJson(new Clear());
+        //璇锋眰鍦板潃
+        String url = realtimeServerBean.getCommand() + ledCode;
+        //璇锋眰
+//        poleLightemitService.updateRequestBody(ledCode, "");
+        String result = post(url, postBody);
+    }
+
+    /**
+     * html浼犺緭鑷砽ed灞�
+     *
+     * @param ledCode
+     * @param username
+     */
+    public void postHtml(String ledCode, String username) {
+
+        PostHtml postHtml = new PostHtml(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
+        String postBody = new Gson().toJson(postHtml);
+
+        //璇锋眰鍦板潃
+        String url = realtimeServerBean.getCommand() + ledCode;
+        //淇濆瓨led鏁版嵁
+        poleLightemitService.updateRequestBody(ledCode, postBody);
+        //璇锋眰
+        String result = post(url, postBody);
+    }
+    /**
+     * html浼犺緭鑷砽ed灞�, 閫氳繃url鑾峰彇html
+     * @param ledCode
+     * @param username
+     */
+    public void postHtmlUseNginx(String ledCode, String username){
+
+        PostHtml postHtml = new PostHtml(nginxConfigBean.getUrl() + username + "_" + ledCode + ".html");
+        String postBody = new Gson().toJson(postHtml);
+
+        //璇锋眰鍦板潃
+        String url = realtimeServerBean.getCommand() + ledCode;
+        //淇濆瓨led鏁版嵁
+        poleLightemitService.updateRequestBody(ledCode, postBody);
+        //璇锋眰
+        String result =  post(url,postBody);
+    }
+
+    /**
+     * 瑙嗛浼犺緭鑷砽ed灞�
+     * @param screenWidth
+     * @param screenHeight
+     * @param filename
+     * @param ledCode
+     */
+    public void postVideo(String screenWidth, String screenHeight, String filename, String ledCode) {
+
+        //led寮�鍙戞澘涓嬭浇瑙嗛璇锋眰body
+        DownloadFileToLocal downloadFileToLocal = new DownloadFileToLocal();
+        downloadFileToLocal.url = realtimeServerBean.getUrl() + filename;
+        downloadFileToLocal.path += filename;
+
+        //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] = "";
+        try{
+            setPlayList.width = Integer.valueOf(screenWidth);
+            setPlayList.height = Integer.valueOf(screenHeight);
+        }catch (Exception e){
+            return;
+        }
+        String postBody = new Gson().toJson(setPlayList);
+        //淇濆瓨led鏁版嵁
+        poleLightemitService.updateRequestBody(ledCode, postBody);
+        //led寮�鍙戞澘瑙嗛鍒楄〃璇锋眰
+        this.post(realtimeServerBean.getCommand() + ledCode, postBody);
+    }
+
+    /**
+     * led灞忓瓧骞曡缃�
+     * @param subTitleSet
+     * @param ledCode
+     */
+    public void subTitleSet(SubTitleSet subTitleSet, String ledCode, Boolean isSave){
+        String postBody =  new Gson().toJson(subTitleSet);
+        if(isSave == true){
+            poleLightemitService.updateRequestBody(ledCode, postBody);
+        }
+        this.post(realtimeServerBean.getCommand() + ledCode, postBody);
+    }
+
+    /**
+     * 娓呴櫎鎾斁鍒楄〃
+     *
+     * @param ledCode
+     */
+    public void clearVideoPlay(String ledCode) {
+//        poleLightemitService.updateRequestBody(ledCode, "");
+        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearVideoPlay()));
+    }
+
+    /**
+     * 娓呴櫎鑺傜洰鍒楄〃
+     *
+     * @param ledCode
+     */
+    public void clearPlayerTask(String ledCode) {
+//        poleLightemitService.updateRequestBody(ledCode, "");
+        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearPlayerTask()));
+    }
+
+    /**
+     * 鑾峰彇led灞忕敾闈�
+     *
+     * @param ledCode
+     */
+    public String getPicture(String ledCode) {
+        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new GetPicture()));
+        //鑾峰彇base64鍥剧墖鏁版嵁
+        if (StringUtils.isBlank(result)) {
+            return "";
+        }
+        String re;
+
+        try {
+            re = JSONObject.parseObject(result).get("result").toString();
+        } catch (Exception e) {
+            re = "0";
+        }
+
+        if (StringUtils.isBlank(re)) {
+            return "";
+        }
+        //鍘婚櫎鎹㈣绗�
+        re.replaceAll("\r|\n*", "");
+        return re;
+    }
+
+    /**
+     * 鍒ゆ柇led灞忔槸鍚﹀紑鍚�
+     *
+     * @param ledCode
+     * @return
+     */
+    public String getIsScreenOpen(String ledCode) {
+        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen()));
+        //鑾峰彇base64鍥剧墖鏁版嵁
+        if (StringUtils.isNotBlank(result)) {
+            String re;
+            try {
+                re = JSONObject.parseObject(result).get("result").toString();
+            } catch (Exception e) {
+                re = "false";
+            }
+            return re;
+        } else {
+            return "";
+        }
+    }
+
+    /*
+    鍚姩xwalk
+     */
+    /*public void startActivity(String ledCode){
+        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new StartActivity()));
+    }*/
+
+    /*
+    浣跨敤xwalk鍔犺浇缃戦〉
+     */
+    /*public void callXwalkFn(String ledCode,String username){
+
+        CallXwalkFn callXwalkFn = new CallXwalkFn();
+
+        callXwalkFn.setArgUrl(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
+        String postBody = new Gson().toJson(callXwalkFn);
+
+        //璇锋眰鍦板潃
+        String url = realtimeServerBean.getCommand() + ledCode;
+        //璇锋眰
+        String result =  post(url,postBody);
+    }*/
+
+    /*
+   鎺у埗灞忓箷寮�鍏�
+    */
+    public String setScreenOpen(String ledCode, Boolean bool) {
+        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new setScreenOpen(bool)));
+        //鑾峰彇base64鍥剧墖鏁版嵁
+        if (StringUtils.isNotBlank(result)) {
+            String re = "";
+            try {
+                re = JSONObject.parseObject(result).get("result").toString();
+            } catch (Exception e) {
+                re = "false";
+            }
+            return re;
+        } else {
+            return "";
+        }
+    }
+
 //    //鍙戦�佹渶鏂扮殑鏁版嵁
 //    public void sendLastCommand(String lightemitControlCode) {
 //        PoleLightemitEntity poleLightemitEntity = poleLightemitService.selectByLightemitControlCode(lightemitControlCode);
@@ -311,68 +321,70 @@
 //        }
 //        this.post(realtimeServerBean.getCommand() + lightemitControlCode, poleLightemitEntity.getRequestBody());
 //    }
-//
-//    /*
-//    璁剧疆led闊抽噺
-//     */
-//    public void setVoiume(String ledCode,Integer volume){
-//
-//        SetVolume setVolume = new SetVolume();
-//        setVolume.arg1 = volume;
-//        String postBody = new Gson().toJson(setVolume);
-//
-//        //璇锋眰
-//        String result =  post(realtimeServerBean.getCommand() + ledCode,postBody);
-//    }
-//
-//    /*
-//    鑾峰彇led闊抽噺
-//     */
-//    /*public String getVoiume(String ledCode){
-//        GetVolume getVolume = new GetVolume();
-//        String postBody = new Gson().toJson(getVolume);
-//
-//        //璇锋眰
-//        String result =  post(realtimeServerBean.getCommand() + ledCode,postBody);
-//        //璇锋眰
-//        if(StringUtils.isNotBlank(result)){
-//            try{
-//                return JSONObject.parseObject(result).get("result").toString();
-//            }catch (Exception e){
-//                return "0";
-//            }
-//        }else{
-//            return "0";
-//        }
-//    }
-//*/
-//    /**
-//     * 鏌ヨ瀹氭椂
-//     * @param ledCode
-//     * @return
-//     */
-//    public String getTimeSchedule(String ledCode) {
-//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new GetTimeSchedule()));
-//        //鑾峰彇瀹氭椂json鏁版嵁
-////        Map map = new Gson().fromJson(result,Map.class);
-////        Gson gson = new Gson();
-////        Task task =gson.fromJson((String)gson.fromJson(result,Map.class).get("task"),Task.class);
-////        Schedules schedules =gson.fromJson((String)gson.fromJson(result,Map.class).get("schedule"),Schedules.class);
-//        if(StringUtils.isBlank(result)){
-//            return "";
-//        }
-//        String re;
-//
-//        //鍘婚櫎瀛楃涓蹭腑鐨刓
-//        re = StringEscapeUtils.unescapeJavaScript(result);
-//        //鍘婚櫎瀛楃涓蹭腑鐨剗"
-//        re = re.replace("}\"","}");
-//        //鍘婚櫎瀛楃涓蹭腑"{
-//        re = re.replace("\"{","{");
-//        re = re.replace("\"null\"","{}");
-//        if(StringUtils.isBlank(re)){
-//            return "";
-//        }
-//        return re;
-//    }
-//}
+
+    /*
+    璁剧疆led闊抽噺
+     */
+    public void setVoiume(String ledCode, Integer volume) {
+
+        SetVolume setVolume = new SetVolume();
+        setVolume.arg1 = volume;
+        String postBody = new Gson().toJson(setVolume);
+
+        //璇锋眰
+        String result = post(realtimeServerBean.getCommand() + ledCode, postBody);
+    }
+
+    /*
+    鑾峰彇led闊抽噺
+     */
+    /*public String getVoiume(String ledCode){
+        GetVolume getVolume = new GetVolume();
+        String postBody = new Gson().toJson(getVolume);
+
+        //璇锋眰
+        String result =  post(realtimeServerBean.getCommand() + ledCode,postBody);
+        //璇锋眰
+        if(StringUtils.isNotBlank(result)){
+            try{
+                return JSONObject.parseObject(result).get("result").toString();
+            }catch (Exception e){
+                return "0";
+            }
+        }else{
+            return "0";
+        }
+    }
+*/
+
+    /**
+     * 鏌ヨ瀹氭椂
+     *
+     * @param ledCode
+     * @return
+     */
+    public String getTimeSchedule(String ledCode) {
+        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new GetTimeSchedule()));
+        //鑾峰彇瀹氭椂json鏁版嵁
+//        Map map = new Gson().fromJson(result,Map.class);
+//        Gson gson = new Gson();
+//        Task task =gson.fromJson((String)gson.fromJson(result,Map.class).get("task"),Task.class);
+//        Schedules schedules =gson.fromJson((String)gson.fromJson(result,Map.class).get("schedule"),Schedules.class);
+        if (StringUtils.isBlank(result)) {
+            return "";
+        }
+        String re;
+
+        //鍘婚櫎瀛楃涓蹭腑鐨刓
+        re = StringEscapeUtils.unescapeJavaScript(result);
+        //鍘婚櫎瀛楃涓蹭腑鐨剗"
+        re = re.replace("}\"", "}");
+        //鍘婚櫎瀛楃涓蹭腑"{
+        re = re.replace("\"{", "{");
+        re = re.replace("\"null\"", "{}");
+        if (StringUtils.isBlank(re)) {
+            return "";
+        }
+        return re;
+    }
+}

--
Gitblit v1.9.3