jyy
2021-01-26 ab2879bbcb846256cc182198b9c04e50fbc276c1
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
package com.matrix.system.hive.action;
 
 
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.hive.bean.Warehouse;
import com.matrix.system.hive.dao.WarehouseDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.List;
 
/**
 * 仓库管理
 *
 * @author yusurui
 * @date 2016-07-11
 */
@Controller
@RequestMapping(value = "admin/warehouse")
public class WarehouseController extends BaseController {
    @Autowired
    private WarehouseDao warehouseDao;
 
    /**
     * 列表显示
     */
    @RequestMapping(value = "/showList")
    public @ResponseBody
    AjaxResult showList(Warehouse warehouse, PaginationVO pageVo) {
 
        List<Warehouse> dataList = warehouseDao.selectInPage(warehouse, pageVo);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList,
                warehouseDao.selectTotalRecord(warehouse));
        return result;
    }
 
    @RequestMapping(value = "/findAll")
    public @ResponseBody
    AjaxResult findAll() {
        List<Warehouse> dataList = warehouseDao.selectInPage(null, null);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, dataList.size());
        return result;
    }
 
    /**
     * 查询总部仓库
     *
     * @return
     */
    @RequestMapping(value = "/findZongbuAll")
    public @ResponseBody
    AjaxResult findZongbuAll() {
        List<Warehouse> dataList = warehouseDao.findZongbuAll(getMe().getCompanyId());
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, dataList.size());
        return result;
    }
 
 
    /**
     * 查询员工所在门店仓库
     *
     * @return
     */
    @RequestMapping(value = "/findShopWarehouse")
    public @ResponseBody
    AjaxResult findShopWarehouse() {
        SysUsers user = getMe();
        List<Warehouse> dataList  = warehouseDao.findShopWarehouse(user.getShopId());
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, dataList.size());
        return result;
    }
 
    @RequestMapping(value = "/findSingleShopWarehouse")
    @ResponseBody
    public AjaxResult findSingleShopWarehouse() {
        SysUsers user = getMe();
        List<Warehouse> list = warehouseDao.findShopWarehouse(user.getShopId());
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, list, list.size());
    }
 
    /**
     * 查询门店所有的仓库
     * @param shopId
     * @return
     */
    @RequestMapping(value = "/getShopWarehouse")
    public @ResponseBody
    AjaxResult getShopWarehouse(Long shopId) {
        List<Warehouse> dataList = warehouseDao.findShopWarehouse(shopId);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, dataList.size());
        return result;
    }
 
 
    /**
     * 新增或修改页面
     */
    @RequestMapping(value = "/addOrModify")
    public @ResponseBody
    AjaxResult addOrModify(Warehouse warehouse) {
        if (warehouse.getId() != null) {
            int i = warehouseDao.update(warehouse);
            if (i > 0) {
                return new AjaxResult(AjaxResult.STATUS_SUCCESS, "修改成功");
            } else {
                return new AjaxResult(AjaxResult.STATUS_FAIL, "修改失败");
            }
        } else {
            int i = warehouseDao.insert(warehouse);
            if (i > 0) {
                return new AjaxResult(AjaxResult.STATUS_SUCCESS, "添加成功");
            } else {
                return new AjaxResult(AjaxResult.STATUS_FAIL, "添加失败");
            }
        }
    }
 
    /**
     * 进入修改界面
     */
    @RequestMapping(value = "/editForm")
    public String editForm(Long id) {
        Warehouse warehouse;
        if (id != null) {
            warehouse = warehouseDao.selectById(id);
            WebUtil.getRequest().setAttribute("obj", warehouse);
        }
        return "admin/hive/orgment/warehouse-form";
    }
 
    /**
     * 删除
     */
    @RequestMapping(value = "/del")
    public @ResponseBody
    AjaxResult del(String keys) {
        List<Long> ids = StringUtils.strToCollToLong(keys, ",");
        int i = warehouseDao.deleteByIds(ids);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, "成功删除" + i + "条数据");
        } else {
            return new AjaxResult(AjaxResult.STATUS_FAIL, "删除失败");
        }
    }
 
}