vs2008的错误:Error: no data exchange control with ID 0x0409

这个错误的信息是:在进行doDataExchange的时候,发现和变量绑定的控件找不到。

今天碰到了这个问题,找了半天,才发现原来是更改了控件引起的。

         在开发过程中,经常会删除或者更改一些控件。这个时候,就很有可能会出现上述问题。

另外:

在vs2008下开发,出现类似错误时,可以看vs2008自带的调用堆栈信息,可以很快并且很方便的找到问题的根源。



import time import random import requests import json import logging import socket from pathlib import Path from openpyxl import load_workbook from selenium import webdriver from selenium.webdriver.edge.service import Service from selenium.webdriver.edge.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains from selenium.common.exceptions import TimeoutException, WebDriverException from fake_useragent import UserAgent, FakeUserAgentError # -------------------------- 新增:手动指定Edge浏览器和驱动路径 -------------------------- EDGE_BINARY_PATH = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" # 浏览器路径 EDGE_DRIVER_PATH = r"C:\Users\27570\Desktop\edgedriver_win32\msedgedriver.exe" # 驱动路径,需下载并指定 # ------------------------------------------------------------------------------------- # 配置日志 logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', handlers=[ logging.FileHandler("ip_query.log"), logging.StreamHandler() ] ) # -------------------------- 优化:整合网络连接检查 -------------------------- def check_internet_connection(): """检查网络连接是否正常,尝试多种连接方式提高可靠性""" try: # 尝试连接到Google的公共DNS服务器 socket.create_connection(("8.8.8.8", 53), timeout=5) logging.info("网络连接测试通过 (DNS)") return True except OSError: logging.warning("无法连接到DNS服务器,尝试HTTP请求...") try: # 尝试HTTP请求到百度 response = requests.get("https://www.baidu.com", timeout=5) if response.status_code == 200: logging.info("网络连接测试通过 (HTTP)") return True except requests.RequestException: logging.warning("HTTP请求失败,尝试HTTPS请求...") try: # 尝试HTTPS请求到百度 response = requests.get("https://www.baidu.com", timeout=5) if response.status_code == 200: logging.info("网络连接测试通过 (HTTPS)") return True except requests.RequestException: logging.error("HTTPS请求失败") return False # ------------------------------------------------------------------------------------- def build_query_url(base_url, ip_address, path_format="{ip}/", use_params=True, param_name="ip"): """构建IP查询URL,支持路径参数和查询参数两种格式""" if not base_url.startswith(('http://', 'https://')): base_url = 'https://' + base_url base_url = base_url.rstrip('/') try: if '.' in ip_address: # IPv4 socket.inet_pton(socket.AF_INET, ip_address) elif ':' in ip_address: # IPv6 socket.inet_pton(socket.AF_INET6, ip_address) else: raise ValueError("无效的IP地址") if ':' in ip_address: ip_address = f"[{ip_address}]" if use_params: # 使用查询参数的方式构造URL from urllib.parse import urlencode # 添加固定参数action=2 params = {param_name: ip_address, "action": 2} return f"{base_url}?{urlencode(params)}" else: # 原有的路径参数方式 from urllib.parse import quote encoded_ip = quote(ip_address) return f"{base_url}/{path_format.format(ip=encoded_ip)}" except socket.error: logging.error(f"无效的IP地址格式: {ip_address}") return None except Exception as e: logging.error(f"构建查询URL时出错: {str(e)}") return None # 手动配置的固定请求头 MANUAL_HEADERS = { 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', 'accept-encoding': 'gzip, deflate, br, zstd', 'accept-language': 'zh-CN,zh;q=0.9', 'cache-control': 'max-age=0', 'connection': 'keep-alive', 'cookie': '_c_WBKFRo=NWgPw1zeBaW3I2CtOcadfhJJw33TcEYmWMtyGzTE; Hm_lvt_f4f76646cd877e538aa1fbbdf351c548=1753560343,1753617545,1753793389,1753862286; HMACCOUNT=96B6BD9DE68EFF3B; PHPSESSID=o9fnnscr7sofru4b8r1khlde3f; Hm_lvt_f4f76646cd877e538aa1fbbdf351c548=1754123598; HMACCOUNT=96B6BD9DE68EFF3B; Hm_lpvt_f4f76646cd877e538aa1fbbdf351c548=1754611428; Hm_lpvt_f4f76646cd877e538aa1fbbdf351c548=1754613370', 'host': 'www.ip138.com', 'referer': 'https://www.ip138.com/iplookup.php?ip=27.154.214.154&action=2', 'sec-ch-ua': '"Not)A;Brand";v="8", "Chromium";v="138", "Microsoft Edge";v="138"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"Windows"', 'sec-fetch-dest': 'document', 'sec-fetch-mode': 'navigate', 'sec-fetch-site': 'same-origin', 'sec-fetch-user': '?1', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0' } def configure_driver(max_retries=5): """配置Edge浏览器驱动""" for attempt in range(max_retries): try: # 先检查网络连接 if not check_internet_connection(): raise Exception("网络连接不可用") # 创建Edge选项 edge_options = Options() # 1. 基础配置 edge_options.binary_location = EDGE_BINARY_PATH # 手动指定浏览器路径 edge_options.add_argument("--disable-blink-features=AutomationControlled") # 核心反检测 edge_options.add_experimental_option("excludeSwitches", ["enable-automation"]) edge_options.add_experimental_option("useAutomationExtension", False) edge_options.add_argument("--start-maximized") # 最大化窗口 # 2. 增强反检测 edge_options.add_argument("--disable-extensions") edge_options.add_argument("--disable-plugins-discovery") edge_options.add_argument("--disable-web-security") # 3. 随机化配置 features_to_disable = [ "AutomationControlled", "InterestCohort", "BlinkGenPropertyTrees" ] edge_options.add_argument(f"--disable-features={','.join(random.sample(features_to_disable, random.randint(2, 4)))}") screen_sizes = [(1366, 768), (1920, 1080), (1536, 864)] width, height = random.choice(screen_sizes) edge_options.add_argument(f"--window-size={width},{height}") if random.random() > 0.5: edge_options.add_argument("--disable-gpu") else: edge_options.add_argument("--enable-gpu-rasterization") # 4. 资源加载控制 prefs = { "profile.managed_default_content_settings.images": 2, "profile.managed_default_content_settings.stylesheets": 2, } edge_options.add_experimental_option("prefs", prefs) edge_options.page_load_strategy = 'eager' # 只等待DOM加载 # 5. 使用手动指定的驱动路径 try: service = Service(EDGE_DRIVER_PATH) # 手动指定驱动路径 logging.info(f"使用手动指定的驱动路径: {EDGE_DRIVER_PATH}") except Exception as e: logging.error(f"驱动路径配置错误: {str(e)}") raise # 6. 创建浏览器实例 driver = webdriver.Edge(service=service, options=edge_options) # 7. 隐藏自动化特征 driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", { "source": """ // 核心:隐藏webdriver标志 Object.defineProperty(navigator, 'webdriver', { get: () => undefined }); // 模拟Chrome特征 window.chrome = { runtime: {} }; // 模拟时区 Intl.DateTimeFormat().resolvedOptions().timeZone = ['Asia/Shanghai', 'Asia/Beijing'][Math.floor(Math.random() * 2)]; """ }) # 8. 设置超时 driver.set_page_load_timeout(30) driver.set_script_timeout(30) # 9. 应用手动配置的请求头 logging.info(f"应用手动配置的请求头: {json.dumps(MANUAL_HEADERS, indent=2)[:100]}...") driver.execute_cdp_cmd("Network.setUserAgentOverride", { "userAgent": MANUAL_HEADERS["user-agent"], "accept": MANUAL_HEADERS["accept"], "acceptLanguage": MANUAL_HEADERS["accept-language"], }) logging.info(f"浏览器驱动初始化成功 (尝试 {attempt+1}/{max_retries})") return driver except Exception as e: logging.error(f"配置浏览器驱动失败 (尝试 {attempt+1}/{max_retries}): {str(e)}") if attempt < max_retries - 1: wait_time = 2 ** attempt + random.uniform(5, 10) logging.info(f"将在 {wait_time:.2f} 秒后重试") time.sleep(wait_time) logging.critical("达到最大重试次数,无法初始化浏览器驱动") return None def change_user_agent(driver): """更换为手动配置的请求头""" logging.info(f"应用手动配置的请求头: {json.dumps(MANUAL_HEADERS, indent=2)[:100]}...") driver.execute_cdp_cmd("Network.setUserAgentOverride", { "userAgent": MANUAL_HEADERS["user-agent"], "accept": MANUAL_HEADERS["accept"], "acceptLanguage": MANUAL_HEADERS["accept-language"], }) driver.refresh() time.sleep(random.uniform(2, 4)) def handle_cookies(driver): """处理和保存Cookie""" cookies = driver.get_cookies() logging.info(f"获取到 {len(cookies)} 个Cookie") return cookies def is_banned(driver): """检测是否被封禁""" try: banned_xpaths = [ '//div[contains(text(), "访问被阻止")]', '//div[contains(text(), "验证码")]', '//div[contains(text(), "您的IP已被封禁")]', ] for xpath in banned_xpaths: if WebDriverWait(driver, 5).until( EC.presence_of_element_located((By.XPATH, xpath)) ): logging.warning("检测到封禁页面") return True return False except: return False def check_dynamic_element(driver, xpaths): """检查网页上是否存在任一动态XPath的元素""" for i, xpath in enumerate(xpaths, 1): try: WebDriverWait(driver, 5).until( EC.presence_of_element_located((By.XPATH, xpath)) ) logging.info(f"使用动态元素XPath {i}: {xpath}") return True except: continue return False def get_result_element(driver, xpaths): """尝试获取任一结果元素""" for i, xpath in enumerate(xpaths, 1): try: element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, xpath)) ) logging.info(f"使用结果元素XPath {i}: {xpath}") return element except: continue return None def simulate_human_behavior(driver): """模拟人类浏览行为""" try: # 随机滚动页面 scroll_height = driver.execute_script("return document.body.scrollHeight") scroll_steps = random.randint(3, 7) for i in range(scroll_steps): scroll_to = int(scroll_height * (i + 1) / scroll_steps) driver.execute_script(f"window.scrollTo(0, {scroll_to})") time.sleep(random.uniform(0.5, 1.5)) # 随机移动鼠标 actions = ActionChains(driver) elements = driver.find_elements(By.TAG_NAME, "a") if elements: for _ in range(random.randint(1, 3)): element = random.choice(elements) actions.move_to_element(element).perform() time.sleep(random.uniform(0.3, 0.8)) except Exception as e: logging.warning(f"模拟人类行为时出错: {e}") def query_ip(driver, ip_address, base_url, xpath_expressions, dynamic_xpaths, max_retries=5): """查询IP信息,添加封禁检测和处理""" if not ip_address or not isinstance(ip_address, str) or ip_address.strip() == "": logging.warning(f"无效的IP地址: {ip_address}") return "无效IP" ip_address = ip_address.strip() for attempt in range(max_retries): try: if attempt > 0: wait_time = 2 ** attempt + random.uniform(3, 7) logging.info(f"第 {attempt+1} 次重试前等待 {wait_time:.2f} 秒...") time.sleep(wait_time) change_user_agent(driver) query_url = build_query_url(base_url, ip_address) if not query_url: logging.error(f"无法构建有效的查询URL,IP: {ip_address}") return "无效URL" logging.info(f"访问查询URL (尝试 {attempt+1}/{max_retries}): {query_url}") try: driver.get(query_url) time.sleep(random.uniform(8, 15)) if is_banned(driver): logging.warning(f"IP {ip_address} 查询时被封禁") driver.quit() time.sleep(5) driver = configure_driver() time.sleep(5) continue current_url = driver.current_url if current_url == "data:," or "about:blank" in current_url: raise Exception("浏览器加载了空白页面") simulate_human_behavior(driver) time.sleep(random.uniform(2, 5)) handle_cookies(driver) except TimeoutException: logging.warning(f"页面加载超时,尝试重新加载") driver.refresh() time.sleep(15) continue if check_dynamic_element(driver, dynamic_xpaths): logging.info(f"检测到动态元素,结果将设为'动态'") return "动态" result_element = get_result_element(driver, xpath_expressions) if result_element: return result_element.text.strip() else: raise Exception("无法找到结果元素") except WebDriverException as e: logging.error(f"WebDriver错误 (尝试 {attempt+1}/{max_retries}): {str(e)}") if "ERR_EMPTY_RESPONSE" in str(e) or "ERR_CONNECTION_RESET" in str(e): logging.warning("检测到连接错误,尝试重启浏览器...") driver.quit() time.sleep(15) driver = configure_driver() time.sleep(10) else: time.sleep(2 ** attempt + random.uniform(5, 10)) continue except Exception as e: logging.error(f"查询IP {ip_address} 失败 (尝试 {attempt+1}/{max_retries}): {str(e)}") time.sleep(2 ** attempt + random.uniform(5, 10)) continue logging.error(f"IP {ip_address} 查询失败,已达到最大重试次数") driver.save_screenshot(f"error_{ip_address}.png") return "查询失败" def is_row_hidden(worksheet, row_idx): """检查Excel行是否被隐藏""" return worksheet.row_dimensions[row_idx].hidden def process_excel(input_file, base_url, xpath_expressions, dynamic_xpaths, ip_column='A', result_column='I', start_row=2): """处理Excel文件""" wb = load_workbook(input_file) ws = wb.active has_filter = ws.auto_filter.ref is not None logging.info(f"检测到筛选: {has_filter}") driver = configure_driver() if not driver: logging.critical("无法初始化浏览器驱动,退出程序") return visible_rows = [] for row_idx in range(start_row, ws.max_row + 1): row_dim = ws.row_dimensions.get(row_idx) if not row_dim or not row_dim.hidden: visible_rows.append(row_idx) logging.info(f"可见行共{len(visible_rows)}行") total_visible = len(visible_rows) processed_count = 0 try: for i, row in enumerate(visible_rows, 1): ip_address = ws[f"{ip_column}{row}"].value if not ip_address: logging.info(f"第 {row} 行IP地址为空,跳过") continue logging.info(f"正在查询IP: {ip_address} ({i}/{total_visible})") result = query_ip(driver, ip_address, base_url, xpath_expressions, dynamic_xpaths) ws[f"{result_column}{row}"] = result processed_count += 1 if i % 3 == 0 or i == total_visible: wb.save(input_file) logging.info(f"已保存进度: {i}/{total_visible} 到 {input_file}") wait_time = random.uniform(20,40) logging.info(f"等待 {wait_time:.2f} 秒后继续...") time.sleep(wait_time) if i % 10 == 0: extra_wait = random.uniform(40,60) logging.info(f"已处理 {i} 个IP,额外休息 {extra_wait:.2f} 秒...") time.sleep(extra_wait) if i % 20 == 0: logging.info(f"已处理 {i} 个IP,重启浏览器以避免被检测...") driver.quit() time.sleep(15) driver = configure_driver() if not driver: logging.critical("无法重新初始化浏览器驱动,退出程序") return except Exception as e: logging.critical(f"处理过程中发生意外错误: {str(e)}") finally: if driver: driver.quit() wb.save(input_file) logging.info(f"已保存最终结果到 {input_file}") logging.info(f"处理完成!共处理 {processed_count}/{total_visible} 个可见IP地址") if __name__ == "__main__": INPUT_FILE = r"C:\Users\27570\Desktop\飞塔-福建-简版-更新版20250730.xlsx" # 修改为新的基础URL BASE_URL = "https://www.ip138.com/iplookup.php" # 配置两种XPath表达式 XPATH_EXPRESSIONS = [ '/html/body/div/div[2]/div[1]/div/table/tbody/tr[2]/td[2]', '/html/body/div/div[2]/div[2]/div/div[2]/div[1]/div/div[2]/div[2]/div[2]/table/tbody/tr[2]/td[2]' ] DYNAMIC_XPATHS = [ '/html/body/div/div[2]/div[1]/div/p/a', '/html/body/div/div[2]/div[2]/div/div[2]/div[1]/div/div[2]/div[2]/div[1]/p[1]/a' ] max_main_retries = 3 for main_attempt in range(max_main_retries): try: logging.info(f"开始处理Excel文件 (尝试 {main_attempt+1}/{max_main_retries})") process_excel(INPUT_FILE, BASE_URL, XPATH_EXPRESSIONS, DYNAMIC_XPATHS) break except Exception as e: logging.critical(f"主程序执行失败 (尝试 {main_attempt+1}/{max_main_retries}): {str(e)}") if main_attempt < max_main_retries - 1: wait_time = 10 + random.uniform(10, 30) logging.info(f"将在 {wait_time:.2f} 秒后重试") time.sleep(wait_time) else: logging.critical("达到最大重试次数,程序终止") 以上代码在运行时出现了以下问题,解决问题并给我完整代码 Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#sessionnotcreatedexception Stacktrace: GetHandleVerifier [0x0xf6d593+37219] (No symbol) [0x0xe1a716] (No symbol) [0x0xbe51ce] (No symbol) [0x0xc0d881] (No symbol) [0x0xc08a43] (No symbol) [0x0xc3d78b] (No symbol) [0x0xc3d22a] (No symbol) [0x0xc324f6] (No symbol) [0x0xc13327] (No symbol) [0x0xc12723] (No symbol) [0x0xc13144] sqlite3_dbdata_init [0x0x105a89c+518364] sqlite3_dbdata_init [0x0x1141ab0+1465072] sqlite3_dbdata_init [0x0x11413e5+1463333] sqlite3_dbdata_init [0x0x11328ec+1403180] sqlite3_dbdata_init [0x0x11422d2+1467154] (No symbol) [0x0xe31d9d] (No symbol) [0x0xe25108] (No symbol) [0x0xe252fb] (No symbol) [0x0xe0a649] BaseThreadInitThunk [0x0x75525d49+25] RtlInitializeExceptionChain [0x0x7706d1ab+107] RtlGetAppContainerNamedObjectPath [0x0x7706d131+561]
最新发布
08-09
日志:[TASK] ====== CONTINUOUS DOWNLOAD STARTED ====== [INFO] Devices: 8 | Save path: F:/GKD/ [PROCESS] Device: GK2025040001 | Date: 2025-07-01 [DEBUG] Time Parameters: Original Local: 2025-07-01T00:00 - 2025-07-01T23:59:59 Converted Server: 2025-07-01 00:00:00 - 2025-07-01 23:59:59 Raw Time: 2025-07-01 00:00:00 & 2025-07-01 23:59:59 [DEBUG] Final request URL: http://nyzbwlw.com/situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%2000:00:00&endTime=2025-07-01%2023:59:59&size=1000&t=1754026969103 2025-08-01 13:42:49 [Thread-1] DEBUG o.s.web.client.RestTemplate - HTTP GET http://nyzbwlw.com/situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026969103 2025-08-01 13:42:49 [Thread-1] DEBUG o.s.web.client.RestTemplate - Accept=[text/plain, application/json, application/*+json, */*] 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://nyzbwlw.com:80][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20] 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://nyzbwlw.com:80][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20] 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {}->http://nyzbwlw.com:80 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to nyzbwlw.com/47.92.156.54:80 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 192.168.2.4:62064<->47.92.156.54:80 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 15000 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026969103 HTTP/1.1 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026969103 HTTP/1.1 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/json, text/plain, */* 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: keep-alive 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Referer: http://nyzbwlw.com/situation/ 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Origin: http://nyzbwlw.com 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Dest: empty 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Mode: cors 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Site: same-origin 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: nyzbwlw.com 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026969103 HTTP/1.1[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/json, text/plain, */*[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: keep-alive[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Referer: http://nyzbwlw.com/situation/[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Origin: http://nyzbwlw.com[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Dest: empty[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Mode: cors[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Site: same-origin[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: nyzbwlw.com[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 [\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: nginx/1.20.2[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Fri, 01 Aug 2025 05:42:49 GMT[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json;charset=UTF-8[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Credentials: true[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Origin: *[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Vary: Origin[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Expose-Headers: Set-Cookie[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Set-Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A; Path=/situation; HttpOnly[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "41[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "{"msg":"[0xe6][0x93][0x8d][0xe4][0xbd][0x9c][0xe6][0x88][0x90][0xe5][0x8a][0x9f][0xef][0xbc][0x81]","code":100,"data":{"count":0,"list":[]}}[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "0[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Server: nginx/1.20.2 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Fri, 01 Aug 2025 05:42:49 GMT 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/json;charset=UTF-8 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: keep-alive 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Credentials: true 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Origin: * 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Vary: Origin 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Expose-Headers: Set-Cookie 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS 2025-08-01 13:42:49 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Set-Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A; Path=/situation; HttpOnly 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.c.p.ResponseProcessCookies - Cookie accepted [JSESSIONID="852AF1576F877DE9C07BC6B516B6220A", version:0, domain:nyzbwlw.com, path:/situation, expiry:null] 2025-08-01 13:42:49 [Thread-1] DEBUG o.s.web.client.RestTemplate - Response 200 OK 2025-08-01 13:42:49 [Thread-1] DEBUG o.s.web.client.RestTemplate - Reading to [java.lang.String] as "application/json;charset=UTF-8" 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->http://nyzbwlw.com:80] can be kept alive indefinitely 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0 2025-08-01 13:42:49 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://nyzbwlw.com:80][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20] [COOKIE] Saved session cookie: JSESSIONID [DEBUG] Response Status: 200 OK [DEBUG] Raw API response snippet: {"msg":"操作成功!","code":100,"data":{"count":0,"list":[]}} [DEBUG] Parsed API response code: 100 | message: 操作成功! [DEBUG] Found 0 valid image entries [RETRY] Retrying in 2000 ms (attempt 2/3) [DEBUG] Time Parameters: Original Local: 2025-07-01T00:00 - 2025-07-01T23:59:59 Converted Server: 2025-07-01 00:00:00 - 2025-07-01 23:59:59 Raw Time: 2025-07-01 00:00:00 & 2025-07-01 23:59:59 [DEBUG] Final request URL: http://nyzbwlw.com/situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%2000:00:00&endTime=2025-07-01%2023:59:59&size=1000&t=1754026971579 [DEBUG] Sending cookies: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A 2025-08-01 13:42:51 [Thread-1] DEBUG o.s.web.client.RestTemplate - HTTP GET http://nyzbwlw.com/situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026971579 2025-08-01 13:42:51 [Thread-1] DEBUG o.s.web.client.RestTemplate - Accept=[text/plain, application/json, application/*+json, */*] 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.c.protocol.RequestAddCookies - Cookie [version: 0][name: JSESSIONID][value: 852AF1576F877DE9C07BC6B516B6220A][domain: nyzbwlw.com][path: /situation][expiry: null] match [nyzbwlw.com:80/situation/http/device/bug/getBugData] 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://nyzbwlw.com:80][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20] 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "[read] I/O error: Read timed out" 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://nyzbwlw.com:80][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20] 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 15000 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026971579 HTTP/1.1 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026971579 HTTP/1.1 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/json, text/plain, */* 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: keep-alive 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Referer: http://nyzbwlw.com/situation/ 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Origin: http://nyzbwlw.com 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Dest: empty 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Mode: cors 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Site: same-origin 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: nyzbwlw.com 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026971579 HTTP/1.1[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/json, text/plain, */*[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: keep-alive[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Referer: http://nyzbwlw.com/situation/[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Origin: http://nyzbwlw.com[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Dest: empty[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Mode: cors[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Site: same-origin[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: nyzbwlw.com[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 [\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: nginx/1.20.2[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Fri, 01 Aug 2025 05:42:51 GMT[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json;charset=UTF-8[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Credentials: true[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Origin: *[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Vary: Origin[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Expose-Headers: Set-Cookie[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "41[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "{"msg":"[0xe6][0x93][0x8d][0xe4][0xbd][0x9c][0xe6][0x88][0x90][0xe5][0x8a][0x9f][0xef][0xbc][0x81]","code":100,"data":{"count":0,"list":[]}}[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "0[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Server: nginx/1.20.2 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Fri, 01 Aug 2025 05:42:51 GMT 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/json;charset=UTF-8 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: keep-alive 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Credentials: true 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Origin: * 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Vary: Origin 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Expose-Headers: Set-Cookie 2025-08-01 13:42:51 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely 2025-08-01 13:42:51 [Thread-1] DEBUG o.s.web.client.RestTemplate - Response 200 OK 2025-08-01 13:42:51 [Thread-1] DEBUG o.s.web.client.RestTemplate - Reading to [java.lang.String] as "application/json;charset=UTF-8" 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->http://nyzbwlw.com:80] can be kept alive indefinitely 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0 2025-08-01 13:42:51 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://nyzbwlw.com:80][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20] [DEBUG] Response Status: 200 OK [DEBUG] Raw API response snippet: {"msg":"操作成功!","code":100,"data":{"count":0,"list":[]}} [DEBUG] Parsed API response code: 100 | message: 操作成功! [DEBUG] Found 0 valid image entries [RETRY] Retrying in 4000 ms (attempt 3/3) [DEBUG] Time Parameters: Original Local: 2025-07-01T00:00 - 2025-07-01T23:59:59 Converted Server: 2025-07-01 00:00:00 - 2025-07-01 23:59:59 Raw Time: 2025-07-01 00:00:00 & 2025-07-01 23:59:59 [DEBUG] Final request URL: http://nyzbwlw.com/situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%2000:00:00&endTime=2025-07-01%2023:59:59&size=1000&t=1754026975716 [DEBUG] Sending cookies: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A 2025-08-01 13:42:55 [Thread-1] DEBUG o.s.web.client.RestTemplate - HTTP GET http://nyzbwlw.com/situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026975716 2025-08-01 13:42:55 [Thread-1] DEBUG o.s.web.client.RestTemplate - Accept=[text/plain, application/json, application/*+json, */*] 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.c.protocol.RequestAddCookies - Cookie [version: 0][name: JSESSIONID][value: 852AF1576F877DE9C07BC6B516B6220A][domain: nyzbwlw.com][path: /situation][expiry: null] match [nyzbwlw.com:80/situation/http/device/bug/getBugData] 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://nyzbwlw.com:80][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20] 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "[read] I/O error: Read timed out" 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://nyzbwlw.com:80][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20] 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 15000 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026975716 HTTP/1.1 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026975716 HTTP/1.1 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/json, text/plain, */* 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: keep-alive 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Referer: http://nyzbwlw.com/situation/ 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Origin: http://nyzbwlw.com 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Dest: empty 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Mode: cors 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Sec-Fetch-Site: same-origin 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: nyzbwlw.com 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "GET /situation/http/device/bug/getBugData?deviceCode=GK2025040001&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754026975716 HTTP/1.1[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/json, text/plain, */*[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: keep-alive[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Referer: http://nyzbwlw.com/situation/[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Origin: http://nyzbwlw.com[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Dest: empty[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Mode: cors[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Sec-Fetch-Site: same-origin[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: nyzbwlw.com[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Cookie: JSESSIONID=852AF1576F877DE9C07BC6B516B6220A[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 [\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: nginx/1.20.2[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Fri, 01 Aug 2025 05:42:55 GMT[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json;charset=UTF-8[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Credentials: true[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Origin: *[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Vary: Origin[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Expose-Headers: Set-Cookie[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "41[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "{"msg":"[0xe6][0x93][0x8d][0xe4][0xbd][0x9c][0xe6][0x88][0x90][0xe5][0x8a][0x9f][0xef][0xbc][0x81]","code":100,"data":{"count":0,"list":[]}}[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "0[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Server: nginx/1.20.2 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Fri, 01 Aug 2025 05:42:55 GMT 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/json;charset=UTF-8 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: keep-alive 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Credentials: true 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Origin: * 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Vary: Origin 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Expose-Headers: Set-Cookie 2025-08-01 13:42:55 [Thread-1] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely 2025-08-01 13:42:55 [Thread-1] DEBUG o.s.web.client.RestTemplate - Response 200 OK 2025-08-01 13:42:55 [Thread-1] DEBUG o.s.web.client.RestTemplate - Reading to [java.lang.String] as "application/json;charset=UTF-8" 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->http://nyzbwlw.com:80] can be kept alive indefinitely 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0 2025-08-01 13:42:55 [Thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://nyzbwlw.com:80][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20] [DEBUG] Response Status: 200 OK [DEBUG] Raw API response snippet: {"msg":"操作成功!","code":100,"data":{"count":0,"list":[]}} [DEBUG] Parsed API response code: 100 | message: 操作成功! [DEBUG] Found 0 valid image entries [STATS] Device: GK2025040001 | Total: 0 | Success: 0 | Failed: 0 [RESULT] Device: GK2025040001 | Date: 2025-07-01 | Found: 0 | Downloaded: 0 | Failed: 0 代码:package com.example.service; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.client.RestTemplate; import org.springframework.http.ResponseEntity; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.core.type.TypeReference; import java.util.*; import java.time.*; import java.time.format.DateTimeFormatter; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.PostConstruct; import com.example.model.BugApiResponse; import com.example.model.BugResponseData; import com.example.model.BugImageInfo; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.net.InetAddress; import java.util.stream.Collectors; import org.springframework.web.util.UriComponentsBuilder; import java.net.URI; @Service public class BugImageDownloadService { private static final ZoneId SERVER_ZONE = ZoneId.of("Asia/Shanghai"); private static final String API_URL = "http://nyzbwlw.com/situation/http/device/bug/getBugData"; private static final DateTimeFormatter API_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private static final DateTimeFormatter FILE_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); private static final DateTimeFormatter FILE_TIME_FORMAT = DateTimeFormatter.ofPattern("HH_mm_ss"); private final ConcurrentHashMap<String, LocalDateTime> deviceLastUpdateMap = new ConcurrentHashMap<>(); @Value("${bug.download.deviceCodes:GK2025040001,GK2025040002,GK2025040003,GK2025040004,GK2025040005,GK2025040006,GK2025040007,GK2025040008}") private List<String> deviceCodes; private final Map<String, String> cookies = new ConcurrentHashMap<>(); // 存储每个设备的下一个处理日期 private final ConcurrentHashMap<String, LocalDate> deviceNextDateMap = new ConcurrentHashMap<>(); @Value("${bug.image.save.path:F:/GKD/}") private String savePath; private final RestTemplate restTemplate; private final ObjectMapper objectMapper; public BugImageDownloadService(RestTemplate restTemplate, ObjectMapper objectMapper) { this.restTemplate = restTemplate; this.objectMapper = objectMapper; } @PostConstruct public void init() { // 所有设备从固定起始日期开始 LocalDate startDate = LocalDate.of(2025, 7, 1); for (String deviceCode : deviceCodes) { deviceNextDateMap.put(deviceCode, startDate); } System.out.println("[INIT] Device date tracking initialized. Start date: " + startDate); } /** * 持续下载所有设备的新图片 */ public void downloadNewImagesContinuously() { System.out.println("[TASK] ====== CONTINUOUS DOWNLOAD STARTED ======"); System.out.println("[INFO] Devices: " + deviceCodes.size() + " | Save path: " + savePath); while (true) { try { boolean allDevicesUpToDate = true; // 处理每个设备的历史数据 for (String deviceCode : deviceCodes) { LocalDate currentDate = deviceNextDateMap.get(deviceCode); LocalDate today = LocalDate.now(SERVER_ZONE); if (currentDate.isBefore(today)) { allDevicesUpToDate = false; // 处理该设备当前日期的数据 LocalDateTime startOfDay = currentDate.atStartOfDay(); LocalDateTime endOfDay = currentDate.atTime(23, 59, 59); System.out.printf("[PROCESS] Device: %s | Date: %s%n", deviceCode, currentDate); // 下载该日期的图片 int[] counts = downloadImagesForDevice( deviceCode, startOfDay, endOfDay, false // 标记为历史数据请求 ); // 更新设备的下一个处理日期(明天) deviceNextDateMap.put(deviceCode, currentDate.plusDays(1)); System.out.printf("[RESULT] Device: %s | Date: %s | Found: %d | Downloaded: %d | Failed: %d%n", deviceCode, currentDate, counts[0], counts[1], counts[2]); // 设备间处理间隔 Thread.sleep(2000); } } // 所有设备都处理到最新日期 if (allDevicesUpToDate) { System.out.println("[STATUS] All devices up-to-date. Starting real-time updates..."); // ===== 优化后的实时更新逻辑 ===== for (String deviceCode : deviceCodes) { // 获取上次更新时间(默认当天0点) LocalDateTime lastUpdate = deviceLastUpdateMap.getOrDefault( deviceCode, LocalDate.now(SERVER_ZONE).atStartOfDay() // 使用服务器时区 ); LocalDateTime now = LocalDateTime.now(); System.out.printf("[REALTIME] Device: %s | Time range: %s to %s%n", deviceCode, lastUpdate, now); // 修复点1:添加第四个参数 true 表示实时请求 int[] counts = downloadImagesForDevice( deviceCode, lastUpdate, // 从上次更新时间开始 now, true // 标记为实时请求 ); // 更新最后记录时间(当前轮询结束时间) deviceLastUpdateMap.put(deviceCode, now); System.out.printf("[REALTIME-RESULT] Device: %s | Downloaded: %d | Failed: %d%n", deviceCode, counts[1], counts[2]); // 设备间处理间隔 Thread.sleep(2000); } // ======================== // 等待4h后再次检查 System.out.println("[STATUS] Real-time round completed. Waiting 4 hours..."); Thread.sleep(14_400_000); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); System.err.println("[ERROR] Task interrupted: " + e.getMessage()); break; } catch (Exception e) { System.err.println("[ERROR] Critical error: " + e.getMessage()); try { Thread.sleep(60_000); // 错误后等待1分钟 } catch (InterruptedException ie) { Thread.currentThread().interrupt(); break; } } } } /** * 下载指定设备在指定时间范围内的图片 */ private int[] downloadImagesForDevice(String deviceCode, LocalDateTime startTime, LocalDateTime endTime, boolean isRealtime) { int maxRetries = 3; int retryCount = 0; int waitTime = 2000; // 初始等待时间 2秒 int total = 0; int success = 0; int failed = 0; while (retryCount < maxRetries) { try { // ====== 网络诊断 ====== // ... [网络诊断代码保持不变] ... // ========== 统一时区转换逻辑 ========== ZonedDateTime serverStart = startTime.atZone(ZoneId.systemDefault()) .withZoneSameInstant(SERVER_ZONE); ZonedDateTime serverEnd = endTime.atZone(ZoneId.systemDefault()) .withZoneSameInstant(SERVER_ZONE); // 格式化为API需要的字符串(不进行手动编码) String startStr = serverStart.format(API_DATE_FORMAT); String endStr = serverEnd.format(API_DATE_FORMAT); // 调试日志增强 System.out.println("[DEBUG] Time Parameters:"); System.out.println(" Original Local: " + startTime + " - " + endTime); System.out.println(" Converted Server: " + serverStart.format(API_DATE_FORMAT) + " - " + serverEnd.format(API_DATE_FORMAT)); System.out.println(" Raw Time: " + startStr + " & " + endStr); // 使用Spring的URI构建器确保正确编码 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(API_URL) .queryParam("deviceCode", deviceCode) .queryParam("startTime", startStr) .queryParam("endTime", endStr) .queryParam("size", 1000) .queryParam("t", System.currentTimeMillis()); URI apiUri = builder.build().encode().toUri(); String apiUrl = apiUri.toString(); System.out.println("[DEBUG] Final request URL: " + apiUrl); // ====== 创建带Cookie的请求头 ====== HttpHeaders headers = new HttpHeaders(); // 添加浏览器级 User-Agent headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0"); // 必须添加的请求头 headers.set("Accept", "application/json, text/plain, */*"); headers.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"); headers.set("Connection", "keep-alive"); headers.set("Referer", "http://nyzbwlw.com/situation/"); // 关键修复:添加 Referer headers.set("Origin", "http://nyzbwlw.com"); headers.set("Sec-Fetch-Dest", "empty"); headers.set("Sec-Fetch-Mode", "cors"); headers.set("Sec-Fetch-Site", "same-origin"); // 添加 Cookie(关键修复:使用持久化 Cookie) if (!cookies.isEmpty()) { String cookieHeader = cookies.entrySet().stream() .map(entry -> entry.getKey() + "=" + entry.getValue()) .collect(Collectors.joining("; ")); headers.add("Cookie", cookieHeader); System.out.println("[DEBUG] Sending cookies: " + cookieHeader); } // 发送请求 ResponseEntity<String> response = restTemplate.exchange( apiUrl, HttpMethod.GET, new HttpEntity<>(headers), String.class); // 保存新Cookie List<String> setCookieHeaders = response.getHeaders().get("Set-Cookie"); if (setCookieHeaders != null) { for (String cookie : setCookieHeaders) { // 提取关键 Cookie(排除过期/路径信息) String[] cookieParts = cookie.split(";")[0].split("="); if (cookieParts.length >= 2) { String cookieName = cookieParts[0].trim(); String cookieValue = cookieParts[1].trim(); cookies.put(cookieName, cookieValue); System.out.println("[COOKIE] Saved session cookie: " + cookieName); } } } // 响应状态日志 System.out.println("[DEBUG] Response Status: " + response.getStatusCodeValue() + " " + response.getStatusCode().getReasonPhrase()); if (response.getStatusCode().is2xxSuccessful() && response.getBody() != null) { String responseBody = response.getBody(); System.out.println("[DEBUG] Raw API response snippet: " + responseBody.substring(0, Math.min(300, responseBody.length())) + (responseBody.length() > 300 ? "..." : "")); // 使用POJO解析响应 BugApiResponse apiResponse = objectMapper.readValue(responseBody, BugApiResponse.class); System.out.printf("[DEBUG] Parsed API response code: %d | message: %s%n", apiResponse.getCode(), apiResponse.getMsg()); if (apiResponse.getCode() == 100) { BugResponseData data = apiResponse.getData(); List<BugImageInfo> bugList = (data != null && data.getList() != null) ? data.getList() : Collections.emptyList(); total = bugList.size(); System.out.printf("[DEBUG] Found %d valid image entries%n", total); // 如果有数据,处理并返回 if (total > 0) { for (BugImageInfo bug : bugList) { String pictureUrl = bug.getPictureUrl(); String collectionTime = bug.getCollectionTime(); if (pictureUrl != null && !pictureUrl.isEmpty() && collectionTime != null && !collectionTime.isEmpty()) { System.out.printf("[PROCESS] Downloading: %s | %s%n", collectionTime, pictureUrl); if (downloadImage(deviceCode, pictureUrl, collectionTime)) { success++; } else { failed++; } } else { System.err.printf("[WARN] Invalid data: URL=%s | Time=%s%n", pictureUrl, collectionTime); failed++; } } return new int[]{total, success, failed}; } } else { System.err.println("[API-ERROR] Device: " + deviceCode + " | Code: " + apiResponse.getCode()); } } } catch (Exception e) { System.err.println("[DOWNLOAD-ERROR] Device: " + deviceCode + " | Error: " + e.getMessage()); e.printStackTrace(); } // 如果没有数据或出错,等待后重试 retryCount++; if (retryCount < maxRetries) { try { System.out.printf("[RETRY] Retrying in %d ms (attempt %d/%d)%n", waitTime, retryCount + 1, maxRetries); Thread.sleep(waitTime); waitTime *= 2; // 指数退避 } catch (InterruptedException ie) { Thread.currentThread().interrupt(); break; } } } System.out.printf("[STATS] Device: %s | Total: %d | Success: %d | Failed: %d%n", deviceCode, total, success, failed); return new int[]{total, success, failed}; } private boolean downloadImage(String deviceCode, String imageUrl, String collectionTime) { try { LocalDateTime dateTime = LocalDateTime.parse(collectionTime, API_DATE_FORMAT); // 创建保存路径 Path saveDir = Paths.get(savePath, deviceCode, dateTime.format(FILE_DATE_FORMAT)); if (!Files.exists(saveDir)) { Files.createDirectories(saveDir); } // 生成文件名 String fileName = dateTime.format(FILE_TIME_FORMAT) + ".jpg"; Path filePath = saveDir.resolve(fileName); // 跳过已存在文件 if (Files.exists(filePath)) { return true; } // 下载图片 byte[] imageBytes = restTemplate.getForObject(imageUrl, byte[].class); if (imageBytes != null && imageBytes.length > 0) { Files.write(filePath, imageBytes); return true; } } catch (Exception e) { System.err.println("[IMAGE-ERROR] URL: " + imageUrl + " | Error: " + e.getMessage()); } return false; } }解决请求http://nyzbwlw.com/situation/http/device/bug/getBugData?deviceCode=GK2025040006&startTime=2025-07-01%252000:00:00&endTime=2025-07-01%252023:59:59&size=1000&t=1754027017557这个api返回count为0,在浏览器中输入这个url返回13条有效数据{"msg":"操作成功!","code":100,"data":{"count":13,"list":[{"eqName":"GK-7","collectionTime":"2025-07-04 05:28:09","monitorId":250704052841640,"exhibitionPath":"","num":"0","pictureUrl":"https://zzoukeqi.oss-cn-beijing.aliyuncs.com/situations/bugImgs/GK2025040007/2025-07-04/250704052841622749.jpg","pictureAnalysis":{}}
08-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值