update:标准公开征求意见导出信息

This commit is contained in:
zzy
2021-06-06 21:22:29 +08:00
parent 9ce1094070
commit 7baf3d24ea
3 changed files with 20 additions and 67 deletions
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdeaAll;
import io.swagger.annotations.Api;
@@ -43,7 +44,7 @@ public class SarPublicIdeaAllController extends BaseController<SarPublicIdeaAll>
}
@ApiOperation(value = "增加意见")
@GetMapping("/insetStand")
@PostMapping("/insetStand")
public ResponseMessage addAllStand(SarPublicIdeaAll sar){
String src=sarPublicIdeaAllImpl.add(sar);
return Result.success("200",src);
@@ -60,7 +61,7 @@ public class SarPublicIdeaAllController extends BaseController<SarPublicIdeaAll>
@ApiOperation(value = "修改意见")
@GetMapping("/updateStand")
@PostMapping("/updateStand")
public ResponseMessage updateStand(SarPublicIdeaAll sarPublicIdeaAll,String autUserId){
String src=sarPublicIdeaAllImpl.updateById(sarPublicIdeaAll,autUserId);
return Result.success("200",src);
@@ -19,10 +19,11 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
@@ -102,7 +103,7 @@ public class SarPublicIdeaAllServiceImpl extends ServiceImpl<SarPublicIdeaAllDao
//标题行抽出字段
String[] title = {"", "标准或政策编号","章节编号", "内容","提出人"};
//设置sheet名称,并创建新的sheet对象
String sheetName = "意见信息一览";
String sheetName = "意见信息";
Sheet stuSheet = wb.createSheet(sheetName);
//获取表头行
Row titleRow = stuSheet.createRow(0);
@@ -135,74 +136,30 @@ public class SarPublicIdeaAllServiceImpl extends ServiceImpl<SarPublicIdeaAllDao
stuSheet.autoSizeColumn(i, true);
stuSheet.setColumnWidth(i, stuSheet.getColumnWidth(i) * 15 / 10);
}
//获取配置文件中保存对应excel文件的路径,本地也可以直接写成Fexcel/stuInfoExcel路径
String folderPath = "D:/";
//设置文件名
String fileName = sdf1.format(new Date()) + sheetName + ".xlsx";
String savePath = folderPath + File.separator + fileName;
OutputStream fileOut = null;
response.setContentType("application/octet-stream; charset=iso-8859-1");
StringBuffer contentDisposition = new StringBuffer("attachment; filename=\"");
String fileName = new String("Reply-content.xlsx".getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
contentDisposition.append(fileName).append("\"");
response.setHeader("Content-disposition", contentDisposition.toString());
ServletOutputStream out = null;
try {
fileOut = new FileOutputStream(savePath);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
wb.write(fileOut);
out = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
fileOut.close();
wb.write(out);
} catch (IOException e) {
e.printStackTrace();
}
response.setContentType("application/vnd..ms-excel");
File file = new File(folderPath, fileName);
if (file.exists()) {
response.setContentType("application/x-download;charset=utf-8");// 设置强制下载不打开
response.addHeader("Content-Disposition", "attachment;fileName=" + fileName);
byte[] buffer = new byte[1024];
FileInputStream fis = null;
BufferedInputStream bis = null;
try {
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
OutputStream outputStream = response.getOutputStream();
int i = bis.read(buffer);
while (i != -1) {
outputStream.write(buffer, 0, i);
i = bis.read(buffer);
}
file.delete();
return "下载成功";
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
try {
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
file.delete();
return "下载失败";
return "下载成功";
}
}
@@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -88,10 +87,6 @@ public class SarPublicIdeaServiceImpl extends ServiceImpl<SarPublicIdeaDao, SarP
if (sar.getEndTime()!=null){
wrapper.gt("end_time",sar.getEndTime());
}
// list.eq(StringUtils.isNotEmpty(sar.getCategory()),"category",sar.getCategory())
// .like(StringUtils.isNotEmpty(sar.getCname()),"cname",sar.getCname())
// .gt(sar.getStartTime()!=null,"start_time",sar.getStartTime())
// .le(sar.getEndTime()!=null,"end_time",sar.getEndTime());
Page<SarPublicIdea> page = new Page<>(seByoDto.getPage(), seByoDto.getSize());
IPage<SarPublicIdea> userIPage = sarPublicIdeaDao.selectPage(page, wrapper);