liu пре 1 година
родитељ
комит
1b969cc904

+ 4 - 0
src/main/java/com/template/controller/WelcomeBuildController.java

@@ -226,6 +226,8 @@ public class WelcomeBuildController implements WelcomeBuildControllerAPI {
                         Optional<WelcomeBuild> ob = wb.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build)).findFirst();
                         if (ob != null && ob.isPresent()) {
                             buildData.setId(ob.get().getId());
+                        }else {
+                            return CommonResult.fail("第"+rowNum+1+"行,已存在该楼栋");
                         }
 
                         buildData.setSchool(school);
@@ -317,6 +319,8 @@ public class WelcomeBuildController implements WelcomeBuildControllerAPI {
                         Optional<WelcomeBuild> ob = wb.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build)).findFirst();
                         if (ob != null && ob.isPresent()) {
                             buildData.setId(ob.get().getId());
+                        }else {
+                            return CommonResult.fail("第"+rowNum+1+"行,已存在该楼栋");
                         }
 
                         buildData.setSchool(school);

+ 80 - 107
src/main/java/com/template/controller/WelcomeDormitoryController.java

@@ -288,7 +288,10 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
                     }
                 }
             }
-            welcomeDormitoryService.updateBatchById(welcomeDormitories);
+            if (ObjectUtils.isNotEmpty(welcomeDormitories)) {
+                welcomeDormitoryService.updateBatchById(welcomeDormitories);
+            }
+
         }
 
 
@@ -382,79 +385,68 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
                     //然后poi会根据字符串读取它
                     //第一行数据获取月份
                     if (rowNum == 0) {
-                        String number = dataFormatter.formatCellValue(row.getCell(0));//序号
-                        if (!number.equals("序号")) {
-                            return CommonResult.fail("导入数据第一列为序号");
-                        }
-                        String school = dataFormatter.formatCellValue(row.getCell(1));//校区名称
+                        String school = dataFormatter.formatCellValue(row.getCell(0));//校区名称
                         if (!school.equals("校区名称")) {
-                            return CommonResult.fail("导入数据第列为校区名称");
+                            return CommonResult.fail("导入数据第一列为校区名称");
                         }
-                        String build = dataFormatter.formatCellValue(row.getCell(2));//楼栋名称
+                        String build = dataFormatter.formatCellValue(row.getCell(1));//楼栋名称
                         if (!build.equals("楼栋名称")) {
-                            return CommonResult.fail("导入数据第列为楼栋名称");
+                            return CommonResult.fail("导入数据第列为楼栋名称");
                         }
-                        String dormitory = dataFormatter.formatCellValue(row.getCell(3));//寝室号
+                        String dormitory = dataFormatter.formatCellValue(row.getCell(2));//寝室号
                         if (!dormitory.equals("寝室号")) {
-                            return CommonResult.fail("导入数据第列为寝室号");
+                            return CommonResult.fail("导入数据第列为寝室号");
                         }
-                        String sex = dataFormatter.formatCellValue(row.getCell(4));//寝室性别
+                        String sex = dataFormatter.formatCellValue(row.getCell(3));//寝室性别
                         if (!sex.equals("寝室性别")) {
-                            return CommonResult.fail("导入数据第列为寝室性别");
+                            return CommonResult.fail("导入数据第列为寝室性别");
                         }
-                        String grade = dataFormatter.formatCellValue(row.getCell(5));//所属年级
+                        String grade = dataFormatter.formatCellValue(row.getCell(4));//所属年级
                         if (!grade.equals("所属年级")) {
-                            return CommonResult.fail("导入数据第列为所属年级");
+                            return CommonResult.fail("导入数据第列为所属年级");
                         }
-                        String college = dataFormatter.formatCellValue(row.getCell(6));//所属学院
+                        String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院
                         if (!college.equals("所属学院")) {
-                            return CommonResult.fail("导入数据第列为所属学院");
+                            return CommonResult.fail("导入数据第列为所属学院");
                         }
-                        String bedNum = dataFormatter.formatCellValue(row.getCell(7));//床位数
+                        String bedNum = dataFormatter.formatCellValue(row.getCell(6));//床位数
                         if (!bedNum.equals("床位数")) {
-                            return CommonResult.fail("导入数据第八列为床位数");
-                        }
-                        String freeBedNumber = dataFormatter.formatCellValue(row.getCell(8));//空闲床位数
-                        if (!freeBedNumber.equals("空闲床位数")) {
-                            return CommonResult.fail("导入数据第九列为空闲床位数");
-                        }
-                        String status = dataFormatter.formatCellValue(row.getCell(9));//入住情况
-                        if (!status.equals("入住情况")) {
-                            return CommonResult.fail("导入数据第十列为入住情况");
+                            return CommonResult.fail("导入数据第七列为床位数");
                         }
-                        String remark = dataFormatter.formatCellValue(row.getCell(10));//备注
+                        String remark = dataFormatter.formatCellValue(row.getCell(7));//备注
                         if (!remark.equals("备注")) {
-                            return CommonResult.fail("导入数据第十一列为备注");
-                        }
-                        String retentionState = dataFormatter.formatCellValue(row.getCell(11));//是否保留
-                        if (!retentionState.equals("是否保留")) {
-                            return CommonResult.fail("导入数据第十二列为是否保留");
+                            return CommonResult.fail("导入数据第列八为备注");
                         }
+
                     } else {
-                        String school = dataFormatter.formatCellValue(row.getCell(1));//校区名称
-                        String build = dataFormatter.formatCellValue(row.getCell(2));//楼栋名称
-                        String dormitory = dataFormatter.formatCellValue(row.getCell(3));//寝室号
+                        String school = dataFormatter.formatCellValue(row.getCell(0));//校区名称
+                        String build = dataFormatter.formatCellValue(row.getCell(1));//楼栋名称
+                        String dormitory = dataFormatter.formatCellValue(row.getCell(2));//寝室号
                         WelcomeDormitory wd = new WelcomeDormitory();
                         Optional<WelcomeDormitory> owelcomeDormitory = wds.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build) && e.getDormitory().equals(dormitory)).findFirst();
                         if (owelcomeDormitory != null && owelcomeDormitory.isPresent()) {
                             wd.setId(owelcomeDormitory.get().getId());
+                        }else {
+                            return CommonResult.fail("第"+rowNum+1+"行,已存在该宿舍");
                         }
 
