Commit 8599ded5 authored by 赵啸非's avatar 赵啸非

修改读取配置文件

parent 657260a1
...@@ -9,6 +9,7 @@ import cn.hutool.http.HttpUtil; ...@@ -9,6 +9,7 @@ import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.setting.dialect.Props; import cn.hutool.setting.dialect.Props;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONValidator;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
...@@ -28,6 +29,7 @@ import org.pcap4j.packet.TcpPacket; ...@@ -28,6 +29,7 @@ import org.pcap4j.packet.TcpPacket;
import java.io.EOFException; import java.io.EOFException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -239,21 +241,20 @@ public class CaptureThread implements Runnable { ...@@ -239,21 +241,20 @@ public class CaptureThread implements Runnable {
log.info("配置文件不存在,返回!"); log.info("配置文件不存在,返回!");
return; return;
} }
Props props = new Props(confPath);
//获取窗口id 默认值为0
windowId = props.getInt("windowId", 0);
//读取当前设置的窗口id
/* HcpReq hcpReq = new HcpReq();
hcpReq.setWindowid(windowId);//todo 读取窗口 共享文件
String hcpUrl = hcpGovUrl + "?affairCode=" + affairCode;
hcpReq.setUrl(hcpUrl);
String body = JSON.toJSONString(hcpReq); String json = FileUtil.readString(confPath, Charset.forName("UTF-8"));
// log.info("req url:{},body:{}", url, body);*/
boolean jsonBoolean = JSONValidator.from(json).validate();
if (!jsonBoolean) {
log.info("配置文件格式错误,返回!:{}", json);
return;
}
HcpReq hcpReq = JSON.parseObject(json, HcpReq.class);
String hcpUrl = hcpGovUrl + "?affairCode=" + affairCode; String hcpUrl = hcpGovUrl + "?affairCode=" + affairCode;
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("url", hcpUrl); paramMap.put("url", hcpUrl);
paramMap.put("windowid", windowId); paramMap.put("windowid", hcpReq.getWindowid());
log.info("req url:{},body:{}", url, JSON.toJSONString(paramMap)); log.info("req url:{},body:{}", url, JSON.toJSONString(paramMap));
String response = HttpUtil.post(url, paramMap); String response = HttpUtil.post(url, paramMap);
...@@ -283,4 +284,12 @@ public class CaptureThread implements Runnable { ...@@ -283,4 +284,12 @@ public class CaptureThread implements Runnable {
return buffer; return buffer;
} }
public static void main(String[] args) {
String json="{ } 12";
boolean jsonBoolean = JSONValidator.from(json).validate();
System.out.println(jsonBoolean);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment