Explorar el Código

新增仓储费明细导出功能

Sun hace 3 años
padre
commit
f2a0c7f2c7

+ 11 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/warehouseBusiness/TStorageFeeCalculationController.java

@@ -17,6 +17,7 @@ import com.ruoyi.framework.web.service.TokenService;
 import com.ruoyi.warehouseBusiness.domain.StorageChargeInsert;
 import com.ruoyi.warehouseBusiness.domain.TWareHouseExcelItems;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
+import com.ruoyi.warehouseBusiness.excel.StorageDetail;
 import com.ruoyi.warehouseBusiness.excel.StorageFee;
 import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -179,4 +180,14 @@ public class TStorageFeeCalculationController extends BaseController {
         return util.exportExcel(list, "计算仓储费");
     }
 
+    /**
+     * 导出仓储详情
+     */
+    @GetMapping("/exportDetail/{fId}")
+    public AjaxResult exportDetail(@PathVariable("fId") Long fId) {
+        List<StorageDetail> list = itWarehouseBillsService.selectStorageDetail(fId);
+        ExcelUtil<StorageDetail> util = new ExcelUtil<>(StorageDetail.class);
+        return util.exportExcel(list, "仓储费明细");
+    }
+
 }

+ 56 - 56
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java

@@ -1,32 +1,5 @@
 package com.ruoyi.common.utils.poi;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import com.alibaba.fastjson.JSONArray;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.util.CellRangeAddressList;
-import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.xssf.streaming.SXSSFWorkbook;
-import org.apache.poi.xssf.usermodel.XSSFDataValidation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.annotation.Excel.ColumnType;
 import com.ruoyi.common.annotation.Excel.Type;
@@ -39,10 +12,24 @@ import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.DictUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.reflect.ReflectUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddressList;
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFDataValidation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * Excel相关处理
- * 
+ *
  * @author ruoyi
  */
 public class ExcelUtil<T>
@@ -124,7 +111,7 @@ public class ExcelUtil<T>
 
     /**
      * 对excel表单默认第一个索引名转换成list
-     * 
+     *
      * @param is 输入流
      * @return 转换后集合
      */
@@ -135,7 +122,7 @@ public class ExcelUtil<T>
 
     /**
      * 对excel表单指定表格索引名转换成list
-     * 
+     *
      * @param sheetName 表格索引名
      * @param is 输入流
      * @return 转换后集合
@@ -291,7 +278,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param list 导出数据集合
      * @param sheetName 工作表的名称
      * @return 结果
@@ -436,7 +423,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param sheetName 工作表的名称
      * @return 结果
      */
@@ -448,7 +435,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @return 结果
      */
     public AjaxResult exportExcel()
@@ -781,7 +768,7 @@ public class ExcelUtil<T>
 
     /**
      * 填充excel数据
-     * 
+     *
      * @param index 序号
      * @param row 单元格行
      */
@@ -808,7 +795,7 @@ public class ExcelUtil<T>
 
     /**
      * 创建表格样式
-     * 
+     *
      * @param wb 工作薄对象
      * @return 样式列表
      */
@@ -846,13 +833,15 @@ public class ExcelUtil<T>
         headerFont.setColor(IndexedColors.WHITE.getIndex());
         style.setFont(headerFont);
         styles.put("header", style);
-        
+
         style = wb.createCellStyle();
+        style.cloneStyleFrom(styles.get("data"));
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setVerticalAlignment(VerticalAlignment.CENTER);
         Font totalFont = wb.createFont();
         totalFont.setFontName("Arial");
         totalFont.setFontHeightInPoints((short) 10);
+        totalFont.setBold(true);
         style.setFont(totalFont);
         styles.put("total", style);
 