-                        String sex = dataFormatter.formatCellValue(row.getCell(4));//寝室性别
-                        String grade = dataFormatter.formatCellValue(row.getCell(5));//所属年级
-                        String college = dataFormatter.formatCellValue(row.getCell(6));//所属学院
-                        String bedNum = dataFormatter.formatCellValue(row.getCell(7));//床位数
-                        String freeBedNumber = dataFormatter.formatCellValue(row.getCell(8));//空闲床位数
-                        String status = dataFormatter.formatCellValue(row.getCell(9));//入住情况
-                        String remark = dataFormatter.formatCellValue(row.getCell(10));//备注
-                        String retentionState = dataFormatter.formatCellValue(row.getCell(11));//是否保留
-
+                        String sex = dataFormatter.formatCellValue(row.getCell(3));//寝室性别
+                        String grade = dataFormatter.formatCellValue(row.getCell(4));//所属年级
+                        String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院
+                        String bedNum = dataFormatter.formatCellValue(row.getCell(6));//床位数
+                        String remark = dataFormatter.formatCellValue(row.getCell(7));//备注
 
                         wd.setSchool(school);
                         Optional<WelcomeBuild> oBuild = buildDatas.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build)).findFirst();
                         if (oBuild != null && oBuild.isPresent()) {
+                            if (!sex.equals(oBuild.get().getSex())) {
+                                return CommonResult.fail("第"+rowNum+1+"行,宿舍性别和楼栋性别不一致");
+                            }
                             wd.setBuild(build);
                             wd.setBuildId(oBuild.get().getId());
+
+                        }else {
+                            return CommonResult.fail("第"+rowNum+1+"行,不存在该楼栋");
                         }
                         wd.setDormitory(dormitory);
                         wd.setSex(sex);
@@ -463,19 +455,15 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
                         if (oCollege != null && oCollege.isPresent()) {
                             wd.setCollege(college);
                             wd.setCollegeId(oCollege.get().getId());
+                        }else {
+                            return CommonResult.fail("第"+rowNum+1+"行,不存在该学院");
                         }
 
