|
|
@@ -1,29 +1,34 @@
|
|
|
package com.template.controller;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.qcloud.cos.utils.IOUtils;
|
|
|
+import com.seewo.open.sdk.DefaultSeewoClient;
|
|
|
+import com.seewo.open.sdk.SeewoClient;
|
|
|
+import com.seewo.open.sdk.auth.Account;
|
|
|
import com.template.api.SmartUserControllerAPI;
|
|
|
-import com.template.common.utils.ExcelUtils;
|
|
|
-import com.template.common.utils.FileUtils;
|
|
|
-import com.template.common.utils.paramUtils;
|
|
|
+import com.template.common.utils.*;
|
|
|
+import com.template.config.ControlConfig;
|
|
|
+import com.template.config.SeewoConfig;
|
|
|
import com.template.model.enumModel.eFileType;
|
|
|
import com.template.model.enumModel.eIdentityStatu;
|
|
|
import com.template.model.enumModel.eLogOff;
|
|
|
import com.template.model.enumModel.eSexStatu;
|
|
|
+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.result.CommonResult;
|
|
|
import com.template.model.result.PageUtils;
|
|
|
-import com.template.model.vo.AffiliateUserVo;
|
|
|
-import com.template.model.vo.DepartmentTreeVo;
|
|
|
-import com.template.model.vo.UserVo;
|
|
|
-import com.template.services.SmartDepartmentService;
|
|
|
-import com.template.services.SmartUploadService;
|
|
|
-import com.template.services.SmartUserService;
|
|
|
+import com.template.model.seewo.*;
|
|
|
+import com.template.model.vo.*;
|
|
|
+import com.template.services.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
@@ -41,13 +46,19 @@ import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
+import java.lang.reflect.Array;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.nio.charset.Charset;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
|
|
+import static com.template.common.utils.AesTestOne.decrypt;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 前端控制器
|
|
|
@@ -59,27 +70,47 @@ import java.util.zip.ZipInputStream;
|
|
|
@RestController
|
|
|
public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SeewoConfig seewoConfig;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ControlConfig controlConfig;
|
|
|
+
|
|
|
@Autowired
|
|
|
private SmartUserService smartUserService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private SmartGradeService smartGradeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SmartClassService smartClassService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private SmartUploadService smartUploadService;
|
|
|
|
|
|
@Autowired
|
|
|
private SmartDepartmentService smartDepartmentService;
|
|
|
|
|
|
@Override
|
|
|
- public CommonResult logoffAccount(int id) {
|
|
|
- SmartUser user = smartUserService.getSmartById(id);
|
|
|
- if (user == null) {
|
|
|
- return CommonResult.fail("用户信息已失效");
|
|
|
+ public CommonResult logoffAccount(useridsRequest ur, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ String st = paramUtils.getParamError(bindingResult);
|
|
|
+ return CommonResult.fail(st);
|
|
|
}
|
|
|
|
|
|
- user.setIsCancel(eLogOff.Logout.getValue());
|
|
|
+ int user = smartUserService.getSmartUserCountByIds(ur.getUserIds());
|
|
|
+ if (user != ur.getUserIds().size()) {
|
|
|
+ return CommonResult.fail("用户信息已失效");
|
|
|
+ }
|
|
|
|
|
|
- int updateResult = smartUserService.updateSmartUser(user);
|
|
|
+// for (:) {
|
|
|
+//
|
|
|
+// }
|
|
|
+// user.setIsCancel(eLogOff.Logout.getValue());
|
|
|
+//
|
|
|
+// int updateResult = smartUserService.updateSmartUser(user);
|
|
|
|
|
|
- return updateResult > 0 ? CommonResult.ok("注销成功") : CommonResult.fail("注销失败");
|
|
|
+ return 0 > 0 ? CommonResult.ok("注销成功") : CommonResult.fail("注销失败");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -150,6 +181,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
return resultBool ? CommonResult.ok("导入成功") : CommonResult.fail("导入失败");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 批量导入用户信息
|
|
|
* 以身份证号作为判断依据 如果存在重复数据就提示存在重复数据
|
|
|
@@ -257,7 +289,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
XSSFWorkbook sheets = new XSSFWorkbook(inputStream);
|
|
|
|
|
|
List<SmartDepartment> departments = smartDepartmentService.list(null);
|
|
|
-
|
|
|
+ List<SmartGrade> grades = smartGradeService.list(null); //年级
|
|
|
+ List<SmartClass> classs = smartClassService.list(null);//班级
|
|
|
//读取第一张sheet
|
|
|
XSSFSheet sheetAt = sheets.getSheetAt(0);
|
|
|
|
|
|
@@ -454,7 +487,23 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
user.setHeadImage(cellImage);
|
|
|
user.setDormitoryNumber(dormitoryNumber == null ? "" : dormitoryNumber);
|
|
|
user.setGrade(grade == null ? "" : grade);
|
|
|
- user.setSchoolClass(schoolClass == null ? "" : schoolClass);
|
|
|
+ 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();
|
|
|
+
|
|
|
+ if (oClass != null && oClass.isPresent()) {
|
|
|
+ user.setSchoolClass(oClass.get().getId());
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail(name + "的班级数据无效,导入失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail(name + "的年级数据无效,导入失败");
|
|
|
+ }
|
|
|
+
|
|
|
user.setCollege("");
|
|
|
user.setSpeciality("");
|
|
|
user.setCampus("");
|
|
|
@@ -498,6 +547,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
HSSFWorkbook sheets = new HSSFWorkbook(inputStream);
|
|
|
|
|
|
List<SmartDepartment> departments = smartDepartmentService.list(null);
|
|
|
+ List<SmartGrade> grades = smartGradeService.list(null); //年级
|
|
|
+ List<SmartClass> classs = smartClassService.list(null);//班级
|
|
|
|
|
|
//读取第一张sheet
|
|
|
HSSFSheet sheetAt = sheets.getSheetAt(0);
|
|
|
@@ -696,7 +747,22 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
user.setHeadImage(cellImage);
|
|
|
user.setDormitoryNumber(dormitoryNumber == null ? "" : dormitoryNumber);
|
|
|
user.setGrade(grade == null ? "" : grade);
|
|
|
- user.setSchoolClass(schoolClass == null ? "" : schoolClass);
|
|
|
+ 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();
|
|
|
+
|
|
|
+ if (oClass != null && oClass.isPresent()) {
|
|
|
+ user.setSchoolClass(oClass.get().getId());
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail(name + "的班级数据无效,导入失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail(name + "的年级数据无效,导入失败");
|
|
|
+ }
|
|
|
user.setCollege("");
|
|
|
user.setSpeciality("");
|
|
|
user.setCampus("");
|
|
|
@@ -725,7 +791,6 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
return CommonResult.ok(result);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 新增用户
|
|
|
*
|
|
|
@@ -734,12 +799,18 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public CommonResult insertSmartUser(insertSmartUserRequest isur, BindingResult bindingResult) {
|
|
|
+ public CommonResult insertSmartUser(insertSmartUserRequest isur, BindingResult bindingResult) throws Exception {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
|
return CommonResult.fail(st);
|
|
|
}
|
|
|
|
|
|
+ //重复性判断
|
|
|
+ int existCount = smartUserService.querySmartUserByCardNo(isur.getCardNo());
|
|
|
+ if (existCount > 0) {
|
|
|
+ return CommonResult.fail("当前学号已存在,请勿重复添加");
|
|
|
+ }
|
|
|
+
|
|
|
SmartUser su = new SmartUser();
|
|
|
su.setCardNo(isur.getCardNo());
|
|
|
su.setName(isur.getName());
|
|
|
@@ -764,6 +835,249 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
su.setDuties(isur.getDuties());
|
|
|
su.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
|
|
|
+ //region 人员信息加入到第三方api
|
|
|
+ //要将用户数据加入到希沃和百胜中
|
|
|
+ //希沃和百胜的老师、学生数据添加是不一样的,所以按身份添加
|
|
|
+ if (isur.getIdentityId().intValue() == eIdentityStatu.Parent.getValue()) {//家长
|
|
|
+ //拿到被关联学生的信息去获取对应的卡号
|
|
|
+ //有多个学生就循环学生
|
|
|
+ if (isur.getAffiliate() == null) {
|
|
|
+ return CommonResult.fail("被关联人不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isur.getAffiliate().size() <= 0) {
|
|
|
+ return CommonResult.fail("被关联人不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartUser> studentDatas = smartUserService.getSmartUserIds(isur.getAffiliate());
|
|
|
+
|
|
|
+ //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);
|
|
|
+
|
|
|
+ //家长列表,最多4个
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem parents = ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem.builder()
|
|
|
+ .name(isur.getName())
|
|
|
+ .phone(isur.getPhone())
|
|
|
+ .index(0)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ students.setParents(java.util.Collections.singletonList(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 result = seewoClient.invoke(request);
|
|
|
+ System.out.println("出参:" + result);
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ if (result == null) {
|
|
|
+ return CommonResult.fail("希沃学生家长数据添加失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!result.getResponseBody().getCode().equals("000000")) {
|
|
|
+ return CommonResult.fail(result.getResponseBody().getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (isur.getIdentityId().intValue() == eIdentityStatu.Student.getValue()) {//学生
|
|
|
+ //获取班级Uid
|
|
|
+ SmartClass classData = smartClassService.getSmartClassById(isur.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(isur.getName())
|
|
|
+ .studentCode(isur.getCardNo())
|
|
|
+ .gender(isur.getSexId())
|
|
|
+ .phone(isur.getPhone() == null ? "" : isur.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 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ su.setXwStudentUid(result.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 = "http://schoolopenapi.szymzh.com/openapi/student/create";
|
|
|
+
|
|
|
+ JSONObject jsonobject = new JSONObject();
|
|
|
+ jsonobject.put("appid", appId);
|
|
|
+ String str = "{\"student_name\":\"" + isur.getName() + "\",\"classtab_no\":\"" + classData.getBsClassNo() + "\",\"student_number\":\"" + isur.getCardNo() + "\",\"student_sex\":\"" + isur.getSexId() + "\",\"student_photo\":\"" + imageUtils.getBase64Url(isur.getHeadImage()) + "\"}";
|
|
|
+ String aesStr = URLEncoder.encode(AesTestOne.encrypt(str), "UTF-8");
|
|
|
+ jsonobject.put("data", aesStr);
|
|
|
+ jsonobject.put("schoolno", schoolno);
|
|
|
+ jsonobject.put("timestamp", timestamp);
|
|
|
+
|
|
|
+ String md5Str = "appid=" + appId + "&data={\"student_name\":\"" + isur.getName() + "\",\"classtab_no\":\"" + classData.getBsClassNo() + "\",\"student_number\":\"" + isur.getCardNo() + "\",\"student_sex\":\"" + isur.getSexId() + "\",\"student_photo\":\"" + imageUtils.getBase64Url(isur.getHeadImage()) + "\"}" + "&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), BsStudentNoVo.class);
|
|
|
+ su.setBsStudentNo(studentNo.getStudent_no());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ } else if (isur.getIdentityId().intValue() == eIdentityStatu.Teacher.getValue()) {//老师
|
|
|
+
|
|
|
+ //region 希沃添加教师数据
|
|
|
+ //初始化客户端
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherParam param = new TeacherServiceBatchSaveOrUpdateTeacherParam();
|
|
|
+ //请求体,MimeType为 application/json
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherParam.JSONRequestBody requestBody = TeacherServiceBatchSaveOrUpdateTeacherParam.JSONRequestBody.builder()
|
|
|
+ .build();
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ //老师信息
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherParam.SaveOrUpdateTeacherBatchQuery query = TeacherServiceBatchSaveOrUpdateTeacherParam.SaveOrUpdateTeacherBatchQuery.builder()
|
|
|
+ .appId(seewoConfig.getAppId())
|
|
|
+ .schoolUid(seewoConfig.getSchoolId())
|
|
|
+ .build();
|
|
|
+ requestBody.setQuery(query);
|
|
|
+ // 老师列表
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherParam.SaveOrUpdateTeacherQuery teachers = TeacherServiceBatchSaveOrUpdateTeacherParam.SaveOrUpdateTeacherQuery.builder()
|
|
|
+ .account(isur.getPhone())//用户账号
|
|
|
+ .name(isur.getName())//用户名字
|
|
|
+ .accountType("phone")//账号类型 phone:手机号 email:邮箱
|
|
|
+ .teacherCode(isur.getPhone())//教师工号
|
|
|
+ .photoUrl(isur.getHeadImage())//图片链接
|
|
|
+ .build();
|
|
|
+ query.setTeachers(java.util.Collections.singletonList(teachers));
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherRequest request = new TeacherServiceBatchSaveOrUpdateTeacherRequest(param);
|
|
|
+ System.out.println("入参:" + request);
|
|
|
+ //如果想要调用沙箱环境,请通过设置 request 对象的 serverUrl 属性,如:
|
|
|
+ //request.setServerUrl("https://openapi.test.seewo.com")
|
|
|
+ //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherResult 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ su.setXwTeacherCode(result.getResponseBody().getData().get(0).getTeacherCode());
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 百胜添加教师数据
|
|
|
+ SmartDepartment departmentData = smartDepartmentService.getSmartById(isur.getDepartmentId());
|
|
|
+ if (departmentData == null) {
|
|
|
+ return CommonResult.fail("部门数据无效,新增教师失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ String departmentNo = departmentData.getBsDepartmentNo();//"DT1701845086538710";
|
|
|
+ String appId = controlConfig.getAppId();
|
|
|
+ String schoolno = controlConfig.getSchoolCode();
|
|
|
+ String timestamp = TimeExchange.DateNowTimeStamo();
|
|
|
+ String appSecret = controlConfig.getAppSecret();
|
|
|
+ String url = "http://schoolopenapi.szymzh.com/openapi/staff/create";
|
|
|
+
|
|
|
+ JSONObject jsonobject = new JSONObject();
|
|
|
+ jsonobject.put("appid", appId);
|
|
|
+ String str = "{\"staff_name\":\"" + isur.getName() + "\",\"department_no\":\"" + departmentNo + "\",\"stafft_number\":\"" + isur.getCardNo() + "\",\"staff_phone\":\"" + isur.getPhone() + "\",\"staff_sex\":\"" + isur.getSexId() + "\",\"staff_photo\":\"" + imageUtils.getBase64Url(isur.getHeadImage()) + "\"}";
|
|
|
+ String aesStr = URLEncoder.encode(AesTestOne.encrypt(str), "UTF-8");
|
|
|
+ jsonobject.put("data", aesStr);
|
|
|
+ jsonobject.put("schoolno", schoolno);
|
|
|
+ jsonobject.put("timestamp", timestamp);
|
|
|
+
|
|
|
+ String md5Str = "appid=" + appId + "&data={\"staff_name\":\"" + isur.getName() + "\",\"department_no\":\"" + departmentNo + "\",\"stafft_number\":\"" + isur.getCardNo() + "\",\"staff_phone\":\"" + isur.getPhone() + "\",\"staff_sex\":\"" + isur.getSexId() + "\",\"staff_photo\":\"" + imageUtils.getBase64Url(isur.getHeadImage()) + "\"}" + "&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();
|
|
|
+ BsStaffVo staff = objectMapper.readValue(bsResult, BsStaffVo.class);
|
|
|
+
|
|
|
+ // URL解码
|
|
|
+ String decodedUrl = URLDecoder.decode(staff.getData(), "UTF-8");
|
|
|
+
|
|
|
+ BsStaffNoVo staffNo = objectMapper.readValue(decrypt(decodedUrl), BsStaffNoVo.class);
|
|
|
+ su.setBsStaffCode(staffNo.getStaff_no());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //最后都要把数据加入到数据库中
|
|
|
int result = smartUserService.insertSmartUser(su);
|
|
|
|
|
|
//新增用户得将用户信息通过接口推送到希沃、百胜
|
|
|
@@ -779,7 +1093,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public CommonResult updateSmartUserById(updateSmartUserRequest usur, BindingResult bindingResult) {
|
|
|
+ public CommonResult updateSmartUserById(updateSmartUserRequest usur, BindingResult bindingResult) throws Exception {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
|
return CommonResult.fail(st);
|
|
|
@@ -787,7 +1101,6 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
//更新的同时将百胜用户信息同步过去或者同步过来?
|
|
|
SmartUser su = smartUserService.getSmartById(usur.getId());
|
|
|
-
|
|
|
if (su == null) {
|
|
|
CommonResult.fail("用户数据已失效,修改失败!");
|
|
|
}
|
|
|
@@ -815,6 +1128,221 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
su.setDuties(usur.getDuties());
|
|
|
su.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
|
|
|
+ if (usur.getIdentityId().intValue() == eIdentityStatu.Parent.getValue()) {//家长
|
|
|
+ //拿到被关联学生的信息去获取对应的卡号
|
|
|
+ //有多个学生就循环学生
|
|
|
+ if (usur.getAffiliate() == null) {
|
|
|
+ return CommonResult.fail("被关联人不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (usur.getAffiliate().size() <= 0) {
|
|
|
+ return CommonResult.fail("被关联人不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartUser> studentDatas = smartUserService.getSmartUserIds(usur.getAffiliate());
|
|
|
+
|
|
|
+ //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);
|
|
|
+
|
|
|
+ //家长列表,最多4个
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem parents = ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem.builder()
|
|
|
+ .name(usur.getName())
|
|
|
+ .phone(usur.getPhone())
|
|
|
+ .index(0)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ students.setParents(java.util.Collections.singletonList(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 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
|
|
|
+
|
|
|
+ } else if (usur.getIdentityId().intValue() == eIdentityStatu.Student.getValue()) {//学生
|
|
|
+
|
|
|
+ //region 更新希沃学生信息
|
|
|
+ //初始化客户端
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ StudentServiceUpdateStudentInfoParam param = new StudentServiceUpdateStudentInfoParam();
|
|
|
+ //响应体,MimeType为 application/json
|
|
|
+ StudentServiceUpdateStudentInfoParam.RequestBody requestBody = StudentServiceUpdateStudentInfoParam.RequestBody.builder()
|
|
|
+ .build();
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ //query
|
|
|
+ StudentServiceUpdateStudentInfoParam.Query query = StudentServiceUpdateStudentInfoParam.Query.builder()
|
|
|
+ .appId(seewoConfig.getAppId())
|
|
|
+ .schoolUid(seewoConfig.getSchoolId())
|
|
|
+ .studentUid(su.getXwStudentUid())
|
|
|
+ .studentCode(su.getCardNo())
|
|
|
+ .studentName(su.getName())
|
|
|
+ .build();
|
|
|
+ requestBody.setQuery(query);
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ StudentServiceUpdateStudentInfoRequest request = new StudentServiceUpdateStudentInfoRequest(param);
|
|
|
+ System.out.println("入参:" + request);
|
|
|
+ //如果想要调用沙箱环境,请通过设置 request 对象的 serverUrl 属性,如:
|
|
|
+ //request.setServerUrl("https://openapi.test.seewo.com")
|
|
|
+ //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
|
|
|
+ StudentServiceUpdateStudentInfoResult 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
|
|
|
+
|
|
|
+ //region 更新百胜学生信息
|
|
|
+ String appId = controlConfig.getAppId();
|
|
|
+ String schoolno = controlConfig.getSchoolCode();
|
|
|
+ String timestamp = TimeExchange.DateNowTimeStamo();
|
|
|
+ String appSecret = controlConfig.getAppSecret();
|
|
|
+ String url = "http://schoolopenapi.szymzh.com/openapi/student/update";
|
|
|
+
|
|
|
+ JSONObject jsonobject = new JSONObject();
|
|
|
+ jsonobject.put("appid", appId);
|
|
|
+ String str = "{\"student_no\":\"" + su.getBsStudentNo() + "\",\"student_name\":\"" + su.getName() + "\",\"student_number\":\"" + su.getCardNo() + "\",\"student_sex\":\"" + su.getSexId() +"\",\"student_idcard\":\"" + su.getIdCard() + "\",\"student_photo\":\"" + imageUtils.getBase64Url(su.getHeadImage()) + "\"}";
|
|
|
+ String aesStr = URLEncoder.encode(AesTestOne.encrypt(str), "UTF-8");
|
|
|
+ jsonobject.put("data", aesStr);
|
|
|
+ jsonobject.put("schoolno", schoolno);
|
|
|
+ jsonobject.put("timestamp", timestamp);
|
|
|
+
|
|
|
+ String md5Str = "appid=" + appId + "&data={\"student_no\":\"" + su.getBsStudentNo() + "\",\"student_name\":\"" + su.getName() + "\",\"student_number\":\"" + su.getCardNo() + "\",\"student_sex\":\"" + su.getSexId() +"\",\"student_idcard\":\"" + su.getIdCard() + "\",\"student_photo\":\"" + imageUtils.getBase64Url(su.getHeadImage()) + "\"}" + "&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("更新成功")) {
|
|
|
+ return CommonResult.fail("百胜学生信息更新失败");
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ } else if (usur.getIdentityId().intValue() == eIdentityStatu.Teacher.getValue()) {//教师
|
|
|
+ //region 希沃更新教师数据
|
|
|
+ //初始化客户端
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherParam param = new TeacherServiceBatchSaveOrUpdateTeacherParam();
|
|
|
+ //请求体,MimeType为 application/json
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherParam.JSONRequestBody requestBody = TeacherServiceBatchSaveOrUpdateTeacherParam.JSONRequestBody.builder()
|
|
|
+ .build();
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ //老师信息
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherParam.SaveOrUpdateTeacherBatchQuery query = TeacherServiceBatchSaveOrUpdateTeacherParam.SaveOrUpdateTeacherBatchQuery.builder()
|
|
|
+ .appId(seewoConfig.getAppId())
|
|
|
+ .schoolUid(seewoConfig.getSchoolId())
|
|
|
+ .build();
|
|
|
+ requestBody.setQuery(query);
|
|
|
+ // 老师列表
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherParam.SaveOrUpdateTeacherQuery teachers = TeacherServiceBatchSaveOrUpdateTeacherParam.SaveOrUpdateTeacherQuery.builder()
|
|
|
+ .account(su.getPhone())//用户账号
|
|
|
+ .name(su.getName())//用户名字
|
|
|
+ .accountType("phone")//账号类型 phone:手机号 email:邮箱
|
|
|
+ .teacherCode("")//教师工号
|
|
|
+ .photoUrl(su.getHeadImage())//图片链接
|
|
|
+ .build();
|
|
|
+ query.setTeachers(java.util.Collections.singletonList(teachers));
|
|
|
+ param.setRequestBody(requestBody);
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherRequest request = new TeacherServiceBatchSaveOrUpdateTeacherRequest(param);
|
|
|
+ System.out.println("入参:" + request);
|
|
|
+ //如果想要调用沙箱环境,请通过设置 request 对象的 serverUrl 属性,如:
|
|
|
+ //request.setServerUrl("https://openapi.test.seewo.com")
|
|
|
+ //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
|
|
|
+ TeacherServiceBatchSaveOrUpdateTeacherResult 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ su.setXwTeacherCode(result.getResponseBody().getData().get(0).getTeacherCode());
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 百胜更新教师数据
|
|
|
+ SmartDepartment departmentData = smartDepartmentService.getSmartById(su.getDepartmentId());
|
|
|
+ if (departmentData == null) {
|
|
|
+ return CommonResult.fail("部门数据无效,更新教师失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ String departmentNo = departmentData.getBsDepartmentNo();
|
|
|
+ String appId = controlConfig.getAppId();
|
|
|
+ String schoolno = controlConfig.getSchoolCode();
|
|
|
+ String timestamp = TimeExchange.DateNowTimeStamo();
|
|
|
+ String appSecret = controlConfig.getAppSecret();
|
|
|
+ String url = "http://schoolopenapi.szymzh.com/openapi/staff/update";
|
|
|
+
|
|
|
+ JSONObject jsonobject = new JSONObject();
|
|
|
+ jsonobject.put("appid", appId);
|
|
|
+ String str = "{\"staff_no\":\"" + su.getBsStaffCode() + "\"staff_name\":\"" + su.getName() + "\",\"department_no\":\"" + departmentNo + "\",\"stafft_number\":\"" + su.getCardNo() + "\",\"staff_phone\":\"" + su.getPhone() + "\",\"staff_sex\":\"" + su.getSexId() + "\",\"staff_photo\":\"" + imageUtils.getBase64Url(su.getHeadImage()) + "\"}";
|
|
|
+ String aesStr = URLEncoder.encode(AesTestOne.encrypt(str), "UTF-8");
|
|
|
+ jsonobject.put("data", aesStr);
|
|
|
+ jsonobject.put("schoolno", schoolno);
|
|
|
+ jsonobject.put("timestamp", timestamp);
|
|
|
+
|
|
|
+ String md5Str = "appid=" + appId + "&data={\"staff_no\":\"" + su.getBsStaffCode() + "\"staff_name\":\"" + su.getName() + "\",\"department_no\":\"" + departmentNo + "\",\"stafft_number\":\"" + su.getCardNo() + "\",\"staff_phone\":\"" + su.getPhone() + "\",\"staff_sex\":\"" + su.getSexId() + "\",\"staff_photo\":\"" + imageUtils.getBase64Url(su.getHeadImage()) + "\"}" + "&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();
|
|
|
+ BsStaffVo staff = objectMapper.readValue(bsResult, BsStaffVo.class);
|
|
|
+
|
|
|
+ // URL解码
|
|
|
+ String decodedUrl = URLDecoder.decode(staff.getData(), "UTF-8");
|
|
|
+
|
|
|
+ BsStaffNoVo staffNo = objectMapper.readValue(decrypt(decodedUrl), BsStaffNoVo.class);
|
|
|
+ su.setBsStaffCode(staffNo.getStaff_no());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+
|
|
|
int result = smartUserService.updateSmartUser(su);
|
|
|
return result > 0 ? CommonResult.ok("修改成功") : CommonResult.fail("修改失败");
|
|
|
}
|
|
|
@@ -835,12 +1363,54 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
childDepartmentIds.add(departmentId);
|
|
|
QueryDepartmentTreeRecords(departmentId, departments, childDepartmentIds);
|
|
|
|
|
|
- if(departmentId == null){
|
|
|
+ if (departmentId == null) {
|
|
|
childDepartmentIds = null;
|
|
|
}
|
|
|
|
|
|
PageUtils<UserVo> result = smartUserService.querySmartUserPages(currentPage, pageCount, childDepartmentIds, name);
|
|
|
|
|
|
+ if (result != null && result.getList() != null) {
|
|
|
+ List<Integer> studentIds = new ArrayList<>();
|
|
|
+ List<String> studentStrs = Arrays.asList(StringUtils.join(result.getList().stream().map(UserVo::getAffiliate).collect(Collectors.toList()), ",").split(","));
|
|
|
+ for (String studentStr : studentStrs) {
|
|
|
+ if(!ObjectUtils.isEmpty(studentStr)){
|
|
|
+ studentIds.add(Integer.valueOf(studentStr));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<SmartUser> students = smartUserService.getSmartUserByIds(studentIds);
|
|
|
+ List<SmartClass> classs = smartClassService.list(null);
|
|
|
+
|
|
|
+ for (UserVo data : result.getList()) {
|
|
|
+ data.setIdentity(eIdentityStatu.stringOf(data.getIdentityId()));
|
|
|
+ data.setSex(eSexStatu.stringOf(data.getSexId()));
|
|
|
+ Optional<SmartDepartment> departmentData = departments == null ? null : departments.stream().filter(e -> e.getId().equals(data.getDepartmentId())).findFirst();
|
|
|
+ if (departmentData != null && departmentData.isPresent()) {
|
|
|
+ data.setDepartment(departmentData.get().getName());
|
|
|
+ }
|
|
|
+ Optional<SmartClass> nowClass = classs == null ? null : classs.stream().filter(e -> e.getId().equals(data.getSchoolClass())).findFirst();
|
|
|
+ if (nowClass != null && nowClass.isPresent()) {
|
|
|
+ data.setClassStr(nowClass.get().getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.setAffiliates(datas);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return CommonResult.ok(result);
|
|
|
}
|
|
|
|
|
|
@@ -893,7 +1463,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
dataRow.createCell(5).setCellValue(eSexStatu.stringOf(user.getSexId()));
|
|
|
//获取父级部门ID
|
|
|
Optional<SmartDepartment> department = departments.stream().filter(e -> e.getId().equals(user.getDepartmentId())).findFirst();
|
|
|
- if(department != null && department.isPresent()){
|
|
|
+ if (department != null && department.isPresent()) {
|
|
|
dataRow.createCell(6).setCellValue(QueryParentDepartments(department.get().getParentId(), departments, null));
|
|
|
}
|
|
|
|
|
|
@@ -950,8 +1520,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
Optional<SmartDepartment> data = lists.stream().filter(e -> e.getId().equals(parentID)).findFirst();
|
|
|
|
|
|
- if(data != null && data.isPresent()){
|
|
|
- departmentStr = departmentStr == null ? data.get().getName() : data.get().getName() + "/"+ departmentStr;
|
|
|
+ if (data != null && data.isPresent()) {
|
|
|
+ departmentStr = departmentStr == null ? data.get().getName() : data.get().getName() + "/" + departmentStr;
|
|
|
QueryParentDepartments(data.get().getParentId(), lists, departmentStr);
|
|
|
}
|
|
|
|
|
|
@@ -959,15 +1529,19 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommonResult deleteSmartUserById(int id) {
|
|
|
+ public CommonResult deleteSmartUserById(useridsRequest ur, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ String st = paramUtils.getParamError(bindingResult);
|
|
|
+ return CommonResult.fail(st);
|
|
|
+ }
|
|
|
|
|
|
- SmartUser data = smartUserService.getSmartById(id);
|
|
|
+ int data = smartUserService.getSmartUserCountByIds(ur.getUserIds());
|
|
|
|
|
|
- if (data == null) {
|
|
|
- return CommonResult.fail("当前数据不存在,删除失败!");
|
|
|
+ if (data != ur.getUserIds().size()) {
|
|
|
+ return CommonResult.fail("存在无效用户数据,删除失败!");
|
|
|
}
|
|
|
|
|
|
- int result = smartUserService.deleteSmartUserById(id);
|
|
|
+ int result = smartUserService.deleteSmartUserByIds(ur.getUserIds());
|
|
|
|
|
|
return result > 0 ? CommonResult.ok("删除成功") : CommonResult.fail("删除失败");
|
|
|
}
|
|
|
@@ -980,7 +1554,79 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
@Override
|
|
|
public CommonResult downloadUserExcel() {
|
|
|
- return CommonResult.ok("200","操作成功","https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/excelModel/人员信息表.xlsx");
|
|
|
+ return CommonResult.ok("200", "操作成功", "https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/excelModel/人员信息表.xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult queryStudents(int userId) {
|
|
|
+
|
|
|
+ List<SmartUser> students = new ArrayList<>();
|
|
|
+ SmartUser user = smartUserService.getSmartById(userId);
|
|
|
+ if (user == null) {
|
|
|
+ return CommonResult.fail("用户信息为空,获取学生列表数据失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (user.getAffiliate() == null) {
|
|
|
+ return CommonResult.ok(students);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> affiliateIds = new ArrayList<>();
|
|
|
+ List<String> affiliates = Arrays.asList(user.getAffiliate().split(","));
|
|
|
+ for (String affiliate : affiliates) {
|
|
|
+ affiliateIds.add(Integer.valueOf(affiliate));
|
|
|
+ }
|
|
|
+
|
|
|
+ students = smartUserService.getSmartUserByIds(affiliateIds);
|
|
|
+
|
|
|
+ List<ParentOfStudentsVo> result = new ArrayList<>();
|
|
|
+ for (SmartUser student : students) {
|
|
|
+ ParentOfStudentsVo data = new ParentOfStudentsVo();
|
|
|
+ data.setId(student.getId());
|
|
|
+ data.setName(student.getName());
|
|
|
+ data.setCardNo(student.getCardNo());
|
|
|
+ data.setDepartmentId(student.getDepartmentId());
|
|
|
+ result.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+ //region 百胜新增学生信息
|
|
|
+ String image = "https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/out_www.yalijuda.com_%E5%8D%8E%E5%BF%97%E6%9D%B0%E3%80%9018279462576%E3%80%91_1h5oBWtHvG.jpg";
|
|
|
+ String appId = "sc5efc60f2bd373df9";
|
|
|
+ String schoolno = "SL1701743624375793";
|
|
|
+ String timestamp = "20240110090422121";//TimeExchange.DateNowTimeStamo();
|
|
|
+ String appSecret = "fe0d767a2a394d1b81ccda6fc0ce5ecc";
|
|
|
+ String url = "http://schoolopenapi.szymzh.com/openapi/student/create";
|
|
|
+
|
|
|
+ JSONObject jsonobject = new JSONObject();
|
|
|
+ jsonobject.put("appid", appId);
|
|
|
+ String str = "{\"student_name\":\"" + "李四" + "\",\"classtab_no\":\"" + "CS1704704260801286" + "\",\"student_number\":\"" + "A123457" + "\",\"student_sex\":\"" + 1 + "\",\"student_photo\":\"" + imageUtils.getBase64Url(image) + "\"}";
|
|
|
+ String aesStr = URLEncoder.encode(AesTestOne.encrypt(str), "UTF-8");
|
|
|
+ jsonobject.put("data", aesStr);
|
|
|
+ jsonobject.put("schoolno", schoolno);
|
|
|
+ jsonobject.put("timestamp", timestamp);
|
|
|
+
|
|
|
+ String md5Str = "appid=" + appId + "&data={\"student_name\":\"" + "李四" + "\",\"classtab_no\":\"" + "CS1704704260801286" + "\",\"student_number\":\"" + "A123457" + "\",\"student_sex\":\"" + 1 + "\",\"student_photo\":\"" + imageUtils.getBase64Url(image) + "\"}" + "&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());
|
|
|
+ System.out.println(bsResult);
|
|
|
+ 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), BsStudentNoVo.class);
|
|
|
+ String sdsd = "";
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
}
|
|
|
}
|
|
|
|