|
@@ -1,7 +1,9 @@
|
|
|
package com.huimv.env.input.server;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
//import com.huimv.env.common.service.IRawDataService;
|
|
|
import com.huimv.env.common.utils.RegexUtil;
|
|
@@ -17,7 +19,11 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
|
import io.netty.util.CharsetUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
@@ -97,7 +103,20 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
* @Time : 17:36
|
|
|
*/
|
|
|
private void handleClientAskCmd(String clientAskText, ChannelHandlerContext ctx) throws ParseException, IOException {
|
|
|
+
|
|
|
+ askTextSb.delete(0, askTextSb.length());
|
|
|
+
|
|
|
System.out.println("接收到消息"+clientAskText);
|
|
|
+ if (clientAskText.length() > 10) {
|
|
|
+ HashMap<String, String> paramsMap = new HashMap<>();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("result", clientAskText);
|
|
|
+ System.out.println(jsonObject);
|
|
|
+ paramsMap.put("Content-Type", "application/json;charset=utf-8");
|
|
|
+ String post = HttpRequest.post("https://huatong.ifarmcloud.com/huatongApi/env-nh3-n/send")
|
|
|
+ .headerMap(paramsMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
|
|
|
+ System.out.println(post);
|
|
|
+ }
|
|
|
ctx.writeAndFlush(Unpooled.copiedBuffer("rok".getBytes()));
|
|
|
|
|
|
// clientAskText = clientAskText.replaceAll("\r", "").replaceAll("\n", "");
|