|
|
@@ -17,10 +17,7 @@ import com.template.model.pojo.SmartClass;
|
|
|
import com.template.model.pojo.SmartDepartment;
|
|
|
import com.template.model.pojo.SmartGrade;
|
|
|
import com.template.model.pojo.SmartUser;
|
|
|
-import com.template.model.request.changeDepartmentRequest;
|
|
|
-import com.template.model.request.insertSmartUserRequest;
|
|
|
-import com.template.model.request.updateSmartUserRequest;
|
|
|
-import com.template.model.request.useridsRequest;
|
|
|
+import com.template.model.request.*;
|
|
|
import com.template.model.result.CommonResult;
|
|
|
import com.template.model.result.PageUtils;
|
|
|
import com.template.model.seewo.*;
|
|
|
@@ -1489,17 +1486,19 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
|
|
|
List<AffiliateUserVo> datas = new ArrayList<>();
|
|
|
- List<String> affiliates = Arrays.asList(data.getAffiliate().split(","));
|
|
|
- for (String a : affiliates) {
|
|
|
- if (!ObjectUtils.isEmpty(a)) {
|
|
|
- Optional<SmartUser> student = students.stream().filter(e -> e.getId().equals(Integer.valueOf(a))).findFirst();
|
|
|
- if (student != null && student.isPresent()) {
|
|
|
- AffiliateUserVo affiliate = new AffiliateUserVo();
|
|
|
- affiliate.setId(student.get().getId());
|
|
|
- affiliate.setName(student.get().getName());
|
|
|
- affiliate.setCardNo(student.get().getCardNo());
|
|
|
- affiliate.setDepartmentId(student.get().getDepartmentId());
|
|
|
- datas.add(affiliate);
|
|
|
+ if (data.getAffiliate() != null) {
|
|
|
+ List<String> affiliates = Arrays.asList(data.getAffiliate().split(","));
|
|
|
+ for (String a : affiliates) {
|
|
|
+ if (!ObjectUtils.isEmpty(a)) {
|
|
|
+ Optional<SmartUser> student = students.stream().filter(e -> e.getId().equals(Integer.valueOf(a))).findFirst();
|
|
|
+ if (student != null && student.isPresent()) {
|
|
|
+ AffiliateUserVo affiliate = new AffiliateUserVo();
|
|
|
+ affiliate.setId(student.get().getId());
|
|
|
+ affiliate.setName(student.get().getName());
|
|
|
+ affiliate.setCardNo(student.get().getCardNo());
|
|
|
+ affiliate.setDepartmentId(student.get().getDepartmentId());
|
|
|
+ datas.add(affiliate);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1702,10 +1701,10 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public CommonResult queryInfoData(int id){
|
|
|
+ public CommonResult queryInfoData(int id) {
|
|
|
|
|
|
SmartUser su = smartUserService.getSmartById(id);
|
|
|
- if(su == null){
|
|
|
+ if (su == null) {
|
|
|
return CommonResult.fail("用户信息失效,获取用户信息失败");
|
|
|
}
|
|
|
|
|
|
@@ -1740,15 +1739,15 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//查找关联人
|
|
|
if (su.getIdentityId().intValue() == eIdentityStatu.Student.getValue()) {//学生
|
|
|
List<AffiliateParentVo> parents = smartUserService.queryAffiliateParents(su.getId());
|
|
|
- if(parents != null && parents.size() > 0){
|
|
|
- String affiliateStr = StringUtils.join(parents.stream().map(AffiliateParentVo::getName).collect(Collectors.toList()),",");
|
|
|
+ if (parents != null && parents.size() > 0) {
|
|
|
+ String affiliateStr = StringUtils.join(parents.stream().map(AffiliateParentVo::getName).collect(Collectors.toList()), ",");
|
|
|
userData.setAffiliateName(affiliateStr);
|
|
|
}
|
|
|
} else if (su.getIdentityId().intValue() == eIdentityStatu.Parent.getValue()) {//家长
|
|
|
- if(su.getAffiliate() != null){
|
|
|
+ if (su.getAffiliate() != null) {
|
|
|
List<String> affiliates = Arrays.asList(su.getAffiliate().split(","));
|
|
|
List<SmartUser> childs = smartUserService.getSmartUserIds(affiliates);
|
|
|
- String affiliateStr = StringUtils.join(childs.stream().map(SmartUser::getName).collect(Collectors.toList()),",");
|
|
|
+ String affiliateStr = StringUtils.join(childs.stream().map(SmartUser::getName).collect(Collectors.toList()), ",");
|
|
|
userData.setAffiliateName(affiliateStr);
|
|
|
}
|
|
|
}
|
|
|
@@ -1772,5 +1771,90 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
return CommonResult.ok(userData);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult bindStudent(bindStudentRequest bsr, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ String st = paramUtils.getParamError(bindingResult);
|
|
|
+ return CommonResult.fail(st);
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartUser parentUser = smartUserService.getSmartById(bsr.getUserId());
|
|
|
+ if (parentUser == null) {
|
|
|
+ return CommonResult.fail("当前用户信息无效,绑定失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parentUser.getIdentityId().intValue() != eIdentityStatu.Parent.getValue()) {
|
|
|
+ return CommonResult.fail("当前用户身份无法进行绑定操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ //查找是否存在学生数据
|
|
|
+ SmartUser studentUser = smartUserService.queryUserInfo(bsr.getName(), bsr.getCardNo(), bsr.getIdCard());
|
|
|
+ if (studentUser == null) {
|
|
|
+ return CommonResult.fail("当前学生不存在,绑定失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断是否已绑定过
|
|
|
+ if (parentUser.getAffiliate() == null) {
|
|
|
+ parentUser.setAffiliate(String.valueOf(studentUser.getId()));
|
|
|
+ } else {
|
|
|
+ List<String> affiliates = Arrays.asList(parentUser.getAffiliate().split(","));
|
|
|
+ long existCount = affiliates.stream().filter(e -> e.equals(String.valueOf(studentUser.getId()))).count();
|
|
|
+ if (existCount > 0) {
|
|
|
+ return CommonResult.fail("当前学生信息已绑定过,请勿重复操作!");
|
|
|
+ }
|
|
|
+ affiliates.add(String.valueOf(studentUser.getId()));
|
|
|
+
|
|
|
+ parentUser.setAddress(StringUtils.join(affiliates.stream().distinct(), ","));
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 新增希沃学生家长信息
|
|
|
+ //初始化客户端
|
|
|
+ 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);
|
|
|
+ //学生与家长列表,最大100条
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem studentParents = ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem.builder()
|
|
|
+ .studentCode(studentUser.getCardNo())
|
|
|
+ .build();
|
|
|
+ query.setStudentParents(java.util.Collections.singletonList(studentParents));
|
|
|
+ //家长列表,最多4个
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem parents = ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem.builder()
|
|
|
+ .name(parentUser.getName())
|
|
|
+ .phone(parentUser.getPhone())
|
|
|
+ .index(0)
|
|
|
+ .build();
|
|
|
+ studentParents.setParents(java.util.Collections.singletonList(parents));
|
|
|
+ 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 result = seewoClient.invoke(request);
|
|
|
+ System.out.println("出参:" + result);
|
|
|
+
|
|
|
+ if (result == null) {
|
|
|
+ return CommonResult.fail("希沃学生家长数据添加失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!result.getResponseBody().getCode().equals("000000")) {
|
|
|
+ return CommonResult.fail(result.getResponseBody().getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ int updateResult = smartUserService.updateSmartUser(parentUser);
|
|
|
+
|
|
|
+ return updateResult > 0 ? CommonResult.ok("绑定成功") : CommonResult.fail("绑定失败");
|
|
|
+ }
|
|
|
}
|
|
|
|