src/main/java/com/ruoyi/stock/controller/StockInventoryController.java
@@ -8,11 +8,15 @@
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.stock.dto.FinishedProductTreeDto;
import com.ruoyi.stock.dto.StockInventoryDto;
import com.ruoyi.stock.execl.FinishedProductInventoryExportData;
import com.ruoyi.stock.execl.NonFinishedProductInventoryExportData;
import com.ruoyi.stock.execl.StockInventoryExportData;
import com.ruoyi.stock.service.StockInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -46,6 +50,23 @@
        return R.ok(stockInventoryDtoIPage);
    }
    /**
     * 查询成品库存树
     */
    @ApiOperation("查询成品库存树")
    @GetMapping("/finishedProductList")
    public List<FinishedProductTreeDto> finishedProductList(StockInventoryDto stockInventoryDto) {
        return stockInventoryService.finishedProductList(stockInventoryDto);
    }
    @GetMapping("/pageListCombinedStockInventory")
    @Operation(summary = "分页查询联合库存列表")
    public R pageListCombinedStockInventory(Page page, StockInventoryDto stockInventoryDto) {
        IPage<StockInventoryDto> stockInventoryDtoIPage = stockInventoryService.pageListCombinedStockInventory(page, stockInventoryDto);
        return R.ok(stockInventoryDtoIPage);
    }
    @PostMapping("/addstockInventory")
    @PreAuthorize("@ss.hasPermi('add:stockInventory')")
    @ApiOperation("新增库存")
@@ -68,22 +89,33 @@
    @PostMapping("importStockInventory")
    @ApiOperation("导入库存")
    public R importStockInventory(MultipartFile file) {
        return stockInventoryService.importStockInventory(file);
    public R importStockInventory(MultipartFile file,
                                  @RequestParam Integer productType) {
        return stockInventoryService.importStockInventory(file, productType);
    }
    @Log(title = "下载库存导入模板", businessType = BusinessType.EXPORT)
    @PostMapping("/downloadStockInventory")
    public void downloadStockInventory(HttpServletResponse response) {
        List<StockInventoryExportData> list = new ArrayList<>();
        ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class);
        util.exportExcel(response, list, "库存模板");
    public void downloadStockInventory(HttpServletResponse response,
                                        @RequestParam Integer productType) {
        // productType: 1=成品, 0=非成品
        if (productType == 1) {
            List<FinishedProductInventoryExportData> list = new ArrayList<>();
            ExcelUtil<FinishedProductInventoryExportData> util = new ExcelUtil<>(FinishedProductInventoryExportData.class);
            util.exportExcel(response, list, "成品库存模板");
        } else {
            List<NonFinishedProductInventoryExportData> list = new ArrayList<>();
            ExcelUtil<NonFinishedProductInventoryExportData> util = new ExcelUtil<>(NonFinishedProductInventoryExportData.class);
            util.exportExcel(response, list, "非成品库存模板");
        }
    }
    @PostMapping("/exportStockInventory")
    @ApiOperation("导出库存")
    public void exportStockInventory(HttpServletResponse response, StockInventoryDto stockInventoryDto) {
        stockInventoryService.exportStockInventory(response, stockInventoryDto);
    public void exportStockInventory(HttpServletResponse response,
                                      StockInventoryDto stockInventoryDto,
                                      @RequestParam Integer productType) {
        stockInventoryService.exportStockInventory(response, stockInventoryDto, productType);
    }
    @GetMapping("stockInventoryPage")