for (WpSellerWxConfig wpSellerWxConfig : configList) { String payServiceNo = wpSellerWxConfig.getSellerId(); if (StrKit.isBlank(payServiceNo)) { continue; } XxlJobLogger.log("payServiceNo:{}:payServiceNo start", payServiceNo); List<PosStoreconfigDto> posStoreconfigList = userService.selectByStoreId(payServiceNo); XxlJobLogger.log("posStoreconfigList:{}:posStoreconfigList end", posStoreconfigList); XxlJobLogger.log("payServiceNo:{}:payServiceNo end", payServiceNo); if (CommonUtil.isNotNullList(posStoreconfigList)) { for (PosStoreconfigDto posStoreconfig : posStoreconfigList) { if (posStoreconfig != null && !StrKit.isBlank(posStoreconfig.getStoreId()) && !sellerIdList.contains(posStoreconfig.getStoreId())) { log.info("t3dStoreId:{}", posStoreconfig.getStoreId()); WpSellerWxConfig wpSellerWxConfig2 =new WpSellerWxConfig(); BeanUtils.copyProperties(wpSellerWxConfig, wpSellerWxConfig2);// wpSellerWxConfig2.setT3dStoreId(posStoreconfig.getStoreId()); wpSellerWxConfig2.setId(posStoreconfig.getStoreId()); log.info("wpSellerWxConfig:" + JsonKit.toJson(wpSellerWxConfig2)); endWxConfig.add(wpSellerWxConfig2);// list 結合add方法時,添加要從新建立對象,否則會覆蓋以前的元素3d
if(("79e5d334031b488facc7f3c585251b96").equals(wpSellerWxConfig2.getT3dStoreId())) { XxlJobLogger.log("aibao1 79e5d334031b488facc7f3c585251b96存在"); }else { XxlJobLogger.log("aibao1 79e5d334031b488facc7f3c585251b96 不存在"); } log.info("posStoreconfig_storeId:{}", posStoreconfig.getStoreId()); XxlJobLogger.log("轉發數據大小:"+endWxConfig.size()); sellerIdList.add(posStoreconfig.getStoreId()); log.info("中間數據:"+JsonKit.toJson(endWxConfig)); if(JsonKit.toJson(endWxConfig).indexOf("79e5d334031b488facc7f3c585251b96")!=-1) { log.info("aibao1 存在"); }else { log.info("aibao1不存在"); } } } }
endWxConfig 集合中最終的數據集始終不對,最初的數據都沒有了 當使用List<T>時,若是T是引用類型,保存的是引用,若是是值類型,保存的是值自己。code
一、T是對象是,也就是說若是是引類型時,在循環外邊已經new了一個對象,至關於這個對象的地址在內存空間已經開闢出來了,保存到了固定的位置,這時候咱們使用add方法時,會增長值的個數,但引用地址不變,因此後面的值會覆蓋掉前面的值對象
二、T是值對象時,這種和上面就不同了,值對象用來保存一組不會改變的量,當咱們須要使用這個對象時,會在系統中開闢另外一個空間。所以,值對象使用add方法時不會出現覆蓋問題。內存