diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualCompPoint/controller/AnnualCompPointController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualCompPoint/controller/AnnualCompPointController.java index b9adf14e..8e8020fa 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualCompPoint/controller/AnnualCompPointController.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualCompPoint/controller/AnnualCompPointController.java @@ -33,8 +33,10 @@ import org.jeecg.modules.demo.annualcomp.service.IAnnualCompService; import org.jeecg.modules.demo.annualcompaward.entity.AnnualCompAward; import org.jeecg.modules.demo.annualcompaward.service.IAnnualCompAwardService; import org.jeecg.modules.demo.annualcompetitionprojectregistration.entity.AnnualCompetitionProjectRegistration; +import org.jeecg.modules.demo.annualcompetitionprojectregistration.entity.InstructorSheet; import org.jeecg.modules.demo.annualcompetitionprojectregistration.entity.TeamManagement; import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.IAnnualCompetitionProjectRegistrationService; +import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.IInstructorSheetService; import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.ITeamManagementService; import org.jeecg.modules.demo.awardpersion.entity.AwardPersion; import org.jeecg.modules.demo.awardpersion.entity.AwardPersionMb; @@ -53,6 +55,7 @@ import org.jeecg.modules.demo.scorepersion.entity.ScorePersion; import org.jeecg.modules.demo.scorepersion.service.IScorePersionService; import org.jeecg.modules.demo.upfile_persion.entity.UpfilePersion; import org.jeecg.modules.demo.upfile_persion.service.IUpfilePersionService; +import org.jeecg.modules.system.entity.SysDict; import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.service.ISysUserService; import org.jeecgframework.poi.excel.ExcelImportUtil; @@ -133,6 +136,9 @@ public class AnnualCompPointController extends JeecgController importExcel(HttpServletRequest request, HttpServletResponse response,@RequestParam(name = "ndbsxmid", required = true) String ndbsxmid) { + //获取年度比赛项目 + AnnualCompPoint annualCompPointss = annualCompPointService.getById(ndbsxmid); + //获取队伍的人数 + int teamnumber =annualCompPointss.getTeacherNumber(); + //获取教师熟练 + int teachernumber = annualCompPointss.getTeacherNumber(); MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map fileMap = multipartRequest.getFileMap(); for (Map.Entry entity : fileMap.entrySet()) { @@ -1077,48 +1089,191 @@ public class AnnualCompPointController extends JeecgController list = ExcelImportUtil.importExcel(file.getInputStream(), AnnualCompPointMb.class, params); - for (int i = 0 ; i < list.size();i++){ - QueryWrapper qw = new QueryWrapper<>(); - qw.eq("work_no",list.get(i).getStudentcode()); - List listsys = sysUserService.list(qw); - //SysUser sysUser = sysUserService.getUserByName(list.get(i).getStudentcode()); - if(listsys.size()==0){ - return Result.error("文件导入失败:第"+(i+1)+"行学生学号不存在"); + //个人赛直接导入 + if(annualCompPointss.getEntryForm().equals("N")) { + List list = ExcelImportUtil.importExcel(file.getInputStream(), AnnualCompPointMb.class, params); + for (int i = 0; i < list.size(); i++) { + QueryWrapper qw = new QueryWrapper<>(); + qw.eq("work_no", list.get(i).getStudentcode()); + List listsys = sysUserService.list(qw); + if (listsys.size() == 0) { + return Result.error("文件导入失败:第" + (i + 1) + "行学生学号不存在"); + } + // 使用 String 的 split 方法将字符串分割成字符串数组 + String[] itemsArray = list.get(i).getTeacherName().split("%"); + //判断老师个数信息是否正确 + if(itemsArray.length>teachernumber){ + return Result.error("文件导入失败:第" + (i + 1) + "老师个数信息有误"); + } } + AnnualCompPoint annualCompPoint = annualCompPointService.getById(ndbsxmid); + String annualId = annualCompService.getById(annualCompPoint.getAnnualCompId()).getAnnualid(); + String annualName = annualService.query().eq("id", annualId).one().getAnnualName(); + for (int k = 0; k < list.size(); k++) { + //生成报名编号 + String enrollCode = getEnrollCode(annualName + "GR"); + AnnualCompetitionProjectRegistration ar = new AnnualCompetitionProjectRegistration(); + ar.setAnnualCompid(ndbsxmid); + ar.setEnrollCode(enrollCode); + ar.setEnrollStatic("2"); + ar.setBackinfo(null); + ar.setEntryFormat("0"); + ar.setTeamName(null); + annualCompetitionProjectRegistrationService.save(ar); + TeamManagement tm = new TeamManagement(); + tm.setEnrollCode(enrollCode); + QueryWrapper qw1 = new QueryWrapper<>(); + qw1.eq("work_no", list.get(k).getStudentcode()); + List listsys1 = sysUserService.list(qw1); + tm.setUserId(listsys1.get(0).getId()); + tm.setCaptain("0"); + teamManagementService.save(tm); + //开始处理指导老师数据 + //创建指导老师类型的成字符串数组 + String[] teachertypes = list.get(k).getTeacherType().split("%"); + //创建指导老师姓名的成字符串数组 + String[] teacherNames = list.get(k).getTeacherName().split("%"); + //创建指导老师学历的成字符串数组 + String[] teacherXls = list.get(k).getTeacherXl().split("%"); + //创建指导老师职称的成字符串数组 + String[] teacherZcs = list.get(k).getTeacherZc().split("%"); + //创建指导老师专业的成字符串数组 + String[] teacherZys = list.get(k).getTeacherZy().split("%"); + //创建指导老师研究方向的成字符串数组 + String[] teacherYjfxs = list.get(k).getTeacherYjfx().split("%"); + //创建指导老师手机号的成字符串数组 + String[] teacherPhone = list.get(k).getTeacherPhone().split("%"); + //开始将这些字符串转化成list + List teachertypelist = Arrays.asList(teachertypes); + List teacherNamelist = Arrays.asList(teacherNames); + List teacherXllist = Arrays.asList(teacherXls); + List teacherZclist = Arrays.asList(teacherZcs); + List teacherZysList = Arrays.asList(teacherZys); + List teacherYjfxlist = Arrays.asList(teacherYjfxs); + List teacherPhonelist = Arrays.asList(teacherPhone); + for (int c =0;c list = ExcelImportUtil.importExcel(file.getInputStream(), AnnualCompPointMb.class, params); + for (int i = 0; i < list.size(); i++) { + QueryWrapper qw = new QueryWrapper<>(); + qw.in("work_no", Arrays.asList(list.get(i).getStudentcode().split("%"))); + List listsys = sysUserService.list(qw); + System.out.println(Arrays.asList(list.get(i).getStudentcode().split("%"))); + System.out.println(list.get(i).getStudentcode().split("%").length); + if (listsys.size() != list.get(i).getStudentcode().split("%").length) { + return Result.error("文件导入失败:第" + (i + 1) + "行学生学号不存在"); + } + // 使用 String 的 split 方法将字符串分割成字符串数组 + String[] itemsArray = list.get(i).getTeacherName().split("%"); + //判断老师个数信息是否正确 + if(itemsArray.length>teachernumber){ + return Result.error("文件导入失败:第" + (i + 1) + "老师个数信息有误"); + } + } + AnnualCompPoint annualCompPoint = annualCompPointService.getById(ndbsxmid); + String annualId = annualCompService.getById(annualCompPoint.getAnnualCompId()).getAnnualid(); + String annualName = annualService.query().eq("id", annualId).one().getAnnualName(); + for (int k = 0; k < list.size(); k++) { + //生成报名编号 + String enrollCode = getEnrollCode(annualName + "TD"); + AnnualCompetitionProjectRegistration ar = new AnnualCompetitionProjectRegistration(); + ar.setAnnualCompid(ndbsxmid); + ar.setEnrollCode(enrollCode); + ar.setEnrollStatic("2"); + ar.setBackinfo(null); + ar.setEntryFormat("0"); + ar.setTeamName(null); + annualCompetitionProjectRegistrationService.save(ar); + //将学生信息姓名放入list + String[] teaname = list.get(k).getStudentname().split("%"); + List teamnamelist =Arrays.asList(teaname); + //将学生的学号放入list + String[] teamworkno = list.get(k).getStudentcode().split("%"); + List teamworknolist =Arrays.asList(teamworkno); + for(int a =0;a qw1 = new QueryWrapper<>(); + qw1.eq("work_no",teamworknolist.get(a)); + List listsys1 = sysUserService.list(qw1); + tm.setUserId(listsys1.get(0).getId()); + if (a==0) { + tm.setCaptain("0"); + } + teamManagementService.save(tm); + } + //开始处理指导老师数据 + //创建指导老师类型的成字符串数组 + String[] teachertypes = list.get(k).getTeacherType().split("%"); + //创建指导老师姓名的成字符串数组 + String[] teacherNames = list.get(k).getTeacherName().split("%"); + //创建指导老师学历的成字符串数组 + String[] teacherXls = list.get(k).getTeacherXl().split("%"); + //创建指导老师职称的成字符串数组 + String[] teacherZcs = list.get(k).getTeacherZc().split("%"); + //创建指导老师专业的成字符串数组 + String[] teacherZys = list.get(k).getTeacherZy().split("%"); + //创建指导老师研究方向的成字符串数组 + String[] teacherYjfxs = list.get(k).getTeacherYjfx().split("%"); + //创建指导老师手机号的成字符串数组 + String[] teacherPhone = list.get(k).getTeacherPhone().split("%"); + //开始将这些字符串转化成list + List teachertypelist = Arrays.asList(teachertypes); + List teacherNamelist = Arrays.asList(teacherNames); + List teacherXllist = Arrays.asList(teacherXls); + List teacherZclist = Arrays.asList(teacherZcs); + List teacherZysList = Arrays.asList(teacherZys); + List teacherYjfxlist = Arrays.asList(teacherYjfxs); + List teacherPhonelist = Arrays.asList(teacherPhone); + for (int c =0;c qw1 = new QueryWrapper<>(); - qw1.eq("work_no",list.get(k).getStudentcode()); - List listsys1 = sysUserService.list(qw1); - tm.setUserId(listsys1.get(0).getId()); - tm.setCaptain("0"); - teamManagementService.save(tm); - } - //update-begin-author:taoyan date:20190528 for:批量插入数据 - long start = System.currentTimeMillis(); - //400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒 - //1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒 - log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒"); - //update-end-author:taoyan date:20190528 for:批量插入数据 - return Result.ok("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { - //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示 String msg = e.getMessage(); log.error(msg, e); if(msg!=null && msg.indexOf("Duplicate entry")>=0){ @@ -1126,7 +1281,6 @@ public class AnnualCompPointController extends JeecgController