|
@@ -2,6 +2,8 @@ package com.pj.tb_trade_area;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
+
|
|
|
+import com.pj.common.core.utils.poi.ExcelUtil;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -14,6 +16,8 @@ import com.pj.current.satoken.StpUserUtil;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Controller: tb_trade_area -- 贸易区域
|
|
@@ -89,12 +93,20 @@ public class TbTradeAreaController {
|
|
|
*/
|
|
|
@RequestMapping("tradeAreaImport")
|
|
|
@ResponseBody
|
|
|
- public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
|
|
|
+ public AjaxJson dataImport( @RequestParam("file") MultipartFile file){
|
|
|
+ List<TbTradeArea> areaList = tbTradeAreaService.list();
|
|
|
+ ExcelUtil<TbTradeArea> excelUtil = new ExcelUtil<>(TbTradeArea.class);
|
|
|
+
|
|
|
try {
|
|
|
- String importData = tbTradeAreaService.importData(file);
|
|
|
- AjaxJson.getSuccess(importData);
|
|
|
+ List<TbTradeArea> tbTradeAreas = excelUtil.importExcel(file.getInputStream());
|
|
|
+ System.out.println(tbTradeAreas);
|
|
|
+
|
|
|
+// String importData = tbTradeAreaService.importData(file);
|
|
|
+// AjaxJson.getSuccess(importData);
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
return AjaxJson.getError();
|
|
|
}
|
|
@@ -106,9 +118,13 @@ public class TbTradeAreaController {
|
|
|
*/
|
|
|
@RequestMapping("tradeAreaOutport")
|
|
|
@ResponseBody
|
|
|
- public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
|
|
|
+ public AjaxJson dataOutport(HttpServletResponse response,@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepath")String filepath){
|
|
|
+
|
|
|
+ List<TbTradeArea> areaList = tbTradeAreaService.list();
|
|
|
+ ExcelUtil<TbTradeArea> excelUtil = new ExcelUtil<>(TbTradeArea.class);
|
|
|
+ excelUtil.exportExcel(response,areaList,"区域表");
|
|
|
try {
|
|
|
- String importData = tbTradeAreaService.outportExcel(keyword);
|
|
|
+ String importData = tbTradeAreaService.outportExcel(keyword,filepath);
|
|
|
AjaxJson.getSuccess(importData);
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|