|
@@ -11,6 +11,10 @@ import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentsimportlist.Aiding
|
|
|
import cn.iocoder.yudao.module.as.dal.mysql.aidingstudentsimportlist.AidingStudentsImportListMapper;
|
|
|
import cn.iocoder.yudao.module.as.dal.redis.aidingstudentsimportlist.AidingStudentsImportListRedisDAO;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
|
|
|
+import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -36,13 +40,21 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
|
|
|
private AidingStudentsImportListMapper aidingStudentsImportListMapper;
|
|
|
@Resource
|
|
|
private AidingStudentsImportListRedisDAO aidingStudentsImportListRedisDAO;
|
|
|
+ @Resource
|
|
|
+ private AdminUserMapper userMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeptMapper deptMapper;
|
|
|
|
|
|
@Override
|
|
|
public Long createAidingStudentsImportList(AidingStudentsImportListSaveReqVO createReqVO, Long aidingStudentsManageId) {
|
|
|
- // 插入
|
|
|
+ // 转换为DO
|
|
|
AidingStudentsImportExcelListDO aidingStudentsImportListDO = BeanUtils.toBean(createReqVO, AidingStudentsImportExcelListDO.class);
|
|
|
+ //set项目id和学院id
|
|
|
aidingStudentsImportListDO.setAsAidingStudentsManageId(aidingStudentsManageId);
|
|
|
- if (checkStudentCodeExists(aidingStudentsImportListDO.getStudentIdNumber(),aidingStudentsManageId)) {
|
|
|
+ aidingStudentsImportListDO.setCollegeId(getCollegeIdByStudentCode(aidingStudentsImportListDO.getStudentCode()));
|
|
|
+
|
|
|
+ if (checkStudentCodeExists(aidingStudentsImportListDO.getStudentCode(),aidingStudentsManageId)) {
|
|
|
throw exception(AIDING_STUDENTS_IMPORT_LIST_STUDENT_EXISTS);
|
|
|
}
|
|
|
aidingStudentsImportListMapper.insert(aidingStudentsImportListDO);
|
|
@@ -95,8 +107,8 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public PageResult<AidingStudentsImportExcelListDO> getAidingStudentsImportListPage(AidingStudentsImportListPageResqVO pageReqVO,Long asAidingStudentsManageId) {
|
|
|
- return aidingStudentsImportListMapper.selectPage(pageReqVO,asAidingStudentsManageId);
|
|
|
+ public PageResult<AidingStudentsImportExcelListDO> getAidingStudentsImportListPage(AidingStudentsImportListPageResqVO pageReqVO) {
|
|
|
+ return aidingStudentsImportListMapper.selectPage(pageReqVO);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -162,6 +174,8 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
|
|
|
}
|
|
|
//赋值给外键
|
|
|
aidingStudentsImportEecleListDO.setAsAidingStudentsManageId(asAidingStudentsManageId);
|
|
|
+ aidingStudentsImportEecleListDO.setCollegeId(getCollegeIdByStudentCode(aidingStudentsImportEecleListDO.getStudentCode()));
|
|
|
+
|
|
|
if (checkStudentCodeExists(aidingStudentsImportEecleListDO.getStudentCode(),asAidingStudentsManageId)) {
|
|
|
respVO.getFailureStudentNames().put(aidingStudentsImportEecleListDO.getStudentName(), "该学生已导入过一次");
|
|
|
return;
|
|
@@ -218,6 +232,8 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
|
|
|
}
|
|
|
// 赋值给外键
|
|
|
aidingStudentsImportEecleListDO.setAsAidingStudentsManageId(aidingStudentsManageId);
|
|
|
+ aidingStudentsImportEecleListDO.setCollegeId(getCollegeIdByStudentCode(aidingStudentsImportEecleListDO.getStudentCode()));
|
|
|
+
|
|
|
//数据库不存在,直接插入
|
|
|
if(!checkStudentCodeExists(aidingStudentsImportEecleListDO.getStudentCode(),aidingStudentsManageId)){
|
|
|
aidingStudentsImportListMapper.insert(aidingStudentsImportEecleListDO);
|
|
@@ -244,4 +260,23 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ //根据学号查学院id
|
|
|
+ public Long getCollegeIdByStudentCode(String studentCode){
|
|
|
+ AdminUserDO adminUserDO = userMapper.selectByUsername(studentCode);
|
|
|
+ if (adminUserDO == null){
|
|
|
+ throw exception(AIDING_STUDENTS_IMPORT_LIST_STUDENT_CODE_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ //循环查询父级部门
|
|
|
+ DeptDO deptDO = new DeptDO();
|
|
|
+ Long parentId = deptMapper.selectById(adminUserDO.getDeptId()).getParentId();
|
|
|
+ while (parentId != 0) {
|
|
|
+ deptDO = deptMapper.selectById(parentId);
|
|
|
+ parentId= deptDO.getParentId();
|
|
|
+ }
|
|
|
+ return deptDO.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|