@@ -890,7 +879,7 @@ public class ExcelUtil<T>
 
     /**
      * 设置单元格信息
-     * 
+     *
      * @param value 单元格值
      * @param attr 注解相关
      * @param cell 单元格信息
@@ -997,7 +986,7 @@ public class ExcelUtil<T>
 
     /**
      * 设置 POI XSSFSheet 单元格提示
-     * 
+     *
      * @param sheet 表单
      * @param promptTitle 提示标题
      * @param promptContent 提示内容
@@ -1020,7 +1009,7 @@ public class ExcelUtil<T>
 
     /**
      * 设置某些列的值只能输入预制的数据,显示下拉框.
-     * 
+     *
      * @param sheet 要设置的sheet.
      * @param textlist 下拉框显示的内容
      * @param firstRow 开始行
@@ -1054,7 +1043,7 @@ public class ExcelUtil<T>
 
     /**
      * 解析导出值 0=男,1=女,2=未知
-     * 
+     *
      * @param propertyValue 参数值
      * @param converterExp 翻译注解
      * @param separator 分隔符
@@ -1091,7 +1080,7 @@ public class ExcelUtil<T>
 
     /**
      * 反向解析值 男=0,女=1,未知=2
-     * 
+     *
      * @param propertyValue 参数值
      * @param converterExp 翻译注解
      * @param separator 分隔符
@@ -1128,7 +1117,7 @@ public class ExcelUtil<T>
 
     /**
      * 解析字典值
-     * 
+     *
      * @param dictValue 字典值
      * @param dictType 字典类型
      * @param separator 分隔符
@@ -1141,7 +1130,7 @@ public class ExcelUtil<T>
 
     /**
      * 反向解析值字典值
-     * 
+     *
      * @param dictLabel 字典标签
      * @param dictType 字典类型
      * @param separator 分隔符
@@ -1166,7 +1155,10 @@ public class ExcelUtil<T>
             }
             try
             {
-                temp = Double.valueOf(text);
+                if (StringUtils.isNotEmpty(text))
+                {
+                    temp = Double.valueOf(text);
+                }
             }
             catch (NumberFormatException e)
             {
@@ -1185,16 +1177,24 @@ public class ExcelUtil<T>
             Cell cell = null;
             Row row = sheet.createRow(sheet.getLastRowNum() + 1);
             Set<Integer> keys = statistics.keySet();
-            cell = row.createCell(0);
-            cell.setCellStyle(styles.get("total"));
-            cell.setCellValue("合计");
 
-            for (Integer key : keys)
+            for (int i = 0; i < sheet.getRow(0).getLastCellNum(); i ++)
             {
-                cell = row.createCell(key);
+                cell = row.createCell(i);
                 cell.setCellStyle(styles.get("total"));
-                cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key)));
             }
+
+            int temp = 16384;
+            for (Integer key : keys)
+            {
+                if (temp > key)
+                {
+                    temp = key;
+                }
+                row.getCell(key).setCellValue(DOUBLE_FORMAT.format(statistics.get(key)));
+            }
+
+            row.getCell(temp - 1).setCellValue("合计");
             statistics.clear();
         }
     }
@@ -1211,7 +1211,7 @@ public class ExcelUtil<T>
 
     /**
      * 获取下载路径
-     * 
+     *
      * @param filename 文件名称
      */
     public String getAbsoluteFile(String filename)
@@ -1227,7 +1227,7 @@ public class ExcelUtil<T>
 
     /**
      * 获取bean中的属性值
-     * 
+     *
      * @param vo 实体对象
      * @param field 字段
      * @param excel 注解
@@ -1258,7 +1258,7 @@ public class ExcelUtil<T>
 
     /**
      * 以类的属性的get方法方法形式获取值
-     * 
+     *
      * @param o
      * @param name
      * @return value
@@ -1328,7 +1328,7 @@ public class ExcelUtil<T>
 
     /**
      * 创建工作表
-     * 
+     *
      * @param sheetNo sheet数量
      * @param index 序号
      */
