From c93c61a5fc415d471a65fe8c3703b06e63aca178 Mon Sep 17 00:00:00 2001 From: wxm <115806199+youfanx@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:41:07 +0800 Subject: [PATCH] up hc --- rxlib/src/main/java/org/rx/core/RxConfig.java | 3 + .../main/java/org/rx/net/http/HttpClient.java | 81 ++++++++++++------- .../org/rx/net/support/ComboIPSearcher.java | 6 +- .../java/org/rx/net/support/IPSearcher.java | 4 +- rxlib/src/main/resources/rx.yml | 1 + rxlib/src/test/java/org/rx/net/TestSocks.java | 3 +- rxlib/src/test/java/org/rx/util/TestUtil.java | 14 ++++ 7 files changed, 72 insertions(+), 40 deletions(-) diff --git a/rxlib/src/main/java/org/rx/core/RxConfig.java b/rxlib/src/main/java/org/rx/core/RxConfig.java index a535fcad..66e61371 100644 --- a/rxlib/src/main/java/org/rx/core/RxConfig.java +++ b/rxlib/src/main/java/org/rx/core/RxConfig.java @@ -57,6 +57,7 @@ public interface ConfigNames { String NET_REACTOR_THREAD_AMOUNT = "app.net.reactorThreadAmount"; String NET_ENABLE_LOG = "app.net.enableLog"; String NET_CONNECT_TIMEOUT_MILLIS = "app.net.connectTimeoutMillis"; + String NET_READ_WRITE_TIMEOUT_MILLIS = "app.net.readWriteTimeoutMillis"; String NET_POOL_MAX_SIZE = "app.net.poolMaxSize"; String NET_POOL_KEEP_ALIVE_SECONDS = "app.net.poolKeepAliveSeconds"; String NET_USER_AGENT = "app.net.userAgent"; @@ -142,6 +143,7 @@ public static class NetConfig { int reactorThreadAmount; boolean enableLog; int connectTimeoutMillis; + int readWriteTimeoutMillis; int poolMaxSize; int poolKeepAliveSeconds; String userAgent; @@ -249,6 +251,7 @@ public void refreshFromSystemProperty() { net.reactorThreadAmount = SystemPropertyUtil.getInt(ConfigNames.NET_REACTOR_THREAD_AMOUNT, net.reactorThreadAmount); net.enableLog = SystemPropertyUtil.getBoolean(ConfigNames.NET_ENABLE_LOG, net.enableLog); net.connectTimeoutMillis = SystemPropertyUtil.getInt(ConfigNames.NET_CONNECT_TIMEOUT_MILLIS, net.connectTimeoutMillis); + net.readWriteTimeoutMillis = SystemPropertyUtil.getInt(ConfigNames.NET_READ_WRITE_TIMEOUT_MILLIS, net.readWriteTimeoutMillis); net.poolMaxSize = SystemPropertyUtil.getInt(ConfigNames.NET_POOL_MAX_SIZE, net.poolMaxSize); if (net.poolMaxSize <= 0) { net.poolMaxSize = Math.max(10, Constants.CPU_THREADS * 2); diff --git a/rxlib/src/main/java/org/rx/net/http/HttpClient.java b/rxlib/src/main/java/org/rx/net/http/HttpClient.java index c4b222b1..7f738f02 100644 --- a/rxlib/src/main/java/org/rx/net/http/HttpClient.java +++ b/rxlib/src/main/java/org/rx/net/http/HttpClient.java @@ -242,7 +242,7 @@ public String toString() { public static final CookieContainer COOKIES = new CookieContainer(); static final ConnectionPool POOL = new ConnectionPool(RxConfig.INSTANCE.getNet().getPoolMaxSize(), RxConfig.INSTANCE.getNet().getPoolKeepAliveSeconds(), TimeUnit.SECONDS); - static final MediaType FORM_TYPE = MediaType.parse("application/x-www-form-urlencoded; charset=utf-8"), JSON_TYPE = MediaType.parse("application/json; charset=utf-8"); + static final MediaType FORM_TYPE = MediaType.parse("application/x-www-form-urlencoded;charset=UTF-8"), JSON_TYPE = MediaType.parse("application/json; charset=utf-8"); static final X509TrustManager TRUST_MANAGER = new X509TrustManager() { final X509Certificate[] empty = new X509Certificate[0]; @@ -376,15 +376,15 @@ public static void saveRawCookie(@NonNull String url, @NonNull String cookie) { } @SneakyThrows - static OkHttpClient createClient(long timeoutMillis, boolean enableCookie, Proxy proxy) { + static OkHttpClient createClient(long connectTimeoutMillis, long readWriteTimeoutMillis, boolean enableCookie, Proxy proxy) { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, new TrustManager[]{TRUST_MANAGER}, new SecureRandom()); Authenticator authenticator = proxy instanceof AuthenticProxy ? ((AuthenticProxy) proxy).getAuthenticator() : Authenticator.NONE; OkHttpClient.Builder builder = new OkHttpClient.Builder() .sslSocketFactory(sslContext.getSocketFactory(), TRUST_MANAGER).hostnameVerifier((s, sslSession) -> true) .connectionPool(POOL).retryOnConnectionFailure(true) //unexpected end of stream - .connectTimeout(timeoutMillis, TimeUnit.MILLISECONDS) - .readTimeout(timeoutMillis, TimeUnit.MILLISECONDS).writeTimeout(timeoutMillis, TimeUnit.MILLISECONDS) + .connectTimeout(connectTimeoutMillis, TimeUnit.MILLISECONDS) + .readTimeout(readWriteTimeoutMillis, TimeUnit.MILLISECONDS).writeTimeout(readWriteTimeoutMillis, TimeUnit.MILLISECONDS) .proxy(proxy).proxyAuthenticator(authenticator); if (enableCookie) { builder.cookieJar(COOKIES); @@ -393,31 +393,55 @@ static OkHttpClient createClient(long timeoutMillis, boolean enableCookie, Proxy } //endregion - @Setter - boolean enableLog = RxConfig.INSTANCE.getNet().isEnableLog(); - @Setter - boolean cachingStream = true; - long timeoutMillis; - boolean enableCookie; + static byte CACHING_STREAM_FLAG = 1, ENABLE_COOKIE_FLAG = 1 << 1, ENABLE_LOG_FLAG = 1 << 2; + //1 cachingStream, 2 enableCookie, 4 enableLog + byte featureFlags = CACHING_STREAM_FLAG; + long connectTimeoutMillis, readWriteTimeoutMillis; AuthenticProxy proxy; //Not thread safe OkHttpClient client; HttpHeaders reqHeaders; ResponseContent resContent; - public synchronized void setTimeoutMillis(long timeoutMillis) { - this.timeoutMillis = timeoutMillis; + public HttpClient withFeatures(boolean enableCookie, boolean enableLog) { + return withFeatures(enableCookie, enableLog); + } + + public synchronized HttpClient withFeatures(boolean enableCookie, boolean enableLog, boolean cachingStream) { + if (enableLog) { + featureFlags |= ENABLE_LOG_FLAG; + } else { + featureFlags &= ~ENABLE_LOG_FLAG; + } + if (enableCookie) { + featureFlags |= ENABLE_COOKIE_FLAG; + } else { + featureFlags &= ~ENABLE_COOKIE_FLAG; + } + if (cachingStream) { + featureFlags |= CACHING_STREAM_FLAG; + } else { + featureFlags &= ~CACHING_STREAM_FLAG; + } client = null; + return this; + } + + public HttpClient withTimeoutMillis(long timeoutMillis) { + return withTimeoutMillis(timeoutMillis, timeoutMillis); } - public synchronized void setEnableCookie(boolean enableCookie) { - this.enableCookie = enableCookie; + public synchronized HttpClient withTimeoutMillis(long connectTimeoutMillis, long readWriteTimeoutMillis) { + this.connectTimeoutMillis = connectTimeoutMillis; + this.readWriteTimeoutMillis = readWriteTimeoutMillis; client = null; + return this; } - public synchronized void setProxy(AuthenticProxy proxy) { + public synchronized HttpClient withProxy(AuthenticProxy proxy) { this.proxy = proxy; client = null; + return this; } public HttpClient withUserAgent() { @@ -445,21 +469,14 @@ public HttpHeaders requestHeaders(boolean readOnly) { } public HttpClient() { - this(RxConfig.INSTANCE.getNet().getConnectTimeoutMillis()); - } - - public HttpClient(long timeoutMillis) { - this(timeoutMillis, false); - } - - public HttpClient(long timeoutMillis, boolean enableCookie) { - this.timeoutMillis = timeoutMillis; - this.enableCookie = enableCookie; + RxConfig.NetConfig conf = RxConfig.INSTANCE.getNet(); + withFeatures(false, conf.isEnableLog()); + withTimeoutMillis(conf.getConnectTimeoutMillis(), conf.getReadWriteTimeoutMillis()); } OkHttpClient getClient() { if (client == null) { - client = createClient(timeoutMillis, enableCookie, proxy); + client = createClient(connectTimeoutMillis, readWriteTimeoutMillis, (featureFlags & ENABLE_COOKIE_FLAG) == ENABLE_COOKIE_FLAG, proxy); } return client; } @@ -473,8 +490,10 @@ Request.Builder createRequest(String url) { } @SneakyThrows - private synchronized ResponseContent invoke(String url, HttpMethod method, RequestContent content) { - ProceedEventArgs args = new ProceedEventArgs(this.getClass(), new Object[]{method.toString(), content.toString()}, false); + synchronized ResponseContent invoke(String url, HttpMethod method, RequestContent content) { + ProceedEventArgs args = new ProceedEventArgs(this.getClass(), + new Object[]{method.toString(), content instanceof JsonContent ? ((JsonContent) content).json : content.toString()}, + false); try { Request.Builder request = createRequest(url); RequestBody requestBody = content.toBody(); @@ -498,14 +517,14 @@ private synchronized ResponseContent invoke(String url, HttpMethod method, Reque } return resContent = args.proceed(() -> { ResponseContent rc = new ResponseContent(getClient().newCall(request.build()).execute()); - rc.cachingStream = cachingStream; + rc.cachingStream = (featureFlags & CACHING_STREAM_FLAG) == CACHING_STREAM_FLAG; return rc; }); } catch (Throwable e) { args.setError(e); throw e; } finally { - if (enableLog) { + if ((featureFlags & ENABLE_LOG_FLAG) == ENABLE_LOG_FLAG) { logHttp(args, url); } } @@ -628,7 +647,7 @@ public RequestBody toBody() { // boolean isGet = Strings.equalsIgnoreCase(servletRequest.getMethod(), HttpMethod.GET.name()); // ResponseContent resContent = new ResponseContent(getClient().newCall(createRequest(forwardUrl).method(servletRequest.getMethod(), isGet ? null : reqContent.toBody()).build()).execute()); ResponseContent resContent = new ResponseContent(getClient().newCall(createRequest(forwardUrl).method(servletRequest.getMethod(), reqContent.toBody()).build()).execute()); - resContent.cachingStream = cachingStream; + resContent.cachingStream = (featureFlags & CACHING_STREAM_FLAG) == CACHING_STREAM_FLAG; servletResponse.setStatus(resContent.response.code()); for (Pair header : resContent.responseHeaders()) { servletResponse.setHeader(header.getFirst(), header.getSecond()); diff --git a/rxlib/src/main/java/org/rx/net/support/ComboIPSearcher.java b/rxlib/src/main/java/org/rx/net/support/ComboIPSearcher.java index 1731265d..f175b178 100644 --- a/rxlib/src/main/java/org/rx/net/support/ComboIPSearcher.java +++ b/rxlib/src/main/java/org/rx/net/support/ComboIPSearcher.java @@ -43,7 +43,7 @@ public ComboIPSearcher() { @Override public String currentIp() { - return Tasks.randomRetry(() -> new HttpClient(TIMEOUT_SECONDS).get("https://api.ipify.org").toString(), + return Tasks.randomRetry(() -> new HttpClient().withTimeoutMillis(TIMEOUT_SECONDS).get("https://api.ipify.org").toString(), () -> searchCurrent().getIp()); } @@ -177,9 +177,7 @@ IPAddress ipInfo(String ip) { } private JSONObject getJson(String url, PredicateFunc check) { - HttpClient client = new HttpClient(TIMEOUT_SECONDS); - client.setEnableLog(true); - String text = client.get(url).toString(); + String text = new HttpClient().withFeatures(false, true).withTimeoutMillis(TIMEOUT_SECONDS).get(url).toString(); if (Strings.isEmpty(text)) { throw new InvalidException("Empty response from {}", url); } diff --git a/rxlib/src/main/java/org/rx/net/support/IPSearcher.java b/rxlib/src/main/java/org/rx/net/support/IPSearcher.java index 2e9a5688..b1a048c7 100644 --- a/rxlib/src/main/java/org/rx/net/support/IPSearcher.java +++ b/rxlib/src/main/java/org/rx/net/support/IPSearcher.java @@ -12,9 +12,7 @@ static String godaddyDns(String ssoKey, String domain, String name) { static String godaddyDns(String ssoKey, String domain, String name, String ip, AuthenticProxy proxy) { String u = String.format("https://api.godaddy.com/v1/domains/%s/records/A/%s", domain, name); - HttpClient c = new HttpClient(); - c.setEnableLog(true); - c.setProxy(proxy); + HttpClient c = new HttpClient().withFeatures(false, true).withProxy(proxy); c.requestHeaders().add("Authorization", "sso-key " + ssoKey); return c.putJson(u, String.format("[\n" + " {\n" + diff --git a/rxlib/src/main/resources/rx.yml b/rxlib/src/main/resources/rx.yml index f8e0e4fb..1633c3ed 100644 --- a/rxlib/src/main/resources/rx.yml +++ b/rxlib/src/main/resources/rx.yml @@ -31,6 +31,7 @@ app: reactorThreadAmount: 0 enableLog: false connectTimeoutMillis: 15000 + readWriteTimeoutMillis: 60000 poolMaxSize: 0 poolKeepAliveSeconds: 120 userAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 QBCore/4.0.1301.400 QQBrowser/9.0.2524.400 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2875.116 Safari/537.36 NetType/WIFI MicroMessenger/7.0.5 WindowsWechat diff --git a/rxlib/src/test/java/org/rx/net/TestSocks.java b/rxlib/src/test/java/org/rx/net/TestSocks.java index 094462a9..e973a377 100644 --- a/rxlib/src/test/java/org/rx/net/TestSocks.java +++ b/rxlib/src/test/java/org/rx/net/TestSocks.java @@ -959,8 +959,7 @@ public void httpServer() { }); RxConfig.INSTANCE.setLogStrategy(LogStrategy.ALWAYS); - HttpClient client = new HttpClient(); - client.setEnableLog(true); + HttpClient client = new HttpClient().withFeatures(false, true); assert hbody.equals(client.post(HttpClient.buildUrl("https://127.0.0.1:8081/api", qs), f, fi).toString()); String resJson = client.postJson("https://127.0.0.1:8081/json", j).toString(); diff --git a/rxlib/src/test/java/org/rx/util/TestUtil.java b/rxlib/src/test/java/org/rx/util/TestUtil.java index bce1fcde..dd96bf8b 100644 --- a/rxlib/src/test/java/org/rx/util/TestUtil.java +++ b/rxlib/src/test/java/org/rx/util/TestUtil.java @@ -7,6 +7,8 @@ import lombok.Data; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import okhttp3.Cookie; +import okhttp3.HttpUrl; import org.apache.commons.io.FilenameUtils; import org.junit.jupiter.api.Test; import org.rx.AbstractTester; @@ -16,6 +18,7 @@ import org.rx.bean.*; import org.rx.core.*; import org.rx.exception.InvalidException; +import org.rx.net.http.HttpClient; import org.rx.test.GirlBean; import org.rx.test.PersonBean; import org.rx.test.PersonGender; @@ -23,6 +26,7 @@ import org.rx.third.guava.CaseFormat; import java.lang.reflect.Method; +import java.net.URI; import java.time.Month; import java.util.Arrays; import java.util.*; @@ -269,6 +273,11 @@ public void other() { // }); // } + String s = "{\"data\":{\"row\":{\"buyerTelephone\":\"18575686257\",\"deliveryTime\":\"2024-4-23 15:00-18:00\",\"coldChainStatus\":1,\"orderPaymentType\":3,\"orderOmsId\":\"102448352115074461\",\"deliveryStartTemperature\":\"0\",\"storePhone\":\"028-65239611\",\"deliveryEndTemperature\":\"0\",\"buyerFullName\":\"陈先生\",\"channelOrderId\":\"20009346551090415\",\"deliverTime\":\"2024-04-23 18:18:01\",\"deliveryBillItemId\":1062,\"deliveryManId\":92,\"serialNo\":\"TESTA001\",\"replySlip\":\"https://gjscrm-1256038144.cos.ap-beijing.myqcloud.com/mobile/050d022daed64bf2b0092515f354631a.jpg\",\"dispatchTime\":\"2024-04-23 18:17:52\",\"orderJson\":{\"orderBase\":{\"orderId\":20009346551090415,\"type\":10,\"userId\":-171386619041599999,\"businessId\":99999,\"storeId\":87446199999,\"orderStatus\":524352,\"orderStatusCur\":14,\"payAmount\":100,\"totalAmount\":100,\"couponAmount\":0,\"expressFee\":0,\"consigneeId\":0,\"consignee\":\"陈先生\",\"consigneePhone\":\"185****6257\",\"consigneeProvince\":\"\",\"consigneeCity\":\"\",\"consigneeArea\":\"\",\"consigneeAddress\":\"上海市四安***\",\"payChannel\":\"1\",\"status\":0,\"extend\":\"{\\\"advanceBookingType\\\":0,\\\"advancePayment\\\":0,\\\"appointmentFlag\\\":0,\\\"b2cSource\\\":0,\\\"coldchainind\\\":1,\\\"consigneeAddress\\\":\\\"\\\",\\\"coverPostAge\\\":false,\\\"dataSource\\\":0,\\\"deliveryMode\\\":3,\\\"ebaoCardPaidAmount\\\":0,\\\"epidemicFlag\\\":0,\\\"erpShiftId\\\":\\\"A\\\",\\\"extendTable\\\":1,\\\"fromCart\\\":0,\\\"fromOms\\\":0,\\\"fullAddress\\\":\\\"\\\",\\\"goodsOrderType\\\":1,\\\"hasAfterSale\\\":0,\\\"hmoCardPayStatus\\\":0,\\\"hmoPayFullNotifyStatus\\\":0,\\\"hmoPayFullStatus\\\":0,\\\"isAppointment\\\":0,\\\"isImagePrescription\\\":0,\\\"isNotify\\\":0,\\\"isRegisterEpidemic\\\":0,\\\"lossType\\\":1,\\\"newUserOnly\\\":false,\\\"notifyPos\\\":0,\\\"offSale\\\":false,\\\"orderWxPointsOverdue\\\":0,\\\"payJumpType\\\":1,\\\"payNo\\\":\\\"20020102404231818492473101990415\\\",\\\"pointsGiven\\\":false,\\\"posDeliveryEndTime\\\":\\\"18:00\\\",\\\"posDeliveryId\\\":\\\"92\\\",\\\"posDeliveryName\\\":\\\"连锁药师测试专用001\\\",\\\"posDeliveryStartTime\\\":\\\"15:00\\\",\\\"posDeliveryTime\\\":\\\"2024-4-23 15:00-18:00\\\",\\\"preCardPaidAmount\\\":0,\\\"preOrderId\\\":\\\"54af7987eef24ac78ee29270e1ff443c\\\",\\\"prescriptionFlag\\\":0,\\\"prescriptionProvid\\\":0,\\\"processId\\\":\\\"b410c62867a7443fa1f2016d2866462a\\\",\\\"processStartTime\\\":\\\"2024-04-23 17:56:18\\\",\\\"productName\\\":\\\"200\\\",\\\"productType\\\":200,\\\"promotionPayPoint\\\":0,\\\"realTimeAppointment\\\":0,\\\"relationRuleShow\\\":0,\\\"retureCouponFlag\\\":false,\\\"rxsalesind\\\":2,\\\"saleSaveCard\\\":false,\\\"scanType\\\":\\\"0\\\",\\\"selfPickupSiteGroupImg\\\":\\\"\\\",\\\"sendCouponFlag\\\":false,\\\"sendIntegralLimit\\\":0,\\\"stockLock\\\":false,\\\"storeExpressType\\\":0,\\\"tongChouPay\\\":true,\\\"totalFair\\\":0,\\\"transferGoodsFlag\\\":false,\\\"useMemberPrice\\\":1,\\\"useNewPromotion\\\":0,\\\"zdtUserCode\\\":\\\"16591565\\\",\\\"zdtUserId\\\":193893723199999,\\\"zdtUserName\\\":\\\"连锁药师测试专用001\\\"}\",\"version\":0,\"payPoints\":0,\"thirdPartyOrderNo\":\"610234722902\",\"promotionDiscounts\":0,\"memberPlusDiscounts\":0,\"itemType\":1,\"wipeMoney\":0,\"payType\":1,\"storeName\":\"01-scrm001测试\",\"totalOriginalAmount\":100,\"promotionLabel\":\"|S_0|\",\"cashier\":\"连锁药师测试专用001\",\"cashierId\":16591565,\"purchasePayAmount\":0,\"orderSign\":\"000000000\",\"offlineCouponAmount\":0,\"pointsDiscountAmount\":0,\"orderSource\":83,\"presentPoints\":0,\"payTime\":1713867930000,\"gmtCreate\":\"2024-04-23T09:56:31\",\"createdAt\":\"2024-04-23 17:56:31\"},\"orderDetails\":[{\"detailId\":20005657961190415,\"orderId\":20009346551090415,\"skuId\":1029942,\"skuName\":\"六神曲\",\"specificationsName\":\"无\",\"skuImage\":\"\",\"skuPrice\":100,\"couponAmount\":0,\"settlePrice\":100,\"points\":0,\"skuCount\":1,\"status\":0,\"extend\":\"{\\\"commonProperty\\\":\\\"{\\\\\\\"orderType\\\\\\\":\\\\\\\"10\\\\\\\"}\\\",\\\"healthInsurance\\\":false,\\\"isRx\\\":2,\\\"expectDays\\\":0,\\\"hasMappingCode\\\":false,\\\"transferGoodsFlag\\\":false,\\\"minPriceSaleState\\\":0,\\\"coldchainind\\\":2,\\\"isSpecial\\\":0,\\\"planWhole\\\":false,\\\"relationAdd\\\":0,\\\"pushLevel\\\":\\\"A5\\\",\\\"otcType\\\":2,\\\"packageGoods\\\":0,\\\"isBreakPrice\\\":0,\\\"isSimulatedGoods\\\":0}\",\"version\":0,\"itemId\":1029942,\"salesman\":\"连锁药师测试专用001\",\"salesmanId\":\"16591565\",\"itemCode\":\"1029942\",\"batchNo\":\"20180906\",\"promotionPrice\":100,\"displayPrice\":100,\"displayPriceType\":0,\"promotionDiscounts\":0,\"dismantled\":0,\"goodsUnit\":\"克\",\"goodsNo\":\"1029942\",\"promotionGift\":0,\"batchCode\":\"1932700001\",\"skuLabel\":\"\",\"pointsTimes\":100,\"businessId\":99999,\"storeId\":87446199999,\"orderStatusCur\":14,\"storeName\":\"01-scrm001测试\",\"cashier\":\"连锁药师测试专用001\",\"cashierId\":193893723199999,\"userCardNum\":\"\",\"username\":\"\",\"userPhone\":\"\",\"name\":\"六神曲\",\"expireDate\":\"2025-12-30 00:00:00\",\"producter\":\"四川弘升药业有限公司\",\"promotionInfo\":\"{}\",\"promotionShareTotal\":0,\"type\":10}]},\"coldNumber\":\"004\",\"buyerFllDetails\":\"陈先生 18575686257 上海市四安里8号\",\"buyerFullAddress\":\"上海市四安里8号\",\"payDetails\":[{\"id\":109,\"payId\":109,\"payNo\":\"20020102404231818492473101990415\",\"merchantOrderNo\":\"20009346551090415\",\"orderAmount\":100,\"orderPayAmount\":100,\"payAmount\":100,\"payTime\":1713867529000,\"refundAmount\":100,\"successAmount\":100,\"successTime\":1713867529000,\"payStatus\":1,\"channelType\":6,\"productType\":200,\"merchantId\":20,\"businessId\":99999,\"storeId\":87446199999,\"description\":\"\",\"settleType\":1,\"billingStatus\":0,\"payUserId\":-171386619041599999,\"requestIp\":\"127.0.0.2\",\"requestUserIp\":\"127.0.0.2\",\"status\":0,\"gmtCreate\":1713867529000,\"gmtUpdate\":1713867529000,\"extend\":\"{\\\"businessName\\\":\\\"00积分商城连锁\\\",\\\"cashierUserId\\\":\\\"16591565\\\",\\\"deviceInfoId\\\":0,\\\"mdmComId\\\":\\\"3000\\\",\\\"mdmStoreNo\\\":\\\"A00Z\\\",\\\"orderSource\\\":0,\\\"posOrderId\\\":\\\"20009346551090415\\\",\\\"riskFundAmount\\\":0,\\\"shareSubBusinessId\\\":0,\\\"storeName\\\":\\\"scrm001测试\\\"}\",\"version\":3,\"createdBy\":0,\"sapChannelType\":\"1000\",\"mchId\":\"123\"}],\"prescription\":{\"doctorHospital\":\"首都医科大学附属北京安贞医院\",\"doctorName\":\"陈志超\",\"medicines\":[{\"medicineCode\":\"1029942\",\"singleDosageUnit\":\"片\",\"unit\":\"盒\",\"medicineUsage\":\"口服\",\"medicineCommonName\":\"六神曲\",\"num\":1.0,\"specification\":\"无\",\"singleDosage\":\"1\",\"frequency\":\"1日1次\"}],\"presDoctorName\":\"朱一龙\",\"prescriptionDate\":\"2024-04-23 14:37:38\",\"doctorId\":229527513620001,\"prescriptionNumber\":\"610234722902\",\"diseaseDescription\":\"肠炎\",\"department\":\"内科\",\"patientInfoDTO\":{\"sex\":1,\"name\":\"苏欣荣\",\"age\":43.0}},\"deliveryName\":\"连锁药师测试专用001\",\"deliveryStatus\":50,\"coldBoxNumber\":\"A3333\"}},\"status\":0}"; + + JSONObject sx = JSONObject.parseObject(s); + System.out.println("asd:"+ Sys.readJsonValue(sx,"data.row").toString()); + //compareVersion assert Strings.compareVersion("1.01", "1.001") == 0; assert Strings.compareVersion("1.0", "1.0.0") == 0; @@ -423,5 +432,10 @@ public void third() { assert "ROW_ID".equals(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, "rowId")); assert "ROW_ID".equals(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, "RowId")); + + String s = "http://x.f-li.cn/asd"; + System.out.println(HttpUrl.get(s).host()); + System.out.println(HttpUrl.get(s).topPrivateDomain()); + System.out.println(URI.create(s).getHost()); } }