Commit 715b68d6 authored by 刘子正's avatar 刘子正

学生excel导入 新增导入学生年级

parent 13fe63e3
......@@ -66,9 +66,9 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
List<BStudent> queryStudentBySlCode(@Param("slCode") String slCode, @Param("classCode") String classCode);
@Insert("<script>INSERT INTO b_student" +
"(create_date,update_date,create_by,update_by,remarks,del_flag,flag,business_id,code)VALUES" +
"(create_date,update_date,create_by,update_by,remarks,del_flag,flag,business_id,code,grade_code)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.createDate},#{item.updateDate},#{item.createBy},#{item.updateBy},#{item.remarks},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code})" +
"( #{item.createDate},#{item.updateDate},#{item.createBy},#{item.updateBy},#{item.remarks},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.gradeCode})" +
"</foreach></script>")
int insertList(List<BStudent> bStudents);
......@@ -164,5 +164,9 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
"and b_student.flag = 1")
@ResultMap(value = "BaseResultMap")
List<BStudent> queryStudentsByClassCode(String classCode);
@Select("select * from b_grade where code = #{gradeCode} and del_flag = 0 and flag = 1")
List<BStudent> checkStudentGrade(BStudent bStudent);
}
......@@ -127,7 +127,7 @@ public class BStudentServiceImpl implements BStudentService {
ArrayList<SysUser> users = new ArrayList<SysUser>();
ArrayList<UserRole> userRoles = new ArrayList<UserRole>();
String[] headers = {"学号", "学生姓名", "性别","邮箱","年级"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb, headers,false); //获取excel数据
ArrayList<String[]> values = ExcelUtil.importExcel(hwb, headers,true); //获取excel数据
if (values.size()<=0){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
......@@ -172,6 +172,14 @@ public class BStudentServiceImpl implements BStudentService {
continue;
}
//判断4:学年是否存在,存在才能录入
BStudent bs = new BStudent();
bs.setGradeCode(value[4]);
if (bStudentRepository.checkStudentGrade(bs).size() == 0){
valuesGrade.add(value[4]);
continue;
}
//合法:通过了三次判断,证明可建立该用户
valuesOK.add(value);
//为合法的用户建立Gitlab账户,并批量存储Student、User和UserRole;
......@@ -204,6 +212,7 @@ public class BStudentServiceImpl implements BStudentService {
//创建完Gitlab账户后,将完整的User信息和UserRole计入users和userRoles中等待插入数据库
BStudent bStudent = new BStudent(value[0]);
bStudent.setGradeCode(value[4]);
UserUtil.setCurrentPersistOperation(bStudent);
if (!students.contains(bStudent)) {
students.add(bStudent);
......@@ -234,6 +243,9 @@ public class BStudentServiceImpl implements BStudentService {
if(valuesEmailExist.size()>0){
result+="以下邮箱已注册:"+ JSON.toJSONString(valuesEmailExist)+"。";
}
if(valuesGrade.size()>0){
result+="以下学生的学年信息不存在:"+ JSON.toJSONString(valuesGrade)+"。";
}
if (valuesOK.size()<1){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment