jyy
2021-06-19 756e16e090b15c7fd8648f55f5451367face6abc
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
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);
 
    }
 
}