|
|
@@ -220,6 +220,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
return CommonResult.fail("年级数据无效,新增失败");
|
|
|
}
|
|
|
|
|
|
+ HashMap<String, List<StudentServiceBatchSaveClassStudentsParam.StudentInfo>> seewoDatas = new HashMap<>();
|
|
|
for (SmartUser student : studentDatas) {
|
|
|
|
|
|
//region 学生参数必填判断:年级、班级
|
|
|
@@ -245,19 +246,36 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
SmartClass classData = oClassData.get();
|
|
|
SmartGrade gradeData = oGradeData.get();
|
|
|
|
|
|
- //region 希沃新增学生信息
|
|
|
+ //region 凑希沃参数
|
|
|
if (useXw == 1) {
|
|
|
- //初始化客户端
|
|
|
- SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
- CommonResult<String> insertStudent = SeewoInsertStudent(seewoClient, student.getName(), student.getCardNo(), student.getSexId(), student.getPhone(), classData.getClassUid());
|
|
|
- if (!insertStudent.isSuccess()) {
|
|
|
- return CommonResult.fail(insertStudent.getMessage());
|
|
|
+ if (!seewoDatas.containsKey(classData.getClassUid())) {
|
|
|
+ seewoDatas.put(classData.getClassUid(), new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
- student.setXwStudentUid(insertStudent.getData());
|
|
|
+ StudentServiceBatchSaveClassStudentsParam.StudentInfo studentSeewo = StudentServiceBatchSaveClassStudentsParam.StudentInfo.builder()
|
|
|
+ .studentName(student.getName())
|
|
|
+ .studentCode(student.getCardNo())
|
|
|
+ .gender(student.getSexId())
|
|
|
+ .phone(student.getPhone() == null ? "" : student.getPhone())
|
|
|
+ .build();
|
|
|
+
|
|
|
+ seewoDatas.get(classData.getClassUid()).add(studentSeewo);
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
+ //region 希沃新增学生信息
|
|
|
+// if (useXw == 1) {
|
|
|
+// //初始化客户端
|
|
|
+// SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+// CommonResult<String> insertStudent = SeewoInsertStudent(seewoClient, student.getName(), student.getCardNo(), student.getSexId(), student.getPhone(), classData.getClassUid());
|
|
|
+// if (!insertStudent.isSuccess()) {
|
|
|
+// return CommonResult.fail(insertStudent.getMessage());
|
|
|
+// }
|
|
|
+//
|
|
|
+// student.setXwStudentUid(insertStudent.getData());
|
|
|
+// }
|
|
|
+ //endregion
|
|
|
+
|
|
|
//region 百胜新增学生信息
|
|
|
if (useBs == 1) {
|
|
|
/**
|
|
|
@@ -275,6 +293,30 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if (useXw == 1) {
|
|
|
+ //初始化客户端
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+
|
|
|
+ List<StudentServiceBatchSaveClassStudentsResult.StudentInfoDto> seewoResultDatas = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<StudentServiceBatchSaveClassStudentsParam.StudentInfo>> entry : seewoDatas.entrySet()) {
|
|
|
+ String classUid = entry.getKey();
|
|
|
+ CommonResult<List<StudentServiceBatchSaveClassStudentsResult.StudentInfoDto>> insertStudents = SeewoInsertBatchStudent(seewoClient, entry.getValue(), classUid);
|
|
|
+ if (!insertStudents.isSuccess()) {
|
|
|
+ return CommonResult.fail(insertStudents.getMessage());
|
|
|
+ }
|
|
|
+ seewoResultDatas.addAll(insertStudents.getData());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (SmartUser student : studentDatas) {
|
|
|
+ Optional<StudentServiceBatchSaveClassStudentsResult.StudentInfoDto> seewoResultData = seewoResultDatas.stream().filter(e -> e.getStudentCode().equals(student.getCardNo())).findFirst();
|
|
|
+ if(seewoResultData != null && seewoResultData.isPresent()){
|
|
|
+ student.setXwStudentUid(seewoResultData.get().getUserUid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (studentDatas != null && studentDatas.size() > 0) {
|
|
|
//批量存储学生信息
|
|
|
boolean resultBool = smartUserService.saveBatch(studentDatas);
|
|
|
@@ -1384,7 +1426,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
*/
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
- public CommonResult updateSmartUserById(updateSmartUserRequest usur, BindingResult bindingResult) throws Exception {
|
|
|
+ public CommonResult updateSmartUserById(updateSmartUserRequest usur, BindingResult bindingResult) throws
|
|
|
+ Exception {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
|
return CommonResult.fail(st);
|
|
|
@@ -1828,8 +1871,53 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
//region 希沃增删改查方法
|
|
|
|
|
|
+ //region 希沃批量新增学生信息
|
|
|
+ public CommonResult<List<StudentServiceBatchSaveClassStudentsResult.StudentInfoDto>> SeewoInsertBatchStudent
|
|
|
+ (SeewoClient seewoClient, List<StudentServiceBatchSaveClassStudentsParam.StudentInfo> students, String
|
|
|
+ classUid) {
|
|
|
+ //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(classUid)
|
|
|
+ .build();
|
|
|
+ requestBody.setQuery(query);
|
|
|
+ // 学生列表
|
|
|
+ query.setStudents(students);
|
|
|
+ query.setInPlaceOld(false);// 是否删除旧学生再保存
|
|
|
+ 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 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok("200", "添加成功", result.getResponseBody().getData());
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
//region 希沃新增学生信息
|
|
|
- public CommonResult<String> SeewoInsertStudent(SeewoClient seewoClient, String name, String cardNo, Integer sexId, String Phone, String classUid) {
|
|
|
+ public CommonResult<String> SeewoInsertStudent(SeewoClient seewoClient, String name, String cardNo, Integer
|
|
|
+ sexId, String Phone, String classUid) {
|
|
|
//region 希沃新增学生信息
|
|
|
//初始化客户端
|
|
|
//SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
@@ -1958,7 +2046,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//region 希沃添加老师数据
|
|
|
//老师数据会根据手机号判断新增不新增
|
|
|
//手机号相同的情况下更新不新增
|
|
|
- public CommonResult<String> SeewoInsertTeacher(SeewoClient seewoClient, String phone, String name, String headImage) {
|
|
|
+ public CommonResult<String> SeewoInsertTeacher(SeewoClient seewoClient, String phone, String name, String
|
|
|
+ headImage) {
|
|
|
//region 希沃添加教师数据
|
|
|
//初始化客户端
|
|
|
//SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
@@ -2010,7 +2099,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//endregion
|
|
|
|
|
|
//region 希沃更新教师
|
|
|
- public CommonResult<String> SeewoUpdateTeacher(SeewoClient seewoClient, String phone, String name, String headImage) {
|
|
|
+ public CommonResult<String> SeewoUpdateTeacher(SeewoClient seewoClient, String phone, String name, String
|
|
|
+ headImage) {
|
|
|
//region 希沃更新教师数据
|
|
|
//初始化客户端
|
|
|
//SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
@@ -2184,7 +2274,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//endregion
|
|
|
|
|
|
//region 希沃新增编辑学生家长信息
|
|
|
- public CommonResult insertOrUpdateStudentParent(SeewoClient seewoClient, List<SmartUser> studentDatas, String name, String phone) {
|
|
|
+ public CommonResult insertOrUpdateStudentParent(SeewoClient
|
|
|
+ seewoClient, List<SmartUser> studentDatas, String name, String phone) {
|
|
|
//region 希沃新增编辑学生家长信息
|
|
|
//学生与家长列表,最大100条
|
|
|
List<ParentServiceBatchSaveOrUpdateParentsParam.StudentParentsItem> studentParents = new ArrayList<>();
|
|
|
@@ -2241,7 +2332,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//endregion
|
|
|
|
|
|
//region 希沃删除学生原有的家长关系
|
|
|
- public CommonResult deleteOldStudentParentShip(SeewoClient seewoClient, String cardNo, List<String> phones) throws JsonProcessingException {
|
|
|
+ public CommonResult deleteOldStudentParentShip(SeewoClient seewoClient, String cardNo, List<String> phones) throws
|
|
|
+ JsonProcessingException {
|
|
|
//region 删除原有的家长关系
|
|
|
//初始化客户端
|
|
|
//SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
@@ -2290,7 +2382,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//endregion
|
|
|
|
|
|
//region 希沃删除原有的家长关系
|
|
|
- public CommonResult deleteOldParentShip(SeewoClient seewoClient, List<SmartUser> studentDatas, String phone) throws JsonProcessingException {
|
|
|
+ public CommonResult deleteOldParentShip(SeewoClient seewoClient, List<SmartUser> studentDatas, String phone) throws
|
|
|
+ JsonProcessingException {
|
|
|
//region 删除原有的家长关系
|
|
|
//初始化客户端
|
|
|
//SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
@@ -2382,7 +2475,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//endregion
|
|
|
|
|
|
//region 百胜新增学生
|
|
|
- public CommonResult<String> bsInsertStudent(String name, String cardNo, Integer sexId, String headImage, Integer timeGroupId, String bsClassNo, String startDate, String endDate) throws Exception {
|
|
|
+ public CommonResult<String> bsInsertStudent(String name, String cardNo, Integer sexId, String
|
|
|
+ headImage, Integer timeGroupId, String bsClassNo, String startDate, String endDate) throws Exception {
|
|
|
//region 百胜新增学生信息
|
|
|
String appId = controlConfig.getAppId();
|
|
|
String schoolno = controlConfig.getSchoolCode();
|
|
|
@@ -2462,7 +2556,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//endregion
|
|
|
|
|
|
//region 百胜添加教师
|
|
|
- public CommonResult<String> bsInsertTeacher(SmartUser su, String departmentNo, String startDate, String endDate) throws Exception {
|
|
|
+ public CommonResult<String> bsInsertTeacher(SmartUser su, String departmentNo, String startDate, String endDate) throws
|
|
|
+ Exception {
|
|
|
//region 百胜添加教师数据
|
|
|
String appId = controlConfig.getAppId();
|
|
|
String schoolno = controlConfig.getSchoolCode();
|
|
|
@@ -2506,7 +2601,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//endregion
|
|
|
|
|
|
//region 百胜更新教师
|
|
|
- public CommonResult<String> updateBsTeacher(SmartUser su, String departmentNo, String startDate, String endDate) throws Exception {
|
|
|
+ public CommonResult<String> updateBsTeacher(SmartUser su, String departmentNo, String startDate, String endDate) throws
|
|
|
+ Exception {
|
|
|
//region 百胜更新教师数据
|
|
|
String appId = controlConfig.getAppId();
|
|
|
String schoolno = controlConfig.getSchoolCode();
|
|
|
@@ -2800,7 +2896,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
* @param lists 数据集合
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<DepartmentTreeVo> QueryDepartmentTreeRecords(Integer parentID, List<SmartDepartment> lists, List<Integer> departmentIds) {
|
|
|
+ private List<DepartmentTreeVo> QueryDepartmentTreeRecords(Integer
|
|
|
+ parentID, List<SmartDepartment> lists, List<Integer> departmentIds) {
|
|
|
List<DepartmentTreeVo> newTrees = new ArrayList<>();
|
|
|
|
|
|
List<SmartDepartment> datas = lists.stream().filter(e -> e.getParentId().equals(parentID)).collect(Collectors.toList());
|