夏文涛 преди 11 месеца
родител
ревизия
33c8587b55
променени са 1 файла, в които са добавени 27 реда и са изтрити 29 реда
  1. 27 29
      src/main/java/com/template/controller/WelcomeStudentController.java

+ 27 - 29
src/main/java/com/template/controller/WelcomeStudentController.java

@@ -132,19 +132,19 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
         ws.setCardId(isr.getCardId());
         //region 校验身份证号 并根据身份证号获取出生年月和性别
         boolean isValidate = CardUtils.validateIdCard(isr.getCardId());//身份证是否合法
-        if(!isValidate){
+        if (!isValidate) {
             return CommonResult.fail("身份证不合法");
         }
         String sex = CardUtils.getSexByIdCard(isr.getCardId());
-        if(!StringUtils.hasText(isr.getSex())){
+        if (!StringUtils.hasText(isr.getSex())) {
             ws.setSex(sex);
-        }else {
+        } else {
             ws.setSex(isr.getSex());
         }
         String birthday = CardUtils.getBirthdayByIdCard(isr.getCardId());
-        if(!StringUtils.hasText(isr.getBirthday())){
+        if (!StringUtils.hasText(isr.getBirthday())) {
             ws.setBirthday(birthday);
-        }else {
+        } else {
             ws.setBirthday(isr.getBirthday());
         }
         //endregion
@@ -477,20 +477,20 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
     }
 
     @Override
-    public CommonResult queryPageStudents(String userId,int currentPage, int pageCount, Integer collegeId, Integer majorId, Integer classstrId, String trafficMethod, String name) {
+    public CommonResult queryPageStudents(String userId, int currentPage, int pageCount, Integer collegeId, Integer majorId, Integer classstrId, String trafficMethod, String name) {
         IPage<StudentPageVo> pages = new Page<>();
-        PageUtils<StudentPageVo> result =new PageUtils<>(pages);
+        PageUtils<StudentPageVo> result = new PageUtils<>(pages);
         WelcomeAccount wa = welcomeAccountService.getManageById(userId);
         if (wa == null) {
             return CommonResult.fail("当前账户已失效,无权限查看");
         }
         List<String> collegeIds = Arrays.asList(wa.getCollegeId().split(","));
-        if(collegeId != null && collegeId.intValue() > 0){
+        if (collegeId != null && collegeId.intValue() > 0) {
             if (!collegeIds.contains(String.valueOf(collegeId))) {
                 pages.setCurrent(currentPage);
                 pages.setSize(pageCount);
                 return CommonResult.ok(result);
-            }else {
+            } else {
                 collegeIds = new ArrayList<>();
                 collegeIds.add(String.valueOf(collegeId));
             }
@@ -805,7 +805,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
     @Override
     @Transactional(rollbackFor = {Exception.class})
     public CommonResult deleteStudentInfo(int id) throws Exception {
-        System.out.println("删除了学生信息:"+id);
+        System.out.println("删除了学生信息:" + id);
         WelcomeStudent ws = welcomeStudentService.getManageById(id);
         if (ws == null) {
             return CommonResult.fail("学生信息已失效,无法进行删除操作!");
@@ -902,7 +902,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
             for (WelcomeStudent ws : result) {
                 Optional<WelcomeStudent> ows = existStudents.stream().filter(e -> e.getCardId().equals(ws.getCardId())).findFirst();
                 if (ows != null && ows.isPresent()) {
-                    sb.append(ows.get().getName() + ows.get().getCardId()+"数据在数据库中已存在;");
+                    sb.append(ows.get().getName() + ows.get().getCardId() + "数据在数据库中已存在;");
                     ws.setId(ows.get().getId());
                     ws.setAdmissNum(ws.getAdmissNum());//录取号
                     ws.setName(ws.getName());//姓名
@@ -944,7 +944,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
         boolean resultBool = welcomeStudentService.saveOrUpdateBatch(result);
 
         System.out.println("导入学生1");
-        return resultBool ? CommonResult.ok("导入成功:"+ sb.toString()) : CommonResult.fail("导入失败");
+        return resultBool ? CommonResult.ok("导入成功:" + sb.toString()) : CommonResult.fail("导入失败");
     }
 
     /**
@@ -1069,15 +1069,15 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                         String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
                         //region 校验身份证号 并根据身份证号获取出生年月和性别
                         boolean isValidate = CardUtils.validateIdCard(cardId);//身份证是否合法
-                        if(!isValidate){
+                        if (!isValidate) {
                             return CommonResult.fail("录取编号为" + assNum + "的身份证不合法");
                         }
                         String sex = CardUtils.getSexByIdCard(cardId);
-                        if(sex != null){
+                        if (sex != null) {
                             studentData.setSex(sex);
                         }
                         String birthday = CardUtils.getBirthdayByIdCard(cardId);
-                        if(birthday != null){
+                        if (birthday != null) {
                             studentData.setBirthday(birthday);
                         }
                         //endregion
@@ -1346,15 +1346,15 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                         String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
                         //region 校验身份证号 并根据身份证号获取出生年月和性别
                         boolean isValidate = CardUtils.validateIdCard(cardId);//身份证是否合法
-                        if(!isValidate){
+                        if (!isValidate) {
                             return CommonResult.fail("录取编号为" + assNum + "的身份证不合法");
                         }
                         String sex = CardUtils.getSexByIdCard(cardId);
-                        if(sex != null){
+                        if (sex != null) {
                             studentData.setSex(sex);
                         }
                         String birthday = CardUtils.getBirthdayByIdCard(cardId);
-                        if(birthday != null){
+                        if (birthday != null) {
                             studentData.setBirthday(birthday);
                         }
                         //endregion
@@ -1374,14 +1374,14 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                         }
 
                         String major = dataFormatter.formatCellValue(row.getCell(6));//专业
-                        Optional<WelcomeOrg> omwo = ws.stream().filter(e -> e.getName().equals(major)).findFirst();
+                        Optional<WelcomeOrg> omwo = ws.stream().filter(e -> owo != null && owo.isPresent() && e.getParentId().intValue() == owo.get().getId().intValue() && e.getName().equals(major)).findFirst();
                         if (omwo != null && omwo.isPresent()) {
                             studentData.setMajor(major);
                             studentData.setMajorId(omwo.get().getId());
                         }
 
                         String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
-                        Optional<WelcomeOrg> ocwo = ws.stream().filter(e -> e.getName().equals(classstr)).findFirst();
+                        Optional<WelcomeOrg> ocwo = ws.stream().filter(e -> omwo != null && omwo.isPresent() && e.getParentId().intValue() == omwo.get().getId().intValue() && e.getName().equals(classstr)).findFirst();
                         if (ocwo != null && ocwo.isPresent()) {
                             studentData.setClassstr(classstr);
                             studentData.setClassstrId(ocwo.get().getId());
@@ -1508,7 +1508,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
     }
 
     @Override
-    public void welcomeStudentExport(String userId,HttpServletResponse response, Integer collegeId, Integer majorId, Integer classstrId, String trafficMethod, String name) {
+    public void welcomeStudentExport(String userId, HttpServletResponse response, Integer collegeId, Integer majorId, Integer classstrId, String trafficMethod, String name) {
         Workbook workbook = new XSSFWorkbook();
         Sheet sheet = workbook.createSheet("学生信息");
         WelcomeAccount wa = welcomeAccountService.getManageById(userId);
@@ -1517,11 +1517,11 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
             ExcelUtils.excelDownload(workbook, "学生信息.xlsx", response);
         }
         List<String> collegeIds = Arrays.asList(wa.getCollegeId().split(","));
-        if(collegeId != null && collegeId.intValue() > 0){
+        if (collegeId != null && collegeId.intValue() > 0) {
             if (!collegeIds.contains(String.valueOf(collegeId))) {
 
                 ExcelUtils.excelDownload(workbook, "学生信息.xlsx", response);
-            }else {
+            } else {
                 collegeIds = new ArrayList<>();
                 collegeIds.add(String.valueOf(collegeId));
             }
@@ -1589,7 +1589,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
 //        BigDecimal total = new BigDecimal(enrollmentTotal);
 //        BigDecimal bedTotal = new BigDecimal(checkInBedTotal);
 //        BigDecimal bigDecimal = bedTotal.divide(total).setScale(4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
-        Double result = ((double)checkInBedTotal / enrollmentTotal) * 100;
+        Double result = ((double) checkInBedTotal / enrollmentTotal) * 100;
         String registrationRate = String.format("%.2f", result);
 
 
@@ -1678,8 +1678,8 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
     @Override
     public CommonResult queryStudentByToken(String userId) {
         WelcomeStudent student = welcomeStudentService.getManageById(Integer.valueOf(userId));
-        if(student == null){
-            return CommonResult.fail("558","学生信息已失效,查询失败");
+        if (student == null) {
+            return CommonResult.fail("558", "学生信息已失效,查询失败");
         }
 
         //家庭成员
@@ -1714,7 +1714,6 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
         student.setAvs(avs);
 
 
-
         //时间段
         List<ArriveTimeVo> atvs = new ArrayList<>();
         List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
@@ -1784,7 +1783,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
     public CommonResult queryStudentInfo(String admissNum) {
         WelcomeStudent ws = welcomeStudentService.getDataByNum(admissNum);
         if (ws == null) {
-            return CommonResult.fail("558","当前学生信息已失效,查询失败");
+            return CommonResult.fail("558", "当前学生信息已失效,查询失败");
         }
 
         //家庭成员
@@ -1819,7 +1818,6 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
         ws.setAvs(avs);
 
 
-
         //时间段
         List<ArriveTimeVo> atvs = new ArrayList<>();
         List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();