|
@@ -1,14 +1,27 @@
|
|
package org.jeecg.modules.ctop.controller;
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
|
|
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
+import org.jeecg.common.constant.AccountReportConstants;
|
|
|
|
+import org.jeecg.common.util.JsonResourceUtil;
|
|
import org.jeecg.modules.ctop.service.IMaterialTopService;
|
|
import org.jeecg.modules.ctop.service.IMaterialTopService;
|
|
import org.jeecg.modules.ctop.vo.MaterialTopVO;
|
|
import org.jeecg.modules.ctop.vo.MaterialTopVO;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Created by JQ.bi on 2020.5.21
|
|
* Created by JQ.bi on 2020.5.21
|
|
*/
|
|
*/
|
|
@@ -47,4 +60,46 @@ public class MaterialTopCtrl {
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @PostMapping("/top/excel")
|
|
|
|
+ public void getExcelReport(@RequestBody JSONObject requestBody,
|
|
|
|
+ @RequestParam(defaultValue = "cost") String target,
|
|
|
|
+ @RequestParam(defaultValue = "desc") String order,
|
|
|
|
+ HttpServletRequest request,
|
|
|
|
+ HttpServletResponse response) {
|
|
|
|
+
|
|
|
|
+ String startDate= requestBody.getString("startDate");
|
|
|
|
+ String endDate= requestBody.getString("endDate");
|
|
|
|
+ List<MaterialTopVO> excelData= materialTopService.selectList(endDate,startDate, target, order);
|
|
|
|
+
|
|
|
|
+ List<List<Object>> excelList= new ArrayList<>();
|
|
|
|
+ excelData.forEach(data->{
|
|
|
|
+ List<Object> temp= new ArrayList<>();
|
|
|
|
+ temp.add(data.getUrl());
|
|
|
|
+ temp.add(data.getName());
|
|
|
|
+ temp.add(data.getCost());
|
|
|
|
+ temp.add(data.getClick());
|
|
|
|
+ temp.add(data.getShowNum());
|
|
|
|
+ temp.add(data.getPlay3s());
|
|
|
|
+ temp.add(data.getPlay10s());
|
|
|
|
+ temp.add(data.getActive());
|
|
|
|
+ temp.add(data.getPay());
|
|
|
|
+ temp.add(data.getResidue());
|
|
|
|
+ temp.add(data.getRegister());
|
|
|
|
+ excelList.add(temp);
|
|
|
|
+ });
|
|
|
|
+ try{
|
|
|
|
+ String[] headers = {"视频","素材名","消耗","点击数","展示数","3s播放数","10s播放数","行为数","支付数","次留数","注册数"};
|
|
|
|
+ OutputStream os = response.getOutputStream();
|
|
|
|
+ ExportExcelUtils eeu = new ExportExcelUtils();
|
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
|
+ eeu.exportExcel(workbook, 0, "top素材", headers, excelList);
|
|
|
|
+ HttpUtils.setResponseHeader(response, "top素材.xlsx");
|
|
|
|
+ workbook.write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ os.close();
|
|
|
|
+ }catch (IOException e){
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|