学生、员工导入修改

hehai
rong.liu 4 years ago
parent cf83a5cc0e
commit 3d38d6559a
  1. 2
      src/main/java/com/msdw/tms/TmsApplication.java
  2. 209
      src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java
  3. 8
      src/main/java/com/msdw/tms/entity/response/CommonCode.java
  4. 14
      src/main/java/com/msdw/tms/entity/vo/StudentImportFailureVo.java
  5. 181
      src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java
  6. 419
      src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java
  7. BIN
      src/main/resources/excel-template/学生导入失败数据导出模板(1).xlsx
  8. 2
      src/main/resources/mapper/tms/UserInfoDao.xml

@ -6,7 +6,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling//定时任务 //@EnableScheduling//定时任务
@SpringBootApplication @SpringBootApplication
public class TmsApplication extends SpringBootServletInitializer { public class TmsApplication extends SpringBootServletInitializer {

@ -1,7 +1,12 @@
package com.msdw.tms.common.utils; package com.msdw.tms.common.utils;
import com.msdw.tms.common.exception.ExceptionCast;
import com.msdw.tms.entity.response.CommonCode;
import com.msdw.tms.entity.vo.StaffVo; import com.msdw.tms.entity.vo.StaffVo;
import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.entity.vo.StudentVo;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -13,15 +18,62 @@ import java.util.List;
public class ExcelImportHelper { public class ExcelImportHelper {
//判断row是否为空
public static boolean isRowEmpty(Row row) {
if (null == row) {
return true;
}
int firstCellNum = row.getFirstCellNum(); //第一个列位置
int lastCellNum = row.getLastCellNum(); //最后一列位置
int nullCellNum = 0; //空列数量
for (int c = firstCellNum; c < lastCellNum; c++) {
Cell cell = row.getCell(c);
if (null == cell || CellType.BLANK == cell.getCellType()) {
nullCellNum++;
continue;
}
cell.setCellType(CellType.STRING);
String cellValue = cell.getStringCellValue().trim();
if (StringUtils.isEmpty(cellValue)) {
nullCellNum++;
}
}
//所有列都为空
if (nullCellNum == (lastCellNum - firstCellNum)) {
return true;
}
return false;
}
//todo 解决POI无法同时读取带多种格式的单元格表格
public static String getValue(Cell cell) {
if (cell == null) {
return "";
} else if (cell.getCellType() == CellType.BOOLEAN) {
return String.valueOf(cell.getBooleanCellValue());
} else if (cell.getCellType() == CellType.NUMERIC) {
String value = "";
return value;
} else {
return String.valueOf(cell.getStringCellValue());
}
}
/** /**
* 读取学生管理 * 读取学生管理
*
* @param file * @param file
* @return * @return
*/ */
public static List<StudentVo> readStudent(MultipartFile file) { public static List<StudentVo> readStudent(MultipartFile file) throws IOException {
List<StudentVo> list = new ArrayList<StudentVo>(); List<StudentVo> list = new ArrayList<StudentVo>();
Workbook workbook=getWorkbook(file); Workbook workbook = getWorkbook(file);
StudentVo student = null; StudentVo student = null;
// 循环工作表Sheet // 循环工作表Sheet
for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) { for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
@ -29,38 +81,57 @@ public class ExcelImportHelper {
if (hssfSheet == null) { if (hssfSheet == null) {
continue; continue;
} }
int count = 1;
// 循环行Row//开始行2 // 循环行Row//开始行2
for (int rowNum = 2; rowNum <= hssfSheet.getLastRowNum(); rowNum++) { for (int rowNum = 2; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
Row row = hssfSheet.getRow(rowNum); Row row = hssfSheet.getRow(rowNum);
if (isRowEmpty(row)) {
count++;
if (count == hssfSheet.getLastRowNum()) {
ExceptionCast.cast(CommonCode.EXCEL_FILE_NULL);
}
continue;
}
if (row == null) {
continue;
} else if (
StringUtils.isEmpty(getValue(row.getCell(0))) &&
StringUtils.isEmpty(getValue(row.getCell(1))) &&
StringUtils.isEmpty(getValue(row.getCell(2)))) {
continue;
}
Cell phone; Cell phone;
Cell email; Cell email;
if (row != null) { if (row != null) {
student = new StudentVo(); student = new StudentVo();
row.getCell(0).setCellType(CellType.STRING); row.getCell(0).setCellType(CellType.STRING);
Cell studentName = row.getCell(0); Cell studentName = row.getCell(0);
row.getCell(1).setCellType(CellType.STRING); row.getCell(1).setCellType(CellType.STRING);
Cell schoolAppellationName = row.getCell(1); Cell account = row.getCell(1);
row.getCell(2).setCellType(CellType.STRING); row.getCell(2).setCellType(CellType.STRING);
Cell account = row.getCell(2);
Cell studentNumber = row.getCell(2);
if (row.getCell(3) != null) {
row.getCell(3).setCellType(CellType.STRING); row.getCell(3).setCellType(CellType.STRING);
Cell studentNumber = row.getCell(3); phone = row.getCell(3);
if (row.getCell(4)!=null){ } else {
row.getCell(4).setCellType(CellType.STRING); phone = row.createCell(3);
phone = row.getCell(4);
}else {
phone = row.createCell(4);
} }
if (row.getCell(5)!=null){
row.getCell(5).setCellType(CellType.STRING); if (row.getCell(4) != null) {
email = row.getCell(5); row.getCell(4).setCellType(CellType.STRING);
}else { email = row.getCell(4);
email = row.createCell(5); } else {
email = row.createCell(4);
} }
// row.getCell(4).setCellType(CellType.STRING);
// Cell phone = row.getCell(4);
// row.getCell(5).setCellType(CellType.STRING);
// Cell email = row.getCell(5);
// 学生姓名 // 学生姓名
@ -69,8 +140,6 @@ public class ExcelImportHelper {
student.setRoleId(ConstantUtils.STUDENT_ROLE); student.setRoleId(ConstantUtils.STUDENT_ROLE);
// 学生学号 // 学生学号
student.setWorkNumber(studentNumber.getStringCellValue()); student.setWorkNumber(studentNumber.getStringCellValue());
//所属院校
student.setSchoolAppellationName(schoolAppellationName.getStringCellValue());
//用户账号 //用户账号
student.setAccount(account.getStringCellValue()); student.setAccount(account.getStringCellValue());
//电话 //电话
@ -87,15 +156,18 @@ public class ExcelImportHelper {
return list; return list;
} }
/** /**
* 读取员工管理 * 读取员工管理
*
* @param file * @param file
* @return * @return
*/ */
public static List<StaffVo> readStaff(MultipartFile file) { public static List<StaffVo> readStaff(MultipartFile file) throws IOException {
List<StaffVo> list = new ArrayList<StaffVo>(); List<StaffVo> list = new ArrayList<StaffVo>();
Workbook workbook=getWorkbook(file); Workbook workbook = getWorkbook(file);
StaffVo staff = null; StaffVo staff = null;
// 循环工作表Sheet // 循环工作表Sheet
for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) { for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
@ -103,97 +175,110 @@ public class ExcelImportHelper {
if (hssfSheet == null) { if (hssfSheet == null) {
continue; continue;
} }
int lastRowNum = hssfSheet.getLastRowNum()+1;//最后一行行标,比行数小1 /*int lastRowNum = hssfSheet.getLastRowNum() + 1;//最后一行行标,比行数小1
if (lastRowNum==2){ if (lastRowNum == 2) {
break; break;
} }*/
int count = 1;
// 循环行Row//开始行2 // 循环行Row//开始行2
for (int rowNum = 2; rowNum <= hssfSheet.getLastRowNum(); rowNum++) { for (int rowNum = 2; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
Row row = hssfSheet.getRow(rowNum); Row row = hssfSheet.getRow(rowNum);
Cell userName; if (isRowEmpty(row)) {
count++;
if (count == hssfSheet.getLastRowNum()) {
ExceptionCast.cast(CommonCode.EXCEL_FILE_NULL);
}
continue;
}
Cell phone; Cell phone;
Cell email; Cell email;
Cell staffGradeName; Cell staffGradeName;
Cell staffProfessionalArchitectureName; Cell staffProfessionalArchitectureName;
Cell staffGradeNameTwo; Cell staffGradeNameTwo;
Cell staffProfessionalArchitectureNameTwo; Cell staffProfessionalArchitectureNameTwo;
if (row != null) { /*Cell account;
Cell role;
Cell workNumber;*/
Cell userName;
if (row == null) {
continue;
} else {
staff = new StaffVo(); staff = new StaffVo();
if (row.getCell(0)!=null){ if (row.getCell(0) != null) {
row.getCell(0).setCellType(CellType.STRING); row.getCell(0).setCellType(CellType.STRING);
userName = row.getCell(0); userName = row.getCell(0);
}else { } else {
continue; userName = row.createCell(0);
} }
//姓名
/* row.getCell(0).setCellType(CellType.STRING);
String userName = row.getCell(0).getStringCellValue();*/
//账号
row.getCell(1).setCellType(CellType.STRING); row.getCell(1).setCellType(CellType.STRING);
Cell account = row.getCell(1); Cell account = row.getCell(1);
//角色
row.getCell(2).setCellType(CellType.STRING); row.getCell(2).setCellType(CellType.STRING);
Cell role = row.getCell(2); Cell role = row.getCell(2);
//工号
row.getCell(3).setCellType(CellType.STRING); row.getCell(3).setCellType(CellType.STRING);
Cell workNumber = row.getCell(3); Cell workNumber = row.getCell(3);
// row.getCell(4).setCellType(CellType.STRING);
// Cell staffGradeName = row.getCell(4);
if (row.getCell(4)!=null){ if (row.getCell(4) != null) {
row.getCell(4).setCellType(CellType.STRING); row.getCell(4).setCellType(CellType.STRING);
staffProfessionalArchitectureName = row.getCell(4); staffProfessionalArchitectureName = row.getCell(4);
}else { } else {
staffProfessionalArchitectureName = row.createCell(4); staffProfessionalArchitectureName = row.createCell(4);
} }
if (row.getCell(5)!=null){ if (row.getCell(5) != null) {
row.getCell(5).setCellType(CellType.STRING); row.getCell(5).setCellType(CellType.STRING);
staffGradeName = row.getCell(5); staffGradeName = row.getCell(5);
}else { } else {
staffGradeName = row.createCell(5); staffGradeName = row.createCell(5);
} }
if (row.getCell(6)!=null){ if (row.getCell(6) != null) {
row.getCell(6).setCellType(CellType.STRING); row.getCell(6).setCellType(CellType.STRING);
staffProfessionalArchitectureNameTwo = row.getCell(6); staffProfessionalArchitectureNameTwo = row.getCell(6);
}else { } else {
staffProfessionalArchitectureNameTwo = row.createCell(6); staffProfessionalArchitectureNameTwo = row.createCell(6);
} }
if (row.getCell(7)!=null){ if (row.getCell(7) != null) {
row.getCell(7).setCellType(CellType.STRING); row.getCell(7).setCellType(CellType.STRING);
staffGradeNameTwo = row.getCell(7); staffGradeNameTwo = row.getCell(7);
}else { } else {
staffGradeNameTwo = row.createCell(7); staffGradeNameTwo = row.createCell(7);
} }
if (row.getCell(8) != null) {
// row.getCell(5).setCellType(CellType.STRING);
// Cell staffProfessionalArchitectureName = row.getCell(5);
// row.getCell(6).setCellType(CellType.STRING);
// Cell staffGradeNameTwo = row.getCell(6);
// row.getCell(7).setCellType(CellType.STRING);
// Cell staffProfessionalArchitectureNameTwo = row.getCell(7);
if (row.getCell(8)!=null){
row.getCell(8).setCellType(CellType.STRING); row.getCell(8).setCellType(CellType.STRING);
phone = row.getCell(8); phone = row.getCell(8);
}else { } else {
phone = row.createCell(8); phone = row.createCell(8);
} }
if (row.getCell(9)!=null){ if (row.getCell(9) != null) {
row.getCell(9).setCellType(CellType.STRING); row.getCell(9).setCellType(CellType.STRING);
email = row.getCell(9); email = row.getCell(9);
}else { } else {
email = row.createCell(9); email = row.createCell(9);
} }
row.getCell(10).setCellType(CellType.STRING);
Cell schoolAppellationName = row.getCell(10);
// row.getCell(11).setCellType(CellType.STRING);
// Cell failureMsg = row.getCell(11);
/*row.getCell(10).setCellType(CellType.STRING);
Cell schoolAppellationName = row.getCell(10);*/
String roleValue = role.getStringCellValue(); String roleValue = role.getStringCellValue();
String str; String str;
// 角色id // 角色id
if (roleValue.equals("管理员")){ if (roleValue.equals("管理员")) {
str = "13";//2 str = "13";//2
}else if (roleValue.equals("老师")){ } else if (roleValue.equals("老师")) {
str = "14";//3 str = "14";//3
}else{ } else {
str = "13,14"; str = "13,14";
} }
staff.setRoleId(str); staff.setRoleId(str);
@ -218,7 +303,7 @@ public class ExcelImportHelper {
//邮箱 //邮箱
staff.setEmail(email.getStringCellValue()); staff.setEmail(email.getStringCellValue());
//所属院校 //所属院校
staff.setSchoolAppellationName(schoolAppellationName.getStringCellValue()); //staff.setSchoolAppellationName(schoolAppellationName.getStringCellValue());
//学校id //学校id
staff.setSchoolId(ConstantUtils.Keda_schoolId); staff.setSchoolId(ConstantUtils.Keda_schoolId);
list.add(staff); list.add(staff);
@ -239,7 +324,7 @@ public class ExcelImportHelper {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
}else if (fileName.endsWith("xls")) { } else if (fileName.endsWith("xls")) {
try { try {
workbook = new HSSFWorkbook(file.getInputStream()); workbook = new HSSFWorkbook(file.getInputStream());
} catch (IOException e) { } catch (IOException e) {

@ -17,10 +17,14 @@ public enum CommonCode implements ResultCode {
EXCEL_FILE_INVALID(false, 10009, "上传excel文件错误!"), EXCEL_FILE_INVALID(false, 10009, "上传excel文件错误!"),
REPEAT_INEXCEL(false, 10010, "试题在excel表中重复!"), REPEAT_INEXCEL(false, 10010, "试题在excel表中重复!"),
EVALUATION_QUESTION_NUM_INVALID(false, 10011, "当前测评题数设置为0,请先设置测评题数!"), EVALUATION_QUESTION_NUM_INVALID(false, 10011, "当前测评题数设置为0,请先设置测评题数!"),
EXCEL_FILE_NULL(false, 100011, "导入失败,导入数据为空!"),
EXCEL_FILE_FORMAT_ERROR(false, 100012, "请根据模板使用说明录入正确的学生信息!"),
EXCEL_FILE_FORMAT_ERROR_STAFFS(false, 100012, "请根据模板使用说明录入正确的员工信息!"),
FAIL(false, 11111, "操作失败!"), FAIL(false, 11111, "操作失败!"),
ROLE_NAME_EXIST(false,20001,"该角色名称已存在,请重新输入!"),
ROLE_EMP_EXIST(false,44001,"该角色有用户关联,不能删除!"), ROLE_NAME_EXIST(false, 20001, "该角色名称已存在,请重新输入!"),
ROLE_EMP_EXIST(false, 44001, "该角色有用户关联,不能删除!"),
SERVER_ERROR(false, 99999, "抱歉,系统繁忙,请稍后重试!"); SERVER_ERROR(false, 99999, "抱歉,系统繁忙,请稍后重试!");
//操作是否成功 //操作是否成功
boolean success; boolean success;

@ -15,23 +15,23 @@ public class StudentImportFailureVo {
//用户姓名 //用户姓名
@ExcelAttribute(sort = 0) @ExcelAttribute(sort = 0)
private String userName; private String userName;
//所属院校 /*//所属院校
@ExcelAttribute(sort = 1) @ExcelAttribute(sort = 1)
private String schoolAppellationName; private String schoolAppellationName;*/
//账号 //账号
@ExcelAttribute(sort = 2) @ExcelAttribute(sort = 1)
private String account; private String account;
//学号 //学号
@ExcelAttribute(sort = 3) @ExcelAttribute(sort = 2)
private String workNumber; private String workNumber;
//手机号码 //手机号码
@ExcelAttribute(sort = 4) @ExcelAttribute(sort = 3)
private String phone; private String phone;
//邮箱 //邮箱
@ExcelAttribute(sort = 5) @ExcelAttribute(sort = 4)
private String email; private String email;
//失败原因 //失败原因
@ExcelAttribute(sort = 6) @ExcelAttribute(sort = 5)
private String failureMsg; private String failureMsg;
// //
// @ExcelAttribute(sort = 7) // @ExcelAttribute(sort = 7)

@ -39,7 +39,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@Service("studentService") @Service("studentService")
public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> implements StudentService { public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> implements StudentService {
@Autowired @Autowired
private StudentDao studentDao; private StudentDao studentDao;
@ -57,11 +57,11 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
StringRedisTemplate stringRedisTemplate; StringRedisTemplate stringRedisTemplate;
@Override @Override
public Integer queryStudentIdNumber(String workNumber,Integer schoolId) { public Integer queryStudentIdNumber(String workNumber, Integer schoolId) {
List<Integer> result = studentDao.queryStudentIdNumber(workNumber,schoolId); List<Integer> result = studentDao.queryStudentIdNumber(workNumber, schoolId);
if (result.size()==1){ if (result.size() == 1) {
return 1; return 1;
}else{ } else {
return 0; return 0;
} }
} }
@ -75,9 +75,9 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
} }
@Override @Override
public PageUtils queryStudent(Integer schoolId,String searchContent, Integer page, Integer size) { public PageUtils queryStudent(Integer schoolId, String searchContent, Integer page, Integer size) {
Page<T> tPage = new Page<>(page,size); Page<T> tPage = new Page<>(page, size);
IPage<StudentVo> saveStudent = studentDao.queryStudent(tPage,searchContent,schoolId); IPage<StudentVo> saveStudent = studentDao.queryStudent(tPage, searchContent, schoolId);
PageUtils pageUtils = new PageUtils(saveStudent); PageUtils pageUtils = new PageUtils(saveStudent);
return pageUtils; return pageUtils;
} }
@ -85,10 +85,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
@Override @Override
public R queryStudentDetails(Integer userId) { public R queryStudentDetails(Integer userId) {
StudentVo saveStudent = studentDao.queryStudentDetails(userId); StudentVo saveStudent = studentDao.queryStudentDetails(userId);
if (saveStudent!=null){ if (saveStudent != null) {
return R.ok().put("data",saveStudent); return R.ok().put("data", saveStudent);
}else { } else {
return R.error(300,"用户不存在!"); return R.error(300, "用户不存在!");
} }
} }
@ -99,7 +99,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
try { try {
Integer delete = studentDao.deleteStudent(studentId); Integer delete = studentDao.deleteStudent(studentId);
return true; return true;
}catch (RuntimeException e){ } catch (RuntimeException e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
@ -110,7 +110,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
try { try {
Integer update = studentDao.updateStudent(studentVo); Integer update = studentDao.updateStudent(studentVo);
return true; return true;
}catch (RuntimeException e){ } catch (RuntimeException e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
@ -118,16 +118,16 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
@Override @Override
public void updateWorkNumber(Integer studentId) { public void updateWorkNumber(Integer studentId) {
studentDao.updateWorkNumber("00",studentId);//将学号重置为00 studentDao.updateWorkNumber("00", studentId);//将学号重置为00
} }
@Override @Override
public R addStudentInfo(StudentVo studentVo) { public R addStudentInfo(StudentVo studentVo) {
R r = new R(); R r = new R();
boolean result = studentDao.addStudentInfo(studentVo); boolean result = studentDao.addStudentInfo(studentVo);
if (result==false){ if (result == false) {
throw new RuntimeException();//添加失败,抛出运行时异常让外层事务回滚 throw new RuntimeException();//添加失败,抛出运行时异常让外层事务回滚
}else{ } else {
return R.ok("注册成功!"); return R.ok("注册成功!");
} }
@ -141,8 +141,15 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
@Transactional @Transactional
@Override @Override
public Map<String, String> upload(MultipartFile file, Integer schoolId) throws IOException{ public Map<String, String> upload(MultipartFile file, Integer schoolId) throws IOException {
List<StudentVo> students = ExcelImportHelper.readStudent(file); List<StudentVo> students = ExcelImportHelper.readStudent(file);
if (students.size() <= 0) {
ExceptionCast.cast(CommonCode.EXCEL_FILE_FORMAT_ERROR);
}
Map<String, String> errorMap = new HashMap<>();
List<StudentImportFailureVo> failVo1 = new ArrayList<>(); List<StudentImportFailureVo> failVo1 = new ArrayList<>();
// 参数合法性校验,只能上传.xlsx后缀的文件 // 参数合法性校验,只能上传.xlsx后缀的文件
if (StringUtils.isBlank(file.getOriginalFilename()) if (StringUtils.isBlank(file.getOriginalFilename())
@ -153,24 +160,83 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
Long ii = 1L;//用于记录序列号 Long ii = 1L;//用于记录序列号
try { try {
for (int i = 0;i<students.size();i++){ for (int i = 0; i < students.size(); i++) {
StudentVo student = students.get(i); StudentVo student = students.get(i);
String userName = student.getUserName();
if (userName.equals("")) {
log.error("*姓名不能为空");
StudentImportFailureVo vo = new StudentImportFailureVo();
++ii;
vo.setIndex(ii)
.setUserName(student.getUserName() + " 必填项:((姓名不能为空)")
.setAccount(student.getAccount())
.setWorkNumber(student.getWorkNumber())
.setPhone(student.getPhone()).setEmail(student.getEmail())
;
failVo1.add(vo);
students.remove(i);
i--;
continue;
}
String phone = student.getPhone(); String phone = student.getPhone();
String workNumber = student.getWorkNumber(); String workNumber = student.getWorkNumber();
if (workNumber.equals("")) {
log.error("*学号不能为空");
StudentImportFailureVo vo = new StudentImportFailureVo();
++ii;
vo.setIndex(ii)
.setUserName(student.getUserName())
.setAccount(student.getAccount())
.setWorkNumber(student.getWorkNumber() + " 必填项:(*学号不能为空)")
.setPhone(student.getPhone()).setEmail(student.getEmail())
;
failVo1.add(vo);
students.remove(i);
i--;
continue;
}
String account = student.getAccount(); String account = student.getAccount();
if (account.equals("")) {
log.error("*账号不能为空");
StudentImportFailureVo vo = new StudentImportFailureVo();
++ii;
vo.setIndex(ii)
.setUserName(student.getUserName())
.setAccount(student.getAccount() + " 必填项:(*账号不能为空)")
.setWorkNumber(student.getWorkNumber())
.setPhone(student.getPhone()).setEmail(student.getEmail())
;
failVo1.add(vo);
students.remove(i);
i--;
continue;
}
StudentVo studentVo = new StudentVo(); StudentVo studentVo = new StudentVo();
String schoolAppellationName = student.getSchoolAppellationName(); //String schoolAppellationName = student.getSchoolAppellationName();
List<Integer> result1 = studentDao.queryStudentIdNumber(workNumber,schoolId); List<Integer> result1 = studentDao.queryStudentIdNumber(workNumber, schoolId);
List<StudentEntity> result4 = userInfoDao.queryStudentAccount(account); List<StudentEntity> result4 = userInfoDao.queryStudentAccount(account);
String email = student.getEmail(); String email = student.getEmail();
if (phone!=null&&phone!=""){ if (phone != null && phone != "") {
List<StudentEntity> result2 = userInfoDao.queryStudentPhone(phone); List<StudentEntity> result2 = userInfoDao.queryStudentPhone(phone);
if (result2.size()>=1){ if (result2.size() >= 1) {
log.error("该号码已被使用"); log.error("该号码已被使用");
StudentImportFailureVo vo = new StudentImportFailureVo(); StudentImportFailureVo vo = new StudentImportFailureVo();
++ii; ++ii;
vo.setIndex(ii).setUserName(student.getUserName()).setSchoolAppellationName(student.getSchoolAppellationName()) vo.setIndex(ii)
.setAccount(student.getAccount()).setWorkNumber(student.getWorkNumber()).setPhone(student.getPhone()+" (重复的号码)").setEmail(student.getEmail()) .setUserName(student.getUserName())
.setAccount(student.getAccount())
.setWorkNumber(student.getWorkNumber())
.setPhone(student.getPhone() + " (重复的号码)")
.setEmail(student.getEmail())
; ;
failVo1.add(vo); failVo1.add(vo);
students.remove(i); students.remove(i);
@ -179,24 +245,29 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
} }
studentVo.setPhone(phone); studentVo.setPhone(phone);
} }
if (email!=null&&email!=""){ if (email != null && email != "") {
studentVo.setEmail(email); studentVo.setEmail(email);
} }
List<Integer> result3 = studentDao.querySchoolName(schoolAppellationName); // List<Integer> result3 = studentDao.querySchoolName(schoolAppellationName);
// 唯一标示性账号 // 唯一标示性账号
studentVo.setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis())). studentVo.setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis())).
setPassword(ConstantUtils.INITIAL_PASSWORD).setToken(new ConstantUtils().token) setPassword(ConstantUtils.INITIAL_PASSWORD).setToken(new ConstantUtils().token)
.setSchoolId(ConstantUtils.Keda_schoolId).setRoleId(ConstantUtils.STUDENT_ROLE) .setSchoolId(ConstantUtils.Keda_schoolId).setRoleId(ConstantUtils.STUDENT_ROLE)
; ;
studentVo.setAccount(student.getAccount()).setSchoolAppellationName(schoolAppellationName) studentVo.setAccount(student.getAccount())
.setUserName(student.getUserName()).setIsdel(Constant.IsDel.NOT_DEL.getType()); .setUserName(student.getUserName())
.setIsdel(Constant.IsDel.NOT_DEL.getType());
if (result1.size()>=1){ if (result1.size() >= 1) {
log.error("该学号已存在"); log.error("该学号已存在");
StudentImportFailureVo vo = new StudentImportFailureVo(); StudentImportFailureVo vo = new StudentImportFailureVo();
++ii; ++ii;
vo.setIndex(ii).setUserName(student.getUserName()).setSchoolAppellationName(student.getSchoolAppellationName()) vo.setIndex(ii)
.setAccount(student.getAccount()).setWorkNumber(student.getWorkNumber()+" (重复的学号)").setPhone(student.getPhone()).setEmail(student.getEmail()) .setUserName(student.getUserName())
.setAccount(student.getAccount())
.setWorkNumber(student.getWorkNumber() + " (重复的学号)")
.setPhone(student.getPhone()).setEmail(student.getEmail())
; ;
// .setFailureMsg("重复的学号"); // .setFailureMsg("重复的学号");
failVo1.add(vo); failVo1.add(vo);
@ -204,12 +275,16 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
students.remove(i); students.remove(i);
i--; i--;
continue; continue;
}else if(result4.size()>=1){ } else if (result4.size() >= 1) {
log.error("账号已存在"); log.error("账号已存在");
StudentImportFailureVo vo = new StudentImportFailureVo(); StudentImportFailureVo vo = new StudentImportFailureVo();
++ii; ++ii;
vo.setIndex(ii).setUserName(student.getUserName()).setSchoolAppellationName(student.getSchoolAppellationName()) vo.setIndex(ii)
.setAccount(student.getAccount()+" (重复的账号)").setWorkNumber(student.getWorkNumber()).setPhone(student.getPhone()).setEmail(student.getEmail()) .setUserName(student.getUserName())
.setAccount(student.getAccount() + " (重复的账号)")
.setWorkNumber(student.getWorkNumber())
.setPhone(student.getPhone())
.setEmail(student.getEmail())
; ;
// .setFailureMsg("重复的账号"); // .setFailureMsg("重复的账号");
failVo1.add(vo); failVo1.add(vo);
@ -218,7 +293,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
i--; i--;
continue; continue;
} }
else if(result3.size()!=1){ /*else if(result3.size()!=1){
log.error("不存在该院校"); log.error("不存在该院校");
StudentImportFailureVo vo = new StudentImportFailureVo(); StudentImportFailureVo vo = new StudentImportFailureVo();
++ii; ++ii;
@ -230,22 +305,23 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
students.remove(i); students.remove(i);
i--; i--;
continue; continue;
} }*/
++ii; ++ii;
if (!students.isEmpty()&&students.size()>0){ if (!students.isEmpty() && students.size() > 0) {
studentVo.setSchoolId(schoolId);
userInfoDao.batchSaveUserInfo(studentVo); userInfoDao.batchSaveUserInfo(studentVo);
student.setUserId(studentVo.getUserId()).setIsdel(Constant.IsDel.NOT_DEL.getType()).setPlatformId(ConstantUtils.PLATFORMID); student.setUserId(studentVo.getUserId()).setIsdel(Constant.IsDel.NOT_DEL.getType()).setPlatformId(ConstantUtils.PLATFORMID);
boolean b = studentDao.saveStudent(student); boolean b = studentDao.saveStudent(student);
if (!b){ if (!b) {
throw new RuntimeException(); throw new RuntimeException();
} }
} }
} }
}catch (RuntimeException e){ } catch (RuntimeException e) {
log.error(e.getMessage()); log.error(e.getMessage());
map.put("failura","添加失败"); map.put("failura", "添加失败");
throw new RuntimeException(); throw new RuntimeException();
} }
String token = ""; String token = "";
@ -261,14 +337,14 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
ops.set(token, failureVOJson, 30 * 60, TimeUnit.SECONDS); ops.set(token, failureVOJson, 30 * 60, TimeUnit.SECONDS);
} }
map.put("token", token); map.put("token", token);
map.put("successNum", (size-failVo1.size())+""); map.put("successNum", (size - failVo1.size()) + "");
map.put("failureNum", failVo1.size()+""); map.put("failureNum", failVo1.size() + "");
return map; return map;
} }
@Override @Override
public void exportFailureRecord(HttpServletResponse response,String token) throws Exception{ public void exportFailureRecord(HttpServletResponse response, String token) throws Exception {
if (StringUtils.isEmpty(token)) { if (StringUtils.isEmpty(token)) {
return; return;
} }
@ -284,23 +360,24 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
parse.sort(Comparator.comparing(StudentImportFailureVo::getIndex)); parse.sort(Comparator.comparing(StudentImportFailureVo::getIndex));
//2.加载模板流数据 //2.加载模板流数据
org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/学生导入失败数据导出模板.xlsx"); org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/学生导入失败数据导出模板(1).xlsx");
InputStream inputStream = resource.getInputStream(); InputStream inputStream = resource.getInputStream();
//3、通过工具类下载文件 //3、通过工具类下载文件
new ExcelExportUtil(StudentImportFailureVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). new ExcelExportUtil(StudentImportFailureVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX).
export(response, inputStream, parse, "学生信息导入失败表.xlsx"); export(response, inputStream, parse, "学生信息导入失败表(1).xlsx");
} }
@Override @Override
public R queryAccount(String account,Integer schoolId) { public R queryAccount(String account, Integer schoolId) {
List<StudentVo> result = studentDao.queryAccount(account,schoolId); List<StudentVo> result = studentDao.queryAccount(account, schoolId);
List<StaffVo> vos = userInfoDao.queryAccount(account); List<StaffVo> vos = userInfoDao.queryAccount(account);
if (result.size()>1){ if (result.size() > 1) {
return R.error("系统存在多个相同的账号:"+account); return R.error("系统存在多个相同的账号:" + account);
}else if (result.size()==1){return R.ok().put("data",result); } else if (result.size() == 1) {
}else if (vos.size()>0){ return R.ok().put("data", result);
} else if (vos.size() > 0) {
return R.error("账号已存在"); return R.error("账号已存在");
} }
return R.ok(); return R.ok();

@ -65,33 +65,35 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
String email = staffVo.getEmail(); String email = staffVo.getEmail();
String workNumber = staffVo.getWorkNumber(); String workNumber = staffVo.getWorkNumber();
List<StaffEntity> staff = staffVo.getStaff(); List<StaffEntity> staff = staffVo.getStaff();
if (phone!=null&&phone!=""){ if (phone != null && phone != "") {
List<Integer> resultP = userInfoDao.queryPhone(phone); List<Integer> resultP = userInfoDao.queryPhone(phone);
if (resultP.size()>0){ if (resultP.size() > 0) {
return R.error(400,"手机号不能重复"); return R.error(400, "手机号不能重复");
} }
} }
if (email!=null&&email!=""){ if (email != null && email != "") {
List<Integer> resultE = userInfoDao.queryEmail(email); List<Integer> resultE = userInfoDao.queryEmail(email);
if (resultE.size()>0){ if (resultE.size() > 0) {
return R.error(400,"手机号不能重复"); return R.error(400, "手机号不能重复");
} }
} }
List<StaffVo> resultA = userInfoDao.queryAccount(account); List<StaffVo> resultA = userInfoDao.queryAccount(account);
// List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber); // List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if(resultA.size()>0){ if (resultA.size() > 0) {
return R.error(400,"账号不能重复"); return R.error(400, "账号不能重复");
} }
Integer userId = userInfoDao.addUserinfo(staffVo); Integer userId = userInfoDao.addUserinfo(staffVo);
for (int i=0;i<staff.size();i++){ for (int i = 0; i < staff.size(); i++) {
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber); List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if (resultW.size()>0){ if (resultW.size() > 0) {
return R.error(400,"工号不能重复"+workNumber); return R.error(400, "工号不能重复" + workNumber);
} }
StaffEntity entity = staff.get(i); StaffEntity entity = staff.get(i);
entity.setSchoolId(ConstantUtils.Keda_schoolId).setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId()); entity.setSchoolId(ConstantUtils.Keda_schoolId).setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId());
boolean result = systemSetttingDao.addStaffN(entity); boolean result = systemSetttingDao.addStaffN(entity);
if (!result) {throw new RuntimeException();} if (!result) {
throw new RuntimeException();
}
} }
// String[] split = staffVo.getRoleId().split(","); // String[] split = staffVo.getRoleId().split(",");
// for (String s : split){ // for (String s : split){
@ -107,7 +109,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
@Override @Override
public PageUtils queryStaff(StaffVo staffVo) { public PageUtils queryStaff(StaffVo staffVo) {
Page<T> tPage = new Page<>(staffVo.getPage(), staffVo.getSize()); Page<T> tPage = new Page<>(staffVo.getPage(), staffVo.getSize());
IPage<StaffVo> staff = systemSetttingDao.queryStaff(tPage, staffVo.getSearchContent(),ConstantUtils.Keda_schoolId,staffVo.getStaffGradeIds(),staffVo.getStaffProfessionalArchitectureIds()); IPage<StaffVo> staff = systemSetttingDao.queryStaff(tPage, staffVo.getSearchContent(), ConstantUtils.Keda_schoolId, staffVo.getStaffGradeIds(), staffVo.getStaffProfessionalArchitectureIds());
PageUtils pageUtils = new PageUtils(staff); PageUtils pageUtils = new PageUtils(staff);
return pageUtils; return pageUtils;
} }
@ -120,8 +122,8 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
List<StaffVo> staff = systemSetttingDao.queryStaffInfo(userId); List<StaffVo> staff = systemSetttingDao.queryStaffInfo(userId);
// result.setWorkNumber(staff.getWorkNumber()).setStaffGradeId(staff.getStaffGradeId()).setStaffGradeName(staff.getStaffGradeName()) // result.setWorkNumber(staff.getWorkNumber()).setStaffGradeId(staff.getStaffGradeId()).setStaffGradeName(staff.getStaffGradeName())
// .setStaffProfessionalArchitectureId(staff.getStaffProfessionalArchitectureId()).setStaffProfessionalArchitectureName(staff.getStaffProfessionalArchitectureName()); // .setStaffProfessionalArchitectureId(staff.getStaffProfessionalArchitectureId()).setStaffProfessionalArchitectureName(staff.getStaffProfessionalArchitectureName());
map.put("userInfo",result); map.put("userInfo", result);
map.put("staffInfo",staff); map.put("staffInfo", staff);
return map; return map;
} }
@ -138,45 +140,49 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
String roleIds = result.getRoleId(); String roleIds = result.getRoleId();
String[] splitOld = staffVo.getRoleId().split(","); String[] splitOld = staffVo.getRoleId().split(",");
String[] splitNew = roleIds.split(","); String[] splitNew = roleIds.split(",");
if (splitOld.length==splitNew.length&&splitNew.length<3){ if (splitOld.length == splitNew.length && splitNew.length < 3) {
for (int i = 0;i<splitNew.length;i++){ for (int i = 0; i < splitNew.length; i++) {
boolean a = systemSetttingDao.updateStaff(staff.get(i)); boolean a = systemSetttingDao.updateStaff(staff.get(i));
if (!a){throw new RuntimeException();} if (!a) {
throw new RuntimeException();
} }
}else if (splitNew.length>splitOld.length){ }
} else if (splitNew.length > splitOld.length) {
boolean a = systemSetttingDao.updateStaff(staff.get(0)); boolean a = systemSetttingDao.updateStaff(staff.get(0));
StaffEntity staffEntity = staff.get(1); StaffEntity staffEntity = staff.get(1);
staffEntity.setUserId(staffVo.getUserId()); staffEntity.setUserId(staffVo.getUserId());
boolean b = systemSetttingDao.addStaffUpdata(staffEntity); boolean b = systemSetttingDao.addStaffUpdata(staffEntity);
if (!a|!b){throw new RuntimeException();} if (!a | !b) {
}else if (splitNew.length<splitOld.length){ throw new RuntimeException();
}
} else if (splitNew.length < splitOld.length) {
boolean a = systemSetttingDao.deleteStaffOnly(staffVo.getUserId());//删除roleId最大的数据 boolean a = systemSetttingDao.deleteStaffOnly(staffVo.getUserId());//删除roleId最大的数据
staffVo.setStaffRoleId(Integer.parseInt(staffVo.getRoleId())); staffVo.setStaffRoleId(Integer.parseInt(staffVo.getRoleId()));
boolean b = systemSetttingDao.updateStaffOnly(staffVo);//修改仅剩的数据 boolean b = systemSetttingDao.updateStaffOnly(staffVo);//修改仅剩的数据
}else{ } else {
return R.error(400,"不存在此账号"); return R.error(400, "不存在此账号");
} }
userInfoDao.setNUM(staffVo.getUserId());//重置账号、手机号码为00 userInfoDao.setNUM(staffVo.getUserId());//重置账号、手机号码为00
// systemSetttingDao.deleteStaffInfo(staffVo.getUserId());// // systemSetttingDao.deleteStaffInfo(staffVo.getUserId());//
List<StaffVo> resultA = userInfoDao.queryAccount(account); List<StaffVo> resultA = userInfoDao.queryAccount(account);
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber); List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if (phone!=null&&phone!=""){ if (phone != null && phone != "") {
List<Integer> resultP = userInfoDao.queryPhone(phone); List<Integer> resultP = userInfoDao.queryPhone(phone);
if (resultP.size()>0){ if (resultP.size() > 0) {
return R.error(400,"手机号不能重复"); return R.error(400, "手机号不能重复");
} }
} }
if (email!=null&&email!=""){ if (email != null && email != "") {
List<Integer> resultE = userInfoDao.queryEmail(email); List<Integer> resultE = userInfoDao.queryEmail(email);
if (resultE.size()>0){ if (resultE.size() > 0) {
return R.error(400,"手机号不能重复"); return R.error(400, "手机号不能重复");
} }
} }
if(resultA.size()>0){ if (resultA.size() > 0) {
return R.error(400,"账号不能重复"); return R.error(400, "账号不能重复");
}else if (resultW.size()>0){ } else if (resultW.size() > 0) {
return R.error(400,"工号不能重复"); return R.error(400, "工号不能重复");
} }
boolean resultUserInfo = userInfoDao.updateUserInfo(staffVo); boolean resultUserInfo = userInfoDao.updateUserInfo(staffVo);
// String[] split = staffVo.getRoleId().split(","); // String[] split = staffVo.getRoleId().split(",");
@ -206,21 +212,21 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
//查询是否存在相同的部门 //查询是否存在相同的部门
String departmentName = staffVo.getStaffProfessionalArchitectureName(); String departmentName = staffVo.getStaffProfessionalArchitectureName();
String gradeName = staffVo.getStaffGradeName(); String gradeName = staffVo.getStaffGradeName();
if (gradeName!=null|gradeName!=""){ if (gradeName != null | gradeName != "") {
Integer department = systemSetttingDao.queryGrade(staffVo); Integer department = systemSetttingDao.queryGrade(staffVo);
if (department==0){ if (department == 0) {
systemSetttingDao.addDepartment(staffVo); systemSetttingDao.addDepartment(staffVo);
} }
map.put("已存在的部门",departmentName); map.put("已存在的部门", departmentName);
}else{ } else {
Integer department = systemSetttingDao.queryDepartment(staffVo); Integer department = systemSetttingDao.queryDepartment(staffVo);
if (department==0){ if (department == 0) {
boolean result = systemSetttingDao.addStaffGrade(staffVo); boolean result = systemSetttingDao.addStaffGrade(staffVo);
if (!result){ if (!result) {
throw new RuntimeException(); throw new RuntimeException();
} }
} }
map.put("已存在的部门",gradeName); map.put("已存在的部门", gradeName);
} }
return map; return map;
} }
@ -231,11 +237,17 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
return result; return result;
} }
@Override @Override
@Transactional @Transactional
public Map<String, String> upload(MultipartFile file) throws IOException { public Map<String, String> upload(MultipartFile file) throws IOException {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
List<StaffVo> staffs = ExcelImportHelper.readStaff(file); List<StaffVo> staffs = ExcelImportHelper.readStaff(file);
if (staffs.size() <= 0) {
ExceptionCast.cast(CommonCode.EXCEL_FILE_FORMAT_ERROR_STAFFS);
}
List<StaffExportVo> failVo1 = new ArrayList<>(); List<StaffExportVo> failVo1 = new ArrayList<>();
// 参数合法性校验,只能上传.xlsx后缀的文件 // 参数合法性校验,只能上传.xlsx后缀的文件
if (StringUtils.isBlank(file.getOriginalFilename()) if (StringUtils.isBlank(file.getOriginalFilename())
@ -245,24 +257,235 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
int size = staffs.size(); int size = staffs.size();
Long ii = 1L; Long ii = 1L;
try { try {
for (int i = 0;i<staffs.size();i++){ for (int i = 0; i < staffs.size(); i++) {
++ii; ++ii;
StaffVo staffVo = staffs.get(i); StaffVo staffVo = staffs.get(i);
String phone = staffVo.getPhone(); String phone = staffVo.getPhone();
String email = staffVo.getEmail(); String email = staffVo.getEmail();
String workNumber = staffVo.getWorkNumber();
//校验员工姓名
if (staffVo.getUserName().equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName() + " *必填项:(员工姓名不能为空) ")
.setAccount(staffVo.getAccount())
.setRole(staffVo.getRole())
.setWorkNumber(staffVo.getWorkNumber())
.setStaffGradeName(staffVo.getStaffGradeName())
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName())
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo())
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo())
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
}
//用户账号
String account = staffVo.getAccount(); String account = staffVo.getAccount();
String gradeName = staffVo.getStaffGradeName(); //校验账号
if (account.equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName())
.setAccount(staffVo.getAccount() + " *必填项:(员工账号不能为空) ")
.setRole(staffVo.getRole())
.setWorkNumber(staffVo.getWorkNumber())
.setStaffGradeName(staffVo.getStaffGradeName())
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName())
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo())
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo())
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
}
//校验角色
String role = staffVo.getRole();
if (role.equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName())
.setAccount(staffVo.getAccount())
.setRole(staffVo.getRole() + " *必填项:(角色不能为空) ")
.setWorkNumber(staffVo.getWorkNumber())
.setStaffGradeName(staffVo.getStaffGradeName())
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName())
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo())
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo())
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
}
//校验工号
String workNumber = staffVo.getWorkNumber();//员工工号
if (workNumber.equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName())
.setAccount(staffVo.getAccount())
.setRole(staffVo.getRole())
.setWorkNumber(staffVo.getWorkNumber() + " *必填项:(员工工号不能为空) ")
.setStaffGradeName(staffVo.getStaffGradeName())
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName())
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo())
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo())
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
}
//绑定专业名称(*管理员的一级部门)
String architectureName = staffVo.getStaffProfessionalArchitectureName(); String architectureName = staffVo.getStaffProfessionalArchitectureName();
String gradeNameTwo = staffVo.getStaffGradeNameTwo(); //绑定年级名称(*管理员的二级部门)
String gradeName = staffVo.getStaffGradeName();
//老师组织架构名称(*老师的一级部门)
String architectureNameTwo = staffVo.getStaffProfessionalArchitectureNameTwo(); String architectureNameTwo = staffVo.getStaffProfessionalArchitectureNameTwo();
//老师专业组织名称(*老师的二级部门)
String gradeNameTwo = staffVo.getStaffGradeNameTwo();
if (role != null) {
//根据角色校验用户导入的数据
switch (role.trim()) {
case "老师":
if (architectureNameTwo.trim().equals("") || gradeNameTwo.trim().equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName())
.setAccount(staffVo.getAccount())
.setRole(staffVo.getRole())
.setWorkNumber(staffVo.getWorkNumber())
.setStaffGradeName(staffVo.getStaffGradeName() + "")
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName())
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo() + " *必填项:(老师的二级部门不能为空) ")
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo() + " *必填项:(老师的一级部门不能为空) ")
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
}
break;
case "管理员+老师":
if (architectureName.trim().equals("") || gradeName.trim().equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName())
.setAccount(staffVo.getAccount())
.setRole(staffVo.getRole())
.setWorkNumber(staffVo.getWorkNumber())
.setStaffGradeName(staffVo.getStaffGradeName() + " *必填项:(管理员的二级部门不能为空) ")
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName() + " *必填项:(管理员的一级部门不能为空) ")
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo())
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo())
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
} else if (architectureNameTwo.trim().equals("") || gradeNameTwo.trim().equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName())
.setAccount(staffVo.getAccount())
.setRole(staffVo.getRole())
.setWorkNumber(staffVo.getWorkNumber())
.setStaffGradeName(staffVo.getStaffGradeName() + "")
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName())
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo() + " *必填项:(老师的二级部门不能为空) ")
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo() + " *必填项:(老师的一级部门不能为空) ")
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
} else if ((architectureNameTwo.trim().equals("") || gradeNameTwo.trim().equals(""))
&&
architectureName.trim().equals("") || gradeName.trim().equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName())
.setAccount(staffVo.getAccount())
.setRole(staffVo.getRole())
.setWorkNumber(staffVo.getWorkNumber())
.setStaffGradeName(staffVo.getStaffGradeName() + " *必填项:(管理员的二级部门不能为空) ")
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName() + " *必填项:(管理员的一级部门不能为空) ")
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo() + " *必填项:(老师的二级部门不能为空) ")
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo() + " *必填项:(老师的一级部门不能为空) ")
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
}
break;
case "管理员":
//architectureName gradeName
if (architectureName.trim().equals("") || gradeName.trim().equals("")) {
StaffExportVo vo = new StaffExportVo();
vo.setIndex(ii)
.setUserName(staffVo.getUserName())
.setAccount(staffVo.getAccount())
.setRole(staffVo.getRole())
.setWorkNumber(staffVo.getWorkNumber())
.setStaffGradeName(staffVo.getStaffGradeName() + " *必填项:(管理员的二级部门不能为空) ")
.setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName() + " *必填项:(管理员的一级部门不能为空) ")
.setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo())
.setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo())
.setPhone(staffVo.getPhone())
.setEmail(staffVo.getEmail())
.setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i);
i--;
failVo1.add(vo);
continue;
}
break;
}
}
StaffVo staff = new StaffVo(); StaffVo staff = new StaffVo();
staff.setSchoolId(ConstantUtils.Keda_schoolId);//设定科大学校id staff.setSchoolId(ConstantUtils.Keda_schoolId);//设定科大学校id
String schoolAppellationName = staffVo.getSchoolAppellationName(); //String schoolAppellationName = staffVo.getSchoolAppellationName();
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber); List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
List<StaffVo> resultA = userInfoDao.queryAccount(account); List<StaffVo> resultA = userInfoDao.queryAccount(account);
List<StaffVo> resultU = userInfoDao.queryUserInfo(staffVo); List<StaffVo> resultU = userInfoDao.queryUserInfo(staffVo);
if (resultU.size()>0){//重复的数据 if (resultU.size() > 0) {//重复的数据
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("用户信息已存在"); vo.setFailureMsg("用户信息已存在");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -270,7 +493,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
i--; i--;
failVo1.add(vo); failVo1.add(vo);
continue; continue;
}else if (resultW.size()>0){ } else if (resultW.size() > 0) {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的工号"); vo.setFailureMsg("重复的工号");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -278,7 +501,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
i--; i--;
failVo1.add(vo); failVo1.add(vo);
continue; continue;
}else if (resultA.size()>0){ } else if (resultA.size() > 0) {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的账号"); vo.setFailureMsg("重复的账号");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -286,9 +509,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
i--; i--;
failVo1.add(vo); failVo1.add(vo);
continue; continue;
}else if (phone!=null&&phone!=""){ } else if (phone != null && phone != "") {
List<Integer> resultP = userInfoDao.queryPhone(phone); List<Integer> resultP = userInfoDao.queryPhone(phone);
if (resultP.size()>0){ if (resultP.size() > 0) {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的手机号码"); vo.setFailureMsg("重复的手机号码");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -297,9 +520,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
failVo1.add(vo); failVo1.add(vo);
continue; continue;
} }
}else if (email!=null&&email!=""){ } else if (email != null && email != "") {
List<Integer> resultE = userInfoDao.queryEmail(email); List<Integer> resultE = userInfoDao.queryEmail(email);
if (resultE.size()>0){ if (resultE.size() > 0) {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的邮箱号"); vo.setFailureMsg("重复的邮箱号");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -310,18 +533,18 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
} }
} }
if (!staffs.isEmpty()&&staffs.size()>0){ if (!staffs.isEmpty() && staffs.size() > 0) {
staffVo.setPassword(ConstantUtils.INITIAL_PASSWORD).setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis())); staffVo.setPassword(ConstantUtils.INITIAL_PASSWORD).setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis()));
staff.setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId()); staff.setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId());
staffVo.setPlatformId(ConstantUtils.PLATFORMID).setToken(new ConstantUtils().token); staffVo.setPlatformId(ConstantUtils.PLATFORMID).setToken(new ConstantUtils().token);
String[] split = staffVo.getRoleId().split(","); String[] split = staffVo.getRoleId().split(",");
String s = ""; String s = "";
for (String str : split) { for (String str : split) {
s=s+str; s = s + str;
} }
if (s.indexOf("13")!=-1){//2 if (s.indexOf("13") != -1) {//2
if (architectureName!=null&&architectureName!=""){ if (architectureName != null && architectureName != "") {
if (gradeName==null|gradeName==""){ if (gradeName == null | gradeName == "") {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("二级部门不能为空(管理员)"); vo.setFailureMsg("二级部门不能为空(管理员)");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -329,9 +552,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
i--; i--;
failVo1.add(vo); failVo1.add(vo);
continue; continue;
}else{ } else {
Integer b = systemSetttingDao.queryDepartmentNameOrganization(architectureName, ConstantUtils.Keda_schoolId); Integer b = systemSetttingDao.queryDepartmentNameOrganization(architectureName, ConstantUtils.Keda_schoolId);
if (b==null){ if (b == null) {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("不存在的一级部门(管理员)"); vo.setFailureMsg("不存在的一级部门(管理员)");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -340,8 +563,8 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
failVo1.add(vo); failVo1.add(vo);
continue; continue;
} }
List<StaffVo> a = systemSetttingDao.judgmentGrade(architectureName,ConstantUtils.Keda_schoolId); List<StaffVo> a = systemSetttingDao.judgmentGrade(architectureName, ConstantUtils.Keda_schoolId);
if (a.size()==0){ if (a.size() == 0) {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("不存在此子级部门(管理员)"); vo.setFailureMsg("不存在此子级部门(管理员)");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -353,9 +576,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
} }
} }
} }
if (s.indexOf("14")!=-1){//3 if (s.indexOf("14") != -1) {//3
if (architectureNameTwo!=null&&architectureNameTwo!=""){ if (architectureNameTwo != null && architectureNameTwo != "") {
if (gradeNameTwo==null|gradeNameTwo==""){ if (gradeNameTwo == null | gradeNameTwo == "") {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("二级部门不能为空(老师)"); vo.setFailureMsg("二级部门不能为空(老师)");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -363,9 +586,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
i--; i--;
failVo1.add(vo); failVo1.add(vo);
continue; continue;
}else{ } else {
Integer b = systemSetttingDao.queryDepartmentNameOrganization(architectureNameTwo, ConstantUtils.Keda_schoolId); Integer b = systemSetttingDao.queryDepartmentNameOrganization(architectureNameTwo, ConstantUtils.Keda_schoolId);
if (b==null){ if (b == null) {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("不存在此的一级部门(老师)"); vo.setFailureMsg("不存在此的一级部门(老师)");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -374,8 +597,8 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
failVo1.add(vo); failVo1.add(vo);
continue; continue;
} }
List<StaffVo> a = systemSetttingDao.judgmentGrade(architectureNameTwo,ConstantUtils.Keda_schoolId); List<StaffVo> a = systemSetttingDao.judgmentGrade(architectureNameTwo, ConstantUtils.Keda_schoolId);
if (a.size()==0){ if (a.size() == 0) {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("不存在的子级部门(老师)"); vo.setFailureMsg("不存在的子级部门(老师)");
vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
@ -389,25 +612,29 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
} }
userInfoDao.addUserinfo(staffVo); userInfoDao.addUserinfo(staffVo);
for (String str : split){ for (String str : split) {
if (Integer.parseInt(str)==13){//2 if (Integer.parseInt(str) == 13) {//2
Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureName(),ConstantUtils.Keda_schoolId); Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureName(), ConstantUtils.Keda_schoolId);
Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeName(),organizationId); Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeName(), organizationId);
staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(organizationId); staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(organizationId);
boolean b = systemSetttingDao.addStaffManager(staffVo); boolean b = systemSetttingDao.addStaffManager(staffVo);
if(!b){throw new RuntimeException();} if (!b) {
}else if (Integer.parseInt(str)==14){//3 throw new RuntimeException();
Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureNameTwo(),ConstantUtils.Keda_schoolId); }
Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeNameTwo(),organizationId); } else if (Integer.parseInt(str) == 14) {//3
Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureNameTwo(), ConstantUtils.Keda_schoolId);
Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeNameTwo(), organizationId);
staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(organizationId); staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(organizationId);
boolean b = systemSetttingDao.addStaffTeacher(staffVo); boolean b = systemSetttingDao.addStaffTeacher(staffVo);
if(!b){throw new RuntimeException();} if (!b) {
throw new RuntimeException();
}
} }
} }
} }
} }
}catch (RuntimeException e){ } catch (RuntimeException e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(); throw new RuntimeException();
} }
@ -424,14 +651,14 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
ops.set(token, failureVOJson, 30 * 60, TimeUnit.SECONDS); ops.set(token, failureVOJson, 30 * 60, TimeUnit.SECONDS);
} }
map.put("token", token); map.put("token", token);
map.put("successNum", (size-failVo1.size())+""); map.put("successNum", (size - failVo1.size()) + "");
map.put("failureNum", failVo1.size()+""); map.put("failureNum", failVo1.size() + "");
return map; return map;
} }
@Override @Override
public void exportFailureRecord(HttpServletResponse response, String token) throws Exception{ public void exportFailureRecord(HttpServletResponse response, String token) throws Exception {
if (StringUtils.isEmpty(token)) { if (StringUtils.isEmpty(token)) {
return; return;
} }
@ -454,14 +681,11 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
new ExcelExportUtil(StaffExportVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). new ExcelExportUtil(StaffExportVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX).
export(response, inputStream, parse, "导入失败数据表.xlsx"); export(response, inputStream, parse, "导入失败数据表.xlsx");
if (inputStream!=null){ if (inputStream != null) {
inputStream.close(); inputStream.close();
} }
// //2.加载模板流数据 // //2.加载模板流数据
// org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/staff/测试.xlsx"); // org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/staff/测试.xlsx");
//// org.springframework.core.io.Resource resource = new FileSystemResource("E:/JavaworkSpace2/msdw_tms/src/main/resources/excel-template/员工信息导入失败模板.xlsx"); //// org.springframework.core.io.Resource resource = new FileSystemResource("E:/JavaworkSpace2/msdw_tms/src/main/resources/excel-template/员工信息导入失败模板.xlsx");
@ -482,18 +706,19 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
} }
@Override @Override
public R queryAccount(String account,Integer schoolId) { public R queryAccount(String account, Integer schoolId) {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
List<StaffVo> result = systemSetttingDao.queryAccount(account,schoolId); List<StaffVo> result = systemSetttingDao.queryAccount(account, schoolId);
List<StaffVo> vos = userInfoDao.queryAccount(account); List<StaffVo> vos = userInfoDao.queryAccount(account);
if (result.size()>1){return R.error("系统存在多个相同的账号:"+account); if (result.size() > 1) {
}else if (result.size()==1){ return R.error("系统存在多个相同的账号:" + account);
} else if (result.size() == 1) {
StaffVo staffVo = result.get(0); StaffVo staffVo = result.get(0);
map.put("user",staffVo); map.put("user", staffVo);
List<StaffVo> staffVos = systemSetttingDao.queryStaffInfo(staffVo.getUserId()); List<StaffVo> staffVos = systemSetttingDao.queryStaffInfo(staffVo.getUserId());
map.put("staff",staffVos); map.put("staff", staffVos);
return R.ok().put("data",map); return R.ok().put("data", map);
}else if (vos.size()>0){ } else if (vos.size() > 0) {
return R.error("账号已存在"); return R.error("账号已存在");
} }
return R.ok(); return R.ok();
@ -501,14 +726,14 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
@Override @Override
@Transactional @Transactional
public R resetPwd(Integer userId,String newPwd) { public R resetPwd(Integer userId, String newPwd) {
UserInfoEntity user = new UserInfoEntity(); UserInfoEntity user = new UserInfoEntity();
user.setPassword(newPwd); user.setPassword(newPwd);
int count = userInfoDao.update(user, new QueryWrapper<UserInfoEntity>().eq("userId", userId)); int count = userInfoDao.update(user, new QueryWrapper<UserInfoEntity>().eq("userId", userId));
if(count > 0){ if (count > 0) {
return R.ok(); return R.ok();
}else{ } else {
return R.error(20002,"重置失败"); return R.error(20002, "重置失败");
} }
} }

@ -146,7 +146,7 @@
values values
(#{userName}, #{uniqueIdentificationAccount}, (#{userName}, #{uniqueIdentificationAccount},
#{phone}, #{account},#{password},#{roleId}, #{phone}, #{account},#{password},#{roleId},
(SELECT schoolId FROM school WHERE schoolName = #{schoolAppellationName}),now(),#{token}) #{schoolId},now(),#{token})
</insert> </insert>
<insert id="addUserinfo" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId"> <insert id="addUserinfo" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId">
INSERT INTO hr_user_info ( account, userName, roleId, phone, email, uniqueIdentificationAccount, schoolId,creationTime,password,token) INSERT INTO hr_user_info ( account, userName, roleId, phone, email, uniqueIdentificationAccount, schoolId,creationTime,password,token)

Loading…
Cancel
Save