-//                        Optional<WelcomeOrg> oMajor = orgs.stream().filter(e -> e.getName().equals(major)).findFirst();
-//                        if (oMajor != null && oMajor.isPresent()) {
-//                            wd.setMajor(major);
-//                            wd.setMajorId(oMajor.get().getId());
-//                        }
-
                         wd.setBedNumber(Integer.valueOf(bedNum));
-                        wd.setFreeBedNumber(Integer.valueOf(freeBedNumber));
-                        wd.setStatus(Integer.valueOf(status));
+                        wd.setFreeBedNumber(Integer.valueOf(bedNum));
+                        wd.setStatus(2);
                         wd.setRemark(remark);
-                        wd.setRetentionState(Integer.valueOf(retentionState));
+                        wd.setRetentionState(1);
                         wd.setGrade(Integer.valueOf(grade));
                         result.add(wd);
                     }
@@ -521,80 +509,69 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
                     //然后poi会根据字符串读取它
                     //第一行数据获取月份
                     if (rowNum == 0) {
-                        String number = dataFormatter.formatCellValue(row.getCell(0));//序号
-                        if (!number.equals("序号")) {
-                            return CommonResult.fail("导入数据第一列为序号");
-                        }
-                        String school = dataFormatter.formatCellValue(row.getCell(1));//校区名称
+                        String school = dataFormatter.formatCellValue(row.getCell(0));//校区名称
                         if (!school.equals("校区名称")) {
-                            return CommonResult.fail("导入数据第列为校区名称");
+                            return CommonResult.fail("导入数据第一列为校区名称");
                         }
-                        String build = dataFormatter.formatCellValue(row.getCell(2));//楼栋名称
+                        String build = dataFormatter.formatCellValue(row.getCell(1));//楼栋名称
                         if (!build.equals("楼栋名称")) {
-                            return CommonResult.fail("导入数据第列为楼栋名称");
+                            return CommonResult.fail("导入数据第列为楼栋名称");
                         }
-                        String dormitory = dataFormatter.formatCellValue(row.getCell(3));//寝室号
+                        String dormitory = dataFormatter.formatCellValue(row.getCell(2));//寝室号
                         if (!dormitory.equals("寝室号")) {
-                            return CommonResult.fail("导入数据第列为寝室号");
+                            return CommonResult.fail("导入数据第列为寝室号");
                         }
-                        String sex = dataFormatter.formatCellValue(row.getCell(4));//寝室性别
+                        String sex = dataFormatter.formatCellValue(row.getCell(3));//寝室性别
                         if (!sex.equals("寝室性别")) {
-                            return CommonResult.fail("导入数据第列为寝室性别");
+                            return CommonResult.fail("导入数据第列为寝室性别");
                         }
-                        String grade = dataFormatter.formatCellValue(row.getCell(5));//所属专业
+                        String grade = dataFormatter.formatCellValue(row.getCell(4));//所属年级
                         if (!grade.equals("所属年级")) {
-                            return CommonResult.fail("导入数据第列为所属年级");
+                            return CommonResult.fail("导入数据第列为所属年级");
                         }
-                        String college = dataFormatter.formatCellValue(row.getCell(6));//所属学院
+                        String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院
                         if (!college.equals("所属学院")) {
-                            return CommonResult.fail("导入数据第列为所属学院");
+                            return CommonResult.fail("导入数据第列为所属学院");
                         }
-                        String bedNum = dataFormatter.formatCellValue(row.getCell(7));//床位数
+                        String bedNum = dataFormatter.formatCellValue(row.getCell(6));//床位数
                         if (!bedNum.equals("床位数")) {
-                            return CommonResult.fail("导入数据第八列为床位数");
-                        }
-                        String freeBedNumber = dataFormatter.formatCellValue(row.getCell(8));//空闲床位数
-                        if (!freeBedNumber.equals("空闲床位数")) {
-                            return CommonResult.fail("导入数据第九列为空闲床位数");
+                            return CommonResult.fail("导入数据第七列为床位数");
                         }
-                        String status = dataFormatter.formatCellValue(row.getCell(9));//入住情况
-                        if (!status.equals("入住情况")) {
-                            return CommonResult.fail("导入数据第十列为入住情况");
-                        }
-                        String remark = dataFormatter.formatCellValue(row.getCell(10));//备注
+                        String remark = dataFormatter.formatCellValue(row.getCell(7));//备注
                         if (!remark.equals("备注")) {
-                            return CommonResult.fail("导入数据第十一列为备注");
-                        }
-                        String retentionState = dataFormatter.formatCellValue(row.getCell(11));//是否保留
-                        if (!retentionState.equals("是否保留")) {
-                            return CommonResult.fail("导入数据第十二列为是否保留");
+                            return CommonResult.fail("导入数据第列八为备注");
                         }
 
+
                     } else {
-                        String school = dataFormatter.formatCellValue(row.getCell(1));//校区名称
-                        String build = dataFormatter.formatCellValue(row.getCell(2));//楼栋名称
-                        String dormitory = dataFormatter.formatCellValue(row.getCell(3));//寝室号
+                        String school = dataFormatter.formatCellValue(row.getCell(0));//校区名称
+                        String build = dataFormatter.formatCellValue(row.getCell(1));//楼栋名称
+                        String dormitory = dataFormatter.formatCellValue(row.getCell(2));//寝室号
                         WelcomeDormitory wd = new WelcomeDormitory();
                         Optional<WelcomeDormitory> owelcomeDormitory = wds.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build) && e.getDormitory().equals(dormitory)).findFirst();
                         if (owelcomeDormitory != null && owelcomeDormitory.isPresent()) {
                             wd.setId(owelcomeDormitory.get().getId());
+                        }else {
+                            return CommonResult.fail("第"+rowNum+1+"行,已存在该宿舍");
                         }
 
