2026-07-01 6b5f7c66fc40d7f6099d561e31a34fbd50dd20d3
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
package cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.plan;
 
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.plan.vo.MesWmStockTakingPlanPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.plan.vo.MesWmStockTakingPlanRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.plan.vo.MesWmStockTakingPlanSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.plan.MesWmStockTakingPlanDO;
import cn.iocoder.yudao.module.mes.service.wm.stocktaking.plan.MesWmStockTakingPlanService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.io.IOException;
 
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - MES 盘点方案")
@RestController
@RequestMapping("/mes/wm/stocktaking-plan")
@Validated
public class MesWmStockTakingPlanController {
 
    @Resource
    private MesWmStockTakingPlanService stockTakingPlanService;
 
    @PostMapping("/create")
    @Operation(summary = "创建盘点方案")
    @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-plan:create')")
    public CommonResult<Long> createStockTakingPlan(@Valid @RequestBody MesWmStockTakingPlanSaveReqVO createReqVO) {
        return success(stockTakingPlanService.createStockTakingPlan(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "修改盘点方案")
    @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-plan:update')")
    public CommonResult<Boolean> updateStockTakingPlan(@Valid @RequestBody MesWmStockTakingPlanSaveReqVO updateReqVO) {
        stockTakingPlanService.updateStockTakingPlan(updateReqVO);
        return success(true);
    }
 
    @PutMapping("/update-status")
    @Operation(summary = "更新盘点方案状态")
    @Parameters({
            @Parameter(name = "id", description = "编号", required = true),
            @Parameter(name = "status", description = "状态", required = true)
    })
    @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-plan:update')")
    public CommonResult<Boolean> updateStockTakingPlanStatus(@RequestParam("id") Long id,
                                                             @RequestParam("status") Integer status) {
        stockTakingPlanService.updateStockTakingPlanStatus(id, status);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除盘点方案")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-plan:delete')")
    public CommonResult<Boolean> deleteStockTakingPlan(@RequestParam("id") Long id) {
        stockTakingPlanService.deleteStockTakingPlan(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得盘点方案")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-plan:query')")
    public CommonResult<MesWmStockTakingPlanRespVO> getStockTakingPlan(@RequestParam("id") Long id) {
        MesWmStockTakingPlanDO plan = stockTakingPlanService.getStockTakingPlan(id);
        return success(plan == null ? null : BeanUtils.toBean(plan, MesWmStockTakingPlanRespVO.class));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得盘点方案分页")
    @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-plan:query')")
    public CommonResult<PageResult<MesWmStockTakingPlanRespVO>> getStockTakingPlanPage(@Valid MesWmStockTakingPlanPageReqVO pageReqVO) {
        PageResult<MesWmStockTakingPlanDO> pageResult = stockTakingPlanService.getStockTakingPlanPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, MesWmStockTakingPlanRespVO.class));
    }
 
    @GetMapping("/export-excel")
    @Operation(summary = "导出盘点方案 Excel")
    @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-plan:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportStockTakingPlanExcel(@Valid MesWmStockTakingPlanPageReqVO pageReqVO,
                                           HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        PageResult<MesWmStockTakingPlanDO> pageResult = stockTakingPlanService.getStockTakingPlanPage(pageReqVO);
        ExcelUtils.write(response, "盘点方案.xls", "数据", MesWmStockTakingPlanRespVO.class,
                BeanUtils.toBean(pageResult.getList(), MesWmStockTakingPlanRespVO.class));
    }
 
}