|
@@ -20,6 +20,7 @@ import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.zsjy.domain.bo.InternshipInfoQueryBO;
|
|
import org.dromara.zsjy.domain.bo.InternshipInfoQueryBO;
|
|
|
import org.dromara.zsjy.domain.bo.InternshipInfoAddBO;
|
|
import org.dromara.zsjy.domain.bo.InternshipInfoAddBO;
|
|
|
import org.dromara.zsjy.domain.bo.InternshipInfoEditBO;
|
|
import org.dromara.zsjy.domain.bo.InternshipInfoEditBO;
|
|
|
|
|
+import org.dromara.zsjy.domain.bo.InternshipInfoChangeBO;
|
|
|
import org.dromara.zsjy.domain.vo.InternshipInfoVO;
|
|
import org.dromara.zsjy.domain.vo.InternshipInfoVO;
|
|
|
import org.dromara.zsjy.domain.ZsjyInternshipInfo;
|
|
import org.dromara.zsjy.domain.ZsjyInternshipInfo;
|
|
|
import org.dromara.zsjy.mapper.InternshipInfoMapper;
|
|
import org.dromara.zsjy.mapper.InternshipInfoMapper;
|
|
@@ -468,34 +469,34 @@ public class InternshipInfoServiceImpl implements IInternshipInfoService {
|
|
|
@Override
|
|
@Override
|
|
|
public InternshipInfoVO getCurrentStudentInternship() {
|
|
public InternshipInfoVO getCurrentStudentInternship() {
|
|
|
log.info("开始获取当前学生的实习信息");
|
|
log.info("开始获取当前学生的实习信息");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 获取当前登录用户ID
|
|
// 获取当前登录用户ID
|
|
|
Long currentUserId = LoginHelper.getUserId();
|
|
Long currentUserId = LoginHelper.getUserId();
|
|
|
log.info("当前登录用户ID:{}", currentUserId);
|
|
log.info("当前登录用户ID:{}", currentUserId);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (currentUserId == null) {
|
|
if (currentUserId == null) {
|
|
|
log.error("当前用户未登录");
|
|
log.error("当前用户未登录");
|
|
|
throw new ServiceException("用户未登录");
|
|
throw new ServiceException("用户未登录");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 根据用户ID查询实习信息
|
|
// 根据用户ID查询实习信息
|
|
|
LambdaQueryWrapper<ZsjyInternshipInfo> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ZsjyInternshipInfo> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(ZsjyInternshipInfo::getStudentId, currentUserId)
|
|
wrapper.eq(ZsjyInternshipInfo::getStudentId, currentUserId)
|
|
|
.eq(ZsjyInternshipInfo::getDeleted, 0)
|
|
.eq(ZsjyInternshipInfo::getDeleted, 0)
|
|
|
.orderByDesc(ZsjyInternshipInfo::getCreateTime)
|
|
.orderByDesc(ZsjyInternshipInfo::getCreateTime)
|
|
|
.last("LIMIT 1"); // 只取最新的一条记录
|
|
.last("LIMIT 1"); // 只取最新的一条记录
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
ZsjyInternshipInfo internshipInfo = zsjyInternshipInfoMapper.selectOne(wrapper);
|
|
ZsjyInternshipInfo internshipInfo = zsjyInternshipInfoMapper.selectOne(wrapper);
|
|
|
log.info("查询到的实习信息:{}", internshipInfo != null ? internshipInfo.getInternshipId() : "无");
|
|
log.info("查询到的实习信息:{}", internshipInfo != null ? internshipInfo.getInternshipId() : "无");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (internshipInfo == null) {
|
|
if (internshipInfo == null) {
|
|
|
log.info("当前学生没有实习信息");
|
|
log.info("当前学生没有实习信息");
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 转换为VO
|
|
// 转换为VO
|
|
|
InternshipInfoVO vo = BeanUtil.toBean(internshipInfo, InternshipInfoVO.class);
|
|
InternshipInfoVO vo = BeanUtil.toBean(internshipInfo, InternshipInfoVO.class);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 查询学生信息并设置到VO中
|
|
// 查询学生信息并设置到VO中
|
|
|
XgStudentMsgVo studentInfo = getStudentInfo(currentUserId);
|
|
XgStudentMsgVo studentInfo = getStudentInfo(currentUserId);
|
|
|
vo.setStudentName(studentInfo.getName());
|
|
vo.setStudentName(studentInfo.getName());
|
|
@@ -504,8 +505,117 @@ public class InternshipInfoServiceImpl implements IInternshipInfoService {
|
|
|
vo.setMajorName(studentInfo.getMajorName());
|
|
vo.setMajorName(studentInfo.getMajorName());
|
|
|
vo.setCollegeName(studentInfo.getCollegeName());
|
|
vo.setCollegeName(studentInfo.getCollegeName());
|
|
|
vo.setGrade(studentInfo.getGrade());
|
|
vo.setGrade(studentInfo.getGrade());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
log.info("成功获取当前学生实习信息,实习ID:{}", vo.getInternshipId());
|
|
log.info("成功获取当前学生实习信息,实习ID:{}", vo.getInternshipId());
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实习信息变更
|
|
|
|
|
+ * <p>业务逻辑:</p>
|
|
|
|
|
+ * <ol>
|
|
|
|
|
+ * <li>将原实习记录的状态设置为"4已变更",标记为失效</li>
|
|
|
|
|
+ * <li>新增一条实习记录,previous_internship_id指向原记录</li>
|
|
|
|
|
+ * <li>保存变更原因到新记录的change_reason字段</li>
|
|
|
|
|
+ * </ol>
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param changeBO 变更参数
|
|
|
|
|
+ * @return 是否成功
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public Boolean changeInternshipInfo(InternshipInfoChangeBO changeBO) {
|
|
|
|
|
+ log.info("=== 实习信息变更开始 ===");
|
|
|
|
|
+ log.info("1. 接收到的变更参数:{}", changeBO);
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 查询原实习记录
|
|
|
|
|
+ ZsjyInternshipInfo oldInternshipInfo = zsjyInternshipInfoMapper.selectById(changeBO.getInternshipId());
|
|
|
|
|
+ if (ObjectUtil.isNull(oldInternshipInfo)) {
|
|
|
|
|
+ log.error("原实习信息不存在,ID:{}", changeBO.getInternshipId());
|
|
|
|
|
+ throw new ServiceException("原实习信息不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("2. 查询到原实习记录:实习ID={}, 学生ID={}, 单位={}",
|
|
|
|
|
+ oldInternshipInfo.getInternshipId(), oldInternshipInfo.getStudentId(),
|
|
|
|
|
+ oldInternshipInfo.getCompanyName());
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 验证学生ID是否匹配
|
|
|
|
|
+ if (!oldInternshipInfo.getStudentId().equals(changeBO.getStudentId())) {
|
|
|
|
|
+ log.error("学生ID不匹配,原记录学生ID:{},变更请求学生ID:{}",
|
|
|
|
|
+ oldInternshipInfo.getStudentId(), changeBO.getStudentId());
|
|
|
|
|
+ throw new ServiceException("学生ID不匹配,无法进行变更操作");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 检查原记录状态是否允许变更(只有"进行中"的实习可以变更)
|
|
|
|
|
+ if (!"1".equals(oldInternshipInfo.getInternshipStatus())) {
|
|
|
|
|
+ log.error("只有进行中的实习信息才能变更,当前状态:{}", oldInternshipInfo.getInternshipStatus());
|
|
|
|
|
+ throw new ServiceException("只有进行中的实习信息才能变更");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 将原实习记录设置为"已变更"状态
|
|
|
|
|
+ ZsjyInternshipInfo updateOldInfo = new ZsjyInternshipInfo();
|
|
|
|
|
+ updateOldInfo.setInternshipId(oldInternshipInfo.getInternshipId());
|
|
|
|
|
+ updateOldInfo.setInternshipStatus("4"); // 4=已变更
|
|
|
|
|
+ int updateResult = zsjyInternshipInfoMapper.updateById(updateOldInfo);
|
|
|
|
|
+ log.info("3. 更新原实习记录状态为'已变更',结果:{}", updateResult > 0 ? "成功" : "失败");
|
|
|
|
|
+
|
|
|
|
|
+ if (updateResult <= 0) {
|
|
|
|
|
+ log.error("更新原实习记录状态失败");
|
|
|
|
|
+ throw new ServiceException("更新原实习记录状态失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 创建新的实习记录
|
|
|
|
|
+ ZsjyInternshipInfo newInternshipInfo = new ZsjyInternshipInfo();
|
|
|
|
|
+
|
|
|
|
|
+ // 复制学生基础信息(从原记录)
|
|
|
|
|
+ newInternshipInfo.setStudentId(oldInternshipInfo.getStudentId());
|
|
|
|
|
+ newInternshipInfo.setStudentNo(oldInternshipInfo.getStudentNo());
|
|
|
|
|
+ newInternshipInfo.setStudentName(oldInternshipInfo.getStudentName());
|
|
|
|
|
+ newInternshipInfo.setGender(oldInternshipInfo.getGender());
|
|
|
|
|
+ newInternshipInfo.setCollegeId(oldInternshipInfo.getCollegeId());
|
|
|
|
|
+ newInternshipInfo.setMajorId(oldInternshipInfo.getMajorId());
|
|
|
|
|
+ newInternshipInfo.setClassId(oldInternshipInfo.getClassId());
|
|
|
|
|
+ newInternshipInfo.setPhone(oldInternshipInfo.getPhone());
|
|
|
|
|
+
|
|
|
|
|
+ // 设置变更关联信息
|
|
|
|
|
+ newInternshipInfo.setPreviousInternshipId(oldInternshipInfo.getInternshipId()); // 关联原记录
|
|
|
|
|
+ newInternshipInfo.setChangeReason(changeBO.getChangeReason()); // 变更原因
|
|
|
|
|
+
|
|
|
|
|
+ // 设置新的实习信息(来自changeBO)
|
|
|
|
|
+ newInternshipInfo.setInternshipStatus(changeBO.getInternshipStatus());
|
|
|
|
|
+ newInternshipInfo.setCompanyName(changeBO.getCompanyName());
|
|
|
|
|
+ newInternshipInfo.setCompanyAddress(changeBO.getCompanyAddress());
|
|
|
|
|
+ newInternshipInfo.setCompanyContact(changeBO.getCompanyContact());
|
|
|
|
|
+ newInternshipInfo.setCompanyPhone(changeBO.getCompanyPhone());
|
|
|
|
|
+ newInternshipInfo.setCompanyIndustry(changeBO.getCompanyIndustry());
|
|
|
|
|
+ newInternshipInfo.setCompanyScale(changeBO.getCompanyScale());
|
|
|
|
|
+ newInternshipInfo.setPositionName(changeBO.getPositionName());
|
|
|
|
|
+ newInternshipInfo.setPositionDuties(changeBO.getPositionDuties());
|
|
|
|
|
+ newInternshipInfo.setInternshipAllowance(changeBO.getInternshipAllowance());
|
|
|
|
|
+ newInternshipInfo.setWorkHours(changeBO.getWorkHours());
|
|
|
|
|
+ newInternshipInfo.setAccommodationAddress(changeBO.getAccommodationAddress());
|
|
|
|
|
+ newInternshipInfo.setAccommodationType(changeBO.getAccommodationType());
|
|
|
|
|
+ newInternshipInfo.setAccommodationCost(changeBO.getAccommodationCost());
|
|
|
|
|
+ newInternshipInfo.setStartDate(changeBO.getStartDate());
|
|
|
|
|
+ newInternshipInfo.setEndDate(changeBO.getEndDate());
|
|
|
|
|
+ newInternshipInfo.setStatus("0"); // 状态:0=正常
|
|
|
|
|
+
|
|
|
|
|
+ log.info("4. 准备插入新实习记录:学生ID={}, 新单位={}, 变更原因={}",
|
|
|
|
|
+ newInternshipInfo.getStudentId(), newInternshipInfo.getCompanyName(),
|
|
|
|
|
+ newInternshipInfo.getChangeReason());
|
|
|
|
|
+
|
|
|
|
|
+ // 6. 插入新记录
|
|
|
|
|
+ int insertResult = zsjyInternshipInfoMapper.insert(newInternshipInfo);
|
|
|
|
|
+ log.info("5. 插入新实习记录,结果:{}", insertResult > 0 ? "成功" : "失败");
|
|
|
|
|
+ log.info("6. 新实习记录ID:{}", newInternshipInfo.getInternshipId());
|
|
|
|
|
+
|
|
|
|
|
+ if (insertResult <= 0) {
|
|
|
|
|
+ log.error("插入新实习记录失败");
|
|
|
|
|
+ throw new ServiceException("插入新实习记录失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ boolean success = insertResult > 0;
|
|
|
|
|
+ log.info("=== 实习信息变更结束,结果:{} ===", success ? "成功" : "失败");
|
|
|
|
|
+
|
|
|
|
|
+ return success;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|