From 9f21969b69703a35bde9d659be19f3e39795010d Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期四, 12 五月 2022 11:58:01 +0800
Subject: [PATCH] fix

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java |   86 ++++++++++++++++++++++--------------------
 1 files changed, 45 insertions(+), 41 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 460f387..ee17684 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");
 
@@ -143,24 +141,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灞�
@@ -232,6 +212,19 @@
     }
 
     /**
+     * 鍙戦�佹渶鏂扮殑鏁版嵁
+     *
+     * @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());
+    }
+
+    /**
      * 鑾峰彇led灞忕敾闈�
      *
      * @param ledCode
@@ -266,6 +259,7 @@
      */
     public String getIsScreenOpen(String ledCode) {
         String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen()));
+        LogUtils.error("getIsScreenOpen:" + result);
         //鑾峰彇base64鍥剧墖鏁版嵁
         if (StringUtils.isNotBlank(result)) {
             String re;
@@ -280,28 +274,23 @@
         }
     }
 
-    /*
-    鍚姩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){
+    public boolean getLedOnLine(String ledCode) {
+        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen()));
+        LogUtils.error("getLedOnLine:" + result);
+        //鑾峰彇base64鍥剧墖鏁版嵁
+        if (StringUtils.isNotBlank(result)) {
+            String re;
+            if (result.contains("not exist")) {
+                return false;
+            } else {
+                return true;
+            }
+        } else {
+            return false;
+        }
+    }
 
-        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);
-    }*/
 
     /*
    鎺у埗灞忓箷寮�鍏�
@@ -345,6 +334,21 @@
         LogUtils.error("璁剧疆缁撴灉:-------------------" + result);
     }
 
+
+    /*
+  璁剧疆led浜害
+   */
+    public void setBrightness(String ledCode, Integer brightness) {
+
+        SetBrightness setBrightness = new SetBrightness();
+        setBrightness.arg1 = brightness;
+        String postBody = new Gson().toJson(setBrightness);
+
+        //璇锋眰
+        String result = post(realtimeServerBean.getCommand() + ledCode, postBody);
+        LogUtils.error("璁剧疆缁撴灉:-------------------" + result);
+    }
+
     //    鑾峰彇led闊抽噺
     public String getVoiume(String ledCode) {
         GetVolume getVolume = new GetVolume();

--
Gitblit v1.9.3