Browse Source

Merge branch 'import_250116' of http://git.dayaedu.com/yonge/cooleshow into test

zouxuan 2 months ago
parent
commit
9ca235d0ae

+ 10 - 9
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/execl/analysis/StudentImportAnalysis.java

@@ -136,21 +136,22 @@ public class StudentImportAnalysis extends DataAnalysis<StudentImportAnalysis> {
             if (StringUtils.isEmpty(item.getSubjectName())) {
                 ret.append("声部不能为空;");
             }else {
-                String[] split = item.getSubjectName().replaceAll(" ", "").replaceAll(",", ",").split(",");
-                for (String s : split) {
-                    if (!subjectMap.containsKey(s)) {
-                        ret.append("声部无效:").append(s);
-                    }
-                    item.setSubjectId(subjectMap.get(s));
+                if (!subjectMap.containsKey(item.getSubjectName())) {
+                    ret.append("声部无效:").append(item.getSubjectName());
                 }
+                item.setSubjectId(subjectMap.get(item.getSubjectName()));
             }
             if (StringUtils.isEmpty(item.getTenantName())) {
                 ret.append("机构名称不能为空;");
             }else {
-                if (!tenantMap.containsKey(item.getTenantName())) {
-                    ret.append("机构无效:").append(item.getTenantName());
+                if("平台".equals(item.getTenantName())){
+                    item.setTenantId(-1L);
+                }else {
+                    if (!tenantMap.containsKey(item.getTenantName())) {
+                        ret.append("机构无效:").append(item.getTenantName());
+                    }
+                    item.setTenantId(tenantMap.get(item.getTenantName()));
                 }
-                item.setTenantId(tenantMap.get(item.getTenantName()));
             }
             if (StringUtils.isEmpty(item.getTenantGroupName())) {
                 ret.append("小组名称不能为空;");

+ 22 - 15
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/execl/analysis/TeacherImportAnalysis.java

@@ -41,7 +41,7 @@ public class TeacherImportAnalysis extends DataAnalysis<TeacherImportAnalysis> {
     private final List<String> phones = Lists.newArrayList();
     private final List<String> idCardNos = Lists.newArrayList();
     private final List<String> existPhones = Lists.newArrayList();
-    private final List<String> existIdCardNos = Lists.newArrayList();
+//    private final List<String> existIdCardNos = Lists.newArrayList();
     public TeacherImportAnalysis(AnalysisContext context) {
         super(context);
     }
@@ -133,20 +133,23 @@ public class TeacherImportAnalysis extends DataAnalysis<TeacherImportAnalysis> {
                     ret.append("身份证格式不正确;");
                 }else {
                     //校验是否重复
-                    if(idCardNos.contains(item.getIdCardNo())){
+                    /*if(idCardNos.contains(item.getIdCardNo())){
                         ret.append("身份证号重复;");
                     }else {
                         if(existIdCardNos.contains(item.getIdCardNo())){
                             ret.append("身份证号已存在;");
                         }
-                        idCardNos.add(item.getIdCardNo());
-                    }
+                    }*/
+                    idCardNos.add(item.getIdCardNo());
                 }
             }
             if (StringUtils.isEmpty(item.getSubjectName())) {
                 ret.append("老师声部不能为空;");
             }else {
                 String[] split = item.getSubjectName().replaceAll(" ", "").replaceAll(",", ",").split(",");
+                if (split.length > 5) {
+                    ret.append("声部最多选择5个;");
+                }
                 String subjectIds = "";
                 for (String s : split) {
                     if (!subjectMap.containsKey(s)) {
@@ -162,10 +165,14 @@ public class TeacherImportAnalysis extends DataAnalysis<TeacherImportAnalysis> {
             if (StringUtils.isEmpty(item.getTenantName())) {
                 ret.append("机构名称不能为空;");
             }else {
-                if (!tenantMap.containsKey(item.getTenantName())) {
-                    ret.append("机构无效:").append(item.getTenantName());
+                if("平台".equals(item.getTenantName())){
+                    item.setTenantId(-1L);
+                }else {
+                    if (!tenantMap.containsKey(item.getTenantName())) {
+                        ret.append("机构无效:").append(item.getTenantName());
+                    }
+                    item.setTenantId(tenantMap.get(item.getTenantName()));
                 }
-                item.setTenantId(tenantMap.get(item.getTenantName()));
             }
             if (item.getIsTestUser() == null) {
                 ret.append("是否测试用户不能为空;");
@@ -210,14 +217,14 @@ public class TeacherImportAnalysis extends DataAnalysis<TeacherImportAnalysis> {
         if (CollectionUtils.isNotEmpty(phones)) {
             existPhones.addAll(easyExcelService.getPhones(phones, "TEACHER"));
         }
-        List<String> idCardNos = getTeacherImportWrappers().stream()
-                .map(TeacherImportWrapper.TeacherImport::getIdCardNo)
-                .filter(StringUtils::isNotBlank)
-                .distinct()
-                .collect(Collectors.toList());
-        if (CollectionUtils.isNotEmpty(idCardNos)) {
-            existIdCardNos.addAll(easyExcelService.getIdCardNos(idCardNos, "TEACHER"));
-        }
+//        List<String> idCardNos = getTeacherImportWrappers().stream()
+//                .map(TeacherImportWrapper.TeacherImport::getIdCardNo)
+//                .filter(StringUtils::isNotBlank)
+//                .distinct()
+//                .collect(Collectors.toList());
+//        if (CollectionUtils.isNotEmpty(idCardNos)) {
+//            existIdCardNos.addAll(easyExcelService.getIdCardNos(idCardNos, "TEACHER"));
+//        }
         subjectMap.putAll(easyExcelService.getSubjectMap());
         tenantMap.putAll(easyExcelService.getTenantMap());
     }

+ 6 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ExcelAnalyseCoreServiceImpl.java

@@ -179,7 +179,9 @@ public class ExcelAnalyseCoreServiceImpl implements ExcelAnalyseCoreService {
         AnalysisContext context = analysis.getContext();
         // 生成导入数据记录
         createFileImportRecord(wrapper, context);
-
+        if(context.getTotal() == 0){
+            throw new BizException("导入数据为空");
+        }
         // 入库业务数据
         if (context.getFailure() > 0) {
             log.info("readExaminationExcelData collect.size={}", analysis.getTeacherImportWrappers().size());
@@ -197,6 +199,9 @@ public class ExcelAnalyseCoreServiceImpl implements ExcelAnalyseCoreService {
         // 生成导入数据记录
         createFileImportRecord(wrapper, context);
 
+        if(context.getTotal() == 0){
+            throw new BizException("导入数据为空");
+        }
         // 入库业务数据
         if (context.getFailure() > 0) {
             log.info("readStudentExcelData collect.size={}", analysis.getStudentImportWrappers().size());