|
@@ -1,16 +1,30 @@
|
|
package org.jeecg.ctop.material.controller;
|
|
package org.jeecg.ctop.material.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.google.gson.JsonObject;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
|
|
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.ctop.material.constants.Check;
|
|
import org.jeecg.ctop.material.constants.Check;
|
|
|
|
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateAccountVo;
|
|
|
|
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo;
|
|
import org.jeecg.ctop.material.mapper.MaterialStareMapper;
|
|
import org.jeecg.ctop.material.mapper.MaterialStareMapper;
|
|
import org.jeecg.ctop.material.service.MaterialStareService;
|
|
import org.jeecg.ctop.material.service.MaterialStareService;
|
|
import org.jeecg.ctop.material.service.impl.MaterialStareServiceImpl;
|
|
import org.jeecg.ctop.material.service.impl.MaterialStareServiceImpl;
|
|
|
|
+import org.jeecgframework.poi.excel.ExcelExportUtil;
|
|
|
|
+import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
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.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
|
+import java.net.URLEncoder;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -28,6 +42,9 @@ public class KuaiShouMaterialStareController {
|
|
@Autowired
|
|
@Autowired
|
|
MaterialStareService materialStareService;
|
|
MaterialStareService materialStareService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MaterialStareMapper materialStareMapper;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
@@ -296,7 +313,7 @@ public class KuaiShouMaterialStareController {
|
|
/**
|
|
/**
|
|
* 获取用户下级的项目以及账户信息
|
|
* 获取用户下级的项目以及账户信息
|
|
*
|
|
*
|
|
- * @param requestJson
|
|
|
|
|
|
+ * @param
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@GetMapping(value = "/participateListByMediaIdAllSubordinate")
|
|
@GetMapping(value = "/participateListByMediaIdAllSubordinate")
|
|
@@ -326,6 +343,160 @@ public class KuaiShouMaterialStareController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ @GetMapping("/exportKuaiShouOperateProjectInfo")
|
|
|
|
+ public Result<JSONObject> getKuaiShouOperateProjectInfo(@RequestParam(name="startTime") String startTime,
|
|
|
|
+ @RequestParam(name="endTime") String endTime,
|
|
|
|
+ @RequestParam(name="userId") String userId,HttpServletResponse response) {
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ JSONObject jsonObject = materialStareMapper.getColumnInfo(userId,"104");
|
|
|
|
+ JSONArray array = jsonObject.getJSONArray("json");
|
|
|
|
+ //第一步创建workbook
|
|
|
|
+ HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
+ //设置样式
|
|
|
|
+ HSSFCellStyle style = wb.createCellStyle();
|
|
|
|
+ style.setAlignment(HorizontalAlignment.CENTER);//水平居中
|
|
|
|
+ //设置字体
|
|
|
|
+ HSSFFont font = wb.createFont();
|
|
|
|
+ font.setFontName("黑体");
|
|
|
|
+ font.setFontHeightInPoints((short) 12);//设置字体大小
|
|
|
|
+ style.setFont(font);
|
|
|
|
+ //2:创建sheet 设置sheet名称
|
|
|
|
+ HSSFSheet sheet = wb.createSheet("项目数据");
|
|
|
|
+ sheet.autoSizeColumn(0,true);
|
|
|
|
+ //3:添加 第一行单元格
|
|
|
|
+ HSSFRow row0 = sheet.createRow(0);
|
|
|
|
+ HSSFCell cell0 = row0.createCell(0);
|
|
|
|
+ //设置 第一行 表头
|
|
|
|
+ cell0.setCellValue("项目数据");
|
|
|
|
+ CellRangeAddress region = new CellRangeAddress(0, 0, 0, array.size()-1);
|
|
|
|
+ sheet.addMergedRegion(region);//合并行
|
|
|
|
+ cell0.setCellStyle(style);
|
|
|
|
+ //4:添加表头2行
|
|
|
|
+ HSSFRow row = sheet.createRow(1);
|
|
|
|
+ //5:创建第2行的单元格
|
|
|
|
+ for (int i = 0;i < array.size(); i++) {
|
|
|
|
+ JSONObject json = (JSONObject)array.get(i);
|
|
|
|
+ HSSFCell cell = row.createCell(i); //第一个单元格
|
|
|
|
+ cell.setCellValue(json.getString("title")); //设定值
|
|
|
|
+ cell.setCellStyle(style); //内容居中
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List< KuaiShouOperateProjectVo > resultList = materialStareService.exportKuaiShouOperateProjectInfo(startTime, endTime, userId);
|
|
|
|
+
|
|
|
|
+ for (int j = 0; j < resultList.size(); j++) {
|
|
|
|
+ KuaiShouOperateProjectVo projectVo = resultList.get(j);
|
|
|
|
+ Map project = Check.parseObj2Map(projectVo);
|
|
|
|
+
|
|
|
|
+ //创建行 (表头占0-1行 所以 从 2开始)
|
|
|
|
+ row = sheet.createRow(j + 2);
|
|
|
|
+ for (int k =0;k < array.size();k++) {
|
|
|
|
+ JSONObject json = (JSONObject)array.get(k);
|
|
|
|
+ String fieldName = KuaiShouOperateProjectVo.class.getDeclaredField(json.getString("dataIndex")).getName();
|
|
|
|
+ project.get(fieldName);
|
|
|
|
+ row.createCell(k).setCellValue(project.get(fieldName).toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
+ response.setHeader("Pragma", "no-cache");
|
|
|
|
+ response.setHeader("Cache-Control", "no-cache");
|
|
|
|
+ response.setDateHeader("Expires", 0);
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("项目列表.xlsx", "UTF-8"));
|
|
|
|
+ OutputStream output = response.getOutputStream();
|
|
|
|
+ BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
|
|
|
|
+ wb.write(bufferedOutPut);
|
|
|
|
+ bufferedOutPut.flush();
|
|
|
|
+ bufferedOutPut.close();
|
|
|
|
+ output.close();
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/exportKuaiShouOperateAccountInfo")
|
|
|
|
+ public Result<JSONObject> exportKuaiShouOperateAccountInfo(@RequestParam(name="startTime") String startTime,
|
|
|
|
+ @RequestParam(name="endTime") String endTime,
|
|
|
|
+ @RequestParam(name="projectId") String projectId,
|
|
|
|
+ @RequestParam(name="userId") String userId,HttpServletResponse response) {
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ JSONObject jsonObject = materialStareMapper.getColumnInfo(userId,"102");
|
|
|
|
+ JSONArray array = jsonObject.getJSONArray("json");
|
|
|
|
+ //第一步创建workbook
|
|
|
|
+ HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
+ //设置样式
|
|
|
|
+ HSSFCellStyle style = wb.createCellStyle();
|
|
|
|
+ style.setAlignment(HorizontalAlignment.CENTER);//水平居中
|
|
|
|
+ //设置字体
|
|
|
|
+ HSSFFont font = wb.createFont();
|
|
|
|
+ font.setFontName("黑体");
|
|
|
|
+ font.setFontHeightInPoints((short) 12);//设置字体大小
|
|
|
|
+ style.setFont(font);
|
|
|
|
+ //2:创建sheet 设置sheet名称
|
|
|
|
+ HSSFSheet sheet = wb.createSheet("账户数据");
|
|
|
|
+ sheet.autoSizeColumn(0,true);
|
|
|
|
+ //3:添加 第一行单元格
|
|
|
|
+ HSSFRow row0 = sheet.createRow(0);
|
|
|
|
+ HSSFCell cell0 = row0.createCell(0);
|
|
|
|
+ //设置 第一行 表头
|
|
|
|
+ cell0.setCellValue("账户数据");
|
|
|
|
+ CellRangeAddress region = new CellRangeAddress(0, 0, 0, array.size()-1);
|
|
|
|
+ sheet.addMergedRegion(region);//合并行
|
|
|
|
+ cell0.setCellStyle(style);
|
|
|
|
+ //4:添加表头2行
|
|
|
|
+ HSSFRow row = sheet.createRow(1);
|
|
|
|
+ //5:创建第2行的单元格
|
|
|
|
+ for (int i = 0;i < array.size(); i++) {
|
|
|
|
+ JSONObject json = (JSONObject)array.get(i);
|
|
|
|
+ HSSFCell cell = row.createCell(i); //第一个单元格
|
|
|
|
+ cell.setCellValue(json.getString("title")); //设定值
|
|
|
|
+ cell.setCellStyle(style); //内容居中
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<KuaiShouOperateAccountVo> resultList = materialStareService.exportKuaiShouOperateAccountInfo(startTime, endTime, projectId,userId);
|
|
|
|
+
|
|
|
|
+ for (int j = 0; j < resultList.size(); j++) {
|
|
|
|
+ KuaiShouOperateAccountVo accountVo = resultList.get(j);
|
|
|
|
+ Map account = Check.parseObj2Map(accountVo);
|
|
|
|
+
|
|
|
|
+ //创建行 (表头占0-1行 所以 从 2开始)
|
|
|
|
+ row = sheet.createRow(j + 2);
|
|
|
|
+ for (int k =0;k < array.size();k++) {
|
|
|
|
+ JSONObject json = (JSONObject)array.get(k);
|
|
|
|
+ String fieldName = KuaiShouOperateAccountVo.class.getDeclaredField(json.getString("dataIndex")).getName();
|
|
|
|
+ account.get(fieldName);
|
|
|
|
+ row.createCell(k).setCellValue(account.get(fieldName).toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
+ response.setHeader("Pragma", "no-cache");
|
|
|
|
+ response.setHeader("Cache-Control", "no-cache");
|
|
|
|
+ response.setDateHeader("Expires", 0);
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("账户列表.xlsx", "UTF-8"));
|
|
|
|
+ OutputStream output = response.getOutputStream();
|
|
|
|
+ BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
|
|
|
|
+ wb.write(bufferedOutPut);
|
|
|
|
+ bufferedOutPut.flush();
|
|
|
|
+ bufferedOutPut.close();
|
|
|
|
+ output.close();
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|