package com.ruoyi.consumables.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.consumables.dto.ConsumablesInventoryDto; import com.ruoyi.consumables.execl.ConsumablesInventoryExportData; import com.ruoyi.consumables.service.ConsumablesInventoryService; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.domain.R; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; /** *

* 耗材库存表 前端控制器 *

* * @author 芯导软件(江苏)有限公司 * @since 2026-01-21 04:16:36 */ @RestController @RequestMapping("/consumablesInventory") @Api(tags = "耗材库存表") public class ConsumablesInventoryController { @Autowired private ConsumablesInventoryService consumablesInventoryService; @GetMapping("/pageConsumablesInventory") @ApiOperation("分页查询库存") public R pageConsumablesInventory(Page page, ConsumablesInventoryDto consumablesInventoryDto) { IPage ConsumablesInventoryDtoIPage = consumablesInventoryService.pageConsumablesInventory(page, consumablesInventoryDto); return R.ok(ConsumablesInventoryDtoIPage); } @PostMapping("/addConsumablesInventory") @ApiOperation("新增库存") public R addConsumablesInventory(@RequestBody ConsumablesInventoryDto consumablesInventoryDto) { consumablesInventoryDto.setRecordType(String.valueOf(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode())); consumablesInventoryDto.setRecordId(0L); return R.ok(consumablesInventoryService.addConsumablesInventory(consumablesInventoryDto)); } @PostMapping("/subtractConsumablesInventory") @ApiOperation("扣减库存") public R subtractConsumablesInventory(@RequestBody ConsumablesInventoryDto consumablesInventoryDto) { consumablesInventoryDto.setRecordType(String.valueOf(StockOutQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_OUT.getCode())); consumablesInventoryDto.setRecordId(0L); return R.ok(consumablesInventoryService.subtractConsumablesInventory(consumablesInventoryDto)); } @PostMapping("importConsumablesInventory") @ApiOperation("导入库存") public R importConsumablesInventory(MultipartFile file) { return consumablesInventoryService.importConsumablesInventory(file); } @Log(title = "下载库存导入模板", businessType = BusinessType.EXPORT) @PostMapping("/downloadConsumablesInventory") public void downloadConsumablesInventory(HttpServletResponse response) { List list = new ArrayList<>(); ExcelUtil util = new ExcelUtil<>(ConsumablesInventoryExportData.class); util.exportExcel(response, list, "库存模板"); } @PostMapping("/exportConsumablesInventory") @ApiOperation("导出库存") public void exportConsumablesInventory(HttpServletResponse response, ConsumablesInventoryDto consumablesInventoryDto) { consumablesInventoryService.exportConsumablesInventory(response, consumablesInventoryDto); } @GetMapping("ConsumablesInventoryPage") @ApiOperation("库存报表查询") public R ConsumablesInventoryPage(Page page, ConsumablesInventoryDto consumablesInventoryDto) { return R.ok(consumablesInventoryService.consumablesInventoryPage(consumablesInventoryDto,page)); } @GetMapping("ConsumablesInAndOutRecord") @ApiOperation("统计各个产品的入库和出库记录") public R ConsumablesInAndOutRecord(ConsumablesInventoryDto consumablesInventoryDto, Page page) { return R.ok(consumablesInventoryService.consumablesInAndOutRecord(consumablesInventoryDto,page)); } @PostMapping("/frozenConsumables") @ApiOperation("冻结库存") public R frozenConsumables(@RequestBody ConsumablesInventoryDto consumablesInventoryDto) { return R.ok(consumablesInventoryService.frozenConsumables(consumablesInventoryDto)); } @PostMapping("/thawConsumables") @ApiOperation("解冻库存") public R thawConsumables(@RequestBody ConsumablesInventoryDto consumablesInventoryDto) { return R.ok(consumablesInventoryService.thawConsumables(consumablesInventoryDto)); } }