test_debug_info_preservation.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>工伤接口Debug信息保留测试</title>
  7. <style>
  8. body {
  9. font-family: Arial, sans-serif;
  10. margin: 20px;
  11. background-color: #f5f5f5;
  12. }
  13. .container {
  14. max-width: 1200px;
  15. margin: 0 auto;
  16. background-color: white;
  17. padding: 20px;
  18. border-radius: 8px;
  19. box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  20. }
  21. h1 {
  22. color: #333;
  23. text-align: center;
  24. margin-bottom: 30px;
  25. }
  26. .test-section {
  27. margin-bottom: 30px;
  28. padding: 20px;
  29. border: 1px solid #ddd;
  30. border-radius: 5px;
  31. background-color: #fafafa;
  32. }
  33. .test-section h3 {
  34. color: #555;
  35. margin-top: 0;
  36. }
  37. button {
  38. background-color: #007bff;
  39. color: white;
  40. border: none;
  41. padding: 10px 20px;
  42. border-radius: 5px;
  43. cursor: pointer;
  44. margin: 5px;
  45. font-size: 14px;
  46. }
  47. button:hover {
  48. background-color: #0056b3;
  49. }
  50. button:disabled {
  51. background-color: #6c757d;
  52. cursor: not-allowed;
  53. }
  54. .result {
  55. margin-top: 15px;
  56. padding: 15px;
  57. border-radius: 5px;
  58. white-space: pre-wrap;
  59. font-family: 'Courier New', monospace;
  60. font-size: 12px;
  61. max-height: 400px;
  62. overflow-y: auto;
  63. }
  64. .success {
  65. background-color: #d4edda;
  66. border: 1px solid #c3e6cb;
  67. color: #155724;
  68. }
  69. .error {
  70. background-color: #f8d7da;
  71. border: 1px solid #f5c6cb;
  72. color: #721c24;
  73. }
  74. .info {
  75. background-color: #d1ecf1;
  76. border: 1px solid #bee5eb;
  77. color: #0c5460;
  78. }
  79. .debug-info {
  80. background-color: #fff3cd;
  81. border: 1px solid #ffeaa7;
  82. color: #856404;
  83. margin-top: 10px;
  84. padding: 10px;
  85. border-radius: 3px;
  86. }
  87. .status {
  88. display: inline-block;
  89. padding: 3px 8px;
  90. border-radius: 3px;
  91. font-size: 12px;
  92. font-weight: bold;
  93. }
  94. .status.success {
  95. background-color: #28a745;
  96. color: white;
  97. }
  98. .status.error {
  99. background-color: #dc3545;
  100. color: white;
  101. }
  102. .status.info {
  103. background-color: #17a2b8;
  104. color: white;
  105. }
  106. </style>
  107. </head>
  108. <body>
  109. <div class="container">
  110. <h1>工伤接口Debug信息保留测试</h1>
  111. <div class="test-section">
  112. <h3>测试说明</h3>
  113. <p>此页面用于测试工伤接口的debug信息是否正确保留。主要检查以下字段是否在返回结果中存在:</p>
  114. <ul>
  115. <li><strong>debug_entry_time</strong>: 方法入口时间</li>
  116. <li><strong>debug_method_entered</strong>: 方法是否已进入</li>
  117. <li><strong>debug_stage</strong>: 当前执行阶段</li>
  118. <li><strong>debug_timestamp</strong>: 时间戳</li>
  119. <li><strong>debug_step</strong>: 执行步骤</li>
  120. <li><strong>debug_request</strong>: 请求参数</li>
  121. <li><strong>debug_action</strong>: 操作类型</li>
  122. </ul>
  123. </div>
  124. <div class="test-section">
  125. <h3>初始化测试</h3>
  126. <p>测试初始化接口,检查debug信息是否被正确保留:</p>
  127. <button onclick="testInit()">测试初始化</button>
  128. <button onclick="testInitWithConfig()">测试初始化(带配置)</button>
  129. <button onclick="testInitTestMode()">测试初始化(测试模式)</button>
  130. <div id="initResult" class="result" style="display: none;"></div>
  131. </div>
  132. <div class="test-section">
  133. <h3>健康检查测试</h3>
  134. <p>测试健康检查接口,检查debug信息是否被正确保留:</p>
  135. <button onclick="testHealth()">测试健康检查</button>
  136. <div id="healthResult" class="result" style="display: none;"></div>
  137. </div>
  138. <div class="test-section">
  139. <h3>统计信息测试</h3>
  140. <p>测试统计信息接口,检查debug信息是否被正确保留:</p>
  141. <button onclick="testStats()">测试统计信息</button>
  142. <div id="statsResult" class="result" style="display: none;"></div>
  143. </div>
  144. <div class="test-section">
  145. <h3>签到状态测试</h3>
  146. <p>测试签到状态接口,检查debug信息是否被正确保留:</p>
  147. <button onclick="testSignInStatus()">测试签到状态</button>
  148. <div id="signInStatusResult" class="result" style="display: none;"></div>
  149. </div>
  150. <div class="test-section">
  151. <h3>批量测试</h3>
  152. <p>批量测试所有接口,检查debug信息保留情况:</p>
  153. <button onclick="runAllTests()">运行所有测试</button>
  154. <div id="allTestsResult" class="result" style="display: none;"></div>
  155. </div>
  156. </div>
  157. <script>
  158. const API_BASE_URL = 'http://localhost:8321/api/entry/workinjury';
  159. // 通用API调用函数
  160. async function callAPI(requestData) {
  161. try {
  162. const response = await fetch(API_BASE_URL, {
  163. method: 'POST',
  164. headers: {
  165. 'Content-Type': 'application/json',
  166. },
  167. body: JSON.stringify(requestData)
  168. });
  169. const result = await response.json();
  170. return {
  171. success: true,
  172. status: response.status,
  173. data: result
  174. };
  175. } catch (error) {
  176. return {
  177. success: false,
  178. error: error.message,
  179. data: null
  180. };
  181. }
  182. }
  183. // 检查debug信息是否完整
  184. function checkDebugInfo(data, testName) {
  185. const requiredFields = [
  186. 'debug_entry_time',
  187. 'debug_method_entered',
  188. 'debug_stage',
  189. 'debug_timestamp',
  190. 'debug_step'
  191. ];
  192. const missingFields = [];
  193. const presentFields = [];
  194. requiredFields.forEach(field => {
  195. if (data[field] !== undefined && data[field] !== null) {
  196. presentFields.push(field);
  197. } else {
  198. missingFields.push(field);
  199. }
  200. });
  201. return {
  202. testName: testName,
  203. allPresent: missingFields.length === 0,
  204. presentFields: presentFields,
  205. missingFields: missingFields,
  206. totalRequired: requiredFields.length,
  207. presentCount: presentFields.length
  208. };
  209. }
  210. // 显示结果
  211. function showResult(elementId, apiResult, testName) {
  212. const element = document.getElementById(elementId);
  213. element.style.display = 'block';
  214. if (!apiResult.success) {
  215. element.className = 'result error';
  216. element.textContent = `API调用失败: ${apiResult.error}`;
  217. return;
  218. }
  219. const debugCheck = checkDebugInfo(apiResult.data, testName);
  220. let resultText = `=== ${testName} ===\n`;
  221. resultText += `HTTP状态: ${apiResult.status}\n`;
  222. resultText += `API成功: ${apiResult.data.success}\n`;
  223. resultText += `返回代码: ${apiResult.data.code}\n`;
  224. resultText += `消息: ${apiResult.data.message}\n\n`;
  225. resultText += `=== Debug信息检查 ===\n`;
  226. resultText += `完整性: ${debugCheck.allPresent ? '✅ 完整' : '❌ 不完整'}\n`;
  227. resultText += `必需字段: ${debugCheck.totalRequired}\n`;
  228. resultText += `存在字段: ${debugCheck.presentCount}\n`;
  229. resultText += `缺失字段: ${debugCheck.missingFields.length > 0 ? debugCheck.missingFields.join(', ') : '无'}\n\n`;
  230. resultText += `=== 存在的Debug字段 ===\n`;
  231. debugCheck.presentFields.forEach(field => {
  232. resultText += `${field}: ${apiResult.data[field]}\n`;
  233. });
  234. if (debugCheck.missingFields.length > 0) {
  235. resultText += `\n=== 缺失的Debug字段 ===\n`;
  236. debugCheck.missingFields.forEach(field => {
  237. resultText += `${field}: 缺失\n`;
  238. });
  239. }
  240. resultText += `\n=== 完整响应数据 ===\n`;
  241. resultText += JSON.stringify(apiResult.data, null, 2);
  242. element.className = debugCheck.allPresent ? 'result success' : 'result error';
  243. element.textContent = resultText;
  244. }
  245. // 测试初始化
  246. async function testInit() {
  247. const requestData = {
  248. action: "init",
  249. timestamp: new Date().toISOString()
  250. };
  251. const result = await callAPI(requestData);
  252. showResult('initResult', result, '初始化测试');
  253. }
  254. // 测试初始化(带配置)
  255. async function testInitWithConfig() {
  256. const requestData = {
  257. action: "init",
  258. timestamp: new Date().toISOString(),
  259. config: {
  260. fixmedinsCode: "SQ201348",
  261. fixmedinsName: "沭阳铭和医院",
  262. interfaceVersion: "V2.1"
  263. }
  264. };
  265. const result = await callAPI(requestData);
  266. showResult('initResult', result, '初始化测试(带配置)');
  267. }
  268. // 测试初始化(测试模式)
  269. async function testInitTestMode() {
  270. const requestData = {
  271. action: "init",
  272. timestamp: new Date().toISOString(),
  273. test_mode: "immediate_return",
  274. config: {
  275. fixmedinsCode: "SQ201348",
  276. fixmedinsName: "沭阳铭和医院",
  277. interfaceVersion: "V2.1"
  278. }
  279. };
  280. const result = await callAPI(requestData);
  281. showResult('initResult', result, '初始化测试(测试模式)');
  282. }
  283. // 测试健康检查
  284. async function testHealth() {
  285. const requestData = {
  286. action: "health",
  287. timestamp: new Date().toISOString()
  288. };
  289. const result = await callAPI(requestData);
  290. showResult('healthResult', result, '健康检查测试');
  291. }
  292. // 测试统计信息
  293. async function testStats() {
  294. const requestData = {
  295. action: "stats",
  296. timestamp: new Date().toISOString()
  297. };
  298. const result = await callAPI(requestData);
  299. showResult('statsResult', result, '统计信息测试');
  300. }
  301. // 测试签到状态
  302. async function testSignInStatus() {
  303. const requestData = {
  304. action: "signin_status",
  305. timestamp: new Date().toISOString()
  306. };
  307. const result = await callAPI(requestData);
  308. showResult('signInStatusResult', result, '签到状态测试');
  309. }
  310. // 运行所有测试
  311. async function runAllTests() {
  312. const element = document.getElementById('allTestsResult');
  313. element.style.display = 'block';
  314. element.className = 'result info';
  315. element.textContent = '正在运行所有测试...';
  316. const tests = [
  317. { name: '初始化', func: testInit },
  318. { name: '初始化(带配置)', func: testInitWithConfig },
  319. { name: '初始化(测试模式)', func: testInitTestMode },
  320. { name: '健康检查', func: testHealth },
  321. { name: '统计信息', func: testStats },
  322. { name: '签到状态', func: testSignInStatus }
  323. ];
  324. let allResults = `=== 批量测试结果 ===\n`;
  325. let successCount = 0;
  326. let totalCount = tests.length;
  327. for (const test of tests) {
  328. allResults += `\n--- ${test.name} ---\n`;
  329. const requestData = {
  330. action: test.name.includes('初始化') ? 'init' :
  331. test.name.includes('健康') ? 'health' :
  332. test.name.includes('统计') ? 'stats' :
  333. test.name.includes('签到') ? 'signin_status' : 'init',
  334. timestamp: new Date().toISOString()
  335. };
  336. if (test.name.includes('带配置')) {
  337. requestData.config = {
  338. fixmedinsCode: "SQ201348",
  339. fixmedinsName: "沭阳铭和医院",
  340. interfaceVersion: "V2.1"
  341. };
  342. } else if (test.name.includes('测试模式')) {
  343. requestData.test_mode = "immediate_return";
  344. requestData.config = {
  345. fixmedinsCode: "SQ201348",
  346. fixmedinsName: "沭阳铭和医院",
  347. interfaceVersion: "V2.1"
  348. };
  349. }
  350. const result = await callAPI(requestData);
  351. const debugCheck = checkDebugInfo(result.data || {}, test.name);
  352. allResults += `状态: ${result.success ? '✅ 成功' : '❌ 失败'}\n`;
  353. allResults += `Debug完整性: ${debugCheck.allPresent ? '✅ 完整' : '❌ 不完整'}\n`;
  354. allResults += `Debug字段: ${debugCheck.presentCount}/${debugCheck.totalRequired}\n`;
  355. if (result.success) successCount++;
  356. }
  357. allResults += `\n=== 总结 ===\n`;
  358. allResults += `总测试数: ${totalCount}\n`;
  359. allResults += `成功数: ${successCount}\n`;
  360. allResults += `失败数: ${totalCount - successCount}\n`;
  361. allResults += `成功率: ${((successCount / totalCount) * 100).toFixed(1)}%\n`;
  362. element.className = successCount === totalCount ? 'result success' : 'result error';
  363. element.textContent = allResults;
  364. }
  365. </script>
  366. </body>
  367. </html>