对象
TbHuidou
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer hid;
/**
* 活动名称
*/
private String acyivity_name;
/**
* 大智慧账号
*/
private String dzh_no;
/**
* 财富号
*/
private String cf_no;
/**
* 理财号
*/
private String lc_no;
/**
* 产品代码
*/
private String product_code;
/**
* 产品类型
*/
private String product_type;
/**
* 功能页面id与前端定义
*/
private String function_id;
/**
* 是否已经发送 0、未发送 1、已发送
*/
private Integer sent;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
//@com.fasterxml.jackson.annotation.JsonIgnore
private Date create_time;
/**
* 修改时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
// @com.fasterxml.jackson.annotation.JsonIgnore
private Date update_time;
/**
* 是否删除 0、未删除 1、已删除
*/
private Integer is_delete;
public TbHuidou() {
}
/**
* 重写eques方法
* @param o
* @return
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TbHuidou tbHuidou = (TbHuidou) o;
return dzh_no.equals(tbHuidou.dzh_no) && lc_no.equals(tbHuidou.lc_no) && product_code.equals(tbHuidou.product_code) && function_id.equals(tbHuidou.function_id);
}
/**
* 重写hascode方法
* @return
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 17;
result = prime * result + (dzh_no == null ? 0 : dzh_no.hashCode());
result = prime * result + (lc_no == null ? 0 : lc_no.hashCode());
result = prime * result + (product_code == null ? 0 : product_code.hashCode());
result = prime * result + (function_id == null ? 0 : function_id.hashCode());
return result;
}
TrequestHuiDouVo
/**
* 理财号
*/
private String vc_custno;
/**
* 组合代码
*/
private String vc_combcode;
/**
* 基金代码
*/
private String vc_fundcode;
取交集代码 tbHuidous数据不能重复 否则需要先去重复
public static void main(String[] args) {
List<TbHuidou> tbHuidous = new ArrayList<>();
TbHuidou tbHuidou = new TbHuidou();
tbHuidou.setCf_no("1");
tbHuidou.setDzh_no("1");
tbHuidou.setLc_no("1");
tbHuidou.setProduct_code("1");
tbHuidou.setFunction_id("1");
tbHuidou.setProduct_type("1");
tbHuidous.add(tbHuidou);
TbHuidou tbHuidou2 = new TbHuidou();
tbHuidou2.setCf_no("2");
tbHuidou2.setDzh_no("2");
tbHuidou2.setLc_no("2");
tbHuidou2.setProduct_code("2");
tbHuidou2.setFunction_id("2");
tbHuidou2.setProduct_type("2");
tbHuidous.add(tbHuidou2);
List<TrequestHuiDouVo> list = new ArrayList<>();
TrequestHuiDouVo trequestHuiDouVo = new TrequestHuiDouVo();
trequestHuiDouVo.setVc_custno("1");
trequestHuiDouVo.setVc_fundcode("1");
list.add(trequestHuiDouVo);
TrequestHuiDouVo trequestHuiDouVo2 = new TrequestHuiDouVo();
trequestHuiDouVo2.setVc_custno("2");
trequestHuiDouVo2.setVc_combcode("2");
list.add(trequestHuiDouVo2);
TrequestHuiDouVo trequestHuiDouVo3 = new TrequestHuiDouVo();
trequestHuiDouVo3.setVc_custno("7");
trequestHuiDouVo3.setVc_combcode("7");
list.add(trequestHuiDouVo3);
List<TbHuidou> list3 = tbHuidous.stream().filter(one -> {
List<Boolean> result = list.stream().map(two -> {
if (one.getProduct_type().equals("1") && one.getLc_no().equals(two.getVc_custno()) && one.getProduct_code().equals(two.getVc_fundcode())){
return true;
}else if (one.getProduct_type().equals("2") && one.getLc_no().equals(two.getVc_custno()) && one.getProduct_code().equals(two.getVc_combcode())){
return true;
}else {
return false;
}
// return one == two;
}).collect(Collectors.toList());
if (result.indexOf(true) > -1)
return true;
return false;
}).collect(Collectors.toList());
list3.stream().forEach(System.out::println);
}
取差集代码
public static void main(String[] args) {
List<TbHuidou> tbHuidous = new ArrayList<>();
TbHuidou tbHuidou = new TbHuidou();
tbHuidou.setCf_no("1");
tbHuidou.setDzh_no("1");
tbHuidou.setLc_no("1");
tbHuidou.setProduct_code("1");
tbHuidou.setFunction_id("1");
tbHuidou.setProduct_type("1");
tbHuidous.add(tbHuidou);
TbHuidou tbHuidou2 = new TbHuidou();
tbHuidou2.setCf_no("2");
tbHuidou2.setDzh_no("2");
tbHuidou2.setLc_no("2");
tbHuidou2.setProduct_code("2");
tbHuidou2.setFunction_id("2");
tbHuidou2.setProduct_type("2");
tbHuidous.add(tbHuidou2);
TbHuidou tbHuidou3 = new TbHuidou();
tbHuidou3.setCf_no("9");
tbHuidou3.setDzh_no("9");
tbHuidou3.setLc_no("9");
tbHuidou3.setProduct_code("9");
tbHuidou3.setFunction_id("9");
tbHuidou3.setProduct_type("9");
tbHuidous.add(tbHuidou3);
List<TrequestHuiDouVo> list = new ArrayList<>();
TrequestHuiDouVo trequestHuiDouVo = new TrequestHuiDouVo();
trequestHuiDouVo.setVc_custno("1");
trequestHuiDouVo.setVc_fundcode("1");
list.add(trequestHuiDouVo);
TrequestHuiDouVo trequestHuiDouVo2 = new TrequestHuiDouVo();
trequestHuiDouVo2.setVc_custno("2");
trequestHuiDouVo2.setVc_combcode("2");
list.add(trequestHuiDouVo2);
TrequestHuiDouVo trequestHuiDouVo3 = new TrequestHuiDouVo();
trequestHuiDouVo3.setVc_custno("7");
trequestHuiDouVo3.setVc_combcode("7");
list.add(trequestHuiDouVo3);
List<TbHuidou> distinctByUniqueList = tbHuidous.stream()
//groupPeopleList - dbaGroupPeoples 差集
.filter(item -> !list.stream()
.map(e -> {
if (item.getProduct_type().equals("1")){
return e.getVc_custno() + e.getVc_fundcode()+item.getProduct_type();
}else {
return e.getVc_custno() + e.getVc_combcode()+item.getProduct_type();
}
})
.collect(Collectors.toList())
.contains(item.getLc_no() + item.getProduct_code()+item.getProduct_type()))
//去重
//.filter(UniqueUtils.distinctByKey(e -> e.getAccount()))
// .peek(e -> e.setId(UUIDUtil.uuid()))
.collect(Collectors.toList());
distinctByUniqueList.stream().forEach(System.out::println);
}