|
|
|
@ -22,7 +22,8 @@ import com.ibeetl.admin.core.util.TimeTool;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.jlw.dao.UniversitiesCollegesDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.*;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherBatchImportDTO;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherBatchImportAdminDTO;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherBatchImportUniAdminDTO;
|
|
|
|
|
import com.ibeetl.jlw.service.*;
|
|
|
|
|
import com.ibeetl.jlw.web.query.*;
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
@ -58,8 +59,8 @@ import static cn.jlw.util.CacheUserUtil.getStudent;
|
|
|
|
|
import static com.ibeetl.admin.console.service.OrgConsoleService.setObjectOrgId;
|
|
|
|
|
import static com.ibeetl.admin.core.util.ExcelUtil.convertData;
|
|
|
|
|
import static com.ibeetl.admin.core.util.ExcelUtil.write;
|
|
|
|
|
import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser;
|
|
|
|
|
import static com.ibeetl.admin.core.web.JsonReturnCode.DIY_ERROR;
|
|
|
|
|
import static java.util.function.UnaryOperator.identity;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Teacher 接口
|
|
|
|
@ -109,6 +110,8 @@ public class TeacherController extends BaseController {
|
|
|
|
|
@Autowired private StudentDefenceLogService studentDefenceLogService;
|
|
|
|
|
@Autowired private StudentDefenceLogInfoService studentDefenceLogInfoService;
|
|
|
|
|
@Autowired private UniversitiesCollegesDao universitiesCollegesDao;
|
|
|
|
|
@Autowired private UniversityFacultyService universityFacultyService;
|
|
|
|
|
@Autowired private UniversitySystemService universitySystemService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
FileService fileService;
|
|
|
|
@ -1526,16 +1529,20 @@ public class TeacherController extends BaseController {
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
@GetMapping({ API + "/exportBatchTemplate.do", MODEL + "/downloadTemplate.json" })
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public void exportBatchTemplate() {
|
|
|
|
|
|
|
|
|
|
Assert.notNull(getUser(), "请登录后再操作");
|
|
|
|
|
public void exportBatchTemplate(@SCoreUser CoreUser coreUser) {
|
|
|
|
|
|
|
|
|
|
String filename = StrUtil.format("批量教师导入模板{}.xlsx", System.currentTimeMillis());
|
|
|
|
|
|
|
|
|
|
setExcelResponse(filename);
|
|
|
|
|
// 输出 Excel
|
|
|
|
|
com.ibeetl.admin.core.util.excelGroupValidation.ExcelUtil.createExcel(Arrays.asList(new TeacherBatchImportDTO()), response.getOutputStream());
|
|
|
|
|
|
|
|
|
|
if (coreUser.isAdmin()) {
|
|
|
|
|
// 输出 Excel
|
|
|
|
|
com.ibeetl.admin.core.util.excelGroupValidation.ExcelUtil.createExcel(Arrays.asList(new TeacherBatchImportAdminDTO()), response.getOutputStream());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 输出 Excel
|
|
|
|
|
com.ibeetl.admin.core.util.excelGroupValidation.ExcelUtil.createExcel(Arrays.asList(new TeacherBatchImportUniAdminDTO()), response.getOutputStream());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1553,15 +1560,60 @@ public class TeacherController extends BaseController {
|
|
|
|
|
try {
|
|
|
|
|
Assert.isNull(getStudent(), "学生无法访问该接口");
|
|
|
|
|
|
|
|
|
|
List<Teacher> list = null;
|
|
|
|
|
// 输出 Excel
|
|
|
|
|
MyValidateExcelCellDataListener<TeacherBatchImportDTO> listener = new MyValidateExcelCellDataListener<>();
|
|
|
|
|
MyValidateExcelCellDataListener listener = new MyValidateExcelCellDataListener<>();
|
|
|
|
|
|
|
|
|
|
ExcelUtil.readExcelNotContainHeader(file, TeacherBatchImportDTO.class, listener);
|
|
|
|
|
// 判断错误的结果集
|
|
|
|
|
Assert.isTrue(CollectionUtil.isEmpty(listener.getFailMessage()), JSONUtil.toJsonStr(listener.getFailMessage()));
|
|
|
|
|
// 类型转换
|
|
|
|
|
List<Teacher> list = listener.getData().stream().map(TeacherBatchImportDTO::pojo)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
if (coreUser.isAdmin()) {
|
|
|
|
|
|
|
|
|
|
ExcelUtil.readExcelNotContainHeader(file, TeacherBatchImportAdminDTO.class, listener);
|
|
|
|
|
// 判断错误的结果集
|
|
|
|
|
Assert.isTrue(CollectionUtil.isEmpty(listener.getFailMessage()), JSONUtil.toJsonStr(listener.getFailMessage()));
|
|
|
|
|
|
|
|
|
|
// 类型转换
|
|
|
|
|
list = (List<Teacher>) listener.getData().stream().map(item -> {
|
|
|
|
|
|
|
|
|
|
TeacherBatchImportAdminDTO item1 = (TeacherBatchImportAdminDTO) item;
|
|
|
|
|
|
|
|
|
|
// 查询这个院校已经存在的院校
|
|
|
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesService.getByNameOrCreate(item1.getUniversitiesCollegesName());
|
|
|
|
|
|
|
|
|
|
// 查询这个院校已经存在的院系
|
|
|
|
|
UniversityFaculty universityFaculty = universityFacultyService.getByNameOrCreate(
|
|
|
|
|
item1.getUniversityFacultyName(), universitiesColleges.getOrgId(), universitiesColleges.getUserId());
|
|
|
|
|
|
|
|
|
|
// 查询这个院校已经存在的专业
|
|
|
|
|
UniversitySystem universitySystem = universitySystemService.getByNameOrCreate(
|
|
|
|
|
item1.getUniversitySystemName(), universitiesColleges.getOrgId(), universitiesColleges.getUserId(), universityFaculty.getUniversityFacultyId());
|
|
|
|
|
|
|
|
|
|
return TeacherBatchImportAdminDTO.pojo(item1, universitiesColleges.getUniversitiesCollegesId(), universityFaculty.getUniversityFacultyId(), universitySystem.getUniversitySystemId(), identity());
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
// 除了超管其他身份
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
ExcelUtil.readExcelNotContainHeader(file, TeacherBatchImportUniAdminDTO.class, listener);
|
|
|
|
|
// 判断错误的结果集
|
|
|
|
|
Assert.isTrue(CollectionUtil.isEmpty(listener.getFailMessage()), JSONUtil.toJsonStr(listener.getFailMessage()));
|
|
|
|
|
// 类型转换
|
|
|
|
|
list = (List<Teacher>) listener.getData().stream().map(item -> {
|
|
|
|
|
|
|
|
|
|
TeacherBatchImportUniAdminDTO item1 = (TeacherBatchImportUniAdminDTO) item;
|
|
|
|
|
|
|
|
|
|
// 查询这个院校已经存在的院系
|
|
|
|
|
Long orgId = coreUser.getOrgId();
|
|
|
|
|
Long userId = coreUser.getId();
|
|
|
|
|
|
|
|
|
|
UniversityFaculty universityFaculty = universityFacultyService.getByNameOrCreate(item1.getUniversityFacultyName(), orgId, userId);
|
|
|
|
|
|
|
|
|
|
// 查询这个院校已经存在的专业
|
|
|
|
|
UniversitySystem universitySystem = universitySystemService.getByNameOrCreate(item1.getUniversitySystemName(), orgId, userId, universityFaculty.getUniversityFacultyId());
|
|
|
|
|
|
|
|
|
|
return TeacherBatchImportUniAdminDTO.pojo(item1, universityFaculty.getUniversitiesCollegesId(), universityFaculty.getUniversityFacultyId(), universitySystem.getUniversitySystemId(), identity());
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置机构ID
|
|
|
|
|
setObjectOrgId(list, (e) -> {
|
|
|
|
@ -1580,8 +1632,7 @@ public class TeacherController extends BaseController {
|
|
|
|
|
listener.putFailMessage(StrUtil.format("异常的院校ID:{},该院校已删除状态", e.getUniversitiesCollegesId()));
|
|
|
|
|
}
|
|
|
|
|
return sc.getOrgId();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
listener.putFailMessage(StrUtil.format("异常的院校ID:{},未查询到院校信息,请联系管理员", e.getUniversitiesCollegesId()));
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|