Commit d4ab65aa by jiang'yun

修改

parent 10262939
...@@ -8,12 +8,18 @@ import com.ruoyi.framework.aspectj.lang.enums.BusinessType; ...@@ -8,12 +8,18 @@ import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.zt.domain.*; import com.ruoyi.project.zt.domain.*;
import com.ruoyi.project.zt.service.DjdcService; import com.ruoyi.project.zt.service.DjdcService;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
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.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -254,16 +260,19 @@ public class DjdcController { ...@@ -254,16 +260,19 @@ public class DjdcController {
// @PreAuthorize("@ss.hasPermi('system:jsba:export')") // @PreAuthorize("@ss.hasPermi('system:jsba:export')")
// @Log(title = "地质简介基本数据", businessType = BusinessType.EXPORT) // @Log(title = "地质简介基本数据", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, CommonParam param) public void export(HttpServletResponse response, CommonParam param) throws Exception {
{
String path = param.getExportPath(); String path = param.getExportPath();
switch (path) { switch (path) {
case "exportLjjw": case "exportLjjw":
//导出邻井查询
List<Ljjw> ljjwList2 = djdcService.getLjjwList(param); List<Ljjw> ljjwList2 = djdcService.getLjjwList(param);
ExcelUtil<Ljjw> util = new ExcelUtil<Ljjw>(Ljjw.class); ExcelUtil<Ljjw> util = new ExcelUtil<Ljjw>(Ljjw.class);
util.exportExcel(response, ljjwList2, "Sheet1"); util.exportExcel(response, ljjwList2, "Sheet1");
case "exportZqshfx":
//导出周期分析
List<DjZqsjfx> zqshfxList = djdcService.getZqshfxList(param);
exportZqshfx(response,zqshfxList);
default: default:
} }
...@@ -271,6 +280,88 @@ public class DjdcController { ...@@ -271,6 +280,88 @@ public class DjdcController {
} }
public void exportZqshfx(HttpServletResponse response,List<DjZqsjfx> list)throws IOException {
Workbook exl = null;
OutputStream out = null;
InputStream in = null;
try {
in =this.getClass().getResourceAsStream("/static/excel/zqfxdcmb.xlsx");
exl = WorkbookFactory.create(in);
out = response.getOutputStream();
response.reset();
String filename = URLEncoder.encode("导入模板.xlsx", "UTF-8");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + filename);
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
Sheet sheet = exl.getSheet("Sheet1");
CellStyle cellStyle = exl.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
cellStyle.setBorderTop(BorderStyle.THIN);//上边框
cellStyle.setBorderRight(BorderStyle.THIN);//右边框
cellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
cellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
Font cellFont = exl.createFont();
cellFont.setFontHeightInPoints((short)9); // 字体大小
cellFont.setFontName("宋体"); // 字体应用到当前单元格上
cellStyle.setFont(cellFont);
cellStyle.setWrapText(true);//设置自动换行
int lastRow = sheet.getLastRowNum()+1;
for(DjZqsjfx item:list){
Row row = sheet.createRow(lastRow);
row.setHeightInPoints(18);
int m = 0;
Cell cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getJh()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getKc()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getJtm()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getKsjs()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getJs()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getJc()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getCw()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getZjzq()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getZjycsl()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getZjsczq()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getZjsl()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getZwzq()+"");
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getWjycsl());
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getWjsczq());
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getZjycms());
cell = row.createCell(m++);cell.setCellStyle(cellStyle); cell.setCellValue(item.getWjycms());
lastRow++;
}
exl.write(out);
exl.close();
}catch (Exception e){
e.getMessage();
throw new IOException();
}finally{
if (exl != null) {
try {
exl.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (out != null) {
try {
out.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment