java如何查看多次发生的记录

时间:2014-07-23 06:55:23

标签: java arrays spring-mvc

我要做的是检查数据库中是否有多个相同的“childid”

如果它只有这个代码应该工作

for(int x=0;x<admi.size();x++){
                     if(admi.get(x).getChildid().matches(chil)){
                         no=no+1;

                            asum.get(asum.size()-1).setNooftime(no); 
                     }
                 }

这是完整的方法

@RequestMapping(value ="/NoOfAdmission",method = RequestMethod.GET)
public ModelAndView NoOfAdmission(ModelAndView modelAndView, ModelMap model, Map<String, Object> map,HttpServletRequest request,
        @RequestParam("syear") int syear,@RequestParam("eyear") int eyear, HttpSession session){
    String childid = (String) session.getAttribute("childid");


    List<AdmissionSummery> asum = new ArrayList<AdmissionSummery>();   
     List<Admitclinic> admitclinic = patientService.listadmitclinic();
    for(int i=syear;i<=eyear;i++){
         asum.add(new AdmissionSummery());
        int no=0;
        for(int j=0;j<admitclinic.size();j++){
            int adyear=Integer.parseInt(admitclinic.get(j).getAdmitdate().substring(0, 4));
            if(adyear==i){

                String chil = admitclinic.get(j).getChildid();
                int AdmitClinic_ID=admitclinic.get(j).getAdmitclinicid();
                 List<Admitclinic> admi=patientService.ListAdChildid(AdmitClinic_ID);
                 for(int x=0;x<admi.size();x++){
                     if(admi.get(x).getChildid().matches(chil)){
                         no=no+1;

                            asum.get(asum.size()-1).setNooftime(no); 
                     }
                 }
            }
        }
        asum.get(asum.size()-1).setDuration(syear+" "+"-"+" "+eyear);
        asum.get(asum.size()-1).setYear(i);

    }

    JRDataSource datasource = new JRBeanCollectionDataSource(asum); 

    model.addAttribute("datasourceADDreportB", datasource);

    model.addAttribute("format", "pdf");

    modelAndView = new ModelAndView("pdfReportViewaddsummeryB", model);



    return modelAndView;


}

有人能指出我该怎么做吗?

0 个答案:

没有答案