123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- //package com.fdage.controller;
- //
- //import com.fdage.constant.ConstantExcel;
- //import com.fdage.respon.ResponCollection;
- //import com.fdage.respon.ResponStatistics;
- //import com.fdage.service.ICollectionService;
- //import com.fdage.service.IExhibitionService;
- //import com.fdage.util.AjaxJson;
- //import com.fdage.util.ExcelUtil;
- //import io.swagger.annotations.Api;
- //import io.swagger.annotations.ApiOperation;
- //import lombok.extern.slf4j.Slf4j;
- //import org.springframework.beans.factory.annotation.Autowired;
- //import org.springframework.beans.factory.annotation.Value;
- //import org.springframework.stereotype.Controller;
- //import org.springframework.web.bind.annotation.PostMapping;
- //import org.springframework.web.bind.annotation.RequestMapping;
- //import org.springframework.web.bind.annotation.ResponseBody;
- //
- //import javax.servlet.http.HttpServletRequest;
- //import javax.servlet.http.HttpServletResponse;
- //import java.io.*;
- //import java.net.URLEncoder;
- //import java.text.DateFormat;
- //import java.text.SimpleDateFormat;
- //import java.util.*;
- //
- ///**
- // * Created by Hb_zzZ on 2020/9/8.
- // */
- //@Api(tags = "数据统计模块")
- //@Controller
- //@RequestMapping("/zhoushan/statistics")
- //@Slf4j
- //public class DataStatisticsController {
- //
- // @Autowired
- // private IExhibitionService exhibitionService;
- //
- // @Autowired
- // private ICollectionService collectionService;
- //
- // @Value("${upload.collection}")
- // private String collectionPath;
- //
- // @PostMapping("collectionTotal")
- // @ResponseBody
- // @ApiOperation("数据总量")
- // public AjaxJson collectionTotal(){
- // return AjaxJson.success(collectionService.findList(null));
- // }
- //
- // @PostMapping("exportCollectionTotal")
- // @ResponseBody
- // @ApiOperation("数据总量")
- // public void exportCollectionTotal(HttpServletRequest request, HttpServletResponse response){
- // List<ResponCollection> list = collectionService.findList(null);
- //
- // //导出的数据
- // int serNum = 1;
- // Map<String, Object> item = null;
- // List<Map> dataList = new ArrayList<Map>();
- //
- // for(ResponCollection collection : list){
- // item = new HashMap();
- // item.put(ConstantExcel.COLLECTION_NAME[0], String.valueOf(serNum));
- // item.put(ConstantExcel.COLLECTION_NAME[1], collection.getName());
- // item.put(ConstantExcel.COLLECTION_NAME[2], collection.getTypeName());
- // item.put(ConstantExcel.COLLECTION_NAME[3], collection.getTimeName());
- // item.put(ConstantExcel.COLLECTION_NAME[4], collection.getLikeNum());
- // item.put(ConstantExcel.COLLECTION_NAME[5], collection.getDownloadNum());
- // item.put(ConstantExcel.COLLECTION_NAME[6], collection.getSearchNum());
- //
- // serNum++;
- // dataList.add(item);
- // }
- //
- // try{
- // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- // String dateStr = dateFormat.format(new Date());
- // String fileName = "文物数据-" + dateStr + ".xls";
- // File file = new File(collectionPath + File.separator + fileName + ".xls");
- //
- // ExcelUtil.writeExcel(dataList, collectionPath + File.separator + fileName + ".xls");
- //
- // String agent = request.getHeader("User-Agent");
- // if (agent != null && (agent.contains("MSIE")||agent.contains("Trident"))) {
- // fileName = URLEncoder.encode(fileName, "UTF-8");
- // } else {
- // //非IE浏览器的处理:
- // fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
- // }
- // response.setHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");
- // response.setContentType(request.getServletContext().getMimeType(fileName));
- // response.setContentLength((int) file.length());
- // output(response, file);
- // }catch (Exception e){
- // e.printStackTrace();
- // }
- // }
- //
- // @PostMapping("total")
- // @ResponseBody
- // @ApiOperation("数据总量")
- // public AjaxJson total(){
- //
- // ResponStatistics result = collectionService.collectionTotal();
- //
- // // 2021-08-16 by owen 改用流量量
- //// Long exhibitionTotal = exhibitionService.exhibitionTotal();
- // Long exhibitionTotal = collectionService.countVisit();
- //
- //
- //
- // result.setExhibitionTotal(exhibitionTotal);
- //
- // result.setExhibitionList(exhibitionService.findListOrderBy());
- //
- // Map<String, String> map = new HashMap<>();
- // map.put("order", "desc");
- // map.put("sidx", "a.search_num");
- //// result.setCollectionSearchList(collectionService.findListOrderBy(map).subList(0, 5));
- //
- // List<ResponCollection> listOrderBy = collectionService.findListOrderBy(map);
- // int max = listOrderBy.size() > 5 ? 5 : listOrderBy.size();
- // result.setCollectionSearchList(listOrderBy.subList(0, max));
- //
- //
- //
- //
- // map.put("sidx", "a.like_num");
- //// result.setCollectionLikeList(collectionService.findListOrderBy(map).subList(0, 10));
- //
- // List<ResponCollection> listOrderBy2 = collectionService.findListOrderBy(map);
- // int max2 = listOrderBy2.size() > 10 ? 10 : listOrderBy2.size();
- // result.setCollectionLikeList(listOrderBy2.subList(0, max2));
- // map.put("sidx", "a.open_num");
- //// result.setCollectionOpenList(collectionService.findListOrderBy(map).subList(0, 3));
- // List<ResponCollection> list3 = collectionService.findListOrderBy(map);
- // int max3 = listOrderBy2.size() > 3 ? 3 : listOrderBy2.size();
- //
- // result.setCollectionOpenList(list3.subList(0, max3));
- //
- // result.setCollectionTypeTotal(collectionService.typeTotal());
- //
- // return AjaxJson.success(result);
- // }
- //
- // private static void output(HttpServletResponse resp, File file) {
- // OutputStream os = null;
- // BufferedInputStream bis = null;
- // byte[] buff = new byte[1024];
- // try {
- // os = resp.getOutputStream();
- // bis = new BufferedInputStream(new FileInputStream(file));
- // int i = 0;
- // while ((i = bis.read(buff)) != -1) {
- // os.write(buff, 0, i);
- // os.flush();
- // }
- // } catch (IOException e) {
- // e.printStackTrace();
- // } finally {
- // try {
- // bis.close();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- // }
- // }
- //}
|