Explorar o código

学生数据添加增加唯一性验证

dzx hai 7 meses
pai
achega
81afc6115e

+ 6 - 3
src/main/java/com/xjrsoft/module/student/controller/StudentManagerController.java

@@ -284,10 +284,13 @@ public class StudentManagerController {
     @PostMapping("/import")
     @ApiOperation(value = "导入学生信息")
     @XjrLog(value = "导入学生信息", saveRequestData = false, saveResponseData = true)
-    public RT<Boolean> importData(@RequestParam("file") MultipartFile file) throws IOException, ParseException {
+    public RT<List<BaseStudentSompleInfoVo>> importData(@RequestParam("file") MultipartFile file) throws IOException, ParseException {
         List<Map<Integer, Object>> excelDataList = EasyExcel.read(file.getInputStream()).sheet().headRowNumber(3).doReadSync();
-
-        return RT.ok(studentManagerService.importStudentData(excelDataList));
+        List<BaseStudentSompleInfoVo> result = studentManagerService.importStudentData(excelDataList);
+        if(!result.isEmpty()){
+            return RT.ok(result);
+        }
+        return RT.ok(null);
     }
 
 

+ 4 - 0
src/main/java/com/xjrsoft/module/student/dto/BaseStudentSimpleInfoDto.java

@@ -3,6 +3,8 @@ package com.xjrsoft.module.student.dto;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * @author dzx
  * @date 2024/7/9
@@ -23,4 +25,6 @@ public class BaseStudentSimpleInfoDto {
 
     @ApiModelProperty("学籍状态")
     private String archivesStatus;
+
+    private List<String> idNumberList;
 }

+ 2 - 1
src/main/java/com/xjrsoft/module/student/service/IStudentManagerService.java

@@ -9,6 +9,7 @@ import com.xjrsoft.module.student.dto.UpdateBaseStudentUserDto;
 import com.xjrsoft.module.student.entity.BaseStudentUser;
 import com.xjrsoft.module.student.vo.BaseDepMajorGradeClassStudenTreeVo;
 import com.xjrsoft.module.student.vo.BaseStudentClassVo;
+import com.xjrsoft.module.student.vo.BaseStudentSompleInfoVo;
 import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
 import com.xjrsoft.module.student.vo.PersonalPortraitPersonalInfoVo;
 import org.springframework.web.multipart.MultipartFile;
@@ -60,7 +61,7 @@ public interface IStudentManagerService extends MPJBaseService<BaseStudentUser>
      */
     PersonalPortraitPersonalInfoVo getPersonalInfo(Long userId);
 
-    Boolean importStudentData(List<Map<Integer, Object>> excelDataList) throws ParseException;
+    List<BaseStudentSompleInfoVo> importStudentData(List<Map<Integer, Object>> excelDataList) throws ParseException;
 
 
     Page<BaseStudentUserPageVo> getStudentPage(Page<BaseStudentUserPageVo> page, BaseStudentUserPageDto dto);

+ 13 - 2
src/main/java/com/xjrsoft/module/student/service/impl/StudentManagerServiceImpl.java

@@ -32,11 +32,13 @@ import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserDeptRelation;
 import com.xjrsoft.module.organization.entity.UserRoleRelation;
 import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
+import com.xjrsoft.module.organization.mapper.UserMapper;
 import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
 import com.xjrsoft.module.organization.service.IDepartmentService;
 import com.xjrsoft.module.organization.service.IUserDeptRelationService;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
+import com.xjrsoft.module.student.dto.BaseStudentSimpleInfoDto;
 import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
 import com.xjrsoft.module.student.dto.MajorGradeClassDto;
 import com.xjrsoft.module.student.dto.UpdateBaseStudentUserDto;
@@ -109,6 +111,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
     private final IBaseGradeService baseGradeService;
     private final IStudentChangeRecordService recordService;
     private IDictionarydetailService dictionarydetailService;
+    private final UserMapper userMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -481,11 +484,19 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
     }
 
     @Override
-    public Boolean importStudentData(List<Map<Integer, Object>> excelDataList) throws ParseException {
+    public List<BaseStudentSompleInfoVo> importStudentData(List<Map<Integer, Object>> excelDataList) throws ParseException {
         List<String> idNumbers = new ArrayList<>();
         for (Map<Integer, Object> integerObjectMap : excelDataList) {
             idNumbers.add(integerObjectMap.get(0).toString());
         }
+
+        List<BaseStudentSompleInfoVo> infos = userMapper.getInfosByParam(new BaseStudentSimpleInfoDto() {{
+            setIdNumberList(idNumbers);
+        }});
+        if(!infos.isEmpty()){
+           return infos;
+        }
+
         //查询所有学生的用户信息,组装起来备用
         List<BaseStudentUser> studentUsers = this.selectJoinList(BaseStudentUser.class,
                 new MPJLambdaWrapper<BaseStudentUser>()
@@ -998,7 +1009,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         if (!insertContactList.isEmpty()) {
             studentContactService.saveBatch(insertContactList);
         }
-        return true;
+        return new ArrayList<>();
     }
 
     @Override

+ 7 - 0
src/main/resources/mapper/organization/UserMapper.xml

@@ -54,6 +54,13 @@
         <if test="dto.archivesStatus != null and dto.archivesStatus != ''">
             AND t3.archives_status = #{dto.archivesStatus}
         </if>
+        <if test="dto.idNumberList != null">
+            and t1.credential_number in
+            <foreach item="idNumber" index="index" collection="dto.idNumberList" open="(" close=")"
+                     separator=",">
+                #{idNumber}
+            </foreach>
+        </if>
     </select>
     <select id="personPage" parameterType="com.xjrsoft.module.organization.dto.PersonPageDto" resultType="com.xjrsoft.module.organization.vo.PersonPageVo">
         SELECT t1.id,t1.name,t1.user_name,t1.mobile,t3.name AS gender_cn,t2.employ_type,t2.employ_way FROM xjr_user t1