jiazx0107
2026-01-16 36509d940d14361429516b9f66f62fa2d4b7a706
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
package com.fzzy.common;
 
import com.fzzy.common.manager.ExportManager;
import com.fzzy.igds.ReportInDetailPR;
import com.fzzy.igds.ReportOutDetailPR;
import com.fzzy.igds.SuperInventoryReportPR;
import com.fzzy.igds.data.ExportWordParam;
import com.fzzy.igds.data.InoutParam;
import com.fzzy.igds.data.SuperInventoryReportData;
import com.fzzy.igds.data.SuperInventoryReportParam;
import com.fzzy.igds.domain.InoutRecord;
import com.fzzy.igds.service.SysDeptService;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Description  数据导出入口
 * @Author CZT
 * @Date 2025/12/29 10:32
 */
@Slf4j
@Controller
@RequestMapping("export")
public class ExportController {
 
    @Resource
    private ExportManager exportManager;
    @Resource
    private SysDeptService sysDeptService;
    @Resource
    private ReportInDetailPR reportInDetailPR;
    @Resource
    private ReportOutDetailPR reportOutDetailPR;
    @Resource
    private SuperInventoryReportPR superInventoryReportPR;
 
    /**
     * 导出word并下载
     *
     * @param response
     * @param bizId
     * @param entityName
     */
    @RequestMapping("/download-word")
    public void downloadWord(HttpServletResponse response,
                             @RequestParam(value = "bizId", required = true) String bizId,
                             @RequestParam(value = "entityName", required = true) String entityName) {
 
        ExportWordParam param = new ExportWordParam();
        param.setBizId(bizId);
        param.setEntityName(entityName);
        exportManager.renderWordDownload(param, response);
    }
 
    /**
     * PDF在线预览
     *
     * @param response
     * @param bizId
     * @param entityName
     */
    @RequestMapping("/preview-pdf")
    public void previewPdf(HttpServletResponse response,
                           @RequestParam(value = "bizId", required = true) String bizId,
                           @RequestParam(value = "entityName", required = true) String entityName) {
 
        //TODO 待实现
        ExportWordParam param = new ExportWordParam();
        param.setBizId(bizId);
        param.setEntityName(entityName);
 
    }
 
    /**
     * 出入库报表导出
     * @return
     */
    @RequestMapping("/inout-excel")
    @ResponseBody
    public AjaxResult inOutExcel(InoutParam param) {
        //设置标题
        String sheetName = "报表数据";
        //查询数据
        List<InoutRecord> list = new ArrayList<>();
 
        if (StringUtils.isNotEmpty(param.getType()) && "IN".equals(param.getType())) {
            sheetName = "入库报表数据";
            list = reportInDetailPR.listRecord(param);
        }
 
        if (StringUtils.isNotEmpty(param.getType()) && "OUT".equals(param.getType())) {
            sheetName = "出库报表数据";
            list = reportOutDetailPR.listRecord(param);
        }
 
        //获取分库编码对应的分库名称
        String deptName = "";
        SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null));
        if (null != subDept) {
            deptName = subDept.getDeptName();
        }
 
        //导出
        ExcelUtil<InoutRecord> util = new ExcelUtil<InoutRecord>(InoutRecord.class);
        return util.exportExcel(list, sheetName, deptName);
    }
 
    /**
     * 库存报表导出
     * @return
     */
    @RequestMapping("/storage-excel")
    @ResponseBody
    public AjaxResult storageExcel(SuperInventoryReportParam param) {
        //设置标题
        String sheetName = "库存报表数据";
        //查询数据
        List<SuperInventoryReportData> list = superInventoryReportPR.getReportData(param);
        //获取分库编码对应的分库名称
        String deptName = "";
        SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null));
        if (null != subDept) {
            deptName = subDept.getDeptName();
        }
 
        //导出
        ExcelUtil<SuperInventoryReportData> util = new ExcelUtil<SuperInventoryReportData>(SuperInventoryReportData.class);
        return util.exportExcel(list, sheetName, deptName);
    }
 
}