无关风月
2024-09-03 56dfe0d4bf81262622a1919cceb2b039fd356209
ruoyi-modules/ruoyi-management/src/main/java/com/ruoyi/management/controller/SlGoodsShelfController.java
@@ -4,11 +4,16 @@
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;
@@ -34,29 +39,43 @@
    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)
@@ -65,7 +84,44 @@
        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();
@@ -74,6 +130,7 @@
    @PostMapping("/wfanzGoodsShelfList")
    @ApiOperation(value = "货架获放置")
    public R<List<SlGoodsShelf>> wfanzGoodsShelfList(@RequestBody GoodsShelfQuery goodsShelfQuery) {
        tokenService.getLoginUser();
        return R.ok(slGoodsShelfService.wfanzGoodsShelfList(goodsShelfQuery));
    }
@@ -81,6 +138,7 @@
    @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);
@@ -90,6 +148,7 @@
    @PostMapping("/fanzGoodsShelfList")
    @ApiOperation(value = "货架放置到图片")
    public R fanzGoodsShelfList(@RequestBody GoodsShelfDTO goodsShelfDTO) {
        tokenService.getLoginUser();
        slGoodsShelfService.fanzGoodsShelfList(goodsShelfDTO);
        return R.ok();
    }
@@ -97,12 +156,14 @@
    @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));
    }