|
@@ -14,6 +14,7 @@ import com.ruoyi.basicData.domain.TGoods;
|
|
|
import com.ruoyi.basicData.domain.TWarehouseArea;
|
|
|
import com.ruoyi.basicData.mapper.*;
|
|
|
import com.ruoyi.basicData.service.impl.TWarehouseServiceImpl;
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.*;
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
@@ -21,6 +22,7 @@ import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.ip.AddressUtils;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtils;
|
|
|
import com.ruoyi.quotation.domain.TSeaprice;
|
|
|
import com.ruoyi.quotation.mapper.TSeapriceMapper;
|
|
|
import com.ruoyi.reportManagement.domain.TWareHouseItemsExcel;
|
|
@@ -28,6 +30,7 @@ import com.ruoyi.reportManagement.domain.TWhgenleg;
|
|
|
import com.ruoyi.reportManagement.mapper.TWhgenlegMapper;
|
|
|
import com.ruoyi.shipping.domain.*;
|
|
|
import com.ruoyi.shipping.excel.TWarehousebillsCntritemsExcel;
|
|
|
+import com.ruoyi.shipping.excel.deriveInventoryExcel;
|
|
|
import com.ruoyi.shipping.mapper.*;
|
|
|
import com.ruoyi.system.domain.SysCheckCode;
|
|
|
import com.ruoyi.system.domain.SysConfig;
|
|
@@ -37,7 +40,9 @@ import com.ruoyi.warehouseBusiness.excel.*;
|
|
|
import com.ruoyi.warehouseBusiness.mapper.*;
|
|
|
import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
|
|
|
import jdk.jfr.events.ExceptionThrownEvent;
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.ss.util.CellReference;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
@@ -49,8 +54,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.servlet.http.HttpServletResponseWrapper;
|
|
|
+import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -162,6 +168,8 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
private TWarehousebillsCntritemsLoggerMapper tWarehousebillsCntritemsLoggerMapper;
|
|
|
@Autowired
|
|
|
private TWarehousebillsfeesLoggerMapper tWarehousebillsfeesLoggerMapper;
|
|
|
+ @Autowired
|
|
|
+ private TVesselMapper tVesselMapper;
|
|
|
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
|
|
|
|
|
|
|
|
@@ -5002,6 +5010,168 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AjaxResult exportInventory(TWarehouseBills tWarehouseBills) {
|
|
|
+ //获取船名
|
|
|
+ TVessel tVessel = tVesselMapper.selectTVesselById(tWarehouseBills.getfVslid());
|
|
|
+ //获取航次
|
|
|
+ TVoyage tVoyage = tVoyageMapper.selectTVoyageById(tWarehouseBills.getfVoyid());
|
|
|
+ //1.创建一个workbook,对应一个excel文件
|
|
|
+ HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
+
|
|
|
+ //2.在workbook中添加一个sheet,对应Excel中的sheet
|
|
|
+ HSSFSheet sheet = wb.createSheet("清单");
|
|
|
+
|
|
|
+ //设置每一列的列宽
|
|
|
+ sheet.setColumnWidth(0,256*15);
|
|
|
+ sheet.setColumnWidth(1,256*20);
|
|
|
+ sheet.setColumnWidth(2,256*20);
|
|
|
+ sheet.setColumnWidth(3,256*20);
|
|
|
+ sheet.setColumnWidth(4,256*15);
|
|
|
+ sheet.setColumnWidth(5,256*15);
|
|
|
+ sheet.setColumnWidth(6,256*15);
|
|
|
+ sheet.setColumnWidth(7,256*15);
|
|
|
+ sheet.setColumnWidth(8,256*15);
|
|
|
+ sheet.setColumnWidth(9,256*15);
|
|
|
+ sheet.setColumnWidth(10,256*15);
|
|
|
+ sheet.setColumnWidth(11,256*20);
|
|
|
+ sheet.setColumnWidth(12,256*35);
|
|
|
+ sheet.setColumnWidth(13,256*35);
|
|
|
+ sheet.setColumnWidth(14,256*25);
|
|
|
+ sheet.setColumnWidth(15,256*25);
|
|
|
+
|
|
|
+ //3.设置样式以及字体样式
|
|
|
+ HSSFCellStyle titleStyle = ExcelUtils.createTitleCellStyle(wb);
|
|
|
+ HSSFCellStyle headerStyle = ExcelUtils.createHeadCellStyle(wb);
|
|
|
+ HSSFCellStyle contentStyle = ExcelUtils.createContentCellStyle(wb);
|
|
|
+
|
|
|
+ //4.创建标题,合并标题单元格
|
|
|
+ //行号
|
|
|
+ int rowNum = 0;
|
|
|
+
|
|
|
+ //创建第一行,索引从0开始(标题行)
|
|
|
+ HSSFRow row0 = sheet.createRow(rowNum++);
|
|
|
+ row0.setHeight((short) 800);// 设置行高
|
|
|
+ String title = "青岛凯和志诚物流装船清单";
|
|
|
+ HSSFCell c00 = row0.createCell(0);
|
|
|
+ c00.setCellValue(title);
|
|
|
+ c00.setCellStyle(contentStyle);
|
|
|
+ // 合并单元格,参数依次为起始行,结束行,起始列,结束列 (索引0开始)
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 15));//标题合并单元格操作,总列数为16
|
|
|
+ //第三行
|
|
|
+ HSSFRow row1 = sheet.createRow(rowNum++);
|
|
|
+ row1.setHeight((short)500);
|
|
|
+ String string = "船名:"+tVessel.getfName()+" "+"航次:"+tVoyage.getfNo()+" "+"离港日期";
|
|
|
+ String[] row_first = {string};
|
|
|
+ for (int i = 0; i < row_first.length; i++) {
|
|
|
+ HSSFCell tempCell = row1.createCell(i);
|
|
|
+ tempCell.setCellValue(row_first[i]);
|
|
|
+ tempCell.setCellStyle(contentStyle);
|
|
|
+ }
|
|
|
+ //合并单元格
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 15));
|
|
|
+ //第四行
|
|
|
+ HSSFRow row3 = sheet.createRow(rowNum++);
|
|
|
+ row3.setHeight((short)500);
|
|
|
+ String[] row_third = {"序号","提单号","箱号","铅封号","尺寸","类型","重量","箱公司","始发港","目的港","货名","运输条款","订舱公司","收货公司名称","收货人地址","收货电话"};
|
|
|
+ for (int i = 0; i < row_third.length; i++) {
|
|
|
+ HSSFCell tempCell = row3.createCell(i);
|
|
|
+ tempCell.setCellValue(row_third[i]);
|
|
|
+ tempCell.setCellStyle(contentStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据船名航次查询清单
|
|
|
+ List<deriveInventoryExcel> list = tWarehouseBillsMapper.deriveInventory(tWarehouseBills);
|
|
|
+
|
|
|
+ for(int i = 0;i<list.size();i++){
|
|
|
+ HSSFRow tempRow = sheet.createRow(rowNum++);
|
|
|
+ tempRow.setHeight((short)500);
|
|
|
+ //循环单元格填入数据
|
|
|
+ for(int j=0;j<16;j++){
|
|
|
+ HSSFCell tempCell = tempRow.createCell(j);
|
|
|
+ tempCell.setCellStyle(contentStyle);
|
|
|
+ String cellValue = "";
|
|
|
+ if(j ==0){
|
|
|
+ //序号
|
|
|
+ cellValue = list.get(i).getRankNo().toString();
|
|
|
+ }else if(j == 1){
|
|
|
+ //提单号
|
|
|
+ cellValue = list.get(i).getfMblno();
|
|
|
+ }else if(j ==2){
|
|
|
+ //箱号
|
|
|
+ cellValue = list.get(i).getfCntrno();
|
|
|
+ }else if(j == 3){
|
|
|
+ //铅封号
|
|
|
+ cellValue = list.get(i).getfSealno();
|
|
|
+ }else if(j ==4){
|
|
|
+ //尺寸
|
|
|
+ cellValue = list.get(i).getMeasure();
|
|
|
+ }else if(j == 5){
|
|
|
+ //类型
|
|
|
+ cellValue = list.get(i).getGenre();
|
|
|
+ }else if(j == 6){
|
|
|
+ //重量
|
|
|
+ cellValue = list.get(i).getfCntrweight().toString();
|
|
|
+ }else if(j ==7){
|
|
|
+ //箱公司
|
|
|
+ cellValue = list.get(i).getfSealno();
|
|
|
+ }else if(j == 8){
|
|
|
+ //始发港
|
|
|
+ cellValue = list.get(i).getPortOfDeparture();
|
|
|
+ }else if(j == 9){
|
|
|
+ //目的港
|
|
|
+ cellValue = list.get(i).getDestinationPort();
|
|
|
+ }else if(j == 10){
|
|
|
+ //货名
|
|
|
+ cellValue = list.get(i).getGoodName();
|
|
|
+ }else if(j == 11){
|
|
|
+ //运输条款
|
|
|
+ cellValue = list.get(i).getTransitClause();
|
|
|
+ }else if( j == 12){
|
|
|
+ //订舱公司
|
|
|
+ cellValue = list.get(i).getBookingCompany();
|
|
|
+ }else if(j == 13){
|
|
|
+ //收货公司名称
|
|
|
+ cellValue = list.get(i).getfConsigneername();
|
|
|
+ }else if(j ==14){
|
|
|
+ //收货公司地址
|
|
|
+ cellValue = list.get(i).getfConsigneeattn();
|
|
|
+ }else if(j == 15){
|
|
|
+ //收货公司电话
|
|
|
+ cellValue = list.get(i).getfConsigneetel();
|
|
|
+ }
|
|
|
+ tempCell.setCellValue(cellValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //导出excel
|
|
|
+
|
|
|
+ String fileName = "清单.xls";
|
|
|
+ try {
|
|
|
+ OutputStream out = null;
|
|
|
+ out = new FileOutputStream(getAbsoluteFile(fileName));
|
|
|
+ wb.write(out);
|
|
|
+ if(null != wb && null != out){
|
|
|
+ wb.write(out);
|
|
|
+ wb.close();
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ return AjaxResult.success(fileName);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("导出Excel失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getAbsoluteFile(String fileName) {
|
|
|
+ String downloadPath = RuoYiConfig.getDownloadPath() + fileName;
|
|
|
+ File desc = new File(downloadPath);
|
|
|
+ if (!desc.getParentFile().exists())
|
|
|
+ {
|
|
|
+ desc.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ return downloadPath;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 判断能否提交审批
|
|
|
* @param billType
|