List<PjtAttrDomainEntity> pjtAttrDomainEntityList=.... 如何对获取pjtAttrDomainEntityList中的所有usrId并去重
时间: 2024-10-15 17:21:46 浏览: 49
要获取`pjtAttrDomainEntityList`中的所有`usrId`并去重,可以使用Java 8的Stream API。首先,将列表转换为Stream,然后使用`map`方法提取每个实体的`usrId`,接着使用`distinct`方法去重,最后使用`collect`方法将结果收集到一个新的列表中。以下是示例代码:
```java
import java.util.List;
import java.util.stream.Collectors;
// 假设PjtAttrDomainEntity类有一个getUsrId方法
public class PjtAttrDomainEntity {
private String usrId;
public String getUsrId() {
return usrId;
}
// 其他属性和方法...
}
// 获取所有不重复的usrId
List<String> distinctUsrIds = pjtAttrDomainEntityList.stream()
.map(PjtAttrDomainEntity::getUsrId)
.distinct()
.collect(Collectors.toList());
```
这段代码首先将`pjtAttrDomainEntityList`转换为一个Stream,然后使用`map`方法将每个`PjtAttrDomainEntity`对象映射为其对应的`usrId`。接下来,`distinct`方法用于去除重复的`usrId`。最后,`collect`方法将去重后的`usrId`收集到一个新的`List<String>`中。
阅读全文
相关推荐






<?php
$footerColor = "#2196F3";
// 启动会话,这步必不可少
session_start();
// 判断是否登陆
if ($_SESSION['usrtag'] === 'admin') {
//echo "您已经成功登陆";
} else {
die("您无权访问");
}
$conn = mysqli_connect("localhost:3306","visitor","helloitsme");
if (!$conn)
{
echo '请检查网络!';
die('Could not connect: ' . mysql_error());
}
mysqli_select_db($conn,'rentcar');
$sql = "select * from bookrecord where result='booking'";
$res = mysqli_query($conn,$sql);
$records=array();
while( $row = mysqli_fetch_array($res)){
$records[]=$row;
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>后台管理</title>
<style type="text/css">
*{margin:0;padding:0;}
body{background-color:white;
width:100%;}
.clear{clear:both;}
#container{
background-color:#BBBBFF;
height:510px;
width:1500px;
margin:auto;}
#picture{height:470px; margin:0px;}
#label{background-color:white; height:30px;}
#container2{
background-color:white;
width:800px;
height:340px;
margin:20px auto;
}
#content{
background-color:white;
width:1000px;
height:100px;
margin:20px auto;
}
a {
color: #F3ADAE;
}
a:link {
color: #0B0B0B;
text-decoration: none;
}
a:visited {
color: #0B0B0B;
text-decoration: none;
}
a:hover {
color: #17E515;
text-decoration: none;
}
a:active {
text-decoration: none;
}
#division{
background-color:white;
width:800px;
height:70px;
margin:20px auto;
}
</style>
</head>
<body>
订单情况
待处理订单
商品数据更新
已注册用户资料
待确认订单信息表
订单编号 账户名 客户邮箱 租借地点 租借时间 归还时间 处理进度 操作
<?php foreach($records as $row) : ?>
<?php echo $row['idbookrecord'];?>
<?php echo $row['usrid'];?>
<?php echo $row['personalid'];?>
<?php echo $row['getcarplace'];?>
<?php echo $row['starttime'];?>
<?php echo $row['endtime'];?>
<?php echo $row['result'];?>
<form action = "confirmrecord.php" method = "post">
<input type="hidden" name="thevalue1" value="<?php echo $row['idbookrecord'];?>">
<input type="submit" name="submit" value="确认" />
</form>
<form action = "rejectrecord.php" method = "post">
<input type="hidden" name="thevalue2" value="<?php echo $row['idbookrecord'];?>">
<input type="submit" name="submit" value="拒绝" />
</form>
<?php endForeach;?>
<form action="logOut.php" method="post" onsubmit="return enter()">
<label><input class="submit" type="submit" name="logout" value="登出账户" /></label>
</form>
充充宝公司版权所有©2024-2025
<script>
// function func1(self){
// //alert(self.innerHTML);
// location.reload();
// }
//a onclick="func1(this)">删除/a
//$('#delete_button').click(function(){
// var comment_id = $(this).attr('id');//you should use the id of the comment as id for the delete button for this to work.
// $.post('delete.php', {'comment_id' : comment_id}, function(){
// $(this).parent('div').remove(); //hide the comment from the user
// });
// });
</script>
</body>
</html>
帮我检查这个代码,底边紫色无法扩充到网页边界





