|
|
@@ -133,7 +133,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommonResult importExcelUsers(MultipartFile excelFile, String headImage) throws IOException {
|
|
|
+ public CommonResult importExcelUsers(MultipartFile excelFile, String headImage) throws Exception {
|
|
|
List<SmartUser> result = new ArrayList<>();
|
|
|
|
|
|
//先解析excel如果excel不满足格式就提示错误信息 避免提前占用带宽上传头像
|
|
|
@@ -169,10 +169,197 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //批量存储用户信息
|
|
|
- boolean resultBool = smartUserService.saveBatch(result);
|
|
|
+ //region 将数据加入第三方
|
|
|
+ List<SmartUser> studentDatas = result.stream().filter(e -> e.getIdentityId().intValue() == eIdentityStatu.Student.getValue()).collect(Collectors.toList());
|
|
|
+ for (SmartUser student : studentDatas) {
|
|
|
|
|
|
- return resultBool ? CommonResult.ok("导入成功") : CommonResult.fail("导入失败");
|
|
|
+ //region 学生参数必填判断:年级、班级
|
|
|
+ if (student.getGrade() == null) {
|
|
|
+ return CommonResult.fail("学生年级不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (student.getSchoolClass() == null) {
|
|
|
+ return CommonResult.fail("学生班级不能为空");
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //获取班级Uid
|
|
|
+ SmartClass classData = smartClassService.getSmartClassById(student.getSchoolClass());
|
|
|
+ if (classData == null) {
|
|
|
+ return CommonResult.fail("班级数据无效,新增失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 希沃新增学生信息
|
|
|
+ //初始化客户端
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ StudentServiceBatchSaveClassStudentsParam param = new StudentServiceBatchSaveClassStudentsParam();
|
|
|
+ //请求体,MimeType为 application/json
|
|
|
+ StudentServiceBatchSaveClassStudentsParam.JSONRequestBody requestBody = StudentServiceBatchSaveClassStudentsParam.JSONRequestBody.builder()
|
|
|
+ .build();
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ //查询条件
|
|
|
+ StudentServiceBatchSaveClassStudentsParam.StudentSaveQuery query = StudentServiceBatchSaveClassStudentsParam.StudentSaveQuery.builder()
|
|
|
+ .appId(seewoConfig.getAppId())
|
|
|
+ .schoolUid(seewoConfig.getSchoolId())
|
|
|
+ .classUid(classData.getClassUid())
|
|
|
+ .build();
|
|
|
+ requestBody.setQuery(query);
|
|
|
+ // 学生列表
|
|
|
+ StudentServiceBatchSaveClassStudentsParam.StudentInfo students = StudentServiceBatchSaveClassStudentsParam.StudentInfo.builder()
|
|
|
+ .studentName(student.getName())
|
|
|
+ .studentCode(student.getCardNo())
|
|
|
+ .gender(student.getSexId())
|
|
|
+ .phone(student.getPhone() == null ? "" : student.getPhone())
|
|
|
+ .build();
|
|
|
+ query.setStudents(java.util.Collections.singletonList(students));
|
|
|
+ query.setInPlaceOld(true);// 是否删除旧学生再保存
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ StudentServiceBatchSaveClassStudentsRequest request = new StudentServiceBatchSaveClassStudentsRequest(param);
|
|
|
+ System.out.println("入参:" + request);
|
|
|
+ //如果想要调用沙箱环境,请通过设置 request 对象的 serverUrl 属性,如:
|
|
|
+ //request.setServerUrl("https://openapi.test.seewo.com")
|
|
|
+ //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
|
|
|
+ StudentServiceBatchSaveClassStudentsResult studentResult = seewoClient.invoke(request);
|
|
|
+ System.out.println("出参:" + studentResult);
|
|
|
+
|
|
|
+ if (studentResult == null) {
|
|
|
+ return CommonResult.fail("希沃学生数据新增失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!studentResult.getResponseBody().getCode().equals("000000")) {
|
|
|
+ return CommonResult.fail(studentResult.getResponseBody().getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ student.setXwStudentUid(studentResult.getResponseBody().getData().get(0).getUserUid());
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 百胜新增学生信息
|
|
|
+ String appId = controlConfig.getAppId();
|
|
|
+ String schoolno = controlConfig.getSchoolCode();
|
|
|
+ String timestamp = TimeExchange.DateNowTimeStamo();
|
|
|
+ String appSecret = controlConfig.getAppSecret();
|
|
|
+ String url = controlConfig.getUrl() + "student/create";
|
|
|
+
|
|
|
+ JSONObject jsonobject = new JSONObject();
|
|
|
+ jsonobject.put("appid", appId);
|
|
|
+ String str = "{\"student_name\":\"" + student.getName() + "\",\"classtab_no\":\"" + classData.getBsClassNo() + "\",\"student_number\":\"" + student.getCardNo() + "\",\"student_sex\":\"" + student.getSexId() + "\",\"student_photo\":\"" + imageUtils.getBase64Url(student.getHeadImage()) + "\",\"student_tgno\":\"" + eTimeGroup.stringOf(student.getTimeGroupId()) + "\"}";
|
|
|
+ String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
|
|
|
+ jsonobject.put("data", aesStr);
|
|
|
+ jsonobject.put("schoolno", schoolno);
|
|
|
+ jsonobject.put("timestamp", timestamp);
|
|
|
+
|
|
|
+ String md5Str = "appid=" + appId + "&data={\"student_name\":\"" + student.getName() + "\",\"classtab_no\":\"" + classData.getBsClassNo() + "\",\"student_number\":\"" + student.getCardNo() + "\",\"student_sex\":\"" + student.getSexId() + "\",\"student_photo\":\"" + imageUtils.getBase64Url(student.getHeadImage()) + "\",\"student_tgno\":\"" + eTimeGroup.stringOf(student.getTimeGroupId()) + "\"}" + "&schoolno=" + schoolno + "×tamp=" + timestamp + "&key=" + appSecret;
|
|
|
+ String sign = CommonUtil.MD5(md5Str);
|
|
|
+ //sign签名
|
|
|
+ jsonobject.put("sign", sign);
|
|
|
+
|
|
|
+ //返回的结果中 code为1表示成功
|
|
|
+ String bsResult = RequestUtils.httpPost(url, jsonobject.toJSONString());
|
|
|
+
|
|
|
+ if (bsResult.contains("添加成功")) {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ BsStudentVo grade = objectMapper.readValue(bsResult, BsStudentVo.class);
|
|
|
+
|
|
|
+ // URL解码
|
|
|
+ String decodedUrl = URLDecoder.decode(grade.getData(), "UTF-8");
|
|
|
+
|
|
|
+ BsStudentNoVo studentNo = objectMapper.readValue(decrypt(decodedUrl, controlConfig.getAppSecret()), BsStudentNoVo.class);
|
|
|
+ student.setBsStudentNo(studentNo.getStudent_no());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (studentDatas != null && studentDatas.size() > 0) {
|
|
|
+ //批量存储学生信息
|
|
|
+ boolean resultBool = smartUserService.saveBatch(studentDatas);
|
|
|
+ if (!resultBool) {
|
|
|
+ return CommonResult.fail("导入失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> cardNos = studentDatas.stream().map(SmartUser::getCardNo).collect(Collectors.toList());
|
|
|
+ for (String cardNo : cardNos) {
|
|
|
+
|
|
|
+ //region 希沃新增编辑学生家长信息
|
|
|
+ //学生与家长列表,最大100条
|
|
|
+ List<ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem> studentParents = new ArrayList<>();
|
|
|
+ for (SmartUser student : studentDatas) {
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem students = ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem.builder()
|
|
|
+ .studentCode(student.getCardNo())
|
|
|
+ .build();
|
|
|
+ studentParents.add(students);
|
|
|
+
|
|
|
+ List<SmartUser> parentDatas = result.stream().filter(e -> e.getIdentityId().intValue() == eIdentityStatu.Parent.getValue() && e.getAffiliate().equals(cardNo)).collect(Collectors.toList());
|
|
|
+ List<ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem> parents = new ArrayList<>();
|
|
|
+ int i = 0;
|
|
|
+ for (SmartUser parent : parentDatas) {
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem data = ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem.builder()
|
|
|
+ .name(parent.getName())
|
|
|
+ .phone(parent.getPhone())
|
|
|
+ .index(i)
|
|
|
+ .build();
|
|
|
+ parents.add(data);
|
|
|
+ ++i;
|
|
|
+ }
|
|
|
+ //家长列表,最多4个
|
|
|
+ students.setParents(parents);
|
|
|
+ }
|
|
|
+
|
|
|
+ //初始化客户端
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam param = new ParentServiceBatchSaveOrUpdateParentsParam();
|
|
|
+ //响应体,MimeType为 application/json
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.RequestBody requestBody = ParentServiceBatchSaveOrUpdateParentsParam.RequestBody.builder()
|
|
|
+ .build();
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ //query
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.Query query = ParentServiceBatchSaveOrUpdateParentsParam.Query.builder()
|
|
|
+ .appId(seewoConfig.getAppId())
|
|
|
+ .schoolUid(seewoConfig.getSchoolId())
|
|
|
+ .build();
|
|
|
+ requestBody.setQuery(query);
|
|
|
+ query.setStudentParents(studentParents);
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsRequest request = new ParentServiceBatchSaveOrUpdateParentsRequest(param);
|
|
|
+ System.out.println("入参:" + request);
|
|
|
+ //如果想要调用沙箱环境,请通过设置 request 对象的 serverUrl 属性,如:
|
|
|
+ //request.setServerUrl("https://openapi.test.seewo.com")
|
|
|
+ //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsResult parentResult = seewoClient.invoke(request);
|
|
|
+ System.out.println("出参:" + parentResult);
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ if (parentResult == null) {
|
|
|
+ return CommonResult.fail("希沃学生家长数据添加失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!parentResult.getResponseBody().getCode().equals("000000")) {
|
|
|
+ return CommonResult.fail(parentResult.getResponseBody().getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ List<SmartUser> parents = result.stream().filter(e -> e.getIdentityId().intValue() == eIdentityStatu.Parent.getValue()).collect(Collectors.toList());
|
|
|
+ List<String> cardNos = studentDatas.stream().map(SmartUser::getCardNo).collect(Collectors.toList());
|
|
|
+ if(cardNos != null && cardNos.size() > 0){
|
|
|
+ List<SmartUser> students = smartUserService.querySmartUserByCardNos(cardNos);
|
|
|
+ for (SmartUser parent : parents) {
|
|
|
+ Optional<SmartUser> student = students.stream().filter(e -> e.getCardNo().equals(parent.getAffiliate())).findFirst();
|
|
|
+ if(student != null && student.isPresent()){
|
|
|
+ parent.setAffiliate(String.valueOf(student.get().getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(parents!= null && parents.size() > 0){
|
|
|
+ //批量存储家长信息
|
|
|
+ boolean resultBool = smartUserService.saveBatch(result);
|
|
|
+ if(!resultBool){
|
|
|
+ return CommonResult.fail("导入失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok("导入成功");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -299,136 +486,103 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//然后poi会根据字符串读取它
|
|
|
//标题 校验
|
|
|
if (rowNum == 0) {
|
|
|
- String cardNo = dataFormatter.formatCellValue(row.getCell(0));//学号
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(0));//班级
|
|
|
+ if (!schoolClass.equals("班级")) {
|
|
|
+ return CommonResult.fail("导入数据第一列为班级");
|
|
|
+ }
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(1));//学号
|
|
|
if (!cardNo.equals("学号")) {
|
|
|
- return CommonResult.fail("导入数据第一列为学号");
|
|
|
+ return CommonResult.fail("导入数据第二列为学号");
|
|
|
}
|
|
|
- String name = dataFormatter.formatCellValue(row.getCell(1));//姓名
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
|
|
|
if (!name.equals("姓名")) {
|
|
|
- return CommonResult.fail("导入数据第二列为姓名");
|
|
|
- }
|
|
|
- String identity = dataFormatter.formatCellValue(row.getCell(2));//身份
|
|
|
- if (!identity.equals("身份")) {
|
|
|
- return CommonResult.fail("导入数据第三列为身份");
|
|
|
+ return CommonResult.fail("导入数据第三列为姓名");
|
|
|
}
|
|
|
- String idCard = dataFormatter.formatCellValue(row.getCell(3));//身份证
|
|
|
- if (!idCard.equals("身份证")) {
|
|
|
- return CommonResult.fail("导入数据第四列为身份证");
|
|
|
- }
|
|
|
- String sex = dataFormatter.formatCellValue(row.getCell(4));//性别
|
|
|
+ String sex = dataFormatter.formatCellValue(row.getCell(3));//性别
|
|
|
if (!sex.equals("性别")) {
|
|
|
- return CommonResult.fail("导入数据第五列为性别");
|
|
|
- }
|
|
|
- String department = dataFormatter.formatCellValue(row.getCell(5));//部门
|
|
|
- if (!department.equals("部门")) {
|
|
|
- return CommonResult.fail("导入数据第六列为部门");
|
|
|
+ return CommonResult.fail("导入数据第四列为性别");
|
|
|
}
|
|
|
- String headImage = dataFormatter.formatCellValue(row.getCell(6));//人脸照片
|
|
|
- if (!headImage.equals("人脸照片")) {
|
|
|
- return CommonResult.fail("导入数据第七列为人脸照片");
|
|
|
+ String nation = dataFormatter.formatCellValue(row.getCell(4));//民族
|
|
|
+ if (!nation.equals("民族")) {
|
|
|
+ return CommonResult.fail("导入数据第五列为民族");
|
|
|
}
|
|
|
- String dormitoryNumber = dataFormatter.formatCellValue(row.getCell(7));//宿舍号
|
|
|
- if (!dormitoryNumber.equals("宿舍号")) {
|
|
|
- return CommonResult.fail("导入数据第八列为宿舍号");
|
|
|
+ String cardId = dataFormatter.formatCellValue(row.getCell(5));//身份证
|
|
|
+ if (!cardId.equals("身份证")) {
|
|
|
+ return CommonResult.fail("导入数据第六列为身份证");
|
|
|
}
|
|
|
- String grade = dataFormatter.formatCellValue(row.getCell(8));//年级
|
|
|
- if (!grade.equals("年级")) {
|
|
|
- return CommonResult.fail("导入数据第九列为年级");
|
|
|
+ String headImage = dataFormatter.formatCellValue(row.getCell(6));//照片
|
|
|
+ if (!headImage.equals("照片")) {
|
|
|
+ return CommonResult.fail("导入数据第七列为照片");
|
|
|
}
|
|
|
- String schoolClass = dataFormatter.formatCellValue(row.getCell(9));//班级
|
|
|
- if (!schoolClass.equals("班级")) {
|
|
|
- return CommonResult.fail("导入数据第十列为班级");
|
|
|
+ String timeGroup = dataFormatter.formatCellValue(row.getCell(7));//常规时间组
|
|
|
+ if (!timeGroup.equals("常规时间组")) {
|
|
|
+ return CommonResult.fail("导入数据第八列为常规时间组");
|
|
|
}
|
|
|
- String phone = dataFormatter.formatCellValue(row.getCell(10));//手机号
|
|
|
- if (!phone.equals("手机号")) {
|
|
|
- return CommonResult.fail("导入数据第十一列为手机号");
|
|
|
+ String address = dataFormatter.formatCellValue(row.getCell(8));//住址
|
|
|
+ if (!address.equals("住址")) {
|
|
|
+ return CommonResult.fail("导入数据第九列为住址");
|
|
|
}
|
|
|
- String affiliate = dataFormatter.formatCellValue(row.getCell(11));//关联人
|
|
|
- if (!affiliate.equals("关联人")) {
|
|
|
- return CommonResult.fail("导入数据第十二列为关联人");
|
|
|
+ String phone = dataFormatter.formatCellValue(row.getCell(9));//联系电话
|
|
|
+ if (!phone.equals("联系电话")) {
|
|
|
+ return CommonResult.fail("导入数据第十列为联系电话");
|
|
|
}
|
|
|
- String title = dataFormatter.formatCellValue(row.getCell(12));//职称
|
|
|
- if (!title.equals("职称")) {
|
|
|
- return CommonResult.fail("导入数据第十三列为职称");
|
|
|
+ String family = dataFormatter.formatCellValue(row.getCell(10));//家属
|
|
|
+ if (!family.equals("家属")) {
|
|
|
+ return CommonResult.fail("导入数据第十一列为家属");
|
|
|
}
|
|
|
- String address = dataFormatter.formatCellValue(row.getCell(13));//家庭住址
|
|
|
- if (!address.equals("家庭住址")) {
|
|
|
- return CommonResult.fail("导入数据第十四列为家庭住址");
|
|
|
+ String familyShip = dataFormatter.formatCellValue(row.getCell(11));//家属与本人关系
|
|
|
+ if (!familyShip.equals("家属与本人关系")) {
|
|
|
+ return CommonResult.fail("导入数据第十二列为家属与本人关系");
|
|
|
}
|
|
|
- String nation = dataFormatter.formatCellValue(row.getCell(14));//民族
|
|
|
- if (!nation.equals("民族")) {
|
|
|
- return CommonResult.fail("导入数据第十五列为民族");
|
|
|
+ String phoneTwo = dataFormatter.formatCellValue(row.getCell(12));//联系电话2
|
|
|
+ if (!phoneTwo.equals("联系电话2")) {
|
|
|
+ return CommonResult.fail("导入数据第十三列为联系电话2");
|
|
|
}
|
|
|
- String ofStudent = dataFormatter.formatCellValue(row.getCell(15));//生源地
|
|
|
- if (!ofStudent.equals("生源地")) {
|
|
|
- return CommonResult.fail("导入数据第十六列为生源地");
|
|
|
+ String familyTwo = dataFormatter.formatCellValue(row.getCell(13));//家属2
|
|
|
+ if (!familyTwo.equals("家属2")) {
|
|
|
+ return CommonResult.fail("导入数据第十四列为家属2");
|
|
|
}
|
|
|
- String graduate = dataFormatter.formatCellValue(row.getCell(16));//毕业学校
|
|
|
- if (!graduate.equals("毕业学校")) {
|
|
|
- return CommonResult.fail("导入数据第十七列为毕业学校");
|
|
|
- }
|
|
|
- String duties = dataFormatter.formatCellValue(row.getCell(17));//职务
|
|
|
- if (!duties.equals("职务")) {
|
|
|
- return CommonResult.fail("导入数据第十八列为职务");
|
|
|
+ String familyShipTwo = dataFormatter.formatCellValue(row.getCell(14));//家属与本人关系2
|
|
|
+ if (!familyShipTwo.equals("家属与本人关系2")) {
|
|
|
+ return CommonResult.fail("导入数据第十五列为家属与本人关系2");
|
|
|
}
|
|
|
} else {
|
|
|
SmartUser user = new SmartUser();
|
|
|
- String name = dataFormatter.formatCellValue(row.getCell(1));
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(2));
|
|
|
if (ObjectUtils.isEmpty(name)) {
|
|
|
return CommonResult.fail("第" + (rowNum + 2) + "条数据的名称不能为空");
|
|
|
}
|
|
|
|
|
|
- //身份是否为空判断
|
|
|
- String identity = dataFormatter.formatCellValue(row.getCell(2));
|
|
|
- if (ObjectUtils.isEmpty(identity)) {
|
|
|
- return CommonResult.fail(name + "的身份不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- String dormitoryNumber = dataFormatter.formatCellValue(row.getCell(7));//宿舍号
|
|
|
- String grade = dataFormatter.formatCellValue(row.getCell(8));//年级
|
|
|
- String schoolClass = dataFormatter.formatCellValue(row.getCell(9));//班级
|
|
|
- //身份为学生的情况下 宿舍号、年级、班级不能为空
|
|
|
- if (eIdentityStatu.integerOf(identity).intValue() == eIdentityStatu.Student.getValue()) {
|
|
|
- if (ObjectUtils.isEmpty(dormitoryNumber)) {
|
|
|
- return CommonResult.fail(name + "的宿舍号不能为空");
|
|
|
- }
|
|
|
- if (ObjectUtils.isEmpty(grade)) {
|
|
|
- return CommonResult.fail(name + "的年级不能为空");
|
|
|
- }
|
|
|
- if (ObjectUtils.isEmpty(schoolClass)) {
|
|
|
- return CommonResult.fail(name + "的班级不能为空");
|
|
|
- }
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(0));//班级
|
|
|
+ if (ObjectUtils.isEmpty(schoolClass)) {
|
|
|
+ return CommonResult.fail(name + "的班级不能为空");
|
|
|
}
|
|
|
|
|
|
//手机号重复判断
|
|
|
- String phone = dataFormatter.formatCellValue(row.getCell(10));
|
|
|
- if (eIdentityStatu.integerOf(identity).intValue() == eIdentityStatu.Parent.getValue() || eIdentityStatu.integerOf(identity).intValue() == eIdentityStatu.Teacher.getValue()) {
|
|
|
- if (ObjectUtils.isEmpty(phone)) {
|
|
|
- return CommonResult.fail(name + "的手机号不能为空");
|
|
|
- }
|
|
|
+ String phone = dataFormatter.formatCellValue(row.getCell(9));
|
|
|
+ if (ObjectUtils.isEmpty(phone)) {
|
|
|
+ return CommonResult.fail(name + "家属的手机号不能为空");
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(phone)) {
|
|
|
phones.add(phone);
|
|
|
}
|
|
|
if (phones.stream().distinct().count() != phones.size()) {
|
|
|
- return CommonResult.fail("导入的Excel中,手机号:" + phone + "存在重复数据");
|
|
|
+ return CommonResult.fail("导入的Excel中,联系电话:" + phone + "存在重复数据");
|
|
|
}
|
|
|
|
|
|
- String affiliate = dataFormatter.formatCellValue(row.getCell(11));//关联人
|
|
|
- if (eIdentityStatu.integerOf(identity).intValue() == eIdentityStatu.Parent.getValue()) {
|
|
|
- if (ObjectUtils.isEmpty(affiliate)) {
|
|
|
- return CommonResult.fail(name + "的关联人不能为空");
|
|
|
- }
|
|
|
+ String family = dataFormatter.formatCellValue(row.getCell(10));//家属
|
|
|
+ if (ObjectUtils.isEmpty(family)) {
|
|
|
+ return CommonResult.fail(name + "的家属不能为空");
|
|
|
}
|
|
|
|
|
|
//性别是否为空判断
|
|
|
- String sex = dataFormatter.formatCellValue(row.getCell(4));
|
|
|
+ String sex = dataFormatter.formatCellValue(row.getCell(3));
|
|
|
if (ObjectUtils.isEmpty(sex)) {
|
|
|
return CommonResult.fail(name + "的性别不能为空");
|
|
|
}
|
|
|
|
|
|
//家庭住址是否为空判断
|
|
|
- String address = dataFormatter.formatCellValue(row.getCell(13));
|
|
|
+ String address = dataFormatter.formatCellValue(row.getCell(8));
|
|
|
if (ObjectUtils.isEmpty(address)) {
|
|
|
return CommonResult.fail(name + "的家庭住址不能为空");
|
|
|
}
|
|
|
@@ -440,54 +594,49 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
|
|
|
//部门是否为空判断
|
|
|
- String department = dataFormatter.formatCellValue(row.getCell(5));
|
|
|
+ String department = dataFormatter.formatCellValue(row.getCell(0)).replace("年级", "") + "学生";
|
|
|
if (ObjectUtils.isEmpty(department)) {
|
|
|
return CommonResult.fail(name + "的部门不能为空");
|
|
|
}
|
|
|
- int lastIndex = department.lastIndexOf("/");
|
|
|
Integer departmentId = null;
|
|
|
- if (lastIndex >= 0) {
|
|
|
- Optional<SmartDepartment> departModel = departments.stream().filter(e -> e.getName().equals(department.substring(lastIndex))).findFirst();
|
|
|
- if (departModel != null && departModel.isPresent()) {
|
|
|
- departmentId = departModel.get().getId();
|
|
|
- }
|
|
|
+ Optional<SmartDepartment> departModel = departments.stream().filter(e -> e.getName().equals(department)).findFirst();
|
|
|
+ if (departModel != null && departModel.isPresent()) {
|
|
|
+ departmentId = departModel.get().getId();
|
|
|
}
|
|
|
|
|
|
//学号重复判断
|
|
|
- String cardNo = dataFormatter.formatCellValue(row.getCell(0));
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(1));
|
|
|
if (!ObjectUtils.isEmpty(cardNo)) {
|
|
|
cardNos.add(cardNo);
|
|
|
}
|
|
|
if (cardNos.stream().distinct().count() != cardNos.size()) {
|
|
|
- return CommonResult.fail("导入的Excel中,卡号:" + cardNo + "存在重复数据");
|
|
|
+ return CommonResult.fail("导入的Excel中," + name + "的学号:" + cardNo + "存在重复数据");
|
|
|
}
|
|
|
|
|
|
//身份证重复判断
|
|
|
- String idCard = dataFormatter.formatCellValue(row.getCell(3));
|
|
|
+ String idCard = dataFormatter.formatCellValue(row.getCell(5));
|
|
|
if (!ObjectUtils.isEmpty(idCard)) {
|
|
|
idCards.add(idCard);
|
|
|
}
|
|
|
- //List<String> noEmptyIdCards = idCards.stream().filter(e -> !e.equals("") || e != null).collect(Collectors.toList());
|
|
|
if (idCards.stream().distinct().count() != idCards.size()) {
|
|
|
- return CommonResult.fail("导入的Excel中,身份证号:" + idCard + "存在重复数据");
|
|
|
+ return CommonResult.fail("导入的Excel中," + name + "的身份证号:" + idCard + "存在重复数据");
|
|
|
}
|
|
|
user.setCardNo(cardNo == null ? "" : cardNo);
|
|
|
user.setName(name == null ? "" : name);
|
|
|
- user.setIdentityId(identity == null ? eIdentityStatu.Student.getValue() : eIdentityStatu.integerOf(identity));
|
|
|
+ user.setIdentityId(eIdentityStatu.Student.getValue());
|
|
|
user.setIdCard(idCard == null ? "" : idCard);
|
|
|
user.setSexId(sex == null ? eSexStatu.Man.getValue() : eSexStatu.integerOf(sex));
|
|
|
user.setDepartmentId(departmentId);
|
|
|
String cellImage = dataFormatter.formatCellValue(row.getCell(6));
|
|
|
user.setHeadImage(cellImage);
|
|
|
- user.setDormitoryNumber(dormitoryNumber == null ? "" : dormitoryNumber);
|
|
|
- user.setGrade(grade == null ? "" : grade);
|
|
|
+ user.setDormitoryNumber("");
|
|
|
+ String grade = schoolClass == null ? "" : schoolClass.substring(0, 3);
|
|
|
+ user.setGrade(grade);
|
|
|
Optional<SmartGrade> oGrade = grades.stream().filter(e -> e.getName().equals(grade)).findFirst();
|
|
|
-
|
|
|
if (oGrade != null && oGrade.isPresent()) {
|
|
|
Integer gradeId = oGrade.get().getId();
|
|
|
-
|
|
|
- Optional<SmartClass> oClass = classs.stream().filter(e -> e.getName().equals(schoolClass) && e.getGradeId().equals(gradeId)).findFirst();
|
|
|
-
|
|
|
+ String schoolClassStr = schoolClass.replace("grade", "");
|
|
|
+ Optional<SmartClass> oClass = classs.stream().filter(e -> e.getName().equals(schoolClassStr) && e.getGradeId().equals(gradeId)).findFirst();
|
|
|
if (oClass != null && oClass.isPresent()) {
|
|
|
user.setSchoolClass(oClass.get().getId());
|
|
|
} else {
|
|
|
@@ -497,25 +646,46 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
} else {
|
|
|
return CommonResult.fail(name + "的年级数据无效,导入失败");
|
|
|
}
|
|
|
-
|
|
|
user.setCollege("");
|
|
|
user.setSpeciality("");
|
|
|
user.setCampus("");
|
|
|
user.setPhone(phone == null ? "" : phone);
|
|
|
- user.setAffiliate(affiliate == null ? "" : affiliate);
|
|
|
- String title = dataFormatter.formatCellValue(row.getCell(12));//职称
|
|
|
- user.setTitle(title == null ? "" : title);
|
|
|
+ user.setAffiliate("");
|
|
|
+ user.setTitle("");
|
|
|
user.setAddress(address == null ? "" : address);
|
|
|
user.setNation(nation == null ? "" : nation);
|
|
|
- String ofStudent = dataFormatter.formatCellValue(row.getCell(15));//生源地
|
|
|
- user.setOfStudent(ofStudent == null ? "" : ofStudent);
|
|
|
- String graduate = dataFormatter.formatCellValue(row.getCell(16));//毕业学校
|
|
|
- user.setGraduate(graduate == null ? "" : graduate);
|
|
|
- String duties = dataFormatter.formatCellValue(row.getCell(17));//职务
|
|
|
- user.setDuties(duties == null ? null : Integer.valueOf(duties));
|
|
|
+ user.setOfStudent("");
|
|
|
+ user.setGraduate("");
|
|
|
+ user.setDuties(null);
|
|
|
+ String timeGroup = dataFormatter.formatCellValue(row.getCell(7));
|
|
|
+ user.setTimeGroupId(eTimeGroup.integerOfTimeName(timeGroup));
|
|
|
user.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
|
|
|
result.add(user);
|
|
|
+
|
|
|
+ //region 家属
|
|
|
+ SmartUser familyOne = new SmartUser();
|
|
|
+ familyOne.setName(family);
|
|
|
+ familyOne.setPhone(phone);
|
|
|
+ familyOne.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ familyOne.setAffiliate(user.getCardNo());
|
|
|
+ String familyShip = dataFormatter.formatCellValue(row.getCell(11));//家属与本人关系
|
|
|
+ familyOne.setShip(familyShip == null ? "" : familyShip);
|
|
|
+ result.add(familyOne);
|
|
|
+
|
|
|
+ SmartUser familyTwo = new SmartUser();
|
|
|
+ String familyNameTwo = dataFormatter.formatCellValue(row.getCell(13));//家属2
|
|
|
+ if (!ObjectUtils.isEmpty(familyNameTwo)) {
|
|
|
+ familyTwo.setName(familyNameTwo);
|
|
|
+ String phoneTwo = dataFormatter.formatCellValue(row.getCell(12));//联系电话2
|
|
|
+ familyTwo.setPhone(phoneTwo == null ? "" : phoneTwo);
|
|
|
+ familyTwo.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ familyOne.setAffiliate(user.getCardNo());
|
|
|
+ String familyShipTwo = dataFormatter.formatCellValue(row.getCell(14));//家属与本人关系2
|
|
|
+ familyTwo.setShip(familyShipTwo == null ? "" : familyShipTwo);
|
|
|
+ result.add(familyTwo);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -558,136 +728,103 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//然后poi会根据字符串读取它
|
|
|
//标题 校验
|
|
|
if (rowNum == 0) {
|
|
|
- String cardNo = dataFormatter.formatCellValue(row.getCell(0));//学号
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(0));//班级
|
|
|
+ if (!schoolClass.equals("班级")) {
|
|
|
+ return CommonResult.fail("导入数据第一列为班级");
|
|
|
+ }
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(1));//学号
|
|
|
if (!cardNo.equals("学号")) {
|
|
|
- return CommonResult.fail("导入数据第一列为学号");
|
|
|
+ return CommonResult.fail("导入数据第二列为学号");
|
|
|
}
|
|
|
- String name = dataFormatter.formatCellValue(row.getCell(1));//姓名
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
|
|
|
if (!name.equals("姓名")) {
|
|
|
- return CommonResult.fail("导入数据第二列为姓名");
|
|
|
- }
|
|
|
- String identity = dataFormatter.formatCellValue(row.getCell(2));//身份
|
|
|
- if (!identity.equals("身份")) {
|
|
|
- return CommonResult.fail("导入数据第三列为身份");
|
|
|
+ return CommonResult.fail("导入数据第三列为姓名");
|
|
|
}
|
|
|
- String idCard = dataFormatter.formatCellValue(row.getCell(3));//身份证
|
|
|
- if (!idCard.equals("身份证")) {
|
|
|
- return CommonResult.fail("导入数据第四列为身份证");
|
|
|
- }
|
|
|
- String sex = dataFormatter.formatCellValue(row.getCell(4));//性别
|
|
|
+ String sex = dataFormatter.formatCellValue(row.getCell(3));//性别
|
|
|
if (!sex.equals("性别")) {
|
|
|
- return CommonResult.fail("导入数据第五列为性别");
|
|
|
- }
|
|
|
- String department = dataFormatter.formatCellValue(row.getCell(5));//部门
|
|
|
- if (!department.equals("部门")) {
|
|
|
- return CommonResult.fail("导入数据第六列为部门");
|
|
|
- }
|
|
|
- String headImage = dataFormatter.formatCellValue(row.getCell(6));//人脸照片
|
|
|
- if (!headImage.equals("人脸照片")) {
|
|
|
- return CommonResult.fail("导入数据第七列为人脸照片");
|
|
|
+ return CommonResult.fail("导入数据第四列为性别");
|
|
|
}
|
|
|
- String dormitoryNumber = dataFormatter.formatCellValue(row.getCell(7));//宿舍号
|
|
|
- if (!dormitoryNumber.equals("宿舍号")) {
|
|
|
- return CommonResult.fail("导入数据第八列为宿舍号");
|
|
|
+ String nation = dataFormatter.formatCellValue(row.getCell(4));//民族
|
|
|
+ if (!nation.equals("民族")) {
|
|
|
+ return CommonResult.fail("导入数据第五列为民族");
|
|
|
}
|
|
|
- String grade = dataFormatter.formatCellValue(row.getCell(8));//年级
|
|
|
- if (!grade.equals("年级")) {
|
|
|
- return CommonResult.fail("导入数据第九列为年级");
|
|
|
+ String cardId = dataFormatter.formatCellValue(row.getCell(5));//身份证
|
|
|
+ if (!cardId.equals("身份证")) {
|
|
|
+ return CommonResult.fail("导入数据第六列为身份证");
|
|
|
}
|
|
|
- String schoolClass = dataFormatter.formatCellValue(row.getCell(9));//班级
|
|
|
- if (!schoolClass.equals("班级")) {
|
|
|
- return CommonResult.fail("导入数据第十列为班级");
|
|
|
+ String headImage = dataFormatter.formatCellValue(row.getCell(6));//照片
|
|
|
+ if (!headImage.equals("照片")) {
|
|
|
+ return CommonResult.fail("导入数据第七列为照片");
|
|
|
}
|
|
|
- String phone = dataFormatter.formatCellValue(row.getCell(10));//手机号
|
|
|
- if (!phone.equals("手机号")) {
|
|
|
- return CommonResult.fail("导入数据第十一列为手机号");
|
|
|
+ String timeGroup = dataFormatter.formatCellValue(row.getCell(7));//常规时间组
|
|
|
+ if (!timeGroup.equals("常规时间组")) {
|
|
|
+ return CommonResult.fail("导入数据第八列为常规时间组");
|
|
|
}
|
|
|
- String affiliate = dataFormatter.formatCellValue(row.getCell(11));//关联人
|
|
|
- if (!affiliate.equals("关联人")) {
|
|
|
- return CommonResult.fail("导入数据第十二列为关联人");
|
|
|
+ String address = dataFormatter.formatCellValue(row.getCell(8));//住址
|
|
|
+ if (!address.equals("住址")) {
|
|
|
+ return CommonResult.fail("导入数据第九列为住址");
|
|
|
}
|
|
|
- String title = dataFormatter.formatCellValue(row.getCell(12));//职称
|
|
|
- if (!title.equals("职称")) {
|
|
|
- return CommonResult.fail("导入数据第十三列为职称");
|
|
|
+ String phone = dataFormatter.formatCellValue(row.getCell(9));//联系电话
|
|
|
+ if (!phone.equals("联系电话")) {
|
|
|
+ return CommonResult.fail("导入数据第十列为联系电话");
|
|
|
}
|
|
|
- String address = dataFormatter.formatCellValue(row.getCell(13));//家庭住址
|
|
|
- if (!address.equals("家庭住址")) {
|
|
|
- return CommonResult.fail("导入数据第十四列为家庭住址");
|
|
|
+ String family = dataFormatter.formatCellValue(row.getCell(10));//家属
|
|
|
+ if (!family.equals("家属")) {
|
|
|
+ return CommonResult.fail("导入数据第十一列为家属");
|
|
|
}
|
|
|
- String nation = dataFormatter.formatCellValue(row.getCell(14));//民族
|
|
|
- if (!nation.equals("民族")) {
|
|
|
- return CommonResult.fail("导入数据第十五列为民族");
|
|
|
+ String familyShip = dataFormatter.formatCellValue(row.getCell(11));//家属与本人关系
|
|
|
+ if (!familyShip.equals("家属与本人关系")) {
|
|
|
+ return CommonResult.fail("导入数据第十二列为家属与本人关系");
|
|
|
}
|
|
|
- String ofStudent = dataFormatter.formatCellValue(row.getCell(15));//生源地
|
|
|
- if (!ofStudent.equals("生源地")) {
|
|
|
- return CommonResult.fail("导入数据第十六列为生源地");
|
|
|
+ String phoneTwo = dataFormatter.formatCellValue(row.getCell(12));//联系电话2
|
|
|
+ if (!phoneTwo.equals("联系电话2")) {
|
|
|
+ return CommonResult.fail("导入数据第十三列为联系电话2");
|
|
|
}
|
|
|
- String graduate = dataFormatter.formatCellValue(row.getCell(16));//毕业学校
|
|
|
- if (!graduate.equals("毕业学校")) {
|
|
|
- return CommonResult.fail("导入数据第十七列为毕业学校");
|
|
|
+ String familyTwo = dataFormatter.formatCellValue(row.getCell(13));//家属2
|
|
|
+ if (!familyTwo.equals("家属2")) {
|
|
|
+ return CommonResult.fail("导入数据第十四列为家属2");
|
|
|
}
|
|
|
- String duties = dataFormatter.formatCellValue(row.getCell(17));//职务
|
|
|
- if (!duties.equals("职务")) {
|
|
|
- return CommonResult.fail("导入数据第十八列为职务");
|
|
|
+ String familyShipTwo = dataFormatter.formatCellValue(row.getCell(14));//家属与本人关系2
|
|
|
+ if (!familyShipTwo.equals("家属与本人关系2")) {
|
|
|
+ return CommonResult.fail("导入数据第十五列为家属与本人关系2");
|
|
|
}
|
|
|
} else {
|
|
|
SmartUser user = new SmartUser();
|
|
|
- String name = dataFormatter.formatCellValue(row.getCell(1));
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(2));
|
|
|
if (ObjectUtils.isEmpty(name)) {
|
|
|
return CommonResult.fail("第" + (rowNum + 2) + "条数据的名称不能为空");
|
|
|
}
|
|
|
|
|
|
- //身份是否为空判断
|
|
|
- String identity = dataFormatter.formatCellValue(row.getCell(2));
|
|
|
- if (ObjectUtils.isEmpty(identity)) {
|
|
|
- return CommonResult.fail(name + "的身份不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- String dormitoryNumber = dataFormatter.formatCellValue(row.getCell(7));//宿舍号
|
|
|
- String grade = dataFormatter.formatCellValue(row.getCell(8));//年级
|
|
|
- String schoolClass = dataFormatter.formatCellValue(row.getCell(9));//班级
|
|
|
- //身份为学生的情况下 宿舍号、年级、班级不能为空
|
|
|
- if (eIdentityStatu.integerOf(identity).intValue() == eIdentityStatu.Student.getValue()) {
|
|
|
- if (ObjectUtils.isEmpty(dormitoryNumber)) {
|
|
|
- return CommonResult.fail(name + "的宿舍号不能为空");
|
|
|
- }
|
|
|
- if (ObjectUtils.isEmpty(grade)) {
|
|
|
- return CommonResult.fail(name + "的年级不能为空");
|
|
|
- }
|
|
|
- if (ObjectUtils.isEmpty(schoolClass)) {
|
|
|
- return CommonResult.fail(name + "的班级不能为空");
|
|
|
- }
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(0));//班级
|
|
|
+ if (ObjectUtils.isEmpty(schoolClass)) {
|
|
|
+ return CommonResult.fail(name + "的班级不能为空");
|
|
|
}
|
|
|
|
|
|
//手机号重复判断
|
|
|
- String phone = dataFormatter.formatCellValue(row.getCell(10));
|
|
|
- if (eIdentityStatu.integerOf(identity).intValue() == eIdentityStatu.Parent.getValue() || eIdentityStatu.integerOf(identity).intValue() == eIdentityStatu.Teacher.getValue()) {
|
|
|
- if (ObjectUtils.isEmpty(phone)) {
|
|
|
- return CommonResult.fail(name + "的手机号不能为空");
|
|
|
- }
|
|
|
+ String phone = dataFormatter.formatCellValue(row.getCell(9));
|
|
|
+ if (ObjectUtils.isEmpty(phone)) {
|
|
|
+ return CommonResult.fail(name + "家属的手机号不能为空");
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(phone)) {
|
|
|
phones.add(phone);
|
|
|
}
|
|
|
if (phones.stream().distinct().count() != phones.size()) {
|
|
|
- return CommonResult.fail("导入的Excel中,手机号:" + phone + "存在重复数据");
|
|
|
+ return CommonResult.fail("导入的Excel中,联系电话:" + phone + "存在重复数据");
|
|
|
}
|
|
|
|
|
|
- String affiliate = dataFormatter.formatCellValue(row.getCell(11));//关联人
|
|
|
- if (eIdentityStatu.integerOf(identity).intValue() == eIdentityStatu.Parent.getValue()) {
|
|
|
- if (ObjectUtils.isEmpty(affiliate)) {
|
|
|
- return CommonResult.fail(name + "的关联人不能为空");
|
|
|
- }
|
|
|
+ String family = dataFormatter.formatCellValue(row.getCell(10));//家属
|
|
|
+ if (ObjectUtils.isEmpty(family)) {
|
|
|
+ return CommonResult.fail(name + "的家属不能为空");
|
|
|
}
|
|
|
|
|
|
//性别是否为空判断
|
|
|
- String sex = dataFormatter.formatCellValue(row.getCell(4));
|
|
|
+ String sex = dataFormatter.formatCellValue(row.getCell(3));
|
|
|
if (ObjectUtils.isEmpty(sex)) {
|
|
|
return CommonResult.fail(name + "的性别不能为空");
|
|
|
}
|
|
|
|
|
|
//家庭住址是否为空判断
|
|
|
- String address = dataFormatter.formatCellValue(row.getCell(13));
|
|
|
+ String address = dataFormatter.formatCellValue(row.getCell(8));
|
|
|
if (ObjectUtils.isEmpty(address)) {
|
|
|
return CommonResult.fail(name + "的家庭住址不能为空");
|
|
|
}
|
|
|
@@ -699,55 +836,49 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
|
|
|
//部门是否为空判断
|
|
|
- String department = dataFormatter.formatCellValue(row.getCell(5));
|
|
|
+ String department = dataFormatter.formatCellValue(row.getCell(0)).replace("年级", "") + "学生";
|
|
|
if (ObjectUtils.isEmpty(department)) {
|
|
|
return CommonResult.fail(name + "的部门不能为空");
|
|
|
}
|
|
|
- int lastIndex = department.lastIndexOf("/");
|
|
|
Integer departmentId = null;
|
|
|
- if (lastIndex >= 0) {
|
|
|
- Optional<SmartDepartment> departModel = departments.stream().filter(e -> e.getName().equals(department.substring(lastIndex))).findFirst();
|
|
|
- if (departModel != null && departModel.isPresent()) {
|
|
|
- departmentId = departModel.get().getId();
|
|
|
- }
|
|
|
+ Optional<SmartDepartment> departModel = departments.stream().filter(e -> e.getName().equals(department)).findFirst();
|
|
|
+ if (departModel != null && departModel.isPresent()) {
|
|
|
+ departmentId = departModel.get().getId();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//学号重复判断
|
|
|
- String cardNo = dataFormatter.formatCellValue(row.getCell(0));
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(1));
|
|
|
if (!ObjectUtils.isEmpty(cardNo)) {
|
|
|
cardNos.add(cardNo);
|
|
|
}
|
|
|
if (cardNos.stream().distinct().count() != cardNos.size()) {
|
|
|
- return CommonResult.fail("导入的Excel中,卡号:" + cardNo + "存在重复数据");
|
|
|
+ return CommonResult.fail("导入的Excel中," + name + "的学号:" + cardNo + "存在重复数据");
|
|
|
}
|
|
|
|
|
|
//身份证重复判断
|
|
|
- String idCard = dataFormatter.formatCellValue(row.getCell(3));
|
|
|
+ String idCard = dataFormatter.formatCellValue(row.getCell(5));
|
|
|
if (!ObjectUtils.isEmpty(idCard)) {
|
|
|
idCards.add(idCard);
|
|
|
}
|
|
|
- //List<String> noEmptyIdCards = idCards.stream().filter(e -> !e.equals("") || e != null).collect(Collectors.toList());
|
|
|
if (idCards.stream().distinct().count() != idCards.size()) {
|
|
|
- return CommonResult.fail("导入的Excel中,身份证号:" + idCard + "存在重复数据");
|
|
|
+ return CommonResult.fail("导入的Excel中," + name + "的身份证号:" + idCard + "存在重复数据");
|
|
|
}
|
|
|
user.setCardNo(cardNo == null ? "" : cardNo);
|
|
|
user.setName(name == null ? "" : name);
|
|
|
- user.setIdentityId(identity == null ? eIdentityStatu.Student.getValue() : eIdentityStatu.integerOf(identity));
|
|
|
+ user.setIdentityId(eIdentityStatu.Student.getValue());
|
|
|
user.setIdCard(idCard == null ? "" : idCard);
|
|
|
user.setSexId(sex == null ? eSexStatu.Man.getValue() : eSexStatu.integerOf(sex));
|
|
|
user.setDepartmentId(departmentId);
|
|
|
String cellImage = dataFormatter.formatCellValue(row.getCell(6));
|
|
|
user.setHeadImage(cellImage);
|
|
|
- user.setDormitoryNumber(dormitoryNumber == null ? "" : dormitoryNumber);
|
|
|
- user.setGrade(grade == null ? "" : grade);
|
|
|
+ user.setDormitoryNumber("");
|
|
|
+ String grade = schoolClass == null ? "" : schoolClass.substring(0, 3);
|
|
|
+ user.setGrade(grade);
|
|
|
Optional<SmartGrade> oGrade = grades.stream().filter(e -> e.getName().equals(grade)).findFirst();
|
|
|
-
|
|
|
if (oGrade != null && oGrade.isPresent()) {
|
|
|
Integer gradeId = oGrade.get().getId();
|
|
|
-
|
|
|
- Optional<SmartClass> oClass = classs.stream().filter(e -> e.getName().equals(schoolClass) && e.getGradeId().equals(gradeId)).findFirst();
|
|
|
-
|
|
|
+ String schoolClassStr = schoolClass.replace("grade", "");
|
|
|
+ Optional<SmartClass> oClass = classs.stream().filter(e -> e.getName().equals(schoolClassStr) && e.getGradeId().equals(gradeId)).findFirst();
|
|
|
if (oClass != null && oClass.isPresent()) {
|
|
|
user.setSchoolClass(oClass.get().getId());
|
|
|
} else {
|
|
|
@@ -761,20 +892,40 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
user.setSpeciality("");
|
|
|
user.setCampus("");
|
|
|
user.setPhone(phone == null ? "" : phone);
|
|
|
- user.setAffiliate(affiliate == null ? "" : affiliate);
|
|
|
- String title = dataFormatter.formatCellValue(row.getCell(12));//职称
|
|
|
- user.setTitle(title == null ? "" : title);
|
|
|
+ user.setAffiliate("");
|
|
|
+ user.setTitle("");
|
|
|
user.setAddress(address == null ? "" : address);
|
|
|
user.setNation(nation == null ? "" : nation);
|
|
|
- String ofStudent = dataFormatter.formatCellValue(row.getCell(15));//生源地
|
|
|
- user.setOfStudent(ofStudent == null ? "" : ofStudent);
|
|
|
- String graduate = dataFormatter.formatCellValue(row.getCell(16));//毕业学校
|
|
|
- user.setGraduate(graduate == null ? "" : graduate);
|
|
|
- String duties = dataFormatter.formatCellValue(row.getCell(17));//职务
|
|
|
- user.setDuties(duties == null ? null : Integer.valueOf(duties));
|
|
|
+ user.setOfStudent("");
|
|
|
+ user.setGraduate("");
|
|
|
+ user.setDuties(null);
|
|
|
+ String timeGroup = dataFormatter.formatCellValue(row.getCell(7));
|
|
|
+ user.setTimeGroupId(eTimeGroup.integerOfTimeName(timeGroup));
|
|
|
user.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
|
|
|
result.add(user);
|
|
|
+
|
|
|
+ //region 家属
|
|
|
+ SmartUser familyOne = new SmartUser();
|
|
|
+ familyOne.setName(family);
|
|
|
+ familyOne.setPhone(phone);
|
|
|
+ familyOne.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ String familyShip = dataFormatter.formatCellValue(row.getCell(11));//家属与本人关系
|
|
|
+ familyOne.setShip(familyShip == null ? "" : familyShip);
|
|
|
+ result.add(familyOne);
|
|
|
+
|
|
|
+ SmartUser familyTwo = new SmartUser();
|
|
|
+ String familyNameTwo = dataFormatter.formatCellValue(row.getCell(13));//家属2
|
|
|
+ if (!ObjectUtils.isEmpty(familyNameTwo)) {
|
|
|
+ familyTwo.setName(familyNameTwo);
|
|
|
+ String phoneTwo = dataFormatter.formatCellValue(row.getCell(12));//联系电话2
|
|
|
+ familyTwo.setPhone(phoneTwo == null ? "" : phoneTwo);
|
|
|
+ familyTwo.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ String familyShipTwo = dataFormatter.formatCellValue(row.getCell(14));//家属与本人关系2
|
|
|
+ familyTwo.setShip(familyShipTwo == null ? "" : familyShipTwo);
|
|
|
+ result.add(familyTwo);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1345,7 +1496,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//返回的结果中 code为1表示成功
|
|
|
String bsResult = RequestUtils.httpPost(url, jsonobject.toJSONString());
|
|
|
|
|
|
- if(bsResult.contains("人员不存在或已删除")){
|
|
|
+ if (bsResult.contains("人员不存在或已删除")) {
|
|
|
//获取班级Uid
|
|
|
SmartClass classData = smartClassService.getSmartClassById(usur.getSchoolClass());
|
|
|
if (classData == null) {
|
|
|
@@ -1516,7 +1667,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
for (UserVo data : result.getList()) {
|
|
|
Optional<SmartIdentity> identityData = idnetitys.stream().filter(e -> e.getId().equals(data.getIdentityId())).findFirst();
|
|
|
- if(identityData != null && identityData.isPresent()){
|
|
|
+ if (identityData != null && identityData.isPresent()) {
|
|
|
data.setIdentity(identityData.get().getName());
|
|
|
}
|
|
|
|
|
|
@@ -1850,7 +2001,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
return CommonResult.fail("当前学生信息已绑定过,请勿重复操作!");
|
|
|
}
|
|
|
|
|
|
- parentUser.setAffiliate(parentUser.getAffiliate() + "," +String.valueOf(studentUser.getId()));
|
|
|
+ parentUser.setAffiliate(parentUser.getAffiliate() + "," + String.valueOf(studentUser.getId()));
|
|
|
}
|
|
|
|
|
|
//region 新增希沃学生家长信息
|