|
@@ -1,18 +1,29 @@
|
|
|
package com.xt.jygl.gkjcxx.mt.service.impl;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.net.URL;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
+
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.xt.jygl.common.Constants;
|
|
|
+import com.xt.jygl.common.ExportUtil;
|
|
|
import com.xt.jygl.common.GlobalData;
|
|
|
import com.xt.jygl.common.service.JyglBaseService;
|
|
|
import com.xt.jygl.gkjcxx.mt.client.MtWebService;
|
|
|
import com.xt.jygl.gkjcxx.mt.dao.MtDao;
|
|
|
import com.xt.jygl.gkjcxx.mt.entity.MtEntity;
|
|
|
import com.xt.jygl.gkjcxx.mt.service.MtService;
|
|
|
+import com.xt.jygl.gkjcxx.mt.vo.MtVo;
|
|
|
+import com.xt.jygl.gkjsgl.xmxxgl.vo.XmxxglVo;
|
|
|
import com.xtframe.core.webService.AuthHandlerResolver;
|
|
|
import com.xtframe.sec.common.SecRepository;
|
|
|
|
|
@@ -76,4 +87,293 @@ public class MtServiceImpl extends JyglBaseService<MtEntity, String> implements
|
|
|
public MtEntity findByYmtidAndJyrId(String ymtid, String jyrid) {
|
|
|
return dao.findByYmtidAndJyrId(ymtid, jyrid);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportExcelAll(List<MtVo> voList, ServletOutputStream outputStream) {
|
|
|
+ // 创建一个workbook 对应一个excel应用文件
|
|
|
+ XSSFWorkbook workBook = new XSSFWorkbook();
|
|
|
+ setSheet(voList, outputStream, workBook);
|
|
|
+ try {
|
|
|
+ workBook.write(outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setSheet(List<MtVo> voList, ServletOutputStream outputStream, XSSFWorkbook workBook) {
|
|
|
+ String[] titles = { "序号", "所在地", "所在港口", "所在港区", "港口经营人", "所在作业区", "所在岸线", "码头名称", "码头长度(米)", "设计货物吞吐量(万吨)", "设计旅客吞吐量(万人)",
|
|
|
+ "年旅客通过能力(万人)", "年集装箱通过能力(万TEU)", "年货物通过能力(万吨)", "服务类型", "是否对外开放", "是否危化品码头", "码头用途", "码头结构型式", "建成日期",
|
|
|
+ "是否为挖入式港池形式", "码头前沿设计水深(米)" };
|
|
|
+ // 在workbook中添加一个sheet,对应Excel文件中的sheet
|
|
|
+ XSSFSheet mtSheet = workBook.createSheet("码头信息");
|
|
|
+ ExportUtil exportUtil = new ExportUtil(workBook, mtSheet);
|
|
|
+ XSSFCellStyle headStyle = exportUtil.getHeadStyle();
|
|
|
+ XSSFCellStyle bodyStyle = exportUtil.getBodyStyle();
|
|
|
+ // 构建表头
|
|
|
+ XSSFRow headRow = mtSheet.createRow(0);
|
|
|
+ XSSFCell cell = null;
|
|
|
+ for (int i = 0; i < titles.length; i++) {
|
|
|
+ cell = headRow.createCell(i);
|
|
|
+ cell.setCellStyle(headStyle);
|
|
|
+ cell.setCellValue(titles[i]);
|
|
|
+ }
|
|
|
+ // 构建表体数据
|
|
|
+ if (voList != null && voList.size() > 0) {
|
|
|
+ for (int j = 0; j < voList.size(); j++) {
|
|
|
+ XSSFRow bodyRow = mtSheet.createRow(j + 1);
|
|
|
+ MtVo mt = voList.get(j);
|
|
|
+ // 序号
|
|
|
+ cell = bodyRow.createCell(0);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(j + 1);
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(1);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getSzdzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(2);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getSzgkzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(3);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getSzgqzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(4);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getSsjyrzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(5);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getSzzyqzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(6);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getSzaxzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(7);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getMtmc());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(8);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ if (null != mt.getMtcd()) {
|
|
|
+ cell.setCellValue(mt.getMtcd());
|
|
|
+ }
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(9);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ if(mt.getSjhwttl() != null){
|
|
|
+ cell.setCellValue(mt.getSjhwttl());
|
|
|
+ }
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(10);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ if (mt.getSjlkttl() != null) {
|
|
|
+ cell.setCellValue(mt.getSjlkttl());
|
|
|
+ }
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(11);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ if(mt.getNlktgnl() != null){
|
|
|
+ cell.setCellValue(mt.getNlktgnl());
|
|
|
+ }
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(12);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ if (null != mt.getNjzxtgnl()) {
|
|
|
+ cell.setCellValue(mt.getNjzxtgnl());
|
|
|
+ }
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(13);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ if (mt.getNhwtgnl() != null) {
|
|
|
+ cell.setCellValue(mt.getNhwtgnl());
|
|
|
+ }
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(14);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getFwlxzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(15);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getSfdwkfzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(16);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getSfwhpzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(17);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getMtytzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(18);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getMtxsdmzw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(19);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getJcrqfmt());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(20);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ cell.setCellValue(mt.getMtsfwarszw());
|
|
|
+
|
|
|
+ cell = bodyRow.createCell(21);
|
|
|
+ cell.setCellStyle(bodyStyle);
|
|
|
+ if (null != mt.getMtsjqyss()) {
|
|
|
+ cell.setCellValue(mt.getMtsjqyss());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+// @Override
|
|
|
+// public void exportExcelAll(List<MtVo> voList, String[] titles, ServletOutputStream outputStream) {
|
|
|
+// // 创建一个workbook 对应一个excel应用文件
|
|
|
+// XSSFWorkbook workBook = new XSSFWorkbook();
|
|
|
+// // 在workbook中添加一个sheet,对应Excel文件中的sheet
|
|
|
+// XSSFSheet sheet = workBook.createSheet("项目信息全部");
|
|
|
+// ExportUtil exportUtil = new ExportUtil(workBook, sheet);
|
|
|
+// XSSFCellStyle headStyle = exportUtil.getHeadStyle();
|
|
|
+// XSSFCellStyle bodyStyle = exportUtil.getBodyStyle();
|
|
|
+// // 构建表头
|
|
|
+// XSSFRow headRow = sheet.createRow(0);
|
|
|
+// XSSFCell cell = null;
|
|
|
+// for (int i = 0; i < titles.length; i++) {
|
|
|
+// cell = headRow.createCell(i);
|
|
|
+// cell.setCellStyle(headStyle);
|
|
|
+// cell.setCellValue(titles[i]);
|
|
|
+// }
|
|
|
+// // 构建表体数据
|
|
|
+// if (voList != null && voList.size() > 0) {
|
|
|
+// for (int j = 0; j < voList.size(); j++) {
|
|
|
+// XSSFRow bodyRow = sheet.createRow(j + 1);
|
|
|
+// MtVo mt = voList.get(j);
|
|
|
+// // 序号
|
|
|
+// cell = bodyRow.createCell(0);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(j + 1);
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(1);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getSzdzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(2);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getSzgkzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(3);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getSzgqzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(4);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getSsjyrzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(5);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getSzzyqzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(6);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getSzaxzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(7);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getMtmc());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(8);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// if (null != mt.getMtcd()) {
|
|
|
+// cell.setCellValue(mt.getMtcd());
|
|
|
+// }
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(9);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// if(mt.getSjhwttl() != null){
|
|
|
+// cell.setCellValue(mt.getSjhwttl());
|
|
|
+// }
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(10);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// if (mt.getSjlkttl() != null) {
|
|
|
+// cell.setCellValue(mt.getSjlkttl());
|
|
|
+// }
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(11);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// if(mt.getNlktgnl() != null){
|
|
|
+// cell.setCellValue(mt.getNlktgnl());
|
|
|
+// }
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(12);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// if (null != mt.getNjzxtgnl()) {
|
|
|
+// cell.setCellValue(mt.getNjzxtgnl());
|
|
|
+// }
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(13);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// if (mt.getNhwtgnl() != null) {
|
|
|
+// cell.setCellValue(mt.getNhwtgnl());
|
|
|
+// }
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(14);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getFwlxzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(15);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getSfdwkfzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(16);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getSfwhpzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(17);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getMtytzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(18);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getMtxsdmzw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(19);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getJcrqfmt());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(20);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// cell.setCellValue(mt.getMtsfwarszw());
|
|
|
+//
|
|
|
+// cell = bodyRow.createCell(21);
|
|
|
+// cell.setCellStyle(bodyStyle);
|
|
|
+// if (null != mt.getMtsjqyss()) {
|
|
|
+// cell.setCellValue(mt.getMtsjqyss());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// try {
|
|
|
+// workBook.write(outputStream);
|
|
|
+// outputStream.flush();
|
|
|
+// outputStream.close();
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// } finally {
|
|
|
+// try {
|
|
|
+// outputStream.close();
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|