瀏覽代碼

更新参数筛选值类型

rsbi 4 年之前
父節點
當前提交
59e1a96622

+ 13 - 6
src/main/java/com/ruisitech/bi/entity/bireport/DimDto.java

@@ -2,14 +2,16 @@ package com.ruisitech.bi.entity.bireport;
 
 import com.ruisitech.bi.entity.common.BaseEntity;
 
+import java.util.List;
+
 public class DimDto extends BaseEntity {
 
 	private Integer id;
 	private String type;
 	private String colname; //码表在事实表中对应的字段名
 	private String alias; //别名
-	private String vals; //码表的限制维
-	private String valDesc; //码表限制维的名称
+	private List<String> vals; //码表的限制维
+	private List<String> valDesc; //码表限制维的名称
 	private String issum; //y,n两值
 	private String tname; //维度所在表name
 	private Integer calc;  //是否计算列
@@ -73,18 +75,23 @@ public class DimDto extends BaseEntity {
 	public void setAlias(String alias) {
 		this.alias = alias;
 	}
-	public String getVals() {
+
+	public List<String> getVals() {
 		return vals;
 	}
-	public void setVals(String vals) {
+
+	public void setVals(List<String> vals) {
 		this.vals = vals;
 	}
-	public String getValDesc() {
+
+	public List<String> getValDesc() {
 		return valDesc;
 	}
-	public void setValDesc(String valDesc) {
+
+	public void setValDesc(List<String> valDesc) {
 		this.valDesc = valDesc;
 	}
+
 	public String getIssum() {
 		return issum;
 	}

+ 21 - 14
src/main/java/com/ruisitech/bi/entity/bireport/ParamDto.java

@@ -2,6 +2,8 @@ package com.ruisitech.bi.entity.bireport;
 
 import com.ruisitech.bi.entity.common.BaseEntity;
 
+import java.util.List;
+
 public class ParamDto extends BaseEntity {
 
 	private String type;
@@ -12,8 +14,8 @@ public class ParamDto extends BaseEntity {
 	private String tname;
 	private String st;
 	private String end;
-	private String vals;
-	private String valStrs;
+	private List<String> vals;
+	private List<String> valStrs;
 	private String valDesc;
 	private Integer id;
 	private Integer cubeId;
@@ -76,12 +78,6 @@ public class ParamDto extends BaseEntity {
 	public void setEnd(String end) {
 		this.end = end;
 	}
-	public String getVals() {
-		return vals;
-	}
-	public void setVals(String vals) {
-		this.vals = vals;
-	}
 	public Integer getId() {
 		return id;
 	}
@@ -136,12 +132,6 @@ public class ParamDto extends BaseEntity {
 	public void setDsid(String dsid) {
 		this.dsid = dsid;
 	}
-	public String getValStrs() {
-		return valStrs;
-	}
-	public void setValStrs(String valStrs) {
-		this.valStrs = valStrs;
-	}
 	public String getGrouptype() {
 		return grouptype;
 	}
@@ -166,6 +156,23 @@ public class ParamDto extends BaseEntity {
 	public void setCalc(Integer calc) {
 		this.calc = calc;
 	}
+
+	public List<String> getVals() {
+		return vals;
+	}
+
+	public void setVals(List<String> vals) {
+		this.vals = vals;
+	}
+
+	public List<String> getValStrs() {
+		return valStrs;
+	}
+
+	public void setValStrs(List<String> valStrs) {
+		this.valStrs = valStrs;
+	}
+
 	@Override
 	public void validate() {
 		 

+ 9 - 9
src/main/java/com/ruisitech/bi/service/bireport/ChartService.java

@@ -245,8 +245,8 @@ public class ChartService extends BaseCompService {
 	 * 其中第二个参数只用在图形中,当用户没选X轴时(xcol)时,用这个做默认xcol
 	 * 其中第三个参数只用在图形中,当用户没选图例(scol)时,用这个做默认图例
 	 * release 表示当前为发布状态, 0 表示不是发布,1表示发布到多维分析,2表示发布到仪表盘
-	 * @param sqlVO
-	 * @param ser
+	 * @param chart
+	 * @param release
 	 * @return
 	 * @throws ParseException
 	 */
@@ -358,7 +358,7 @@ public class ChartService extends BaseCompService {
 				if(dim.getDay() != null){
 					sql.append(" and " + dim.getColname() + " between '"+dim.getDay().getStartDay()+"' and '" + dim.getDay().getEndDay()+"'");
 				}else
-				if(dim.getVals() != null && dim.getVals().length() > 0){
+				if(dim.getVals() != null && dim.getVals().size() > 0){
 					String vls = RSBIUtils.dealStringParam(dim.getVals());
 					sql.append(" and " + dim.getColname() + " in ("+vls+")");
 				}
@@ -367,15 +367,15 @@ public class ChartService extends BaseCompService {
 				if(dim.getMonth() != null){
 					sql.append(" and " + dim.getColname() + " between '"+dim.getMonth().getStartMonth()+"' and '" + dim.getMonth().getEndMonth()+"'");
 				}else
-				if(dim.getVals() != null && dim.getVals().length() > 0){
+				if(dim.getVals() != null && dim.getVals().size() > 0){
 					String vls = RSBIUtils.dealStringParam(dim.getVals());
 					sql.append(" and " + dim.getColname() + " in ("+vls+")");
 					//isDealDate = true;
 				}
 			}else{
 				//限制维度筛选
-				if(dim.getVals() != null && dim.getVals().length() > 0){
-					String  vls = dim.getVals();
+				if(dim.getVals() != null && dim.getVals().size() > 0){
+					String  vls = RSBIUtils.dealIntegerParam(dim.getVals());
 					if("string".equalsIgnoreCase(dim.getValType())){
 						vls = RSBIUtils.dealStringParam(dim.getVals());
 					}
@@ -405,9 +405,9 @@ public class ChartService extends BaseCompService {
 					sql.append(" #if($"+alias+" != '') and " + tableAlias.get(tname) + "." +colname + " = $"+alias + " #end");   //仪表盘发布,日期,月份只有一个参数
 				}
 			}else{
-				if(release == 0 && param.getVals() != null && param.getVals().length() > 0){
+				if(release == 0 && param.getVals() != null && param.getVals().size() > 0){
 					//字符串特殊处理
-					String  vls = param.getVals();
+					String  vls = RSBIUtils.dealIntegerParam(param.getVals());
 					if("string".equalsIgnoreCase(param.getValType())){
 						vls = RSBIUtils.dealStringParam(param.getVals());
 					}
@@ -539,7 +539,7 @@ public class ChartService extends BaseCompService {
 	/**
 	 * 创建图形的dataCenter
 	 * @param sql
-	 * @param sqlVO
+	 * @param chartJson
 	 * @return
 	 * @throws IOException
 	 */

+ 2 - 5
src/main/java/com/ruisitech/bi/service/bireport/ReportService.java

@@ -96,7 +96,7 @@ public class ReportService extends BaseCompService {
 					String name = param.getName();
 					String type = param.getType();
 					String colname = param.getColname();
-					String values = param.getVals();
+					List<String> values = param.getVals();
 					
 					InputField input = null;
 					InputField input2 = null;
@@ -106,7 +106,7 @@ public class ReportService extends BaseCompService {
 						String template = TemplateManager.getInstance().createTemplate(sql);
 						target.setTemplateName(template);
 						input = target;
-						input.setDefaultValue(values == null ? "" : values);
+						input.setDefaultValue(values == null ? "" : values.get(0));
 						input.setDesc(name);
 						input.setId(colname);
 					}else if("day".equalsIgnoreCase(type)){
@@ -189,9 +189,6 @@ public class ReportService extends BaseCompService {
 	/**
 	 * 
 	 * @param mv
-	 * @param tableJson
-	 * @param kpiJson
-	 * @param params
 	 * @param release  判断当前是否为发布状态, 0 表示不是发布,1表示发布到多维分析,2表示发布到仪表盘
 	 * @return
 	 * @throws IOException

+ 25 - 27
src/main/java/com/ruisitech/bi/service/bireport/TableService.java

@@ -177,9 +177,7 @@ public class TableService extends BaseCompService {
 	
 	/**
 	 * 生成表格SQL
-	 * @param sqlVO
-	 * @param tinfo
-	 * @param params
+	 * @param table
 	 * @param release  判断当前是否为发布状态, 0 表示不是发布,1表示发布到多维分析,2表示发布到仪表盘
 	 * @return
 	 * @throws ParseException
@@ -271,17 +269,17 @@ public class TableService extends BaseCompService {
 					}
 					sql.append(" and " + dim.getColname() + " between '"+start+"' and '" + end + "'");
 				}else
-				if(dim.getVals() != null && dim.getVals().length() > 0){
-					String ret = dim.getVals();
+				if(dim.getVals() != null && dim.getVals().size() > 0){
+					String ret = RSBIUtils.dealIntegerParam(dim.getVals());
 					if(jstype != 0){
 						ret = resetVals(ret, dim.getType(), dim.getDateformat(), jstype);
 						GridFilterContext filter = new GridFilterContext();
 						filter.setColumn(dim.getAlias());
 						filter.setFilterType(GridFilter.in);
-						filter.setValue(dim.getVals());
+						filter.setValue(ret);
 						this.filters.add(filter);
 					}
-					ret = RSBIUtils.dealStringParam(ret);
+					ret = RSBIUtils.dealStringParam(dim.getVals());
 					sql.append(" and " + dim.getColname()+ " in ("+ret+")");
 				}
 			}
@@ -305,37 +303,37 @@ public class TableService extends BaseCompService {
 					}
 					sql.append(" and " + dim.getColname()+ " between '"+start+"' and '" + end + "'");
 				}else
-				if(dim.getVals() != null && dim.getVals().length() > 0){
+				if(dim.getVals() != null && dim.getVals().size() > 0){
 					//如果有计算指标,需要重写数据值列表
-					String ret = dim.getVals();
+					String ret = RSBIUtils.dealIntegerParam(dim.getVals());
 					if(jstype != 0){
 						ret = resetVals(ret, dim.getType(), dim.getDateformat(), jstype);
 						GridFilterContext filter = new GridFilterContext();
 						filter.setColumn(dim.getAlias());
 						filter.setFilterType(GridFilter.in);
-						filter.setValue(dim.getVals());
+						filter.setValue(ret);
 						this.filters.add(filter);
 					}
-					ret = RSBIUtils.dealStringParam(ret);
+					ret = RSBIUtils.dealStringParam(dim.getVals());
 					sql.append(" and " + dim.getColname() + " in ("+ret+")");
 				}
 			} else {
 				//限制维度筛选
-				if(dim.getVals() != null && dim.getVals().length() > 0){
+				if(dim.getVals() != null && dim.getVals().size() > 0){
 					String vls = null;
 					if( jstype != 0){  //有计算指标,需要从写时间值
-						vls = resetVals(dim.getVals(), dim.getType(), dim.getDateformat(), jstype);
+						vls = resetVals(RSBIUtils.dealIntegerParam(dim.getVals()), dim.getType(), dim.getDateformat(), jstype);
 						GridFilterContext filter = new GridFilterContext();
 						filter.setColumn(dim.getAlias());
 						filter.setFilterType(GridFilter.in);
-						filter.setValue(dim.getVals());
+						filter.setValue(RSBIUtils.dealIntegerParam(dim.getVals()));
 						this.filters.add(filter);
 					}else{
-						vls = dim.getVals();
+						vls = RSBIUtils.dealIntegerParam(dim.getVals());
 					}
 					//处理字符串
 					if("string".equalsIgnoreCase(dim.getValType())){
-						vls = RSBIUtils.dealStringParam(vls);
+						vls = RSBIUtils.dealStringParam(dim.getVals());
 					}
 					sql.append(" and " + (dim.getCalc() == 1 ? dim.getColname(): tableAlias.get(dim.getTname()) + "." + dim.getColname()) + " in ("+vls+")");
 				}
@@ -389,14 +387,14 @@ public class TableService extends BaseCompService {
 					this.filters.add(filter);
 				}
 			}else{
-				if(release == 0 && param.getVals() != null && param.getVals().length() > 0){
+				if(release == 0 && param.getVals() != null && param.getVals().size() > 0){
 					//字符串特殊处理
-					String  vls = param.getVals();
+					String  vls = RSBIUtils.dealIntegerParam(param.getVals());
 					if(jstype != 0 && ("year".equals(tp) || "quarter".equals(tp))){
 						vls = resetVals(vls, tp, param.getDateformat(), jstype);
 					}
 					if("string".equalsIgnoreCase(valType)){
-						vls = RSBIUtils.dealStringParam(vls);
+						vls = RSBIUtils.dealStringParam(param.getVals());
 					}
 					sql.append(" and " + (param.getCalc() == 0 ?(tableAlias.get(tname) + "."):"") +colname + " in ("+vls+")");
 				}else if(release == 1 || release == 2){
@@ -407,8 +405,8 @@ public class TableService extends BaseCompService {
 					GridFilterContext filter = new GridFilterContext();
 					filter.setColumn(param.getAlias());
 					filter.setFilterType(GridFilter.in);
-					if(release == 0 && param.getVals() != null && param.getVals().length() > 0){
-						filter.setValue(param.getVals());
+					if(release == 0 && param.getVals() != null && param.getVals().size() > 0){
+						filter.setValue(RSBIUtils.dealIntegerParam(param.getVals()));
 					}else if(release == 1 || release == 2){
 						filter.setValue("${"+colname+"}");
 					}
@@ -813,7 +811,7 @@ public class TableService extends BaseCompService {
 					cf.setDateType("day");
 					cf.setDateTypeFmt(obj.getDateformat());
 					cf.setUselink(uselink);
-					cf.setValue(obj.getVals());
+					cf.setValue(RSBIUtils.dealIntegerParam(obj.getVals()));
 					cf.setMulti(true);
 					cf.setShowWeek(false);
 					cf.setDesc(obj.getDimdesc());
@@ -864,7 +862,7 @@ public class TableService extends BaseCompService {
 						cf.setDateType("day");
 						cf.setDateTypeFmt(obj.getDateformat());
 						cf.setUselink(uselink);
-						cf.setValue(obj.getVals());
+						cf.setValue(RSBIUtils.dealIntegerParam(obj.getVals()));
 						cf.setMulti(true);
 						cf.setShowWeek(false);
 						cf.setDesc(obj.getDimdesc());
@@ -917,7 +915,7 @@ public class TableService extends BaseCompService {
 					cf.setDateType("month");
 					cf.setDateTypeFmt(obj.getDateformat());
 					cf.setUselink(uselink);
-					cf.setValue(obj.getVals());
+					cf.setValue(RSBIUtils.dealIntegerParam(obj.getVals()));
 					cf.setMulti(true);
 					cf.setDesc(obj.getDimdesc());
 					String alias = obj.getAlias();
@@ -967,7 +965,7 @@ public class TableService extends BaseCompService {
 						cf.setDateType("month");
 						cf.setDateTypeFmt(obj.getDateformat());
 						cf.setUselink(uselink);
-						cf.setValue(obj.getVals());
+						cf.setValue(RSBIUtils.dealIntegerParam(obj.getVals()));
 						cf.setMulti(true);
 						cf.setDesc(obj.getDimdesc());
 						String alias = obj.getAlias();
@@ -1016,7 +1014,7 @@ public class TableService extends BaseCompService {
 					cf.setTop(obj.getTop());
 					cf.setTopType(obj.getTopType());
 					cf.setUselink(uselink);
-					cf.setValue(obj.getVals());
+					cf.setValue(RSBIUtils.dealIntegerParam(obj.getVals()));
 					cf.setMulti(true);
 					cf.setSubs(new ArrayList<CrossField>());
 					tmp.add(cf);
@@ -1104,7 +1102,7 @@ public class TableService extends BaseCompService {
 						cf.setTop(obj.getTop());
 						cf.setTopType(obj.getTopType());
 						cf.setUselink(uselink);
-						cf.setValue(obj.getVals());
+						cf.setValue(RSBIUtils.dealIntegerParam(obj.getVals()));
 						cf.setMulti(true);
 						cf.setSubs(new ArrayList<CrossField>());
 						cf.setParent(tp);

+ 16 - 9
src/main/java/com/ruisitech/bi/util/RSBIUtils.java

@@ -15,10 +15,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import java.security.NoSuchAlgorithmException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
 
 public final class RSBIUtils {
 	
@@ -78,13 +75,23 @@ public final class RSBIUtils {
 		return UUID.randomUUID().toString().replace("-","");
 	}
 	
-	public static String dealStringParam(String vals){
-		String[] vls = vals.split(",");
+	public static String dealStringParam(List<String> vals){
 		StringBuffer sb = new StringBuffer();
-		for(int i=0; i<vls.length; i++){
-			String v = vls[i];
+		for(int i=0; i<vals.size(); i++){
+			String v = vals.get(i);
 			sb.append("'" + v + "'");
-			if(i != vls.length - 1){
+			if(i != vals.size() - 1){
+				sb.append(",");
+			}
+		}
+		return sb.toString();
+	}
+	public static String dealIntegerParam(List<String> vals){
+		StringBuffer sb = new StringBuffer();
+		for(int i=0; i<vals.size(); i++){
+			String v = vals.get(i);
+			sb.append(v);
+			if(i != vals.size() - 1){
 				sb.append(",");
 			}
 		}

+ 10 - 10
src/main/java/com/ruisitech/bi/web/bireport/DimController.java

@@ -4,18 +4,20 @@ import com.ruisitech.bi.entity.bireport.ParamDto;
 import com.ruisitech.bi.entity.model.Dimension;
 import com.ruisitech.bi.service.bireport.OlapService;
 import com.ruisitech.bi.service.model.DimensionService;
+import com.ruisitech.bi.util.BaseController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 @Controller
 @RequestMapping(value = "/bireport")
-public class DimController {
+public class DimController extends BaseController {
 	
 	@Autowired
 	private OlapService service;
@@ -30,19 +32,17 @@ public class DimController {
 	}
 	
 	@RequestMapping(value="/paramFilter.action")
-	public String paramFilter(ParamDto param, ModelMap model) throws Exception{
-		
+	public @ResponseBody
+	Object paramFilter(ParamDto param) throws Exception{
 		Dimension d = dimService.getDimInfo(param.getId(), param.getCubeId());
 		List<Map<String, Object>> ls = service.paramFilter(d, null, param.getDsid());
-		model.addAttribute("datas", ls);
-		model.addAttribute("dimType", d.getType());
-		model.addAttribute("vals", param.getVals());
-		model.addAttribute("dimId", param.getId());
+		Map<String, Object> ret = new HashMap<>();
+		ret.put("datas", ls);
 		if(d.getType().equals("month") || d.getType().equals("day")){
-			model.addAttribute("st", param.getSt());
-			model.addAttribute("end", param.getEnd());
+			ret.put("st", param.getSt());
+			ret.put("end", param.getEnd());
 		}
-		return "bireport/DimFilter-pfilter";
+		return super.buildSucces(ret);
 	}
 	
 	@RequestMapping(value="/paramSearch.action")