|
@@ -189,8 +189,48 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ //根据项目id和list导入数据库
|
|
|
+ @Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
|
|
+ public AidingStudentsImportExcelRespVO aidingStudentsImportExcelListFromCloud( Long asAidingStudentsManageId,List<AidingStudentsImportExcelListDO> list) {
|
|
|
+ // 校验是否为空
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ throw exception(AIDING_STUDENTS_IMPORT_LIST_IS_NULL);
|
|
|
+ }
|
|
|
+ // 创建响应对象
|
|
|
+ AidingStudentsImportExcelRespVO respVO = AidingStudentsImportExcelRespVO.builder().createStudentNames(new ArrayList<>())
|
|
|
+ .failureStudentNames(new LinkedHashMap<>()).build();
|
|
|
+ // 转换对象
|
|
|
+ List<AidingStudentsImportExcelListDO> aidingStudentsImportEecleListDOS = BeanUtils.toBean(list, AidingStudentsImportExcelListDO.class);
|
|
|
+ aidingStudentsImportEecleListDOS.forEach(aidingStudentsImportEecleListDO -> {
|
|
|
+
|
|
|
+ // 校验,判断是否有不符合的原因
|
|
|
+
|
|
|
+ String result = validateImportListForCreateOrUpdate(aidingStudentsImportEecleListDO.getStudentName(), aidingStudentsImportEecleListDO.getStudentIdNumber(),
|
|
|
+ aidingStudentsImportEecleListDO.getStudentCode(), aidingStudentsImportEecleListDO.getStudentAge(), aidingStudentsImportEecleListDO.getStudentSex());
|
|
|
+ if (result != null){
|
|
|
+ respVO.getFailureStudentNames().put(aidingStudentsImportEecleListDO.getStudentName(), result);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //赋值给外键
|
|
|
+ aidingStudentsImportEecleListDO.setAsAidingStudentsManageId(asAidingStudentsManageId);
|
|
|
+ aidingStudentsImportEecleListDO.setCollegeId(getCollegeIdByStudentCode(aidingStudentsImportEecleListDO.getStudentCode()));
|
|
|
+
|
|
|
+ //判断此次项目数据库是否已经存在
|
|
|
+ if (checkStudentCodeExists(aidingStudentsImportEecleListDO.getStudentCode(),asAidingStudentsManageId)) {
|
|
|
+ respVO.getFailureStudentNames().put(aidingStudentsImportEecleListDO.getStudentName(), "该学生已导入过一次");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //插入数据库
|
|
|
+ aidingStudentsImportListMapper.insert(aidingStudentsImportEecleListDO);
|
|
|
+ respVO.getCreateStudentNames().add(aidingStudentsImportEecleListDO.getStudentName());
|
|
|
+ });
|
|
|
+ return respVO;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//导入到redis中
|
|
|
- @Override
|
|
|
+/* @Override
|
|
|
public String aidingStudentsImportExcelToRedis(List<AidingStudentsImportExcelVO> list) {
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
throw exception(AIDING_STUDENTS_IMPORT_LIST_IS_NULL);
|
|
@@ -205,6 +245,27 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
|
|
|
log.error("导入redis失败", e);
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
+ }
|
|
|
+ return redisUUID;
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String aidingStudentsImportExcelToRedis(List<AidingStudentsImportExcelVO> list) {
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ throw exception(AIDING_STUDENTS_IMPORT_LIST_IS_NULL);
|
|
|
+ }
|
|
|
+ String redisUUID = String.valueOf(UUID.randomUUID());
|
|
|
+ try {
|
|
|
+ List<AidingStudentsImportExcelListDO> aidingStudentsImportEecleListDOS = BeanUtils.toBean(list, AidingStudentsImportExcelListDO.class);
|
|
|
+ aidingStudentsImportEecleListDOS.forEach(aidingStudentsImportEecleListDO -> {
|
|
|
+ aidingStudentsImportListRedisDAO.setWithredisUUID(aidingStudentsImportEecleListDO);
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("导入redis失败", e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+
|
|
|
}
|
|
|
return redisUUID;
|
|
|
}
|