@RequestMapping(value = "/tablelist/provs/{type}") public ModelAndView provincelist( HttpServletRequest request, @PathVariable String orgi, @PathVariable String type, @ModelAttribute("data") RequestData data) { ResponseData responseData = new ResponseData("/pages/manage/sinosig/location/provincelist"); responseData.setRqdata(data); List<SinoLocation> lists = super.getService() .findAllByCriteria( DetachedCriteria.forClass(SinoLocation.class) .add(Restrictions.eq("orgi", orgi)) .add(Restrictions.eq("type", type))); Map<String, SinoLocation> provincesmap = new HashMap<String, SinoLocation>(); List<SinoLocation> list = new ArrayList<SinoLocation>(); String indexpro = null; for (SinoLocation local : lists) { if (!provincesmap.containsKey(local.getProvince())) { if (indexpro == null) { indexpro = local.getProvince(); } provincesmap.put(local.getProvince(), local); } } if (lists != null && lists.size() > 0) { if (provincesmap != null) { Iterator<SinoLocation> iterator = provincesmap.values().iterator(); while (iterator.hasNext()) { list.add(iterator.next()); } } } responseData.setValueList(list); /*responseData.setValueList(Arrays.asList(provincesmap.values())); responseData.setDataList(Arrays.asList(citysmap.values()));*/ ModelAndView view = request(responseData, orgi, data); return view; }
@SuppressWarnings("unused") @RequestMapping(value = "/tablelist/{type}/{pro}") public ModelAndView list( HttpServletRequest request, @PathVariable String orgi, @PathVariable String type, @PathVariable String pro, @ModelAttribute("data") RequestData data) { ResponseData responseData = new ResponseData("/pages/manage/sinosig/location/list"); responseData.setRqdata(data); String search = request.getParameter("search"); String key = "%" + search + "%"; if (search == null) { if ("0".equals(pro) || "".equals(pro)) { // responseData.setValueList(super.getService().findAllByCriteria(DetachedCriteria.forClass(SinoLocation.class).add(Restrictions.and(Restrictions.eq("orgi", orgi), Restrictions.eq("type", type))),null,Projections.distinct(Projections.property("province")))); responseData.setDataList( super.getService() .findPageByCriteria( DetachedCriteria.forClass(SinoLocation.class) .add( Restrictions.and( Restrictions.eq("orgi", orgi), Restrictions.eq("type", type))), data.getPs(), data.getP())); } else { responseData.setDataList( super.getService() .findPageByCriteria( DetachedCriteria.forClass(SinoLocation.class) .add( Restrictions.and( Restrictions.eq("orgi", orgi), Restrictions.eq("province", pro))) .add(Restrictions.eq("type", type)), data.getPs(), data.getP())); } } else { if ("0".equals(pro) || "".equals(pro)) { // responseData.setValueList(super.getService().findAllByCriteria(DetachedCriteria.forClass(SinoLocation.class).add(Restrictions.and(Restrictions.eq("orgi", orgi), Restrictions.eq("type", type))),null,Projections.distinct(Projections.property("province")))); responseData.setDataList( super.getService() .findPageByCriteria( DetachedCriteria.forClass(SinoLocation.class) .add( Restrictions.and( Restrictions.eq("orgi", orgi), Restrictions.eq("type", type))) .add( Restrictions.or( Restrictions.or( Restrictions.like("province", key), Restrictions.like("city", key)), Restrictions.or( Restrictions.like("address", key), Restrictions.like("dept", key)))), data.getPs(), data.getP())); } else { responseData.setDataList( super.getService() .findPageByCriteria( DetachedCriteria.forClass(SinoLocation.class) .add( Restrictions.and( Restrictions.eq("orgi", orgi), Restrictions.eq("province", pro))) .add(Restrictions.eq("type", type)) .add( Restrictions.or( Restrictions.or( Restrictions.like("province", key), Restrictions.like("city", key)), Restrictions.or( Restrictions.like("address", key), Restrictions.like("dept", key)))), data.getPs(), data.getP())); } } /*responseData.setValueList(Arrays.asList(provincesmap.values())); responseData.setDataList(Arrays.asList(citysmap.values()));*/ ModelAndView view = request(responseData, orgi, data); return view; }