|
|
@@ -1,4 +1,7 @@
|
|
|
package com.common.workflow.web.rest;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.common.workflow.service.util.FileUtils;
|
|
|
import com.common.workflow.web.rest.vm.*;
|
|
|
import com.github.crab2died.ExcelUtils;
|
|
|
@@ -12,6 +15,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.File;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.lang.reflect.Type;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@@ -157,4 +161,41 @@ public class ExcelResource {
|
|
|
outputStream.flush();
|
|
|
outputStream.close();
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/aptitude-excel")
|
|
|
+ public void exportAptitudeConfig(@Valid @RequestBody ExcelTemplateAptitudeConfigVM aptitudeConfigVM, HttpServletResponse response) throws Exception {
|
|
|
+ response.reset();
|
|
|
+ response.setContentType("multipart/form-data;charset=utf-8");
|
|
|
+ response.setHeader("content-disposition", "attachment;filename=" + aptitudeConfigVM.getFileName());
|
|
|
+ response.setHeader("Pragma","No-cache");
|
|
|
+ response.setHeader ( "Cache-Control", "no-store");
|
|
|
+ response.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
+ response.setHeader("Access-Control-Allow-Headers", "*");
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ String fullFileName = FileUtils.getExcelTemplatePath() + "/" + aptitudeConfigVM.getFileName();
|
|
|
+
|
|
|
+ File file = new File(fullFileName);
|
|
|
+
|
|
|
+ if (file.exists()) {
|
|
|
+ file.delete(); //清除历史文件
|
|
|
+ }
|
|
|
+
|
|
|
+ fullFileName = FileUtils.downLoadFromUrl(aptitudeConfigVM.getTemplateUrl(), aptitudeConfigVM.getFileName(), FileUtils.getExcelTemplatePath());
|
|
|
+
|
|
|
+ if (aptitudeConfigVM.getSupplierType().equals("1")) {
|
|
|
+ // 物资类
|
|
|
+ } else if (aptitudeConfigVM.getSupplierType().equals("2")) {
|
|
|
+ // 服务类
|
|
|
+ String obj = JSONObject.toJSONString(aptitudeConfigVM.getDataList().get("data"));
|
|
|
+ List<TechSrcAptitudeVo> list = JSONArray.parseArray(obj, TechSrcAptitudeVo.class);
|
|
|
+ Map<String, String> data = new HashMap<>();
|
|
|
+ data.put("title", "大港油田公司服务准入项目所需资质、资料明细表");
|
|
|
+ ExcelUtils.getInstance().exportObjects2Excel(fullFileName, 0, list, data, TechSrcAptitudeVo.class, false, outputStream);
|
|
|
+ } else {
|
|
|
+ log.info("其他导出");
|
|
|
+ }
|
|
|
+
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ }
|
|
|
}
|