From 938d93722b6ebaf8953e1e17307ef7739affc3d0 Mon Sep 17 00:00:00 2001 From: wzp <2040239371@qq.com> Date: 星期日, 04 五月 2025 16:21:11 +0800 Subject: [PATCH] feat: 回调地址可配置、回调接口文档和知情同意 --- ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java | 78 +++++++++++++++++++++++++++------------ 1 files changed, 54 insertions(+), 24 deletions(-) diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java index 6fdb634..10363e2 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java @@ -1,12 +1,10 @@ package com.ruoyi.quartz.task; import com.ruoyi.common.utils.HttpUtil; -import com.ruoyi.system.domain.AOrderStatus; -import com.ruoyi.system.domain.DispatchOrd; -import com.ruoyi.system.domain.OrderStatusCallBackVo; -import com.ruoyi.system.domain.TbOrders; +import com.ruoyi.system.domain.*; import com.ruoyi.system.service.IAOrderStatusService; import com.ruoyi.system.service.IDispatchOrdService; +import com.ruoyi.system.service.ISysClientAppService; import com.ruoyi.system.service.ITbOrdersService; import com.ruoyi.system.service.impl.SysUserServiceImpl; import org.slf4j.Logger; @@ -37,6 +35,9 @@ @Autowired private IDispatchOrdService dispatchOrdService; + @Autowired + private ISysClientAppService sysClientAppService; + public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { System.out.println(StringUtils.format("鎵ц澶氬弬鏂规硶锛� 瀛楃涓茬被鍨媨}锛屽竷灏旂被鍨媨}锛岄暱鏁村瀷{}锛屾诞鐐瑰瀷{}锛屾暣褰}", s, b, l, d, i)); @@ -52,6 +53,9 @@ System.out.println("鎵ц鏃犲弬鏂规硶"); } + /** + * 鍥炶皟鎺ㄩ�佺姸鎬� + */ public void ryOrderStatus() { try { List<AOrderStatus> orderStatusList = orderStatusService.selectAOrderStatusList(); @@ -62,7 +66,6 @@ for (AOrderStatus orderStatus : orderStatusList) { int count = tbOrdersService.checkServiceOrdIDExists(orderStatus.getServiceOrdID()); if (count > 0) { - // orderStatusService.updateAOrderStatusFlag(orderStatus.getId()); System.out.println("鏈嶅姟璁㈠崟ID瀛樺湪锛�" + orderStatus.getServiceOrdID()); TbOrders tbOrders = tbOrdersService.selectTbOrdersByServiceOrdID(orderStatus.getServiceOrdID()); @@ -108,10 +111,13 @@ log.error("鑾峰彇璋冨害鍗曞紓甯革細"+e.getMessage()); } + SysClientApp clientApp = sysClientAppService.selectSysClientAppByAppId(1L); + if(clientApp==null){ + log.error("鍥炶皟鍦板潃涓嶅瓨鍦�"); + return; + } - - // 浣跨敤鑾峰彇鍒扮殑鎵�鏈夊徃鏈哄鍚� - String callbackUrl = "http://localhost:8080/system/apitest/orderCallback"; + String callbackUrl = clientApp.getCallbackUrl(); try { // 鏋勫缓璇锋眰鍙傛暟 Map<String, String> map = new HashMap<>(); @@ -123,25 +129,29 @@ map.put("driverMobile",driverMobiles.toString()); map.put("driverName", driverNames.toString()); - // 鎵撳嵃璇锋眰鍙傛暟 - log.info("鍙戦�佸洖璋冭姹傦紝URL: " + callbackUrl); - log.info("璇锋眰鍙傛暟: " + map); - - // 鍙戦�佽姹傚苟鑾峰彇鍝嶅簲 - String response = HttpUtil.post(callbackUrl, map); - - // 鎵撳嵃鍝嶅簲缁撴灉 - log.info("鍥炶皟鍝嶅簲缁撴灉: " + response); - - // 鏇存柊鐘舵�� - // orderStatusService.updateAOrderStatusFlag(orderStatus.getId()); + // 绗竴娆″皾璇� + String response = sendCallback(callbackUrl, map); + + if (response == null) { + // 濡傛灉绗竴娆″け璐ワ紝绛夊緟3绉掑悗閲嶈瘯 + Thread.sleep(3000); + log.info("绗竴娆″洖璋冨け璐ワ紝鍑嗗閲嶈瘯"); + response = sendCallback(callbackUrl, map); + } + + if (response != null) { + // 鏇存柊鐘舵�� + log.info("鍥炶皟鎺ㄩ�佹垚鍔燂紝鍙傛暟濡備笅锛�"); + map.forEach((key, value) -> log.info(" {} : {}", key, value)); + orderStatusService.updateAOrderStatusFlag(orderStatus.getId()); + } else { + log.error("鍥炶皟璇锋眰閲嶈瘯鍚庝粛鐒跺け璐�"); + orderStatusService.updateAOrderStatusFlag(orderStatus.getId()); + } } catch (Exception e) { log.error("鍥炶皟璇锋眰澶辫触: " + e.getMessage()); - // 鍙互鑰冭檻閲嶈瘯鏈哄埗鎴栬�呰褰曞け璐ユ棩蹇� + orderStatusService.updateAOrderStatusFlag(orderStatus.getId()); } - - - } else { log.info("鏈嶅姟璁㈠崟ID涓嶅瓨鍦細" + orderStatus.getServiceOrdID()); @@ -153,4 +163,24 @@ e.printStackTrace(); } } + + // 鏂板鍙戦�佸洖璋冪殑鏂规硶 + private String sendCallback(String callbackUrl, Map<String, String> params) { + try { + // 鎵撳嵃璇锋眰鍙傛暟 + log.info("鍙戦�佸洖璋冭姹傦紝URL: " + callbackUrl); + log.info("璇锋眰鍙傛暟: " + params); + + // 鍙戦�佽姹傚苟鑾峰彇鍝嶅簲 + String response = HttpUtil.post(callbackUrl, params); + + // 鎵撳嵃鍝嶅簲缁撴灉 + log.info("鍥炶皟鍝嶅簲缁撴灉: " + response); + + return response; + } catch (Exception e) { + log.error("鍥炶皟璇锋眰寮傚父: " + e.getMessage()); + return null; + } + } } -- Gitblit v1.9.1