|  | @@ -2,6 +2,7 @@ package com.ruoyi.warehouseBusiness.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.ruoyi.basicData.mapper.TFeesMapper;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.config.RuoYiConfig;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.core.domain.AjaxResult;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.utils.DateUtils;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.utils.StringUtils;
 | 
	
	
		
			
				|  | @@ -20,6 +21,7 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.io.*;
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.util.ArrayList;
 | 
	
		
			
				|  |  |  import java.util.Collections;
 | 
	
	
		
			
				|  | @@ -109,7 +111,8 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     *  查询报表
 | 
	
		
			
				|  |  | +     * 查询报表
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param tWarehousebillsfees
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -117,9 +120,9 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
 | 
	
		
			
				|  |  |      public List<FleetExcel> selectFleetExcelList(TWarehousebillsfees tWarehousebillsfees) {
 | 
	
		
			
				|  |  |          List<FleetExcel> fleetExcelList = new ArrayList<>();
 | 
	
		
			
				|  |  |          // 开始月份
 | 
	
		
			
				|  |  | -        int  startMonth = 1;
 | 
	
		
			
				|  |  | +        int startMonth = 1;
 | 
	
		
			
				|  |  |          // 结束月份
 | 
	
		
			
				|  |  | -        int  endMonth = 1;
 | 
	
		
			
				|  |  | +        int endMonth = 1;
 | 
	
		
			
				|  |  |          if (StringUtils.isNotEmpty(tWarehousebillsfees.getfYears())) {
 | 
	
		
			
				|  |  |              // 年份
 | 
	
		
			
				|  |  |              List<String> month = tWarehousebillsfees.getfMonth();
 | 
	
	
		
			
				|  | @@ -151,7 +154,8 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     *  查询报表合计
 | 
	
		
			
				|  |  | +     * 查询报表合计
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param fleetExcelsList
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -212,22 +216,22 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
 | 
	
		
			
				|  |  |          HSSFCellStyle cellStyle = getCellStyle(wb);
 | 
	
		
			
				|  |  |          // 创建标题,合并标题单元格
 | 
	
		
			
				|  |  |          // 行号
 | 
	
		
			
				|  |  | -        int ruwNum = 0;
 | 
	
		
			
				|  |  | +        int rowNum = 0;
 | 
	
		
			
				|  |  |          // 第一行
 | 
	
		
			
				|  |  | -        HSSFRow first = sheet.createRow(ruwNum++);
 | 
	
		
			
				|  |  | -        String[] left = {"序号","业务类型","作业类型","提单号","货名","客户","件数","重量","体积","入库时间","计算天数","货物堆存费"};
 | 
	
		
			
				|  |  | +        HSSFRow first = sheet.createRow(rowNum++);
 | 
	
		
			
				|  |  | +        String[] left = {"序号", "业务类型", "作业类型", "提单号", "货名", "客户", "件数", "重量", "体积", "入库时间", "计算天数", "货物堆存费"};
 | 
	
		
			
				|  |  |          List<String> middle = tFeesMapper.selectTFeesNameList();
 | 
	
		
			
				|  |  | -        String[] right = {"金额","计划员","计费时间","结费时间","仓库","备注"};
 | 
	
		
			
				|  |  | +        String[] right = {"金额", "计划员", "计费时间", "结费时间", "仓库", "备注"};
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<String> all = new ArrayList<>();
 | 
	
		
			
				|  |  | -        Collections.addAll(all,left);
 | 
	
		
			
				|  |  | +        Collections.addAll(all, left);
 | 
	
		
			
				|  |  |          all.addAll(middle);
 | 
	
		
			
				|  |  | -        Collections.addAll(all,right);
 | 
	
		
			
				|  |  | +        Collections.addAll(all, right);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          int size = all.size();
 | 
	
		
			
				|  |  | -        for (int i = 0;i < size;i++){
 | 
	
		
			
				|  |  | +        for (int i = 0; i < size; i++) {
 | 
	
		
			
				|  |  |              HSSFCell tempCell = first.createCell(i);
 | 
	
		
			
				|  |  | -            if (i>11 && i<size-6){
 | 
	
		
			
				|  |  | +            if (i > 11 && i < size - 6) {
 | 
	
		
			
				|  |  |                  tempCell.setCellValue(all.get(i) + "单价");
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  tempCell.setCellValue(all.get(i));
 | 
	
	
		
			
				|  | @@ -241,14 +245,103 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
 | 
	
		
			
				|  |  |              return AjaxResult.error("无数据,导出Excel失败");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        for (BillDetailsSubItem billDetailsSubItem1 : list) {
 | 
	
		
			
				|  |  | +        int index = 1;
 | 
	
		
			
				|  |  | +        for (BillDetailsSubItem bd : list) {
 | 
	
		
			
				|  |  | +            HSSFRow tempRow = sheet.createRow(rowNum++);
 | 
	
		
			
				|  |  | +            // 循环单元格填入数据
 | 
	
		
			
				|  |  | +            for (int i = 0; i < size; i++) {
 | 
	
		
			
				|  |  | +                HSSFCell temCell = tempRow.createCell(i);
 | 
	
		
			
				|  |  | +                String cellValue = "";
 | 
	
		
			
				|  |  | +                if (i == 0) {
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(index++);
 | 
	
		
			
				|  |  | +                } else if (i == 1) {
 | 
	
		
			
				|  |  | +                    // 业务类型
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfBusinesstype());
 | 
	
		
			
				|  |  | +                } else if (i == 2) {
 | 
	
		
			
				|  |  | +                    // 作业类型
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getTwlfBusinesstype());
 | 
	
		
			
				|  |  | +                } else if (i == 3) {
 | 
	
		
			
				|  |  | +                    // 提单号
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfStatementno());
 | 
	
		
			
				|  |  | +                } else if (i == 4) {
 | 
	
		
			
				|  |  | +                    // 货名
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getTgfName());
 | 
	
		
			
				|  |  | +                } else if (i == 5) {
 | 
	
		
			
				|  |  | +                    // 客户
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getTcfName());
 | 
	
		
			
				|  |  | +                } else if (i == 6) {
 | 
	
		
			
				|  |  | +                    // 件数
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfQty());
 | 
	
		
			
				|  |  | +                } else if (i == 7) {
 | 
	
		
			
				|  |  | +                    // 重量
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfNetweight());
 | 
	
		
			
				|  |  | +                } else if (i == 8) {
 | 
	
		
			
				|  |  | +                    // 体积
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfVolumn());
 | 
	
		
			
				|  |  | +                } else if (i == 9) {
 | 
	
		
			
				|  |  | +                    // 入库时间
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfOriginalbilldate());
 | 
	
		
			
				|  |  | +                } else if (i == 10) {
 | 
	
		
			
				|  |  | +                    // 出库时间
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfBsdate());
 | 
	
		
			
				|  |  | +                } else if (i == 11) {
 | 
	
		
			
				|  |  | +                    // 计费天数
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfBillingdays());
 | 
	
		
			
				|  |  | +                } else if (i == size - 6) {
 | 
	
		
			
				|  |  | +                    // 金额
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfAmount());
 | 
	
		
			
				|  |  | +                } else if (i == size - 5) {
 | 
	
		
			
				|  |  | +                    // 计划员
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getCreateBy());
 | 
	
		
			
				|  |  | +                } else if (i == size - 4) {
 | 
	
		
			
				|  |  | +                    // 计费时间
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfChargedate());
 | 
	
		
			
				|  |  | +                } else if (i == size - 3) {
 | 
	
		
			
				|  |  | +                    // 结费时间
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfStlamountdate());
 | 
	
		
			
				|  |  | +                } else if (i == size - 2) {
 | 
	
		
			
				|  |  | +                    // 仓库
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getfWarehouseId());
 | 
	
		
			
				|  |  | +                } else if (i == size - 1) {
 | 
	
		
			
				|  |  | +                    // 备注
 | 
	
		
			
				|  |  | +                    cellValue = StringUtils.objToStr(bd.getRemark());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                temCell.setCellValue(cellValue);
 | 
	
		
			
				|  |  | +                temCell.setCellStyle(cellStyle);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        for (int i = 0; i < size; i++) {
 | 
	
		
			
				|  |  | +            sheet.autoSizeColumn(i);
 | 
	
		
			
				|  |  | +            sheet.setColumnWidth(i,sheet.getColumnWidth(i)*17/10);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 导出 excel
 | 
	
		
			
				|  |  | +        String fileName = "账单明细导出分项.xls";
 | 
	
		
			
				|  |  | +        // 创建导出流
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            OutputStream out = new FileOutputStream(getAbsoluteFile(fileName));
 | 
	
		
			
				|  |  | +            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 null;
 | 
	
		
			
				|  |  | +        return downloadPath;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // 获取 excel 表格的 cell 相关样式
 | 
	
		
			
				|  |  | -    public HSSFCellStyle getCellStyle(HSSFWorkbook wb){
 | 
	
		
			
				|  |  | +    public HSSFCellStyle getCellStyle(HSSFWorkbook wb) {
 | 
	
		
			
				|  |  |          HSSFCellStyle cellStyle = wb.createCellStyle();
 | 
	
		
			
				|  |  |          // 水平居中
 | 
	
		
			
				|  |  |          cellStyle.setAlignment(HorizontalAlignment.CENTER);
 |