liu 1 year ago
parent
commit
99b2614692
1 changed files with 37 additions and 44 deletions
  1. 37 44
      src/main/java/com/template/controller/WelcomeBedController.java

+ 37 - 44
src/main/java/com/template/controller/WelcomeBedController.java

@@ -307,7 +307,8 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
         List<WelcomeBuild> wbils = welcomeBuildService.list(null);
         List<WelcomeBuild> wbils = welcomeBuildService.list(null);
         List<WelcomeDormitory> wds = welcomeDormitoryService.list(null);
         List<WelcomeDormitory> wds = welcomeDormitoryService.list(null);
         List<WelcomeSchool> ws = welcomeSchoolService.list(null);
         List<WelcomeSchool> ws = welcomeSchoolService.list(null);
-
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
         //读取第一张sheet
         //读取第一张sheet
         HSSFSheet sheetAt = sheets.getSheetAt(0);
         HSSFSheet sheetAt = sheets.getSheetAt(0);
         DataFormatter dataFormatter = new DataFormatter();
         DataFormatter dataFormatter = new DataFormatter();
@@ -345,29 +346,25 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
                             return CommonResult.fail("导入数据第五列为床位性别");
                             return CommonResult.fail("导入数据第五列为床位性别");
                         }
                         }
 
 
-                        String grade = dataFormatter.formatCellValue(row.getCell(5));//所属年级
-                        if (!grade.equals("所属年级")) {
-                            return CommonResult.fail("导入数据第六列为所属年级");
-                        }
-                        String college = dataFormatter.formatCellValue(row.getCell(6));//所属学院
+                        String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院
                         if (!college.equals("所属学院")) {
                         if (!college.equals("所属学院")) {
-                            return CommonResult.fail("导入数据第列为所属学院");
+                            return CommonResult.fail("导入数据第六列为所属学院");
                         }
                         }
-                        String major = dataFormatter.formatCellValue(row.getCell(7));//所属专业
+                        String major = dataFormatter.formatCellValue(row.getCell(6));//所属专业
                         if (!major.equals("所属专业")) {
                         if (!major.equals("所属专业")) {
-                            return CommonResult.fail("导入数据第列为所属专业");
+                            return CommonResult.fail("导入数据第列为所属专业");
                         }
                         }
-                        String classstr = dataFormatter.formatCellValue(row.getCell(8));//所属班级
+                        String classstr = dataFormatter.formatCellValue(row.getCell(7));//所属班级
                         if (!classstr.equals("所属班级")) {
                         if (!classstr.equals("所属班级")) {
-                            return CommonResult.fail("导入数据第列为所属班级");
+                            return CommonResult.fail("导入数据第列为所属班级");
                         }
                         }
-                        String instructor = dataFormatter.formatCellValue(row.getCell(9));//辅导员
+                        String instructor = dataFormatter.formatCellValue(row.getCell(8));//辅导员
                         if (!instructor.equals("辅导员")) {
                         if (!instructor.equals("辅导员")) {
-                            return CommonResult.fail("导入数据第列为辅导员");
+                            return CommonResult.fail("导入数据第列为辅导员");
                         }
                         }
-                        String remark = dataFormatter.formatCellValue(row.getCell(10));//备注
+                        String remark = dataFormatter.formatCellValue(row.getCell(9));//备注
                         if (!remark.equals("备注")) {
                         if (!remark.equals("备注")) {
-                            return CommonResult.fail("导入数据第十列为备注");
+                            return CommonResult.fail("导入数据第十列为备注");
                         }
                         }
 
 
                     } else {
                     } else {
@@ -383,12 +380,11 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
                         }
                         }
 
 
                         String sex = dataFormatter.formatCellValue(row.getCell(4));//床位性别
                         String sex = dataFormatter.formatCellValue(row.getCell(4));//床位性别
-                        String grade = dataFormatter.formatCellValue(row.getCell(5));//所属年级
-                        String college = dataFormatter.formatCellValue(row.getCell(6));//所属学院
-                        String major = dataFormatter.formatCellValue(row.getCell(7));//所属专业
-                        String classstr = dataFormatter.formatCellValue(row.getCell(8));//所属班级
-                        String instructor = dataFormatter.formatCellValue(row.getCell(9));//辅导员
-                        String remark = dataFormatter.formatCellValue(row.getCell(10));//备注
+                        String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院
+                        String major = dataFormatter.formatCellValue(row.getCell(6));//所属专业
+                        String classstr = dataFormatter.formatCellValue(row.getCell(7));//所属班级
+                        String instructor = dataFormatter.formatCellValue(row.getCell(8));//辅导员
+                        String remark = dataFormatter.formatCellValue(row.getCell(9));//备注
 
 
                         //校区
                         //校区
                         if (ws != null && ws.size() > 0) {
                         if (ws != null && ws.size() > 0) {
@@ -471,7 +467,7 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
                         bedData.setRemark(remark);
                         bedData.setRemark(remark);
                         bedData.setRetentionState(1);
                         bedData.setRetentionState(1);
                         bedData.setInstructor(instructor);
                         bedData.setInstructor(instructor);
-                        bedData.setGrade(Integer.valueOf(grade));
+                        bedData.setGrade(year);
                         result.add(bedData);
                         result.add(bedData);
                     }
                     }
                 }
                 }
