| package com.matrix.system.hive.action; | 
|   | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.DateUtil; | 
| import com.matrix.core.tools.excl.ExcelSheetPO; | 
| import com.matrix.core.tools.excl.ExcelVersion; | 
| import com.matrix.system.common.tools.DataAuthUtil; | 
| import com.matrix.system.common.tools.ResponseHeadUtil; | 
| import com.matrix.system.constance.Dictionary; | 
| import com.matrix.system.hive.action.util.QueryUtil; | 
| import com.matrix.system.hive.bean.SysCheckInfo; | 
| import com.matrix.system.hive.dao.SysStoreInfoDao; | 
| import com.matrix.core.tools.DateUtil; | 
| import com.matrix.system.hive.pojo.StoreInOutRecordVO; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.ui.ModelMap; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.ResponseBody; | 
|   | 
| import javax.servlet.http.HttpServletRequest; | 
| import javax.servlet.http.HttpServletResponse; | 
| import java.io.IOException; | 
| import java.io.OutputStream; | 
| import java.net.URLDecoder; | 
| import java.net.URLEncoder; | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
|   | 
| /** | 
|  * 库存 | 
|  * | 
|  * @author jiangyouyao | 
|  * @date 2016-07-20 | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/storeInOut") | 
| public class StoreInOutController extends BaseController { | 
|   | 
|     @Autowired | 
|     SysStoreInfoDao storeInfoDao; | 
|   | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showList(StoreInOutRecordVO inOutRecordVO, PaginationVO pageVo) { | 
|         QueryUtil.setQueryLimitCom(inOutRecordVO); | 
|         List<StoreInOutRecordVO> dataList =storeInfoDao.findStoreInOutRecord(inOutRecordVO,pageVo); | 
|         return AjaxResult.buildSuccessInstance(dataList,storeInfoDao.findStoreInOutTotal(inOutRecordVO)); | 
|     } | 
|   | 
|   | 
|   | 
|     /** | 
|      * 显示当前登录人门店数据 | 
|      */ | 
|     @RequestMapping(value = "/showCurrentShopList") | 
|     public @ResponseBody | 
|     AjaxResult showCurrentShopList(StoreInOutRecordVO inOutRecordVO, PaginationVO pageVo) { | 
|         QueryUtil.setQueryLimit(inOutRecordVO); | 
|         List<StoreInOutRecordVO> dataList =storeInfoDao.findStoreInOutRecord(inOutRecordVO,pageVo); | 
|         return AjaxResult.buildSuccessInstance(dataList,storeInfoDao.findStoreInOutTotal(inOutRecordVO)); | 
|     } | 
|   | 
|   | 
|     @RequestMapping(value = "/exportExcel") | 
|     public void report(ModelMap model, HttpServletRequest request, HttpServletResponse response, StoreInOutRecordVO inOutRecordVO) throws IOException { | 
|   | 
|         QueryUtil.setQueryLimitCom(inOutRecordVO); | 
|   | 
|         List<ExcelSheetPO> res = new ArrayList<>(); | 
|         ExcelSheetPO orderSheet = new ExcelSheetPO(); | 
|         String title = "库存流向明细"; | 
|         orderSheet.setSheetName(title); | 
|         orderSheet.setTitle(title); | 
|         String[] header = {"时间", "产品编码", "商品名称", "库存分类", "出库数量", "出库单价", "出库金额", "单据编号", "单据类型", "库存批次", "操作人", "单据备注", "门店"}; | 
|         orderSheet.setHeaders(header); | 
|   | 
|         if (getMe().getShopRole().equals(Dictionary.FLAG_NO_N)) { | 
|             inOutRecordVO.setShopId(getMe().getShopId()); | 
|         } | 
|         List<StoreInOutRecordVO> dataList =storeInfoDao.findStoreInOutRecord(inOutRecordVO,null); | 
|         List<List<Object>> list = new ArrayList<>(); | 
|         if (dataList.size() > 0) { | 
|             for (StoreInOutRecordVO item : dataList) { | 
|                 List<Object> temp = new ArrayList<>(); | 
|                 String strDate = DateUtil.dateToString(item.getCreateTime(), DateUtil.DATE_FORMAT_MM); | 
|                 temp.add(strDate); | 
|                 temp.add(item.getCode()); | 
|                 temp.add(item.getName()); | 
|                 temp.add(item.getTypeName()); | 
|                 temp.add(item.getAmount()); | 
|                 temp.add(item.getGoodsPrice()); | 
|                 temp.add(item.getTotalPrice()); | 
|                 temp.add(item.getOrderNo()); | 
|                 temp.add(item.getOrderType()); | 
|                 temp.add(item.getBatch()); | 
|                 temp.add(item.getUserName()); | 
|                 temp.add(item.getRemark()); | 
|                 temp.add(item.getShopName()); | 
|                 list.add(temp); | 
|             } | 
|         } | 
|         orderSheet.setDataList(list); | 
|         res.add(orderSheet); | 
|         response = ResponseHeadUtil.setExcelHead(response); | 
|         response.setHeader("Content-Disposition", | 
|                 "attachment;filename=" + URLEncoder.encode(title + DateUtil.getTimeMark() + ".xlsx".trim(), "UTF-8")); | 
|         OutputStream os = response.getOutputStream(); | 
|         com.matrix.core.tools.excl.ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true); | 
|   | 
|     } | 
|   | 
| } |