Authored by mali

价格趋势

package com.yohoufo.product.model;
import com.alibaba.fastjson.JSONObject;
import java.math.BigDecimal;
import java.util.Objects;
import java.util.Optional;
/**
* Created by li.ma on 2019/1/8.
... ... @@ -93,6 +97,19 @@ public class PriceTrendResp {
return null != this.endTime && this.endTime.equals(resp.getEndTime());
}
@Override
public int hashCode() {
if (Objects.isNull(this.endTime)) {
return super.hashCode();
}
return this.endTime.hashCode();
}
@Override
public String toString() {
return JSONObject.toJSONString(this);
}
public static class Builder {
private Integer id;
... ...
... ... @@ -53,6 +53,10 @@ public class ProductPriceService implements ApplicationContextAware{
LOG.info("priceTrendModels result is {}", priceTrendModels.size());
if (priceTrendModels.size() <= 1) {
return Lists.newArrayList();
}
List<PriceTrendResp> result = Lists.newArrayList();
priceTrendModels.stream().forEach(item ->
result.add(new PriceTrendResp.Builder().setProductId(item.getProductId())
... ...
package com.yohoufo.order;
import com.google.common.collect.Lists;
import com.yohoufo.product.model.PriceTrendResp;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by li.ma on 2019/1/17.
*/
public class Test11 {
public static void main(String[] args) {
List<PriceTrendResp> result = Lists.newArrayList();
PriceTrendResp resp =new PriceTrendResp();
resp.setEndTime("2019-01-09 00:00:00");
resp.setProductId(1002512);
result.add(resp);
PriceTrendResp resp1 =new PriceTrendResp();
resp1.setEndTime("2019-01-09 00:00:00");
resp1.setProductId(46346346);
result.add(resp1);
List<PriceTrendResp> collect = result.stream().distinct().collect(Collectors.toList());
System.out.println(collect);
}
}
... ...