@@ -1349,7 +1349,7 @@ public class ExcelUtil<T>
 
     /**
      * 获取单元格值
-     * 
+     *
      * @param row 获取的行
      * @param column 获取单元格列号
      * @return 单元格值
@@ -1406,4 +1406,4 @@ public class ExcelUtil<T>
         }
         return val;
     }
-}
+}

+ 101 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/excel/StorageDetail.java

@@ -0,0 +1,101 @@
+package com.ruoyi.warehouseBusiness.excel;
+
+import com.ruoyi.common.annotation.Excel;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 仓储明细导出
+ *
+ * @author shz
+ * @date 2021-12-20
+ */
+public class StorageDetail {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 提单号
+     */
+    @Excel(name = "提单号")
+    private String fMblno;
+
+    /**
+     * 货物名称
+     */
+    @Excel(name = "货物名称")
+    private String fProductName;
+
+    /**
+     * 包装
+     */
+    @Excel(name = "包装")
+    private String fPackagespecs;
+
+    /**
+     * 计划原因
+     */
+    @Excel(name = "计划原因")
+    private String fBusinessType;
+
+    /**
+     * 入库日期
+     */
+    @Excel(name = "入库日期", dateFormat = "yyyy-MM-dd")
+    private Date inStockDate;
+
+    /**
+     * 入库件数
+     */
+    @Excel(name = "件数", isStatistics = true)
+    private Long fQtyD;
+
+    /**
+     * 入库重量
+     */
+    @Excel(name = "重量", isStatistics = true)
+    private Float fGrossweightD;
+
+    /**
+     * 出库日期
+     */
+    @Excel(name = "出库日期", dateFormat = "yyyy-MM-dd")
+    private Date outStockDate;
+
+    /**
+     * 车号
+     */
+    @Excel(name = "车号")
+    private String fTruckno;
+
+    /**
+     * 出库件数
+     */
+    @Excel(name = "件数", isStatistics = true)
+    private Long fQtyC;
+
+    /**
+     * 出库重量
+     */
+    @Excel(name = "重量", isStatistics = true)
+    private Float fGrossweightC;
+
+    /**
+     * 堆存天数
+     */
+    @Excel(name = "堆存天数")
+    private Long fBillingDays;
+
+    /**
+     * 出库堆存费
+     */
+    @Excel(name = "出库堆存费", isStatistics = true)
+    private BigDecimal fAmount;
+
+    /**
+     * 结余
+     */
+    @Excel(name = "结余", isStatistics = true)
+    private BigDecimal surplus;
+
+}

+ 16 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehouseBillsMapper.java

@@ -13,6 +13,7 @@ import com.ruoyi.warehouseBusiness.domain.TWareHouseExcelItems;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import com.ruoyi.warehouseBusiness.domain.dto.WarehousebillsDTO;
 import com.ruoyi.warehouseBusiness.domain.vo.WarehouseBillsVO;
