数据库去重查询问题详解

预算 2014年院线预算   影城(多选) 北京CBD影城   查询
             
科目 蚌埠万达广场店 北京CBD影城        
营业收入 1 1        
票房收入 1 1        
卖品收入 0 0        
逾期收入 0 0        
广告收入 0 0        
映前广告 0 0        
LCD广告 0 0        
阵地收入 0 0        
IMAX广告收入 0 0        
其他广告收入 0 0        
其他收入 0 0        
租赁收入 0 0        
喷绘费收入 0 0        
卡费收入 0 0        
影片返点奖励收入 0 0        
IMAX冠名费收入 0 0        
其它冠名费收入 0 0        
赞助费 0          
RealD广告赞助费 0          
万达自有媒体收入 0          
其它(其他收入) 0          
变动成本 0          
票房成本 0          
卖品成本 0          
广告成本 0          
其他成本 0          
营业税金及附加(不含专资) 0          
电影专资 0          
变动费用 0          
影院分成租金 0          
IMAX设备租金 0          
固定费用 0          
影院固定租金 0          
职工薪酬 0          
折旧摊销费 0          
办公房屋租金及物业费 0          

List<HashMap> list_temp = new ArrayList<HashMap>();
   List listSubject = hrSalaryReportDetail.removeDuplicateWithSubject(allCinema);
   List listOrg = hrSalaryReportDetail.removeDuplicatWithOrg(allCinema);
   HashMap map = new HashMap();
   for (int k = 0; k < allCinema.size(); k++) {
    // String org_id = listOrg.get(i).toString().split("_")[0];
    Object[] objLIst = (Object[]) allCinema.get(k);// 结果集
    // if(objLIst[2].toString().equals(org_id)&&objLIst[1].toString().equals(listSubject.get(j).toString())){//subjectid与orgid对应
    map.put(objLIst[2].toString() + "_" + objLIst[3].toString(),
      objLIst[6].toString());// subjectid与orgid对应
    // }
   }

   for (int j = 0; j < listSubject.size(); j++) {
    String subject_id = listSubject.get(j).toString().split("_")[0];
    String subject_name = listSubject.get(j).toString().split("_")[1];
    String subject_parent_id = listSubject.get(j).toString().split("_")[2];
  
    HashMap sub_map = new HashMap();
    sub_map.put("subjectId", subject_id);
    sub_map.put("parentSubjectId", subject_parent_id);
    sub_map.put("subject_name", subject_name);
    for (int i = 0; i < listOrg.size(); i++) {
     String org_id = listOrg.get(i).toString().split("_")[0];
     String str_key = subject_id + "_" + org_id;
     String str_value = "";
     if (map.containsKey(str_key)) {
      str_value = map.get(str_key).toString();
     }
     sub_map.put(org_id, str_value);
    }
    list_temp.add(sub_map);

原文地址:https://www.cnblogs.com/SunDexu/p/3356174.html