@Override public List<Object> changeStat(int stat, String ids) { List<Object> rsList = new ArrayList<Object>(); try { if (NullCheck.nullStr(ids)) { rsList.add(1); } else { List<Integer> l = new ArrayList<Integer>(); for (String s : ids.replaceAll(" ", "").split(",")) { if (NullCheck.notNullStr(s)) { l.add(Integer.valueOf(s)); } } String hql = "update " + clazz.getSimpleName() + " set stat=:st where id in :ids"; this.getSession() .createQuery(hql) .setParameter("st", stat) .setParameterList("ids", l) .executeUpdate(); rsList.add(-1); } } catch (Exception e) { log.error("修改配价状态异常:", e); rsList.add(1); } return rsList; }
@Override public Map<String, Object> queryStoreDatas(int bid) { Session se = session(); List<RetailStore> list = se.createQuery("from RetailStore where base_id=:bid and opening_state<>8") .setParameter("bid", bid) .list(); if (NullCheck.notNullList(list)) { Map<String, Object> reMap = new HashMap<String, Object>(); reMap.put("count", list.size()); List<Integer> ids = new ArrayList<Integer>(); Map<String, List<RetailStore>> dataMap = new HashMap<String, List<RetailStore>>(); for (RetailStore retailStore : list) { if (!ids.contains(retailStore.getCity_id())) { ids.add(retailStore.getCity_id()); } } for (Integer i : ids) { List<RetailStore> l = new ArrayList<RetailStore>(); for (RetailStore ol : list) { if (i == ol.getCity_id()) { l.add(ol); } } if (NullCheck.notNullList(l)) { dataMap.put(DatasCache.AREAS_ID_NAME.get(i), l); } } reMap.put("datas", dataMap); return reMap; } return null; }
@Override public int queryTotal(List<RetailStore> rsList) { if (NullCheck.notNullList(rsList)) { List<Integer> l = new ArrayList<Integer>(); for (RetailStore r : rsList) { l.add(r.getId()); } String hql = "select count(*) from " + clazz.getSimpleName() + " where belongs_id in :bid"; return Integer.valueOf( getSession().createQuery(hql).setParameterList("bid", l).list().get(0).toString()); } return 0; }
@Override public List<T> queryDatasList(List<RetailStore> rsList, int current, int nums) { if (NullCheck.notNullList(rsList)) { List<Integer> l = new ArrayList<Integer>(); for (RetailStore r : rsList) { l.add(r.getId()); } String hql = "from " + clazz.getSimpleName() + " where belongs_id in :bid and stat<>8"; return getSession() .createQuery(hql) .setParameterList("bid", l) .setFirstResult((current - 1) * nums) .setMaxResults(nums) .list(); } return null; }
@Action( value = Views.HD_WEDDING, results = {@Result(name = SUCCESS, location = VPath.HD_WEDDING)}) public String toHdWeddingMoreList() { try { String str = checkPrecondition4HD(7); if (str != null) { rsp().getWriter().print(str); return null; } rsList = retailStoreService.queryStoreList(belongs_id(), 1); if (NullCheck.notNullList(rsList)) { brands = carModelService.queryBrands(belongs_id()); rents = service.queryDatasList(rsList, current, nums); total = service.queryTotal(rsList); count = total % nums == 0 ? total / nums : total / nums + 1; } } catch (Exception e) { log.error("跳转代驾婚庆业务列表页异常:", e); } return SUCCESS; }