|
|
@@ -2747,6 +2747,131 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
return CommonResult.ok("导入成功");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @DESRespondSecret(validated = false)
|
|
|
+ public CommonResult ChangeExcelUpdateClass(MultipartFile excelFile, String headImage) throws Exception {
|
|
|
+ List<SmartUser> result = new ArrayList<>();
|
|
|
+
|
|
|
+ int useXw = 0;
|
|
|
+ int useBs = 1;
|
|
|
+
|
|
|
+ //先解析excel如果excel不满足格式就提示错误信息 避免提前占用带宽上传头像
|
|
|
+ if (excelFile.isEmpty() || excelFile.getSize() == 0) {
|
|
|
+ return CommonResult.fail("excel文件不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ String ContentType = excelFile.getContentType();
|
|
|
+ InputStream inputStream = excelFile.getInputStream();
|
|
|
+
|
|
|
+ //xls格式文件
|
|
|
+ if (ContentType.equals(eFileType.Xls.getValue())) {
|
|
|
+ CommonResult<List<SmartUser>> resultData = readUpdateClassXls(inputStream);
|
|
|
+ if (!resultData.isSuccess()) {
|
|
|
+ return resultData;
|
|
|
+ }
|
|
|
+ result = resultData.getData();
|
|
|
+ } else if (ContentType.equals(eFileType.Xlsx.getValue())) {
|
|
|
+ CommonResult<List<SmartUser>> resultData = readUpdateClassXlsx(inputStream);
|
|
|
+ if (!resultData.isSuccess()) {
|
|
|
+ return resultData;
|
|
|
+ }
|
|
|
+ result = resultData.getData();
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail("用户导入只支持Xls、Xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取导入学生的相关数据
|
|
|
+ List<String> cardNos = result.stream().map(SmartUser::getCardNo).collect(Collectors.toList());
|
|
|
+ if (cardNos == null) {
|
|
|
+ return CommonResult.fail("文档内容为空,批量更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartGrade> grades = smartGradeService.list(null);
|
|
|
+ List<SmartClass> classes = smartClassService.list(null);
|
|
|
+
|
|
|
+ List<SmartUser> updateStudent = new ArrayList<>();
|
|
|
+
|
|
|
+ List<SmartUser> updateStudents = result.stream().filter(e -> e.getId() != null && e.getIdentityId().intValue() == eIdentityStatu.Student.getValue()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (SmartUser studentData : updateStudents) {
|
|
|
+ studentData.setName(studentData.getName());//姓名
|
|
|
+ studentData.setSchoolClass(studentData.getSchoolClass());//班级
|
|
|
+ studentData.setGrade(studentData.getGrade());//可能会变年级
|
|
|
+ studentData.setTimeGroupId(studentData.getTimeGroupId());//时间组
|
|
|
+ updateStudent.add(studentData);
|
|
|
+ Optional<SmartGrade> oGrade = grades.stream().filter(e -> String.valueOf(e.getId()).equals(studentData.getGrade())).findFirst();
|
|
|
+ if (oGrade != null && oGrade.isPresent()) {
|
|
|
+ Optional<SmartClass> oClass = classes.stream().filter(e -> e.getId().equals(studentData.getSchoolClass())).findFirst();
|
|
|
+ if (oClass != null && oClass.isPresent()) {
|
|
|
+ if (useXw == 1) {
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ CommonResult updateSwStudent = SeewoUpdateStudent(seewoClient, studentData);
|
|
|
+ if (!updateSwStudent.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + updateSwStudent.getMessage());
|
|
|
+ }
|
|
|
+ if (!studentData.getOldClassUid().equals(oClass.get().getClassUid())) {
|
|
|
+ CommonResult changeClass = SeewoChangeClass(seewoClient, seewoConfig.getSchoolId(), studentData.getXwStudentUid(), studentData.getOldClassUid(), oClass.get().getClassUid());
|
|
|
+ if (!changeClass.isSuccess()) {
|
|
|
+ //return CommonResult.fail("希沃平台:" + changeClass.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (useBs == 1) {
|
|
|
+ /**
|
|
|
+ * 学生数据的有效期是到毕业年份的8月31日
|
|
|
+ */
|
|
|
+ String startTime = TimeExchange.DateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String endTime = queryGraduationYear(oGrade.get().getGradeNo());
|
|
|
+ CommonResult<String> updateBsStudent = bsTUpdateStudent(studentData, oClass.get().getBsClassNo(), startTime, endTime);
|
|
|
+ if (!updateBsStudent.isSuccess()) {
|
|
|
+ return CommonResult.fail("百胜平台:" + updateBsStudent.getMessage());
|
|
|
+ }
|
|
|
+ System.out.println(studentData.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail("学号为:" + studentData.getCardNo() + "的" + studentData.getName() + "的班级数据无效,无法进行更新操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail("学号为:" + studentData.getCardNo() + "的" + studentData.getName() + "的年级数据无效,无法进行更新操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartUser> updateParents = result.stream().filter(e -> e.getId() != null && e.getIdentityId().intValue() == eIdentityStatu.Parent.getValue()).collect(Collectors.toList());
|
|
|
+ if (updateParents != null && updateParents.size() > 0) {
|
|
|
+ boolean updateBatch = smartUserService.updateBatchById(updateParents);
|
|
|
+ if (!updateBatch) {
|
|
|
+ return CommonResult.fail("系统批量更新家长出错,导入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (updateStudent != null && updateStudent.size() > 0) {
|
|
|
+ boolean updateBatch = smartUserService.updateBatchById(updateStudent);
|
|
|
+ if (!updateBatch) {
|
|
|
+ return CommonResult.fail("系统批量更新出错,导入失败");
|
|
|
+ } else {
|
|
|
+ //修改需同步到海康平台
|
|
|
+ for (SmartUser su : updateStudent) {
|
|
|
+ Integer identityId = su.getIdentityId();
|
|
|
+ if (2 == identityId || identityId == 3) {
|
|
|
+ Integer id = su.getId();
|
|
|
+ SmartOperationUser smartOperationUser = new SmartOperationUser();
|
|
|
+ smartOperationUser.setOperationId(id);
|
|
|
+ smartOperationUser.setOperationMode("2");
|
|
|
+ smartOperationUser.setStatus(1);
|
|
|
+ smartOperationUser.setType(identityId);
|
|
|
+ smartOperationUserService.save(smartOperationUser);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("导入完成");
|
|
|
+ return CommonResult.ok("导入成功");
|
|
|
+ }
|
|
|
//endregion
|
|
|
|
|
|
//region Xls文件读取方法
|
|
|
@@ -3734,6 +3859,399 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
+ //region 换班
|
|
|
+ //region Xls文件读取方法
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Xls文件读取方法
|
|
|
+ *
|
|
|
+ * @param inputStream 文件流
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ private CommonResult<List<SmartUser>> readUpdateClassXls(InputStream inputStream) throws IOException {
|
|
|
+ List<String> idCards = new ArrayList<>();
|
|
|
+ List<String> cardNos = new ArrayList<>();
|
|
|
+ List<SmartUser> result = new ArrayList<>();
|
|
|
+ HSSFWorkbook sheets = new HSSFWorkbook(inputStream);
|
|
|
+
|
|
|
+ List<SmartGrade> grades = smartGradeService.list(null);//年级
|
|
|
+ List<SmartClass> classs = smartClassService.list(null);//班级
|
|
|
+ List<SmartTimeGroup> timeGroups = smartTimeGroupService.queryTimeGroups();//时间组
|
|
|
+ List<SmartDepartment> departments = smartDepartmentService.list(null);
|
|
|
+
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
+ for (int i = Year.now().getValue() - 2; i <= Year.now().getValue(); i++) {
|
|
|
+ String strName = (i + "级");
|
|
|
+ Optional<SmartGrade> oGrade = grades.stream().filter(e -> e.getName().equals(strName)).findFirst();
|
|
|
+ if (oGrade != null && oGrade.isPresent()) {
|
|
|
+ ids.add(oGrade.get().getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //读取第一张sheet
|
|
|
+ HSSFSheet sheetAt = sheets.getSheetAt(0);
|
|
|
+ DataFormatter dataFormatter = new DataFormatter();
|
|
|
+ List<SmartUser> users = smartUserService.queryStudentDatas(eIdentityStatu.Student.getValue(), ids);
|
|
|
+ List<SmartUser> parents = smartUserService.getSmartUserByIdentity(eIdentityStatu.Parent.getValue());
|
|
|
+
|
|
|
+ try {
|
|
|
+ for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
|
|
|
+ HSSFRow row = sheetAt.getRow(rowNum);
|
|
|
+
|
|
|
+ if (row != null) {
|
|
|
+ //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。
|
|
|
+ //所以先使用setCellType()方法先将该单元格的类型设置为STRING
|
|
|
+ //然后poi会根据字符串读取它
|
|
|
+ //标题 校验
|
|
|
+ if (rowNum == 0) {
|
|
|
+ String schoolGrade = dataFormatter.formatCellValue(row.getCell(0));//年级
|
|
|
+ if (!schoolGrade.equals("年级")) {
|
|
|
+ return CommonResult.fail("导入数据第一列为年级");
|
|
|
+ }
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(1));//班级
|
|
|
+ if (!schoolClass.equals("班级")) {
|
|
|
+ return CommonResult.fail("导入数据第二列为班级");
|
|
|
+ }
|
|
|
+ String departmentNo = dataFormatter.formatCellValue(row.getCell(2));//部门
|
|
|
+ if (!departmentNo.equals("部门")) {
|
|
|
+ return CommonResult.fail("导入数据第三列为部门");
|
|
|
+ }
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(3));//学号
|
|
|
+ if (!cardNo.equals("学号")) {
|
|
|
+ return CommonResult.fail("导入数据第四列为学号");
|
|
|
+ }
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(4));//姓名
|
|
|
+ if (!name.equals("姓名")) {
|
|
|
+ return CommonResult.fail("导入数据第五列为姓名");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ SmartUser user = new SmartUser();
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(3));//学号
|
|
|
+ if (ObjectUtils.isEmpty(cardNo)) {
|
|
|
+ return CommonResult.fail("第" + (rowNum) + "条数据的学号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional<SmartUser> oUser = users.stream().filter(e -> e.getCardNo().equals(cardNo)).findFirst();
|
|
|
+ if (oUser != null && oUser.isPresent()) {
|
|
|
+
|
|
|
+ user = oUser.get();
|
|
|
+ Optional<SmartClass> oldClass = classs.stream().filter(e -> e.getId().equals(oUser.get().getSchoolClass())).findFirst();
|
|
|
+ if (oldClass != null && oldClass.isPresent()) {
|
|
|
+ user.setOldClassUid(oldClass.get().getClassUid());
|
|
|
+ }
|
|
|
+
|
|
|
+ //学号重复判断
|
|
|
+ if (!ObjectUtils.isEmpty(cardNo)) {
|
|
|
+ cardNos.add(cardNo);
|
|
|
+ }
|
|
|
+ if (cardNos.stream().distinct().count() != cardNos.size()) {
|
|
|
+ return CommonResult.fail("导入的Excel中," + user.getName() + "的学号:" + cardNo + "存在重复数据");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(4));//姓名
|
|
|
+ if (ObjectUtils.isEmpty(name)) {
|
|
|
+ return CommonResult.fail("第" + (rowNum) + "条数据的姓名不能为空");
|
|
|
+ }
|
|
|
+ String department = dataFormatter.formatCellValue(row.getCell(2));//部门
|
|
|
+ if (ObjectUtils.isEmpty(department)) {
|
|
|
+ return CommonResult.fail(name + "的部门不能为空");
|
|
|
+ }
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(1));//班级
|
|
|
+ if (ObjectUtils.isEmpty(schoolClass)) {
|
|
|
+ return CommonResult.fail(name + "的班级不能为空");
|
|
|
+ }
|
|
|
+ Integer parentDid = null;
|
|
|
+ Integer departmentId = null;
|
|
|
+ String[] departmentStrs = department.split("/");
|
|
|
+ for (int i = 0; i < departmentStrs.length; i++) {
|
|
|
+ String departmentName = departmentStrs[i];
|
|
|
+ Optional<SmartDepartment> oD = departments.stream().filter(e -> e.getName().equals(departmentName)).findFirst();
|
|
|
+ if (oD != null && oD.isPresent()) {
|
|
|
+ parentDid = oD.get().getId();
|
|
|
+ } else {
|
|
|
+ String bsDepartment = insertDepartmentToBs(departmentName);
|
|
|
+ if (bsDepartment == null) {
|
|
|
+ return CommonResult.fail(name + "的部门添加到百胜失败");
|
|
|
+ }
|
|
|
+ SmartDepartment sdParent = new SmartDepartment();
|
|
|
+ sdParent.setParentId(parentDid);
|
|
|
+ sdParent.setName(departmentName);
|
|
|
+ sdParent.setBsDepartmentNo(bsDepartment);
|
|
|
+ int departmentData = smartDepartmentService.insertSmartDepartment(sdParent);
|
|
|
+ departmentId = departmentData;
|
|
|
+ parentDid = departmentData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ user.setDepartmentId(departmentId == null ? parentDid : departmentId);
|
|
|
+ user.setCardNo(cardNo == null ? "" : cardNo);
|
|
|
+ user.setName(name == null ? "" : name);
|
|
|
+ user.setIdentityId(eIdentityStatu.Student.getValue());
|
|
|
+
|
|
|
+ Optional<SmartClass> oClass = classs.stream().filter(e -> e.getName().equals(schoolClass)).findFirst();
|
|
|
+ if (oClass != null && oClass.isPresent()) {
|
|
|
+ user.setSchoolClass(oClass.get().getId());
|
|
|
+ user.setGrade(String.valueOf(oClass.get().getGradeId()));
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail(name + "的班级数据无效,导入失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ result.add(user);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(4));
|
|
|
+ // if (ObjectUtils.isEmpty(name)) {
|
|
|
+ // return CommonResult.fail("第" + (rowNum + 1) + "条数据的名称不能为空");
|
|
|
+ // }
|
|
|
+ if (ObjectUtils.isEmpty(name)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.fail(name+"是新生");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return CommonResult.fail("请按模板格式导入数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok(result);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region Xlsx文件读取方法
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Xlsx文件读取方法
|
|
|
+ *
|
|
|
+ * @param inputStream 文件流
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ private CommonResult<List<SmartUser>> readUpdateClassXlsx(InputStream inputStream) throws IOException {
|
|
|
+ List<String> idCards = new ArrayList<>();
|
|
|
+ List<String> cardNos = new ArrayList<>();
|
|
|
+ List<SmartUser> result = new ArrayList<>();
|
|
|
+ XSSFWorkbook sheets = new XSSFWorkbook(inputStream);
|
|
|
+
|
|
|
+ List<SmartGrade> grades = smartGradeService.list(null);//年级
|
|
|
+ List<SmartClass> classs = smartClassService.list(null);//班级
|
|
|
+ List<SmartTimeGroup> timeGroups = smartTimeGroupService.queryTimeGroups();//时间组
|
|
|
+ List<SmartDepartment> departments = smartDepartmentService.list(null);
|
|
|
+
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
+ for (int i = Year.now().getValue() - 2; i <= Year.now().getValue(); i++) {
|
|
|
+ String strName = (i + "级");
|
|
|
+ Optional<SmartGrade> oGrade = grades.stream().filter(e -> e.getName().equals(strName)).findFirst();
|
|
|
+ if (oGrade != null && oGrade.isPresent()) {
|
|
|
+ ids.add(oGrade.get().getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //读取第一张sheet
|
|
|
+ XSSFSheet sheetAt = sheets.getSheetAt(0);
|
|
|
+ DataFormatter dataFormatter = new DataFormatter();
|
|
|
+ List<SmartUser> users = smartUserService.queryStudentDatas(eIdentityStatu.Student.getValue(), ids);
|
|
|
+ List<SmartUser> parents = smartUserService.getSmartUserByIdentity(eIdentityStatu.Parent.getValue());
|
|
|
+ try {
|
|
|
+ for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
|
|
|
+ XSSFRow row = sheetAt.getRow(rowNum);
|
|
|
+
|
|
|
+ if (row != null) {
|
|
|
+ //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。
|
|
|
+ //所以先使用setCellType()方法先将该单元格的类型设置为STRING
|
|
|
+ //然后poi会根据字符串读取它
|
|
|
+ //标题 校验
|
|
|
+ if (rowNum == 0) {
|
|
|
+ String schoolGrade = dataFormatter.formatCellValue(row.getCell(0));//年级
|
|
|
+ if (!schoolGrade.equals("年级")) {
|
|
|
+ return CommonResult.fail("导入数据第一列为年级");
|
|
|
+ }
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(1));//班级
|
|
|
+ if (!schoolClass.equals("班级")) {
|
|
|
+ return CommonResult.fail("导入数据第二列为班级");
|
|
|
+ }
|
|
|
+ String departmentNo = dataFormatter.formatCellValue(row.getCell(2));//部门
|
|
|
+ if (!departmentNo.equals("部门")) {
|
|
|
+ return CommonResult.fail("导入数据第三列为部门");
|
|
|
+ }
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(3));//学号
|
|
|
+ if (!cardNo.equals("学号")) {
|
|
|
+ return CommonResult.fail("导入数据第四列为学号");
|
|
|
+ }
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(4));//姓名
|
|
|
+ if (!name.equals("姓名")) {
|
|
|
+ return CommonResult.fail("导入数据第五列为姓名");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ SmartUser user = new SmartUser();
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(4));//姓名
|
|
|
+ if (ObjectUtils.isEmpty(name)) {
|
|
|
+ return CommonResult.fail("第" + (rowNum) + "条数据的姓名不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional<SmartUser> oUser = users.stream().filter(e -> e.getName().equals(name)).findFirst();
|
|
|
+ if (oUser != null && oUser.isPresent()) {
|
|
|
+
|
|
|
+ user = oUser.get();
|
|
|
+ Optional<SmartClass> oldClass = classs.stream().filter(e -> e.getId().equals(oUser.get().getSchoolClass())).findFirst();
|
|
|
+ if (oldClass != null && oldClass.isPresent()) {
|
|
|
+ user.setOldClassUid(oldClass.get().getClassUid());
|
|
|
+ }
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(3));//学号
|
|
|
+ if (ObjectUtils.isEmpty(cardNo)) {
|
|
|
+ return CommonResult.fail("第" + (rowNum) + "条数据的学号不能为空");
|
|
|
+ }
|
|
|
+ //学号重复判断
|
|
|
+ if (!ObjectUtils.isEmpty(cardNo)) {
|
|
|
+ cardNos.add(cardNo);
|
|
|
+ }
|
|
|
+ if (cardNos.stream().distinct().count() != cardNos.size()) {
|
|
|
+ return CommonResult.fail("导入的Excel中," + user.getName() + "的学号:" + cardNo + "存在重复数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ String department = dataFormatter.formatCellValue(row.getCell(2));//部门
|
|
|
+ if (ObjectUtils.isEmpty(department)) {
|
|
|
+ return CommonResult.fail(name + "的部门不能为空");
|
|
|
+ }
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(1));//班级
|
|
|
+ if (ObjectUtils.isEmpty(schoolClass)) {
|
|
|
+ return CommonResult.fail(name + "的班级不能为空");
|
|
|
+ }
|
|
|
+ Integer parentDid = null;
|
|
|
+ Integer departmentId = null;
|
|
|
+ String[] departmentStrs = department.split("/");
|
|
|
+ for (int i = 0; i < departmentStrs.length; i++) {
|
|
|
+ String departmentName = departmentStrs[i];
|
|
|
+ Optional<SmartDepartment> oD = departments.stream().filter(e -> e.getName().equals(departmentName)).findFirst();
|
|
|
+ if (oD != null && oD.isPresent()) {
|
|
|
+ parentDid = oD.get().getId();
|
|
|
+ } else {
|
|
|
+ String bsDepartment = insertDepartmentToBs(departmentName);
|
|
|
+ if (bsDepartment == null) {
|
|
|
+ return CommonResult.fail(name + "的部门添加到百胜失败");
|
|
|
+ }
|
|
|
+ SmartDepartment sdParent = new SmartDepartment();
|
|
|
+ sdParent.setParentId(parentDid);
|
|
|
+ sdParent.setName(departmentName);
|
|
|
+ sdParent.setBsDepartmentNo(bsDepartment);
|
|
|
+ int departmentData = smartDepartmentService.insertSmartDepartment(sdParent);
|
|
|
+ departmentId = departmentData;
|
|
|
+ parentDid = departmentData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ user.setDepartmentId(departmentId == null ? parentDid : departmentId);
|
|
|
+ user.setCardNo(cardNo == null ? "" : cardNo);
|
|
|
+ user.setName(name == null ? "" : name);
|
|
|
+ user.setIdentityId(eIdentityStatu.Student.getValue());
|
|
|
+
|
|
|
+ Optional<SmartClass> oClass = classs.stream().filter(e -> e.getName().equals(schoolClass)).findFirst();
|
|
|
+ if (oClass != null && oClass.isPresent()) {
|
|
|
+ user.setSchoolClass(oClass.get().getId());
|
|
|
+ user.setGrade(String.valueOf(oClass.get().getGradeId()));
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail(name + "的班级数据无效,导入失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ result.add(user);
|
|
|
+//不判断重复性 因为会出现双胞胎
|
|
|
+ String phone = dataFormatter.formatCellValue(row.getCell(5));
|
|
|
+ //部门是否为空判断
|
|
|
+ String familyDepartment = dataFormatter.formatCellValue(row.getCell(1)).replace("年级", "") + "家长";
|
|
|
+
|
|
|
+ Integer familyDepartmentId = null;
|
|
|
+ Optional<SmartDepartment> familyDepartModel = departments.stream().filter(e -> e.getName().equals(familyDepartment)).findFirst();
|
|
|
+ if (familyDepartModel != null && familyDepartModel.isPresent()) {
|
|
|
+ familyDepartmentId = familyDepartModel.get().getId();
|
|
|
+ } else {
|
|
|
+ familyDepartmentId = 16;
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 家属
|
|
|
+
|
|
|
+ if (user.getName().equals("张宇霏")) {
|
|
|
+ String sdsd = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(phone)) {
|
|
|
+ if (phone.length() != 11) {
|
|
|
+ return CommonResult.fail(name + "的学生家长手机号长度不符合标准");
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartUser familyOne = new SmartUser();
|
|
|
+ Optional<SmartUser> oneParent = parents.stream().filter(e -> e.getPhone().equals(phone)).findFirst();
|
|
|
+ if (oneParent != null && oneParent.isPresent()) {
|
|
|
+ familyOne = oneParent.get();
|
|
|
+ } else {
|
|
|
+ familyOne.setAffiliate(user.getCardNo());
|
|
|
+ }
|
|
|
+ String family = dataFormatter.formatCellValue(row.getCell(6));//家属
|
|
|
+ familyOne.setName(!ObjectUtils.isEmpty(family) ? family : "家长");
|
|
|
+ familyOne.setDepartmentId(familyDepartmentId);
|
|
|
+ familyOne.setPhone(phone);
|
|
|
+ familyOne.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ familyOne.setSexId(eSexStatu.Man.getValue());
|
|
|
+ familyOne.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
+ String familyShip = dataFormatter.formatCellValue(row.getCell(7));//家属与本人关系
|
|
|
+ familyOne.setShip(familyShip == null ? "其他" : familyShip);
|
|
|
+ result.add(familyOne);
|
|
|
+ }
|
|
|
+
|
|
|
+ String phoneTwo = dataFormatter.formatCellValue(row.getCell(8));//联系电话2
|
|
|
+ if (!ObjectUtils.isEmpty(phoneTwo)) {
|
|
|
+ if (phoneTwo.length() != 11) {
|
|
|
+ return CommonResult.fail(name + "的学生家长手机号长度不符合标准");
|
|
|
+ }
|
|
|
+ SmartUser familyTwo = new SmartUser();
|
|
|
+ Optional<SmartUser> oneParent = parents.stream().filter(e -> e.getPhone().equals(phoneTwo)).findFirst();
|
|
|
+ if (oneParent != null && oneParent.isPresent()) {
|
|
|
+ familyTwo = oneParent.get();
|
|
|
+ } else {
|
|
|
+ familyTwo.setAffiliate(user.getCardNo());
|
|
|
+ }
|
|
|
+ String familyNameTwo = dataFormatter.formatCellValue(row.getCell(9));//家属2
|
|
|
+ familyTwo.setName(!ObjectUtils.isEmpty(familyNameTwo) ? familyNameTwo : "家长");
|
|
|
+ familyTwo.setDepartmentId(familyDepartmentId);
|
|
|
+ familyTwo.setPhone(phoneTwo == null ? "" : phoneTwo);
|
|
|
+ familyTwo.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ familyTwo.setSexId(eSexStatu.Man.getValue());
|
|
|
+ familyTwo.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
+ String familyShipTwo = dataFormatter.formatCellValue(row.getCell(10));//家属与本人关系2
|
|
|
+ familyTwo.setShip(familyShipTwo == null ? "其他" : familyShipTwo);
|
|
|
+ result.add(familyTwo);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //希沃不允许一个学生家长的两个手机号重复 所以做一个重复性判断
|
|
|
+ if (!ObjectUtils.isEmpty(phone) && !ObjectUtils.isEmpty(dataFormatter.formatCellValue(row.getCell(8)))) {
|
|
|
+ if (phone.equals(dataFormatter.formatCellValue(row.getCell(8)))) {
|
|
|
+ return CommonResult.fail(name + "的学生家长手机号不可重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isEmpty(name)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.fail(name+"是新生");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return CommonResult.fail("请按模板格式导入数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok(result);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ //endregion
|
|
|
+
|
|
|
//endregion
|
|
|
|
|
|
//region 时间组数据集合
|
|
|
@@ -5813,6 +6331,10 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//region 百胜更新学生信息 给批量导入用的
|
|
|
public CommonResult bsEUpdateStudent(SmartUser su, String bsClassNo, String startDate, String endDate) throws
|
|
|
Exception {
|
|
|
+
|
|
|
+ if(su.getName().equals("欧阳丹")){
|
|
|
+String sds = "";
|
|
|
+ }
|
|
|
//region 更新百胜学生信息
|
|
|
String appId = controlConfig.getAppId();
|
|
|
String schoolno = controlConfig.getSchoolCode();
|
|
|
@@ -5854,6 +6376,9 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//region 百胜更新学生信息 给设置时间组接口用的
|
|
|
public CommonResult bsTUpdateStudent(SmartUser su, String bsClassNo, String startDate, String endDate) throws
|
|
|
Exception {
|
|
|
+ if(su.getName().equals("辛语涵")){
|
|
|
+ String sdsd = "";
|
|
|
+ }
|
|
|
//region 更新百胜学生信息
|
|
|
String appId = controlConfig.getAppId();
|
|
|
String schoolno = controlConfig.getSchoolCode();
|
|
|
@@ -5879,7 +6404,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
//返回的结果中 code为1表示成功
|
|
|
String bsResult = RequestUtils.httpPosts(url, jsonobject.toJSONString());
|
|
|
-
|
|
|
+ System.out.println(bsResult);
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
BsClassVo result = objectMapper.readValue(bsResult, BsClassVo.class);
|
|
|
|
|
|
@@ -8749,6 +9274,9 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
break;
|
|
|
case 9:
|
|
|
+ if(currentDate.getMonthValue() > 9){
|
|
|
+ endYear = endYear + 1;
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|