导出功能完善

This commit is contained in:
梁州 2024-07-15 13:30:19 +08:00
parent 0863752ec6
commit 97c0e80317
3 changed files with 45 additions and 7 deletions

View File

@ -5,13 +5,15 @@ import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wms.constants.enums.*;
import com.wms.entity.app.ResponseEntity;
import com.wms.entity.app.dto.LocationDto;
import com.wms.entity.app.dto.StockDto;
import com.wms.entity.app.dto.TaskDto;
import com.wms.entity.app.dto.TaskRecordDto;
import com.wms.entity.app.dto.VehicleDto;
import com.wms.entity.app.request.LocationQuery;
import com.wms.entity.app.request.StockQuery;
import com.wms.entity.app.request.TaskRecordQuery;
import com.wms.entity.app.request.VehicleQuery;
import com.wms.entity.table.Location;
import com.wms.entity.table.Vehicle;
import com.wms.service.*;
import com.wms.utils.StringUtils;
@ -30,8 +32,6 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@ -51,6 +51,7 @@ public class ExcelController {
private final HttpServletRequest servletRequest;// 请求服务
private final TaskRecordService taskRecordService;// 任务记录服务
private final VehicleService vehicleService;// 载具服务
private final LocationService locationService;// 库位服务
/**
* 导入库存信息
@ -65,6 +66,7 @@ public class ExcelController {
logger.info("导入库存请求ip{}", getIpAddr(servletRequest));
ResponseEntity response = new ResponseEntity();
try {
List<StockDto> stocksDto = ExcelUtils.readMultipartFile(file, StockDto.class);
response.setCode(ResponseCode.OK.getCode());
response.setMessage("导入库存成功");
response.setReturnData(file);
@ -131,14 +133,14 @@ public class ExcelController {
}
/**
* 导出入库记录
* 导出载具记录
*
* @param response 请求
*/
@GetMapping("/downloadVehicleExcel")
@ResponseBody
public void downloadVehicleExcel(@RequestParam("vehicleQuery") VehicleQuery vehicleQuery, HttpServletResponse response) {
logger.info("导出载具记录,查询参数:{}请求ip{}",convertJsonString(vehicleQuery), getIpAddr(servletRequest));
logger.info("导出载具记录,查询参数:{}请求ip{}", convertJsonString(vehicleQuery), getIpAddr(servletRequest));
List<Vehicle> vehicles = vehicleService.list(new LambdaQueryWrapper<Vehicle>()
.like(StringUtils.isNotEmpty(vehicleQuery.getVehicleId()), Vehicle::getVehicleId, vehicleQuery.getVehicleId())
.like(StringUtils.isNotEmpty(vehicleQuery.getCurrentLocation()), Vehicle::getCurrentLocation, vehicleQuery.getCurrentLocation())
@ -150,4 +152,25 @@ public class ExcelController {
ExcelUtils.export(response, "载具报表", BeanUtil.copyToList(vehicles, VehicleDto.class), VehicleDto.class);
}
}
/**
* 导出库位详情
*
* @param response 请求
*/
@GetMapping("/downloadLocationsExcel")
@ResponseBody
public void downloadLocationsExcel(@RequestParam("locationQuery") LocationQuery locationQuery, HttpServletResponse response) {
logger.info("导出库位详情,查询参数:{}请求ip{}", convertJsonString(locationQuery), getIpAddr(servletRequest));
List<Location> locations = locationService.list(new LambdaQueryWrapper<Location>()
.like(StringUtils.isNotEmpty(locationQuery.getLocationId()), Location::getLocationId, locationQuery.getLocationId())
.eq(locationQuery.getAreaId() != null, Location::getAreaId, locationQuery.getAreaId())
.eq(locationQuery.getIsLock() != null, Location::getIsLock, locationQuery.getIsLock())
.eq(locationQuery.getLocationStatus() != null, Location::getLocationStatus, locationQuery.getLocationStatus()));
if (locations == null || locations.isEmpty()) {
ExcelUtils.export(response, "库位报表", Collections.emptyList(), LocationDto.class);
} else {
ExcelUtils.export(response, "库位报表", BeanUtil.copyToList(locations, LocationDto.class), LocationDto.class);
}
}
}

View File

@ -10,14 +10,31 @@ import lombok.Data;
@Data
public class PageQuery {
/**
* 页号
*/
@JsonProperty("pageNo")
private Long pageNo = 1L;
/**
* 页面大小
*/
@JsonProperty("pageSize")
private Long pageSize = 10L;
/**
* 排序字段
*/
@JsonProperty("sortBy")
private String sortBy;
/**
* 是否升序
*/
@JsonProperty("isAsc")
private Boolean isAsc = true;
/**
* 用户名
*/
@JsonProperty("userName")
private String userName;
/**
* 将前端查询转换为数据库查询可用的分页查询

View File

@ -5,8 +5,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.wms.entity.table.User;
import com.wms.utils.MyPassword;
import com.wms.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;