DataStatisticsController.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //package com.fdage.controller;
  2. //
  3. //import com.fdage.constant.ConstantExcel;
  4. //import com.fdage.respon.ResponCollection;
  5. //import com.fdage.respon.ResponStatistics;
  6. //import com.fdage.service.ICollectionService;
  7. //import com.fdage.service.IExhibitionService;
  8. //import com.fdage.util.AjaxJson;
  9. //import com.fdage.util.ExcelUtil;
  10. //import io.swagger.annotations.Api;
  11. //import io.swagger.annotations.ApiOperation;
  12. //import lombok.extern.slf4j.Slf4j;
  13. //import org.springframework.beans.factory.annotation.Autowired;
  14. //import org.springframework.beans.factory.annotation.Value;
  15. //import org.springframework.stereotype.Controller;
  16. //import org.springframework.web.bind.annotation.PostMapping;
  17. //import org.springframework.web.bind.annotation.RequestMapping;
  18. //import org.springframework.web.bind.annotation.ResponseBody;
  19. //
  20. //import javax.servlet.http.HttpServletRequest;
  21. //import javax.servlet.http.HttpServletResponse;
  22. //import java.io.*;
  23. //import java.net.URLEncoder;
  24. //import java.text.DateFormat;
  25. //import java.text.SimpleDateFormat;
  26. //import java.util.*;
  27. //
  28. ///**
  29. // * Created by Hb_zzZ on 2020/9/8.
  30. // */
  31. //@Api(tags = "数据统计模块")
  32. //@Controller
  33. //@RequestMapping("/zhoushan/statistics")
  34. //@Slf4j
  35. //public class DataStatisticsController {
  36. //
  37. // @Autowired
  38. // private IExhibitionService exhibitionService;
  39. //
  40. // @Autowired
  41. // private ICollectionService collectionService;
  42. //
  43. // @Value("${upload.collection}")
  44. // private String collectionPath;
  45. //
  46. // @PostMapping("collectionTotal")
  47. // @ResponseBody
  48. // @ApiOperation("数据总量")
  49. // public AjaxJson collectionTotal(){
  50. // return AjaxJson.success(collectionService.findList(null));
  51. // }
  52. //
  53. // @PostMapping("exportCollectionTotal")
  54. // @ResponseBody
  55. // @ApiOperation("数据总量")
  56. // public void exportCollectionTotal(HttpServletRequest request, HttpServletResponse response){
  57. // List<ResponCollection> list = collectionService.findList(null);
  58. //
  59. // //导出的数据
  60. // int serNum = 1;
  61. // Map<String, Object> item = null;
  62. // List<Map> dataList = new ArrayList<Map>();
  63. //
  64. // for(ResponCollection collection : list){
  65. // item = new HashMap();
  66. // item.put(ConstantExcel.COLLECTION_NAME[0], String.valueOf(serNum));
  67. // item.put(ConstantExcel.COLLECTION_NAME[1], collection.getName());
  68. // item.put(ConstantExcel.COLLECTION_NAME[2], collection.getTypeName());
  69. // item.put(ConstantExcel.COLLECTION_NAME[3], collection.getTimeName());
  70. // item.put(ConstantExcel.COLLECTION_NAME[4], collection.getLikeNum());
  71. // item.put(ConstantExcel.COLLECTION_NAME[5], collection.getDownloadNum());
  72. // item.put(ConstantExcel.COLLECTION_NAME[6], collection.getSearchNum());
  73. //
  74. // serNum++;
  75. // dataList.add(item);
  76. // }
  77. //
  78. // try{
  79. // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  80. // String dateStr = dateFormat.format(new Date());
  81. // String fileName = "文物数据-" + dateStr + ".xls";
  82. // File file = new File(collectionPath + File.separator + fileName + ".xls");
  83. //
  84. // ExcelUtil.writeExcel(dataList, collectionPath + File.separator + fileName + ".xls");
  85. //
  86. // String agent = request.getHeader("User-Agent");
  87. // if (agent != null && (agent.contains("MSIE")||agent.contains("Trident"))) {
  88. // fileName = URLEncoder.encode(fileName, "UTF-8");
  89. // } else {
  90. // //非IE浏览器的处理:
  91. // fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
  92. // }
  93. // response.setHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");
  94. // response.setContentType(request.getServletContext().getMimeType(fileName));
  95. // response.setContentLength((int) file.length());
  96. // output(response, file);
  97. // }catch (Exception e){
  98. // e.printStackTrace();
  99. // }
  100. // }
  101. //
  102. // @PostMapping("total")
  103. // @ResponseBody
  104. // @ApiOperation("数据总量")
  105. // public AjaxJson total(){
  106. //
  107. // ResponStatistics result = collectionService.collectionTotal();
  108. //
  109. // // 2021-08-16 by owen 改用流量量
  110. //// Long exhibitionTotal = exhibitionService.exhibitionTotal();
  111. // Long exhibitionTotal = collectionService.countVisit();
  112. //
  113. //
  114. //
  115. // result.setExhibitionTotal(exhibitionTotal);
  116. //
  117. // result.setExhibitionList(exhibitionService.findListOrderBy());
  118. //
  119. // Map<String, String> map = new HashMap<>();
  120. // map.put("order", "desc");
  121. // map.put("sidx", "a.search_num");
  122. //// result.setCollectionSearchList(collectionService.findListOrderBy(map).subList(0, 5));
  123. //
  124. // List<ResponCollection> listOrderBy = collectionService.findListOrderBy(map);
  125. // int max = listOrderBy.size() > 5 ? 5 : listOrderBy.size();
  126. // result.setCollectionSearchList(listOrderBy.subList(0, max));
  127. //
  128. //
  129. //
  130. //
  131. // map.put("sidx", "a.like_num");
  132. //// result.setCollectionLikeList(collectionService.findListOrderBy(map).subList(0, 10));
  133. //
  134. // List<ResponCollection> listOrderBy2 = collectionService.findListOrderBy(map);
  135. // int max2 = listOrderBy2.size() > 10 ? 10 : listOrderBy2.size();
  136. // result.setCollectionLikeList(listOrderBy2.subList(0, max2));
  137. // map.put("sidx", "a.open_num");
  138. //// result.setCollectionOpenList(collectionService.findListOrderBy(map).subList(0, 3));
  139. // List<ResponCollection> list3 = collectionService.findListOrderBy(map);
  140. // int max3 = listOrderBy2.size() > 3 ? 3 : listOrderBy2.size();
  141. //
  142. // result.setCollectionOpenList(list3.subList(0, max3));
  143. //
  144. // result.setCollectionTypeTotal(collectionService.typeTotal());
  145. //
  146. // return AjaxJson.success(result);
  147. // }
  148. //
  149. // private static void output(HttpServletResponse resp, File file) {
  150. // OutputStream os = null;
  151. // BufferedInputStream bis = null;
  152. // byte[] buff = new byte[1024];
  153. // try {
  154. // os = resp.getOutputStream();
  155. // bis = new BufferedInputStream(new FileInputStream(file));
  156. // int i = 0;
  157. // while ((i = bis.read(buff)) != -1) {
  158. // os.write(buff, 0, i);
  159. // os.flush();
  160. // }
  161. // } catch (IOException e) {
  162. // e.printStackTrace();
  163. // } finally {
  164. // try {
  165. // bis.close();
  166. // } catch (IOException e) {
  167. // e.printStackTrace();
  168. // }
  169. // }
  170. // }
  171. //}