Crunchy
2025-06-14 b2f31607cbe26d721cd7514b619162b3e355b1aa
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
package com.wms_admin.server.controller;
 
import cn.hutool.db.sql.Order;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wms_admin.excel.ExcelOrderInformation;
import com.wms_admin.excel.ExcelSendAndStoringUtil;
import com.wms_admin.server.entity.OrderInformation;
import com.wms_admin.server.service.OrderInformationService;
import com.wms_admin.utils.Result;
import com.wms_admin.utils.StyleUtils;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
 
@Slf4j
@Api(tags = "库存管理")
@RestController
@RequestMapping("/order_info")
public class OrderInformationController {
 
    @Autowired
    private OrderInformationService service;
 
    @ApiOperation(value = "分页获取库存管理信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "startTime", value = "开始时间", dataTypeClass = String.class, required = false),
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataTypeClass = String.class, required = false),
            @ApiImplicitParam(name = "pageNo", value = "起始页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "pageSize", value = "页总数", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/add_out")
    public Result<Map<String, Object>> sendingAndStoringManagement(String startTime, String  endTime, Integer pageNo, Integer pageSize) {
        IPage<Map<String, Object>> data = service.SendingAndStoringManagement(startTime, endTime, new Page(pageNo, pageSize));
        Map<String, Object> map = new HashMap<>();
        map.put("row", data.getRecords());
        map.put("total", data.getTotal());
        return Result.success(map);
    }
 
    @ApiOperation(value = "库存管理Excel导出")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "startTime", value = "开始时间", dataTypeClass = String.class, required = false),
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataTypeClass = String.class, required = false)
    })
    @GetMapping("/add_out/excel")
    public void sendingAndStoringManagementExcel(String startTime, String  endTime, HttpServletResponse response) throws IOException {
        List<ExcelSendAndStoringUtil> data = service.sendingAndStoringManagementExcel(startTime, endTime);
        // 设置单元格样式
        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleUtils.getHeadStyle(), StyleUtils.getContentStyle());
        // 保存到第一个sheet中
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setHeader("requestType","excel");
        response.setHeader("Access-Control-Expose-Headers", "requestType");
        EasyExcel
                .write(response.getOutputStream(), ExcelSendAndStoringUtil.class)
                .sheet()
                .needHead(true)
                .registerWriteHandler(horizontalCellStyleStrategy)
                .doWrite(data);
    }
 
    @ApiOperation(value = "出库台账excel导出")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "startTime", value = "开始时间", dataTypeClass = String.class, required = false),
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataTypeClass = String.class, required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataTypeClass = String.class, required = false)
    })
    @GetMapping("/excel")
    public void ListOutProduct(String startTime, String  endTime, String customerName, HttpServletResponse response) throws IOException {
        List<ExcelOrderInformation> data = service.SelectOutProductExcel(startTime, endTime, customerName);
        Integer i = 1;
        for(ExcelOrderInformation orderInformation : data){
            orderInformation.setId(i);
            i++;
        };
        // 设置单元格样式
        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleUtils.getHeadStyle(), StyleUtils.getContentStyle());
        // 保存到第一个sheet中
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setHeader("requestType","excel");
        response.setHeader("Access-Control-Expose-Headers", "requestType");
        EasyExcel
                .write(response.getOutputStream(), ExcelOrderInformation.class)
                .sheet()
                .needHead(true)
                .registerWriteHandler(horizontalCellStyleStrategy)
                .doWrite(data);
    }
 
    @ApiOperation(value = "分页获取出库台账信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "startTime", value = "开始时间", dataTypeClass = String.class, required = false),
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataTypeClass = String.class, required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataTypeClass = String.class, required = false),
            @ApiImplicitParam(name = "pageNo", value = "起始页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "pageSize", value = "页总数", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/list")
    public Result<Map<String, Object>> ListOutProduct(String startTime, String  endTime, String customerName, Integer pageNo, Integer pageSize) {
        IPage<OrderInformation> data = service.SelectOutProductPage(startTime, endTime, customerName, new Page(pageNo, pageSize));
        Map<String, Object> map = new HashMap<>();
        map.put("row", data.getRecords());
        map.put("total", data.getTotal());
        return Result.success(map);
    }
}