您的位置:首页 > 其它

过滤IBatis方法查询出来的重复数据

2010-11-22 15:29 453 查看
1. IBatis通过以下语句查询出来的List,内含一个个map对象.

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: