From feac6e0c2db4e60d55417fde1971a0bc6d703566 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 27 五月 2022 15:58:28 +0800
Subject: [PATCH] fix

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java |   94 +++++++++++++++++------------------------------
 1 files changed, 34 insertions(+), 60 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 af55daf..bd05d86 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
@@ -2,10 +2,10 @@
 
 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;
@@ -28,8 +28,6 @@
     PoleLightemitService poleLightemitService;
     @Autowired
     ApplicationContext applicationContext;
-    @Autowired
-    NginxConfigBean nginxConfigBean;
     //body灏佽缂栫爜
     private final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
 
@@ -114,14 +112,14 @@
      *
      * @param ledCode
      */
-    public void clear(String ledCode) {
+    public String clear(String ledCode) {
         String postBody = new Gson().toJson(new Clear());
         //璇锋眰鍦板潃
         String url = realtimeServerBean.getCommand() + ledCode;
         //璇锋眰
-//        poleLightemitService.updateRequestBody(ledCode, "");
         String result = post(url, postBody);
         LogUtils.error("娓呭睆缁撴灉:" + result);
+        return result;
     }
 
     /**
@@ -131,10 +129,9 @@
      * @param username
      */
     public void postHtml(String ledCode, String username) {
-
+        //html缃戦〉鍐呭
         PostHtml postHtml = new PostHtml(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
         String postBody = new Gson().toJson(postHtml);
-
         //璇锋眰鍦板潃
         String url = realtimeServerBean.getCommand() + ledCode;
         //淇濆瓨led鏁版嵁
@@ -143,24 +140,6 @@
         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灞�
@@ -217,7 +196,6 @@
      * @param ledCode
      */
     public void clearVideoPlay(String ledCode) {
-//        poleLightemitService.updateRequestBody(ledCode, "");
         this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearVideoPlay()));
     }
 
@@ -227,8 +205,20 @@
      * @param ledCode
      */
     public void clearPlayerTask(String ledCode) {
-//        poleLightemitService.updateRequestBody(ledCode, "");
         this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearPlayerTask()));
+    }
+
+    /**
+     * 鍙戦�佹渶鏂扮殑鏁版嵁
+     *
+     * @param lightemitControlCode
+     */
+    public void sendLastCommand(String lightemitControlCode) {
+        PoleLightemitEntity poleLightemitEntity = poleLightemitService.getLedByLightControlCode(lightemitControlCode);
+        if (poleLightemitEntity == null || StringUtils.isBlank(poleLightemitEntity.getRequestBody())) {
+            return;
+        }
+        this.post(realtimeServerBean.getCommand() + lightemitControlCode, poleLightemitEntity.getRequestBody());
     }
 
     /**
@@ -243,7 +233,6 @@
             return "";
         }
         String re;
-
         try {
             re = JSONObject.parseObject(result).get("result").toString();
         } catch (Exception e) {
@@ -265,8 +254,8 @@
      * @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 {
@@ -280,35 +269,20 @@
         }
     }
 
-    /*
-    鍚姩xwalk
+
+    public boolean getLedOnLine(String ledCode) {
+        //閫氳繃灞忓箷鏄惁寮�鍚寚浠よ幏鍙栧睆骞曟槸鍚﹀湪绾�
+        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen()));
+        result = result.trim();
+        return result.startsWith("{") && result.endsWith("}");
+    }
+
+
+    /**
+     * 鎺у埗灞忓箷寮�鍏�
      */
-    /*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 {
@@ -331,8 +305,8 @@
 //        this.post(realtimeServerBean.getCommand() + lightemitControlCode, poleLightemitEntity.getRequestBody());
 //    }
 
-    /*
-    璁剧疆led闊抽噺
+    /**
+     * 璁剧疆led闊抽噺
      */
     public void setVoiume(String ledCode, Integer volume) {
 
@@ -346,9 +320,9 @@
     }
 
 
-    /*
-  璁剧疆led浜害
-   */
+    /**
+     * 璁剧疆led浜害
+     */
     public void setBrightness(String ledCode, Integer brightness) {
 
         SetBrightness setBrightness = new SetBrightness();

--
Gitblit v1.9.3