-                        String sex = dataFormatter.formatCellValue(row.getCell(4));//寝室性别
-                        String grade = dataFormatter.formatCellValue(row.getCell(5));//所属年级
-                        String college = dataFormatter.formatCellValue(row.getCell(6));//所属学院
-                        String bedNum = dataFormatter.formatCellValue(row.getCell(7));//床位数
-                        String freeBedNumber = dataFormatter.formatCellValue(row.getCell(8));//空闲床位数
-                        String status = dataFormatter.formatCellValue(row.getCell(9));//入住情况
-                        String remark = dataFormatter.formatCellValue(row.getCell(10));//备注
-                        String retentionState = dataFormatter.formatCellValue(row.getCell(11));//是否保留
-
+                        String sex = dataFormatter.formatCellValue(row.getCell(3));//寝室性别
+                        String grade = dataFormatter.formatCellValue(row.getCell(4));//所属年级
+                        String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院
+                        String bedNum = dataFormatter.formatCellValue(row.getCell(6));//床位数
+                        String remark = dataFormatter.formatCellValue(row.getCell(7));//备注
 
                         wd.setSchool(school);
                         Optional<WelcomeBuild> oBuild = buildDatas.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build)).findFirst();
                         if (oBuild != null && oBuild.isPresent()) {
+                            if (!sex.equals(oBuild.get().getSex())) {
+                                return CommonResult.fail("第"+rowNum+1+"行,宿舍性别和楼栋性别不一致");
+                            }
                             wd.setBuild(build);
                             wd.setBuildId(oBuild.get().getId());
+
+                        }else {
+                            return CommonResult.fail("第"+rowNum+1+"行,不存在该楼栋");
                         }
                         wd.setDormitory(dormitory);
                         wd.setSex(sex);
@@ -603,19 +580,15 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
                         if (oCollege != null && oCollege.isPresent()) {
                             wd.setCollege(college);
                             wd.setCollegeId(oCollege.get().getId());
+                        }else {
+                            return CommonResult.fail("第"+rowNum+1+"行,不存在该学院");
                         }
 
-//                        Optional<WelcomeOrg> oMajor = orgs.stream().filter(e -> e.getName().equals(major)).findFirst();
-//                        if (oMajor != null && oMajor.isPresent()) {
-//                            wd.setMajor(major);
-//                            wd.setMajorId(oMajor.get().getId());
-//                        }
-
                         wd.setBedNumber(Integer.valueOf(bedNum));
-                        wd.setFreeBedNumber(Integer.valueOf(freeBedNumber));
-                        wd.setStatus(Integer.valueOf(status));
+                        wd.setFreeBedNumber(Integer.valueOf(bedNum));
+                        wd.setStatus(2);
                         wd.setRemark(remark);
-                        wd.setRetentionState(Integer.valueOf(retentionState));
+                        wd.setRetentionState(1);
                         wd.setGrade(Integer.valueOf(grade));
                         result.add(wd);
                     }