guoyu/修复所有班级status问题.bat
2025-12-11 23:28:07 +08:00

37 lines
1.3 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 >nul
echo ========================================
echo 批量修复 student_class 表的 status 问题
echo ========================================
echo.
echo 此脚本将:
echo 1. 统计当前有多少无效分配status=0
echo 2. 将所有学员的最新班级分配设置为有效status=1
echo 3. 显示修复结果
echo.
pause
echo.
echo [1/3] 统计无效分配数量...
mysql -u root -proot -e "USE study; SELECT COUNT(*) AS 无效分配总数 FROM student_class WHERE status = 0;"
echo.
echo [2/3] 开始修复(这可能需要几秒钟)...
mysql -u root -proot -e "USE study; UPDATE student_class SET status = 1 WHERE id IN (SELECT id FROM (SELECT sc.id FROM student_class sc INNER JOIN sys_user u ON sc.student_id = u.user_id WHERE sc.status = 0 AND u.del_flag = '0') AS temp);"
echo.
echo [3/3] 显示修复结果...
mysql -u root -proot -e "USE study; SELECT COUNT(*) AS 剩余无效分配 FROM student_class WHERE status = 0;"
echo.
echo ========================================
echo 修复完成!
echo ========================================
echo.
echo 说明:
echo - 已将所有正常学员的班级分配状态改为有效status=1
echo - 已删除学员的分配记录保持不变
echo - 导入新学员或修改课程分配时,系统会自动设置正确的状态
echo.
pause