24282 1 жил өмнө
parent
commit
686484b7cf

+ 1 - 1
sd-business/src/main/java/com/sd/business/controller/inventory/InventoryController.java

@@ -70,7 +70,7 @@ public class InventoryController {
      */
     @NonInterception
     @GetMapping("/exportExcel")
-    public void exportExcel(@RequestBody InventorySelectDto dto) {
+    public void exportExcel(InventorySelectDto dto) {
         inventoryService.exportExcel(dto);
     }
 

+ 5 - 2
sd-business/src/main/java/com/sd/business/entity/inventory/po/Inventory.java

@@ -1,6 +1,7 @@
 package com.sd.business.entity.inventory.po;
 
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.ruoyi.common.core.domain.BasePo;
 import lombok.Getter;
@@ -39,13 +40,15 @@ public class Inventory extends BasePo {
     /**
      * 数量
      */
-    @ExcelProperty(value = "库存", index = 5)
+    @ColumnWidth(15)
+    @ExcelProperty(value = "库存", index = 4)
     private BigDecimal quantity;
 
     /**
      * 结存单价
      */
-    @ExcelProperty(value = "结存单价", index = 4)
+    @ColumnWidth(15)
+    @ExcelProperty(value = "结存单价", index = 3)
     private BigDecimal balanceUnitPrice;
 
 }

+ 11 - 4
sd-business/src/main/java/com/sd/business/entity/inventory/vo/InventoryVo.java

@@ -1,6 +1,8 @@
 package com.sd.business.entity.inventory.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import com.sd.business.entity.inventory.po.Inventory;
 import lombok.Getter;
 import lombok.Setter;
@@ -15,24 +17,28 @@ import java.math.BigDecimal;
  */
 @Getter
 @Setter
+@ExcelIgnoreUnannotated
 public class InventoryVo extends Inventory {
 
     /**
      * 仓库名称
      */
-    @ExcelProperty(value = "仓库", index = 1)
+    @ColumnWidth(15)
+    @ExcelProperty(value = "仓库", index = 0)
     private String warehouseName;
 
     /**
      * 品名
      */
-    @ExcelProperty(value = "品名", index = 2)
+    @ColumnWidth(50)
+    @ExcelProperty(value = "品名", index = 1)
     private String bomSpecName;
 
     /**
      * 品号
      */
-    @ExcelProperty(value = "品号", index = 3)
+    @ColumnWidth(15)
+    @ExcelProperty(value = "品号", index = 2)
     private String bomSpecCode;
 
     /**
@@ -43,7 +49,8 @@ public class InventoryVo extends Inventory {
     /**
      * 结存总价
      */
-    @ExcelProperty(value = "结存总价", index = 6)
+    @ColumnWidth(15)
+    @ExcelProperty(value = "结存总价", index = 5)
     private BigDecimal totalPrice;
 
 }

+ 4 - 5
sd-business/src/main/java/com/sd/business/service/inventory/impl/InventoryServiceImpl.java

@@ -1,5 +1,6 @@
 package com.sd.business.service.inventory.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.exception.ServiceException;
@@ -28,10 +29,7 @@ import org.springframework.stereotype.Service;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -190,7 +188,8 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
     public void exportExcel(InventorySelectDto dto) {
         IWrapper<Inventory> wrapper = getDtoWrapper(dto);
         List<InventoryVo> list = baseMapper.getList(wrapper);
-        ExcelUtil.export(response, list, InventoryVo.class);
+        ExcelUtil.export(response, DateUtil.format(new Date(), "yyyy-MM-dd库存数据"),
+                "库存数据", list, InventoryVo.class);
     }
 
     /**