2
0

debug-simple.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // 简单调试脚本
  2. const { exec } = require('child_process');
  3. const util = require('util');
  4. const execPromise = util.promisify(exec);
  5. async function debugSimple() {
  6. console.log('=== 简单调试打印任务问题 ===\n');
  7. try {
  8. // 1. 检查订单ID 25
  9. console.log('1. 检查订单ID 25...');
  10. const { stdout: orderStdout } = await execPromise(
  11. 'psql -h 127.0.0.1 -U postgres -d postgres -c "SELECT id, order_no, amount, pay_state, state FROM orders_mt WHERE id = 25"'
  12. );
  13. console.log(orderStdout);
  14. // 2. 检查飞鹅配置
  15. console.log('\n2. 检查飞鹅配置...');
  16. const { stdout: configStdout } = await execPromise(
  17. 'psql -h 127.0.0.1 -U postgres -d postgres -c "SELECT config_key, config_value FROM feie_config_mt WHERE tenant_id = 1 AND config_key LIKE \'feie.%\'"'
  18. );
  19. console.log(configStdout);
  20. // 3. 检查打印机
  21. console.log('\n3. 检查打印机...');
  22. const { stdout: printerStdout } = await execPromise(
  23. 'psql -h 127.0.0.1 -U postgres -d postgres -c "SELECT id, printer_sn, printer_name, is_default FROM feie_printer_mt WHERE tenant_id = 1"'
  24. );
  25. console.log(printerStdout);
  26. // 4. 检查打印任务
  27. console.log('\n4. 检查打印任务...');
  28. const { stdout: taskStdout } = await execPromise(
  29. 'psql -h 127.0.0.1 -U postgres -d postgres -c "SELECT id, tenant_id, task_id, order_id, print_status, scheduled_at, created_at FROM feie_print_task_mt WHERE order_id = 25 OR order_id = 999 ORDER BY created_at DESC"'
  30. );
  31. console.log(taskStdout);
  32. // 5. 检查系统配置
  33. console.log('\n5. 检查系统配置...');
  34. const { stdout: systemConfigStdout } = await execPromise(
  35. 'psql -h 127.0.0.1 -U postgres -d postgres -c "SELECT config_key, config_value FROM system_config_mt WHERE tenant_id = 1 AND config_key LIKE \'feie.%\'"'
  36. );
  37. console.log(systemConfigStdout);
  38. // 6. 分析问题
  39. console.log('\n6. 问题分析...');
  40. const configLines = configStdout.trim().split('\n');
  41. const hasFeieConfig = configLines.length > 2; // 超过标题行和空行
  42. const printerLines = printerStdout.trim().split('\n');
  43. const hasPrinter = printerLines.length > 2;
  44. const taskLines = taskStdout.trim().split('\n');
  45. const hasTaskFor25 = taskStdout.includes('25');
  46. console.log(` 飞鹅配置: ${hasFeieConfig ? '✅ 存在' : '❌ 缺失'}`);
  47. console.log(` 打印机: ${hasPrinter ? '✅ 存在' : '❌ 缺失'}`);
  48. console.log(` 订单25的打印任务: ${hasTaskFor25 ? '✅ 存在' : '❌ 缺失'}`);
  49. if (!hasFeieConfig) {
  50. console.log('\n 问题: 缺少飞鹅配置');
  51. console.log(' 解决方案: 在feie_config_mt表中添加配置');
  52. }
  53. if (!hasPrinter) {
  54. console.log('\n 问题: 缺少打印机');
  55. console.log(' 解决方案: 在feie_printer_mt表中添加打印机');
  56. }
  57. } catch (error) {
  58. console.error('调试失败:', error.message);
  59. }
  60. }
  61. debugSimple().catch(console.error);