2021与蓝度共同重构项目,服务端
liuhaonan
2022-05-06 93c4a7420a87b7d7e2bbeeef8e6ccff0a8909a9d
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传输至led屏, 通过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);
    }
    /**
     * 视频传输至led屏
@@ -229,6 +209,19 @@
    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());
    }
    /**
@@ -345,6 +338,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();