From 3d38d6559ab7714502dd1d3bc829113c6d6a0a0d Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Fri, 26 Mar 2021 17:18:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E3=80=81=E5=91=98=E5=B7=A5?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/msdw/tms/TmsApplication.java | 2 +- .../tms/common/utils/ExcelImportHelper.java | 213 ++++++--- .../msdw/tms/entity/response/CommonCode.java | 8 +- .../tms/entity/vo/StudentImportFailureVo.java | 14 +- .../tms/service/impl/StudentServiceImpl.java | 187 +++++--- .../impl/SystemSettingServiceImpl.java | 419 ++++++++++++++---- ...生导入失败数据导出模板(1).xlsx | Bin 0 -> 9279 bytes src/main/resources/mapper/tms/UserInfoDao.xml | 2 +- 8 files changed, 618 insertions(+), 227 deletions(-) create mode 100644 src/main/resources/excel-template/学生导入失败数据导出模板(1).xlsx diff --git a/src/main/java/com/msdw/tms/TmsApplication.java b/src/main/java/com/msdw/tms/TmsApplication.java index e2715d0..1e5e101 100644 --- a/src/main/java/com/msdw/tms/TmsApplication.java +++ b/src/main/java/com/msdw/tms/TmsApplication.java @@ -6,7 +6,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.scheduling.annotation.EnableScheduling; -@EnableScheduling//定时任务 +//@EnableScheduling//定时任务 @SpringBootApplication public class TmsApplication extends SpringBootServletInitializer { diff --git a/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java b/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java index 83a3ff9..5de5e0a 100644 --- a/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java +++ b/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java @@ -1,7 +1,12 @@ 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.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.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -13,15 +18,62 @@ import java.util.List; 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 * @return */ - public static List readStudent(MultipartFile file) { + public static List readStudent(MultipartFile file) throws IOException { List list = new ArrayList(); - Workbook workbook=getWorkbook(file); + Workbook workbook = getWorkbook(file); StudentVo student = null; // 循环工作表Sheet for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) { @@ -29,38 +81,57 @@ public class ExcelImportHelper { if (hssfSheet == null) { continue; } + + int count = 1; // 循环行Row//开始行2 for (int rowNum = 2; rowNum <= hssfSheet.getLastRowNum(); 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 email; if (row != null) { student = new StudentVo(); + row.getCell(0).setCellType(CellType.STRING); Cell studentName = row.getCell(0); + + row.getCell(1).setCellType(CellType.STRING); - Cell schoolAppellationName = row.getCell(1); + Cell account = row.getCell(1); row.getCell(2).setCellType(CellType.STRING); - Cell account = row.getCell(2); - row.getCell(3).setCellType(CellType.STRING); - Cell studentNumber = row.getCell(3); - if (row.getCell(4)!=null){ - row.getCell(4).setCellType(CellType.STRING); - phone = row.getCell(4); - }else { - phone = row.createCell(4); + + Cell studentNumber = row.getCell(2); + if (row.getCell(3) != null) { + row.getCell(3).setCellType(CellType.STRING); + phone = row.getCell(3); + } else { + phone = row.createCell(3); } - if (row.getCell(5)!=null){ - row.getCell(5).setCellType(CellType.STRING); - email = row.getCell(5); - }else { - email = row.createCell(5); + + if (row.getCell(4) != null) { + row.getCell(4).setCellType(CellType.STRING); + email = row.getCell(4); + } 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.setWorkNumber(studentNumber.getStringCellValue()); - //所属院校 - student.setSchoolAppellationName(schoolAppellationName.getStringCellValue()); //用户账号 student.setAccount(account.getStringCellValue()); //电话 @@ -87,15 +156,18 @@ public class ExcelImportHelper { return list; } + + /** * 读取员工管理 + * * @param file * @return */ - public static List readStaff(MultipartFile file) { + public static List readStaff(MultipartFile file) throws IOException { List list = new ArrayList(); - Workbook workbook=getWorkbook(file); + Workbook workbook = getWorkbook(file); StaffVo staff = null; // 循环工作表Sheet for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) { @@ -103,97 +175,110 @@ public class ExcelImportHelper { if (hssfSheet == null) { continue; } - int lastRowNum = hssfSheet.getLastRowNum()+1;//最后一行行标,比行数小1 - if (lastRowNum==2){ + /*int lastRowNum = hssfSheet.getLastRowNum() + 1;//最后一行行标,比行数小1 + if (lastRowNum == 2) { break; - } + }*/ + int count = 1; // 循环行Row//开始行2 for (int rowNum = 2; rowNum <= hssfSheet.getLastRowNum(); 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 email; Cell staffGradeName; Cell staffProfessionalArchitectureName; Cell staffGradeNameTwo; Cell staffProfessionalArchitectureNameTwo; - if (row != null) { + /*Cell account; + Cell role; + Cell workNumber;*/ + Cell userName; + + + if (row == null) { + continue; + } else { staff = new StaffVo(); - if (row.getCell(0)!=null){ + if (row.getCell(0) != null) { row.getCell(0).setCellType(CellType.STRING); userName = row.getCell(0); - }else { - continue; + } else { + userName = row.createCell(0); } + //姓名 + /* row.getCell(0).setCellType(CellType.STRING); + String userName = row.getCell(0).getStringCellValue();*/ + //账号 row.getCell(1).setCellType(CellType.STRING); Cell account = row.getCell(1); + //角色 row.getCell(2).setCellType(CellType.STRING); Cell role = row.getCell(2); + //工号 row.getCell(3).setCellType(CellType.STRING); 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); staffProfessionalArchitectureName = row.getCell(4); - }else { + } else { staffProfessionalArchitectureName = row.createCell(4); } - if (row.getCell(5)!=null){ + if (row.getCell(5) != null) { row.getCell(5).setCellType(CellType.STRING); staffGradeName = row.getCell(5); - }else { + } else { staffGradeName = row.createCell(5); } - if (row.getCell(6)!=null){ + if (row.getCell(6) != null) { row.getCell(6).setCellType(CellType.STRING); staffProfessionalArchitectureNameTwo = row.getCell(6); - }else { + } else { staffProfessionalArchitectureNameTwo = row.createCell(6); } - if (row.getCell(7)!=null){ + if (row.getCell(7) != null) { row.getCell(7).setCellType(CellType.STRING); staffGradeNameTwo = row.getCell(7); - }else { + } else { staffGradeNameTwo = row.createCell(7); } - - -// 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){ + if (row.getCell(8) != null) { row.getCell(8).setCellType(CellType.STRING); phone = row.getCell(8); - }else { + } else { phone = row.createCell(8); } - if (row.getCell(9)!=null){ + if (row.getCell(9) != null) { row.getCell(9).setCellType(CellType.STRING); email = row.getCell(9); - }else { + } else { 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 str; // 角色id - if (roleValue.equals("管理员")){ + if (roleValue.equals("管理员")) { str = "13";//2 - }else if (roleValue.equals("老师")){ + } else if (roleValue.equals("老师")) { str = "14";//3 - }else{ + } else { str = "13,14"; } staff.setRoleId(str); @@ -218,7 +303,7 @@ public class ExcelImportHelper { //邮箱 staff.setEmail(email.getStringCellValue()); //所属院校 - staff.setSchoolAppellationName(schoolAppellationName.getStringCellValue()); + //staff.setSchoolAppellationName(schoolAppellationName.getStringCellValue()); //学校id staff.setSchoolId(ConstantUtils.Keda_schoolId); list.add(staff); @@ -229,7 +314,7 @@ public class ExcelImportHelper { return list; } - private static Workbook getWorkbook(MultipartFile file) { + private static Workbook getWorkbook(MultipartFile file) { String fileName = file.getOriginalFilename(); Workbook workbook = null; @@ -239,7 +324,7 @@ public class ExcelImportHelper { } catch (IOException e) { e.printStackTrace(); } - }else if (fileName.endsWith("xls")) { + } else if (fileName.endsWith("xls")) { try { workbook = new HSSFWorkbook(file.getInputStream()); } catch (IOException e) { diff --git a/src/main/java/com/msdw/tms/entity/response/CommonCode.java b/src/main/java/com/msdw/tms/entity/response/CommonCode.java index c8aa3ce..74889ed 100644 --- a/src/main/java/com/msdw/tms/entity/response/CommonCode.java +++ b/src/main/java/com/msdw/tms/entity/response/CommonCode.java @@ -17,10 +17,14 @@ public enum CommonCode implements ResultCode { EXCEL_FILE_INVALID(false, 10009, "上传excel文件错误!"), REPEAT_INEXCEL(false, 10010, "试题在excel表中重复!"), 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, "操作失败!"), - ROLE_NAME_EXIST(false,20001,"该角色名称已存在,请重新输入!"), - ROLE_EMP_EXIST(false,44001,"该角色有用户关联,不能删除!"), + + ROLE_NAME_EXIST(false, 20001, "该角色名称已存在,请重新输入!"), + ROLE_EMP_EXIST(false, 44001, "该角色有用户关联,不能删除!"), SERVER_ERROR(false, 99999, "抱歉,系统繁忙,请稍后重试!"); //操作是否成功 boolean success; diff --git a/src/main/java/com/msdw/tms/entity/vo/StudentImportFailureVo.java b/src/main/java/com/msdw/tms/entity/vo/StudentImportFailureVo.java index 9c4429c..ae10562 100644 --- a/src/main/java/com/msdw/tms/entity/vo/StudentImportFailureVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/StudentImportFailureVo.java @@ -15,23 +15,23 @@ public class StudentImportFailureVo { //用户姓名 @ExcelAttribute(sort = 0) private String userName; - //所属院校 + /*//所属院校 @ExcelAttribute(sort = 1) - private String schoolAppellationName; + private String schoolAppellationName;*/ //账号 - @ExcelAttribute(sort = 2) + @ExcelAttribute(sort = 1) private String account; //学号 - @ExcelAttribute(sort = 3) + @ExcelAttribute(sort = 2) private String workNumber; //手机号码 - @ExcelAttribute(sort = 4) + @ExcelAttribute(sort = 3) private String phone; //邮箱 - @ExcelAttribute(sort = 5) + @ExcelAttribute(sort = 4) private String email; //失败原因 - @ExcelAttribute(sort = 6) + @ExcelAttribute(sort = 5) private String failureMsg; // // @ExcelAttribute(sort = 7) diff --git a/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java index e3a099d..13f85c5 100644 --- a/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java @@ -39,7 +39,7 @@ import java.util.*; import java.util.concurrent.TimeUnit; @Service("studentService") -public class StudentServiceImpl extends ServiceImpl implements StudentService { +public class StudentServiceImpl extends ServiceImpl implements StudentService { @Autowired private StudentDao studentDao; @@ -57,11 +57,11 @@ public class StudentServiceImpl extends ServiceImpl im StringRedisTemplate stringRedisTemplate; @Override - public Integer queryStudentIdNumber(String workNumber,Integer schoolId) { - List result = studentDao.queryStudentIdNumber(workNumber,schoolId); - if (result.size()==1){ + public Integer queryStudentIdNumber(String workNumber, Integer schoolId) { + List result = studentDao.queryStudentIdNumber(workNumber, schoolId); + if (result.size() == 1) { return 1; - }else{ + } else { return 0; } } @@ -75,9 +75,9 @@ public class StudentServiceImpl extends ServiceImpl im } @Override - public PageUtils queryStudent(Integer schoolId,String searchContent, Integer page, Integer size) { - Page tPage = new Page<>(page,size); - IPage saveStudent = studentDao.queryStudent(tPage,searchContent,schoolId); + public PageUtils queryStudent(Integer schoolId, String searchContent, Integer page, Integer size) { + Page tPage = new Page<>(page, size); + IPage saveStudent = studentDao.queryStudent(tPage, searchContent, schoolId); PageUtils pageUtils = new PageUtils(saveStudent); return pageUtils; } @@ -85,10 +85,10 @@ public class StudentServiceImpl extends ServiceImpl im @Override public R queryStudentDetails(Integer userId) { StudentVo saveStudent = studentDao.queryStudentDetails(userId); - if (saveStudent!=null){ - return R.ok().put("data",saveStudent); - }else { - return R.error(300,"用户不存在!"); + if (saveStudent != null) { + return R.ok().put("data", saveStudent); + } else { + return R.error(300, "用户不存在!"); } } @@ -99,7 +99,7 @@ public class StudentServiceImpl extends ServiceImpl im try { Integer delete = studentDao.deleteStudent(studentId); return true; - }catch (RuntimeException e){ + } catch (RuntimeException e) { e.printStackTrace(); return false; } @@ -110,7 +110,7 @@ public class StudentServiceImpl extends ServiceImpl im try { Integer update = studentDao.updateStudent(studentVo); return true; - }catch (RuntimeException e){ + } catch (RuntimeException e) { e.printStackTrace(); return false; } @@ -118,16 +118,16 @@ public class StudentServiceImpl extends ServiceImpl im @Override public void updateWorkNumber(Integer studentId) { - studentDao.updateWorkNumber("00",studentId);//将学号重置为00 + studentDao.updateWorkNumber("00", studentId);//将学号重置为00 } @Override public R addStudentInfo(StudentVo studentVo) { R r = new R(); boolean result = studentDao.addStudentInfo(studentVo); - if (result==false){ - throw new RuntimeException();//添加失败,抛出运行时异常让外层事务回滚 - }else{ + if (result == false) { + throw new RuntimeException();//添加失败,抛出运行时异常让外层事务回滚 + } else { return R.ok("注册成功!"); } @@ -141,8 +141,15 @@ public class StudentServiceImpl extends ServiceImpl im @Transactional @Override - public Map upload(MultipartFile file, Integer schoolId) throws IOException{ + public Map upload(MultipartFile file, Integer schoolId) throws IOException { + List students = ExcelImportHelper.readStudent(file); + if (students.size() <= 0) { + ExceptionCast.cast(CommonCode.EXCEL_FILE_FORMAT_ERROR); + } + + Map errorMap = new HashMap<>(); + List failVo1 = new ArrayList<>(); // 参数合法性校验,只能上传.xlsx后缀的文件 if (StringUtils.isBlank(file.getOriginalFilename()) @@ -153,24 +160,83 @@ public class StudentServiceImpl extends ServiceImpl im Map map = new HashMap<>(); Long ii = 1L;//用于记录序列号 try { - for (int i = 0;i result1 = studentDao.queryStudentIdNumber(workNumber,schoolId); + //String schoolAppellationName = student.getSchoolAppellationName(); + List result1 = studentDao.queryStudentIdNumber(workNumber, schoolId); List result4 = userInfoDao.queryStudentAccount(account); String email = student.getEmail(); - if (phone!=null&&phone!=""){ + if (phone != null && phone != "") { List result2 = userInfoDao.queryStudentPhone(phone); - if (result2.size()>=1){ + if (result2.size() >= 1) { log.error("该号码已被使用"); StudentImportFailureVo vo = new StudentImportFailureVo(); ++ii; - vo.setIndex(ii).setUserName(student.getUserName()).setSchoolAppellationName(student.getSchoolAppellationName()) - .setAccount(student.getAccount()).setWorkNumber(student.getWorkNumber()).setPhone(student.getPhone()+" (重复的号码)").setEmail(student.getEmail()) + vo.setIndex(ii) + .setUserName(student.getUserName()) + .setAccount(student.getAccount()) + .setWorkNumber(student.getWorkNumber()) + .setPhone(student.getPhone() + " (重复的号码)") + .setEmail(student.getEmail()) ; failVo1.add(vo); students.remove(i); @@ -179,24 +245,29 @@ public class StudentServiceImpl extends ServiceImpl im } studentVo.setPhone(phone); } - if (email!=null&&email!=""){ + if (email != null && email != "") { studentVo.setEmail(email); } - List result3 = studentDao.querySchoolName(schoolAppellationName); + // List result3 = studentDao.querySchoolName(schoolAppellationName); // 唯一标示性账号 studentVo.setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis())). setPassword(ConstantUtils.INITIAL_PASSWORD).setToken(new ConstantUtils().token) .setSchoolId(ConstantUtils.Keda_schoolId).setRoleId(ConstantUtils.STUDENT_ROLE) ; - studentVo.setAccount(student.getAccount()).setSchoolAppellationName(schoolAppellationName) - .setUserName(student.getUserName()).setIsdel(Constant.IsDel.NOT_DEL.getType()); + studentVo.setAccount(student.getAccount()) + .setUserName(student.getUserName()) + .setIsdel(Constant.IsDel.NOT_DEL.getType()); + - if (result1.size()>=1){ + if (result1.size() >= 1) { log.error("该学号已存在"); StudentImportFailureVo vo = new StudentImportFailureVo(); ++ii; - vo.setIndex(ii).setUserName(student.getUserName()).setSchoolAppellationName(student.getSchoolAppellationName()) - .setAccount(student.getAccount()).setWorkNumber(student.getWorkNumber()+" (重复的学号)").setPhone(student.getPhone()).setEmail(student.getEmail()) + vo.setIndex(ii) + .setUserName(student.getUserName()) + .setAccount(student.getAccount()) + .setWorkNumber(student.getWorkNumber() + " (重复的学号)") + .setPhone(student.getPhone()).setEmail(student.getEmail()) ; // .setFailureMsg("重复的学号"); failVo1.add(vo); @@ -204,12 +275,16 @@ public class StudentServiceImpl extends ServiceImpl im students.remove(i); i--; continue; - }else if(result4.size()>=1){ + } else if (result4.size() >= 1) { log.error("账号已存在"); StudentImportFailureVo vo = new StudentImportFailureVo(); ++ii; - vo.setIndex(ii).setUserName(student.getUserName()).setSchoolAppellationName(student.getSchoolAppellationName()) - .setAccount(student.getAccount()+" (重复的账号)").setWorkNumber(student.getWorkNumber()).setPhone(student.getPhone()).setEmail(student.getEmail()) + vo.setIndex(ii) + .setUserName(student.getUserName()) + .setAccount(student.getAccount() + " (重复的账号)") + .setWorkNumber(student.getWorkNumber()) + .setPhone(student.getPhone()) + .setEmail(student.getEmail()) ; // .setFailureMsg("重复的账号"); failVo1.add(vo); @@ -218,7 +293,7 @@ public class StudentServiceImpl extends ServiceImpl im i--; continue; } - else if(result3.size()!=1){ + /*else if(result3.size()!=1){ log.error("不存在该院校"); StudentImportFailureVo vo = new StudentImportFailureVo(); ++ii; @@ -230,23 +305,24 @@ public class StudentServiceImpl extends ServiceImpl im students.remove(i); i--; continue; - } + }*/ ++ii; - if (!students.isEmpty()&&students.size()>0){ + if (!students.isEmpty() && students.size() > 0) { + studentVo.setSchoolId(schoolId); userInfoDao.batchSaveUserInfo(studentVo); student.setUserId(studentVo.getUserId()).setIsdel(Constant.IsDel.NOT_DEL.getType()).setPlatformId(ConstantUtils.PLATFORMID); boolean b = studentDao.saveStudent(student); - if (!b){ - throw new RuntimeException(); + if (!b) { + throw new RuntimeException(); } } } - }catch (RuntimeException e){ + } catch (RuntimeException e) { log.error(e.getMessage()); - map.put("failura","添加失败"); - throw new RuntimeException(); + map.put("failura", "添加失败"); + throw new RuntimeException(); } String token = ""; @@ -261,14 +337,14 @@ public class StudentServiceImpl extends ServiceImpl im ops.set(token, failureVOJson, 30 * 60, TimeUnit.SECONDS); } map.put("token", token); - map.put("successNum", (size-failVo1.size())+""); - map.put("failureNum", failVo1.size()+""); + map.put("successNum", (size - failVo1.size()) + ""); + map.put("failureNum", failVo1.size() + ""); return map; } @Override - public void exportFailureRecord(HttpServletResponse response,String token) throws Exception{ + public void exportFailureRecord(HttpServletResponse response, String token) throws Exception { if (StringUtils.isEmpty(token)) { return; } @@ -284,23 +360,24 @@ public class StudentServiceImpl extends ServiceImpl im parse.sort(Comparator.comparing(StudentImportFailureVo::getIndex)); //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(); //3、通过工具类下载文件 new ExcelExportUtil(StudentImportFailureVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). - export(response, inputStream, parse, "学生信息导入失败表.xlsx"); + export(response, inputStream, parse, "学生信息导入失败表(1).xlsx"); } @Override - public R queryAccount(String account,Integer schoolId) { - List result = studentDao.queryAccount(account,schoolId); + public R queryAccount(String account, Integer schoolId) { + List result = studentDao.queryAccount(account, schoolId); List vos = userInfoDao.queryAccount(account); - if (result.size()>1){ - return R.error("系统存在多个相同的账号:"+account); - }else if (result.size()==1){return R.ok().put("data",result); - }else if (vos.size()>0){ + if (result.size() > 1) { + return R.error("系统存在多个相同的账号:" + account); + } else if (result.size() == 1) { + return R.ok().put("data", result); + } else if (vos.size() > 0) { return R.error("账号已存在"); } return R.ok(); diff --git a/src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java index e620417..3229994 100644 --- a/src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java @@ -65,33 +65,35 @@ public class SystemSettingServiceImpl implements SystemSetttingService { String email = staffVo.getEmail(); String workNumber = staffVo.getWorkNumber(); List staff = staffVo.getStaff(); - if (phone!=null&&phone!=""){ + if (phone != null && phone != "") { List resultP = userInfoDao.queryPhone(phone); - if (resultP.size()>0){ - return R.error(400,"手机号不能重复"); + if (resultP.size() > 0) { + return R.error(400, "手机号不能重复"); } } - if (email!=null&&email!=""){ + if (email != null && email != "") { List resultE = userInfoDao.queryEmail(email); - if (resultE.size()>0){ - return R.error(400,"手机号不能重复"); + if (resultE.size() > 0) { + return R.error(400, "手机号不能重复"); } } List resultA = userInfoDao.queryAccount(account); // List resultW = systemSetttingDao.queryWorkNumber(workNumber); - if(resultA.size()>0){ - return R.error(400,"账号不能重复"); + if (resultA.size() > 0) { + return R.error(400, "账号不能重复"); } Integer userId = userInfoDao.addUserinfo(staffVo); - for (int i=0;i resultW = systemSetttingDao.queryWorkNumber(workNumber); - if (resultW.size()>0){ - return R.error(400,"工号不能重复"+workNumber); + if (resultW.size() > 0) { + return R.error(400, "工号不能重复" + workNumber); } StaffEntity entity = staff.get(i); entity.setSchoolId(ConstantUtils.Keda_schoolId).setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId()); boolean result = systemSetttingDao.addStaffN(entity); - if (!result) {throw new RuntimeException();} + if (!result) { + throw new RuntimeException(); + } } // String[] split = staffVo.getRoleId().split(","); // for (String s : split){ @@ -107,7 +109,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService { @Override public PageUtils queryStaff(StaffVo staffVo) { Page tPage = new Page<>(staffVo.getPage(), staffVo.getSize()); - IPage staff = systemSetttingDao.queryStaff(tPage, staffVo.getSearchContent(),ConstantUtils.Keda_schoolId,staffVo.getStaffGradeIds(),staffVo.getStaffProfessionalArchitectureIds()); + IPage staff = systemSetttingDao.queryStaff(tPage, staffVo.getSearchContent(), ConstantUtils.Keda_schoolId, staffVo.getStaffGradeIds(), staffVo.getStaffProfessionalArchitectureIds()); PageUtils pageUtils = new PageUtils(staff); return pageUtils; } @@ -120,8 +122,8 @@ public class SystemSettingServiceImpl implements SystemSetttingService { List staff = systemSetttingDao.queryStaffInfo(userId); // result.setWorkNumber(staff.getWorkNumber()).setStaffGradeId(staff.getStaffGradeId()).setStaffGradeName(staff.getStaffGradeName()) // .setStaffProfessionalArchitectureId(staff.getStaffProfessionalArchitectureId()).setStaffProfessionalArchitectureName(staff.getStaffProfessionalArchitectureName()); - map.put("userInfo",result); - map.put("staffInfo",staff); + map.put("userInfo", result); + map.put("staffInfo", staff); return map; } @@ -138,45 +140,49 @@ public class SystemSettingServiceImpl implements SystemSetttingService { String roleIds = result.getRoleId(); String[] splitOld = staffVo.getRoleId().split(","); String[] splitNew = roleIds.split(","); - if (splitOld.length==splitNew.length&&splitNew.length<3){ - for (int i = 0;isplitOld.length){ + } else if (splitNew.length > splitOld.length) { boolean a = systemSetttingDao.updateStaff(staff.get(0)); StaffEntity staffEntity = staff.get(1); staffEntity.setUserId(staffVo.getUserId()); boolean b = systemSetttingDao.addStaffUpdata(staffEntity); - if (!a|!b){throw new RuntimeException();} - }else if (splitNew.length resultA = userInfoDao.queryAccount(account); List resultW = systemSetttingDao.queryWorkNumber(workNumber); - if (phone!=null&&phone!=""){ + if (phone != null && phone != "") { List resultP = userInfoDao.queryPhone(phone); - if (resultP.size()>0){ - return R.error(400,"手机号不能重复"); + if (resultP.size() > 0) { + return R.error(400, "手机号不能重复"); } } - if (email!=null&&email!=""){ + if (email != null && email != "") { List resultE = userInfoDao.queryEmail(email); - if (resultE.size()>0){ - return R.error(400,"手机号不能重复"); + if (resultE.size() > 0) { + return R.error(400, "手机号不能重复"); } } - if(resultA.size()>0){ - return R.error(400,"账号不能重复"); - }else if (resultW.size()>0){ - return R.error(400,"工号不能重复"); + if (resultA.size() > 0) { + return R.error(400, "账号不能重复"); + } else if (resultW.size() > 0) { + return R.error(400, "工号不能重复"); } boolean resultUserInfo = userInfoDao.updateUserInfo(staffVo); // String[] split = staffVo.getRoleId().split(","); @@ -206,21 +212,21 @@ public class SystemSettingServiceImpl implements SystemSetttingService { //查询是否存在相同的部门 String departmentName = staffVo.getStaffProfessionalArchitectureName(); String gradeName = staffVo.getStaffGradeName(); - if (gradeName!=null|gradeName!=""){ + if (gradeName != null | gradeName != "") { Integer department = systemSetttingDao.queryGrade(staffVo); - if (department==0){ + if (department == 0) { systemSetttingDao.addDepartment(staffVo); } - map.put("已存在的部门",departmentName); - }else{ + map.put("已存在的部门", departmentName); + } else { Integer department = systemSetttingDao.queryDepartment(staffVo); - if (department==0){ + if (department == 0) { boolean result = systemSetttingDao.addStaffGrade(staffVo); - if (!result){ + if (!result) { throw new RuntimeException(); } } - map.put("已存在的部门",gradeName); + map.put("已存在的部门", gradeName); } return map; } @@ -231,11 +237,17 @@ public class SystemSettingServiceImpl implements SystemSetttingService { return result; } + @Override @Transactional public Map upload(MultipartFile file) throws IOException { HashMap map = new HashMap<>(); List staffs = ExcelImportHelper.readStaff(file); + + if (staffs.size() <= 0) { + ExceptionCast.cast(CommonCode.EXCEL_FILE_FORMAT_ERROR_STAFFS); + } + List failVo1 = new ArrayList<>(); // 参数合法性校验,只能上传.xlsx后缀的文件 if (StringUtils.isBlank(file.getOriginalFilename()) @@ -245,24 +257,235 @@ public class SystemSettingServiceImpl implements SystemSetttingService { int size = staffs.size(); Long ii = 1L; try { - for (int i = 0;i resultW = systemSetttingDao.queryWorkNumber(workNumber); List resultA = userInfoDao.queryAccount(account); List resultU = userInfoDao.queryUserInfo(staffVo); - if (resultU.size()>0){//重复的数据 + if (resultU.size() > 0) {//重复的数据 StaffExportVo vo = new StaffExportVo(); 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()); @@ -270,7 +493,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService { i--; failVo1.add(vo); continue; - }else if (resultW.size()>0){ + } else if (resultW.size() > 0) { StaffExportVo vo = new StaffExportVo(); 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()); @@ -278,7 +501,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService { i--; failVo1.add(vo); continue; - }else if (resultA.size()>0){ + } else if (resultA.size() > 0) { StaffExportVo vo = new StaffExportVo(); 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()); @@ -286,9 +509,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService { i--; failVo1.add(vo); continue; - }else if (phone!=null&&phone!=""){ + } else if (phone != null && phone != "") { List resultP = userInfoDao.queryPhone(phone); - if (resultP.size()>0){ + if (resultP.size() > 0) { StaffExportVo vo = new StaffExportVo(); 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()); @@ -297,9 +520,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService { failVo1.add(vo); continue; } - }else if (email!=null&&email!=""){ + } else if (email != null && email != "") { List resultE = userInfoDao.queryEmail(email); - if (resultE.size()>0){ + if (resultE.size() > 0) { StaffExportVo vo = new StaffExportVo(); 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()); @@ -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())); staff.setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId()); staffVo.setPlatformId(ConstantUtils.PLATFORMID).setToken(new ConstantUtils().token); String[] split = staffVo.getRoleId().split(","); String s = ""; for (String str : split) { - s=s+str; + s = s + str; } - if (s.indexOf("13")!=-1){//2 - if (architectureName!=null&&architectureName!=""){ - if (gradeName==null|gradeName==""){ + if (s.indexOf("13") != -1) {//2 + if (architectureName != null && architectureName != "") { + if (gradeName == null | gradeName == "") { StaffExportVo vo = new StaffExportVo(); 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()); @@ -329,9 +552,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService { i--; failVo1.add(vo); continue; - }else{ + } else { Integer b = systemSetttingDao.queryDepartmentNameOrganization(architectureName, ConstantUtils.Keda_schoolId); - if (b==null){ + if (b == null) { StaffExportVo vo = new StaffExportVo(); 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()); @@ -340,8 +563,8 @@ public class SystemSettingServiceImpl implements SystemSetttingService { failVo1.add(vo); continue; } - List a = systemSetttingDao.judgmentGrade(architectureName,ConstantUtils.Keda_schoolId); - if (a.size()==0){ + List a = systemSetttingDao.judgmentGrade(architectureName, ConstantUtils.Keda_schoolId); + if (a.size() == 0) { StaffExportVo vo = new StaffExportVo(); 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()); @@ -353,9 +576,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService { } } } - if (s.indexOf("14")!=-1){//3 - if (architectureNameTwo!=null&&architectureNameTwo!=""){ - if (gradeNameTwo==null|gradeNameTwo==""){ + if (s.indexOf("14") != -1) {//3 + if (architectureNameTwo != null && architectureNameTwo != "") { + if (gradeNameTwo == null | gradeNameTwo == "") { StaffExportVo vo = new StaffExportVo(); 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()); @@ -363,9 +586,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService { i--; failVo1.add(vo); continue; - }else{ + } else { Integer b = systemSetttingDao.queryDepartmentNameOrganization(architectureNameTwo, ConstantUtils.Keda_schoolId); - if (b==null){ + if (b == null) { StaffExportVo vo = new StaffExportVo(); 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()); @@ -374,8 +597,8 @@ public class SystemSettingServiceImpl implements SystemSetttingService { failVo1.add(vo); continue; } - List a = systemSetttingDao.judgmentGrade(architectureNameTwo,ConstantUtils.Keda_schoolId); - if (a.size()==0){ + List a = systemSetttingDao.judgmentGrade(architectureNameTwo, ConstantUtils.Keda_schoolId); + if (a.size() == 0) { StaffExportVo vo = new StaffExportVo(); 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()); @@ -389,25 +612,29 @@ public class SystemSettingServiceImpl implements SystemSetttingService { } userInfoDao.addUserinfo(staffVo); - for (String str : split){ - if (Integer.parseInt(str)==13){//2 - Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureName(),ConstantUtils.Keda_schoolId); - Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeName(),organizationId); + for (String str : split) { + if (Integer.parseInt(str) == 13) {//2 + Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureName(), ConstantUtils.Keda_schoolId); + Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeName(), organizationId); staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(organizationId); boolean b = systemSetttingDao.addStaffManager(staffVo); - if(!b){throw new RuntimeException();} - }else if (Integer.parseInt(str)==14){//3 - Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureNameTwo(),ConstantUtils.Keda_schoolId); - Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeNameTwo(),organizationId); + if (!b) { + throw new RuntimeException(); + } + } 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); boolean b = systemSetttingDao.addStaffTeacher(staffVo); - if(!b){throw new RuntimeException();} + if (!b) { + throw new RuntimeException(); + } } } } } - }catch (RuntimeException e){ + } catch (RuntimeException e) { e.printStackTrace(); throw new RuntimeException(); } @@ -424,14 +651,14 @@ public class SystemSettingServiceImpl implements SystemSetttingService { ops.set(token, failureVOJson, 30 * 60, TimeUnit.SECONDS); } map.put("token", token); - map.put("successNum", (size-failVo1.size())+""); - map.put("failureNum", failVo1.size()+""); + map.put("successNum", (size - failVo1.size()) + ""); + map.put("failureNum", failVo1.size() + ""); return map; } @Override - public void exportFailureRecord(HttpServletResponse response, String token) throws Exception{ + public void exportFailureRecord(HttpServletResponse response, String token) throws Exception { if (StringUtils.isEmpty(token)) { return; } @@ -454,14 +681,11 @@ public class SystemSettingServiceImpl implements SystemSetttingService { new ExcelExportUtil(StaffExportVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). export(response, inputStream, parse, "导入失败数据表.xlsx"); - if (inputStream!=null){ + if (inputStream != null) { inputStream.close(); } - - - // //2.加载模板流数据 // 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"); @@ -482,18 +706,19 @@ public class SystemSettingServiceImpl implements SystemSetttingService { } @Override - public R queryAccount(String account,Integer schoolId) { + public R queryAccount(String account, Integer schoolId) { HashMap map = new HashMap<>(); - List result = systemSetttingDao.queryAccount(account,schoolId); + List result = systemSetttingDao.queryAccount(account, schoolId); List vos = userInfoDao.queryAccount(account); - if (result.size()>1){return R.error("系统存在多个相同的账号:"+account); - }else if (result.size()==1){ + if (result.size() > 1) { + return R.error("系统存在多个相同的账号:" + account); + } else if (result.size() == 1) { StaffVo staffVo = result.get(0); - map.put("user",staffVo); + map.put("user", staffVo); List staffVos = systemSetttingDao.queryStaffInfo(staffVo.getUserId()); - map.put("staff",staffVos); - return R.ok().put("data",map); - }else if (vos.size()>0){ + map.put("staff", staffVos); + return R.ok().put("data", map); + } else if (vos.size() > 0) { return R.error("账号已存在"); } return R.ok(); @@ -501,14 +726,14 @@ public class SystemSettingServiceImpl implements SystemSetttingService { @Override @Transactional - public R resetPwd(Integer userId,String newPwd) { + public R resetPwd(Integer userId, String newPwd) { UserInfoEntity user = new UserInfoEntity(); user.setPassword(newPwd); int count = userInfoDao.update(user, new QueryWrapper().eq("userId", userId)); - if(count > 0){ + if (count > 0) { return R.ok(); - }else{ - return R.error(20002,"重置失败"); + } else { + return R.error(20002, "重置失败"); } } diff --git a/src/main/resources/excel-template/学生导入失败数据导出模板(1).xlsx b/src/main/resources/excel-template/学生导入失败数据导出模板(1).xlsx new file mode 100644 index 0000000000000000000000000000000000000000..d44230a9aa0b8eaeb5b1eb031cbb37efb1fe49e9 GIT binary patch literal 9279 zcmaia1z40@*ES#_9SYLj-Q78KBQZ1#-6@^Y4JsflASsQ4bayuhNOuk`{)4{fc=SEr z`|sYwxw!tb41-KY~SqdT3!vUqv6Te>FtNjhTa~inD{G3yTUw>?!1n z$3Mh|#evXl&`?l(Fi=n!{}eNJbY%9lv&~3olY7L5@$x9>2*de=-NExmBZ6HT; zjlJe^`o{J48xG0?Iel*gxMi5rPxH%3QQMCss{$CMcp0zKXa_??t6xg5i6!c*(UTA; zTE#G|mh|KEf;XF?WlZ>qNf2i-K4SH&UZJh?IZcoIOUOI$3xC$Pmw?ear3{(JS1ihJ zsG;^c$F8i73Dk|up=A;E*myQCtx=V)gZ$FR%#uXy8=Zv*eohpVXGz{vteTI-fV{{I zG+lAr%+_Un&q(1jy2Q-o8z)Pm;R_W-FA0427=6)AKs)p5xEiXbCX?$skpLQrl}xfV z(AzyOsEu@q=4Pjca|XS;yH7VTzr)MB0;*Dhz^e~|7xSO+nmRa}Kj7<|D5liGiXn9g zSR^|YuFM!mDy2+;a+9K>j1=8x^q$AZqNzf)8fgtR>ag;{c>4~uNR(0N`$)P71SIEP0?Jk-wcV zRnn&y@D$gXR#YI$O7bLbCXjAF3$={h5vSjdp=Cn&FrG<@=Hf6$v#GLt?>%uXn~z^4 z$rg{tL2=IbP#J7CV?q$(qs0{JY8!AVXVjp3Bz;^zpA3Y%i~yZ?EKz9lEOL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