|
@@ -1,12 +1,20 @@
|
|
|
package cn.com.qmth.mps.controller;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.List;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.CellType;
|
|
|
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -20,8 +28,6 @@ import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
|
-import com.qmth.boot.tools.excel.ExcelWriter;
|
|
|
-import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
|
|
|
|
import cn.com.qmth.mps.bean.ImportMsg;
|
|
|
import cn.com.qmth.mps.service.PaperDetailService;
|
|
@@ -94,10 +100,48 @@ public class PaperController extends BaseController {
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
|
List<PaperStructInfoVo> list = paperService.subjectiveList(query,getAccessUser());
|
|
|
- ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
|
|
|
-
|
|
|
- writer.writeObjects("sheet1", null, PaperStructInfoVo.class, list.iterator());
|
|
|
- writer.output(response.getOutputStream());
|
|
|
+ Workbook wb=null;
|
|
|
+ OutputStream out=null;
|
|
|
+ try {
|
|
|
+ wb = new XSSFWorkbook(ResouceUtil.getStream("importtemplates/structImport.xlsx"));
|
|
|
+ if(CollectionUtils.isNotEmpty(list)) {
|
|
|
+ CellStyle style = wb.createCellStyle();
|
|
|
+ style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ Sheet sheet=wb.getSheetAt(0);
|
|
|
+ int rowIndex=1;
|
|
|
+ for(PaperStructInfoVo vo:list) {
|
|
|
+ rowIndex++;
|
|
|
+ Row row=sheet.createRow(rowIndex);
|
|
|
+ row.createCell(0, CellType.STRING).setCellValue(getStringVal(vo.getCourseCode()));
|
|
|
+ row.createCell(1, CellType.STRING).setCellValue(getStringVal(vo.getCourseName()));
|
|
|
+ row.createCell(2, CellType.STRING).setCellValue(getStringVal(vo.getDetailName()));
|
|
|
+ row.createCell(3, CellType.STRING).setCellValue(getStringVal(vo.getDetailNumber()));
|
|
|
+ row.createCell(4, CellType.STRING).setCellValue(getStringVal(vo.getUnitNumber()));
|
|
|
+ row.createCell(5, CellType.STRING).setCellValue(getStringVal(vo.getScore()));
|
|
|
+ row.createCell(6, CellType.STRING).setCellValue(getStringVal(vo.getScoreStep()));
|
|
|
+ row.createCell(7, CellType.STRING).setCellValue(getStringVal(vo.getGroupNumber()));
|
|
|
+ for(int i=0;i<8;i++) {
|
|
|
+ row.getCell(i).setCellStyle(style);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ out=response.getOutputStream();
|
|
|
+ wb.write(out);
|
|
|
+ } finally {
|
|
|
+ if(wb!=null) {
|
|
|
+ wb.close();
|
|
|
+ }
|
|
|
+ if(out!=null) {
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getStringVal(Object o) {
|
|
|
+ if(o==null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return o.toString();
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取分页")
|