Helius
2021-03-17 8f9e3814fd49efd763f06305ffbfff6d87012627
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
package com.matrix.system.hive.action;
 
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
 
import com.matrix.core.tools.DateUtil;
import com.matrix.system.hive.bean.SysCheckDetail;
import com.matrix.system.hive.bean.SysCheckInfo;
import com.matrix.system.hive.plugin.util.ExcelUtil;
import com.matrix.system.hive.service.CodeService;
import com.matrix.system.hive.service.SysCheckDetailService;
import com.matrix.system.hive.service.SysCheckInfoService;
import com.matrix.system.hive.service.SysStoreInfoService;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.formula.functions.T;
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 org.springframework.web.servlet.ModelAndView;
 
 
 
 
/**
 * 盘点单明细controller
 * 
 * @Title: CheckInfoDetailController.java  
 * @Package com.zkingsoft.actions.admin  
 * @description
 * @author jyy
 * @email 18075895212@qq.com
 * @date 2016年9月3日 下午4:15:09
 */
@Controller
@RequestMapping(value = "admin/checkDetail")
public class CheckInfoDetailController extends BaseController {
    public static final String fnCode = "checkDetail";
    public static final String search = fnCode + ":search";
    public static final String edit = fnCode + ":edit";
    public static final String del = fnCode + ":del";
    public static final String add = fnCode + ":add";
 
 
 
    @Resource
    private SysCheckDetailService currentService;
 
    @Resource
    private SysStoreInfoService sysStoreInfoService;
    @Resource
    private CodeService codeService;
    @Resource
    private SysCheckInfoService sysCheckInfoService;
 
    /**
     * 列表显示
     */
    @RequestMapping(value = "/showList")
    public @ResponseBody
    AjaxResult showList(SysCheckDetail sysCheckDetail, PaginationVO pageVo) {
        List<SysCheckDetail> dataList = currentService.findInPage(sysCheckDetail, pageVo);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS,  dataList, currentService.findTotal(sysCheckDetail));
        return result;
    }
 
    /**
     * 列表显示
     */
    @RequestMapping(value = "/editCheckDetail")
    public @ResponseBody AjaxResult editCheckDetail(SysCheckInfo sysCheckInfo) {
        int i = currentService.modifyList(sysCheckInfo);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS,  "保存成功");
        } else {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS,  "保存失败");
        }
    }
 
    /**
     * @author jiangyouyao @Title: report  盘点单明细导出 @param @param
     *         model @param @param request @param @param response @param @param
     *         vipInfo @param @return 设定文件 @return ModelAndView 返回类型 @throws
     */
    @RequestMapping(value = "/exportExcel")
    public void report(HttpServletRequest request, HttpServletResponse response,
            SysCheckDetail sysCheckDetail) throws IOException {
        List<List<List<Object>>> list = new ArrayList<>();
        // 表格1内容
        List<List<Object>> list1 = new ArrayList<>();
        // 查询出来调拨单
        SysCheckInfo checkInfo = sysCheckInfoService.findById(sysCheckDetail.getCheckId());
        List<Object> temp1 = new ArrayList<>();
        temp1.add(checkInfo.getCheckType());
        temp1.add(checkInfo.getCheckNo());
        // 时间转为字符串
        String strDate = DateUtil.dateToString(checkInfo.getCheckDate(), DateUtil.DATE_FORMAT_DD);
        temp1.add(strDate);
        temp1.add(checkInfo.getMakingManName());
        temp1.add(checkInfo.getAppManName());
        temp1.add(checkInfo.getCheckStatus());
        list1.add(temp1);
        list.add(list1);
        // 表格2内容
        List<List<Object>> list2 = new ArrayList<>();
        // 调拨单明细
        SysCheckDetail queryVo = new SysCheckDetail();
        queryVo.setCheckId(sysCheckDetail.getCheckId());
        List<SysCheckDetail> dataList = currentService.findByModel(queryVo);
        if (dataList.size() > 0) {
            for (SysCheckDetail obj : dataList) {
 
                List<Object> temp = new ArrayList<>();
                if(obj.getGoods()!=null){
                    temp.add(obj.getGoods().getGoodsNo());
                    temp.add(obj.getGoods().getName());
                    temp.add(obj.getBeginBalance());
                    temp.add(obj.getActuallySum());
                    temp.add(obj.getRemark());
                    temp.add(obj.getGoods().getGoodsSortName());
                    temp.add(obj.getGoods().getUnit());
                }
                list2.add(temp);
            }
        }
        list.add(list2);
        HSSFWorkbook workbook = ExcelUtil.generateExcelMore("盘点单以及明细",
                new String[][] { { "盘点单类型", "盘点单编号", "盘点时间", "制单人", "审核人", "盘点状态" },
                        { "存货编号", "存货名称", "存货数量", "实盘数", "备注", "存货分类", "存货单位"} },
                list);
 
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-disposition", "attachment;filename=checkDetails.xls");
        OutputStream ouputStream = response.getOutputStream();
        workbook.write(ouputStream);
        ouputStream.flush();
        ouputStream.close();
 
    }
}