|
|
@@ -1,9 +1,6 @@
|
|
|
package com.common.workflow.web.rest;
|
|
|
import com.common.workflow.service.util.FileUtils;
|
|
|
-import com.common.workflow.web.rest.vm.ExcelTemplateVM;
|
|
|
-import com.common.workflow.web.rest.vm.OilContractSumScoreVo;
|
|
|
-import com.common.workflow.web.rest.vm.OilContractSumScoreVo2;
|
|
|
-import com.common.workflow.web.rest.vm.WordTemplateVM;
|
|
|
+import com.common.workflow.web.rest.vm.*;
|
|
|
import com.github.crab2died.ExcelUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -87,4 +84,57 @@ public class ExcelResource {
|
|
|
outputStream.flush();
|
|
|
outputStream.close();
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/contrast-excel")
|
|
|
+ public void ContrastExcelTemplate(@Valid @RequestBody ExcelTemplateVM wordTemplateVM, HttpServletResponse response) throws Exception {
|
|
|
+ response.reset();
|
|
|
+ response.setContentType("multipart/form-data;charset=utf-8");
|
|
|
+ response.setHeader("content-disposition", "attachment;filename=" + wordTemplateVM.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() + "/" + wordTemplateVM.getFileName();
|
|
|
+
|
|
|
+ File file = new File(fullFileName);
|
|
|
+ if (file.exists()) {
|
|
|
+ file.delete(); //清除历史文件
|
|
|
+ }
|
|
|
+ fullFileName = FileUtils.downLoadFromUrl(wordTemplateVM.getTemplateUrl(), wordTemplateVM.getFileName(), FileUtils.getExcelTemplatePath());
|
|
|
+
|
|
|
+ Map<String, List<?>> classes = new HashMap<>();
|
|
|
+ List<ContrastExcelVM> reportList = new ArrayList<>();
|
|
|
+ List<ContrastExcelVM> reportList1 = new ArrayList<>();
|
|
|
+ ArrayList<LinkedHashMap<String,Object>> list = (ArrayList<LinkedHashMap<String,Object>>) wordTemplateVM.getDatas().get("data");
|
|
|
+ for(LinkedHashMap<String,Object> entry : list){
|
|
|
+ ContrastExcelVM contrastExcelVM = new ContrastExcelVM();
|
|
|
+ contrastExcelVM.setSupplierName(entry.get("SupplierName").toString());
|
|
|
+ contrastExcelVM.setInFlag(entry.get("InFlag").toString());
|
|
|
+ contrastExcelVM.setAccessCardNo(entry.get("AccessCardNo").toString());
|
|
|
+ contrastExcelVM.setSupplierTypeCode(entry.get("SupplierTypeCode").toString());
|
|
|
+ contrastExcelVM.setLegalPerson(entry.get("LegalPerson").toString());
|
|
|
+ contrastExcelVM.setRegCapital(entry.get("RegCapital").toString());
|
|
|
+ contrastExcelVM.setMobile(entry.get("Mobile").toString());
|
|
|
+ contrastExcelVM.setChecked(entry.get("Checked").toString());
|
|
|
+ if (entry.get("Checked").toString().equals("1")) {
|
|
|
+ reportList.add(contrastExcelVM);
|
|
|
+ } else {
|
|
|
+ reportList1.add(contrastExcelVM);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ classes.put("class_two", reportList);
|
|
|
+ classes.put("class_one", reportList1);
|
|
|
+ Map<String, String> data = new HashMap<>();
|
|
|
+ data.put("title", "资质导入对比表");
|
|
|
+
|
|
|
+ Date d = new Date();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
+
|
|
|
+ data.put("info", sdf.format(d));
|
|
|
+ ExcelUtils.getInstance().exportObject2Excel(fullFileName, 0, classes, data, ContrastExcelVM.class, false, outputStream);
|
|
|
+
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ }
|
|
|
}
|