wangwei 7 سال پیش
والد
کامیت
5e14dd82c4
2فایلهای تغییر یافته به همراه48 افزوده شده و 1 حذف شده
  1. 3 1
      sql/云平台2.0升级-数据割接-基础信息.sql
  2. 45 0
      sql/考生导入-存储过程.sql

+ 3 - 1
sql/云平台2.0升级-数据割接-基础信息.sql

@@ -10,4 +10,6 @@ DELETE  from ecs_core_user where type='STUDENT';
 
 --角色割接
 insert into ec_b_user_role_relation(user_id,role_id,role_code)   
-SELECT DISTINCT  X.user_id,Y.id,Y.code from ecs_core_user_role X, ec_b_role Y where x.role_code=Y.code;
+SELECT DISTINCT  X.user_id,Y.id,Y.code from ecs_core_user_role X, ec_b_role Y where x.role_code=Y.code;
+
+--删除ecs_exam表中的org_id的非空约束

+ 45 - 0
sql/考生导入-存储过程.sql

@@ -0,0 +1,45 @@
+CREATE DEFINER=`root`@`%` PROCEDURE `import_exam_students`(IN `batch_id` bigint)
+BEGIN
+	DECLARE done INT DEFAULT FALSE;
+	declare id BIGINT(20);
+	declare course_id_temp BIGINT(20);
+	declare course_code varchar(255); 
+	declare identity_number varchar(255); 
+	declare student_code varchar(255);
+	declare org_id_temp BIGINT(20);
+	declare org_code varchar(255);
+ 	declare	root_org_id  BIGINT(20);
+	
+	DECLARE cursor_temp CURSOR FOR  
+	select t.id,t.course_code,t.student_code,t.identity_number,t.org_code,t.root_org_id from ec_e_exam_student_tmp t 
+	where t.batch_id= batch_id;
+	
+	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
+	open cursor_temp;
+	
+	read_loop: LOOP
+		FETCH cursor_temp INTO id,course_code,student_code,identity_number,org_code,root_org_id;
+
+		IF done THEN
+			LEAVE read_loop;
+		END IF;
+		
+		SELECT x.id into course_id_temp from ecs_core_course x where x.code= course_code and x.org_id=root_org_id;
+		SELECT course_id_temp;
+  		IF course_id_temp is not null THEN
+		     update ec_e_exam_student_tmp x set x.course_id=course_id_temp 
+				 where  x.course_code=course_code and  x.batch_id= batch_id;
+		END IF;
+		
+		SELECT x.id into org_id_temp from ecs_core_org x where x.code= org_code and x.root_id=root_org_id;
+		SELECT org_id_temp;
+  		IF org_id_temp is not null THEN
+		     update ec_e_exam_student_tmp x set x.org_id=org_id_temp 
+				 where  x.org_code=org_code and  x.batch_id= batch_id;
+		END IF;
+		
+	END LOOP;
+ 	
+    close cursor_temp;
+	
+END