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屏
@@ -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