|
@@ -1,7 +1,15 @@
|
|
|
package com.qlm.controller.jinzai;
|
|
package com.qlm.controller.jinzai;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
+import com.jfinal.plugin.activerecord.Record;
|
|
|
import com.qlm.annotation.RequestUrl;
|
|
import com.qlm.annotation.RequestUrl;
|
|
|
import com.qlm.controller.common.CommonController;
|
|
import com.qlm.controller.common.CommonController;
|
|
|
|
|
+import com.qlm.tools.WxUtil;
|
|
|
|
|
|
|
|
@RequestUrl("/jxsList")
|
|
@RequestUrl("/jxsList")
|
|
|
public class JxsController extends CommonController{
|
|
public class JxsController extends CommonController{
|
|
@@ -16,4 +24,121 @@ public class JxsController extends CommonController{
|
|
|
// TODO Auto-generated method stub
|
|
// TODO Auto-generated method stub
|
|
|
return "/page/jinzai/jxs.jsp";
|
|
return "/page/jinzai/jxs.jsp";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void query(){
|
|
|
|
|
+ int pageSize = getParaToInt("pageSize",10);
|
|
|
|
|
+ int page = getParaToInt("pageNumber",1);
|
|
|
|
|
+ int pageStart = pageSize*(page-1);
|
|
|
|
|
+ String tableName = getPara("key");
|
|
|
|
|
+ String order = getPara("order");
|
|
|
|
|
+ String toolBarConfig = getPara("toolBarConfig");
|
|
|
|
|
+ String startdate = getPara("startdate");
|
|
|
|
|
+
|
|
|
|
|
+ String endDate = getPara("enddate");
|
|
|
|
|
+ String dateField = getPara("datefield");
|
|
|
|
|
+ String whereSql = "";
|
|
|
|
|
+ List<String> conditions = new ArrayList<String>();
|
|
|
|
|
+ if(!WxUtil.isNull(toolBarConfig)){
|
|
|
|
|
+ JSONArray parseArray = JSONArray.parseArray(toolBarConfig);
|
|
|
|
|
+ for (int i = 0; i < parseArray.size(); i++) {
|
|
|
|
|
+ JSONObject jsonObject = parseArray.getJSONObject(i);
|
|
|
|
|
+ String nameKey = jsonObject.getString("key");
|
|
|
|
|
+ String type = jsonObject.getString("type");
|
|
|
|
|
+ String para = getPara(nameKey);
|
|
|
|
|
+ if(nameKey.equals("city") && "空".equals(para)){
|
|
|
|
|
+ if(whereSql.length()>0){
|
|
|
|
|
+ whereSql+= " and ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ whereSql+= " where ";
|
|
|
|
|
+ }
|
|
|
|
|
+ whereSql += " city = '' ";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(WxUtil.isNull(para) || "all".equals(para)){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(whereSql.length()>0){
|
|
|
|
|
+ whereSql+= " and ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ whereSql+= " where ";
|
|
|
|
|
+ }
|
|
|
|
|
+ para = para.replace("\n","");
|
|
|
|
|
+ if("input".equals(type)){
|
|
|
|
|
+ whereSql += " "+nameKey+" like '%"+para+"%'";
|
|
|
|
|
+ }else if("select".equals(type)){
|
|
|
|
|
+ whereSql += " "+nameKey+" =? ";
|
|
|
|
|
+ conditions.add(para);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!WxUtil.isNull(dateField)){
|
|
|
|
|
+ if(!WxUtil.isNull(endDate)){
|
|
|
|
|
+ if(whereSql.length()>0){
|
|
|
|
|
+ whereSql+= " and ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ whereSql+= " where ";
|
|
|
|
|
+ }
|
|
|
|
|
+ whereSql += " "+dateField+" <= '"+endDate+"' ";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(!WxUtil.isNull(startdate)){
|
|
|
|
|
+ if(whereSql.length()>0){
|
|
|
|
|
+ whereSql+= " and ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ whereSql+= " where ";
|
|
|
|
|
+ }
|
|
|
|
|
+ whereSql += " "+dateField+" >= '"+startdate+"' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String paramConfig = getPara("paramConfig");
|
|
|
|
|
+ if(!WxUtil.isNull(paramConfig)){
|
|
|
|
|
+ String [] paramConfigs = paramConfig.split(";");
|
|
|
|
|
+ for (String extraConfig : paramConfigs) {
|
|
|
|
|
+ String[] values = extraConfig.split("=");
|
|
|
|
|
+ String pName = values[0];
|
|
|
|
|
+ if(whereSql.length()>0){
|
|
|
|
|
+ whereSql+= " and "+pName+"= ? ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ whereSql+= " where "+pName+"= ? ";;
|
|
|
|
|
+ }
|
|
|
|
|
+ conditions.add(values[1]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ Record data = getData(tableName,pageStart,pageSize);
|
|
|
|
|
+ Long queryLong = null;
|
|
|
|
|
+ List<Record> find = null;
|
|
|
|
|
+ if(data != null){
|
|
|
|
|
+ queryLong = data.getLong("total");
|
|
|
|
|
+ find = data.get("list");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ String[] array = conditions.toArray(new String[conditions.size()]);
|
|
|
|
|
+ if(conditions.isEmpty()){
|
|
|
|
|
+ queryLong = Db.queryLong("select count(*) from "+tableName+" "+whereSql);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ queryLong = Db.queryLong("select count(*) from "+tableName+" "+whereSql,array);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String sql = "";
|
|
|
|
|
+ if(!WxUtil.isNull(order)){
|
|
|
|
|
+ sql = "select * from "+tableName +" "+" "+whereSql+" "+order+" limit "+pageStart+","+pageSize;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ sql = "select * from "+tableName +" "+whereSql+" limit "+pageStart+","+pageSize;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(conditions.isEmpty()){
|
|
|
|
|
+ find = Db.find(sql);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ find = Db.find(sql,array);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ formatData(tableName,find);
|
|
|
|
|
+ Record r = new Record();
|
|
|
|
|
+ r.set("rows", find);
|
|
|
|
|
+ r.set("total", queryLong);
|
|
|
|
|
+ renderJson(r);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|