6 天以前 1e123568c2f561013f5636e45dc0db30b17a3517
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.ruoyi.stock.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
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.StockCheckStartDto;
import com.ruoyi.stock.pojo.StockCheckDetail;
import com.ruoyi.stock.pojo.StockCheckMain;
import com.ruoyi.stock.service.StockCheckService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@RestController
@RequestMapping("/stockCheck")
@RequiredArgsConstructor
@Tag(name = "库存盘点")
public class StockCheckController {
 
    private final StockCheckService stockCheckService;
 
    @PostMapping("/start")
    @Log(title = "Start stock check", businessType = BusinessType.INSERT)
    @Operation(summary = "发起盘点(生成账面快照明细)")
    public R start(@RequestBody StockCheckStartDto dto) {
        return stockCheckService.start(dto, dto.getProductModelIds());
    }
 
    @GetMapping("/listPage")
    @Operation(summary = "盘点单分页")
    public R<IPage<StockCheckMain>> listPage(Page<StockCheckMain> page, StockCheckMain query) {
        return R.ok(stockCheckService.listPage(page, query));
    }
 
    @GetMapping("/{id}")
    @Operation(summary = "盘点单详情(主表)")
    public R<StockCheckMain> getInfo(@PathVariable Long id) {
        return R.ok(stockCheckService.getMain(id));
    }
 
    @GetMapping("/detailPage")
    @Operation(summary = "盘点明细分页(onlyDiff=true只看已录入且有差异)")
    public R<IPage<StockCheckDetail>> detailPage(Page<StockCheckDetail> page,
                                                 @RequestParam Long mainId,
                                                 @RequestParam(required = false) Boolean onlyDiff) {
        return R.ok(stockCheckService.detailPage(page, mainId, onlyDiff));
    }
 
    @PutMapping("/entry")
    @Log(title = "Stock check entry", businessType = BusinessType.UPDATE)
    @Operation(summary = "录入实盘数量 [{id,actualQty,remark}...]")
    public R entry(@RequestBody List<StockCheckDetail> details) {
        return stockCheckService.entry(details);
    }
 
    @PostMapping("/finish")
    @Log(title = "Finish stock check", businessType = BusinessType.UPDATE)
    @Operation(summary = "完成盘点(差异生成待审核调账单据)")
    public R finish(@RequestBody StockCheckMain main) {
        return stockCheckService.finish(main.getId());
    }
 
    @PostMapping("/cancel")
    @Log(title = "Cancel stock check", businessType = BusinessType.UPDATE)
    @Operation(summary = "取消盘点(仅盘点中)")
    public R cancel(@RequestBody StockCheckMain main) {
        return stockCheckService.cancel(main.getId());
    }
 
    @DeleteMapping("/delete")
    @Log(title = "Delete stock check", businessType = BusinessType.DELETE)
    @Operation(summary = "删除盘点单(连带删除明细)")
    public R delete(@RequestBody List<Long> ids) {
        return stockCheckService.delete(ids);
    }
 
    @GetMapping("/diffList")
    @Operation(summary = "差异分析列表")
    public R<List<StockCheckDetail>> diffList(@RequestParam Long mainId) {
        return R.ok(stockCheckService.diffList(mainId));
    }
 
    @GetMapping("/diffList/export")
    @Log(title = "Export stock check diff", businessType = BusinessType.EXPORT)
    @Operation(summary = "差异分析导出")
    public void diffExport(HttpServletResponse response, @RequestParam Long mainId) {
        List<StockCheckDetail> list = stockCheckService.diffList(mainId);
        ExcelUtil<StockCheckDetail> util = new ExcelUtil<>(StockCheckDetail.class);
        util.exportExcel(response, list, "盘点差异分析");
    }
 
    @GetMapping("/export")
    @Log(title = "Export stock check", businessType = BusinessType.EXPORT)
    @Operation(summary = "盘点单导出")
    public void export(HttpServletResponse response, StockCheckMain query) {
        List<StockCheckMain> list = stockCheckService.listForExport(query);
        ExcelUtil<StockCheckMain> util = new ExcelUtil<>(StockCheckMain.class);
        util.exportExcel(response, list, "库存盘点单");
    }
 
    @GetMapping("/detailExport")
    @Log(title = "Export stock check detail", businessType = BusinessType.EXPORT)
    @Operation(summary = "盘点明细导出")
    public void detailExport(HttpServletResponse response, @RequestParam Long mainId) {
        List<StockCheckDetail> list = stockCheckService.detailPage(new Page<>(1, -1), mainId, null).getRecords();
        ExcelUtil<StockCheckDetail> util = new ExcelUtil<>(StockCheckDetail.class);
        util.exportExcel(response, list, "盘点明细");
    }
}