Ver código fonte

Merge remote-tracking branch 'origin/dev' into dev

lazhaoqian 3 anos atrás
pai
commit
0853dd52ae

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/warehouseBusiness/TWarehousebillsfeesController.java

@@ -141,11 +141,18 @@ public class TWarehousebillsfeesController extends BaseController {
      */
     @GetMapping("/exportBillSubItemDetails")
     public AjaxResult exportBillSubItemDetails(TWarehousebillsfees tWarehousebillsfees){
+        List<QueryMenu> list = tWarehousebillsfeesService.selectQueryMenuList(tWarehousebillsfees);
+        if (list.size()<1) {
+            return AjaxResult.error("当前选择无数据,无法导出");
+        }
         if (tWarehousebillsfees.getfCorpid() == null) {
             return AjaxResult.error("请选择客户名称");
+        } else if (tWarehousebillsfees.getDateRange()==null) {
+            return AjaxResult.error("请选择业务日期");
         } else {
             BillDetailsSubItem billDetailsSubItem = new BillDetailsSubItem();
             billDetailsSubItem.setfCorpid(tWarehousebillsfees.getfCorpid());
+            billDetailsSubItem.setDateRange(tWarehousebillsfees.getDateRange());
             return tWarehousebillsfeesService.exportBillSubItemDetails(billDetailsSubItem);
         }
     }

+ 1 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/excel/Profit.java

@@ -54,7 +54,7 @@ public class Profit {
     /**
      * 应收金额
      */
-    @Excel(name = "应金额")
+    @Excel(name = "应金额")
     private Double fAmount;
 
     /**

+ 13 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehousebillsfees.java

@@ -432,6 +432,19 @@ public class TWarehousebillsfees extends BaseEntity {
      */
     private List<String> fMonth;
 
+    /**
+     * 传递前台搜索审核日期范围,用来做 excel 表的统计范围
+     */
+    private String dateRange;
+
+    public String getDateRange() {
+        return dateRange;
+    }
+
+    public void setDateRange(String dateRange) {
+        this.dateRange = dateRange;
+    }
+
     public String getfYears() {
         return fYears;
     }

+ 21 - 10
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/excel/BillDetailsSubItem.java

@@ -7,7 +7,7 @@ import java.math.BigDecimal;
  */
 public class BillDetailsSubItem {
     // 业务类型
-    private String fBusinesstype;
+    private String fBilltype;
 
     // 作业类型
     private String twlfBusinesstype;
@@ -55,17 +55,28 @@ public class BillDetailsSubItem {
     private String fStlamountdate;
 
     // 仓库
-    private int fWarehouseId;
+    private String fhName;
 
     // 备注
     private String remark;
 
-    public String getfBusinesstype() {
-        return fBusinesstype;
+    // 统计范围
+    private String dateRange;
+
+    public String getDateRange() {
+        return dateRange;
+    }
+
+    public void setDateRange(String dateRange) {
+        this.dateRange = dateRange;
+    }
+
+    public String getfBilltype() {
+        return fBilltype;
     }
 
-    public void setfBusinesstype(String fBusinesstype) {
-        this.fBusinesstype = fBusinesstype;
+    public void setfBilltype(String fBilltype) {
+        this.fBilltype = fBilltype;
     }
 
     public String getTwlfBusinesstype() {
@@ -188,12 +199,12 @@ public class BillDetailsSubItem {
         this.fStlamountdate = fStlamountdate;
     }
 
-    public int getfWarehouseId() {
-        return fWarehouseId;
+    public String getFhName() {
+        return fhName;
     }
 
-    public void setfWarehouseId(int fWarehouseId) {
-        this.fWarehouseId = fWarehouseId;
+    public void setFhName(String fhName) {
+        this.fhName = fhName;
     }
 
     public String getRemark() {

+ 109 - 24
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehousebillsfeesServiceImpl.java

@@ -18,6 +18,7 @@ import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.BorderStyle;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -213,13 +214,14 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
         // 在 workbook 中添加一个sheet,对应 excel 文档中的 sheet
         HSSFSheet sheet = wb.createSheet("分项明细");
         // 获取 cell 样式
-        HSSFCellStyle cellStyle = getCellStyle(wb);
+        HSSFCellStyle cellTitleStyle = getCellStyle(wb,"center",true);
+        HSSFCellStyle cellContentStyle = getCellStyle(wb,"center",true);
         // 创建标题,合并标题单元格
         // 行号
-        int rowNum = 0;
+        int rowNum = 2;
         // 第一行
         HSSFRow first = sheet.createRow(rowNum++);
-        String[] left = {"序号", "业务类型", "作业类型", "提单号", "货名", "客户", "件数", "重量", "体积", "入库时间", "计算天数", "货物堆存费"};
+        String[] left = {"序号", "业务类型", "作业类型", "提单号", "货名", "客户", "件数", "重量", "体积", "入库时间","出库时间", "计算天数", "货物堆存费"};
         List<String> middle = tFeesMapper.selectTFeesNameList();
         String[] right = {"金额", "计划员", "计费时间", "结费时间", "仓库", "备注"};
 
@@ -228,15 +230,29 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
         all.addAll(middle);
         Collections.addAll(all, right);
 
+        // 创建并获取大标题样式
+        /*HSSFCellStyle cellBigTitleStyle = getCellStyle(wb,"center",false);
+        CellRangeAddress cBigTitle = new CellRangeAddress(0,0,0,all.size()/4);
+        setBigTitle("青岛大木仓配物流有限公司现场收费统计表(仓储业务)",0,sheet,cellBigTitleStyle,cBigTitle);
+        setFont(cellBigTitleStyle,wb,"宋体",11,true);*/
+
+        // 创建并获取统计范围时间样式
+        HSSFCellStyle cellRangeTimeStyle = getCellStyle(wb,"center",false);
+        CellRangeAddress cRangeTimeTitle = new CellRangeAddress(1,1,0,all.size()/9);
+        setBigTitle("统计范围:" + billDetailsSubItem.getDateRange(),1,sheet,cellRangeTimeStyle,cRangeTimeTitle);
+        setFont(cellRangeTimeStyle,wb,"宋体",11,false);
+
         int size = all.size();
         for (int i = 0; i < size; i++) {
             HSSFCell tempCell = first.createCell(i);
-            if (i > 11 && i < size - 6) {
+            if (i > 12 && i < size - 6) {
                 tempCell.setCellValue(all.get(i) + "单价");
             } else {
                 tempCell.setCellValue(all.get(i));
             }
-            tempCell.setCellStyle(cellStyle);
+            tempCell.setCellStyle(cellTitleStyle);
+            // 设置第三行标题栏字体
+            setFont(cellTitleStyle,wb,"宋体",11,true);
         }
 
         // 根据客户名称,发货方查询清单数据
@@ -253,10 +269,11 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
                 HSSFCell temCell = tempRow.createCell(i);
                 String cellValue = "";
                 if (i == 0) {
+                    // 序号
                     cellValue = StringUtils.objToStr(index++);
                 } else if (i == 1) {
                     // 业务类型
-                    cellValue = StringUtils.objToStr(bd.getfBusinesstype());
+                    cellValue = StringUtils.objToStr(bd.getfBilltype());
                 } else if (i == 2) {
                     // 作业类型
                     cellValue = StringUtils.objToStr(bd.getTwlfBusinesstype());
@@ -301,13 +318,14 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
                     cellValue = StringUtils.objToStr(bd.getfStlamountdate());
                 } else if (i == size - 2) {
                     // 仓库
-                    cellValue = StringUtils.objToStr(bd.getfWarehouseId());
+                    cellValue = StringUtils.objToStr(bd.getFhName());
                 } else if (i == size - 1) {
                     // 备注
                     cellValue = StringUtils.objToStr(bd.getRemark());
                 }
                 temCell.setCellValue(cellValue);
-                temCell.setCellStyle(cellStyle);
+                temCell.setCellStyle(cellContentStyle);
+                setFont(cellContentStyle,wb,"宋体",12,false);
             }
         }
 
@@ -340,23 +358,90 @@ public class TWarehousebillsfeesServiceImpl implements ITWarehousebillsfeesServi
         return downloadPath;
     }
 
-    // 获取 excel 表格的 cell 相关样式
-    public HSSFCellStyle getCellStyle(HSSFWorkbook wb) {
-        HSSFCellStyle cellStyle = wb.createCellStyle();
-        // 水平居中
-        cellStyle.setAlignment(HorizontalAlignment.CENTER);
-        // 垂直居中
-        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
-        // 上边框
-        cellStyle.setBorderTop(BorderStyle.THIN);
-        // 下边框
-        cellStyle.setBorderBottom(BorderStyle.THIN);
-        // 左边框
-        cellStyle.setBorderLeft(BorderStyle.THIN);
-        // 右边框
-        cellStyle.setBorderRight(BorderStyle.THIN);
+    /**
+     * 封装大标题实现复用
+     * @param title 标题
+     * @param row 所在行
+     * @param sheet sheet
+     * @param cellStyle 样式
+     * @param cellAddresses 合并行参数
+     */
+    public void setBigTitle(String title,int row,HSSFSheet sheet,HSSFCellStyle cellStyle,CellRangeAddress cellAddresses){
+        // 合并参数
+        sheet.addMergedRegion(cellAddresses);
+        // 大标题部分
+        HSSFRow bigTitleRow = sheet.createRow(row);
+        HSSFCell cell = bigTitleRow.createCell(0);
+        cell.setCellValue(title);
+        cell.setCellStyle(cellStyle);
+    }
+
+    /**
+     * 设置 excel 内内容字体
+     * @param style 传入的已设置的 excel 样式
+     * @param workbook 工作簿
+     * @param fontName 字体名称,例如: "宋体"
+     * @param fontSize 字体大小
+     * @param isBold 是否加粗,true:加粗,false:不加粗
+     */
+    public void setFont(HSSFCellStyle style,HSSFWorkbook workbook,String fontName,int fontSize,boolean isBold){
+        HSSFFont font = workbook.createFont();
+        // 设置字体
+        font.setFontName(fontName);
+        // 是否加粗
+        font.setBold(isBold);
+        // 字体大小
+        font.setFontHeightInPoints((short) fontSize);
+        // 需要设置在谁上
+        style.setFont(font);
+    }
+
+    /**
+     * 获取并设置工作表 excel 样式
+     * @param workbook 工作簿
+     * @param position 位置参数:left-居左,right-居右,center-居中
+     * @param showFrame 是否显示边框,true:显示,false:不显示
+     * @return 已设置的 excel 样式
+     */
+    public HSSFCellStyle getCellStyle(HSSFWorkbook workbook,String position,boolean showFrame){
+        // 创建标题的显示样式
+        HSSFCellStyle headerStyle = workbook.createCellStyle();
+        // 设置水平垂直居中+上下左右边框+边框是否显示
+        setHeaderStyle(headerStyle,position,showFrame);
         // 返回
-        return cellStyle;
+        return headerStyle;
     }
 
+    /**
+     * 封装边框以及水平+垂直居中+边框是否显示
+     * @param headerStyle 样式
+     * @param position 位置参数:left-居左,right-居右,center-居中
+     * @param showFrame 是否显示边框,true:显示,false:不显示
+     */
+    public void setHeaderStyle(HSSFCellStyle headerStyle,String position,boolean showFrame){
+        // 水平位置摆放
+        switch (position) {
+            case "left": // 居左
+                headerStyle.setAlignment(HorizontalAlignment.LEFT);
+                break;
+            case "right": // 居右
+                headerStyle.setAlignment(HorizontalAlignment.RIGHT);
+                break;
+            case "center": // 居中
+                headerStyle.setAlignment(HorizontalAlignment.CENTER);
+                break;
+        }
+        // 垂直居中
+        headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        if (showFrame) {
+            // 上边框
+            headerStyle.setBorderTop(BorderStyle.THIN);
+            // 下边框
+            headerStyle.setBorderBottom(BorderStyle.THIN);
+            // 左边框
+            headerStyle.setBorderLeft(BorderStyle.THIN);
+            // 右边框
+            headerStyle.setBorderRight(BorderStyle.THIN);
+        }
+    }
 }

+ 32 - 24
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml

@@ -934,31 +934,39 @@
 
     <select id="selectBillDetailsSubItem" resultType="com.ruoyi.warehouseBusiness.excel.BillDetailsSubItem">
         select
-            tw.f_business_type as fBusinesstype,
-            twl.f_business_type as twlfBusinesstype,
-            tw.f_corpid as fCorpid,
-            tw.f_statement_no as fStatementno,
-            tg.f_name as tgfName,
-            tc.f_name as tcfName,
-            tw.f_qty as fQty,
-            twb.f_netweight as fNetweight,
-            twb.f_volumn as fVolumn,
-            DATE_FORMAT(twb.f_originalbilldate, '%Y-%m-%d') fOriginalbilldate,
-            DATE_FORMAT(twb.f_bsdate, '%Y-%m-%d') fBsdate,
-            twb.f_billing_days as fBillingdays,
-            tw.f_amount as fAmount,
-            twb.create_by as createBy,
-            DATE_FORMAT(twb.f_chargedate, '%Y-%m-%d') fChargedate,
-            DATE_FORMAT(tw.f_stlamount_date, '%Y-%m-%d') fStlamountdate,
-            tw.f_warehouseid as fWarehouseId,
-            twb.remark as remark
-        from t_warehousebillsfees tw
-                 LEFT JOIN t_warehousebillsitems twb on twb.f_pid = tw.f_id
-                 LEFT JOIN t_warehousebillsfees_logger twl on twl.f_pid = tw.f_id
-                 LEFT JOIN t_goods tg on twb.f_goodsid = tg.f_id
-                 LEFT JOIN t_corps tc on tw.f_corpid = tc.f_id
+        CASE
+        WHEN tw.f_billtype = 'SJRK' THEN '入库'
+        WHEN tw.f_billtype = 'SJCK' THEN '实际出库'
+        WHEN tw.f_billtype = 'CKDB' THEN '调拨'
+        WHEN tw.f_billtype = 'HQZY' THEN '货权转移'
+        WHEN tw.f_billtype = 'CDZZ' THEN '场地直装'
+        END as fBilltype,
+        twl.f_business_type as twlfBusinesstype,
+        twf.f_corpid as fCorpid,
+        twf.f_statement_no as fStatementno,
+        tg.f_name as tgfName,
+        tc.f_name as tcfName,
+        twf.f_qty as fQty,
+        twb.f_netweight as fNetweight,
+        twb.f_volumn as fVolumn,
+        date_format(twf.f_originalbilldate, '%Y-%m-%d') fOriginalbilldate,
+        date_format(twf.f_bsdate, '%Y-%m-%d') fBsdate,
+        twf.f_billing_days as fBillingdays,
+        twf.f_amount as fAmount,
+        twf.create_by as createBy,
+        date_format(twf.f_chargedate, '%Y-%m-%d') fChargedate,
+        date_format(twf.f_stlamount_date, '%Y-%m-%d') fStlamountdate,
+        th.f_name as fhName,
+        twf.remark as remark
+        from t_warehousebillsfees twf
+        LEFT JOIN t_warehousebills tw on twf.f_pid = tw.f_id
+        LEFT JOIN t_warehousebillsitems twb on twb.f_pid = twf.f_id
+        LEFT JOIN t_warehousebillsfees_logger twl on twl.f_pid = twf.f_id
+        LEFT JOIN t_goods tg on tw.f_goodsid = tg.f_id
+        LEFT JOIN t_corps tc on twf.f_corpid = tc.f_id
+        LEFT JOIN t_warehouse th on tw.f_warehouseid = th.f_id
         <where>
-            <if test="fCorpid != null  and fCorpid != ''">and tw.f_corpid = #{fCorpid}</if>
+            <if test="fCorpid != null  and fCorpid != ''">and twf.f_corpid = #{fCorpid}</if>
         </where>
     </select>
 </mapper>