opt:页面新增导出功能案例
This commit is contained in:
@@ -4,7 +4,9 @@ package org.nl.wms.basedata_manage.controller;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
@@ -15,7 +17,7 @@ import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.language.LangBehavior;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleinfoService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleinfo;
|
||||
import org.nl.wms.system_manage.service.columnInfo.ColumnInfoService;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateDtlService;
|
||||
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
||||
@@ -29,12 +31,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,6 +61,9 @@ public class GroupController {
|
||||
@Autowired
|
||||
private final IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService;
|
||||
|
||||
@Autowired
|
||||
private ColumnInfoService columnInfoService;
|
||||
|
||||
@GetMapping
|
||||
@Log("分页查询")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
@@ -124,4 +128,32 @@ public class GroupController {
|
||||
public ResponseEntity<Object> getdtl(@PathVariable String id) {
|
||||
return new ResponseEntity<>(iMdPbGroupplateService.getdtl(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/exportFile")
|
||||
public void exportFile(@RequestBody Map whereJson, HttpServletResponse response) {
|
||||
PageQuery page = new PageQuery();
|
||||
page.setPage(0);
|
||||
page.setSize(99999);
|
||||
IPage<JSONObject> groupPlateIPage = iMdPbGroupplateService.queryAll(whereJson, page);
|
||||
List<JSONObject> groupPlateList = groupPlateIPage.getRecords();
|
||||
|
||||
List<Map> maps = groupPlateList.stream().map(groupPlate -> {
|
||||
try {
|
||||
return groupPlate.toJavaObject(new TypeReference<Map<String, Object>>() {});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
try {
|
||||
columnInfoService.exportFile("md_pb_groupplate", maps, response,
|
||||
null,
|
||||
null);
|
||||
} catch (IOException e) {
|
||||
log.info("EXCEL 导出异常,异常原因=【{}】",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user