李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
 *    Copyright (c) 2018-2025, ztt All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: ztt
 */
 
package com.chinaztt.mes.warehouse.controller;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
import com.chinaztt.mes.warehouse.dto.CheckDetailDTO;
import com.chinaztt.mes.warehouse.dto.CheckMainDTO;
import com.chinaztt.mes.warehouse.entity.CheckDetail;
import com.chinaztt.mes.warehouse.entity.CheckDiffAdjDetail;
import com.chinaztt.mes.warehouse.service.CheckDetailService;
import com.chinaztt.ztt.common.core.util.R;
import com.chinaztt.ztt.common.log.annotation.SysLog;
import com.chinaztt.mes.warehouse.service.CheckMainService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
 
/**
 * 盘点主表
 *
 * @author sunxl
 * @date 2020-12-01 11:06:00
 */
@RestController
@AllArgsConstructor
@RequestMapping("/checkMain" )
@Api(value = "checkMain", tags = "盘点主表管理")
public class CheckMainController {
 
    private final  CheckMainService checkMainService;
    private final CheckDetailService checkDetailService;
    /**
     * 分页查询
     * @param page 分页对象
     * @param checkMainDTO 盘点主表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('warehouse_checkmain_view')" )
    public R getCheckMainPage(Page page, CheckMainDTO checkMainDTO) {
        return R.ok(checkMainService.getCheckMainPage(page,QueryWrapperUtil.gen(checkMainDTO)));
    }
    /**
     * 分页查询
     * @param page 分页对象
     * @param checkMainDTO 盘点主表
     * @return
     */
    @ApiOperation(value = "分页查询过滤盘点主表", notes = "分页查询过滤盘点主表")
    @GetMapping("/page/check" )
    public R getCheckPage(Page page, CheckMainDTO checkMainDTO) {
        return R.ok(checkMainService.getCheckPage(page,QueryWrapperUtil.gen(checkMainDTO)));
    }
    /**
     * 分页查询
     * @param page 分页对象
     * @param checkDetailDTO 盘点明细表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/check/page" )
    public R getCheckDetailPage(Page page, CheckDetailDTO checkDetailDTO) {
        return R.ok(checkDetailService.getCheckDetailPage(page,QueryWrapperUtil.gen(checkDetailDTO)));
    }
    /**
     * 分页查询
     * @param page 分页对象
     * @param checkDetailDTO 盘点差异报告
     * @return
     */
    @ApiOperation(value = "盘点差异报告", notes = "盘点差异报告")
    @GetMapping("/check/detail/page" )
    public R getCheckDetailByPage(Page page, CheckDetailDTO checkDetailDTO) {
        return R.ok(checkDetailService.getCheckDetailByPage(page,QueryWrapperUtil.gen(checkDetailDTO)));
    }
    /**
     * 通过id查询盘点主表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('warehouse_checkmain_view')" )
    public R getByCheckMainId(@PathVariable("id" ) Long id) {
        return R.ok(checkMainService.getCheckMainPageById(id));
    }
    /**
     * 通过id查询盘点明细表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/check/{id}" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(checkDetailService.getCheckDetailById(id));
    }
    /**
     * 新增盘点主表
     * @param checkMain 盘点主表
     * @return R
     */
    @ApiOperation(value = "新增盘点主表", notes = "新增盘点主表")
    @SysLog("新增盘点主表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('warehouse_checkmain_add')" )
    public R saveCheckMain(@RequestBody CheckMainDTO checkMainDTO) {
        return R.ok(checkMainService.fullSave(checkMainDTO));
    }
    /**
     * 新增盘点明细表
     * @param checkDetail 盘点明细表
     * @return R
     */
    @ApiOperation(value = "新增盘点明细表", notes = "新增盘点明细表")
    @SysLog("新增盘点明细表" )
    @PostMapping("/check")
    public R save(@RequestBody CheckDetail checkDetail) {
        return R.ok(checkDetailService.save(checkDetail));
    }
    /**
     * 修改盘点主表
     * @param checkMain 盘点主表
     * @return R
     */
    @ApiOperation(value = "修改盘点主表", notes = "修改盘点主表")
    @SysLog("修改盘点主表" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('warehouse_checkmain_edit')" )
    public R updateByCheckMainId(@RequestBody CheckMainDTO checkMainDTO) {
        return R.ok(checkMainService.updateByCheckMainId(checkMainDTO));
    }
    /**
     * 修改盘点明细表
     * @param checkDetail 盘点明细表
     * @return R
     */
    @ApiOperation(value = "修改盘点明细表", notes = "修改盘点明细表")
    @SysLog("修改盘点明细表" )
    @PutMapping("/check")
    public R updateById(@RequestBody CheckDetail checkDetail) {
        return R.ok(checkDetailService.updateById(checkDetail));
    }
    /**
     * 通过id删除盘点主表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除盘点主表", notes = "通过id删除盘点主表")
    @SysLog("通过id删除盘点主表" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('warehouse_checkmain_del')" )
    public void removeByCheckMainId(@PathVariable Long id) {
       checkMainService.fullDelete(id);
    }
    /**
     * 通过id删除盘点明细表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除盘点明细表", notes = "通过id删除盘点明细表")
    @SysLog("通过id删除盘点明细表" )
    @DeleteMapping("/check/{id}" )
    public R removeById(@PathVariable Long id) {
        return R.ok(checkDetailService.removeById(id));
    }
    /**
     * 执行
     * @param  ids
     * @return R
     */
    @ApiOperation(value = "执行", notes = "执行")
    @SysLog("执行" )
    @PostMapping("/perform")
    public R issue(@RequestBody List<Long> ids) {
        return R.ok(checkMainService.updateWarehouseCheck(ids));
    }
 
    /**
     * 新增盘点差异调整明细表
     * @param checkDiffAdjDetail 盘点差异调整明细表
     * @return R
     */
    @ApiOperation(value = "新增盘点差异调整明细表", notes = "新增盘点差异调整明细表")
    @SysLog("新增盘点差异调整明细表" )
    @PostMapping("/diffAdjDetail" )
    public R save(@RequestBody CheckDiffAdjDetail checkDiffAdjDetail) {
        return R.ok(checkDetailService.fullSave(checkDiffAdjDetail));
    }
    /**
     * 分页查询
     * @param page 分页对象
     * @param checkDiffAdjDetail 盘点差异调整明细表
     * @param id
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/diffAdjDetail/page/{id}" )
    public R getCheckDiffAdjDetailPage(Page page, CheckDiffAdjDetail checkDiffAdjDetail,@PathVariable("id" ) Long id) {
        checkDiffAdjDetail.setId(null);
        return R.ok(checkDetailService.getCheckDiffAdjDetailPage(page, QueryWrapperUtil.gen(checkDiffAdjDetail),id));
    }
    /**
     * 执行
     * @param  ids
     * @return R
     */
    @ApiOperation(value = "执行", notes = "执行")
    @SysLog("提交" )
    @GetMapping("/submit/{id}")
    public R submit(@PathVariable("id" ) Long id) {
        return R.ok(checkMainService.submitWarehouseCheck(id));
    }
}