|
|
@@ -23,6 +23,8 @@ import org.dromara.jcbt.enums.WorkStudyApplicationStatusEnum;
|
|
|
import org.dromara.jcbt.mapper.JcbtWorkStudyApplicationMapper;
|
|
|
import org.dromara.jcbt.mapper.JcbtWorkStudyPositionMapper;
|
|
|
import org.dromara.jcbt.service.IJcbtWorkStudyApplicationService;
|
|
|
+import org.dromara.xg.service.IXgStudentMsgService;
|
|
|
+import org.dromara.xg.domain.vo.XgStudentMsgVo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -42,6 +44,7 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic
|
|
|
|
|
|
private final JcbtWorkStudyApplicationMapper baseMapper;
|
|
|
private final JcbtWorkStudyPositionMapper positionMapper;
|
|
|
+ private final IXgStudentMsgService xgStudentMsgService;
|
|
|
|
|
|
/**
|
|
|
* 查询勤工俭学申请信息
|
|
|
@@ -161,10 +164,46 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic
|
|
|
if (add.getStudentId() == null) {
|
|
|
add.setStudentId(LoginHelper.getUserId());
|
|
|
}
|
|
|
- // 设置学院ID(如果BO中没有设置的话,设置为默认值0,表示待确定)
|
|
|
- if (add.getCollegeId() == null) {
|
|
|
- add.setCollegeId(0L);
|
|
|
+
|
|
|
+ // 智能设置学院ID:优先使用BO中的值,否则根据学生信息自动获取
|
|
|
+ if (add.getCollegeId() == null || add.getCollegeId().equals(0L)) {
|
|
|
+ // 根据学生ID从学生信息表中获取学院ID
|
|
|
+ Long studentId = add.getStudentId();
|
|
|
+ if (studentId != null) {
|
|
|
+ try {
|
|
|
+ // 调用学生信息服务获取学院ID
|
|
|
+ XgStudentMsgVo studentInfo = xgStudentMsgService.queryByUserId(studentId);
|
|
|
+ if (studentInfo != null && StringUtils.isNotBlank(studentInfo.getCollegeId())) {
|
|
|
+ // 将字符串类型的collegeId转换为Long类型
|
|
|
+ try {
|
|
|
+ Long collegeId = Long.parseLong(studentInfo.getCollegeId());
|
|
|
+ add.setCollegeId(collegeId);
|
|
|
+ log.info("成功获取学生学院信息,studentId={}, collegeId={}, collegeName={}",
|
|
|
+ studentId, collegeId, studentInfo.getCollegeName());
|
|
|
+
|
|
|
+ // 同时确保学院名称的一致性
|
|
|
+ if (StringUtils.isBlank(add.getCollegeName()) && StringUtils.isNotBlank(studentInfo.getCollegeName())) {
|
|
|
+ add.setCollegeName(studentInfo.getCollegeName());
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.warn("学院ID格式转换失败,studentId={}, collegeId={}", studentId, studentInfo.getCollegeId(), e);
|
|
|
+ add.setCollegeId(0L);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果仍然获取不到,记录日志并设置为待确定状态
|
|
|
+ log.warn("无法获取学生ID={}的学院信息,设置为待确定状态", studentId);
|
|
|
+ add.setCollegeId(0L);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取学生学院信息失败,studentId={}", studentId, e);
|
|
|
+ add.setCollegeId(0L);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.warn("学生ID为空,无法获取学院信息");
|
|
|
+ add.setCollegeId(0L);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
// 设置年级(如果BO中没有设置的话,设置为默认值)
|
|
|
if (add.getGrade() == null || add.getGrade().trim().isEmpty()) {
|
|
|
add.setGrade("未设置");
|
|
|
@@ -173,7 +212,7 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic
|
|
|
if (add.getMajorName() == null || add.getMajorName().trim().isEmpty()) {
|
|
|
add.setMajorName("待确定");
|
|
|
}
|
|
|
- // 设置申请状态为已提交
|
|
|
+ // 设置申请状态为已提交
|
|
|
add.setStatus(WorkStudyApplicationStatusEnum.SUBMITTED.getCode());
|
|
|
add.setApplicationDate(new Date());
|
|
|
// 设置岗位名称
|
|
|
@@ -225,7 +264,7 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic
|
|
|
if (application == null) {
|
|
|
throw new ServiceException("申请不存在");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 检查当前登录用户权限
|
|
|
Long currentUserId = LoginHelper.getUserId();
|
|
|
if (!currentUserId.equals(application.getCreateBy())) {
|
|
|
@@ -236,7 +275,7 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic
|
|
|
if (!WorkStudyApplicationStatusEnum.SUBMITTED.getCode().equals(application.getStatus())) {
|
|
|
throw new ServiceException("申请状态异常");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|