Browse Source

7.23 更改导出时自动获取当前登录用户的桌面路径

Mechrevo 1 year ago
parent
commit
9da15c8b80
26 changed files with 243 additions and 86 deletions
  1. 34 3
      sp-core/sp-base/pom.xml
  2. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseController.java
  3. 10 4
      sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseService.java
  4. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsController.java
  5. 10 4
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java
  6. 3 2
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitController.java
  7. 10 4
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitService.java
  8. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeController.java
  9. 12 5
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeService.java
  10. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsController.java
  11. 10 4
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsService.java
  12. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupController.java
  13. 10 4
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java
  14. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleController.java
  15. 10 4
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java
  16. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopController.java
  17. 10 4
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java
  18. 21 5
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaController.java
  19. 10 4
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaService.java
  20. 26 1
      sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaser.java
  21. 10 2
      sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserController.java
  22. 17 7
      sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserService.java
  23. 2 2
      sp-service/transport-server/src/main/java/com/pj/project/tb_driver/TbDriverController.java
  24. 12 5
      sp-service/transport-server/src/main/java/com/pj/project/tb_driver/TbDriverService.java
  25. 2 4
      sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleController.java
  26. 10 4
      sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleService.java

+ 34 - 3
sp-core/sp-base/pom.xml

@@ -39,9 +39,40 @@
             <artifactId>poi-ooxml</artifactId>
             <version>4.0.0</version>
         </dependency>
-    
-    
-	    <!-- nacos 注册中心 -->
+
+
+        <!-- 自定义验证注解 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+
+        <!-- Swagger3依赖 -->
+<!--        <dependency>-->
+<!--            <groupId>io.springfox</groupId>-->
+<!--            <artifactId>springfox-boot-starter</artifactId>-->
+<!--            <version>3.0.0</version>-->
+<!--            <exclusions>-->
+<!--                <exclusion>-->
+<!--                    <groupId>io.swagger</groupId>-->
+<!--                    <artifactId>swagger-models</artifactId>-->
+<!--                </exclusion>-->
+<!--            </exclusions>-->
+<!--        </dependency>-->
+
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.73</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.fastjson2</groupId>
+            <artifactId>fastjson2</artifactId>
+            <version>2.0.3.graal</version>
+        </dependency>
+
+        <!-- nacos 注册中心 -->
 	    <dependency>
 		    <groupId>com.alibaba.cloud</groupId>
 		    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseController.java

