package com.ruoyi.consumables.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.consumables.dto.ConsumablesOutRecordDto; import com.ruoyi.consumables.service.ConsumablesOutRecordService; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.stock.dto.StockInRecordDto; import com.ruoyi.stock.word.WeighbridgeDocGenerator; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.List; /** *

* 耗材出库记录表 前端控制器 *

* * @author 芯导软件(江苏)有限公司 * @since 2026-01-21 05:27:04 */ @Api(tags = "耗材出库") @RestController @RequestMapping("/consumablesOutRecord") public class ConsumablesOutRecordController { @Autowired private ConsumablesOutRecordService consumablesUnInventoryDto; @Autowired private WeighbridgeDocGenerator weighbridgeDocGenerator; @GetMapping("/listPage") @Log(title = "生产出库-出库管理-列表", businessType = BusinessType.OTHER) @ApiOperation(value = "出库管理列表") public AjaxResult listPage(Page page, ConsumablesOutRecordDto consumablesOutRecordDto) { IPage result = consumablesUnInventoryDto.listPage(page, consumablesOutRecordDto); return AjaxResult.success(result); } @PostMapping("") @Log(title = "出库管理-新增出库", businessType = BusinessType.INSERT) public AjaxResult add(@RequestBody ConsumablesOutRecordDto consumablesOutRecordDto) { return AjaxResult.success(consumablesUnInventoryDto.add(consumablesOutRecordDto)); } @PostMapping("/editStockOut") @PreAuthorize("@ss.hasPermi('c_dispatch_edit')") @ApiOperation("编辑出库记录") public AjaxResult update(@RequestBody ConsumablesOutRecordDto consumablesOutRecordDto) { if (consumablesOutRecordDto.getId() == null) { return AjaxResult.error("出库记录ID不能为空"); } StockInRecordDto stockInRecordDto = new StockInRecordDto(); BeanUtils.copyProperties(consumablesOutRecordDto, stockInRecordDto); stockInRecordDto.setStockInNum(consumablesOutRecordDto.getStockOutNum()); String absoluteDocPath = weighbridgeDocGenerator.generateWeighbridgeDoc(stockInRecordDto); consumablesOutRecordDto.setWeighbridgeDocPath(absoluteDocPath); consumablesOutRecordDto.setStockOutNum(consumablesOutRecordDto.getQualitity()); return AjaxResult.success(consumablesUnInventoryDto.updateById(consumablesOutRecordDto)); } @DeleteMapping("") @PreAuthorize("@ss.hasPermi('c_dispatch_cancel')") @Log(title = "出库管理-删除出库", businessType = BusinessType.DELETE) public AjaxResult delete(@RequestBody List ids) { if(CollectionUtils.isEmpty(ids)){ return AjaxResult.error("请选择至少一条数据"); } return AjaxResult.success(consumablesUnInventoryDto.batchDelete(ids)); } @PostMapping("/exportConsumablesOutRecord") @ApiOperation("导出出库记录") public void exportConsumablesOutRecord(HttpServletResponse response, ConsumablesOutRecordDto consumablesOutRecordDto) { consumablesUnInventoryDto.exportConsumablesOutRecord(response,consumablesOutRecordDto); } }