This commit is contained in:
2025-03-09 21:44:39 +08:00
parent b600f7f5af
commit b400a1e0bc
11 changed files with 248 additions and 106 deletions

View File

@@ -10,6 +10,9 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
public class OwnHttpUtils {
@@ -25,9 +28,10 @@ public class OwnHttpUtils {
public static CalcResultVo getBaseCalc(String fileName, String personName) {
// 目标接口地址
String jsonBody = String.format("{\"file_name\":\"%s\",\"person_name\":\"%s\"}", fileName, personName);
jsonBody = getResult("get_person_info",jsonBody);
String jsonBody = String.format("{\"file_name\":%s,\"person_name\":\"%s\"}", fileName, personName);
System.out.println(jsonBody);
jsonBody = getResult("get_person_info",jsonBody);
// 1. 将 JSON 字符串解析成 JSONObject
JSONObject jsonObject = JSON.parseObject(jsonBody);
@@ -107,12 +111,7 @@ public class OwnHttpUtils {
}
public static void main(String[] args) {
String fileName = "/home/ubuntu/lyq/fad_oa_kqdeal/202411.json";
String personName = "丁苗松";
String jsonBody = String.format("{\"file_name\":\"%s\",\"person_name\":\"%s\"}", fileName, personName);
StringToDate("2025-03");
}
@@ -164,4 +163,20 @@ public class OwnHttpUtils {
return null;
}
}
private static Date StringToDate(String dateStr) {
// 1. 解析字符串到 YearMonth只包含年和月
YearMonth yearMonth = YearMonth.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM"));
// 2. 在 YearMonth 基础上指定“日”为 1
LocalDate localDate = yearMonth.atDay(1);
// 3. 转成 Instant
Instant instant = localDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
// 4. 转成旧版本 Date
return Date.from(instant);
}
}