@@ -114,9 +114,9 @@ public class TbEnterpriseController {
 	 */
 	@RequestMapping("enterpriseOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepath")String filepath){
 		try {
-			String importData = tbEnterpriseService.outportExcel(keyword);
+			String importData = tbEnterpriseService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 10 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseService.java

@@ -19,6 +19,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 
 /**
  * Service: tb_enterprise -- 商家
@@ -93,11 +95,15 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "商家数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\商家数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbEnterprise> selectedList = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>().eq(StringUtils.isNoneBlank(keyword), TbEnterprise::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsController.java

@@ -111,9 +111,9 @@ public class TbGoodsController {
 	 */
 	@RequestMapping("goodsOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepath")String filepath){
 		try {
-			String importData = tbGoodsService.outportExcel(keyword);
+			String importData = tbGoodsService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 10 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java

@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_goods -- 商品
  * @author qzy 
@@ -93,11 +95,15 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "商品数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\商品数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbGoods> selectedList = tbGoodsMapper.selectList(new LambdaQueryWrapper<TbGoods>().eq(StringUtils.isNoneBlank(keyword), TbGoods::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";

+ 3 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitController.java

@@ -126,13 +126,14 @@ public class TbGoodsTransitController {
 	/**
 	 * 导出
 	 * @param keyword
+	 * @param filepath
 	 * @return
 	 */
 	@RequestMapping("goodsTransitOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepath")String filepath){
 		try {
-			String importData = tbGoodsTransitService.outportExcel(keyword);
+			String importData = tbGoodsTransitService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 10 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitService.java

@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_goods_transit -- 审核商户在APP端发布的商品
  * @author qzy 
@@ -94,11 +96,15 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "商家商品审核数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\商家商品审核数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbGoodsTransit> selectedList = tbGoodsTransitMapper.selectList(new LambdaQueryWrapper<TbGoodsTransit>().eq(StringUtils.isNoneBlank(keyword), TbGoodsTransit::getMerchantName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeController.java

@@ -114,9 +114,9 @@ public class TbGoodsTypeController {
 	 */
 	@RequestMapping("goodsTypeOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepathh")String filepath){
 		try {
-			String importData = tbGoodsTypeService.outportExcel(keyword);
+			String importData = tbGoodsTypeService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 12 - 5
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeService.java

@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_goods_type -- 商品分类
  * @author qzy 
@@ -93,13 +95,18 @@ public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsTy
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "商品分类数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\商品分类数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
-		List<TbGoodsType> selectedList = tbGoodsTypeMapper.selectList(new LambdaQueryWrapper<TbGoodsType>().eq(StringUtils.isNoneBlank(keyword), TbGoodsType::getName, keyword));
+		List<TbGoodsType> selectedList = tbGoodsTypeMapper.selectList
+				(new LambdaQueryWrapper<TbGoodsType>().eq(StringUtils.isNoneBlank(keyword), TbGoodsType::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";
 		//建立excel对象封装数据
 		HSSFWorkbook workbook = new HSSFWorkbook();

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsController.java

@@ -101,9 +101,9 @@ public class TbGoodsUnitsController {
 	 */
 	@RequestMapping("goodsUnitsOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepath")String filepath){
 		try {
-			String importData = tbGoodsUnitsService.outportExcel(keyword);
+			String importData = tbGoodsUnitsService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 10 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsService.java

@@ -20,6 +20,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_goods_units -- 商品单位
  * @author qzy 
@@ -92,11 +94,15 @@ public class TbGoodsUnitsService extends ServiceImpl<TbGoodsUnitsMapper, TbGoods
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "商品分类数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\商品分类数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbGoodsUnits> selectedList = tbGoodsUnitsMapper.selectList(new LambdaQueryWrapper<TbGoodsUnits>().eq(StringUtils.isNoneBlank(keyword), TbGoodsUnits::getUnits, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupController.java

@@ -115,9 +115,9 @@ public class TbGroupController {
 	 */
 	@RequestMapping("groupOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepath")String filepath){
 		try {
-			String importData = tbGroupService.outportExcel(keyword);
+			String importData = tbGroupService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 10 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java

@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_group -- 互助组
  * @author qzy 
@@ -93,11 +95,15 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "互助组数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\互助组数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbGroup> selectedList = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(StringUtils.isNoneBlank(keyword), TbGroup::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleController.java

@@ -114,9 +114,9 @@ public class TbPeopleController {
 	 */
 	@RequestMapping("peopleOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepath")String filepath){
 		try {
-			String importData = tbPeopleService.outportExcel(keyword);
+			String importData = tbPeopleService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 10 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java

@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_people -- 边民
  * @author qzy 
@@ -93,11 +95,15 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "边民数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\边民数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbPeople> selectedList = tbPeopleMapper.selectList(new LambdaQueryWrapper<TbPeople>().eq(StringUtils.isNoneBlank(keyword), TbPeople::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopController.java

@@ -117,9 +117,9 @@ public class TbShopController {
 	 */
 	@RequestMapping("shopOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam("filepath")String filepath){
 		try {
-			String importData = tbShopService.outportExcel(keyword);
+			String importData = tbShopService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 10 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java

@@ -19,6 +19,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_shop -- 铺位
  * @author qzy 
@@ -92,11 +94,15 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "铺位数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\铺位数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbShop> selectedList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(StringUtils.isNoneBlank(keyword), TbShop::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";

+ 21 - 5
sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaController.java

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

+ 10 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaService.java

@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_trade_area -- 贸易区域
  * @author qzy 
@@ -93,11 +95,15 @@ public class TbTradeAreaService extends ServiceImpl<TbTradeAreaMapper, TbTradeAr
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "贸易区域审核数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\贸易区域审核数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbTradeArea> selectedList = tbTradeAreaMapper.selectList(new LambdaQueryWrapper<TbTradeArea>().eq(StringUtils.isNoneBlank(keyword), TbTradeArea::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";

+ 26 - 1
sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaser.java

@@ -5,6 +5,7 @@ import java.util.*;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.pj.common.core.annotation.Excel;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -44,126 +45,150 @@ public class TbPurchaser extends Model<TbPurchaser> implements Serializable {
 	/**
 	 * 主键 
 	 */
+	@Excel(name = "id")
 	@TableId(type = IdType.AUTO)
 	private Long id;	
 
 	/**
 	 * 名称 
 	 */
-	private String name;	
+	@Excel(name = "名称")
+	private String name;
 
 	/**
 	 * 法人 
 	 */
+	@Excel(name = "法人")
 	private String legalPerson;	
 
 	/**
 	 * 身份证号 
 	 */
+	@Excel(name = "身份证号码")
 	private String idCard;	
 
 	/**
 	 * 手机号码 
 	 */
+	@Excel(name = "手机号码")
 	private String contact;	
 
 	/**
 	 * 营业执照 
 	 */
+	@Excel(name = "营业执照")
 	private String businessLicense;	
 
 	/**
 	 * 银行编号 
 	 */
+	@Excel(name = "银行编号")
 	private String bankNo;	
 
 	/**
 	 * 银行名称 
 	 */
+	@Excel(name = "银行名称")
 	private String bankName;	
 
 	/**
 	 * 银行账号 
 	 */
+	@Excel(name = "银行账号")
 	private String bankAccount;	
 
 	/**
 	 * 税号 
 	 */
+	@Excel(name = "税号")
 	private String dutyParagraph;	
 
 	/**
 	 * 地址编号 
 	 */
+	@Excel(name = "地址编号")
 	private String addressIds;	
 
 	/**
 	 * 地址 
 	 */
+	@Excel(name = "地址")
 	private String address;	
 
 	/**
 	 * 审核状态(0=未通过,1=已通过) 
 	 */
+	@Excel(name = "审核状态")
 	private Integer judgeStatus;
 
 	/**
 	 * 审核意见 
 	 */
+	@Excel(name = "审核意见")
 	private String judgeContent;	
 
 	/**
 	 * 上次审核时间 
 	 */
+	@Excel(name = "上次审核时间")
 	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date judgeTime;	
 
 	/**
 	 * 注册时间 
 	 */
+	@Excel(name = "注册时间")
 	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date registerTime;	
 
 	/**
 	 * 人脸编号 
 	 */
+	@Excel(name = "人脸编号")
 	private String personId;	
 
 	/**
 	 * 创建时间 
 	 */
+	@Excel(name = "创建时间")
 	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date createTime;
 
 	/**
 	 * 创建人编号 
 	 */
+	@Excel(name = "创建人编号")
 	private String createBy;	
 
 	/**
 	 * 创建人名称 
 	 */
+	@Excel(name = "创建人名称")
 	private String createName;	
 
 	/**
 	 * 更新时间 
 	 */
+	@Excel(name = "更新时间")
 	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date updateTime;
 
 	/**
 	 * 更新人编号 
 	 */
+	@Excel(name = "更信人编号")
 	private String updateBy;	
 
 	/**
 	 * 更新人名称 
 	 */
+	@Excel(name = "更新人名称")
 	private String updateName;	
 
 	/**
 	 * 删除状态(0=禁用,1=启用) 
 	 */
+	@Excel(name = "删除状态")
 	private Integer deleteStatus;	
 
 

+ 10 - 2
sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserController.java

@@ -2,6 +2,8 @@ package com.pj.tb_purchaser;
 
 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.web.bind.annotation.*;
@@ -12,6 +14,8 @@ import com.pj.project4sp.SP;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+
 
 /**
  * Controller: tb_purchaser -- 收购商
@@ -111,9 +115,13 @@ public class TbPurchaserController {
 	 */
 	@RequestMapping("purchaserOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(HttpServletResponse response, @RequestParam(value = "keyword",required = false) String keyword,@RequestParam(value = "filepath",required = false)String filepath){
+		List<TbPurchaser> list = tbPurchaserService.list();
+		ExcelUtil<TbPurchaser> tbPurchaserExcelUtil = new ExcelUtil<>(TbPurchaser.class);
+		tbPurchaserExcelUtil.exportExcel(response,list,"测试");
+
 		try {
-			String importData = tbPurchaserService.outportExcel(keyword);
+			String importData = tbPurchaserService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 17 - 7
sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserService.java

@@ -19,6 +19,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_purchaser -- 收购商
  * @author qzy 
@@ -92,13 +94,18 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "收购商数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\收购商数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
-		List<TbPurchaser> selectedList = tbPurchaserMapper.selectList(new LambdaQueryWrapper<TbPurchaser>().eq(StringUtils.isNoneBlank(keyword), TbPurchaser::getName, keyword));
+		List<TbPurchaser> selectedList = tbPurchaserMapper.selectList
+				(new LambdaQueryWrapper<TbPurchaser>().eq(StringUtils.isNoneBlank(keyword), TbPurchaser::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";
 		//建立excel对象封装数据
 		HSSFWorkbook workbook = new HSSFWorkbook();
@@ -132,6 +139,8 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 		row.createCell(19).setCellValue("更新人名称");
 		row.createCell(20).setCellValue("删除状态");
 
+		//定义计数器
+		int count = 0;
 		//遍历集合
 		for (int i = 0; i < selectedList.size(); i++) {
 			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
@@ -160,6 +169,7 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 			sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
 			sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
 			sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null")? "": selectedList.get(i).getDeleteStatus() + "");
+			count += 1;
 		}
 		//建立输出流,输出文件
 		FileOutputStream fos = new FileOutputStream(filepath);
@@ -169,7 +179,7 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 		//关闭输出流
 		fos.close();
 		workbook.close();
-		System.out.println("\n数据导出完成!");
-		return "数据导出完成!";
+		System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
+		return "数据导出完成!共导出 " + count + " 条数据。";
 	}
 }

+ 2 - 2
sp-service/transport-server/src/main/java/com/pj/project/tb_driver/TbDriverController.java

@@ -107,9 +107,9 @@ public class TbDriverController {
 	 */
 	@RequestMapping("driverOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam(value = "filepath",required = false)String filepath){
 		try {
-			String importData = tbDriverService.outportExcel(keyword);
+			String importData = tbDriverService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 12 - 5
sp-service/transport-server/src/main/java/com/pj/project/tb_driver/TbDriverService.java

@@ -20,6 +20,8 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_driver -- 司机
  * @author qzy 
@@ -91,13 +93,18 @@ public class TbDriverService extends ServiceImpl<TbDriverMapper, TbDriver> imple
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "货运司机数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\货运司机数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
-		List<TbDriver> selectedList = tbDriverMapper.selectList(new LambdaQueryWrapper<TbDriver>().eq(StringUtils.isNoneBlank(keyword), TbDriver::getName, keyword));
+		List<TbDriver> selectedList = tbDriverMapper.selectList
+				(new LambdaQueryWrapper<TbDriver>().eq(StringUtils.isNoneBlank(keyword), TbDriver::getName, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";
 		//建立excel对象封装数据
 		HSSFWorkbook workbook = new HSSFWorkbook();

+ 2 - 4
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleController.java

@@ -4,13 +4,11 @@ import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import com.pj.utils.sg.*;
 import com.pj.project4sp.SP;
 
-import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -106,9 +104,9 @@ public class TbVehicleController {
 	 */
 	@RequestMapping("vehicleOutport")
 	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam(value = "filepath",required = false)String filepath){
 		try {
-			String importData = tbVehicleService.outportExcel(keyword);
+			String importData = tbVehicleService.outportExcel(keyword,filepath);
 			AjaxJson.getSuccess(importData);
 		} catch (IOException e) {
 			throw new RuntimeException(e);

+ 10 - 4
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleService.java

@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.swing.filechooser.FileSystemView;
+
 /**
  * Service: tb_vehicle -- 车辆
  * @author loovi 
@@ -93,11 +95,15 @@ public class TbVehicleService extends ServiceImpl<TbVehicleMapper, TbVehicle> im
 	 * @param keyword
 	 * @return
 	 */
-	public String outportExcel(String keyword) throws IOException {
+	public String outportExcel(String keyword,String filepath) throws IOException {
 		System.out.println("\n开始执行文件导出....\n");
-		//路径
-		String localPath = "C:\\Users\\Administrator\\Desktop\\generate\\";
-		String filepath = localPath + "车辆信息数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+		//导出的文件的路径
+		if(filepath == null){
+			// 获取当前用户的桌面路径
+			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+			filepath = fileSystemView.getHomeDirectory().getPath();
+		}
+		filepath = filepath + "\\车辆信息数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
 		//根据需求查询数据
 		List<TbVehicle> selectedList = tbVehicleMapper.selectList(new LambdaQueryWrapper<TbVehicle>().eq(StringUtils.isNoneBlank(keyword), TbVehicle::getOwner, keyword));
 		if(selectedList.size() == 0)return "没有可导出的数据。";