|
|
@@ -2183,6 +2183,91 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//更新家长
|
|
|
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) {
|
|
|
+ List<String> familyCardNos = updateStudents.stream().map(SmartUser::getCardNo).distinct().collect(Collectors.toList());
|
|
|
+ List<SmartFamilyIndex> indexs = smartFamilyIndexService.querySmartFamilyByCardNo(familyCardNos);
|
|
|
+ //region 希沃新增编辑学生家长信息
|
|
|
+ if (useXw == 1) {
|
|
|
+ int num = (int) Math.ceil((double) updateStudents.size() / 100);
|
|
|
+ for (int count = 1; count <= num; count++) {
|
|
|
+ int startIndex = (count - 1) * 100;
|
|
|
+ int endIndex = count * 100;
|
|
|
+ if (count == num) {
|
|
|
+ endIndex = startIndex + (updateStudents.size() % 100);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartUser> currentStudentDatas = updateStudents.subList(startIndex, endIndex);//结尾不包含下标100
|
|
|
+ //学生与家长列表,最大100条
|
|
|
+ List<ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem> studentParents = new ArrayList<>();
|
|
|
+ for (SmartUser student : currentStudentDatas) {
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem students = ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem.builder()
|
|
|
+ .studentCode(student.getCardNo())
|
|
|
+ .build();
|
|
|
+
|
|
|
+
|
|
|
+ List<SmartUser> parentDatas = updateParents.stream().filter(e -> e.getIdentityId().intValue() == eIdentityStatu.Parent.getValue() && (","+e.getAffiliate()+",").contains(","+student.getId()+",")).collect(Collectors.toList());
|
|
|
+ List<ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem> parents = new ArrayList<>();
|
|
|
+
|
|
|
+ for (SmartUser parent : parentDatas) {
|
|
|
+ int i = 0;
|
|
|
+ Optional<SmartFamilyIndex> oIndexData = indexs.stream().filter(e -> e.getStudentNo().equals(student.getCardNo()) && e.getParentPhone().equals(parent.getPhone())).findFirst();
|
|
|
+ if(oIndexData != null && oIndexData.isPresent()){
|
|
|
+ i = oIndexData.get().getIndexData();
|
|
|
+ }
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem data = ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem.builder()
|
|
|
+ .name(parent.getShip())
|
|
|
+ .phone(parent.getPhone())
|
|
|
+ .index(i)
|
|
|
+ .build();
|
|
|
+ parents.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parents != null && parents.size() > 0) {
|
|
|
+ studentParents.add(students);
|
|
|
+ //家长列表,最多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);
|
|
|
+ String jsonString = JSON.toJSONString(request);
|
|
|
+ logger.info("入参:" + request);
|
|
|
+ //如果想要调用沙箱环境,请通过设置 request 对象的 serverUrl 属性,如:
|
|
|
+ //request.setServerUrl("https://openapi.test.seewo.com")
|
|
|
+ //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsResult parentResult = seewoClient.invoke(request);
|
|
|
+ logger.info("出参:" + parentResult);
|
|
|
+
|
|
|
+
|
|
|
+ if (parentResult == null) {
|
|
|
+ return CommonResult.fail("希沃学生家长数据添加失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!parentResult.getResponseBody().getCode().equals("000000")) {
|
|
|
+ return CommonResult.fail("希沃平台:" + parentResult.getResponseBody().getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //更新家长
|
|
|
+
|
|
|
+ if (updateParents != null && updateParents.size() > 0) {
|
|
|
boolean updateBatch = smartUserService.updateBatchById(updateParents);
|
|
|
if (!updateBatch) {
|
|
|
return CommonResult.fail("系统批量更新家长出错,导入失败");
|