//获得查询的条件
String qtype = request.getParameter("qtype");
//计算查询开始数据下标
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
IAddressDao addressDao = (IAddressDao) ac.getBean("addressDao");
if("1".equals(hidden) || Integer.parseInt(hidden) == 1)
{
if(query!=null && !("").equals(query))
{
String[] q1 = qtype.split(",");
String[] q2 = query.split(",");
Map<String,Object> map = new HashMap<String, Object>();
for(int i=0;i<q2.length;i++)
{
String[] q22 = q2[i].split("#");
map.put(q22[0], q22.length > 1?q22[1]:"");
}
for(int i=0;i<q1.length;i++)
{
String q = q1[i].split(":")[0];
String d = q1[i].split(":").length>1?q1[i].split(":")[1]:"";
if("date".equals(d) && !"".equals(d))
{
String d1 = map.get(q).toString().split("&")[0];
String d2 = map.get(q).toString().split("&").length >1?map.get(q).toString().split("&")[1]:"";
hql += " and " + q + " >= str_to_date('"+d1+"','%Y-%m-%d %H:%i:%s')";
hql += "".equals(d2)?"":" and " + q + " <= str_to_date('"+d2+"','%Y-%m-%d %H:%i:%s')";
}else if(!"".equals(map.get(q)))
{
hql += " and " + q + " like '%"+map.get(q)+"%'";
}
}
}
PageList list = addressDao.findByPage4Report(hql, new Object[]{}, Integer.parseInt(page), Integer.parseInt(maxResult));
//当前页数设置
pageInfo.put("page", page);
//当前页数设置
pageInfo.put("size", maxResult);
//总搜索数据量设置
pageInfo.put("total", list.getTotalRecordNum());
String jsonStr = creMessageJSON(list.getDataList(), pageInfo);
//response相关处理
response.setContentType("html/txt");
response.setCharacterEncoding("utf-8");
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache, must-revalidate");
response.setHeader("Pragma", "no-cache");
try {
response.getWriter().write(jsonStr);
response.getWriter().flush();
response.getWriter().close();
} catch (IOException e) {
e.printStackTrace();
}
}
else if("3".equals(hidden))
{
String idStr = request.getParameter("addressId");
String[] ids = idStr.split(",");
addressDao.batchDeleteAddress(ids);
//跳转
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print("<script type=\"text/javascript\">alert('删除成功');location.href='page/management/member/member_welcome.jsp?url=member_address.jsp'</script>");
}