|
|
@@ -216,7 +216,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
|
|
|
if (users != null && users.size() > 0) {
|
|
|
- boolean insertData = smartUserService.updateUserBatchById(users);
|
|
|
+ boolean insertData = smartUserService.updateBatchById(users);
|
|
|
if (!insertData) {
|
|
|
return CommonResult.fail("导入失败");
|
|
|
}
|
|
|
@@ -536,7 +536,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
user.setDepartmentId(cdr.getDepartmentId());
|
|
|
|
|
|
}
|
|
|
- boolean result = smartUserService.updateUserBatchById(users);
|
|
|
+ boolean result = smartUserService.updateBatchById(users);
|
|
|
|
|
|
return result ? CommonResult.ok("移动成功") : CommonResult.fail("移动失败");
|
|
|
}
|
|
|
@@ -2107,7 +2107,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
List<SmartUser> insertStudent = new ArrayList<>();
|
|
|
List<SmartUser> updateStudent = new ArrayList<>();
|
|
|
|
|
|
- List<SmartUser> updateStudents = result.stream().filter(e -> e.getId() != null).collect(Collectors.toList());
|
|
|
+ List<SmartUser> updateStudents = result.stream().filter(e -> e.getId() != null && e.getIdentityId().intValue() == eIdentityStatu.Student.getValue()).collect(Collectors.toList());
|
|
|
|
|
|
for (SmartUser studentData : updateStudents) {
|
|
|
studentData.setName(studentData.getName());//姓名
|
|
|
@@ -2128,7 +2128,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
if (!studentData.getOldClassUid().equals(oClass.get().getClassUid())) {
|
|
|
CommonResult changeClass = SeewoChangeClass(seewoClient, seewoConfig.getSchoolId(), studentData.getXwStudentUid(), studentData.getOldClassUid(), oClass.get().getClassUid());
|
|
|
if (!changeClass.isSuccess()) {
|
|
|
- return CommonResult.fail("希沃平台:" + changeClass.getMessage());
|
|
|
+ //return CommonResult.fail("希沃平台:" + changeClass.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2153,8 +2153,149 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
return CommonResult.fail("学号为:" + studentData.getCardNo() + "的" + studentData.getName() + "的年级数据无效,无法进行更新操作");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //更新家长
|
|
|
+ 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){
|
|
|
+ boolean updateBatch = smartUserService.updateBatchById(updateParents);
|
|
|
+ if (!updateBatch) {
|
|
|
+ return CommonResult.fail("系统批量更新家长出错,导入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增家长
|
|
|
+ List<SmartUser> insertParentDatas = new ArrayList<>();
|
|
|
+ List<SmartUser> insertParents = result.stream().filter(e -> e.getId() == null && e.getIdentityId().intValue() == eIdentityStatu.Parent.getValue()).collect(Collectors.toList());
|
|
|
+ if(insertParents != null && insertParents.size() > 0){
|
|
|
+ List<String> familyCardNos = updateStudents.stream().map(SmartUser::getCardNo).distinct().collect(Collectors.toList());
|
|
|
+ List<SmartFamilyIndex> indexs = smartFamilyIndexService.querySmartFamilyByCardNo(familyCardNos);
|
|
|
+ List<SmartFamilyIndex> familyIndexs = new ArrayList<>();
|
|
|
+ //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 = insertParents.stream().filter(e -> e.getIdentityId().intValue() == eIdentityStatu.Parent.getValue() && e.getAffiliate().equals(student.getCardNo())).collect(Collectors.toList());
|
|
|
+ List<ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem> parents = new ArrayList<>();
|
|
|
+
|
|
|
+ long indexCount = indexs.stream().filter(e -> e.getStudentNo().equals(student.getCardNo())).count();
|
|
|
+ int i = (indexCount<= 0 ? 0 : (int)indexCount);
|
|
|
+
|
|
|
+ for (SmartUser parent : parentDatas) {
|
|
|
+ insertParentDatas.add(parent);
|
|
|
+ SmartFamilyIndex familyIndex = new SmartFamilyIndex();
|
|
|
+ familyIndex.setParentPhone(parent.getPhone());
|
|
|
+ familyIndex.setStudentNo(student.getCardNo());
|
|
|
+ familyIndex.setIndexData(i);
|
|
|
+ familyIndexs.add(familyIndex);
|
|
|
+ ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem data = ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem.builder()
|
|
|
+ .name(parent.getShip())
|
|
|
+ .phone(parent.getPhone())
|
|
|
+ .index(i)
|
|
|
+ .build();
|
|
|
+ parents.add(data);
|
|
|
+ ++i;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 (familyIndexs != null && familyIndexs.size() > 0) {
|
|
|
+
|
|
|
+ boolean insertBatch = smartFamilyIndexService.saveBatch(familyIndexs);
|
|
|
+ if (!insertBatch) {
|
|
|
+ return CommonResult.fail("导入失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartUser> newParents = new ArrayList<>();
|
|
|
+ if(insertParentDatas != null && insertParentDatas.size() > 0){
|
|
|
+ for (SmartUser parent : insertParentDatas) {
|
|
|
+ Optional<SmartUser> student = updateStudents.stream().filter(e -> e.getCardNo().equals(parent.getAffiliate())).findFirst();
|
|
|
+ if (student != null && student.isPresent()) {
|
|
|
+ //先查找是否存在
|
|
|
+ Optional<SmartUser> newData = newParents.stream().filter(e -> e.getName().equals(parent.getName()) && e.getPhone().equals(parent.getPhone()) && e.getShip().equals(parent.getShip())).findFirst();
|
|
|
+ if (newData != null && newData.isPresent()) {
|
|
|
+ String affiliate = newData.get().getAffiliate() + "," + student.get().getId();
|
|
|
+ newData.get().setAffiliate(affiliate);
|
|
|
+ } else {
|
|
|
+ SmartUser newParent = new SmartUser();
|
|
|
+ newParent.setName(parent.getName());
|
|
|
+ newParent.setDepartmentId(parent.getDepartmentId());
|
|
|
+ newParent.setPhone(parent.getPhone());
|
|
|
+ newParent.setIdentityId(parent.getIdentityId());
|
|
|
+ newParent.setSexId(parent.getSexId());
|
|
|
+ newParent.setIsCancel(parent.getIsCancel());
|
|
|
+ newParent.setAffiliate(String.valueOf(student.get().getId()));
|
|
|
+ newParent.setShip(parent.getShip());
|
|
|
+ newParents.add(newParent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ boolean insertBatch = smartUserService.saveBatch(newParents);
|
|
|
+ if (!insertBatch) {
|
|
|
+ return CommonResult.fail("批量新增家长失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (updateStudent != null && updateStudent.size() > 0) {
|
|
|
- boolean updateBatch = smartUserService.updateUserBatchById(updateStudent);
|
|
|
+ boolean updateBatch = smartUserService.updateBatchById(updateStudent);
|
|
|
if (!updateBatch) {
|
|
|
return CommonResult.fail("系统批量更新出错,导入失败");
|
|
|
} else {
|
|
|
@@ -2176,7 +2317,11 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
|
|
|
List<SmartUser> insertStudents = result.stream().filter(e -> e.getId() == null).collect(Collectors.toList());
|
|
|
+
|
|
|
if (insertStudents != null && insertStudents.size() > 0) {
|
|
|
+ if(headImage == null){
|
|
|
+ return CommonResult.fail("更新数据文档中存在新增数据,头像不能为空");
|
|
|
+ }
|
|
|
List<String> uploadImages = Arrays.asList(headImage.split(","));
|
|
|
for (SmartUser user : insertStudents) {
|
|
|
Optional<String> image = uploadImages == null ? null : uploadImages.stream().filter(e -> e.equals("https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/" + user.getHeadImage())).findFirst();
|
|
|
@@ -2192,7 +2337,10 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
//region 将数据加入第三方
|
|
|
List<SmartUser> studentDatas = insertStudents.stream().filter(e -> e.getIdentityId().intValue() == eIdentityStatu.Student.getValue()).collect(Collectors.toList());
|
|
|
-
|
|
|
+ List<String> newCardNos = studentDatas.stream().map(SmartUser::getCardNo).collect(Collectors.toList());
|
|
|
+ if (newCardNos == null) {
|
|
|
+ return CommonResult.fail("文档内容为空,批量更新失败");
|
|
|
+ }
|
|
|
if (studentDatas != null && studentDatas.size() > 0) {
|
|
|
//判断是否存在重复数据
|
|
|
List<String> cardNoDatas = studentDatas.stream().map(SmartUser::getCardNo).collect(Collectors.toList());
|
|
|
@@ -2423,8 +2571,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//双胞胎家长
|
|
|
List<SmartUser> newParents = new ArrayList<>();
|
|
|
|
|
|
- if (cardNos != null && cardNos.size() > 0) {
|
|
|
- List<SmartUser> students = smartUserService.querySmartUserByCardNos(cardNos);
|
|
|
+ if (newCardNos != null && newCardNos.size() > 0) {
|
|
|
+ List<SmartUser> students = smartUserService.querySmartUserByCardNos(newCardNos);
|
|
|
for (SmartUser parent : parents) {
|
|
|
Optional<SmartUser> student = students.stream().filter(e -> e.getCardNo().equals(parent.getAffiliate())).findFirst();
|
|
|
if (student != null && student.isPresent()) {
|
|
|
@@ -2516,6 +2664,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
HSSFSheet sheetAt = sheets.getSheetAt(0);
|
|
|
DataFormatter dataFormatter = new DataFormatter();
|
|
|
List<SmartUser> users = smartUserService.queryStudentDatas(eIdentityStatu.Student.getValue(), ids);
|
|
|
+ List<SmartUser> parents = smartUserService.getSmartUserByIdentity(eIdentityStatu.Parent.getValue());
|
|
|
|
|
|
try {
|
|
|
for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
|
|
|
@@ -2677,6 +2826,8 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
user.setCardNo(cardNo == null ? "" : cardNo);
|
|
|
user.setName(name == null ? "" : name);
|
|
|
user.setIdentityId(eIdentityStatu.Student.getValue());
|
|
|
+ String cardId = dataFormatter.formatCellValue(row.getCell(7));//身份证
|
|
|
+ user.setIdCard(cardId == null ? user.getIdCard() : cardId);
|
|
|
|
|
|
Optional<SmartClass> oClass = classs.stream().filter(e -> e.getName().equals(schoolClass)).findFirst();
|
|
|
if (oClass != null && oClass.isPresent()) {
|
|
|
@@ -2691,6 +2842,72 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
user.setTimeGroupId(oGroup.get().getId());
|
|
|
}
|
|
|
result.add(user);
|
|
|
+
|
|
|
+ //不判断重复性 因为会出现双胞胎
|
|
|
+ String phone = dataFormatter.formatCellValue(row.getCell(11));
|
|
|
+ //部门是否为空判断
|
|
|
+ String familyDepartment = dataFormatter.formatCellValue(row.getCell(1)).replace("年级", "") + "家长";
|
|
|
+
|
|
|
+ Integer familyDepartmentId = null;
|
|
|
+ Optional<SmartDepartment> familyDepartModel = departments.stream().filter(e -> e.getName().equals(familyDepartment)).findFirst();
|
|
|
+ if (familyDepartModel != null && familyDepartModel.isPresent()) {
|
|
|
+ familyDepartmentId = familyDepartModel.get().getId();
|
|
|
+ } else {
|
|
|
+ familyDepartmentId = 16;
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 家属
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(phone)) {
|
|
|
+ if (phone.length() != 11) {
|
|
|
+ return CommonResult.fail(name + "的学生家长手机号长度不符合标准");
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartUser familyOne = new SmartUser();
|
|
|
+ Optional<SmartUser> oneParent = parents.stream().filter(e -> e.getPhone().equals(phone)).findFirst();
|
|
|
+ if(oneParent != null && oneParent.isPresent()){
|
|
|
+ familyOne = oneParent.get();
|
|
|
+ }else{
|
|
|
+ familyOne.setAffiliate(user.getCardNo());
|
|
|
+ }
|
|
|
+ String family = dataFormatter.formatCellValue(row.getCell(12));//家属
|
|
|
+ familyOne.setName(!ObjectUtils.isEmpty(family) ? family : "家长");
|
|
|
+ familyOne.setDepartmentId(familyDepartmentId);
|
|
|
+ familyOne.setPhone(phone);
|
|
|
+ familyOne.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ familyOne.setSexId(eSexStatu.Man.getValue());
|
|
|
+ familyOne.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
+ familyOne.setAffiliate(user.getCardNo());
|
|
|
+ String familyShip = dataFormatter.formatCellValue(row.getCell(13));//家属与本人关系
|
|
|
+ familyOne.setShip(familyShip == null ? "其他" : familyShip);
|
|
|
+ result.add(familyOne);
|
|
|
+ }
|
|
|
+
|
|
|
+ String phoneTwo = dataFormatter.formatCellValue(row.getCell(14));//联系电话2
|
|
|
+ if (!ObjectUtils.isEmpty(phoneTwo)) {
|
|
|
+ if (phoneTwo.length() != 11) {
|
|
|
+ return CommonResult.fail(name + "的学生家长手机号长度不符合标准");
|
|
|
+ }
|
|
|
+ SmartUser familyTwo = new SmartUser();
|
|
|
+ Optional<SmartUser> oneParent = parents.stream().filter(e -> e.getPhone().equals(phoneTwo)).findFirst();
|
|
|
+ if(oneParent != null && oneParent.isPresent()){
|
|
|
+ familyTwo = oneParent.get();
|
|
|
+ }else{
|
|
|
+ familyTwo.setAffiliate(user.getCardNo());
|
|
|
+ }
|
|
|
+ String familyNameTwo = dataFormatter.formatCellValue(row.getCell(15));//家属2
|
|
|
+ familyTwo.setName(!ObjectUtils.isEmpty(familyNameTwo) ? familyNameTwo : "家长");
|
|
|
+ familyTwo.setDepartmentId(familyDepartmentId);
|
|
|
+ familyTwo.setPhone(phoneTwo == null ? "" : phoneTwo);
|
|
|
+ familyTwo.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ familyTwo.setSexId(eSexStatu.Man.getValue());
|
|
|
+ familyTwo.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
+ familyTwo.setAffiliate(user.getCardNo());
|
|
|
+ String familyShipTwo = dataFormatter.formatCellValue(row.getCell(16));//家属与本人关系2
|
|
|
+ familyTwo.setShip(familyShipTwo == null ? "其他" : familyShipTwo);
|
|
|
+ result.add(familyTwo);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
} else {
|
|
|
String name = dataFormatter.formatCellValue(row.getCell(4));
|
|
|
// if (ObjectUtils.isEmpty(name)) {
|
|
|
@@ -2930,6 +3147,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
XSSFSheet sheetAt = sheets.getSheetAt(0);
|
|
|
DataFormatter dataFormatter = new DataFormatter();
|
|
|
List<SmartUser> users = smartUserService.queryStudentDatas(eIdentityStatu.Student.getValue(), ids);
|
|
|
+ List<SmartUser> parents = smartUserService.getSmartUserByIdentity(eIdentityStatu.Parent.getValue());
|
|
|
try {
|
|
|
for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
|
|
|
XSSFRow row = sheetAt.getRow(rowNum);
|
|
|
@@ -3091,6 +3309,11 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
user.setName(name == null ? "" : name);
|
|
|
user.setIdentityId(eIdentityStatu.Student.getValue());
|
|
|
|
|
|
+ String cardId = dataFormatter.formatCellValue(row.getCell(7));//身份证
|
|
|
+ user.setIdCard(cardId == null ? user.getIdCard() : cardId);
|
|
|
+ String address = dataFormatter.formatCellValue(row.getCell(10));//住址
|
|
|
+ user.setAddress(address == null ? user.getAddress() : address);
|
|
|
+
|
|
|
Optional<SmartClass> oClass = classs.stream().filter(e -> e.getName().equals(schoolClass)).findFirst();
|
|
|
if (oClass != null && oClass.isPresent()) {
|
|
|
user.setSchoolClass(oClass.get().getId());
|
|
|
@@ -3104,6 +3327,75 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
user.setTimeGroupId(oGroup.get().getId());
|
|
|
}
|
|
|
result.add(user);
|
|
|
+
|
|
|
+ //不判断重复性 因为会出现双胞胎
|
|
|
+ String phone = dataFormatter.formatCellValue(row.getCell(11));
|
|
|
+ //部门是否为空判断
|
|
|
+ String familyDepartment = dataFormatter.formatCellValue(row.getCell(1)).replace("年级", "") + "家长";
|
|
|
+
|
|
|
+ Integer familyDepartmentId = null;
|
|
|
+ Optional<SmartDepartment> familyDepartModel = departments.stream().filter(e -> e.getName().equals(familyDepartment)).findFirst();
|
|
|
+ if (familyDepartModel != null && familyDepartModel.isPresent()) {
|
|
|
+ familyDepartmentId = familyDepartModel.get().getId();
|
|
|
+ } else {
|
|
|
+ familyDepartmentId = 16;
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 家属
|
|
|
+
|
|
|
+ if(user.getName().equals("张宇霏")){
|
|
|
+ String sdsd ="";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(phone)) {
|
|
|
+ if (phone.length() != 11) {
|
|
|
+ return CommonResult.fail(name + "的学生家长手机号长度不符合标准");
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartUser familyOne = new SmartUser();
|
|
|
+ Optional<SmartUser> oneParent = parents.stream().filter(e -> e.getPhone().equals(phone)).findFirst();
|
|
|
+ if(oneParent != null && oneParent.isPresent()){
|
|
|
+ familyOne = oneParent.get();
|
|
|
+ }else{
|
|
|
+ familyOne.setAffiliate(user.getCardNo());
|
|
|
+ }
|
|
|
+ String family = dataFormatter.formatCellValue(row.getCell(12));//家属
|
|
|
+ familyOne.setName(!ObjectUtils.isEmpty(family) ? family : "家长");
|
|
|
+ familyOne.setDepartmentId(familyDepartmentId);
|
|
|
+ familyOne.setPhone(phone);
|
|
|
+ familyOne.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ familyOne.setSexId(eSexStatu.Man.getValue());
|
|
|
+ familyOne.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
+ String familyShip = dataFormatter.formatCellValue(row.getCell(13));//家属与本人关系
|
|
|
+ familyOne.setShip(familyShip == null ? "其他" : familyShip);
|
|
|
+ result.add(familyOne);
|
|
|
+ }
|
|
|
+
|
|
|
+ String phoneTwo = dataFormatter.formatCellValue(row.getCell(14));//联系电话2
|
|
|
+ if (!ObjectUtils.isEmpty(phoneTwo)) {
|
|
|
+ if (phoneTwo.length() != 11) {
|
|
|
+ return CommonResult.fail(name + "的学生家长手机号长度不符合标准");
|
|
|
+ }
|
|
|
+ SmartUser familyTwo = new SmartUser();
|
|
|
+ Optional<SmartUser> oneParent = parents.stream().filter(e -> e.getPhone().equals(phoneTwo)).findFirst();
|
|
|
+ if(oneParent != null && oneParent.isPresent()){
|
|
|
+ familyTwo = oneParent.get();
|
|
|
+ }else{
|
|
|
+ familyTwo.setAffiliate(user.getCardNo());
|
|
|
+ }
|
|
|
+ String familyNameTwo = dataFormatter.formatCellValue(row.getCell(15));//家属2
|
|
|
+ familyTwo.setName(!ObjectUtils.isEmpty(familyNameTwo) ? familyNameTwo : "家长");
|
|
|
+ familyTwo.setDepartmentId(familyDepartmentId);
|
|
|
+ familyTwo.setPhone(phoneTwo == null ? "" : phoneTwo);
|
|
|
+ familyTwo.setIdentityId(eIdentityStatu.Parent.getValue());
|
|
|
+ familyTwo.setSexId(eSexStatu.Man.getValue());
|
|
|
+ familyTwo.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
+ String familyShipTwo = dataFormatter.formatCellValue(row.getCell(16));//家属与本人关系2
|
|
|
+ familyTwo.setShip(familyShipTwo == null ? "其他" : familyShipTwo);
|
|
|
+ result.add(familyTwo);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
} else {
|
|
|
String name = dataFormatter.formatCellValue(row.getCell(4));
|
|
|
// if (ObjectUtils.isEmpty(name)) {
|
|
|
@@ -3739,6 +4031,197 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
+ @Override
|
|
|
+ @DESRespondSecret(validated = true)
|
|
|
+ @PassToken
|
|
|
+ public CommonResult updateTest(int departmentId) throws Exception {
|
|
|
+ List<Integer> departmentIds = new ArrayList<>();
|
|
|
+ departmentIds.add(81);
|
|
|
+ departmentIds.add(82);
|
|
|
+ departmentIds.add(83);
|
|
|
+ departmentIds.add(84);
|
|
|
+ departmentIds.add(85);
|
|
|
+ departmentIds.add(86);
|
|
|
+ departmentIds.add(87);
|
|
|
+ departmentIds.add(88);
|
|
|
+ departmentIds.add(89);
|
|
|
+ departmentIds.add(90);
|
|
|
+ departmentIds.add(91);
|
|
|
+ departmentIds.add(92);
|
|
|
+ departmentIds.add(93);
|
|
|
+ departmentIds.add(94);
|
|
|
+ departmentIds.add(95);
|
|
|
+ departmentIds.add(96);
|
|
|
+ departmentIds.add(97);
|
|
|
+ departmentIds.add(98);
|
|
|
+ List<SmartUser> users = smartUserService.queryDatasByDepartments(departmentIds);
|
|
|
+
|
|
|
+ for (SmartUser usur:users) {
|
|
|
+
|
|
|
+ if(usur.getName().equals("张玉玲")){
|
|
|
+ String sdsd = "";
|
|
|
+ }
|
|
|
+ int useXw = 1;
|
|
|
+ int useBs = 1;
|
|
|
+
|
|
|
+ //更新的同时将百胜用户信息同步过去或者同步过来?
|
|
|
+ SmartUser su = smartUserService.getSmartById(usur.getId());
|
|
|
+ if (su == null) {
|
|
|
+ return CommonResult.fail("用户数据已失效,修改失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否转换身份
|
|
|
+ boolean changeIdentity = false;
|
|
|
+ Integer oldIdentity = null;
|
|
|
+ String oldAffiliate = su.getAffiliate();
|
|
|
+ Integer oldSchoolClass = su.getSchoolClass();
|
|
|
+ String oldStaffNo = su.getBsStaffCode();
|
|
|
+ String oldCardNo = su.getCardNo();
|
|
|
+ if (usur.getIdentityId().intValue() != su.getIdentityId().intValue()) {
|
|
|
+ changeIdentity = true;
|
|
|
+ oldIdentity = su.getIdentityId().intValue();
|
|
|
+ }
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+
|
|
|
+ su.setTimeGroupId(usur.getTimeGroupId());
|
|
|
+ su.setCardNo(usur.getCardNo());
|
|
|
+ su.setName(usur.getName());
|
|
|
+ su.setIdentityId(usur.getIdentityId());
|
|
|
+ su.setIdCard(usur.getIdCard());
|
|
|
+ su.setSexId(usur.getSexId());
|
|
|
+ su.setDepartmentId(usur.getDepartmentId());
|
|
|
+ su.setHeadImage(usur.getHeadImage());
|
|
|
+ su.setGrade(usur.getGrade());
|
|
|
+ su.setCollege(usur.getCollege());
|
|
|
+ su.setSpeciality(usur.getSpeciality());
|
|
|
+ su.setSchoolClass(usur.getSchoolClass());
|
|
|
+ su.setCampus(usur.getCampus());
|
|
|
+ su.setDormitoryNumber(usur.getDormitoryNumber());
|
|
|
+ su.setPhone(usur.getPhone());
|
|
|
+ su.setAffiliate(StringUtils.join(usur.getAffiliate(), ","));
|
|
|
+ su.setTitle(usur.getTitle());
|
|
|
+ su.setAddress(usur.getAddress());
|
|
|
+ su.setNation(usur.getNation());
|
|
|
+ su.setOfStudent(usur.getOfStudent());
|
|
|
+ su.setGraduate(usur.getGraduate());
|
|
|
+ su.setDuties(usur.getDuties());
|
|
|
+ su.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
+
|
|
|
+ if (usur.getIdentityId().intValue() == eIdentityStatu.Parent.getValue()) {//家长
|
|
|
+ //拿到被关联学生的信息去获取对应的卡号
|
|
|
+ //有多个学生就循环学生
|
|
|
+ if (usur.getAffiliate() == null) {
|
|
|
+ return CommonResult.fail("被关联人不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> affiliates = Arrays.asList(usur.getAffiliate().split(","));
|
|
|
+ if (affiliates.size() <= 0) {
|
|
|
+ return CommonResult.fail("被关联人不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartUser oldUser = smartUserService.queryParentByPhone(usur.getPhone());
|
|
|
+ if (oldUser != null && oldUser.getId().intValue() != usur.getId().intValue()) {
|
|
|
+ //return CommonResult.fail("当前手机号已被其他家长使用");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartUser> studentDatas = smartUserService.getSmartUserIds(affiliates);
|
|
|
+
|
|
|
+ if(studentDatas.size() <= 0){
|
|
|
+ smartUserService.deleteSmartUserById(usur.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!changeIdentity) {
|
|
|
+ //region 希沃新增编辑学生家长信息
|
|
|
+ if (useXw == 1) {
|
|
|
+ //学生与家长列表,最大100条
|
|
|
+ CommonResult insertOrUpdateResult = insertOrUpdateStudentParent(seewoClient, studentDatas, "其他", usur.getPhone(), false);
|
|
|
+ if (!insertOrUpdateResult.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + insertOrUpdateResult.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ } else {
|
|
|
+ if (oldIdentity.intValue() == eIdentityStatu.Student.getValue()) {
|
|
|
+ //region 希沃删除学生
|
|
|
+ //获取班级Uid
|
|
|
+ SmartClass classData = smartClassService.getSmartClassById(oldSchoolClass);
|
|
|
+ if (classData == null) {
|
|
|
+ return CommonResult.fail("班级数据无效,更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (useXw == 1) {
|
|
|
+ CommonResult deleteStudent = SeewoDeleteStudent(seewoClient, classData.getClassUid(), oldCardNo);
|
|
|
+ if (!deleteStudent.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + deleteStudent.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 百胜删除学生
|
|
|
+ if (useBs == 1) {
|
|
|
+ CommonResult deleteBsStudent = bsDeleteStudent(su);
|
|
|
+ if (!deleteBsStudent.isSuccess()) {
|
|
|
+ return CommonResult.fail("百胜平台:" + deleteBsStudent.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ } else if (oldIdentity.intValue() == eIdentityStatu.Teacher.getValue()) {
|
|
|
+ //获取班级Uid
|
|
|
+ SmartClass classData = smartClassService.getSmartClassById(oldSchoolClass);
|
|
|
+ if (classData == null) {
|
|
|
+ return CommonResult.fail("班级数据无效,更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 希沃删除教师
|
|
|
+ if (useXw == 1) {
|
|
|
+ CommonResult deleteTeacher = SeewoDeleteTeacher(seewoClient, su.getPhone());
|
|
|
+ if (!deleteTeacher.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + deleteTeacher.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 希沃删除班主任
|
|
|
+ if (useXw == 1) {
|
|
|
+ CommonResult deleteTeacherMaster = SeewoDeleteTeacherMaster(seewoClient, classData.getClassUid(), su.getPhone());
|
|
|
+ if (deleteTeacherMaster.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + deleteTeacherMaster.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 百胜删除教师
|
|
|
+ if (useBs == 1) {
|
|
|
+ CommonResult bsDeleteTeacher = bsDeleteTeacher(oldStaffNo);
|
|
|
+ if (!bsDeleteTeacher.isSuccess()) {
|
|
|
+ return CommonResult.fail("百胜平台:" + bsDeleteTeacher.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 希沃新增编辑学生家长信息
|
|
|
+ if (useXw == 1) {
|
|
|
+ List<SmartFamilyIndex> indexs = smartFamilyIndexService.querySmartFamilyByCardNo(su.getCardNo());
|
|
|
+ if (indexs != null && indexs.size() >= 4) {
|
|
|
+ return CommonResult.fail("绑定失败,希沃学生家长最多绑定四个家长");
|
|
|
+ }
|
|
|
+
|
|
|
+ CommonResult insertOrUpdate = insertOrUpdateStudentParent(seewoClient, studentDatas, su.getShip(), su.getPhone(), true);
|
|
|
+ if (!insertOrUpdate.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + insertOrUpdate.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
//region 更新用户
|
|
|
|
|
|
/**
|
|
|
@@ -4131,6 +4614,18 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
return CommonResult.fail("班级数据无效,新增失败");
|
|
|
}
|
|
|
|
|
|
+ if (useXw == 1) {
|
|
|
+ //获取班级Uid
|
|
|
+ SmartClass oldClassData = smartClassService.getSmartClassById(oldSchoolClass);
|
|
|
+ if (oldClassData == null) {
|
|
|
+ return CommonResult.fail("班级数据无效,更新失败");
|
|
|
+ }
|
|
|
+ CommonResult deleteMaster = SeewoDeleteTeacherMaster(seewoClient, oldClassData.getClassUid(), su.getPhone());
|
|
|
+ if (!deleteMaster.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + deleteMaster.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//region 将班主任推送到希沃
|
|
|
if (useXw == 1) {
|
|
|
CommonResult pushMaster = SeewoPushMaster(seewoClient, su.getPhone(), classData.getClassUid());
|
|
|
@@ -4414,7 +4909,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
XwBodyVo xwResult = objectMapper.readValue(result.getBody(), XwBodyVo.class);
|
|
|
if (!xwResult.getCode().equals("000000")) {
|
|
|
- return CommonResult.fail("希沃平台:" + result.getMessage());
|
|
|
+ return CommonResult.fail("希沃平台:" + xwResult.getMessage());
|
|
|
}
|
|
|
|
|
|
return CommonResult.ok("换班成功");
|
|
|
@@ -6375,6 +6870,53 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
ExcelUtils.excelDownload(workbook, s1 + ":统计报表.xlsx", response);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @PassToken
|
|
|
+ public CommonResult lostBan(String teacherUid, String classUid) {
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ CommonResult deleteTeacherMaster = SeewoDeleteTeacherMaster(seewoClient, classUid, teacherUid);
|
|
|
+ if (deleteTeacherMaster.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + deleteTeacherMaster.getMessage());
|
|
|
+ }
|
|
|
+// CommonResult pushMaster = SeewoPushMaster(seewoClient, teacherUid, classUid);
|
|
|
+// if (!pushMaster.isSuccess()) {
|
|
|
+// return CommonResult.fail("希沃平台:" + pushMaster.getMessage());
|
|
|
+// }
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public CommonResult seeWoLostBan(SeewoClient seewoClient,String schoolUid, String classUid, String teacherUid){
|
|
|
+ MdmTeacherClassApiTeacherLeaveClassParam requestParam = new MdmTeacherClassApiTeacherLeaveClassParam();
|
|
|
+ //请求体,MimeType为 application/json
|
|
|
+ MdmTeacherClassApiTeacherLeaveClassParam.JSONRequestBody requestBody = MdmTeacherClassApiTeacherLeaveClassParam.JSONRequestBody.builder()
|
|
|
+ .build();
|
|
|
+ requestParam.setRequestBody(requestBody);
|
|
|
+ //
|
|
|
+ List<String> teacherIds = new ArrayList<>();
|
|
|
+ teacherIds.add(teacherUid);
|
|
|
+ MdmTeacherClassApiTeacherLeaveClassParam.TeacherLeaveClassReqDto reqDto = MdmTeacherClassApiTeacherLeaveClassParam.TeacherLeaveClassReqDto.builder()
|
|
|
+ .orgUid(schoolUid)
|
|
|
+ .classUid(classUid)
|
|
|
+ .teacherUids(teacherIds)
|
|
|
+ .positionCode("CLASS_MASTER")
|
|
|
+ .build();
|
|
|
+ requestBody.setReqDto(reqDto);
|
|
|
+ MdmTeacherClassApiTeacherLeaveClassRequest request = new MdmTeacherClassApiTeacherLeaveClassRequest(requestParam);
|
|
|
+ System.out.println("入参:" +request);
|
|
|
+ //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
|
|
|
+ MdmTeacherClassApiTeacherLeaveClassResult 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("删除成功");
|
|
|
+ }
|
|
|
|
|
|
//endregion
|
|
|
|
|
|
@@ -7513,7 +8055,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
logger.info("循环结束:" + TimeExchange.getDateMillS());
|
|
|
//region 批量更新学生数据
|
|
|
- boolean updateBatch = smartUserService.updateUserBatchById(users);
|
|
|
+ boolean updateBatch = smartUserService.updateBatchById(users);
|
|
|
|
|
|
logger.info("存储结束:" + TimeExchange.getDateMillS());
|
|
|
|