1. map用法示例:
set - get ; 对象 - 对象的引用
1 public ListselectCompareList( 2 Req_compareInfo_query record) { 3 4 /** 1、查询日切流水表,得到记录*/ 5 List list= organBatchFlowDao.selectCompareList(dto); 6 if(list==null ||list.size()<1){ 7 LOGGER.info("### step1: query from welink_adm_organ_batch_flow ,and size = 0"); 8 return new ArrayList (); 9 }10 /** 2、遍历,将记录存到 Map 中*/11 SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");12 Map map = new HashMap (); 13 for(OrganBatchFlowDTO t:list){14 if(StringUtils.equals(WftsAdmConstant.UP_ORGAN_NO, t.getOrgan_no())){15 t.setOrgan_name("统一支付平台");16 }17 t.setSettleDate(fmt.format(t.getBatch_change_last_time()));18 t.setOrganNo(t.getOrgan_no());19 map.put(t.getOrgan_no()+fmt.format(t.getBatch_change_last_time()), t);20 }21 /** 3、查询对账待办事项,遍历,补齐字段*/22 List list2= compareFileDao.selectForCompare();23 24 if(list2.size()>0){25 for(CompareFileDTO t2:list2){26 if(map.containsKey((t2.getOrganNo()+t2.getSettleDate())) && 27 map.get((t2.getOrganNo()+t2.getSettleDate()))!=null ){28 String key =t2.getOrganNo()+t2.getSettleDate() ;29 map.get(key).setCompareStatus(t2.getComparStatus());30 map.get(key).setTransType(t2.getTransType());31 }32 }33 } 34 /** 4、查询对账文件列表,遍历,补齐字段*/35 List list3= fileStatusDao.selectForCompare();36 for(FileStatusDTO t3:list3){37 if(map.containsKey((t3.getOrganNo()+t3.getSettleDate())) && 38 map.get((t3.getOrganNo()+t3.getSettleDate()))!=null ){39 String key =t3.getOrganNo()+t3.getSettleDate() ;40 map.get(key).setFileLineCount(t3.getFileLineCount());41 map.get(key).setTotalAmount(t3.getTotalAmount());42 map.get(key).setsFileLineCount(t3.getsFileLineCount());43 map.get(key).setsTotalAmount(t3.getsTotalAmount());44 map.get(key).setFileName(t3.getFileName());45 map.get(key).setMd5Str(t3.getMd5Str());46 map.get(key).setAccountDataAddr(t3.getAccountDataAddr());47 }48 }49 /** 50 * map 存的value是list当中的对象,map的value值改变,同时也改变list元素对象的值, * 所以最后可以返回改变后的list52 */53 return list;54 }
2. set用法示例