过滤IBatis方法查询出来的重复数据
2010-11-22 15:29
453 查看
1. IBatis通过以下语句查询出来的List,内含一个个map对象.
2. 通过以下方法对process_id,node_code,audit_date进行过滤操作.
select * from ( select v.BIZCODE as process_type, v.BIZID as process_id, v.INITORGID as corp_code, t.nodeid as node_code, t.nodename as node_name, nvl(v.INITSTAFFID,' ') as applicant, (case when t.createddatetime is null then ' ' when t.createddatetime is not null then to_char(t.createddatetime,'yyyy-mm-dd') end ) as app_date, nvl(t.executorid,' ') as audit_person, (case when t.donedatetime is null then ' ' when t.donedatetime is not null then to_char(t.donedatetime,'yyyy-mm-dd') end ) as audit_date, nvl(t.ownerid,' ') as ownername, tf.id_num as id_num from v_process_task v, task t, tf_payout_list tf where v.STATUS = #status# and (v.BIZCODE = #tobaccopay02# or v.BIZCODE = #unagrpayout#) and v.MPID = t.mpid and v.INITORGID = '114201' and t.flag = #flag# and tf.payout_id = v.BIZID and to_char(t.donedatetime,'yyyyMMdd')<!--[CDATA[ > ]]-->'20100901' ) a where not exists (SELECT 1 FROM OUT_SEND_TO_ISO_LOG OUT WHERE OUT.SEND_BIZID = a.PROCESS_ID)
2. 通过以下方法对process_id,node_code,audit_date进行过滤操作.
/** * 用来对查询出来的数据进行主键上的过滤,以便每次都只传递一条唯一ID以及NODE的流程数据 * @param list * @return */ private List getTransferList(List list) { Map map = null; Map idFilterMap = new HashMap(); List allList = new ArrayList(); for(int i=0;i<list.size();i++) { map = (HashMap)list.get(i); String id = map.get("PROCESS_ID").toString(); if(idFilterMap.containsKey(id)) { if(judgeNodeFlag(id,map,allList)) { if(judgeTimeFlag(id,map,allList)) { // System.out.println("进来了!"); } else { allList.add(map); } } else { allList.add(map); } } else { idFilterMap.put(id, map); allList.add(map); } } return allList; } private static boolean judgeNodeFlag(String id,Map map,List allList) { Map temp = null; boolean result = false; //为空的时候有可能是第一次进入,需要和idList中的记录进行比较 for(int i=0;i<allList.size();i++) { temp = (HashMap)allList.get(i); //当ID相等,NODE也相等的时候,标志设置为true,进行“时间”字段上的过滤 if(id.equals(temp.get("PROCESS_ID").toString())) { if(temp.get("NODE_CODE").toString().equals(map.get("NODE_CODE"))) result = true; } } return result; } private static boolean judgeTimeFlag(String id,Map map,List allList) { Map temp = null; boolean result = false; //为空的时候有可能是第一次进入,需要和NodeList中的记录进行比较 for(int i=0;i<allList.size();i++) { temp = (HashMap)allList.get(i); //当ID相等,NODE也相等的时候,标志设置为true,进行“时间”字段上的过滤 if(id.equals(temp.get("PROCESS_ID").toString())) { if(temp.get("NODE_CODE").toString().equals(map.get("NODE_CODE"))) { if(temp.get("AUDIT_DATE").toString().equals(map.get("AUDIT_DATE").toString())) result = true; } } } return result; }
相关文章推荐
- 查询出的列表过滤掉重复数据的方法(主要是一对多的重复)
- 使用aggregate在MongoDB中查询重复数据记录的方法
- Oracle查询表里的重复数据方法:
- mysql查询表里的重复数据方法:
- 数据列表过滤重复值几种方法的性能比较
- oracle查询重复数据与删除重复记录方法
- 查询mysql中重复数据的方法
- Sql查询语句过滤重复的数据
- 过滤重复数据 JavaScript push() 方法
- MSSql简单查询出数据表中所有重复数据的方法
- mysql查询表里的重复数据方法
- 查询及删除数据重复记录的方法
- Oracle查询重复数据与删除重复记录方法
- 过滤重复数据 JavaScript push() 方法
- 关于sql查询中去掉重复数据的方法
- 查询和删除数据库表中有重复的数据,只保留唯一条记录的方法
- MySQL 查询过滤重复数据
- ibatis 过滤重复数据
- 使用aggregate在MongoDB中查询重复数据记录的方法
- 过滤重复数据 JavaScript push() 方法