liding
9 天以前 cf65d0a608b21f07dc50a98b864dfe47def4f86b
src/main/java/com/ruoyi/stock/controller/StockInRecordController.java
@@ -7,20 +7,26 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.stock.dto.StockInRecordDto;
import com.ruoyi.stock.service.StockInRecordService;
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;
@RestController
@Api(tags = "采购入库")
@Api(tags = "入库")
@RequestMapping("/stockInRecord")
public class StockInRecordController {
    @Autowired
    private StockInRecordService stockInRecordService;
    @Autowired
    private WeighbridgeDocGenerator weighbridgeDocGenerator;
    @GetMapping("/listPage")
    @Log(title = "生产入库-入库管理-列表", businessType = BusinessType.OTHER)
@@ -30,25 +36,33 @@
        return AjaxResult.success(result);
    }
    @PostMapping("")
    @Log(title = "入库管理-新增入库", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody StockInRecordDto stockInRecordDto) {
        return AjaxResult.success(stockInRecordService.add(stockInRecordDto));
    }
    @PutMapping("/{id}")
    @Log(title = "入库管理-更新入库", businessType = BusinessType.UPDATE)
    public AjaxResult update(@PathVariable("id") Long id, @RequestBody StockInRecordDto stockInRecordDto) {
        return AjaxResult.success(stockInRecordService.update(id, stockInRecordDto));
    @PostMapping("/editStockInStock")
    @PreAuthorize("@ss.hasPermi('receipt_edit')")
    @ApiOperation("编辑入库记录")
    public AjaxResult editStockInStock(@RequestBody StockInRecordDto stockInRecordDto) {
        if (stockInRecordDto.getId() == null) {
            return AjaxResult.error("入库记录ID不能为空");
        }
        stockInRecordDto.setStockInNum(stockInRecordDto.getNetWeight());
        String absoluteDocPath = weighbridgeDocGenerator.generateWeighbridgeDoc(stockInRecordDto);
        stockInRecordDto.setWeighbridgeDocPath(absoluteDocPath);
        return AjaxResult.success(stockInRecordService.updateById(stockInRecordDto));
    }
    @DeleteMapping("")
    @PreAuthorize("@ss.hasPermi('receipt_cancel')")
    @Log(title = "入库管理-删除入库", businessType = BusinessType.DELETE)
    public AjaxResult delete(@RequestBody List<Long> ids) {
        if(CollectionUtils.isEmpty(ids)){
        if (CollectionUtils.isEmpty(ids)) {
            return AjaxResult.error("请选择至少一条数据");
        }
        return AjaxResult.success(stockInRecordService.batchDelete(ids));
    }
    @PostMapping("/exportStockInRecord")
    @ApiOperation("导出入库记录")
    public void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto) {
        stockInRecordService.exportStockInRecord(response, stockInRecordDto);
    }
}