|
|
@@ -1,18 +1,21 @@
|
|
|
package com.template.controller;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.seewo.open.sdk.DefaultSeewoClient;
|
|
|
import com.seewo.open.sdk.SeewoClient;
|
|
|
import com.seewo.open.sdk.auth.Account;
|
|
|
import com.template.annotation.DESRespondSecret;
|
|
|
import com.template.annotation.PassToken;
|
|
|
import com.template.api.SmartEnrollmentUserControllerAPI;
|
|
|
-import com.template.common.utils.TimeExchange;
|
|
|
+import com.template.common.utils.*;
|
|
|
+import com.template.config.ControlConfig;
|
|
|
import com.template.config.SeewoConfig;
|
|
|
import com.template.model.dto.SmartEnrollmentUserSaveDto;
|
|
|
import com.template.model.enumModel.eDuties;
|
|
|
@@ -26,10 +29,14 @@ import com.template.model.request.isrRequest;
|
|
|
import com.template.model.result.CommonResult;
|
|
|
import com.template.model.result.PageUtils;
|
|
|
import com.template.model.seewo.PhotoServiceSavePhotosParam;
|
|
|
+import com.template.model.vo.BsStudentNoVo;
|
|
|
+import com.template.model.vo.BsStudentVo;
|
|
|
import com.template.model.vo.SmartEnrollmentUserExamineDto;
|
|
|
import com.template.model.vo.SmartEnrollmentUserVo;
|
|
|
import com.template.services.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
@@ -37,8 +44,12 @@ import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.template.common.utils.AesTestOne.decrypt;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 前端控制器
|
|
|
@@ -74,6 +85,13 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
@Autowired
|
|
|
private SmartOperationUserService smartOperationUserService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ControlConfig controlConfig;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SmartTimeGroupService smartTimeGroupService;
|
|
|
+
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(SmartUserController.class);
|
|
|
|
|
|
@Override
|
|
|
@PassToken
|
|
|
@@ -83,21 +101,23 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
BeanUtils.copyProperties(dto, smartEnrollmentUser);
|
|
|
|
|
|
// 找到对应的年级
|
|
|
- String gradeName = dto.getGradeName();
|
|
|
- LambdaQueryWrapper<SmartGrade> wrapperSG = new LambdaQueryWrapper<>();
|
|
|
- wrapperSG.eq(SmartGrade::getName, gradeName);
|
|
|
- SmartGrade smartGrade = smartGradeService.getOne(wrapperSG);
|
|
|
+ Integer gradeId = dto.getGradeId();
|
|
|
+// LambdaQueryWrapper<SmartGrade> wrapperSG = new LambdaQueryWrapper<>();
|
|
|
+// wrapperSG.eq(SmartGrade::getName, gradeName);
|
|
|
+// SmartGrade smartGrade = smartGradeService.getOne(wrapperSG);
|
|
|
+ SmartGrade smartGrade = smartGradeService.getById(gradeId);
|
|
|
if (ObjectUtils.isEmpty(smartGrade)) {
|
|
|
return CommonResult.fail("年级不存在");
|
|
|
-
|
|
|
}
|
|
|
smartEnrollmentUser.setGrade(smartGrade.getId() + "");
|
|
|
|
|
|
// 找到对应的班级
|
|
|
- String schoolClassName = dto.getSchoolClassName();
|
|
|
- LambdaQueryWrapper<SmartClass> wrapperSC = new LambdaQueryWrapper<>();
|
|
|
- wrapperSC.eq(SmartClass::getName, schoolClassName);
|
|
|
- SmartClass smartClass = smartClassService.getOne(wrapperSC);
|
|
|
+// String schoolClassName = dto.getSchoolClassName();
|
|
|
+// LambdaQueryWrapper<SmartClass> wrapperSC = new LambdaQueryWrapper<>();
|
|
|
+// wrapperSC.eq(SmartClass::getName, schoolClassName);
|
|
|
+// SmartClass smartClass = smartClassService.getOne(wrapperSC);
|
|
|
+ Integer classId = dto.getClassId();
|
|
|
+ SmartClass smartClass = smartClassService.getById(classId);
|
|
|
if (ObjectUtils.isEmpty(smartClass)) {
|
|
|
return CommonResult.fail("班级不存在");
|
|
|
}
|
|
|
@@ -114,6 +134,9 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
smartEnrollmentUser.setIdentityId(2);
|
|
|
smartEnrollmentUser.setTimeGroupId(8);
|
|
|
// 获取学号
|
|
|
+ String schoolClassName = smartClass.getName();
|
|
|
+ String gradeName = smartGrade.getName();
|
|
|
+ String year = gradeName.replace("级", "");
|
|
|
String[] s = schoolClassName.split("级");
|
|
|
if (s.length < 2) {
|
|
|
return CommonResult.fail("获取学号异常");
|
|
|
@@ -127,14 +150,21 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
if (ObjectUtils.isEmpty(s3)) {
|
|
|
return CommonResult.fail("获取学号异常");
|
|
|
}
|
|
|
- LambdaQueryWrapper<SmartEnrollmentUser> wrapperCount = new LambdaQueryWrapper<>();
|
|
|
- wrapperCount.eq(SmartEnrollmentUser::getIdentityId, 2)
|
|
|
- .eq(SmartEnrollmentUser::getGrade, smartGrade.getId())
|
|
|
- .eq(SmartEnrollmentUser::getSchoolClass, smartClass.getId());
|
|
|
- int count = smartEnrollmentUserService.count(wrapperCount);
|
|
|
- String cardNo = cardNo(s3, count + 1);
|
|
|
-
|
|
|
- smartEnrollmentUser.setCardNo(cardNo);
|
|
|
+ LambdaQueryWrapper<SmartUser> wrapperCount = new LambdaQueryWrapper<>();
|
|
|
+ wrapperCount.eq(SmartUser::getIdentityId, 2)
|
|
|
+ .eq(SmartUser::getGrade, smartGrade.getId())
|
|
|
+ .eq(SmartUser::getSchoolClass, smartClass.getId());
|
|
|
+ int count = smartUserService.count(wrapperCount);
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ int year2 = cal.get(Calendar.YEAR);
|
|
|
+ Integer integer = Integer.valueOf(year);
|
|
|
+ if (year2==integer) {
|
|
|
+ String cardNo = cardNo(year,s3, count + 1);
|
|
|
+ smartEnrollmentUser.setCardNo(cardNo);
|
|
|
+ }else {
|
|
|
+ String cardNo = cardNo(year,s3, count + 10);
|
|
|
+ smartEnrollmentUser.setCardNo(cardNo);
|
|
|
+ }
|
|
|
|
|
|
smartEnrollmentUserService.save(smartEnrollmentUser);
|
|
|
|
|
|
@@ -158,7 +188,7 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
} else {
|
|
|
String affiliate = user.getAffiliate();
|
|
|
user.setAffiliate(affiliate + "," + smartEnrollmentUser.getId() + "");
|
|
|
- smartEnrollmentUserService.save(user);
|
|
|
+ smartEnrollmentUserService.updateById(user);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -169,7 +199,7 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
|
|
|
@Override
|
|
|
@PassToken
|
|
|
- @DESRespondSecret(validated = false)
|
|
|
+ @DESRespondSecret(validated = true)
|
|
|
public CommonResult list(Integer currentPage, Integer pageCount, String status, String grade, Integer schoolClass, String keyWord) {
|
|
|
|
|
|
PageUtils<SmartEnrollmentUserVo> result = smartEnrollmentUserService.listPage(currentPage, pageCount, status, grade, schoolClass, keyWord);
|
|
|
@@ -178,8 +208,8 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @DESRespondSecret(validated = true)
|
|
|
@PassToken
|
|
|
- @DESRespondSecret(validated = false)
|
|
|
public CommonResult examine(SmartEnrollmentUserExamineDto dto) throws Exception {
|
|
|
Integer id = dto.getId();
|
|
|
String status = dto.getStatus();
|
|
|
@@ -191,124 +221,76 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
return CommonResult.fail("学生信息不存在");
|
|
|
}
|
|
|
|
|
|
- smartEnrollmentUser2.setStatus(status);
|
|
|
- smartEnrollmentUser2.setRemark(remark);
|
|
|
|
|
|
-// smartEnrollmentUserService.updateById(smartEnrollmentUser2);
|
|
|
-
|
|
|
-// 获取
|
|
|
-// 家长信息
|
|
|
+// 获取家长信息
|
|
|
Integer userId = smartEnrollmentUser2.getId();
|
|
|
|
|
|
List<SmartEnrollmentUser> list = smartEnrollmentUserService.getJiaZhang(userId);
|
|
|
|
|
|
- ArrayList<SmartEnrollmentUser> smartEnrollmentUsers = new ArrayList<>();
|
|
|
- smartEnrollmentUsers.add(smartEnrollmentUser2);
|
|
|
- smartEnrollmentUsers.addAll(list);
|
|
|
-
|
|
|
-
|
|
|
- SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
|
|
|
//同意
|
|
|
if ("1".equals(status)) {
|
|
|
- for (SmartEnrollmentUser smartEnrollmentUser : smartEnrollmentUsers) {
|
|
|
+ String affiliate="";
|
|
|
+// 需要先添加学生才能添加家长
|
|
|
+ if (ObjectUtils.isNotEmpty(smartEnrollmentUser2)) {
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ smartEnrollmentUser2.setStatus(status);
|
|
|
+ smartEnrollmentUser2.setRemark(remark);
|
|
|
|
|
|
// 需要同步到学生表,然后同步到希沃,百胜门禁
|
|
|
int useBs = 1;
|
|
|
int useXw = 1;
|
|
|
SmartGrade gradeData = null;
|
|
|
SmartClass classData = null;
|
|
|
- if (org.springframework.util.StringUtils.hasText(smartEnrollmentUser.getCardNo())) {
|
|
|
+ if (org.springframework.util.StringUtils.hasText(smartEnrollmentUser2.getCardNo())) {
|
|
|
//重复性判断
|
|
|
- int existCount = smartUserService.querySmartUserByCardNo(smartEnrollmentUser.getCardNo());
|
|
|
+ int existCount = smartUserService.querySmartUserByCardNo(smartEnrollmentUser2.getCardNo());
|
|
|
if (existCount > 0) {
|
|
|
return CommonResult.fail("当前学号已存在,请勿重复添加");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
SmartUser su = new SmartUser();
|
|
|
- su.setTimeGroupId(smartEnrollmentUser.getTimeGroupId());
|
|
|
- su.setCardNo(smartEnrollmentUser.getCardNo());
|
|
|
- su.setName(smartEnrollmentUser.getName());
|
|
|
- su.setIdentityId(smartEnrollmentUser.getIdentityId());
|
|
|
- su.setIdCard(smartEnrollmentUser.getIdCard());
|
|
|
- su.setSexId(smartEnrollmentUser.getSexId());
|
|
|
- su.setDepartmentId(smartEnrollmentUser.getDepartmentId());
|
|
|
- su.setHeadImage(smartEnrollmentUser.getHeadImage());
|
|
|
- su.setGrade(smartEnrollmentUser.getGrade());
|
|
|
- su.setSchoolClass(smartEnrollmentUser.getSchoolClass());
|
|
|
- su.setPhone(smartEnrollmentUser.getPhone());
|
|
|
- su.setAffiliate(smartEnrollmentUser.getAffiliate());
|
|
|
+ su.setTimeGroupId(smartEnrollmentUser2.getTimeGroupId());
|
|
|
+ su.setCardNo(smartEnrollmentUser2.getCardNo());
|
|
|
+ su.setName(smartEnrollmentUser2.getName());
|
|
|
+ su.setIdentityId(smartEnrollmentUser2.getIdentityId());
|
|
|
+ su.setIdCard(smartEnrollmentUser2.getIdCard());
|
|
|
+ su.setSexId(smartEnrollmentUser2.getSexId());
|
|
|
+ su.setDepartmentId(smartEnrollmentUser2.getDepartmentId());
|
|
|
+ su.setHeadImage(smartEnrollmentUser2.getHeadImage());
|
|
|
+ su.setGrade(smartEnrollmentUser2.getGrade());
|
|
|
+ su.setSchoolClass(smartEnrollmentUser2.getSchoolClass());
|
|
|
+ su.setPhone(smartEnrollmentUser2.getPhone());
|
|
|
+ su.setAffiliate(smartEnrollmentUser2.getAffiliate());
|
|
|
su.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
|
|
|
- //region 人员信息加入到第三方api
|
|
|
- //要将用户数据加入到希沃和百胜中
|
|
|
- //希沃和百胜的老师、学生数据添加是不一样的,所以按身份添加
|
|
|
- if (smartEnrollmentUser.getIdentityId().intValue() == eIdentityStatu.Parent.getValue()) {//家长
|
|
|
-
|
|
|
- //region 家长参数必填判断:手机号
|
|
|
- if (smartEnrollmentUser.getPhone() == null) {
|
|
|
- return CommonResult.fail("家长手机号不能为空");
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
- //查找家长身份是否存在用了该手机号的用户
|
|
|
-// int existCount = smartUserService.queryParentByCount(smartEnrollmentUser.getPhone());
|
|
|
-// if (existCount > 0) {
|
|
|
-// return CommonResult.fail("当前手机号已被其他家长使用");
|
|
|
-// }
|
|
|
-
|
|
|
- //拿到被关联学生的信息去获取对应的卡号
|
|
|
- //有多个学生就循环学生
|
|
|
-
|
|
|
- if (smartEnrollmentUser.getAffiliate() == null) {
|
|
|
- return CommonResult.fail("被关联人不能为空");
|
|
|
- }
|
|
|
- String affiliate = smartEnrollmentUser.getAffiliate();
|
|
|
- String[] split = affiliate.split(",");
|
|
|
- ArrayList<String> affiliateList = new ArrayList<>();
|
|
|
- affiliateList.addAll(Arrays.asList(split));
|
|
|
- if (affiliateList.size() <= 0) {
|
|
|
- return CommonResult.fail("被关联人不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- List<SmartUser> studentDatas = smartUserService.getSmartUserIds(affiliateList);
|
|
|
-
|
|
|
- //region 希沃新增编辑学生家长信息
|
|
|
- if (useXw == 1) {
|
|
|
- CommonResult insertOrUpdateStudent = smartUserController.insertOrUpdateStudentParent(seewoClient, studentDatas, "其他", smartEnrollmentUser.getPhone(), true);
|
|
|
- if (!insertOrUpdateStudent.isSuccess()) {
|
|
|
- return CommonResult.fail("希沃平台:" + insertOrUpdateStudent.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
- } else if (smartEnrollmentUser.getIdentityId().intValue() == eIdentityStatu.Student.getValue()) {//学生
|
|
|
+ if (smartEnrollmentUser2.getIdentityId() == eIdentityStatu.Student.getValue()) {//学生
|
|
|
|
|
|
//region 学生参数必填判断:年级、班级
|
|
|
- if (smartEnrollmentUser.getGrade() == null) {
|
|
|
+ if (smartEnrollmentUser2.getGrade() == null) {
|
|
|
return CommonResult.fail("学生年级不能为空");
|
|
|
}
|
|
|
|
|
|
- if (smartEnrollmentUser.getSchoolClass() == null) {
|
|
|
+ if (smartEnrollmentUser2.getSchoolClass() == null) {
|
|
|
return CommonResult.fail("学生班级不能为空");
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
//获取班级Uid
|
|
|
- classData = smartClassService.getSmartClassById(smartEnrollmentUser.getSchoolClass());
|
|
|
+ classData = smartClassService.getSmartClassById(smartEnrollmentUser2.getSchoolClass());
|
|
|
if (classData == null) {
|
|
|
return CommonResult.fail("班级数据无效,新增失败");
|
|
|
}
|
|
|
|
|
|
- gradeData = smartGradeService.querySmartGradeById(su.getGrade() == null || su.getGrade() == "" ? null : Integer.valueOf(smartEnrollmentUser.getGrade()));
|
|
|
+ gradeData = smartGradeService.querySmartGradeById(su.getGrade() == null || su.getGrade() == "" ? null : Integer.valueOf(smartEnrollmentUser2.getGrade()));
|
|
|
if (gradeData == null) {
|
|
|
return CommonResult.fail("年级数据无效,新增失败");
|
|
|
}
|
|
|
|
|
|
//region 希沃新增学生信息
|
|
|
if (useXw == 1) {
|
|
|
- CommonResult<String> insertStudent = smartUserController.SeewoInsertStudent(seewoClient, smartEnrollmentUser.getName(), smartEnrollmentUser.getCardNo(), smartEnrollmentUser.getSexId(), smartEnrollmentUser.getPhone(), classData.getClassUid());
|
|
|
+ CommonResult<String> insertStudent = smartUserController.SeewoInsertStudent(seewoClient, smartEnrollmentUser2.getName(), smartEnrollmentUser2.getCardNo(), smartEnrollmentUser2.getSexId(), smartEnrollmentUser2.getPhone(), classData.getClassUid());
|
|
|
if (!insertStudent.isSuccess()) {
|
|
|
return CommonResult.fail("希沃平台:" + insertStudent.getMessage());
|
|
|
}
|
|
|
@@ -335,7 +317,7 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
*/
|
|
|
String startTime = TimeExchange.DateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
|
String endTime = smartUserController.queryGraduationYear(gradeData.getGradeNo());
|
|
|
- CommonResult<String> insertBsStudent = smartUserController.bsInsertStudent(smartEnrollmentUser.getName(), smartEnrollmentUser.getCardNo(), smartEnrollmentUser.getSexId(), smartEnrollmentUser.getHeadImage(), smartEnrollmentUser.getTimeGroupId(), classData.getBsClassNo(), startTime, endTime, smartEnrollmentUser.getIdCard());
|
|
|
+ CommonResult<String> insertBsStudent = bsInsertStudent(smartEnrollmentUser2.getName(), smartEnrollmentUser2.getCardNo(), smartEnrollmentUser2.getSexId(), smartEnrollmentUser2.getHeadImage(), smartEnrollmentUser2.getTimeGroupId(), classData.getBsClassNo(), startTime, endTime, smartEnrollmentUser2.getIdCard());
|
|
|
if (!insertBsStudent.isSuccess()) {
|
|
|
return CommonResult.fail("百胜平台:" + insertBsStudent.getMessage());
|
|
|
}
|
|
|
@@ -345,9 +327,9 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
|
|
|
|
|
|
//最后都要把数据加入到数据库中
|
|
|
- if (org.springframework.util.StringUtils.hasText(smartEnrollmentUser.getPhone())) {
|
|
|
+ if (org.springframework.util.StringUtils.hasText(smartEnrollmentUser2.getPhone())) {
|
|
|
//多身份
|
|
|
- List<SmartUser> users = smartUserService.getPhoneUsers(smartEnrollmentUser.getPhone());
|
|
|
+ List<SmartUser> users = smartUserService.getPhoneUsers(smartEnrollmentUser2.getPhone());
|
|
|
if (users != null && users.size() > 0) {
|
|
|
Optional<SmartUser> ownerUser = users.stream().filter(e -> org.springframework.util.StringUtils.hasText(e.getXOpenId())).findFirst();
|
|
|
if (ownerUser != null && ownerUser.isPresent()) {
|
|
|
@@ -358,6 +340,10 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
|
|
|
int result = smartUserService.insertSmartUser(su);
|
|
|
|
|
|
+ affiliate=su.getId()+"";
|
|
|
+ smartEnrollmentUser2.setUserAffiliate(affiliate);
|
|
|
+ smartEnrollmentUserService.updateById(smartEnrollmentUser2);
|
|
|
+
|
|
|
if (result > 0) {
|
|
|
// 将添加的用户同步到海康平台
|
|
|
Integer identityId = su.getIdentityId();
|
|
|
@@ -373,7 +359,118 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }else {//拒绝
|
|
|
+
|
|
|
+
|
|
|
+ for (SmartEnrollmentUser smartEnrollmentUser : list) {
|
|
|
+ SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
|
|
|
+ smartEnrollmentUser.setStatus(status);
|
|
|
+ smartEnrollmentUser.setRemark(remark);
|
|
|
+
|
|
|
+// 需要同步到学生表,然后同步到希沃,百胜门禁
|
|
|
+ int useBs = 1;
|
|
|
+ int useXw = 1;
|
|
|
+ SmartGrade gradeData = null;
|
|
|
+ SmartClass classData = null;
|
|
|
+ if (org.springframework.util.StringUtils.hasText(smartEnrollmentUser.getCardNo())) {
|
|
|
+ //重复性判断
|
|
|
+ int existCount = smartUserService.querySmartUserByCardNo(smartEnrollmentUser.getCardNo());
|
|
|
+ if (existCount > 0) {
|
|
|
+ return CommonResult.fail("当前学号已存在,请勿重复添加");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartUser su = new SmartUser();
|
|
|
+ su.setTimeGroupId(smartEnrollmentUser.getTimeGroupId());
|
|
|
+ su.setCardNo(smartEnrollmentUser.getCardNo());
|
|
|
+ su.setName(smartEnrollmentUser.getName());
|
|
|
+ su.setIdentityId(smartEnrollmentUser.getIdentityId());
|
|
|
+ su.setIdCard(smartEnrollmentUser.getIdCard());
|
|
|
+ su.setSexId(smartEnrollmentUser.getSexId());
|
|
|
+ su.setDepartmentId(smartEnrollmentUser.getDepartmentId());
|
|
|
+ su.setHeadImage(smartEnrollmentUser.getHeadImage());
|
|
|
+ su.setGrade(smartEnrollmentUser.getGrade());
|
|
|
+ su.setSchoolClass(smartEnrollmentUser.getSchoolClass());
|
|
|
+ su.setPhone(smartEnrollmentUser.getPhone());
|
|
|
+ String userAffiliate = smartEnrollmentUser.getUserAffiliate();
|
|
|
+ if (ObjectUtils.isNotEmpty(userAffiliate)) {
|
|
|
+ userAffiliate=userAffiliate+","+affiliate;
|
|
|
+ }else {
|
|
|
+ userAffiliate=affiliate;
|
|
|
+ }
|
|
|
+ smartEnrollmentUser.setUserAffiliate(userAffiliate);
|
|
|
+ su.setAffiliate(userAffiliate);
|
|
|
+ su.setIsCancel(eLogOff.Unlogout.getValue());
|
|
|
+
|
|
|
+ //region 人员信息加入到第三方api
|
|
|
+ //要将用户数据加入到希沃和百胜中
|
|
|
+ //希沃和百胜的老师、学生数据添加是不一样的,所以按身份添加
|
|
|
+ if (smartEnrollmentUser.getIdentityId() == eIdentityStatu.Parent.getValue()) {//家长
|
|
|
+
|
|
|
+ //region 家长参数必填判断:手机号
|
|
|
+ if (smartEnrollmentUser.getPhone() == null) {
|
|
|
+ return CommonResult.fail("家长手机号不能为空");
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //查找家长身份是否存在用了该手机号的用户
|
|
|
+// int existCount = smartUserService.queryParentByCount(smartEnrollmentUser.getPhone());
|
|
|
+// if (existCount > 0) {
|
|
|
+// return CommonResult.fail("当前手机号已被其他家长使用");
|
|
|
+// }
|
|
|
+
|
|
|
+ //拿到被关联学生的信息去获取对应的卡号
|
|
|
+ //有多个学生就循环学生
|
|
|
+
|
|
|
+ if (smartEnrollmentUser.getAffiliate() == null) {
|
|
|
+ return CommonResult.fail("被关联人不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] split = affiliate.split(",");
|
|
|
+ ArrayList<String> affiliateList = new ArrayList<>();
|
|
|
+ affiliateList.addAll(Arrays.asList(split));
|
|
|
+ if (affiliateList.size() <= 0) {
|
|
|
+ return CommonResult.fail("被关联人不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartUser> studentDatas = smartUserService.getSmartUserIds(affiliateList);
|
|
|
+
|
|
|
+ //region 希沃新增编辑学生家长信息
|
|
|
+ if (useXw == 1) {
|
|
|
+ CommonResult insertOrUpdateStudent = smartUserController.insertOrUpdateStudentParent(seewoClient, studentDatas, "其他", smartEnrollmentUser.getPhone(), true);
|
|
|
+ if (!insertOrUpdateStudent.isSuccess()) {
|
|
|
+ return CommonResult.fail("希沃平台:" + insertOrUpdateStudent.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //最后都要把数据加入到数据库中
|
|
|
+ if (org.springframework.util.StringUtils.hasText(smartEnrollmentUser.getPhone())) {
|
|
|
+ //多身份
|
|
|
+ List<SmartUser> users = smartUserService.getPhoneUsers(smartEnrollmentUser.getPhone());
|
|
|
+ if (users != null && users.size() > 0) {
|
|
|
+ Optional<SmartUser> ownerUser = users.stream().filter(e -> org.springframework.util.StringUtils.hasText(e.getXOpenId())).findFirst();
|
|
|
+ if (ownerUser != null && ownerUser.isPresent()) {
|
|
|
+ su.setXOpenId(ownerUser.get().getXOpenId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int result = smartUserService.insertSmartUser(su);
|
|
|
+
|
|
|
+ smartEnrollmentUserService.updateById(smartEnrollmentUser);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else if ("2".equals(status)){//拒绝
|
|
|
+ smartEnrollmentUser2.setStatus(status);
|
|
|
+ smartEnrollmentUser2.setRemark(remark);
|
|
|
+ smartEnrollmentUserService.updateById(smartEnrollmentUser2);
|
|
|
+
|
|
|
// 需要修改家长信息
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SmartEnrollmentUser smartEnrollmentUser = list.get(i);
|
|
|
@@ -381,20 +478,20 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
String[] split = affiliate.split(",");
|
|
|
ArrayList<String> affiliateList = new ArrayList<>(Arrays.asList(split));
|
|
|
affiliateList.remove(String.valueOf(userId));
|
|
|
- String aff="";
|
|
|
+ String aff = "";
|
|
|
for (int j = 0; j < affiliateList.size(); j++) {
|
|
|
String s = affiliateList.get(j);
|
|
|
- if (j==0) {
|
|
|
- aff=s;
|
|
|
- }else {
|
|
|
- aff=aff+","+s;
|
|
|
+ if (j == 0) {
|
|
|
+ aff = s;
|
|
|
+ } else {
|
|
|
+ aff = aff + "," + s;
|
|
|
}
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(aff)) {
|
|
|
// 则需要删除
|
|
|
smartEnrollmentUserService.removeById(smartEnrollmentUser.getId());
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// 需要修改关系人
|
|
|
smartEnrollmentUser.setAffiliate(aff);
|
|
|
smartEnrollmentUserService.updateById(smartEnrollmentUser);
|
|
|
@@ -404,15 +501,100 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- smartEnrollmentUserService.updateById(smartEnrollmentUser2);
|
|
|
|
|
|
+
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @PassToken
|
|
|
+ @DESRespondSecret(validated = true)
|
|
|
+ public CommonResult insertTeacherSmartEnrollmentUser(SmartEnrollmentUserSaveDto dto) throws Exception {
|
|
|
+ SmartEnrollmentUser smartEnrollmentUser = new SmartEnrollmentUser();
|
|
|
+ BeanUtils.copyProperties(dto, smartEnrollmentUser);
|
|
|
+
|
|
|
+// 找到对应的年级
|
|
|
+ Integer gradeId = dto.getGradeId();
|
|
|
+
|
|
|
+ SmartGrade smartGrade = smartGradeService.getById(gradeId);
|
|
|
+ if (ObjectUtils.isEmpty(smartGrade)) {
|
|
|
+ return CommonResult.fail("年级不存在");
|
|
|
+ }
|
|
|
+ smartEnrollmentUser.setGrade(smartGrade.getId() + "");
|
|
|
+
|
|
|
+// 找到对应的班级
|
|
|
+ Integer classId = dto.getClassId();
|
|
|
+ SmartClass smartClass = smartClassService.getById(classId);
|
|
|
+ if (ObjectUtils.isEmpty(smartClass)) {
|
|
|
+ return CommonResult.fail("班级不存在");
|
|
|
+ }
|
|
|
+ smartEnrollmentUser.setSchoolClass(smartClass.getId());
|
|
|
+
|
|
|
+ smartEnrollmentUser.setStatus("0");
|
|
|
+ smartEnrollmentUser.setIsCancel(0);
|
|
|
+ smartEnrollmentUser.setIdentityId(2);
|
|
|
+
|
|
|
+// 获取学号
|
|
|
+ String schoolClassName = smartClass.getName();
|
|
|
+ String gradeName = smartGrade.getName();
|
|
|
+ String year = gradeName.replace("级", "");
|
|
|
+ String[] s = schoolClassName.split("级");
|
|
|
+ if (s.length < 2) {
|
|
|
+ return CommonResult.fail("获取学号异常");
|
|
|
+ }
|
|
|
+ String s1 = s[1];
|
|
|
+ if (ObjectUtils.isEmpty(s1)) {
|
|
|
+ return CommonResult.fail("获取学号异常");
|
|
|
+ }
|
|
|
+ String[] s2 = s1.split("班");
|
|
|
+ String s3 = s2[0];
|
|
|
+ if (ObjectUtils.isEmpty(s3)) {
|
|
|
+ return CommonResult.fail("获取学号异常");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<SmartUser> wrapperCount = new LambdaQueryWrapper<>();
|
|
|
+ wrapperCount.eq(SmartUser::getIdentityId, 2)
|
|
|
+ .eq(SmartUser::getGrade, smartGrade.getId())
|
|
|
+ .eq(SmartUser::getSchoolClass, smartClass.getId());
|
|
|
+ int count = smartUserService.count(wrapperCount);
|
|
|
+ String cardNo = cardNo(year,s3, count + 1);
|
|
|
+
|
|
|
+ smartEnrollmentUser.setCardNo(cardNo);
|
|
|
+
|
|
|
+ smartEnrollmentUserService.save(smartEnrollmentUser);
|
|
|
+
|
|
|
+ List<SmartEnrollmentUser> list = dto.getList();
|
|
|
+ for (SmartEnrollmentUser enrollmentUser : list) {
|
|
|
+// 判断该父母是否已存在
|
|
|
+ String phone = enrollmentUser.getPhone();
|
|
|
+ LambdaQueryWrapper<SmartEnrollmentUser> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(SmartEnrollmentUser::getPhone, phone);
|
|
|
+ SmartEnrollmentUser user = smartEnrollmentUserService.getOne(wrapper);
|
|
|
+
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(user)) {
|
|
|
+ enrollmentUser.setSexId(1);
|
|
|
+ enrollmentUser.setAffiliate(smartEnrollmentUser.getId() + "");
|
|
|
+ enrollmentUser.setStatus("0");
|
|
|
+ enrollmentUser.setIsCancel(0);
|
|
|
+
|
|
|
+ enrollmentUser.setIdentityId(1);
|
|
|
+ smartEnrollmentUserService.save(enrollmentUser);
|
|
|
+ } else {
|
|
|
+ String affiliate = user.getAffiliate();
|
|
|
+ user.setAffiliate(affiliate + "," + smartEnrollmentUser.getId() + "");
|
|
|
+ smartEnrollmentUserService.save(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ SmartEnrollmentUserExamineDto smartEnrollmentUserExamineDto = new SmartEnrollmentUserExamineDto();
|
|
|
+ smartEnrollmentUserExamineDto.setId(smartEnrollmentUser.getId());
|
|
|
+ smartEnrollmentUserExamineDto.setStatus("1");
|
|
|
+ smartEnrollmentUserExamineDto.setRemark("老师添加");
|
|
|
+ examine(smartEnrollmentUserExamineDto);
|
|
|
return CommonResult.ok();
|
|
|
}
|
|
|
|
|
|
- public static String cardNo(String grade, Integer count) {
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- // 获取当前年
|
|
|
- int year = calendar.get(Calendar.YEAR);
|
|
|
+ public static String cardNo(String year,String grade, Integer count) {
|
|
|
if (grade.length() < 2) {
|
|
|
Integer i = 2 - grade.length();
|
|
|
for (int j = 0; j < i; j++) {
|
|
|
@@ -420,7 +602,7 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- String card = year + "" + grade;
|
|
|
+ String card = year+grade;
|
|
|
String s = "";
|
|
|
if (count < 10) {
|
|
|
s = "0" + count + "";
|
|
|
@@ -431,7 +613,55 @@ public class SmartEnrollmentUserController implements SmartEnrollmentUserControl
|
|
|
return cardNo;
|
|
|
}
|
|
|
|
|
|
+ public CommonResult<String> bsInsertStudent(String name, String cardNo, Integer sexId, String
|
|
|
+ headImage, Integer timeGroupId, String bsClassNo, String startDate, String endDate, String idCard) throws
|
|
|
+ Exception {
|
|
|
+ //region 百胜新增学生信息
|
|
|
+ String appId = controlConfig.getAppId();
|
|
|
+ String schoolno = controlConfig.getSchoolCode();
|
|
|
+ String timestamp = TimeExchange.DateNowTimeStamo();
|
|
|
+ String appSecret = controlConfig.getAppSecret();
|
|
|
+ String url = controlConfig.getUrl() + "student/create";
|
|
|
+
|
|
|
+ String idCardStr = org.springframework.util.StringUtils.hasText(idCard) ? "\",\"student_idcard\":\"" + idCard : "\",\"student_idcard\":\"" + "";
|
|
|
+
|
|
|
+ String bsGroupNo = eGroupTime(timeGroupId);
|
|
|
+ JSONObject jsonobject = new JSONObject();
|
|
|
+ jsonobject.put("appid", appId);
|
|
|
+ String str = "{\"student_name\":\"" + name + "\",\"classtab_no\":\"" + bsClassNo + "\",\"student_number\":\"" + cardNo + "\",\"student_sex\":\"" + sexId + idCardStr + "\",\"student_photo\":\"" + imageUtils.getBase64Url(headImage) + "\",\"student_startdate\":\"" + startDate + "\",\"student_effdate\":\"" + endDate + "\",\"student_tgno\":\"" + bsGroupNo + "\"}";
|
|
|
+ String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
|
|
|
+ jsonobject.put("data", aesStr);
|
|
|
+ jsonobject.put("schoolno", schoolno);
|
|
|
+ jsonobject.put("timestamp", timestamp);
|
|
|
+
|
|
|
+ String md5Str = "appid=" + appId + "&data={\"student_name\":\"" + name + "\",\"classtab_no\":\"" + bsClassNo + "\",\"student_number\":\"" + cardNo + "\",\"student_sex\":\"" + sexId + idCardStr + "\",\"student_photo\":\"" + imageUtils.getBase64Url(headImage) + "\",\"student_startdate\":\"" + startDate + "\",\"student_effdate\":\"" + endDate + "\",\"student_tgno\":\"" + bsGroupNo + "\"}" + "&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());
|
|
|
+
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ BsStudentVo grade = objectMapper.readValue(bsResult, BsStudentVo.class);
|
|
|
+
|
|
|
+ if (!bsResult.contains("添加成功")) {
|
|
|
+ return CommonResult.fail("百胜平台:" + grade.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ // URL解码
|
|
|
+ String decodedUrl = URLDecoder.decode(grade.getData(), "UTF-8");
|
|
|
+
|
|
|
+ BsStudentNoVo studentNo = objectMapper.readValue(decrypt(decodedUrl, controlConfig.getAppSecret()), BsStudentNoVo.class);
|
|
|
|
|
|
+ return CommonResult.ok("200", "新增成功", studentNo.getStudent_no());
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ public String eGroupTime(Integer id) {
|
|
|
+ SmartTimeGroup result = smartTimeGroupService.queryTimeGroupById(id);
|
|
|
+ return result == null ? "" : result.getBsno();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|