| package com.matrix.system.hiveErp.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.constance.Dictionary; | 
| import com.matrix.system.hive.action.BaseController; | 
| import com.matrix.system.hive.action.util.QueryUtil; | 
| 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 = "hiveErp/warehouse") | 
| public class ErpWarehouseController extends BaseController { | 
|     @Autowired | 
|     private WarehouseDao warehouseDao; | 
|   | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showList(Warehouse warehouse, PaginationVO pageVo) { | 
|         QueryUtil.setQueryLimitCom(warehouse); | 
|         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(Warehouse warehouse) { | 
|         QueryUtil.setQueryLimitCom(warehouse); | 
|         List<Warehouse> dataList = warehouseDao.selectInPage(warehouse, 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(Warehouse warehouse) { | 
|         QueryUtil.setQueryLimit(warehouse); | 
|         List<Warehouse> dataList = warehouseDao.selectInPage(warehouse, null); | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, dataList.size()); | 
|         return result; | 
|     } | 
|   | 
|     /** | 
|      * 查询门店所有的仓库 | 
|      * @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 { | 
|             QueryUtil.setQueryLimit(warehouse); | 
|             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-erp/warehouse/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, "删除失败"); | 
|         } | 
|     } | 
|   | 
| } |