check-project-status.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /**
  2. * 检查项目停滞期和改图期数据的验证脚本
  3. *
  4. * 使用方法:
  5. * 1. 在浏览器控制台运行(需要先登录系统)
  6. * 2. 复制下面的代码到控制台执行
  7. */
  8. async function checkProjectStatusFields() {
  9. console.log('🔍 开始检查项目停滞期和改图期字段...\n');
  10. const Parse = window.Parse;
  11. if (!Parse) {
  12. console.error('❌ Parse SDK 未加载!请确保已登录系统。');
  13. return;
  14. }
  15. try {
  16. // 查询所有项目
  17. const query = new Parse.Query('Project');
  18. query.limit(1000); // 最多查询1000个项目
  19. const projects = await query.find();
  20. console.log(`📊 总项目数: ${projects.length}\n`);
  21. let stalledCount = 0;
  22. let modificationCount = 0;
  23. const stalledProjects = [];
  24. const modificationProjects = [];
  25. // 遍历所有项目
  26. projects.forEach(project => {
  27. const id = project.id;
  28. const title = project.get('title') || '未命名项目';
  29. const currentStage = project.get('currentStage') || 'N/A';
  30. const data = project.get('data') || {};
  31. // 检查停滞期
  32. if (data.isStalled === true) {
  33. stalledCount++;
  34. stalledProjects.push({
  35. id,
  36. title,
  37. currentStage,
  38. reasonType: data.stagnationReasonType,
  39. customReason: data.stagnationCustomReason,
  40. estimatedResumeDate: data.estimatedResumeDate,
  41. markedAt: data.markedAt,
  42. markedBy: data.markedBy,
  43. notes: data.reasonNotes
  44. });
  45. }
  46. // 检查改图期
  47. if (data.isModification === true) {
  48. modificationCount++;
  49. modificationProjects.push({
  50. id,
  51. title,
  52. currentStage,
  53. reasonType: data.modificationReasonType,
  54. customReason: data.modificationCustomReason,
  55. markedAt: data.markedAt,
  56. markedBy: data.markedBy,
  57. notes: data.reasonNotes
  58. });
  59. }
  60. });
  61. // 输出统计结果
  62. console.log('📈 统计结果:');
  63. console.log(` ⏸️ 停滞期项目: ${stalledCount} 个`);
  64. console.log(` 🎨 改图期项目: ${modificationCount} 个\n`);
  65. // 输出停滞期项目详情
  66. if (stalledCount > 0) {
  67. console.log('⏸️ 停滞期项目详情:');
  68. console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
  69. stalledProjects.forEach((p, index) => {
  70. console.log(`\n${index + 1}. ${p.title}`);
  71. console.log(` ID: ${p.id}`);
  72. console.log(` 当前阶段: ${p.currentStage}`);
  73. console.log(` 原因类型: ${p.reasonType || 'N/A'}`);
  74. if (p.customReason) {
  75. console.log(` 自定义原因: ${p.customReason}`);
  76. }
  77. if (p.estimatedResumeDate) {
  78. console.log(` 预计恢复: ${new Date(p.estimatedResumeDate).toLocaleDateString()}`);
  79. }
  80. if (p.markedBy) {
  81. console.log(` 标记人: ${p.markedBy}`);
  82. }
  83. if (p.markedAt) {
  84. console.log(` 标记时间: ${new Date(p.markedAt).toLocaleString()}`);
  85. }
  86. if (p.notes) {
  87. console.log(` 备注: ${p.notes}`);
  88. }
  89. });
  90. console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
  91. }
  92. // 输出改图期项目详情
  93. if (modificationCount > 0) {
  94. console.log('🎨 改图期项目详情:');
  95. console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
  96. modificationProjects.forEach((p, index) => {
  97. console.log(`\n${index + 1}. ${p.title}`);
  98. console.log(` ID: ${p.id}`);
  99. console.log(` 当前阶段: ${p.currentStage}`);
  100. console.log(` 原因类型: ${p.reasonType || 'N/A'}`);
  101. if (p.customReason) {
  102. console.log(` 自定义原因: ${p.customReason}`);
  103. }
  104. if (p.markedBy) {
  105. console.log(` 标记人: ${p.markedBy}`);
  106. }
  107. if (p.markedAt) {
  108. console.log(` 标记时间: ${new Date(p.markedAt).toLocaleString()}`);
  109. }
  110. if (p.notes) {
  111. console.log(` 备注: ${p.notes}`);
  112. }
  113. });
  114. console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
  115. }
  116. // 检查数据完整性
  117. console.log('🔬 数据完整性检查:');
  118. let incompleteCount = 0;
  119. const allStatusProjects = [...stalledProjects, ...modificationProjects];
  120. allStatusProjects.forEach(p => {
  121. const issues = [];
  122. if (!p.reasonType) issues.push('缺少原因类型');
  123. if (!p.markedBy) issues.push('缺少标记人');
  124. if (!p.markedAt) issues.push('缺少标记时间');
  125. if (issues.length > 0) {
  126. incompleteCount++;
  127. console.log(` ⚠️ ${p.title}: ${issues.join(', ')}`);
  128. }
  129. });
  130. if (incompleteCount === 0) {
  131. console.log(' ✅ 所有标记项目的数据完整\n');
  132. } else {
  133. console.log(` ⚠️ 有 ${incompleteCount} 个项目的数据不完整\n`);
  134. }
  135. // 返回数据供进一步分析
  136. return {
  137. total: projects.length,
  138. stalledCount,
  139. modificationCount,
  140. stalledProjects,
  141. modificationProjects
  142. };
  143. } catch (error) {
  144. console.error('❌ 检查失败:', error);
  145. return null;
  146. }
  147. }
  148. // 检查特定项目
  149. async function checkSingleProject(projectId) {
  150. console.log(`🔍 检查项目 ID: ${projectId}\n`);
  151. const Parse = window.Parse;
  152. if (!Parse) {
  153. console.error('❌ Parse SDK 未加载!');
  154. return;
  155. }
  156. try {
  157. const query = new Parse.Query('Project');
  158. const project = await query.get(projectId);
  159. const title = project.get('title') || '未命名项目';
  160. const currentStage = project.get('currentStage') || 'N/A';
  161. const stage = project.get('stage') || 'N/A';
  162. const data = project.get('data') || {};
  163. console.log('📋 项目基本信息:');
  164. console.log(` 项目名称: ${title}`);
  165. console.log(` 当前阶段 (currentStage): ${currentStage}`);
  166. console.log(` 阶段 (stage): ${stage}`);
  167. console.log(` 停滞期状态: ${data.isStalled === true ? '✅ 是' : '❌ 否'}`);
  168. console.log(` 改图期状态: ${data.isModification === true ? '✅ 是' : '❌ 否'}\n`);
  169. if (data.isStalled === true) {
  170. console.log('⏸️ 停滞期详情:');
  171. console.log(` 原因类型: ${data.stagnationReasonType || 'N/A'}`);
  172. console.log(` 自定义原因: ${data.stagnationCustomReason || 'N/A'}`);
  173. console.log(` 预计恢复: ${data.estimatedResumeDate ? new Date(data.estimatedResumeDate).toLocaleDateString() : 'N/A'}`);
  174. console.log(` 标记人: ${data.markedBy || 'N/A'}`);
  175. console.log(` 标记时间: ${data.markedAt ? new Date(data.markedAt).toLocaleString() : 'N/A'}`);
  176. console.log(` 备注: ${data.reasonNotes || 'N/A'}\n`);
  177. }
  178. if (data.isModification === true) {
  179. console.log('🎨 改图期详情:');
  180. console.log(` 原因类型: ${data.modificationReasonType || 'N/A'}`);
  181. console.log(` 自定义原因: ${data.modificationCustomReason || 'N/A'}`);
  182. console.log(` 标记人: ${data.markedBy || 'N/A'}`);
  183. console.log(` 标记时间: ${data.markedAt ? new Date(data.markedAt).toLocaleString() : 'N/A'}`);
  184. console.log(` 备注: ${data.reasonNotes || 'N/A'}\n`);
  185. }
  186. console.log('📦 完整 data 字段:');
  187. console.log(data);
  188. return {
  189. title,
  190. currentStage,
  191. stage,
  192. isStalled: data.isStalled,
  193. isModification: data.isModification,
  194. data
  195. };
  196. } catch (error) {
  197. console.error('❌ 查询失败:', error);
  198. return null;
  199. }
  200. }
  201. // 使用说明
  202. console.log('📖 使用方法:');
  203. console.log('1. 检查所有项目: await checkProjectStatusFields()');
  204. console.log('2. 检查特定项目: await checkSingleProject("项目ID")');
  205. console.log('\n示例:');
  206. console.log(' const result = await checkProjectStatusFields();');
  207. console.log(' await checkSingleProject("abc123def456");');
  208. console.log('\n开始执行检查...\n');
  209. // 自动执行检查
  210. checkProjectStatusFields();