|
@@ -0,0 +1,84 @@
|
|
|
|
+package cn.hmsoft.art.control.ex.photo;
|
|
|
|
+
|
|
|
|
+import cn.hmsoft.application.web.Ajax;
|
|
|
|
+import cn.hmsoft.application.web.AjaxControl;
|
|
|
|
+import cn.hmsoft.art.service.ex.photo.LyRoomModelPhotoService;
|
|
|
|
+import cn.hmsoft.helper.excel.Excel2007Writer;
|
|
|
|
+import cn.hmsoft.jdbc.entity.Pager;
|
|
|
|
+import cn.hmsoft.log.LogHelper;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Description 笔试考场模特拍照控制类
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+public class LyRoomModelPhotoControl extends AjaxControl {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private LyRoomModelPhotoService lyRoomModelPhotoService;
|
|
|
|
+
|
|
|
|
+ @RequestMapping("ly/room/model/photo/page")
|
|
|
|
+ public Ajax page(Integer start, Integer limit, String query, String order, String type, Integer num) {
|
|
|
|
+ return new Ajax(lyRoomModelPhotoService.page(start, limit, query, getQueryOrder(order, type), num));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping("ly/room/model/photo/export")
|
|
|
|
+ public void export(String query, String order, String type, Integer num) {
|
|
|
|
+ List<List<Object>> values = new ArrayList<>();
|
|
|
|
+ List<Object> headerList = new ArrayList<>();
|
|
|
|
+ ServletOutputStream outStream = null;
|
|
|
|
+ headerList.add("分组名称");
|
|
|
|
+ headerList.add("考场名称");
|
|
|
|
+ headerList.add("考场地址");
|
|
|
|
+ headerList.add("照片数量");
|
|
|
|
+ values.add(headerList);
|
|
|
|
+
|
|
|
|
+ Pager pager = lyRoomModelPhotoService.page(0, Integer.MAX_VALUE, query, getQueryOrder(order, type), num);
|
|
|
|
+ List<Map<String,Object>> list = (List<Map<String, Object>>) pager.getRecords();
|
|
|
|
+ for(Map<String,Object> map: list) {
|
|
|
|
+ List<Object> rowList = new ArrayList<Object>();
|
|
|
|
+ rowList.add(map.get("group_name"));
|
|
|
|
+ rowList.add(map.get("room_name"));
|
|
|
|
+ rowList.add(map.get("room_addr"));
|
|
|
|
+ rowList.add(map.get("nums"));
|
|
|
|
+ values.add(rowList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ String fileName = "模特拍照统计" + ".xlsx";
|
|
|
|
+ fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
|
|
+ fileName = new String(fileName.getBytes(), StandardCharsets.ISO_8859_1);
|
|
|
|
+ XSSFWorkbook wb = Excel2007Writer.createExcel(values);
|
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
+ wb.write(os);
|
|
|
|
+ this.getResponse().reset();
|
|
|
|
+ this.getResponse().setContentType("application/x-msdownload");
|
|
|
|
+ this.getResponse().setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
|
|
|
+ outStream = this.getResponse().getOutputStream();
|
|
|
|
+ outStream.write(os.toByteArray());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ LogHelper.error(e.getMessage());
|
|
|
|
+ } finally {
|
|
|
|
+ if(outStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ outStream.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ LogHelper.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|