From c8ce26aac0004e249a0cef35fe15b2ddb280ad25 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期三, 27 四月 2022 15:51:10 +0800
Subject: [PATCH] 大气数据推送到LED
---
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java | 77 ++++++++++++++++++++++++++++----------
1 files changed, 56 insertions(+), 21 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 1c9e8ac..8d20209 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
@@ -6,6 +6,7 @@
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;
@@ -14,6 +15,10 @@
import org.springframework.stereotype.Component;
import java.io.IOException;
+
+/**
+ * 鐔欒灞忓箷鎺у埗
+ */
@Component
public class LightemitUtils {
@@ -32,10 +37,10 @@
private OkHttpClient client = new OkHttpClient();
-// public void init(){
-// //閲嶆柊鑾峰彇鍗曚緥
-// poleLightemitService = applicationContext.getBean(PoleLightemitService.class);
-// }
+ public void init() {
+ //閲嶆柊鑾峰彇鍗曚緥
+ poleLightemitService = applicationContext.getBean(PoleLightemitService.class);
+ }
/**
* post璇锋眰灏佽鏂规硶
@@ -117,6 +122,7 @@
//璇锋眰
// poleLightemitService.updateRequestBody(ledCode, "");
String result = post(url, postBody);
+ LogUtils.error("娓呭睆缁撴灉:" + result);
}
/**
@@ -137,12 +143,14 @@
//璇锋眰
String result = post(url, postBody);
}
+
/**
* html浼犺緭鑷砽ed灞�, 閫氳繃url鑾峰彇html
+ *
* @param ledCode
* @param username
*/
- public void postHtmlUseNginx(String ledCode, String username){
+ public void postHtmlUseNginx(String ledCode, String username) {
PostHtml postHtml = new PostHtml(nginxConfigBean.getUrl() + username + "_" + ledCode + ".html");
String postBody = new Gson().toJson(postHtml);
@@ -152,11 +160,12 @@
//淇濆瓨led鏁版嵁
poleLightemitService.updateRequestBody(ledCode, postBody);
//璇锋眰
- String result = post(url,postBody);
+ String result = post(url, postBody);
}
/**
* 瑙嗛浼犺緭鑷砽ed灞�
+ *
* @param screenWidth
* @param screenHeight
* @param filename
@@ -174,12 +183,12 @@
//led寮�鍙戞澘瑙嗛鍒楄〃璇锋眰body
SetPlayList setPlayList = new SetPlayList();
- setPlayList.list[0] = "/data/data/com.xixun.xy.conn/files/local/abc/"+filename;
+ setPlayList.list[0] = "/data/data/com.xixun.xy.conn/files/local/abc/" + filename;
// setPlayList.pathList[0] = "";
- try{
+ try {
setPlayList.width = Integer.valueOf(screenWidth);
setPlayList.height = Integer.valueOf(screenHeight);
- }catch (Exception e){
+ } catch (Exception e) {
return;
}
String postBody = new Gson().toJson(setPlayList);
@@ -191,12 +200,13 @@
/**
* led灞忓瓧骞曡缃�
+ *
* @param subTitleSet
* @param ledCode
*/
- public void subTitleSet(SubTitleSet subTitleSet, String ledCode, Boolean isSave){
- String postBody = new Gson().toJson(subTitleSet);
- if(isSave == true){
+ 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);
@@ -220,6 +230,18 @@
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());
}
/**
@@ -333,29 +355,42 @@
//璇锋眰
String result = post(realtimeServerBean.getCommand() + ledCode, postBody);
+ LogUtils.error("璁剧疆缁撴灉:-------------------" + result);
}
+
/*
- 鑾峰彇led闊抽噺
- */
- /*public String getVoiume(String ledCode){
+ 璁剧疆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();
String postBody = new Gson().toJson(getVolume);
//璇锋眰
- String result = post(realtimeServerBean.getCommand() + ledCode,postBody);
+ String result = post(realtimeServerBean.getCommand() + ledCode, postBody);
//璇锋眰
- if(StringUtils.isNotBlank(result)){
- try{
+ if (StringUtils.isNotBlank(result)) {
+ try {
return JSONObject.parseObject(result).get("result").toString();
- }catch (Exception e){
+ } catch (Exception e) {
return "0";
}
- }else{
+ } else {
return "0";
}
}
-*/
/**
* 鏌ヨ瀹氭椂
--
Gitblit v1.9.3