Browse Source

参数重构

rsbi 4 years ago
parent
commit
6ce5fda920
1 changed files with 18 additions and 34 deletions
  1. 18 34
      src/main/java/com/ruisitech/bi/web/bireport/DimController.java

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

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Controller
 @RequestMapping(value = "/bireport")
@@ -33,44 +34,27 @@ public class DimController extends BaseController {
 	
 	@RequestMapping(value="/paramFilter.action")
 	public @ResponseBody
-	Object paramFilter(ParamDto param) throws Exception{
+	Object paramFilter(ParamDto param, String keyword) throws Exception{
 		Dimension d = dimService.getDimInfo(param.getId(), param.getCubeId());
-		List<Map<String, Object>> ls = service.paramFilter(d, null, param.getDsid());
+		List<Map<String, Object>> ls = service.paramFilter(d, keyword, param.getDsid());
 		Map<String, Object> ret = new HashMap<>();
 		ret.put("datas", ls);
-		if(d.getType().equals("month") || d.getType().equals("day")){
-			ret.put("st", param.getSt());
-			ret.put("end", param.getEnd());
+		if(ls.size() > 0) {
+			if (d.getType().equals("month") || d.getType().equals("day")) {
+				//排序
+				ls = ls.stream().sorted((m1, m2)->{
+					String v1 = (String)m1.get("id");
+					String v2 = (String)m2.get("id");
+					return v1.compareTo(v2);
+				}).collect(Collectors.toList());
+				Map<String, Object> first = ls.get(0);
+				Map<String, Object> end = ls.get(ls.size() - 1);
+
+				ret.put("st", first.get("id"));
+				ret.put("end", end.get("id"));
+				ret.remove("datas");
+			}
 		}
 		return super.buildSucces(ret);
 	}
-	
-	@RequestMapping(value="/paramSearch.action")
-	public String paramSearch(ParamDto param, String keyword, ModelMap model) throws Exception{
-		
-		Dimension d = dimService.getDimInfo(param.getId(), param.getCubeId());
-		List<Map<String, Object>> ls = service.paramFilter(d, keyword, param.getDsid());
-		model.addAttribute("datas", ls);
-		model.addAttribute("dimType", d.getType());
-		model.addAttribute("vals", param.getVals());
-		model.addAttribute("dimId", param.getId());
-		return "bireport/DimFilter-search";
-	}
-	
-	@RequestMapping(value="/DimFilter.action")
-	public String dimFilter(ParamDto param, ModelMap model) 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());
-		if(d.getType().equals("month") || d.getType().equals("day")){
-			model.addAttribute("st", param.getSt());
-			model.addAttribute("end", param.getEnd());
-		}
-		model.addAttribute("filtertype", param.getFiltertype());
-		model.addAttribute("dateformat", param.getDateformat());
-		return "bireport/DimFilter";
-	}
 }