无关风月
2024-09-03 56dfe0d4bf81262622a1919cceb2b039fd356209
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
package com.ruoyi.management.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.management.domain.*;
import com.ruoyi.management.domain.dto.*;
import com.ruoyi.management.domain.vo.SlGoodsShelfVO;
import com.ruoyi.management.mapper.SlVolumeProductionRkMapper;
import com.ruoyi.management.service.SlGoodsShelfService;
import com.ruoyi.management.service.SlStoreManagementService;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * <p>
 * 货架表 前端控制器
 * </p>
 *
 * @author hjl
 * @since 2024-06-25
 */
@RestController
@RequestMapping("/sl-goods-shelf")
@Api(value = "货架管理", tags = "货架管理", description = "货架管理")
public class SlGoodsShelfController {
 
    @Resource
    private SlGoodsShelfService  slGoodsShelfService;
    @Resource
    private SlVolumeProductionRkMapper slVolumeProductionRkMapper;
    @Resource
    private TokenService tokenService;
    @PostMapping("/getGoodsShelfList")
    @ApiOperation(value = "分页获货架表管理")
    public R<PageDTO<SlGoodsShelfVO>> getGoodsShelfList(@RequestBody SlGoodsShelfQuery slGoodsShelfQuery) {
        tokenService.getLoginUser();
        return R.ok(slGoodsShelfService.getGoodsShelfList(slGoodsShelfQuery));
    }
    @PostMapping("/getGoodsShelfList1")
    @ApiOperation(value = "大屏--分页获取配置了平面图的货架表管理")
    public R<PageDTO<SlGoodsShelfVO>> getGoodsShelfList1(@RequestBody SlGoodsShelfQuery slGoodsShelfQuery) {
        tokenService.getLoginUser();
        return R.ok(slGoodsShelfService.getGoodsShelfList1(slGoodsShelfQuery));
    }
 
    @PostMapping("/addSlGoodsShelf")
    @ApiOperation(value = "添加/修改货架管理")
    public R addSlGoodsShelf(@RequestBody SlGoodsShelfDTO slGoodsShelfDTO) {
        tokenService.getLoginUser();
        return slGoodsShelfService.addSlGoodsShelf(slGoodsShelfDTO);
    }
 
    @GetMapping("/SlGoodsShelf/{id}")
    @ApiOperation(value = "货架管理详情")
    public R<SlGoodsShelfVO> getSlGoodsShelfOne(@ApiParam(name = "id", value = "货架管理id", required = true) @PathVariable("id") Long id) {
        tokenService.getLoginUser();
        return R.ok(slGoodsShelfService.getSlGoodsShelfOne(id));
    }
    @Resource
    private SlStoreManagementService SlStoreManagementService;
    @Resource
    private SysUserClient sysUserClient;
    @ApiOperation("删除货架")
    @DeleteMapping("/{id}")
    public R<?> delStoreManagement(
            @ApiParam(name = "id", value = "货架管理id", required = true) @PathVariable("id") Long id) {
        tokenService.getLoginUser();
        List<SlVolumeProductionRk> slVolumeProductionRks = slVolumeProductionRkMapper.selectList(new QueryWrapper<SlVolumeProductionRk>()
                .eq("shelf_id", id)
                .ge("repertory_zhai",0)
                .isNotNull("new_add_time")
                .eq("del_flag", "0"));
        if (slVolumeProductionRks.size() > 0) {
            return R.fail("删除失败,当前货架存有物资");
        }
        // 判断当前登陆人等级是否大于等于仓库等级
        Long userId = SecurityUtils.getUserId();
        SysUser data = sysUserClient.getSysUser(userId).getData();
 
        SlGoodsShelf byId = slGoodsShelfService.getById(id);
        SlStoreManagement byId1 = SlStoreManagementService.getById(byId.getStoreManagementId());
        if (data!=null){
            if (!data.getUserType().equals("00")){
                if (data.getRoleType().equals(byId1.getStoreManagementGrade())){
                    if (data.getRoleType().equals(byId1.getStoreManagementGrade())){
                        // 判断所在地是否一样
                        switch (data.getRoleType()){
                            case 3:
                                if (!data.getCityCode().equals(byId1.getCityCode())){
                                    return R.fail("权限不足");
                                }
                                break;
                            case 4:
                                if (!data.getCountyCode().equals(byId1.getCountyCode())){
                                    return R.fail("权限不足");
                                }
                                break;
                            case 5:
                                if (!data.getTownCode().equals(byId1.getTownCode())){
                                    return R.fail("权限不足");
                                }
                            case 6:
                                if (!data.getTownCode().equals(byId1.getTownCode())){
                                    return R.fail("权限不足");
                                }
                                break;
                        }
                    }
                }else{
                    return R.fail("权限不足");
                }
            }
        }
        byId.setDelFlag("1");
        slGoodsShelfService.updateById(byId);
        return R.ok();
    }
 
    @PostMapping("/wfanzGoodsShelfList")
    @ApiOperation(value = "货架获放置")
    public R<List<SlGoodsShelf>> wfanzGoodsShelfList(@RequestBody GoodsShelfQuery goodsShelfQuery) {
        tokenService.getLoginUser();
        return R.ok(slGoodsShelfService.wfanzGoodsShelfList(goodsShelfQuery));
    }
 
    @PostMapping("/wfanzGoodsShelfListDel/{id}")
    @ApiOperation(value = "货架获放置删除")
    public R wfanzGoodsShelfListDel(
            @ApiParam(name = "id", value = "货架管理id", required = true) @PathVariable("id") Long id){
        tokenService.getLoginUser();
        SlGoodsShelf byId = slGoodsShelfService.getById(id);
        byId.setIsStoreManagement(1);
        slGoodsShelfService.updateById(byId);
        return R.ok();
    }
 
    @PostMapping("/fanzGoodsShelfList")
    @ApiOperation(value = "货架放置到图片")
    public R fanzGoodsShelfList(@RequestBody GoodsShelfDTO goodsShelfDTO) {
        tokenService.getLoginUser();
        slGoodsShelfService.fanzGoodsShelfList(goodsShelfDTO);
        return R.ok();
    }
 
    @PostMapping("/getStoreManagementimgSheif")
    @ApiOperation(value = "获取仓库管理平面圖的货架")
    public R<List<SlGoodsShelf>> getStoreManagementimgSheif(@RequestBody GoodsShelfDTO goodsShelfDTO) {
        tokenService.getLoginUser();
        return R.ok(slGoodsShelfService.getStoreManagementimgSheif(goodsShelfDTO));
    }
 
    @PostMapping("/getGoodsSheManagementlfList")
    @ApiOperation(value = "分页通过仓库和层数货架表管理")
    public R<List<SlGoodsShelf>> getGoodsSheManagementlfList(@RequestBody SlGoodsShelfQuery slGoodsShelfQuery) {
        tokenService.getLoginUser();
        return R.ok(slGoodsShelfService.getGoodsSheManagementlfList(slGoodsShelfQuery));
    }
 
}