diff --git a/pom.xml b/pom.xml index 1888f60..521842c 100644 --- a/pom.xml +++ b/pom.xml @@ -220,10 +220,31 @@ 2.1.1 + com.github.pagehelper - pagehelper - 5.1.2 + pagehelper-spring-boot-starter + 1.2.10 + + + + org.mybatis + mybatis + + + org.mybatis + mybatis-spring + + + + + + com.baomidou + mybatis-plus-boot-starter + 3.2.0 diff --git a/src/main/java/com/msdw/tms/api/AchievementManagementApi.java b/src/main/java/com/msdw/tms/api/AchievementManagementApi.java index 61eb7ed..cc0eb4e 100644 --- a/src/main/java/com/msdw/tms/api/AchievementManagementApi.java +++ b/src/main/java/com/msdw/tms/api/AchievementManagementApi.java @@ -35,6 +35,7 @@ public interface AchievementManagementApi { @RequestParam(value = "开始时间", required = false) String startTime, @RequestParam(value = "结束时间", required = false) String endTime, @RequestParam(value = "月份", required = false) Integer month, + @RequestParam(value = "系统",required = true) Integer systemId, @RequestParam(value = "页码", required = true) Integer page, @RequestParam(value = "页数大小", required = true) Integer size); @@ -55,7 +56,7 @@ public interface AchievementManagementApi { // R updateScore(@ApiParam(value = "recordid和score") ProjectRecordEntity entity); @ApiOperation(value = "删除实验报告", notes = "根据实验记录主键reportId和实验报告主键recordId删除实验报告") - R deleteReport(@ApiParam(value = "实验记录主键", required = true) Integer reportId, @ApiParam(value = "实验报告主键", required = true) @RequestParam Integer recordId); + R deleteReport(@ApiParam(value = "实验记录主键", required = true) List reportId, @ApiParam(value = "实验报告主键", required = true) @RequestParam List recordId); @ApiOperation(value = "班级实验报告列表查询", notes = "班级实验报告列表查询") R queryEvaluationReport(@ApiParam(value = "搜索内容(学校名称/学生姓名)", required = false) String searchContant, diff --git a/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java b/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java index 06eb889..655e53c 100644 --- a/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java +++ b/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java @@ -25,7 +25,7 @@ public interface ProjectRcordControllerApi { R queryUserRecord(Integer page,Integer size,Integer userId,Integer projectPermissions,Integer systemId); @ApiOperation(value = "用户端教学实验记录",notes = "用户端教学实验记录") - R getUserExperimentscore(Integer page,Integer size,Integer userid); + R getUserExperimentscore(Integer page,Integer size,Integer userid, Integer systemId); @ApiOperation(value = "个人实验概览",notes = "个人实验概览") R queryScore(Integer userId); diff --git a/src/main/java/com/msdw/tms/api/StudentControllerApi.java b/src/main/java/com/msdw/tms/api/StudentControllerApi.java index d4bd3da..db1438a 100644 --- a/src/main/java/com/msdw/tms/api/StudentControllerApi.java +++ b/src/main/java/com/msdw/tms/api/StudentControllerApi.java @@ -18,6 +18,9 @@ public interface StudentControllerApi { @ApiOperation(value = "新增学生",notes = "新增学生") public R addStudent(@RequestBody StudentVo studentVo); + @ApiOperation(value = "新增学生",notes = "新增学生") + public R zzAddStudent(@RequestBody StudentVo studentVo); + @ApiOperation(value = "学生列表信息",notes = "学生列表信息") public R queryStudent(Integer schoolId, String seachContent, Integer page, Integer size); diff --git a/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java b/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java index 51edcf5..7f84ee6 100644 --- a/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java +++ b/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java @@ -24,7 +24,10 @@ public interface UserInfoControllerApi { R getUserId(String token); @ApiOperation(value = "注册",notes = "注册") - R save(UserInfoEntity entity); + R save(UserInfoEntity entity,@ApiParam(value = "学号",required = true)String workNumber); + + @ApiOperation(value = "注册",notes = "注册") + R zzAdd(UserInfoEntity entity,@ApiParam(value = "学号",required = true)String workNumber); @ApiOperation(value = "个人中心信息展示",notes = "个人中心信息展示") R userInfo(Integer id); diff --git a/src/main/java/com/msdw/tms/common/utils/Constant.java b/src/main/java/com/msdw/tms/common/utils/Constant.java index 96214b0..e0d4263 100644 --- a/src/main/java/com/msdw/tms/common/utils/Constant.java +++ b/src/main/java/com/msdw/tms/common/utils/Constant.java @@ -54,6 +54,10 @@ public class Constant { * 通过excel批量导入试题数据时起始行 */ public static final int ROW_INDEX = 2; + /** + * 通过excel批量导入试题数据时起始行(专门用于练习,考核报告的) + */ + public static final int ROW_INDEX_REPORT = 3; /** * 通过excel批量导入试题数据时起始行 */ 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/common/utils/poi/ExcelExportUtil.java b/src/main/java/com/msdw/tms/common/utils/poi/ExcelExportUtil.java index e43d0fb..27e470b 100644 --- a/src/main/java/com/msdw/tms/common/utils/poi/ExcelExportUtil.java +++ b/src/main/java/com/msdw/tms/common/utils/poi/ExcelExportUtil.java @@ -1,5 +1,6 @@ package com.msdw.tms.common.utils.poi; +import com.msdw.tms.entity.vo.StudentVo; import lombok.Data; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -8,6 +9,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.lang.reflect.Field; import java.net.URLEncoder; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -75,6 +77,74 @@ public class ExcelExportUtil { workbook.write(response.getOutputStream()); } + + /** + * 基于注解导出(新增需求拓展) + * 参数: + * response: + * InputStream:模板的输入流 + * objs:数据 + * obj:拓展对象 + * fileName:生成的文件名 + */ + public void exportExpand(HttpServletResponse response, InputStream is, List objs,Object obj, String fileName) throws Exception { + + //1.根据模板创建工作簿 + XSSFWorkbook workbook = new XSSFWorkbook(is); + //2.读取工作表 + Sheet sheet = workbook.getSheetAt(0); + Row row1 = sheet.getRow(styleIndex); + //3.提取公共的样式 + CellStyle[] styles = getTemplateStyles(row1); + + //导出学生姓名,学号 + Sheet sheet1 = this.exportStudentInfo(sheet,(StudentVo)obj); + + //4.根据数据创建每一行和每一个单元格的数据2 + AtomicInteger datasAi = new AtomicInteger(rowIndex); //数字 + for (T t : objs) { + //datasAi.getAndIncrement() :获取数字,并++ i++ + Row row = sheet1.createRow(datasAi.getAndIncrement()); + for (int i = 0; i < styles.length; i++) { + Cell cell = row.createCell(i); + cell.setCellStyle(styles[i]); + for (Field field : fields) { + if (field.isAnnotationPresent(ExcelAttribute.class)) { + field.setAccessible(true); + ExcelAttribute ea = field.getAnnotation(ExcelAttribute.class); + if (i == ea.sort()) { + if (field.get(t) != null) { + cell.setCellValue(field.get(t).toString()); + } + } + } + } + } + } + fileName = URLEncoder.encode(fileName, "UTF-8"); + response.setContentType("application/octet-stream"); + response.setHeader("content-disposition", "attachment;filename=" + new String(fileName.getBytes("ISO8859-1"))); + response.setHeader("filename", fileName); + workbook.write(response.getOutputStream()); + } + + /** + * 添加姓名,学号的导出 + * @param sheet + * @return + */ + private Sheet exportStudentInfo(Sheet sheet,StudentVo studentVo){ + Integer ROW_INDEX = 1; + Integer CELL_INDEX_NAME = 1; + Integer CELL_INDEX_WORKNUMBER = 3; + + sheet.getRow(ROW_INDEX).getCell(CELL_INDEX_NAME).setCellValue(studentVo.getUserName()); + sheet.getRow(ROW_INDEX).getCell(CELL_INDEX_WORKNUMBER).setCellValue(studentVo.getWorkNumber()); + return sheet; + } + + + CellStyle[] getTemplateStyles(Row row) { CellStyle[] styles = new CellStyle[row.getLastCellNum()]; for (int i = 0; i < row.getLastCellNum(); i++) { diff --git a/src/main/java/com/msdw/tms/config/EmailUtils.java b/src/main/java/com/msdw/tms/config/EmailUtils.java index cee3b26..1f2e9de 100644 --- a/src/main/java/com/msdw/tms/config/EmailUtils.java +++ b/src/main/java/com/msdw/tms/config/EmailUtils.java @@ -30,6 +30,8 @@ public class EmailUtils { try { HtmlEmail email = new HtmlEmail(); email.setHostName(SERVER_ADDRESS); + email.setSSLOnConnect(true); //使用ssl加密true + email.setSslSmtpPort("465"); //使用465端口 email.setCharset("UTF-8"); email.addTo(emailaddress); diff --git a/src/main/java/com/msdw/tms/config/SendSMS.java b/src/main/java/com/msdw/tms/config/SendSMS.java index f34eb41..aaf7a23 100644 --- a/src/main/java/com/msdw/tms/config/SendSMS.java +++ b/src/main/java/com/msdw/tms/config/SendSMS.java @@ -16,7 +16,7 @@ public class SendSMS { private static final String PHONSMSTEMPLATE = "SMS_204155294"; public static void main(String[] args){ - String mobile="17722612183";//需要接受短信验证码的手机号 + String mobile="12345678910";//需要接受短信验证码的手机号 // String sendTemplate="SMS_204155294";//短信模板ID,需要去阿里云平台申请,审核通过后方能使用,通常是以"SMS_"开头字符串 String code = (int)((Math.random() * 9 + 1) * 100000)+ "";//要发送给用户的短信验证码,行业通常使用六位纯数字 @@ -26,7 +26,6 @@ public class SendSMS { }else{ System.out.println("短信发送失败"); } - } /** * 通过阿里云平台发送短信,如果发送成功,返回"OK" ;否则返回的是错误信息 diff --git a/src/main/java/com/msdw/tms/controller/AchievementManagementController.java b/src/main/java/com/msdw/tms/controller/AchievementManagementController.java index 37a20d5..269de60 100644 --- a/src/main/java/com/msdw/tms/controller/AchievementManagementController.java +++ b/src/main/java/com/msdw/tms/controller/AchievementManagementController.java @@ -1,23 +1,26 @@ package com.msdw.tms.controller; +import com.github.pagehelper.PageInfo; import com.msdw.tms.api.AchievementManagementApi; +import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.R; import com.msdw.tms.entity.*; import com.msdw.tms.entity.vo.AchievementManagementVO; import com.msdw.tms.entity.vo.ResultsVo; import com.msdw.tms.service.AchievementManagementService; import com.msdw.tms.service.ProjectRecordService; +import com.msdw.tms.util.ListPageUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; import java.util.List; /** * 成绩管理 */ +@CrossOrigin @RestController @RequestMapping("/Achievement") public class AchievementManagementController implements AchievementManagementApi { @@ -89,7 +92,9 @@ public class AchievementManagementController implements AchievementManagementApi if (endTime != null) { vo.setEndTime(endTime); } - List result = service.list(vo, page, size); + PageInfo result = service.list(vo, page, size); + + return R.ok().put("data", result); } @@ -103,6 +108,7 @@ public class AchievementManagementController implements AchievementManagementApi @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) Integer month, + @RequestParam(required = true) Integer systemId, @RequestParam(required = true) Integer page, @RequestParam(required = true) Integer size) { ResultsVo vo = new ResultsVo(); @@ -120,7 +126,10 @@ public class AchievementManagementController implements AchievementManagementApi if (endTime != null) { vo.setEndTime(endTime); } - List result = service.newList(vo, page, size); + if (systemId != null){ + vo.setSystemId(systemId); + } + PageInfo result = service.newList(vo, page, size); return R.ok().put("data", result); } @@ -198,7 +207,16 @@ public class AchievementManagementController implements AchievementManagementApi */ @Override @PostMapping("/deleteReport") - public R deleteReport(@RequestParam Integer reportId, @RequestParam Integer recordId) { + public R deleteReport(@RequestParam List reportId, @RequestParam List recordId) { + if (reportId == null || reportId.size() == 0){ + return R.error(400,"参数错误!"); + } + if (recordId == null || recordId.size() == 0){ + return R.error(400,"参数错误!"); + } + if (reportId.size() != recordId.size()){ + return R.error(400,"参数错误!"); + } R result = service.deleteReport(reportId, recordId); return result; } @@ -230,7 +248,7 @@ public class AchievementManagementController implements AchievementManagementApi @Override @GetMapping("/exportAchievement") public void exportAchievement(HttpServletResponse response, @RequestParam String ids, @RequestParam Integer source) throws Exception { - service.exportAchievement(response, ids,source);//SearchAchievementVo vo + service.exportAchievement(response, ids, source);//SearchAchievementVo vo } //成绩管理列表 diff --git a/src/main/java/com/msdw/tms/controller/EvaluationRecordController.java b/src/main/java/com/msdw/tms/controller/EvaluationRecordController.java index f7f1cd4..d219259 100644 --- a/src/main/java/com/msdw/tms/controller/EvaluationRecordController.java +++ b/src/main/java/com/msdw/tms/controller/EvaluationRecordController.java @@ -134,7 +134,7 @@ public class EvaluationRecordController implements EvaluationRecordControllerApi Integer id = fractionEntityService.queryScore(userId,type); if (id>0){ Integer score = fractionEntityService.queryExerciseRecord(userId); - if (score>=60){ + if (score>=80){ return R.ok("true"); }else{ return R.error(200,"false"); @@ -152,7 +152,7 @@ public class EvaluationRecordController implements EvaluationRecordControllerApi Integer id = fractionEntityService.queryScore(userId,type); if (id>0){ Integer score = fractionEntityService.queryTeachingRecord(userId); - if (score>=60){ + if (score>=80){ return R.ok("true"); }else{ return R.error(200,"false"); diff --git a/src/main/java/com/msdw/tms/controller/ProjectRecordController.java b/src/main/java/com/msdw/tms/controller/ProjectRecordController.java index 55374c2..14b035b 100644 --- a/src/main/java/com/msdw/tms/controller/ProjectRecordController.java +++ b/src/main/java/com/msdw/tms/controller/ProjectRecordController.java @@ -8,6 +8,7 @@ import com.msdw.tms.entity.ProjectEntity; import com.msdw.tms.entity.ProjectRecordEntity; import com.msdw.tms.entity.vo.ProjectRecordVo; import com.msdw.tms.service.ProjectRecordService; +import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; @@ -18,10 +19,8 @@ import java.util.HashMap; import java.util.List; /** - * - * - * @author - * @email + * @author + * @email * @date 2020-08-19 16:07:02 */ @RestController @@ -35,27 +34,32 @@ public class ProjectRecordController implements ProjectRcordControllerApi { */ @Override @GetMapping("/schoolRecord") - public R list(@RequestParam Integer page, @RequestParam Integer size, @RequestParam Integer month,@RequestParam String startTime,@RequestParam String endTime, - @RequestParam Integer recordState,@RequestParam String condition ){ + public R list(@RequestParam Integer page, @RequestParam Integer size, @RequestParam Integer month, @RequestParam String startTime, @RequestParam String endTime, + @RequestParam Integer recordState, @RequestParam String condition) { ProjectRecordVo recordVo = new ProjectRecordVo(); - if(!StringUtils.isEmpty(month)) { + if (!StringUtils.isEmpty(month)) { recordVo.setMonth(month); - }if(!StringUtils.isEmpty(startTime)) { + } + if (!StringUtils.isEmpty(startTime)) { recordVo.setStartTime(startTime); - }if(!StringUtils.isEmpty(endTime)) { + } + if (!StringUtils.isEmpty(endTime)) { recordVo.setEndTime(endTime); - }if(!StringUtils.isEmpty(recordState)) { + } + if (!StringUtils.isEmpty(recordState)) { recordVo.setRecordstate(recordState); - }if(!StringUtils.isEmpty(condition)){ + } + if (!StringUtils.isEmpty(condition)) { recordVo.setCondition(condition); } - PageUtils page1 = projectRecordService.querySchoolRecord(page,size,recordVo); + PageUtils page1 = projectRecordService.querySchoolRecord(page, size, recordVo); return R.ok().put("page", page1); } /** - * 用户端虚拟仿真实验记录 + * 用户端虚拟仿真实验记录(练习列表) + * * @param page * @param size * @param @@ -63,13 +67,14 @@ public class ProjectRecordController implements ProjectRcordControllerApi { */ @Override @GetMapping("/user/record") - public R queryUserRecord(@RequestParam Integer page,@RequestParam Integer size,@RequestParam Integer userId,@RequestParam Integer projectPermissions,@RequestParam Integer systemId){ - PageUtils page1 = projectRecordService.queryPage(page,size,userId,projectPermissions,systemId); + public R queryUserRecord(@RequestParam Integer page, @RequestParam Integer size, @RequestParam Integer userId, @RequestParam Integer projectPermissions, @RequestParam Integer systemId) { + PageUtils page1 = projectRecordService.queryPage(page, size, userId, projectPermissions, systemId); return R.ok().put("data", page1); } /** * 科大用户端虚拟仿真实验记录 + * * @param page * @param size * @param @@ -77,13 +82,14 @@ public class ProjectRecordController implements ProjectRcordControllerApi { */ @Override @GetMapping("/user/kdRecord") - public R kdRecord(@RequestParam Integer page,@RequestParam Integer size,@RequestParam Integer userId,@RequestParam Integer projectPermissions,@RequestParam Integer systemId){ - PageUtils page1 = projectRecordService.getByKDUserRecord(page,size,userId,projectPermissions,systemId); + public R kdRecord(@RequestParam Integer page, @RequestParam Integer size, @RequestParam Integer userId, @RequestParam Integer projectPermissions, @RequestParam Integer systemId) { + PageUtils page1 = projectRecordService.getByKDUserRecord(page, size, userId, projectPermissions, systemId); return R.ok().put("data", page1); } /** - * 用户端教学实验记录 + * 用户端教学实验记录(考核列表) + * * @param page * @param size * @param userid @@ -91,20 +97,21 @@ public class ProjectRecordController implements ProjectRcordControllerApi { */ @Override @GetMapping("/user/experimentRecord") - public R getUserExperimentscore(@RequestParam Integer page,@RequestParam Integer size,@RequestParam Integer userid){ - PageUtils page1 = projectRecordService.queryExperimentPage(page,size,userid); + public R getUserExperimentscore(@RequestParam Integer page, @RequestParam Integer size, @RequestParam Integer userid, @RequestParam Integer systemId) { + PageUtils page1 = projectRecordService.queryExperimentPage(page, size, userid, systemId); return R.ok().put("data", page1); } /** * 个人实验预览 + * * @param userId * @return */ @Override @GetMapping("/user/queryScore/{userId}") - public R queryScore(@PathVariable("userId") Integer userId){ + public R queryScore(@PathVariable("userId") Integer userId) { ProjectRecordVo projectRecord = projectRecordService.queryScore(userId); return R.ok().put("data", projectRecord); @@ -112,12 +119,13 @@ public class ProjectRecordController implements ProjectRcordControllerApi { /** * 个人实验预览 + * * @param userid * @return */ @Override @GetMapping("/user/score/{userId}") - public R getUserScore(@PathVariable("userId") Integer userid){ + public R getUserScore(@PathVariable("userId") Integer userid) { ProjectRecordVo projectRecord = projectRecordService.queryUserScore(userid); return R.ok().put("data", projectRecord); @@ -125,35 +133,37 @@ public class ProjectRecordController implements ProjectRcordControllerApi { /** * 导出个人虚拟仿真实验记录 + * * @param response * @param userId * @throws Exception */ @Override @GetMapping("/user/exportProjectRecord") - public void exportProjectRecord(HttpServletResponse response,@RequestParam("userId") Integer userId)throws Exception{ - projectRecordService.exportProjectRecord(response,userId); + public void exportProjectRecord(HttpServletResponse response, @RequestParam("userId") Integer userId) throws Exception { + projectRecordService.exportProjectRecord(response, userId); } /** * 导出个人教学实验记录 + * * @param response * @param userId * @throws Exception */ @Override @GetMapping("/user/exportExperimentProjectRecord") - public void exportExperimentProjectRecord(HttpServletResponse response,@RequestParam("userId") Integer userId)throws Exception{ - projectRecordService.exportExperimentProjectRecord(response,userId); + public void exportExperimentProjectRecord(HttpServletResponse response, @RequestParam("userId") Integer userId) throws Exception { + projectRecordService.exportExperimentProjectRecord(response, userId); } /** * 信息 */ @GetMapping("/info/{recordid}") - public R info(@PathVariable("recordid") Integer recordid){ - ProjectRecordEntity projectRecord = projectRecordService.getById(recordid); + public R info(@PathVariable("recordid") Integer recordid) { + ProjectRecordEntity projectRecord = projectRecordService.getById(recordid); return R.ok().put("projectRecord", projectRecord); } @@ -162,8 +172,8 @@ public class ProjectRecordController implements ProjectRcordControllerApi { * 保存 */ @RequestMapping("/save") - public R save(@RequestBody ProjectRecordEntity projectRecord){ - projectRecordService.save(projectRecord); + public R save(@RequestBody ProjectRecordEntity projectRecord) { + projectRecordService.save(projectRecord); return R.ok(); } @@ -173,10 +183,10 @@ public class ProjectRecordController implements ProjectRcordControllerApi { */ @Override @PutMapping("/update") - public R update(@RequestBody ProjectRecordEntity projectRecord){ + public R update(@RequestBody ProjectRecordEntity projectRecord) { boolean result = projectRecordService.updateUserRecord(projectRecord); - return R.ok().put("data",result); + return R.ok().put("data", result); } /** @@ -184,8 +194,8 @@ public class ProjectRecordController implements ProjectRcordControllerApi { */ @Override @DeleteMapping("/delete") - public R delete(@RequestBody Integer[] recordids){ - projectRecordService.removeByIds(Arrays.asList(recordids)); + public R delete(@RequestBody Integer[] recordids) { + projectRecordService.removeByIds(Arrays.asList(recordids)); return R.ok(); } diff --git a/src/main/java/com/msdw/tms/controller/StudentController.java b/src/main/java/com/msdw/tms/controller/StudentController.java index 614c4b9..5f82491 100644 --- a/src/main/java/com/msdw/tms/controller/StudentController.java +++ b/src/main/java/com/msdw/tms/controller/StudentController.java @@ -40,13 +40,13 @@ public class StudentController implements StudentControllerApi{ private UserInfoService userInfoService; /** - * 新增学生 + * 职站新增学生 * @param studentVo * @return */ @Transactional @Override - @PostMapping("/addStudent") + @PostMapping("/zzAddStudent") public R addStudent(@RequestBody @Valid StudentVo studentVo){ studentVo.setSchoolId(ConstantUtils.Keda_schoolId); String account = studentVo.getAccount(); @@ -83,6 +83,49 @@ public class StudentController implements StudentControllerApi{ } } + /** + * 科大新增学生 + * @param studentVo + * @return + */ + @Transactional + @Override + @PostMapping("/addStudent") + public R zzAddStudent(@RequestBody @Valid StudentVo studentVo){ + String account = studentVo.getAccount(); + String phone = studentVo.getPhone(); + Integer schoolId = studentVo.getSchoolId(); + Integer result = studentService.queryStudentIdNumber(studentVo.getWorkNumber(),schoolId); + Integer res = userInfoService.queryStudentAccount(account,schoolId); + if (phone!=null&&phone!=""){ + Integer outcome = userInfoService.queryStudentPhone(phone); + if(outcome==1){ + return R.error("手机号不能重复,只能绑定一个用户"); + } + } + String email = studentVo.getEmail(); + if (result==1){ + return R.error("学号不能重复"); + }else if (res==1){ + return R.error("账号不能重复"); + } + else{ + UserInfoEntity userInfoList = new UserInfoEntity(); + + userInfoList.setAccount(account) + .setPhone(phone) + .setEmail(studentVo.getEmail()) + .setSchoolId(studentVo.getSchoolAppellationId()) + .setUserName(studentVo.getUserName()) + .setToken(new ConstantUtils().token); + userInfoService.saveUserInfo(userInfoList); + + studentVo.setUserId(userInfoList.getUserId()).setPlatformId(ConstantUtils.PLATFORMID);//暂时写死平台id(PlatformId) + boolean saveStudent = studentService.saveStudent(studentVo); + return saveStudent ? R.ok() : R.error(); + } + } + /** * 学生列表 * @param schoolId diff --git a/src/main/java/com/msdw/tms/controller/UserInfoController.java b/src/main/java/com/msdw/tms/controller/UserInfoController.java index 5f9586a..1ea72ce 100644 --- a/src/main/java/com/msdw/tms/controller/UserInfoController.java +++ b/src/main/java/com/msdw/tms/controller/UserInfoController.java @@ -8,6 +8,7 @@ import com.msdw.tms.entity.UserEntity; import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.UserPersonalFileEntity; import com.msdw.tms.entity.vo.CheckVo; +import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.entity.vo.UserEntityVo; import com.msdw.tms.entity.vo.UserProsonalEntityVo; import com.msdw.tms.service.StudentService; @@ -58,27 +59,82 @@ public class UserInfoController implements UserInfoControllerApi { @Override @Transactional @PostMapping("/add") - public R save(@RequestBody UserInfoEntity userInfoEntity){ + public R save(@RequestBody UserInfoEntity userInfoEntity,@RequestParam String workNumber){ String token ="UT_"+ UUID.randomUUID().toString().replace("-", ""); userInfoEntity.setToken(token); - userInfoEntity.setSchoolId(2105); Integer schoolId = userInfoEntity.getSchoolId(); Integer integer = userInfoService.queryStudentAccount(userInfoEntity.getAccount(),schoolId); Integer integer1 = userInfoService.queryStudentPhone(userInfoEntity.getPhone()); + + //新增学生 + StudentVo studentVo = new StudentVo(); + + studentVo.setRoleId(Integer.valueOf(userInfoEntity.getRoleId())); + studentVo.setSchoolId(schoolId); + studentVo.setIsdel(0); + studentVo.setWorkNumber(workNumber); + studentVo.setPlatformId(1); + //为1 学号有重复 + int num = studentService.queryStudentByWorkNumber(studentVo); + if (integer==1){ return R.error(400,"账号已存在"); } if (integer1==1){ - return R.error(400,"改手机号已被绑定"); + return R.error(400,"该手机号已被绑定"); + } + if (num == 1){ + return R.error(400,"该学号重复!"); } int userId = userInfoService.add(userInfoEntity); if (userId==0){ return R.error(400,"添加用户信息失败"); } // userInfoEntity.setUserId(userId); - studentService.addStudentInfo(userInfoEntity); + studentVo.setUserId(userInfoEntity.getUserId()); + return studentService.addStudentInfo(studentVo); + } - return R.ok(); + /** + * 职站注册 + */ + @Override + @Transactional + @PostMapping("/zzAdd") + public R zzAdd(@RequestBody UserInfoEntity userInfoEntity,@RequestParam String workNumber){ + String token ="UT_"+ UUID.randomUUID().toString().replace("-", ""); + userInfoEntity.setToken(token); + userInfoEntity.setSchoolId(2105); + Integer schoolId = userInfoEntity.getSchoolId(); + Integer integer = userInfoService.queryStudentAccount(userInfoEntity.getAccount(),schoolId); + Integer integer1 = userInfoService.queryStudentPhone(userInfoEntity.getPhone()); + + //新增学生 + StudentVo studentVo = new StudentVo(); + + studentVo.setRoleId(Integer.valueOf(userInfoEntity.getRoleId())); + studentVo.setSchoolId(schoolId); + studentVo.setIsdel(0); + studentVo.setWorkNumber(workNumber); + studentVo.setPlatformId(1); + //为1 学号有重复 + int num = studentService.queryStudentByWorkNumber(studentVo); + if (integer==1){ + return R.error(400,"账号已存在"); + } + if (integer1==1){ + return R.error(400,"该手机号已被绑定"); + } + if (num == 1){ + return R.error(400,"该学号重复!"); + } + int userId = userInfoService.add(userInfoEntity); + if (userId==0){ + return R.error(400,"添加用户信息失败"); + } +// userInfoEntity.setUserId(userId); + studentVo.setUserId(userInfoEntity.getUserId()); + return studentService.addStudentInfo(studentVo); } /** @@ -126,6 +182,12 @@ public class UserInfoController implements UserInfoControllerApi { UserInfoEntity userInfo = vo.getUserInfoEntity(); Integer userId = userInfo.getUserId(); String password = userInfo.getPassword(); + + //验证账号是否存在 + int num = userInfoService.queryAccountExist(userInfo.getAccount()); + if (num >= 1){ + return R.error(500,"更新失败,账号不能重复"); + } String userPassword = userInfoService.queryPasword(userId); if (userPassword.equals(password)==true){ return R.error(400,"false,the password is the same!!!"); @@ -207,7 +269,7 @@ public class UserInfoController implements UserInfoControllerApi { @Override @GetMapping("/getUserId") public R getUserId(@RequestParam String token){ - Integer userId = userInfoService.getUserId(token); - return R.ok().put("userId", userId); + R result = userInfoService.getUserId(token); + return result; } } diff --git a/src/main/java/com/msdw/tms/dao/AchievementManagementDao.java b/src/main/java/com/msdw/tms/dao/AchievementManagementDao.java index 46004bd..c9f48eb 100644 --- a/src/main/java/com/msdw/tms/dao/AchievementManagementDao.java +++ b/src/main/java/com/msdw/tms/dao/AchievementManagementDao.java @@ -56,7 +56,7 @@ public interface AchievementManagementDao extends BaseMapper queryAchievement(@Param("ids") List ids); //导出考核 - List queryAchievementByAssessment(Integer id); + List queryAchievementByAssessment(@Param("ids") List ids); List queryFictitiousRecord(Integer systemId, String searchContant, String startingtime, String endtime, Integer month, List projectIds); diff --git a/src/main/java/com/msdw/tms/dao/ProjectHiddenDao.java b/src/main/java/com/msdw/tms/dao/ProjectHiddenDao.java new file mode 100644 index 0000000..ea4ef92 --- /dev/null +++ b/src/main/java/com/msdw/tms/dao/ProjectHiddenDao.java @@ -0,0 +1,13 @@ +package com.msdw.tms.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.msdw.tms.entity.ProjectHiddenEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface ProjectHiddenDao extends BaseMapper { + + ProjectHiddenEntity selectByProjectId(Integer projectId); + + ProjectHiddenEntity selectByTeachId(Integer teachId); +} diff --git a/src/main/java/com/msdw/tms/dao/ProjectRecordDao.java b/src/main/java/com/msdw/tms/dao/ProjectRecordDao.java index ef3a655..a7b082e 100644 --- a/src/main/java/com/msdw/tms/dao/ProjectRecordDao.java +++ b/src/main/java/com/msdw/tms/dao/ProjectRecordDao.java @@ -23,11 +23,11 @@ import java.util.List; @Mapper public interface ProjectRecordDao extends BaseMapper { - IPage getByKDUserRecord(Page page,@Param("pro") ProjectRecordEntity projectRecordEntity,Integer projectPermissions); + IPage getByKDUserRecord(Page page, @Param("pro") ProjectRecordEntity projectRecordEntity, Integer projectPermissions); - IPage getByUserRecord(Page page, @Param("userId") Integer userId, @Param("projectPermissions") Integer projectPermissions,@Param("systemId") Integer systemId); + IPage getByUserRecord(Page page, @Param("userId") Integer userId, @Param("projectPermissions") Integer projectPermissions, @Param("systemId") Integer systemId); - IPage getByUserExperimentRecord(Page page, @Param("pro") ProjectRecordEntity projectRecordEntity); + IPage getByUserExperimentRecord(Page page, @Param("pro") ProjectRecordEntity projectRecordEntity, Integer systemId); List getByUserRecordImport(ProjectRecordEntity projectRecordEntity); @@ -46,4 +46,11 @@ public interface ProjectRecordDao extends BaseMapper { ProjectRecordEntity queryReport(Integer recordId); void updateScore(ProjectRecordEntity vo); + + //练习统计 + List sumByPracticeNum(Integer userId); + + //考核统计 + List sumByAssessmentNum(Integer userId); + } diff --git a/src/main/java/com/msdw/tms/dao/StudentDao.java b/src/main/java/com/msdw/tms/dao/StudentDao.java index b426e78..1dff280 100644 --- a/src/main/java/com/msdw/tms/dao/StudentDao.java +++ b/src/main/java/com/msdw/tms/dao/StudentDao.java @@ -28,7 +28,7 @@ public interface StudentDao extends BaseMapper { void updateWorkNumber(String workNumber,Integer studentId); - boolean addStudentInfo(UserInfoEntity userInfoEntity); + boolean addStudentInfo(StudentVo studentVo); List querySchoolName(String schoolAppellationName); @@ -37,4 +37,6 @@ public interface StudentDao extends BaseMapper { int querySchoolAppellationName(String schoolAppellationName); List queryAccount(String account,Integer schoolId); + + int queryStudentByWorkNumber(StudentVo studentVo); } diff --git a/src/main/java/com/msdw/tms/dao/UserInfoDao.java b/src/main/java/com/msdw/tms/dao/UserInfoDao.java index b1a3cfc..ccdb1fc 100644 --- a/src/main/java/com/msdw/tms/dao/UserInfoDao.java +++ b/src/main/java/com/msdw/tms/dao/UserInfoDao.java @@ -66,4 +66,6 @@ public interface UserInfoDao extends BaseMapper { List queryStudentName(Integer userId); Integer getUserId(String token); + + Integer queryAccountExist(String account); } diff --git a/src/main/java/com/msdw/tms/entity/ProjectHiddenEntity.java b/src/main/java/com/msdw/tms/entity/ProjectHiddenEntity.java new file mode 100644 index 0000000..c06a2bf --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/ProjectHiddenEntity.java @@ -0,0 +1,34 @@ +package com.msdw.tms.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@ApiModel(value = "此表是在教师端成绩管理,虚仿以及教学列表展示中使用到") +@TableName("tms_project_hidden") +public class ProjectHiddenEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + @ApiModelProperty(value = "主键") + private Integer id; + + @ApiModelProperty(value = "项目id(对应hr_project_management主键)") + private Integer projectId; + + @ApiModelProperty(value = "实验教学id(对应tms_experimental_teaching主键)") + private Integer teachId; + + @ApiModelProperty(value = "是否隐藏(0不隐藏,1隐藏)") + private Integer isHidden; + + +} diff --git a/src/main/java/com/msdw/tms/entity/ResultsEntity.java b/src/main/java/com/msdw/tms/entity/ResultsEntity.java index 4ec085d..f52b044 100644 --- a/src/main/java/com/msdw/tms/entity/ResultsEntity.java +++ b/src/main/java/com/msdw/tms/entity/ResultsEntity.java @@ -48,8 +48,7 @@ public class ResultsEntity{ //实验名称 private String experimentalName; + //是否删除 private Integer isdel; - - } diff --git a/src/main/java/com/msdw/tms/entity/request/ExperimentProjectRecordImportRequest.java b/src/main/java/com/msdw/tms/entity/request/ExperimentProjectRecordImportRequest.java index 2dac435..2254101 100644 --- a/src/main/java/com/msdw/tms/entity/request/ExperimentProjectRecordImportRequest.java +++ b/src/main/java/com/msdw/tms/entity/request/ExperimentProjectRecordImportRequest.java @@ -8,36 +8,42 @@ import lombok.Data; */ @Data public class ExperimentProjectRecordImportRequest { + /** - * 实验班级名称 + * 实验名称(即考核名称) */ @ExcelAttribute(sort = 0) + private String experimentalName; + /** + * 实验班级名称 + */ + @ExcelAttribute(sort = 1) private String experimentalClassName; /** * 实验项目名称 */ - @ExcelAttribute(sort = 1) + @ExcelAttribute(sort = 2) private String projectName; /** * 得分 */ - @ExcelAttribute(sort = 2) + @ExcelAttribute(sort = 3) private Integer score; /** * 耗时 */ - @ExcelAttribute(sort = 3) + @ExcelAttribute(sort = 4) private Integer timeSum; /** * 起始时间 */ - @ExcelAttribute(sort = 4) + @ExcelAttribute(sort = 5) private String startTime; /** * 结束时间 */ - @ExcelAttribute(sort = 5) + @ExcelAttribute(sort = 6) private String endTime; } 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/AchievementManagementVO.java b/src/main/java/com/msdw/tms/entity/vo/AchievementManagementVO.java index e5e2fa5..99913e1 100644 --- a/src/main/java/com/msdw/tms/entity/vo/AchievementManagementVO.java +++ b/src/main/java/com/msdw/tms/entity/vo/AchievementManagementVO.java @@ -88,4 +88,10 @@ public class AchievementManagementVO extends ExperimentalReportEntity { private String answer; //判分点名称 private String judgmentPointsName; + + //学生id + private Integer studentId; + + //运行有没有出现错误(0、运行正确 1、运行错误 + private Integer isError; } diff --git a/src/main/java/com/msdw/tms/entity/vo/ProjectRecordExportVo.java b/src/main/java/com/msdw/tms/entity/vo/ProjectRecordExportVo.java index 080b776..10a0573 100644 --- a/src/main/java/com/msdw/tms/entity/vo/ProjectRecordExportVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/ProjectRecordExportVo.java @@ -88,4 +88,8 @@ public class ProjectRecordExportVo extends ProjectRecordEntity implements Serial * 实验班级名称 */ private String experimental_class_name; + /** + * 实验名称(即考核名称) + */ + private String experimentalName; } diff --git a/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java b/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java index adb3cfc..9dc2a0b 100644 --- a/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.experimental.Accessors; import java.io.Serializable; +import java.math.BigDecimal; import java.util.List; @Data @@ -51,7 +52,7 @@ public class ProjectRecordVo extends ProjectRecordEntity implements Serializable /** * 平均分 */ - private double avgScore; + private double avgScore; /** * 几个月 */ @@ -59,7 +60,7 @@ public class ProjectRecordVo extends ProjectRecordEntity implements Serializable /** * 查询条件 */ - private String condition; + private String condition; /** * 开始时间 */ @@ -76,7 +77,9 @@ public class ProjectRecordVo extends ProjectRecordEntity implements Serializable * 待评分 */ private Integer tobescored; - /** 记录状态(0 未修改,1 已修改)*/ + /** + * 记录状态(0 未修改,1 已修改) + */ private Integer recordState; // =====================================记录实验项目信息 /** @@ -95,7 +98,10 @@ public class ProjectRecordVo extends ProjectRecordEntity implements Serializable * 实验班级名 */ private String experimentalClassName; - + /** + * 实验名称 + */ + private String experimentalName; /** * 封装多个项目id */ @@ -109,4 +115,9 @@ public class ProjectRecordVo extends ProjectRecordEntity implements Serializable */ private Integer schoolId; + /** + * 系统id + */ + private Integer systemId; + } 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/entity/vo/StudentVo.java b/src/main/java/com/msdw/tms/entity/vo/StudentVo.java index e1daa44..1617a47 100644 --- a/src/main/java/com/msdw/tms/entity/vo/StudentVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/StudentVo.java @@ -5,6 +5,7 @@ import com.msdw.tms.entity.UserInfoEntity; import lombok.Data; import lombok.experimental.Accessors; +import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import java.util.List; diff --git a/src/main/java/com/msdw/tms/service/AchievementManagementService.java b/src/main/java/com/msdw/tms/service/AchievementManagementService.java index dfd3bc2..df44ed6 100644 --- a/src/main/java/com/msdw/tms/service/AchievementManagementService.java +++ b/src/main/java/com/msdw/tms/service/AchievementManagementService.java @@ -1,16 +1,15 @@ package com.msdw.tms.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.github.pagehelper.PageInfo; import com.msdw.tms.common.utils.R; import com.msdw.tms.entity.ExperimentalReportEntity; -import com.msdw.tms.entity.ExperimentalTeachingEntity; import com.msdw.tms.entity.ReportEntity; import com.msdw.tms.entity.ResultsEntity; import com.msdw.tms.entity.vo.AchievementManagementVO; import com.msdw.tms.entity.vo.ResultsVo; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; import java.util.List; public interface AchievementManagementService extends IService { @@ -21,10 +20,10 @@ public interface AchievementManagementService extends IService list(ResultsVo vo, Integer page, Integer size); + PageInfo list(ResultsVo vo, Integer page, Integer size); //查询实验教学列表 - List newList(ResultsVo vo, Integer page, Integer size); + PageInfo newList(ResultsVo vo, Integer page, Integer size); List reportList(ResultsVo vo, Integer page, Integer size); @@ -32,7 +31,7 @@ public interface AchievementManagementService extends IService reportId,List recordId); R queryEvaluationReport(String searchContant, Integer projectId, Integer page, Integer size); diff --git a/src/main/java/com/msdw/tms/service/ProjectHiddenService.java b/src/main/java/com/msdw/tms/service/ProjectHiddenService.java new file mode 100644 index 0000000..4a8ed2b --- /dev/null +++ b/src/main/java/com/msdw/tms/service/ProjectHiddenService.java @@ -0,0 +1,7 @@ +package com.msdw.tms.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.msdw.tms.entity.ProjectHiddenEntity; + +public interface ProjectHiddenService extends IService { +} diff --git a/src/main/java/com/msdw/tms/service/ProjectRecordService.java b/src/main/java/com/msdw/tms/service/ProjectRecordService.java index 5da29f2..3a77782 100644 --- a/src/main/java/com/msdw/tms/service/ProjectRecordService.java +++ b/src/main/java/com/msdw/tms/service/ProjectRecordService.java @@ -16,12 +16,13 @@ import java.util.List; * @date 2020-08-19 16:07:02 */ public interface ProjectRecordService extends IService { - PageUtils getByKDUserRecord(Integer page,Integer size,Integer userId,Integer projectPermissions,Integer systemId); + PageUtils getByKDUserRecord(Integer page, Integer size, Integer userId, Integer projectPermissions, Integer systemId); - PageUtils queryPage(Integer page, Integer size, Integer userId, Integer projectPermissions,Integer systemId); + PageUtils queryPage(Integer page, Integer size, Integer userId, Integer projectPermissions, Integer systemId); - PageUtils queryExperimentPage(Integer page, Integer size, Integer userid); + PageUtils queryExperimentPage(Integer page, Integer size, Integer userid, Integer systemId); + //学生端实验概览 ProjectRecordVo queryUserScore(Integer userId); ProjectRecordVo queryScore(Integer userId); @@ -35,5 +36,6 @@ public interface ProjectRecordService extends IService { boolean updateUserRecord(ProjectRecordEntity projectRecord); void updateScore(ProjectRecordEntity vo); + } diff --git a/src/main/java/com/msdw/tms/service/StudentService.java b/src/main/java/com/msdw/tms/service/StudentService.java index 05d99e9..efc4e0e 100644 --- a/src/main/java/com/msdw/tms/service/StudentService.java +++ b/src/main/java/com/msdw/tms/service/StudentService.java @@ -30,7 +30,7 @@ public interface StudentService extends IService{ void updateWorkNumber(Integer studentId); - R addStudentInfo(UserInfoEntity userInfoEntity); + R addStudentInfo(StudentVo studentVo); void downloadFiles(HttpServletResponse response) throws IOException; @@ -40,4 +40,5 @@ public interface StudentService extends IService{ R queryAccount(String account,Integer schoolId); + int queryStudentByWorkNumber(StudentVo studentVo); } diff --git a/src/main/java/com/msdw/tms/service/UserInfoService.java b/src/main/java/com/msdw/tms/service/UserInfoService.java index b6b52dd..59b44e0 100644 --- a/src/main/java/com/msdw/tms/service/UserInfoService.java +++ b/src/main/java/com/msdw/tms/service/UserInfoService.java @@ -48,6 +48,7 @@ public interface UserInfoService extends IService { R queryAccount(); - Integer getUserId(String token); + R getUserId(String token); + Integer queryAccountExist(String account); } diff --git a/src/main/java/com/msdw/tms/service/impl/AchievementManagementServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/AchievementManagementServiceImpl.java index 69853a1..393fc74 100644 --- a/src/main/java/com/msdw/tms/service/impl/AchievementManagementServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/AchievementManagementServiceImpl.java @@ -3,14 +3,13 @@ package com.msdw.tms.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.msdw.tms.common.utils.Constant; import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.poi.ExcelExportUtil; -import com.msdw.tms.dao.AchievementManagementDao; -import com.msdw.tms.dao.ExperimentalTeachingDao; -import com.msdw.tms.dao.ProjectRecordDao; -import com.msdw.tms.dao.UserInfoDao; +import com.msdw.tms.dao.*; import com.msdw.tms.entity.*; import com.msdw.tms.entity.request.AchievementImportRequest; import com.msdw.tms.entity.request.ImportAssessmentRequest; @@ -46,6 +45,9 @@ public class AchievementManagementServiceImpl extends ServiceImpl list(ResultsVo vo, Integer page, Integer size) { - + public PageInfo list(ResultsVo vo, Integer page, Integer size) { + //使用分页插件,核心代码就这一行 + PageHelper.startPage(page, size); List list = achievementManagementDao.list(vo); + PageInfo info = new PageInfo(list); for (ResultsEntity entity : list) { Integer number = achievementManagementDao.getImitationAchievement(entity.getProjectId()).size(); entity.setNumber(number); } +/* + Date begin = new Date(); + list.parallelStream().forEach(x -> { + x.setNumber(achievementManagementDao.getImitationAchievement(x.getProjectId()).size()); + x.setProjectHiddenEntity(projectHiddenDao.selectByProjectId(x.getProjectId())); + }); + Date end = new Date(); + // System.out.println("时间1:" + (end.getTime() - begin.getTime())); + + Date begin1 = new Date(); + for (ResultsEntity entity : list) { + Integer number = achievementManagementDao.getImitationAchievement(entity.getProjectId()).size(); + entity.setNumber(number); + ProjectHiddenEntity hiddenEntity = projectHiddenDao.selectByProjectId(entity.getProjectId()); + entity.setProjectHiddenEntity(hiddenEntity); + } + Date end1 = new Date();*/ + //System.out.println("时间2:" + (end1.getTime() - begin1.getTime())); - return list; + + // PageInfo ret = new PageInfo<>(); + + return info; } @Override @@ -109,13 +134,17 @@ public class AchievementManagementServiceImpl extends ServiceImpl newList(ResultsVo vo, Integer page, Integer size) { + public PageInfo newList(ResultsVo vo, Integer page, Integer size) { + //使用分页插件,核心代码就这一行 + PageHelper.startPage(page, size); List newList = achievementManagementDao.newList(vo); for (ResultsEntity entity : newList) { Integer number = achievementManagementDao.getTeachAchievement(entity.getId()).size(); entity.setNumber(number); } - return newList; + + PageInfo info = new PageInfo(newList); + return info; } @@ -193,8 +222,10 @@ public class AchievementManagementServiceImpl extends ServiceImpl reportId,List recordId) { + for (int i = 0; i < reportId.size(); i++) { + achievementManagementDao.deleteReport(reportId.get(i), recordId.get(i)); + } return R.ok(); } @@ -218,6 +249,7 @@ public class AchievementManagementServiceImpl extends ServiceImpl assessment = achievementManagementDao.queryAchievementByAssessment(id); + /*List assessment = null; + for (Integer id : list) { + assessment = achievementManagementDao.queryAchievementByAssessment(id); + }*/ + //Integer id = Integer.valueOf(list.get(0)); + List assessment = achievementManagementDao.queryAchievementByAssessment(list); //2.加载模板流数据 ClassPathResource resource1 = new ClassPathResource("excel-template/川大成绩管理实验记录导出模板 (2).xlsx"); @@ -327,6 +363,11 @@ public class AchievementManagementServiceImpl extends ServiceImpl projectIds, Integer projectPermissions, List ids) { + + ProjectHiddenEntity projectHiddenEntity = new ProjectHiddenEntity(); + //projectHiddenEntity.setId(null); + int num = 0; + if (projectPermissions == 1) {//实验教学 for (Integer id : ids) { List teachAchievements = achievementManagementDao.getTeachAchievement(id); @@ -335,6 +376,15 @@ public class AchievementManagementServiceImpl extends ServiceImpl data = achievementManagementDao.queryPythonTest(recordId); HashMap map = new HashMap<>(); map.put("data", data); diff --git a/src/main/java/com/msdw/tms/service/impl/ProjectHiddenServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/ProjectHiddenServiceImpl.java new file mode 100644 index 0000000..ac567ae --- /dev/null +++ b/src/main/java/com/msdw/tms/service/impl/ProjectHiddenServiceImpl.java @@ -0,0 +1,18 @@ +package com.msdw.tms.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.msdw.tms.dao.ProjectHiddenDao; +import com.msdw.tms.entity.ProjectHiddenEntity; +import com.msdw.tms.service.ProjectHiddenService; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.Map; +import java.util.function.Function; + +@Service("projectHiddenService") +public class ProjectHiddenServiceImpl extends ServiceImpl implements ProjectHiddenService { + + +} diff --git a/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java index 89c6c31..844115e 100644 --- a/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java @@ -8,6 +8,7 @@ import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.poi.ExcelExportUtil; import com.msdw.tms.dao.ProjectRecordDao; +import com.msdw.tms.dao.StudentDao; import com.msdw.tms.entity.ExperimentalReportEntity; import com.msdw.tms.entity.ProjectRecordEntity; import com.msdw.tms.entity.request.ExperimentProjectRecordImportRequest; @@ -15,6 +16,7 @@ import com.msdw.tms.entity.request.ProjectRecordImportRequest; import com.msdw.tms.entity.resp.GetByUserRecordResp; import com.msdw.tms.entity.vo.ProjectRecordExportVo; import com.msdw.tms.entity.vo.ProjectRecordVo; +import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.service.ProjectRecordService; import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.BeanUtils; @@ -24,6 +26,8 @@ import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.HashMap; import java.util.List; @@ -36,16 +40,19 @@ public class ProjectRecordServiceImpl extends ServiceImpl page1 = new Page<>(page, size); - IPage projectRecordVos = this.baseMapper.getByKDUserRecord(page1,projectRecord,projectPermissions); + IPage projectRecordVos = this.baseMapper.getByKDUserRecord(page1, projectRecord, projectPermissions); PageUtils questionsPage = new PageUtils(projectRecordVos); @@ -53,7 +60,7 @@ public class ProjectRecordServiceImpl extends ServiceImpl page1 = new Page<>(page, size); - IPage projectRecordVos = this.baseMapper.getByUserRecord(page1, userId, projectPermissions,systemId); + IPage projectRecordVos = this.baseMapper.getByUserRecord(page1, userId, projectPermissions, systemId); PageUtils questionsPage = new PageUtils(projectRecordVos); @@ -69,14 +76,14 @@ public class ProjectRecordServiceImpl extends ServiceImpl page1 = new Page<>(page, size); - IPage projectRecordVos = this.baseMapper.getByUserExperimentRecord(page1, projectRecord); + IPage projectRecordVos = this.baseMapper.getByUserExperimentRecord(page1, projectRecord, systemId); PageUtils questionsPage = new PageUtils(projectRecordVos); @@ -88,6 +95,57 @@ public class ProjectRecordServiceImpl extends ServiceImpl sumByPracticeNum = this.baseMapper.sumByPracticeNum(userId); + + //练习总分 + Integer practiceByScore = 0; + //练习总耗时 + Integer practiceByTime = 0; + for (GetByUserRecordResp resp : sumByPracticeNum) { + //累计总分 + practiceByScore += resp.getScore(); + //累计时间 + practiceByTime += resp.getTimeSum(); + } + + //考核统计 + List sumByAssessmentNum = this.baseMapper.sumByAssessmentNum(userId); + + //练习总分 + Integer assessmenteByScore = 0; + //练习总耗时 + double assessmentByTime = 0; + for (ProjectRecordVo vo : sumByAssessmentNum) { + //累计总分 + assessmenteByScore += vo.getScore(); + //累计时间 + assessmentByTime += vo.getTimeSum(); + } + + + //设置实验次数 + Integer numer = sumByPracticeNum.size() + sumByAssessmentNum.size(); + projectRecordVo.setExperimentNumber(numer); + + + //取平均分 + //BigDecimal getSumByScore = (new BigDecimal(practiceByScore).add(new BigDecimal(assessmenteByScore))).divide(new BigDecimal(numer)).setScale(2, RoundingMode.HALF_UP); + + if (practiceByScore + assessmenteByScore != 0) { + double getSumByScore = (practiceByScore + assessmenteByScore) / numer; + projectRecordVo.setAvgScore(getSumByScore); + } else { + projectRecordVo.setAvgScore(0); + } + + + //获得总耗时 + double getTime = practiceByTime + assessmentByTime; + projectRecordVo.setTotalTime(new Double(getTime)); + + Double totalTime = projectRecordVo.getTotalTime(); if (totalTime != null) { DecimalFormat df = new DecimalFormat("0.00"); @@ -115,6 +173,8 @@ public class ProjectRecordServiceImpl extends ServiceImpl projectRecordVos = this.baseMapper.getByRecordImport(projectRecord); // List projectRecordVos = this.baseMapper.getByUserRecordImport(projectRecord); + StudentVo studentVo = studentDao.queryStudentDetails(userId); + List importRequests = projectRecordVos.stream().map(project -> { ProjectRecordImportRequest request = new ProjectRecordImportRequest(); BeanUtils.copyProperties(project, request); @@ -125,13 +185,13 @@ public class ProjectRecordServiceImpl extends ServiceImpl projectRecordVos = this.baseMapper.getByUserRecordImport(projectRecord); + StudentVo studentVo = studentDao.queryStudentDetails(userId); + List importRequests = projectRecordVos.stream().map(project -> { ExperimentProjectRecordImportRequest request = new ExperimentProjectRecordImportRequest(); BeanUtils.copyProperties(project, request); @@ -153,13 +215,13 @@ public class ProjectRecordServiceImpl 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,22 +118,19 @@ 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(UserInfoEntity userInfoEntity) { + public R addStudentInfo(StudentVo studentVo) { R r = new R(); - boolean result = studentDao.addStudentInfo(userInfoEntity); - if (result==false){ - r.put("code",300); - r.put("errmessage","注册失败!"); - return r; - }else{ - r.put("code",200); - r.put("errmessage","注册成功!"); - return r; + boolean result = studentDao.addStudentInfo(studentVo); + if (result == false) { + throw new RuntimeException();//添加失败,抛出运行时异常让外层事务回滚 + } else { + return R.ok("注册成功!"); } + } @Override @@ -144,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()) @@ -156,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); @@ -182,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); @@ -207,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); @@ -221,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; @@ -233,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 = ""; @@ -264,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; } @@ -287,27 +360,33 @@ 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(); } + @Override + public int queryStudentByWorkNumber(StudentVo studentVo) { + return studentDao.queryStudentByWorkNumber(studentVo); + } + } 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 f553cd1..6282bc1 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); - staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(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).setRoleId("13"); 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); - staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(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).setRoleId("14"); 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/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java index 392b2aa..3559522 100644 --- a/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java @@ -223,8 +223,13 @@ public class UserInfoServiceImpl extends ServiceImpl { + /** + * 原集合 + */ + private List data; + + /** + * 上一页 + */ + private int lastPage; + + /** + * 当前页 + */ + private int nowPage; + + /** + * 下一页 + */ + private int nextPage; + + /** + * 每页条数 + */ + private int pageSize; + + /** + * 总页数 + */ + private int totalPage; + + /** + * 总数据条数 + */ + private int totalCount; + + public ListPageUtil(List data, int nowPage, int pageSize) { + if (data == null || data.isEmpty()) { + //throw new IllegalArgumentException("暂无数据"); + this.data = null; +// this.pageSize = pageSize; +// this.nowPage = nowPage; +// this.totalCount = data.size(); + } + + this.data = data; + this.pageSize = pageSize; + this.nowPage = nowPage; + this.totalCount = data.size(); + this.totalPage = (totalCount + pageSize - 1) / pageSize; + this.lastPage = nowPage - 1 > 1 ? nowPage - 1 : 1; + this.nextPage = nowPage >= totalPage ? totalPage : nowPage + 1; + + } + + /** + * 得到分页后的数据 + * + * @return 分页后结果 + */ + public List getPagedList() { + int fromIndex = (nowPage - 1) * pageSize; + if (fromIndex >= data.size()) { + return Collections.emptyList();//空数组 + } + if (fromIndex < 0) { + return Collections.emptyList();//空数组 + } + int toIndex = nowPage * pageSize; + if (toIndex >= data.size()) { + toIndex = data.size(); + } + return data.subList(fromIndex, toIndex); + } + + public int getPageSize() { + return pageSize; + } + + public List getData() { + return data; + } + + public int getLastPage() { + return lastPage; + } + + public int getNowPage() { + return nowPage; + } + + public int getNextPage() { + return nextPage; + } + + public int getTotalPage() { + return totalPage; + } + + public int getTotalCount() { + return totalCount; + } + + public static void main(String[] args) { + Integer[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + List list = Arrays.asList(array); + + ListPageUtil listPageUtil = new ListPageUtil(list, 1, 4); + List pagedList = listPageUtil.getPagedList(); + System.out.println(pagedList); + } + +} diff --git a/src/main/resources/excel-template/员工导入失败数据导出模板.xlsx b/src/main/resources/excel-template/员工导入失败数据导出模板.xlsx index 30133bd..185e557 100644 Binary files a/src/main/resources/excel-template/员工导入失败数据导出模板.xlsx and b/src/main/resources/excel-template/员工导入失败数据导出模板.xlsx differ diff --git a/src/main/resources/excel-template/学生导入失败数据导出模板(1).xlsx b/src/main/resources/excel-template/学生导入失败数据导出模板(1).xlsx new file mode 100644 index 0000000..d44230a Binary files /dev/null and b/src/main/resources/excel-template/学生导入失败数据导出模板(1).xlsx differ diff --git a/src/main/resources/excel-template/教学实验报告导出模板.xlsx b/src/main/resources/excel-template/教学实验报告导出模板.xlsx deleted file mode 100644 index c2d3deb..0000000 Binary files a/src/main/resources/excel-template/教学实验报告导出模板.xlsx and /dev/null differ diff --git a/src/main/resources/excel-template/练习记录模板.xlsx b/src/main/resources/excel-template/练习记录模板.xlsx new file mode 100644 index 0000000..36b4162 Binary files /dev/null and b/src/main/resources/excel-template/练习记录模板.xlsx differ diff --git a/src/main/resources/excel-template/考核记录模板.xlsx b/src/main/resources/excel-template/考核记录模板.xlsx new file mode 100644 index 0000000..519379b Binary files /dev/null and b/src/main/resources/excel-template/考核记录模板.xlsx differ diff --git a/src/main/resources/excel-template/虚拟仿真实验报告导出模板.xlsx b/src/main/resources/excel-template/虚拟仿真实验报告导出模板.xlsx deleted file mode 100644 index 2ab5031..0000000 Binary files a/src/main/resources/excel-template/虚拟仿真实验报告导出模板.xlsx and /dev/null differ diff --git a/src/main/resources/mapper/tms/AchievementManagementDao.xml b/src/main/resources/mapper/tms/AchievementManagementDao.xml index c2a1330..20c8d1b 100644 --- a/src/main/resources/mapper/tms/AchievementManagementDao.xml +++ b/src/main/resources/mapper/tms/AchievementManagementDao.xml @@ -177,7 +177,8 @@ u.userName, re.score, re.submitTime, - r.eventId + r.eventId, + s.studentId FROM tms_experimental_report r INNER JOIN tms_experimental_teaching t ON t.id = r.projectId @@ -238,27 +239,34 @@ - SELECT schoolName, - experimental_class_name, - userName, - workNumber, - r.score, - r.recordId, - report.reportId, - r.submitTime, - stu.studentId, - t.id AS projectId, - experimental_name AS experimentalName + experimental_class_name, + userName, + workNumber, + r.score, + r.recordId, + report.reportId, + r.submitTime, + stu.studentId, + t.id AS projectId, + experimental_name AS experimentalName FROM tms_experimental_teaching t - INNER JOIN tms_experimental_report report ON report.projectId = t.id - INNER JOIN tms_project_record r ON r.recordId = report.eventId - INNER JOIN hr_user_info u ON u.userId = r.userId - INNER JOIN school s ON s.schoolId = u.schoolId - INNER JOIN student stu ON stu.userId = u.userId - WHERE t.id = #{id} - AND report.isdel = 0 + INNER JOIN tms_experimental_report report ON report.projectId = t.id + INNER JOIN tms_project_record r ON r.recordId = report.eventId + INNER JOIN hr_user_info u ON u.userId = r.userId + INNER JOIN school s ON s.schoolId = u.schoolId + INNER JOIN student stu ON stu.userId = u.userId + WHERE + + r.recordId IN ( + + #{recordId} + + ) + + + AND report.isdel = 0 + + SELECT is_hidden FROM tms_project_hidden WHERE project_id = #{projectId} + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/tms/ProjectRecordDao.xml b/src/main/resources/mapper/tms/ProjectRecordDao.xml index 8495e51..b143123 100644 --- a/src/main/resources/mapper/tms/ProjectRecordDao.xml +++ b/src/main/resources/mapper/tms/ProjectRecordDao.xml @@ -22,77 +22,80 @@ - + SELECT her.reportId as reportId, + her.projectId, + projectName, + her.score, + her.timeConsuming, + her.startTime, + her.creationTime as endTime, + her.className + FROM hr_experimental_report her + LEFT JOIN hr_project_management tp ON her.projectId = tp.projectId + WHERE her.studentId = #{pro.userid} + AND her.isdel = 0 + AND tp.projectPermissions = #{projectPermissions} + order by her.creationTime desc + - + + SELECT re.reportId, + projectName, + c.recordId, + r.score, + c.codeId, + r.startingTime, + r.submitTime, + r.timeSum, + c.userId, + t.systemId + FROM hr_experiment_code c + INNER JOIN hr_project_management t ON t.projectId = c.projectId + INNER JOIN tms_project_record r ON r.recordId = c.recordId + INNER JOIN tms_experimental_report re ON re.eventId = r.recordId + WHERE c.userId = #{userId} + AND projectPermissions = 0 + GROUP BY c.recordId DESC; + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/tms/StudentDao.xml b/src/main/resources/mapper/tms/StudentDao.xml index e421705..13cea29 100644 --- a/src/main/resources/mapper/tms/StudentDao.xml +++ b/src/main/resources/mapper/tms/StudentDao.xml @@ -28,6 +28,9 @@ u.schoolId AS schoolAppellationId, u.disableAccount, u.lastLoginTime, + u.phone, + u.email, + u.uniqueIdentificationAccount, s.roleId, s.workNumber as workNumber, s.isdel, @@ -43,7 +46,7 @@ AND u.isdel = 0 AND l.isdel = 0 AND s.isdel = 0 - AND (l.schoolName LIKE CONCAT('%',#{searchContent},'%') OR u.userName LIKE CONCAT('%',#{searchContent},'%')) + AND (l.schoolName LIKE CONCAT('%',#{searchContent},'%') OR u.userName LIKE CONCAT('%',#{searchContent},'%') OR u.account LIKE CONCAT('%',#{searchContent},'%') ) ORDER BY studentId DESC @@ -94,9 +97,9 @@ WHERE ) - INSERT INTO student(schoolId,userId,roleId,isdel,platformId) + INSERT INTO student(schoolId,userId,roleId,isdel,platformId,workNumber) VALUES - ( #{schoolId},#{userId},4,0,1 + ( #{schoolId},#{userId},#{roleId},#{isdel},#{platformId},#{workNumber} ) @@ -146,4 +149,8 @@ WHERE update student set workNumber = #{workNumber} where studentId = #{studentId} + + \ No newline at end of file diff --git a/src/main/resources/mapper/tms/SystemSetting.xml b/src/main/resources/mapper/tms/SystemSetting.xml index 1fefb9e..4c61eee 100644 --- a/src/main/resources/mapper/tms/SystemSetting.xml +++ b/src/main/resources/mapper/tms/SystemSetting.xml @@ -25,12 +25,12 @@ INSERT INTO staff (userId,schoolId,workNumber,staffGradeId,staffProfessionalArchitectureId,staffGradeName,staffProfessionalArchitectureName,platformId,roleId) VALUES - (#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeName},#{staffProfessionalArchitectureName},#{platformId},2) + (#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeName},#{staffProfessionalArchitectureName},#{platformId},#{roleId}) INSERT INTO staff (userId,schoolId,workNumber,staffGradeId,staffProfessionalArchitectureId,staffGradeName,staffProfessionalArchitectureName,platformId,roleId) VALUES - (#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeNameTwo},#{staffProfessionalArchitectureNameTwo},#{platformId},3) + (#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeNameTwo},#{staffProfessionalArchitectureNameTwo},#{platformId},#{roleId}) INSERT INTO staff (userId,schoolId,workNumber,staffGradeId,staffProfessionalArchitectureId,staffGradeName,staffProfessionalArchitectureName,platformId,roleId) diff --git a/src/main/resources/mapper/tms/UserDao.xml b/src/main/resources/mapper/tms/UserDao.xml index ba71046..f7508ac 100644 --- a/src/main/resources/mapper/tms/UserDao.xml +++ b/src/main/resources/mapper/tms/UserDao.xml @@ -19,6 +19,7 @@ u.IDNumber, u.documentType, u.educationDegree, + u.userAvatars, pro.provinceId, pro.provinceName, s.schoolId, diff --git a/src/main/resources/mapper/tms/UserInfoDao.xml b/src/main/resources/mapper/tms/UserInfoDao.xml index 5ec1bd1..b8160b5 100644 --- a/src/main/resources/mapper/tms/UserInfoDao.xml +++ b/src/main/resources/mapper/tms/UserInfoDao.xml @@ -146,7 +146,7 @@ values (#{userName}, #{uniqueIdentificationAccount}, #{phone}, #{account},#{password},#{roleId}, - (SELECT schoolId FROM school WHERE schoolName = #{schoolAppellationName}),now(),#{token}) + #{schoolId},now(),#{token}) INSERT INTO hr_user_info ( account, userName, roleId, phone, email, uniqueIdentificationAccount, schoolId,creationTime,password,token) @@ -291,4 +291,8 @@ SELECT userId FROM hr_user_info where token = #{token} and isdel = 0 + + \ No newline at end of file