+import com.ruoyi.warehouseBusiness.excel.StorageDetail;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
@@ -125,6 +126,21 @@ public interface TWarehouseBillsMapper extends BaseMapper<TWarehouseBills> {
      */
     public List<TWareHouseExcelItems> selectTWarehousebillsItemsList(@Param("fId") Long fid);
 
+    /**
+     * 查询入库信息
+     */
+    public List<StorageDetail> selectInStockDetail(@Param("fId") Long fId);
+
+    /**
+     * 查询非入库信息
+     */
+    public List<StorageDetail> selectNotInStockDetail(@Param("fId") Long fId, @Param("billType") String billType);
+
+    /**
+     * 查询库存信息
+     */
+    public List<StorageDetail> selectInventoryDetail(@Param("fId") Long fId);
+
     List<Map<String, Object>> selectInventorySJRKList(TWarehouseBills tWarehousebills);
 
     List<Map<String, Object>> selectInventorySJCKList(TWarehouseBills tWarehousebills);

+ 8 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehouseBillsService.java

@@ -293,6 +293,14 @@ public interface ITWarehouseBillsService {
     public List<TWareHouseExcelItems> selectTWarehousebillsItemsList(Long fId);
 
     /**
+     * 导出仓储明细
+     *
+     * @param fId
+     * @return
+     */
+    public List<StorageDetail> selectStorageDetail(Long fId);
+
+    /**
      * 查询出入库汇总列表
      *
      * @param tWarehouseBills 仓储主表

+ 13 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -1541,6 +1541,19 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         return tWarehouseBillsMapper.selectTWarehousebillsItemsList(fId);
     }
 
+    /**
+     * 导出仓储明细
+     */
+    @Override
+    public List<StorageDetail> selectStorageDetail(Long fId) {
+        List<StorageDetail> storageDetails = new ArrayList<>();
+        storageDetails.addAll(tWarehouseBillsMapper.selectInStockDetail(fId));
+        storageDetails.addAll(tWarehouseBillsMapper.selectNotInStockDetail(fId, "HQZY"));
+        storageDetails.addAll(tWarehouseBillsMapper.selectNotInStockDetail(fId, "SJCK"));
+        storageDetails.addAll(tWarehouseBillsMapper.selectInventoryDetail(fId));
+        return storageDetails;
+    }
+
     @Override
     public List<Map<String, Object>> selectInventoryList(TWarehouseBills tWarehouseBills) {
         if (StringUtils.isNotNull(tWarehouseBills.getfWarehouseid())) {

+ 65 - 0
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml

@@ -627,6 +627,71 @@
           AND dict.dict_type = 'data_unitfees'
     </select>
 
+    <select id="selectInStockDetail" resultType="com.ruoyi.warehouseBusiness.excel.StorageDetail">
+        SELECT
+        wi.f_mblno AS fMblno,
+        tg.f_name AS fProductName,
+        wi.f_packagespecs AS fPackagespecs,
+        dict.dict_label AS fBusinessType,
+        wi.f_bsdate AS inStockDate,
+        wi.f_qty AS fQtyD,
+        wi.f_grossweight AS fGrossweightD
+        FROM t_warehousebillsitems wi
+        LEFT JOIN t_goods tg ON wi.f_goodsid = tg.f_id
+        LEFT JOIN sys_dict_data dict ON wi.f_business_type = dict.dict_value
+        WHERE
+        wi.f_billtype = 'SJRK'
+        AND dict.dict_type = 'st_in_type'
+        AND dict.status = 0
+        AND wi.f_billstatus = 40
+        <if test="fId != null and fId!= ''">AND wi.f_mblno = (select f_mblno from t_warehousebills where f_id = #{fId})</if>
+    </select>
+
+    <select id="selectNotInStockDetail" resultType="com.ruoyi.warehouseBusiness.excel.StorageDetail">
+        SELECT
+        wf.f_mblno            AS fMblno,
+        wf.f_product_name     AS fProductName,
+        wi.f_packagespecs     AS fPackagespecs,
+        dict.dict_label       AS fBusinessType,
+        wf.f_chargedate       AS inStockDate,
+        wf.f_billing_deadline AS outStockDate,
+        wi.f_truckno          AS fTruckno,
+        wf.f_billing_qty      AS fQtyC,
+        wi.f_grossweight      AS fGrossweightC,
+        wf.f_billing_days     AS fBillingDays,
+        wf.f_amount           AS fAmount
+        FROM t_warehousebills w
+        LEFT JOIN t_warehousebillsfees wf ON w.f_id = wf.f_pid
+        LEFT JOIN t_warehousebillsitems wi ON wi.f_id = wf.src_id
+        LEFT JOIN sys_dict_data dict ON wi.f_business_type = dict.dict_value
+        WHERE w.f_id = #{fId}
+        AND w.f_typeid IS NULL
+        AND dict.status = '0'
+        <if test="billType != null and billType!= '' and billType== 'SJCK'">
+          AND wf.f_billtype = 'SJCK'
+          AND dict.dict_type = 'st_out_type'
+        </if>
+        <if test="billType != null and billType!= '' and billType== 'HQZY'">
+            AND wf.f_billtype = 'HQZY'
+            AND dict.dict_type = 'st_goodstf_type'
+        </if>
+    </select>
+
+    <select id="selectInventoryDetail" resultType="com.ruoyi.warehouseBusiness.excel.StorageDetail">
+        SELECT
+        wf.f_mblno            AS fMblno,
+        wf.f_product_name     AS fProductName,
+        wi.f_packagespecs     AS fPackagespecs,
+        '库存'       AS fBusinessType,
+        wf.f_billing_qty      AS surplus
+        FROM t_warehousebills w
+        LEFT JOIN t_warehousebillsfees wf ON w.f_id = wf.f_pid
+        LEFT JOIN t_warehousebillsitems wi ON wi.f_id = wf.src_id
+        WHERE w.f_id = #{fId}
+        AND w.f_typeid IS NULL
+        AND wf.f_billtype = 'KCZZ'
+    </select>
+
     <select id="selectInventorySJRKList" parameterType="TWarehousebills" resultType="java.util.Map">
         SELECT
         co.f_name AS fName,