From 2424da6799f7c3c24cf86df50d14d3a8b0bd661b Mon Sep 17 00:00:00 2001 From: zhuangqian Date: Wed, 23 Nov 2016 14:05:51 +0800 Subject: [PATCH] bug fix --- .../java/com/smallchill/core/constant/ConstCacheKey.java | 2 ++ .../smallchill/system/controller/ExcelController.java | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/smallchill/core/constant/ConstCacheKey.java b/src/main/java/com/smallchill/core/constant/ConstCacheKey.java index 312e0839..75fcaae1 100644 --- a/src/main/java/com/smallchill/core/constant/ConstCacheKey.java +++ b/src/main/java/com/smallchill/core/constant/ConstCacheKey.java @@ -80,6 +80,8 @@ public interface ConstCacheKey { String EXCEL_SQL = "excel_sql_"; + String EXCEL_SQL_PARA = "excel_sql_para_"; + String EXCEL_COL_NAME = "excel_colname_"; String EXCEL_COL_MODEL = "excel_colmodel_"; diff --git a/src/main/java/com/smallchill/system/controller/ExcelController.java b/src/main/java/com/smallchill/system/controller/ExcelController.java index a1ea6696..3c603616 100644 --- a/src/main/java/com/smallchill/system/controller/ExcelController.java +++ b/src/main/java/com/smallchill/system/controller/ExcelController.java @@ -64,12 +64,18 @@ public class ExcelController extends BaseController{ sort = sidx + " " + sord + (Func.isEmpty(sort) ? ("," + sort) : ""); } String orderby = (Func.isOneEmpty(sort, order)) ? (" order by " + sort + " " + order) : ""; + Map para = JsonKit.parse(Func.isEmpty(Func.decodeUrl((String)where)) ? null : Func.decodeUrl((String)where), HashMap.class); + if (Func.isEmpty(para)) { + para = new HashMap<>(); + } String sql = "select {} from (" + _source + ") a " + SqlKeyword.getWhere((String) where) + orderby; CacheKit.remove(cacheName, EXCEL_SQL + code); + CacheKit.remove(cacheName, EXCEL_SQL_PARA + code); CacheKit.remove(cacheName, EXCEL_COL_NAME + code); CacheKit.remove(cacheName, EXCEL_COL_MODEL + code); CacheKit.put(cacheName, EXCEL_SQL + code, sql); + CacheKit.put(cacheName, EXCEL_SQL_PARA + code, para); CacheKit.put(cacheName, EXCEL_COL_NAME + code, _colname); CacheKit.put(cacheName, EXCEL_COL_MODEL + code, _colmodel); @@ -82,6 +88,7 @@ public class ExcelController extends BaseController{ @RequestMapping("/export") public String export(ModelMap modelMap, HttpServletResponse response, @RequestParam String code) { String sql = CacheKit.get(cacheName, EXCEL_SQL + code); + Map para = CacheKit.get(cacheName, EXCEL_SQL_PARA + code); String [] _colname = CacheKit.get(cacheName, EXCEL_COL_NAME + code); List> _colmodel = CacheKit.get(cacheName, EXCEL_COL_MODEL + code); @@ -103,7 +110,7 @@ public class ExcelController extends BaseController{ String menu_name = getInfoByCode(code, "NAME"); @SuppressWarnings("rawtypes") - List dataResult = Db.selectList(Func.format(sql, StrKit.removeSuffix(sb.toString(), ","))); + List dataResult = Db.selectList(Func.format(sql, StrKit.removeSuffix(sb.toString(), ",")), para); ExportParams exportParams = new ExportParams(menu_name + " 数据导出表", "导出人账号:" + ShiroKit.getUser().getLoginName() + " 导出时间:" + DateKit.getTime(), code); exportParams.setColor(HSSFColor.GREY_50_PERCENT.index); exportParams.setAddIndex(true);