main
han-l 2 years ago
parent 7bbdb446be
commit 1d4aaf946a

@ -10,10 +10,7 @@ import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.*;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.util.MultiValueMap;
@ -28,6 +25,36 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
public class HTTPUtil {
public static String sendPOSTRequest(String url, String json) {
RestTemplate restTemplate = new RestTemplate();
// 设置请求头信息
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
// 构建请求体数据
// 创建HttpEntity对象并将请求头和请求体添加进去
HttpEntity<String> entity = new HttpEntity<>(json, headers);
// 发送POST请求
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
// 获取返回结果
String result = response.getBody();
return result;
// RestTemplate client = new RestTemplate();
// HttpHeaders headers = new HttpHeaders();
// HttpMethod method = HttpMethod.POST;
// // 以表单的方式提交
//// headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
// headers.setContentType(MediaType.APPLICATION_JSON);
// // 将请求头部和参数合成一个请求
// HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
// // 执行HTTP请求将返回的结构使用String类格式化
// ResponseEntity<String> response = client.exchange(url, method, requestEntity, String.class);
// return response.getBody();
}
/**
* @param url

@ -52,7 +52,7 @@ public class LogUtil {
filedir.mkdir();
File[] fs = logPathFile.listFiles();
LocalDateTime now = LocalDateTime.now();
int delFlag = Integer.parseInt(now.minus(30, ChronoUnit.DAYS).format(DateTimeFormatter.ofPattern("yyyyMMdd")));
int delFlag = Integer.parseInt(now.minus(7, ChronoUnit.DAYS).format(DateTimeFormatter.ofPattern("yyyyMMdd")));
if (fs != null) {
for (File f : fs) {
int deldir = Integer.parseInt(f.getName());

@ -2,33 +2,35 @@ package com.nmgs.util;
import com.trkf.PasswordEncryption.PassWordUtils;
import org.json.JSONObject;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class Main {
static int counter = 0;
static final Object room = new Object();
public static void main(String[] args) throws UnsupportedEncodingException, InterruptedException {
// Thread t1 = new Thread(() -> {
// for (int i = 0; i < 5000; i++) {
// synchronized (room) {
// counter++;
// }
// }
// }, "t1");
// Thread t2 = new Thread(() -> {
// for (int i = 0; i < 5000; i++) {
// synchronized (room) {
// counter--;
// }
// }
// }, "t2");
// t1.start();
// t2.start();
// t1.join();
// t2.join();
// System.out.println(counter);
// String url, MultiValueMap<String, String> params, HttpMethod method, HttpHeaders headers
String url="http://192.168.101.70:5000/lvtong/vehicle/info";
Map<String, String> valueMap = new HashMap<>();
valueMap.put("vehicleId","蒙A37V70_01");
valueMap.put("startTime","2024-01-11 00:00:00");
valueMap.put("endTime","2024-01-11 23:59:59");
HttpHeaders headers=new HttpHeaders();
headers.add("Content-Type","application/json");
String aaa=HTTPUtil.sendPOSTRequest(url,new JSONObject(valueMap).toString());
System.out.println(aaa.replace("\\",""));
Map<String, Object> map = com.alibaba.fastjson.JSONObject.parseObject(aaa);
System.out.println(map);
}
}

@ -131,6 +131,7 @@
<workItem from="1704266777528" duration="22000" />
<workItem from="1704447514285" duration="566000" />
<workItem from="1704674001080" duration="775000" />
<workItem from="1704788088455" duration="386000" />
</task>
<task id="LOCAL-00001" summary="变更">
<created>1699319109952</created>

@ -50,9 +50,9 @@ export const uploadSpeedTest = data => post("/system/systemView/uploadSpeedTest"
//配置文件管理
export const selectAll = data => post("/system/systemControl/selectAll", data)
export const saveAll = data => post("/system/systemControl/saveAll", data)
//版本管理
export const selectVersionAll = data => post("/system/version/selectVersionAll", data)
export const showVersionText = data => post("/system/version/showVersionText", data)
//版本管理
//站管理配置
export const selectAllHuman = (data) => post("/system/UserSta/selectAllHumanOfUserSta", data)
export const selectStaTree = () => post("/system/UserSta/selectStaTree", {})

Loading…
Cancel
Save