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);
|
}
|
}
|