@@ -483,6 +479,7 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
         return CommonResult.ok(result);
         return CommonResult.ok(result);
     }
     }
 
 
+
     /**
     /**
      * xls文件读取方法
      * xls文件读取方法
      *
      *
@@ -503,7 +500,8 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
         //读取第一张sheet
         //读取第一张sheet
         XSSFSheet sheetAt = sheets.getSheetAt(0);
         XSSFSheet sheetAt = sheets.getSheetAt(0);
         DataFormatter dataFormatter = new DataFormatter();
         DataFormatter dataFormatter = new DataFormatter();
-
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
         try {
         try {
             //rowNum = 3 从第三行开始获取值
             //rowNum = 3 从第三行开始获取值
             //sheetAt.getLastRowNum():从0开始统计数量 所以得+1
             //sheetAt.getLastRowNum():从0开始统计数量 所以得+1
@@ -537,29 +535,25 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
                             return CommonResult.fail("导入数据第五列为床位性别");
                             return CommonResult.fail("导入数据第五列为床位性别");
                         }
                         }
 
 
-                        String grade = dataFormatter.formatCellValue(row.getCell(5));//所属年级
-                        if (!grade.equals("所属年级")) {
-                            return CommonResult.fail("导入数据第六列为所属年级");
-                        }
-                        String college = dataFormatter.formatCellValue(row.getCell(6));//所属学院
+                        String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院
                         if (!college.equals("所属学院")) {
                         if (!college.equals("所属学院")) {
-                            return CommonResult.fail("导入数据第列为所属学院");
+                            return CommonResult.fail("导入数据第六列为所属学院");
                         }
                         }
-                        String major = dataFormatter.formatCellValue(row.getCell(7));//所属专业
+                        String major = dataFormatter.formatCellValue(row.getCell(6));//所属专业
                         if (!major.equals("所属专业")) {
                         if (!major.equals("所属专业")) {
-                            return CommonResult.fail("导入数据第列为所属专业");
+                            return CommonResult.fail("导入数据第列为所属专业");
                         }
                         }
-                        String classstr = dataFormatter.formatCellValue(row.getCell(8));//所属班级
+                        String classstr = dataFormatter.formatCellValue(row.getCell(7));//所属班级
                         if (!classstr.equals("所属班级")) {
                         if (!classstr.equals("所属班级")) {
-                            return CommonResult.fail("导入数据第列为所属班级");
+                            return CommonResult.fail("导入数据第列为所属班级");
                         }
                         }
-                        String instructor = dataFormatter.formatCellValue(row.getCell(9));//辅导员
+                        String instructor = dataFormatter.formatCellValue(row.getCell(8));//辅导员
                         if (!instructor.equals("辅导员")) {
                         if (!instructor.equals("辅导员")) {
-                            return CommonResult.fail("导入数据第列为辅导员");
+                            return CommonResult.fail("导入数据第列为辅导员");
                         }
                         }
-                        String remark = dataFormatter.formatCellValue(row.getCell(10));//备注
+                        String remark = dataFormatter.formatCellValue(row.getCell(9));//备注
                         if (!remark.equals("备注")) {
                         if (!remark.equals("备注")) {
-                            return CommonResult.fail("导入数据第十列为备注");
+                            return CommonResult.fail("导入数据第十列为备注");
                         }
                         }
 
 
                     } else {
                     } else {
@@ -575,12 +569,11 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
                         }
                         }
 
 
                         String sex = dataFormatter.formatCellValue(row.getCell(4));//床位性别
                         String sex = dataFormatter.formatCellValue(row.getCell(4));//床位性别
-                        String grade = dataFormatter.formatCellValue(row.getCell(5));//所属年级
-                        String college = dataFormatter.formatCellValue(row.getCell(6));//所属学院
-                        String major = dataFormatter.formatCellValue(row.getCell(7));//所属专业
-                        String classstr = dataFormatter.formatCellValue(row.getCell(8));//所属班级
-                        String instructor = dataFormatter.formatCellValue(row.getCell(9));//辅导员
-                        String remark = dataFormatter.formatCellValue(row.getCell(10));//备注
+                        String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院
+                        String major = dataFormatter.formatCellValue(row.getCell(6));//所属专业
+                        String classstr = dataFormatter.formatCellValue(row.getCell(7));//所属班级
+                        String instructor = dataFormatter.formatCellValue(row.getCell(8));//辅导员
+                        String remark = dataFormatter.formatCellValue(row.getCell(9));//备注
 
 
                         //校区
                         //校区
                         if (ws != null && ws.size() > 0) {
                         if (ws != null && ws.size() > 0) {
@@ -663,7 +656,7 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
                         bedData.setRemark(remark);
                         bedData.setRemark(remark);
                         bedData.setRetentionState(1);
                         bedData.setRetentionState(1);
                         bedData.setInstructor(instructor);
                         bedData.setInstructor(instructor);
-                        bedData.setGrade(Integer.valueOf(grade));
+                        bedData.setGrade(year);
                         result.add(bedData);
                         result.add(bedData);
                     }
                     }
                 }
                 }