From 3e2913e9934f8cf311301d3834197365c7e86299 Mon Sep 17 00:00:00 2001 From: mashuai Date: Thu, 7 Nov 2024 15:42:06 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/base/basic/mapper/TbPeopleMapper.java | 6 ------ .../basic/service/impl/TbPeopleServiceImpl.java | 17 ++--------------- .../mapper/base/basic/TbPeopleMapper.xml | 16 ---------------- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/bonus-modules/base/src/main/java/com/bonus/base/basic/mapper/TbPeopleMapper.java b/bonus-modules/base/src/main/java/com/bonus/base/basic/mapper/TbPeopleMapper.java index 29f7d70..758b706 100644 --- a/bonus-modules/base/src/main/java/com/bonus/base/basic/mapper/TbPeopleMapper.java +++ b/bonus-modules/base/src/main/java/com/bonus/base/basic/mapper/TbPeopleMapper.java @@ -81,11 +81,5 @@ public interface TbPeopleMapper { */ SysUser getUserById(Long userId); - /** - * 根据身份证号查询人员信息 - * @param idCards - * @return - */ - List queryByIdCards(@Param("list") ArrayList idCards); } diff --git a/bonus-modules/base/src/main/java/com/bonus/base/basic/service/impl/TbPeopleServiceImpl.java b/bonus-modules/base/src/main/java/com/bonus/base/basic/service/impl/TbPeopleServiceImpl.java index 6f2eed1..b00d407 100644 --- a/bonus-modules/base/src/main/java/com/bonus/base/basic/service/impl/TbPeopleServiceImpl.java +++ b/bonus-modules/base/src/main/java/com/bonus/base/basic/service/impl/TbPeopleServiceImpl.java @@ -380,15 +380,8 @@ public class TbPeopleServiceImpl implements TbPeopleService { ExcelUtil util = new ExcelUtil<>(TbPeopleDto.class); List tbPeopleList = util.importExcel(file.getInputStream()); int result = 0; - // 使用一个 Set 来记录已经处理过的 idCard,避免重复处理相同的人员数据 - Set processedIdCards = new HashSet<>(); - // 提前收集所有的 idCard,减少数据库查询次数 - Set allIdCards = new HashSet<>(); - for (TbPeopleDto tbPeople : tbPeopleList) { - allIdCards.add(tbPeople.getIdCard()); - } - // 批量查询数据库中所有的 idCard 对应的人员 - List existingPeopleList = tbPeopleDao.queryByIdCards(new ArrayList<>(allIdCards)); + //查询数据库人员信息 + List existingPeopleList = tbPeopleDao.queryByName(new TbPeople()); // 创建一个 Map 来缓存已查询的人员信息,以 idCard 为 key Map existingPeopleMap = new HashMap<>(); for (TbPeople people : existingPeopleList) { @@ -396,10 +389,6 @@ public class TbPeopleServiceImpl implements TbPeopleService { } // 遍历 tbPeopleList 进行处理 for (TbPeopleDto tbPeople : tbPeopleList) { - // 如果该 idCard 已处理,则跳过 - if (processedIdCards.contains(tbPeople.getIdCard())) { - continue; - } // 查找是否已有此人员数据 TbPeople existingPeople = existingPeopleMap.get(tbPeople.getIdCard()); if (existingPeople != null) { @@ -425,8 +414,6 @@ public class TbPeopleServiceImpl implements TbPeopleService { dto.setPostCode(tbPeople.getPostCode()); result += tbPeopleDao.insert(dto); } - // 标记该 idCard 已处理 - processedIdCards.add(tbPeople.getIdCard()); } if (result > 0) { return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); diff --git a/bonus-modules/base/src/main/resources/mapper/base/basic/TbPeopleMapper.xml b/bonus-modules/base/src/main/resources/mapper/base/basic/TbPeopleMapper.xml index 24dcc1d..882dc42 100644 --- a/bonus-modules/base/src/main/resources/mapper/base/basic/TbPeopleMapper.xml +++ b/bonus-modules/base/src/main/resources/mapper/base/basic/TbPeopleMapper.xml @@ -157,21 +157,5 @@ select user_id as userId, user_name as userName, password as password from sys_user where user_id = #{userId} - -