bug修改
This commit is contained in:
parent
949b32b603
commit
3e2913e993
|
|
@ -81,11 +81,5 @@ public interface TbPeopleMapper {
|
|||
*/
|
||||
SysUser getUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 根据身份证号查询人员信息
|
||||
* @param idCards
|
||||
* @return
|
||||
*/
|
||||
List<TbPeople> queryByIdCards(@Param("list") ArrayList<String> idCards);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -380,15 +380,8 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
ExcelUtil<TbPeopleDto> util = new ExcelUtil<>(TbPeopleDto.class);
|
||||
List<TbPeopleDto> tbPeopleList = util.importExcel(file.getInputStream());
|
||||
int result = 0;
|
||||
// 使用一个 Set 来记录已经处理过的 idCard,避免重复处理相同的人员数据
|
||||
Set<String> processedIdCards = new HashSet<>();
|
||||
// 提前收集所有的 idCard,减少数据库查询次数
|
||||
Set<String> allIdCards = new HashSet<>();
|
||||
for (TbPeopleDto tbPeople : tbPeopleList) {
|
||||
allIdCards.add(tbPeople.getIdCard());
|
||||
}
|
||||
// 批量查询数据库中所有的 idCard 对应的人员
|
||||
List<TbPeople> existingPeopleList = tbPeopleDao.queryByIdCards(new ArrayList<>(allIdCards));
|
||||
//查询数据库人员信息
|
||||
List<TbPeople> existingPeopleList = tbPeopleDao.queryByName(new TbPeople());
|
||||
// 创建一个 Map 来缓存已查询的人员信息,以 idCard 为 key
|
||||
Map<String, TbPeople> 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);
|
||||
|
|
|
|||
|
|
@ -157,21 +157,5 @@
|
|||
select user_id as userId, user_name as userName, password as password from sys_user where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="queryByIdCards" resultType="com.bonus.base.basic.domain.TbPeople">
|
||||
select
|
||||
id as id,
|
||||
team_id as teamId,
|
||||
rel_name as relName,
|
||||
rel_phone as relPhone,
|
||||
id_card as idCard,
|
||||
post_code as postCode,
|
||||
sex as sex
|
||||
from tb_people
|
||||
where id_card in
|
||||
<foreach collection="list" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue