luqingyang
2023-10-31 f6cfa006799083136a586b551a3b7eb2dd15aa9f
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
package com.consum.base.controller;
 
import com.consum.base.BaseController;
import com.consum.base.pojo.LWhFormInventoryDto;
import com.consum.base.pojo.LWhFormInventoryParam;
import com.consum.base.service.LWhFormInventoryServiceImpl;
import com.consum.model.po.BaseCategory;
import com.consum.model.po.FinSysTenantUser;
import com.consum.model.po.LWhFormInventory;
import com.iplatform.model.po.S_user_core;
import com.walker.db.page.GenericPager;
import com.walker.web.ResponseValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * @Description 盘点
 * @Author 卢庆阳
 * @Date 2023/10/23
 */
@RestController
@RequestMapping("/pc/l/wh/form/inventory")
public class LWhFormInventoryController extends BaseController {
 
    @Autowired
    private LWhFormInventoryServiceImpl lWhFormInventoryService;
 
    /**
     * @Description 新增
     * @Author 卢庆阳
     * @Date 2023/10/31
     */
    @PostMapping("/add")
    public ResponseValue add(@RequestBody LWhFormInventoryParam param) {
        //根据盘点人id查询盘点人
        S_user_core operatorUser = this.getUser(param.getOperatorId());
        //根据监盘人id查询监盘人
        S_user_core operatorUser2 = this.getUser(param.getOperatorId2());
        int result = this.lWhFormInventoryService.add(param, this.getSysInfo(),operatorUser,operatorUser2);
        if (result > 0) return ResponseValue.success(1);
        return ResponseValue.error("新增失败!");
    }
 
    /**
     * @Description 盘点单列表查询
     * @Author 卢庆阳
     * @Date 2023/10/31
     */
    @GetMapping("/list")
    public ResponseValue queryList(LWhFormInventoryParam param) {
        FinSysTenantUser sysInfo = this.getSysInfo();
        if (sysInfo == null) {
            return ResponseValue.error("登录用户信息不存在");
        }
        GenericPager<LWhFormInventory> pager = this.lWhFormInventoryService.queryList(param,sysInfo);
        return ResponseValue.success(pager);
    }
 
    /**
     * @Description 编辑
     * @Author 卢庆阳
     * @Date 2023/10/31
     */
    @PostMapping("/edit")
    public ResponseValue edit(@RequestBody LWhFormInventoryParam param) {
        LWhFormInventory lWhFormInventory = lWhFormInventoryService.get(new LWhFormInventory(param.getId()));
        if (lWhFormInventory == null) {
            return ResponseValue.error("编辑失败!");
        }
        if (lWhFormInventory.getStates() != 0) {
            return ResponseValue.error("未开始状态才能编辑!");
        }
        int num = lWhFormInventoryService.delete(new LWhFormInventory(param.getId()));
        if (num == 0) {
            return ResponseValue.error("编辑失败!");
        }
        ResponseValue add = this.add(param);
        if (add.getCode() == ResponseValue.CODE_SUCCESS) {
            return ResponseValue.success(1);
        }
 
        return ResponseValue.error("编辑失败!");
    }
 
    /**
     * @Description 根据id删除
     */
    @DeleteMapping("/del")
    public ResponseValue delById(Long id) {
        if (id == null) {
            return ResponseValue.error("参数不能为空!");
        }
        LWhFormInventory lWhFormInventory = lWhFormInventoryService.get(new LWhFormInventory(id));
        if (lWhFormInventory == null) {
            return ResponseValue.error("删除失败!");
        }
        if (lWhFormInventory.getStates() != 0) {
            return ResponseValue.error("未开始状态才能删除!");
        }
        int num = lWhFormInventoryService.delete(new LWhFormInventory(id));
        if (num == 0) {
            return ResponseValue.error("删除失败!");
        }
 
        return ResponseValue.success(1);
    }
 
    /**
     * @Description 盘点
     * @Author 卢庆阳
     * @Date 2023/10/31
     */
    @GetMapping("/select/pdList")
    public ResponseValue queryPdList(Long id) {
        if (id == null) {
            return ResponseValue.error("盘点失败!");
        }
 
        List list = this.lWhFormInventoryService.queryPdList(id);
        return ResponseValue.success(list);
    }
 
    /**
     * 暂存
     * @author 卢庆阳
     * @date 2023/10/31
     */
    @PostMapping("/temporaryStorage")
    public ResponseValue temporaryStorage(@RequestBody LWhFormInventoryDto dto) {
        if (dto == null) {
            return ResponseValue.error("参数错误");
        }
 
        int num = this.lWhFormInventoryService.temporaryStorage(dto);
        return num > 0 ? ResponseValue.success(1) : ResponseValue.error("暂存失败!");
    }
 
    /**
     * 完成盘点
     * @author 卢庆阳
     * @date 2023/10/31
     */
    @PostMapping("/finish")
    public ResponseValue finishPd(@RequestBody LWhFormInventoryDto dto) {
        if (dto == null) {
            return ResponseValue.error("参数错误");
        }
 
        int num = this.lWhFormInventoryService.finishPd(dto);
        return num > 0 ? ResponseValue.success(1) : ResponseValue.error("暂存失败!");
    }
 
 
 
}