无关风月
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
package com.ruoyi.management.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.management.domain.ManagementGoodsMaterials;
import com.ruoyi.management.domain.SlGoodsMaterials;
import com.ruoyi.management.domain.SlStoreManagement;
import com.ruoyi.management.domain.SlVolumeProductionRk;
import com.ruoyi.management.domain.dto.*;
import com.ruoyi.management.domain.vo.SlGoodsMaterialsVO;
import com.ruoyi.management.domain.vo.SlGoodsShelfVO;
import com.ruoyi.management.domain.vo.StoreManagementGoodSmaterialsVO;
import com.ruoyi.management.mapper.ManagementGoodsMaterialsMapper;
import com.ruoyi.management.mapper.SlVolumeProductionCkMapper;
import com.ruoyi.management.mapper.SlVolumeProductionRkMapper;
import com.ruoyi.management.mapper.SlVolumeProductionZyMapper;
import com.ruoyi.management.service.ManagementGoodsMaterialsService;
import com.ruoyi.management.service.SlGoodsMaterialsService;
import com.ruoyi.management.service.SlStoreManagementService;
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-materials")
@Api(value = "物资管理接口", tags = "物资管理接口", description = "物资管理接口")
public class SlGoodsMaterialsController {
 
    @Resource
    private TokenService tokenService;
    @PostMapping("/getGoodSmaterialsList")
    @ApiOperation(value = "分页获物资管理")
    public R<PageDTO<SlGoodsMaterialsVO>> getGoodSmaterialsList(@RequestBody SlGoodsMaterialsQuery slGoodsMaterialsQuery) {
        tokenService.getLoginUser();
        return R.ok(slGoodsMaterialsService.getGoodSmaterialsList(slGoodsMaterialsQuery));
    }
 
    @PostMapping("/addGoodSmaterials")
    @ApiOperation(value = "添加/修改物资管理")
    public R addSlGoodsShelf(@RequestBody SlGoodsMaterialsDTO slGoodsMaterialsDTO) {
        tokenService.getLoginUser();
        slGoodsMaterialsService.addSlGoodsShelf(slGoodsMaterialsDTO);
        return R.ok();
    }
    @Resource
    private SlGoodsMaterialsService slGoodsMaterialsService;
 
    @Resource
    private ManagementGoodsMaterialsMapper managementGoodsMaterialsMapper;
    @Resource
    private SlVolumeProductionRkMapper slVolumeProductionRkMapper;
    @Resource
    private SlVolumeProductionCkMapper slVolumeProductionCkMapper;
    @Resource
    private SlVolumeProductionZyMapper slVolumeProductionZyMapper;
    @Resource
    private SlStoreManagementService storeManagementService;
    @ApiOperation("删除物资管理")
    @DeleteMapping("/{id}")
    public R<?> delStoreManagement(
            @ApiParam(name = "id", value = "货架管理id", required = true) @PathVariable("id") Long id) {
        tokenService.getLoginUser();
        // 判断当前物资有没有存在于入库 出库 转移记录 和库存
        List<ManagementGoodsMaterials> goodsMaterialsId = managementGoodsMaterialsMapper.selectList(new QueryWrapper<ManagementGoodsMaterials>()
                .eq("goods_materials_id", id)
                .eq("del_flag",0));
 
        if (!goodsMaterialsId.isEmpty()){
            StringBuilder stringBuilder = new StringBuilder();
            for (ManagementGoodsMaterials managementGoodsMaterials : goodsMaterialsId) {
                if (managementGoodsMaterials.getManagementId() != null) {
                    SlStoreManagement byId1 = storeManagementService.getById(managementGoodsMaterials.getManagementId());
                    stringBuilder.append(byId1.getStoreManagementName()).append(",");
                }
            }
            // 去除最后一位字符
            stringBuilder.deleteCharAt(stringBuilder.length() - 1);
            return R.fail("删除失败," + stringBuilder + "仓库还有当前物资");
        }
        SlGoodsMaterials byId = slGoodsMaterialsService.getById(id);
        byId.setDelFlag("1");
        slGoodsMaterialsService.updateById(byId);
        return R.ok();
    }
 
    @GetMapping("/getGoodSmaterialsOne/{id}")
    @ApiOperation(value = "物资管理詳情")
    public R<SlGoodsMaterials> getGoodSmaterialsOne(@ApiParam(name = "id", value = "物资管理id", required = true) @PathVariable("id") Long id) {
        tokenService.getLoginUser();
        return R.ok(slGoodsMaterialsService.getById(id));
    }
 
    @PostMapping("/getStoreManagementGoodSmaterialsOne")
    @ApiOperation(value = "库存管理查看详情")
    public R<PageDTO<StoreManagementGoodSmaterialsVO>> getStoreManagementGoodSmaterialsOne(@RequestBody StoreManagementGoodSmaterialsQuery storeManagementGoodSmaterialsQuery) {
        tokenService.getLoginUser();
        return R.ok(slGoodsMaterialsService.getStoreManagementGoodSmaterialsOne(storeManagementGoodSmaterialsQuery));
    }
 
    @PostMapping("/getSmaterialsOne")
    @ApiOperation(value = "感觉物资库存管理查看详情")
    public R<StoreManagementGoodSmaterialsVO> getSmaterialsOne(@RequestBody StoreManagementGoodSmaterialsQuery storeManagementGoodSmaterialsQuery) {
        tokenService.getLoginUser();
        return R.ok(slGoodsMaterialsService.getSmaterialsOne(storeManagementGoodSmaterialsQuery));
    }
 
    @GetMapping("/getGooManagementGoodSmaterials/{id}")
    @ApiOperation(value = "库存管理查看物资詳情")
    public R<StoreManagementGoodSmaterialsVO> getGooManagementGoodSmaterials(@ApiParam(name = "id", value = "物资管理id", required = true) @PathVariable("id") Long id) {
        tokenService.getLoginUser();
        StoreManagementGoodSmaterialsVO storeManagementGoodSmaterialsVO=new StoreManagementGoodSmaterialsVO();
        LambdaQueryWrapper<ManagementGoodsMaterials> wrappers= Wrappers.lambdaQuery();
        wrappers.eq( ManagementGoodsMaterials::getGoodsMaterialsId,id);
        ManagementGoodsMaterials managementGoodsMaterials = managementGoodsMaterialsMapper.selectById(id);
        BeanUtils.copyProperties(managementGoodsMaterials, storeManagementGoodSmaterialsVO);
        SlGoodsMaterials byId = slGoodsMaterialsService.getById(managementGoodsMaterials.getGoodsMaterialsId());
        storeManagementGoodSmaterialsVO.setGoodsMaterialsName(byId.getGoodsMaterialsName());
        storeManagementGoodSmaterialsVO.setIsConsume(byId.getIsConsume());
        return R.ok(storeManagementGoodSmaterialsVO);
    }
 
}