Guest User

Untitled

a guest
Nov 21st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. @RequestMapping(value = "/getData/{from}/{to}/{groupType}/{status}/", method = RequestMethod.POST)
  2. public @ResponseBody ResponseEntity<?> getData(
  3. @PathVariable("status") String status,
  4. @PathVariable("from") String dateFrom,
  5. @PathVariable("to") String dateTo,
  6. @PathVariable("groupType") String groupType,
  7. @RequestBody String json)
  8. throws Exception {
  9.  
  10. json = StringUtil.removeBackslash(URLDecoder.decode(json, "UTF-8")).replaceAll("json=", "");
  11. Map<String, Object> result = manager.createEmptyResult();
  12. Map<String, Object> resultTotal = manager.createEmptyResult();
  13. try {
  14. Map<String, Object> data = manager.getTableData(null, "null", "null", "null", "null", "null", null, dateFrom, dateTo, groupType,
  15. status, json, (groupType.equals(BIGroupBy.NO_GROUPING) ? "revenue" : groupType), false, true, false);
  16.  
  17. if(data == null) {
  18. return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
  19. }
  20.  
  21. result.putAll(data);
  22.  
  23. Map<String, Object> dataTotal = manager.getTotalData(null,
  24. "null", "null", "null", "null", "null", status, dateFrom, dateTo, groupType, json, false, true);
  25.  
  26. if(dataTotal == null) {
  27. return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
  28. }
  29.  
  30. resultTotal.putAll(dataTotal);
  31. } catch (Exception e) {
  32. log.error("Getting data failed!!!", e);
  33. }
  34. return new ResponseEntity<>(result, HttpStatus.OK);
  35. }
  36.  
  37. public Map<String, Object> createEmptyResult() throws Exception {
  38. Map<String, Object> result = new HashMap<String, Object>();
  39. result.put("total", "0");
  40. result.put("data", new ArrayList<String>());
  41. return result;
  42. }
  43.  
  44. Map<String, Object> resultNew = manager.createEmptyResult();
  45. resultNew.putAll(result);
  46. resultNew.putAll(resultTotal);
Add Comment
Please, Sign In to add comment