Browse Source

7.21 基础资料的上传和导出

Mechrevo 1 year ago
parent
commit
d7599c79da
51 changed files with 3614 additions and 902 deletions
  1. 12 0
      sp-core/sp-base/pom.xml
  2. 139 0
      sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/MethodEnterpriseService.java
  3. 12 5
      sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterprise.java
  4. 38 1
      sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseController.java
  5. 137 2
      sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseService.java
  6. 101 101
      sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseUtil.java
  7. 101 0
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/MethodGoodsService.java
  8. 43 8
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoods.java
  9. 41 5
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsController.java
  10. 117 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java
  11. 69 69
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsUtil.java
  12. 116 0
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/MethodGoodsTransitService.java
  13. 11 5
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransit.java
  14. 37 3
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitController.java
  15. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitMapper.xml
  16. 121 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitService.java
  17. 85 85
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitUtil.java
  18. 80 0
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/MethodGoodsTypeService.java
  19. 8 3
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsType.java
  20. 43 5
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeController.java
  21. 101 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeService.java
  22. 65 65
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeUtil.java
  23. 73 0
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/MethodGoodsUnitsService.java
  24. 43 7
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsController.java
  25. 86 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsService.java
  26. 49 49
      sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsUtil.java
  27. 102 0
      sp-service/level-one-server/src/main/java/com/pj/tb_group/MethodGroupService.java
  28. 8 3
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroup.java
  29. 43 5
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupController.java
  30. 115 1
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java
  31. 77 77
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupUtil.java
  32. 171 0
      sp-service/level-one-server/src/main/java/com/pj/tb_people/MethodPeopleService.java
  33. 18 11
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeople.java
  34. 43 5
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleController.java
  35. 146 1
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java
  36. 113 113
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleUtil.java
  37. 108 0
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/MethodShopService.java
  38. 6 3
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShop.java
  39. 43 5
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopController.java
  40. 116 2
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java
  41. 80 80
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopUtil.java
  42. 84 0
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/MethodTradeAreaService.java
  43. 5 2
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeArea.java
  44. 45 7
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaController.java
  45. 103 1
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaService.java
  46. 66 66
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaUtil.java
  47. 125 0
      sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/MethodPurchaserService.java
  48. 8 3
      sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaser.java
  49. 41 5
      sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserController.java
  50. 126 1
      sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserService.java
  51. 92 92
      sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserUtil.java

+ 12 - 0
sp-core/sp-base/pom.xml

@@ -27,6 +27,18 @@
             <version>${project.parent.version}</version>
         </dependency>
 		<!-- ================= 模块依赖 end ================= -->
+
+        <!-- excel文件导入与导出 -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>4.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>4.0.0</version>
+        </dependency>
     
     
 	    <!-- nacos 注册中心 -->

+ 139 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/MethodEnterpriseService.java

@@ -0,0 +1,139 @@
+package com.pj.tb_enterprise;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 11 26
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodEnterpriseService {
+
+    @Autowired
+    private TbEnterpriseMapper tbEnterpriseMapper;
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbEnterprise tbEnterprise = new TbEnterprise();
+            //解析数据
+            if(row.getCell(1) != null && !row.getCell(1).toString().trim().equals(""))
+                tbEnterprise.setName(row.getCell(1).getStringCellValue());
+
+            if(row.getCell(2) != null && !row.getCell(2).toString().trim().equals(""))
+                tbEnterprise.setNationality(row.getCell(2).getStringCellValue());
+
+            if(row.getCell(3) != null && !row.getCell(3).toString().trim().equals(""))
+                tbEnterprise.setType(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(4) != null && !row.getCell(4).toString().trim().equals(""))
+                tbEnterprise.setLegalPerson(row.getCell(4).getStringCellValue());
+
+            if(row.getCell(5) != null && !row.getCell(5).toString().trim().equals(""))
+                tbEnterprise.setIdCard(row.getCell(5).getStringCellValue());
+
+            if(row.getCell(6) != null && !row.getCell(6).toString().trim().equals(""))
+                tbEnterprise.setContact(row.getCell(6).getStringCellValue());
+
+            if(row.getCell(7) != null && !row.getCell(7).toString().trim().equals(""))
+                tbEnterprise.setBusinessLicense(row.getCell(7).getStringCellValue());
+
+            HSSFCell cell5 = row.getCell(8);
+            if (cell5 != null && (cell5.getCellType() == CellType.NUMERIC || cell5.getCellType() == CellType.FORMULA))
+                tbEnterprise.setShopId((long)cell5.getNumericCellValue());
+
+            if(row.getCell(9) != null && !row.getCell(9).toString().trim().equals(""))
+                tbEnterprise.setShopName(row.getCell(9).getStringCellValue());
+
+            if(row.getCell(10) != null && !row.getCell(10).toString().trim().equals(""))
+                tbEnterprise.setBankNo(row.getCell(10).getStringCellValue());
+
+            if(row.getCell(11) != null && !row.getCell(11).toString().trim().equals(""))
+                tbEnterprise.setBankName(row.getCell(11).getStringCellValue());
+
+            if(row.getCell(12) != null && !row.getCell(12).toString().trim().equals(""))
+                tbEnterprise.setBankAccount(row.getCell(12).getStringCellValue());
+
+            if(row.getCell(13) != null && !row.getCell(13).toString().trim().equals(""))
+                tbEnterprise.setDutyParagraph(row.getCell(13).getStringCellValue());
+
+            if(row.getCell(14) != null && !row.getCell(14).toString().trim().equals(""))
+                tbEnterprise.setAddressIds(row.getCell(14).getStringCellValue());
+
+            if(row.getCell(15) != null && !row.getCell(15).toString().trim().equals(""))
+                tbEnterprise.setAddress(row.getCell(15).getStringCellValue());
+
+            if(row.getCell(16) != null && !row.getCell(16).toString().trim().equals(""))
+                tbEnterprise.setAgreement(row.getCell(16).getStringCellValue());
+
+            HSSFCell cell6 = row.getCell(17);
+            if (cell6 != null && (cell6.getCellType() == CellType.NUMERIC || cell6.getCellType() == CellType.FORMULA))
+                 tbEnterprise.setJudgeStatus(Integer.parseInt(row.getCell(17).getStringCellValue()));
+
+            if(row.getCell(18) != null && !row.getCell(18).toString().trim().equals(""))
+                tbEnterprise.setJudgeContent(row.getCell(18).getStringCellValue());
+
+            HSSFCell cell = row.getCell(19);
+            if (cell != null && cell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell))
+                tbEnterprise.setJudgeTime(cell.getDateCellValue());
+
+            HSSFCell cell1 = row.getCell(20);
+            if (cell1 != null && cell1.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell1)) {
+                Date dateValue = cell1.getDateCellValue();
+                tbEnterprise.setRegisterTime(dateValue);
+            }
+
+            if(row.getCell(21) != null && !row.getCell(21).toString().trim().equals(""))
+                tbEnterprise.setPersonId(row.getCell(21).getStringCellValue());
+
+            //公共字段
+            HSSFCell cell2 = row.getCell(22);
+            if (cell2 != null && cell2.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell2)) {
+                tbEnterprise.setCreateTime(cell2.getDateCellValue());
+            }
+
+            if(row.getCell(23) != null && !row.getCell(23).toString().trim().equals(""))
+                tbEnterprise.setCreateBy(row.getCell(23).getStringCellValue());
+
+            if(row.getCell(24) != null && !row.getCell(24).toString().trim().equals(""))
+                tbEnterprise.setCreateName(row.getCell(24).getStringCellValue());
+
+            if(row.getCell(25) != null && !row.getCell(25).toString().trim().equals(""))
+                tbEnterprise.setUpdateBy(row.getCell(25).getStringCellValue());
+            if(row.getCell(26) != null && !row.getCell(26).toString().trim().equals(""))
+                tbEnterprise.setUpdateName(row.getCell(26).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(27);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbEnterprise.setUpdateTime(row.getCell(27).getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbEnterprise.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbEnterprise);
+            int insert = tbEnterpriseMapper.insert(tbEnterprise);
+            count += insert;
+        }
+        return count;
+    }
+}

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

@@ -1,8 +1,11 @@
 package com.pj.tb_enterprise;
 
 import java.io.Serializable;
+import java.util.Date;
+
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -128,7 +131,7 @@ public class TbEnterprise extends Model<TbEnterprise> implements Serializable {
 	/**
 	 *  
 	 */
-	private String judgeStatus;	
+	private int judgeStatus;
 
 	/**
 	 *  
@@ -138,12 +141,14 @@ public class TbEnterprise extends Model<TbEnterprise> implements Serializable {
 	/**
 	 *  
 	 */
-	private String judgeTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date judgeTime;
 
 	/**
 	 *  
 	 */
-	private String registerTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date registerTime;
 
 	/**
 	 *  
@@ -153,7 +158,8 @@ public class TbEnterprise extends Model<TbEnterprise> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
-	private String createTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date createTime;
 
 	/**
 	 * 创建人编号 
@@ -168,7 +174,8 @@ public class TbEnterprise extends Model<TbEnterprise> implements Serializable {
 	/**
 	 * 更新时间 
 	 */
-	private String updateTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date updateTime;
 
 	/**
 	 * 更新人编号 

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

@@ -1,5 +1,6 @@
 package com.pj.tb_enterprise;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,9 @@ import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
 
 
 /**
@@ -85,7 +89,40 @@ public class TbEnterpriseController {
 		int line = SP.publicMapper.updateColumnById(TbEnterprise.TABLE_NAME, "delete_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("enterpriseImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file")MultipartFile file){
+		try {
+			String importData = tbEnterpriseService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("enterpriseOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbEnterpriseService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
 	
 
 	

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

@@ -1,13 +1,24 @@
 package com.pj.tb_enterprise;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
-import com.pj.utils.sg.*;
+import org.springframework.web.multipart.MultipartFile;
+
 
 /**
  * Service: tb_enterprise -- 商家
@@ -21,6 +32,10 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
 	@Autowired
 	TbEnterpriseMapper tbEnterpriseMapper;
 
+	/** 非事务方法调用事务方法需要代理对象 */
+	@Autowired
+	private MethodEnterpriseService methodEnterpriseService;
+
 	/** 增 */
 	void add(TbEnterprise t){
 		save(t);
@@ -46,6 +61,126 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
 	List<TbEnterprise> getList(SoMap so) { 
 		return tbEnterpriseMapper.getList(so);	
 	}
-	
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodEnterpriseService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		List<TbEnterprise> selectedList = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>().eq(StringUtils.isNoneBlank(keyword), TbEnterprise::getName, keyword));
+		if(selectedList.size() == 0)return "没有可导出的数据。";
+		//建立excel对象封装数据
+		HSSFWorkbook workbook = new HSSFWorkbook();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("名称");
+		row.createCell(2).setCellValue("国别");
+		row.createCell(3).setCellValue("商户分类");
+		row.createCell(4).setCellValue("法人");
+		row.createCell(5).setCellValue("身份证号");
+		row.createCell(6).setCellValue("手机号码");
+		row.createCell(7).setCellValue("营业执照");
+		row.createCell(8).setCellValue("所在铺位");
+		row.createCell(9).setCellValue("所在铺位名称");
+		row.createCell(10).setCellValue("银行编号");
+		row.createCell(11).setCellValue("银行名称");
+		row.createCell(12).setCellValue("银行账号");
+		row.createCell(13).setCellValue("银行税号");
+		row.createCell(14).setCellValue("地址ID集合");
+		row.createCell(15).setCellValue("地址");
+		row.createCell(16).setCellValue("agreement");
+		row.createCell(17).setCellValue("judge_status");
+		row.createCell(18).setCellValue("judge_content");
+		row.createCell(19).setCellValue("judge_time");
+		row.createCell(20).setCellValue("注册时间");
+		row.createCell(21).setCellValue("人物编号");
+		row.createCell(22).setCellValue("创建时间");
+		row.createCell(23).setCellValue("创建人编号");
+		row.createCell(24).setCellValue("创建人名称");
+		row.createCell(25).setCellValue("更新时间");
+		row.createCell(26).setCellValue("更新人编号");
+		row.createCell(27).setCellValue("更新人名称");
+		row.createCell(28).setCellValue("删除状态");
+
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getNationality() + "").equals("null")? "": selectedList.get(i).getNationality() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getType() + "").equals("null")? "": selectedList.get(i).getType() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getLegalPerson() + "").equals("null")? "": selectedList.get(i).getLegalPerson() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getIdCard() + "").equals("null")? "": selectedList.get(i).getIdCard() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getContact() + "").equals("null")? "": selectedList.get(i).getContact() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getBusinessLicense() + "").equals("null")? "": selectedList.get(i).getBusinessLicense() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getShopId() + "" ).equals("null")? "": selectedList.get(i).getShopId() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getShopName() + "").equals("null")? "": selectedList.get(i).getShopName() + "");
+			sheetRow.createCell(10).setCellValue((selectedList.get(i).getBankNo() + "").equals("null")? "": selectedList.get(i).getBankNo() + "");
+			sheetRow.createCell(11).setCellValue((selectedList.get(i).getBankName() + "").equals("null")? "": selectedList.get(i).getBankName() + "");
+			sheetRow.createCell(12).setCellValue((selectedList.get(i).getBankAccount() + "").equals("null")? "": selectedList.get(i).getBankAccount() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getDutyParagraph() + "").equals("null")? "": selectedList.get(i).getDutyParagraph() + "");
+			sheetRow.createCell(14).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
+			sheetRow.createCell(15).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
+			sheetRow.createCell(16).setCellValue((selectedList.get(i).getAgreement() + "").equals("null")? "": selectedList.get(i).getAgreement() + "");
+			sheetRow.createCell(17).setCellValue((selectedList.get(i).getJudgeStatus() + "").equals("null")? "": selectedList.get(i).getJudgeStatus() + "");
+			sheetRow.createCell(18).setCellValue((selectedList.get(i).getJudgeContent() + "").equals("null")? "": selectedList.get(i).getJudgeContent() + "");
+			sheetRow.createCell(19).setCellValue((selectedList.get(i).getJudgeTime() + "").equals("null")? "": selectedList.get(i).getJudgeTime() + "");
+			sheetRow.createCell(20).setCellValue((selectedList.get(i).getRegisterTime() + "").equals("null")? "": selectedList.get(i).getRegisterTime() + "");
+			sheetRow.createCell(21).setCellValue((selectedList.get(i).getPersonId() + "").equals("null")? "": selectedList.get(i).getPersonId() + "");
+			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			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() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
+
 
 }

+ 101 - 101
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseUtil.java

@@ -1,101 +1,101 @@
-package com.pj.tb_enterprise;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-
-/**
- * 工具类:tb_enterprise -- 商家
- * @author qzy 
- *
- */
-@Component
-public class TbEnterpriseUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbEnterpriseMapper tbEnterpriseMapper;
-	@Autowired
-	private void setTbEnterpriseMapper(TbEnterpriseMapper tbEnterpriseMapper) {
-		TbEnterpriseUtil.tbEnterpriseMapper = tbEnterpriseMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbEnterprise 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbEnterprise t) {
-		AjaxError.throwByIsNull(t.getId(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称 
-		AjaxError.throwByIsNull(t.getNationality(), "[国别] 不能为空");		// 验证: 国别 
-		AjaxError.throwByIsNull(t.getType(), "[商户分类] 不能为空");		// 验证: 商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺) 
-		AjaxError.throwByIsNull(t.getLegalPerson(), "[法人] 不能为空");		// 验证: 法人 
-		AjaxError.throwByIsNull(t.getIdCard(), "[身份证号] 不能为空");		// 验证: 身份证号 
-		AjaxError.throwByIsNull(t.getContact(), "[手机号码] 不能为空");		// 验证: 手机号码 
-		AjaxError.throwByIsNull(t.getBusinessLicense(), "[营业执照] 不能为空");		// 验证: 营业执照 
-		AjaxError.throwByIsNull(t.getShopId(), "[所在铺位ID] 不能为空");		// 验证: 所在铺位ID 
-		AjaxError.throwByIsNull(t.getShopName(), "[所在铺位名称] 不能为空");		// 验证: 所在铺位名称(1=100-2) 
-		AjaxError.throwByIsNull(t.getBankNo(), "[银行编号] 不能为空");		// 验证: 银行编号(CMB= 招商银行) 
-		AjaxError.throwByIsNull(t.getBankName(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getBankAccount(), "[银行账号] 不能为空");		// 验证: 银行账号 
-		AjaxError.throwByIsNull(t.getDutyParagraph(), "[税号] 不能为空");		// 验证: 税号 
-		AjaxError.throwByIsNull(t.getAddressIds(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getAddress(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getAgreement(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getJudgeStatus(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getJudgeContent(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getJudgeTime(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getRegisterTime(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getPersonId(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称 
-		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用) 
-	}
-
-	/** 
-	 * 获取一个TbEnterprise (方便复制代码用) [G] 
-	 */ 
-	static TbEnterprise getTbEnterprise() {
-		TbEnterprise t = new TbEnterprise();	// 声明对象 
-		t.setId(0L);		//  
-		t.setName("");		// 名称 
-		t.setNationality("");		// 国别 
-		t.setType("");		// 商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺) 
-		t.setLegalPerson("");		// 法人 
-		t.setIdCard("");		// 身份证号 
-		t.setContact("");		// 手机号码 
-		t.setBusinessLicense("");		// 营业执照 
-		t.setShopId(0L);		// 所在铺位ID 
-		t.setShopName("");		// 所在铺位名称(1=100-2) 
-		t.setBankNo("");		// 银行编号(CMB= 招商银行) 
-		t.setBankName("");		//  
-		t.setBankAccount("");		// 银行账号 
-		t.setDutyParagraph("");		// 税号 
-		t.setAddressIds("");		//  
-		t.setAddress("");		//  
-		t.setAgreement("");		//  
-		t.setJudgeStatus("");		//  
-		t.setJudgeContent("");		//  
-		t.setJudgeTime("");		//  
-		t.setRegisterTime("");		//  
-		t.setPersonId("");		//  
-		t.setCreateTime("");		// 创建时间 
-		t.setCreateBy("");		// 创建人编号 
-		t.setCreateName("");		// 创建人名称 
-		t.setUpdateTime("");		// 更新时间 
-		t.setUpdateBy("");		// 更新人编号 
-		t.setUpdateName("");		// 更新人名称 
-		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用) 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_enterprise;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//
+///**
+// * 工具类:tb_enterprise -- 商家
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbEnterpriseUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbEnterpriseMapper tbEnterpriseMapper;
+//	@Autowired
+//	private void setTbEnterpriseMapper(TbEnterpriseMapper tbEnterpriseMapper) {
+//		TbEnterpriseUtil.tbEnterpriseMapper = tbEnterpriseMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbEnterprise 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbEnterprise t) {
+//		AjaxError.throwByIsNull(t.getId(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称
+//		AjaxError.throwByIsNull(t.getNationality(), "[国别] 不能为空");		// 验证: 国别
+//		AjaxError.throwByIsNull(t.getType(), "[商户分类] 不能为空");		// 验证: 商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺)
+//		AjaxError.throwByIsNull(t.getLegalPerson(), "[法人] 不能为空");		// 验证: 法人
+//		AjaxError.throwByIsNull(t.getIdCard(), "[身份证号] 不能为空");		// 验证: 身份证号
+//		AjaxError.throwByIsNull(t.getContact(), "[手机号码] 不能为空");		// 验证: 手机号码
+//		AjaxError.throwByIsNull(t.getBusinessLicense(), "[营业执照] 不能为空");		// 验证: 营业执照
+//		AjaxError.throwByIsNull(t.getShopId(), "[所在铺位ID] 不能为空");		// 验证: 所在铺位ID
+//		AjaxError.throwByIsNull(t.getShopName(), "[所在铺位名称] 不能为空");		// 验证: 所在铺位名称(1=100-2)
+//		AjaxError.throwByIsNull(t.getBankNo(), "[银行编号] 不能为空");		// 验证: 银行编号(CMB= 招商银行)
+//		AjaxError.throwByIsNull(t.getBankName(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getBankAccount(), "[银行账号] 不能为空");		// 验证: 银行账号
+//		AjaxError.throwByIsNull(t.getDutyParagraph(), "[税号] 不能为空");		// 验证: 税号
+//		AjaxError.throwByIsNull(t.getAddressIds(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getAddress(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getAgreement(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getJudgeStatus(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getJudgeContent(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getJudgeTime(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getRegisterTime(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getPersonId(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称
+//		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用)
+//	}
+//
+//	/**
+//	 * 获取一个TbEnterprise (方便复制代码用) [G]
+//	 */
+//	static TbEnterprise getTbEnterprise() {
+//		TbEnterprise t = new TbEnterprise();	// 声明对象
+//		t.setId(0L);		//
+//		t.setName("");		// 名称
+//		t.setNationality("");		// 国别
+//		t.setType("");		// 商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺)
+//		t.setLegalPerson("");		// 法人
+//		t.setIdCard("");		// 身份证号
+//		t.setContact("");		// 手机号码
+//		t.setBusinessLicense("");		// 营业执照
+//		t.setShopId(0L);		// 所在铺位ID
+//		t.setShopName("");		// 所在铺位名称(1=100-2)
+//		t.setBankNo("");		// 银行编号(CMB= 招商银行)
+//		t.setBankName("");		//
+//		t.setBankAccount("");		// 银行账号
+//		t.setDutyParagraph("");		// 税号
+//		t.setAddressIds("");		//
+//		t.setAddress("");		//
+//		t.setAgreement("");		//
+//		t.setJudgeStatus("");		//
+//		t.setJudgeContent("");		//
+//		t.setJudgeTime("");		//
+//		t.setRegisterTime("");		//
+//		t.setPersonId("");		//
+//		t.setCreateTime("");		// 创建时间
+//		t.setCreateBy("");		// 创建人编号
+//		t.setCreateName("");		// 创建人名称
+//		t.setUpdateTime("");		// 更新时间
+//		t.setUpdateBy("");		// 更新人编号
+//		t.setUpdateName("");		// 更新人名称
+//		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用)
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 101 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_goods/MethodGoodsService.java

@@ -0,0 +1,101 @@
+package com.pj.tb_goods;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 15 52
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodGoodsService {
+
+    @Autowired
+    private TbGoodsMapper tbGoodsMapper;
+
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbGoods tbGoods = new TbGoods();
+            //解析数据
+            if(row.getCell(1) != null)
+                tbGoods.setName(row.getCell(1).getStringCellValue());
+            if(row.getCell(2) != null)
+                tbGoods.setAvatar(row.getCell(2).getStringCellValue());
+            if(row.getCell(3) != null)
+                tbGoods.setTypeIds(row.getCell(3).getStringCellValue());
+            if(row.getCell(4) != null)
+                tbGoods.setTypeNames(row.getCell(4).getStringCellValue());
+            if(row.getCell(5) != null)
+                tbGoods.setCode(row.getCell(5).getStringCellValue());
+            if(row.getCell(6) != null)
+                tbGoods.setRemark(row.getCell(6).getStringCellValue());
+            if(row.getCell(7) != null)
+                tbGoods.setSource(row.getCell(7).getStringCellValue());
+
+            HSSFCell cell8 = row.getCell(8);
+            if (cell8 != null && (cell8.getCellType() == CellType.NUMERIC || cell8.getCellType() == CellType.FORMULA))
+                tbGoods.setStatus((int)row.getCell(9).getNumericCellValue());
+
+            if(row.getCell(9) != null)
+                tbGoods.setUnit(row.getCell(9).getStringCellValue());
+
+            HSSFCell cell11 = row.createCell(10);
+            if (cell11 != null && (cell11.getCellType() == CellType.NUMERIC || cell11.getCellType() == CellType.FORMULA))
+                tbGoods.setSinglePrice(row.getCell(11).getNumericCellValue());
+
+            if(row.getCell(11) != null)
+                tbGoods.setTaxNo(row.getCell(11).getStringCellValue());
+
+            //公共字段
+            HSSFCell cell2 = row.getCell(12);
+            if (cell2 != null && cell2.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell2)) {
+                tbGoods.setCreateTime(cell2.getDateCellValue());
+            }
+
+            if(row.getCell(13) != null && !row.getCell(13).toString().trim().equals(""))
+                tbGoods.setCreateBy(row.getCell(13).getStringCellValue());
+
+            if(row.getCell(14) != null && !row.getCell(14).toString().trim().equals(""))
+                tbGoods.setCreateName(row.getCell(14).getStringCellValue());
+
+            if(row.getCell(15) != null && !row.getCell(15).toString().trim().equals(""))
+                tbGoods.setUpdateBy(row.getCell(15).getStringCellValue());
+
+            if(row.getCell(16) != null && !row.getCell(16).toString().trim().equals(""))
+                tbGoods.setUpdateName(row.getCell(16).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(17);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbGoods.setUpdateTime(row.getCell(17).getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbGoods.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbGoods);
+            int insert = tbGoodsMapper.insert(tbGoods);
+            count += insert;
+        }
+        return count;
+    }
+
+}

+ 43 - 8
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoods.java

@@ -1,8 +1,11 @@
 package com.pj.tb_goods;
 
 import java.io.Serializable;
+import java.util.Date;
+
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -43,7 +46,7 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 	 * 主键 
 	 */
 	@TableId(type = IdType.AUTO)
-	private String id;	
+	private Long id;
 
 	/**
 	 * 名称 
@@ -83,12 +86,9 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 	/**
 	 * 状态(0=禁用,1=启用) 
 	 */
-	private String status;	
+	private int status;
+
 
-	/**
-	 * 创建时间 
-	 */
-	private String createTime;	
 
 	/**
 	 *  
@@ -103,13 +103,48 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 	/**
 	 *  
 	 */
-	private String taxNo;	
+	private String taxNo;
+
+
+	/**
+	 * 创建时间
+	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date createTime;
+
+	/**
+	 * 创建人编号
+	 */
+	private String createBy;
+
+	/**
+	 * 创建人名称
+	 */
+	private String createName;
+
+	/**
+	 * 更新时间
+	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date updateTime;
+
+	/**
+	 * 更新人编号
+	 */
+	private String updateBy;
 
+	/**
+	 * 更新人名称
+	 */
+	private String updateName;
 
+	/**
+	 * 删除状态(0=禁用,1=启用)
+	 */
+	private Integer deleteStatus;
 
 
 
-	
 
 
 }

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

@@ -1,5 +1,6 @@
 package com.pj.tb_goods;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -85,11 +87,45 @@ public class TbGoodsController {
 		int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("goodsImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbGoodsService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("goodsOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbGoodsService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
+
 
-	
-	
-	
 
 }

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

@@ -1,13 +1,25 @@
 package com.pj.tb_goods;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.tb_enterprise.TbEnterprise;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_goods -- 商品
@@ -21,6 +33,9 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
 	@Autowired
 	TbGoodsMapper tbGoodsMapper;
 
+	@Autowired
+	private MethodGoodsService methodGoodsService;
+
 	/** 增 */
 	void add(TbGoods t){
 		save(t);
@@ -46,6 +61,107 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
 	List<TbGoods> getList(SoMap so) { 
 		return tbGoodsMapper.getList(so);	
 	}
-	
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodGoodsService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		List<TbGoods> selectedList = tbGoodsMapper.selectList(new LambdaQueryWrapper<TbGoods>().eq(StringUtils.isNoneBlank(keyword), TbGoods::getName, keyword));
+		if(selectedList.size() == 0)return "没有可导出的数据。";
+		//建立excel对象封装数据
+		HSSFWorkbook workbook = new HSSFWorkbook();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("名称");
+		row.createCell(2).setCellValue("主图");
+		row.createCell(3).setCellValue("分类");
+		row.createCell(4).setCellValue("分类名称");
+		row.createCell(5).setCellValue("编号");
+		row.createCell(6).setCellValue("备注");
+		row.createCell(7).setCellValue("原产地");
+		row.createCell(8).setCellValue("状态");
+		row.createCell(9).setCellValue("unit");
+		row.createCell(10).setCellValue("single_price");
+		row.createCell(11).setCellValue("tax_no");
+		row.createCell(12).setCellValue("创建时间");
+		row.createCell(13).setCellValue("创建人编号");
+		row.createCell(14).setCellValue("创建人名称");
+		row.createCell(15).setCellValue("更新时间");
+		row.createCell(16).setCellValue("更新人编号");
+		row.createCell(17).setCellValue("更新人名称");
+		row.createCell(18).setCellValue("删除状态");
+
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getAvatar() + "").equals("null")? "": selectedList.get(i).getAvatar() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getTypeIds() + "").equals("null")? "": selectedList.get(i).getTypeIds() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getTypeNames() + "").equals("null")? "": selectedList.get(i).getTypeNames() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getCode() + "").equals("null")? "": selectedList.get(i).getCode() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getRemark() + "").equals("null")? "": selectedList.get(i).getRemark() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getSource() + "").equals("null")? "": selectedList.get(i).getSource() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getStatus() + "" ).equals("null")? "": selectedList.get(i).getStatus() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getUnit() + "").equals("null")? "": selectedList.get(i).getUnit() + "");
+			sheetRow.createCell(10).setCellValue((selectedList.get(i).getSinglePrice() + "").equals("null")? "": selectedList.get(i).getSinglePrice() + "");
+			sheetRow.createCell(11).setCellValue((selectedList.get(i).getTaxNo() + "").equals("null")? "": selectedList.get(i).getTaxNo() + "");
+			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			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() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
+
+
 
 }

+ 69 - 69
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsUtil.java

@@ -1,69 +1,69 @@
-package com.pj.tb_goods;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-
-/**
- * 工具类:tb_goods -- 商品
- * @author qzy 
- *
- */
-@Component
-public class TbGoodsUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbGoodsMapper tbGoodsMapper;
-	@Autowired
-	private void setTbGoodsMapper(TbGoodsMapper tbGoodsMapper) {
-		TbGoodsUtil.tbGoodsMapper = tbGoodsMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbGoods 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbGoods t) {
-		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
-		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称 
-		AjaxError.throwByIsNull(t.getAvatar(), "[主图] 不能为空");		// 验证: 主图 
-		AjaxError.throwByIsNull(t.getTypeIds(), "[分类ID字符串(可多选)] 不能为空");		// 验证: 分类ID 字符串(可多选) 
-		AjaxError.throwByIsNull(t.getTypeNames(), "[分类名称] 不能为空");		// 验证: 分类名称 
-		AjaxError.throwByIsNull(t.getCode(), "[编号] 不能为空");		// 验证: 编号 
-		AjaxError.throwByIsNull(t.getRemark(), "[备注] 不能为空");		// 验证: 备注 
-		AjaxError.throwByIsNull(t.getSource(), "[原产地] 不能为空");		// 验证: 原产地 
-		AjaxError.throwByIsNull(t.getStatus(), "[状态] 不能为空");		// 验证: 状态(0=禁用,1=启用) 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getUnit(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getSinglePrice(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getTaxNo(), "[] 不能为空");		// 验证:  
-	}
-
-	/** 
-	 * 获取一个TbGoods (方便复制代码用) [G] 
-	 */ 
-	static TbGoods getTbGoods() {
-		TbGoods t = new TbGoods();	// 声明对象 
-		t.setId("");		// 主键 
-		t.setName("");		// 名称 
-		t.setAvatar("");		// 主图 
-		t.setTypeIds("");		// 分类ID 字符串(可多选) 
-		t.setTypeNames("");		// 分类名称 
-		t.setCode("");		// 编号 
-		t.setRemark("");		// 备注 
-		t.setSource("");		// 原产地 
-		t.setStatus("");		// 状态(0=禁用,1=启用) 
-		t.setCreateTime("");		// 创建时间 
-		t.setUnit("");		//  
-		t.setSinglePrice(0.0);		//  
-		t.setTaxNo("");		//  
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_goods;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//
+///**
+// * 工具类:tb_goods -- 商品
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbGoodsUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbGoodsMapper tbGoodsMapper;
+//	@Autowired
+//	private void setTbGoodsMapper(TbGoodsMapper tbGoodsMapper) {
+//		TbGoodsUtil.tbGoodsMapper = tbGoodsMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbGoods 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbGoods t) {
+//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
+//		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称
+//		AjaxError.throwByIsNull(t.getAvatar(), "[主图] 不能为空");		// 验证: 主图
+//		AjaxError.throwByIsNull(t.getTypeIds(), "[分类ID字符串(可多选)] 不能为空");		// 验证: 分类ID 字符串(可多选)
+//		AjaxError.throwByIsNull(t.getTypeNames(), "[分类名称] 不能为空");		// 验证: 分类名称
+//		AjaxError.throwByIsNull(t.getCode(), "[编号] 不能为空");		// 验证: 编号
+//		AjaxError.throwByIsNull(t.getRemark(), "[备注] 不能为空");		// 验证: 备注
+//		AjaxError.throwByIsNull(t.getSource(), "[原产地] 不能为空");		// 验证: 原产地
+//		AjaxError.throwByIsNull(t.getStatus(), "[状态] 不能为空");		// 验证: 状态(0=禁用,1=启用)
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getUnit(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getSinglePrice(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getTaxNo(), "[] 不能为空");		// 验证:
+//	}
+//
+//	/**
+//	 * 获取一个TbGoods (方便复制代码用) [G]
+//	 */
+//	static TbGoods getTbGoods() {
+//		TbGoods t = new TbGoods();	// 声明对象
+//		t.setId("");		// 主键
+//		t.setName("");		// 名称
+//		t.setAvatar("");		// 主图
+//		t.setTypeIds("");		// 分类ID 字符串(可多选)
+//		t.setTypeNames("");		// 分类名称
+//		t.setCode("");		// 编号
+//		t.setRemark("");		// 备注
+//		t.setSource("");		// 原产地
+//		t.setStatus("");		// 状态(0=禁用,1=启用)
+//		t.setCreateTime("");		// 创建时间
+//		t.setUnit("");		//
+//		t.setSinglePrice(0.0);		//
+//		t.setTaxNo("");		//
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 116 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/MethodGoodsTransitService.java

@@ -0,0 +1,116 @@
+package com.pj.tb_goods_transit;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 16 36
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodGoodsTransitService {
+    
+    @Autowired
+    private TbGoodsTransitMapper tbGoodsTransitMapper;
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbGoodsTransit tbGoodsTransit = new TbGoodsTransit();
+            //解析数据
+            if(row.getCell(1) != null && !row.getCell(1).toString().trim().equals(""))
+                tbGoodsTransit.setMerchantId(row.getCell(1).getStringCellValue());
+
+            if(row.getCell(2) != null && !row.getCell(2).toString().trim().equals(""))
+                tbGoodsTransit.setMerchantName(row.getCell(2).getStringCellValue());
+
+            if(row.getCell(3) != null && !row.getCell(3).toString().trim().equals(""))
+                tbGoodsTransit.setGoodsType(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(4) != null && !row.getCell(4).toString().trim().equals(""))
+                tbGoodsTransit.setGoodsName(row.getCell(4).getStringCellValue());
+
+            if(row.getCell(5) != null && !row.getCell(5).toString().trim().equals(""))
+                tbGoodsTransit.setGoodsUnits(row.getCell(5).getStringCellValue());
+
+            HSSFCell cell6 = row.getCell(6);
+            if (cell6 != null && (cell6.getCellType() == CellType.NUMERIC || cell6.getCellType() == CellType.FORMULA))
+                tbGoodsTransit.setPrice(cell6.getNumericCellValue());
+
+            if(row.getCell(7) != null && !row.getCell(7).toString().trim().equals(""))
+                tbGoodsTransit.setPlaceOrigin(row.getCell(7).getStringCellValue());
+
+            if(row.getCell(8) != null && !row.getCell(8).toString().trim().equals(""))
+                tbGoodsTransit.setDescription(row.getCell(8).getStringCellValue()   );
+
+            HSSFCell cell9 = row.getCell(9);
+            if (cell9 != null && (cell9.getCellType() == CellType.NUMERIC || cell9.getCellType() == CellType.FORMULA))
+                tbGoodsTransit.setStock((int)cell9.getNumericCellValue());
+
+            HSSFCell cell10 = row.getCell(10);
+            if (cell10 != null && (cell10.getCellType() == CellType.NUMERIC || cell10.getCellType() == CellType.FORMULA))
+                tbGoodsTransit.setGoodsStatus((int)cell10.getNumericCellValue());
+
+            HSSFCell cell11 = row.getCell(11);
+            if (cell11 != null && (cell11.getCellType() == CellType.NUMERIC || cell11.getCellType() == CellType.FORMULA))
+                tbGoodsTransit.setAuditStatus((int) cell11.getNumericCellValue());
+
+            HSSFCell cell2 = row.getCell(12);
+            if (cell2 != null && cell2.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell2))
+                if(row.getCell(12) != null && !row.getCell(12).toString().trim().equals(""))
+                    tbGoodsTransit.setAuditTime(cell2.getDateCellValue());
+
+            if(row.getCell(13) != null && !row.getCell(13).toString().trim().equals(""))
+                tbGoodsTransit.setRemark(row.getCell(13).getStringCellValue());
+
+            //公共字段
+            HSSFCell cell4 = row.getCell(14);
+            if (cell4 != null && cell4.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell4)) {
+                tbGoodsTransit.setCreateTime(cell4.getDateCellValue());
+            }
+
+            if(row.getCell(15) != null && !row.getCell(15).toString().trim().equals(""))
+                tbGoodsTransit.setCreateBy(row.getCell(15).getStringCellValue());
+
+            if(row.getCell(16) != null && !row.getCell(16).toString().trim().equals(""))
+                tbGoodsTransit.setCreateName(row.getCell(16).getStringCellValue());
+
+            if(row.getCell(17) != null && !row.getCell(17).toString().trim().equals(""))
+                tbGoodsTransit.setUpdateBy(row.getCell(17).getStringCellValue());
+
+            if(row.getCell(18) != null && !row.getCell(18).toString().trim().equals(""))
+                tbGoodsTransit.setUpdateName(row.getCell(18).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(19);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbGoodsTransit.setUpdateTime(row.getCell(19).getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbGoodsTransit.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbGoodsTransit);
+            int insert = tbGoodsTransitMapper.insert(tbGoodsTransit);
+            count += insert;
+        }
+        return count;
+    }
+    
+}

+ 11 - 5
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransit.java

@@ -1,8 +1,11 @@
 package com.pj.tb_goods_transit;
 
 import java.io.Serializable;
+import java.util.Date;
+
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -83,7 +86,7 @@ public class TbGoodsTransit extends Model<TbGoodsTransit> implements Serializabl
 	/**
 	 * 商品描述 
 	 */
-	private String discription;	
+	private String description;
 
 	/**
 	 * 库存数量 
@@ -103,7 +106,8 @@ public class TbGoodsTransit extends Model<TbGoodsTransit> implements Serializabl
 	/**
 	 * 审核时间 
 	 */
-	private String auditTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date auditTime;
 
 	/**
 	 * 审核意见 
@@ -113,7 +117,8 @@ public class TbGoodsTransit extends Model<TbGoodsTransit> implements Serializabl
 	/**
 	 * 创建时间 
 	 */
-	private String createTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date createTime;
 
 	/**
 	 * 创建人编号 
@@ -128,7 +133,8 @@ public class TbGoodsTransit extends Model<TbGoodsTransit> implements Serializabl
 	/**
 	 * 更新时间 
 	 */
-	private String updateTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date updateTime;
 
 	/**
 	 * 更新人编号 
@@ -143,7 +149,7 @@ public class TbGoodsTransit extends Model<TbGoodsTransit> implements Serializabl
 	/**
 	 * 删除状态(0=禁用,1=启用) 
 	 */
-	private Integer delStatus;	
+	private Integer deleteStatus;
 
 
 

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

@@ -1,5 +1,6 @@
 package com.pj.tb_goods_transit;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -101,10 +103,42 @@ public class TbGoodsTransitController {
 		int line = SP.publicMapper.updateColumnById(TbGoodsTransit.TABLE_NAME, "del_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	
 
-	
+
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("goodsTransitImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbGoodsTransitService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("goodsTransitOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbGoodsTransitService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
 	
 	
 

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

@@ -30,7 +30,7 @@
 			<if test=' this.has("goodsUnits") '> and goods_units = #{goodsUnits} </if>
 			<if test=' this.has("price") '> and price = #{price} </if>
 			<if test=' this.has("placeOrigin") '> and place_origin = #{placeOrigin} </if>
-			<if test=' this.has("discription") '> and discription = #{discription} </if>
+			<if test=' this.has("description") '> and discription = #{discription} </if>
 			<if test=' this.has("stock") '> and stock = #{stock} </if>
 			<if test=' this.has("goodsStatus") '> and goods_status = #{goodsStatus} </if>
 			<if test=' this.has("auditStatus") '> and audit_status = #{auditStatus} </if>
@@ -42,7 +42,7 @@
 			<if test=' this.has("updateTime") '> and update_time = #{updateTime} </if>
 			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
 			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>
-			<if test=' this.has("delStatus") '> and del_status = #{delStatus} </if>
+			<if test=' this.has("deleteStatus") '> and del_status = #{delStatus} </if>
 		</where>
 		order by
 		<choose>

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

@@ -1,13 +1,25 @@
 package com.pj.tb_goods_transit;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.tb_enterprise.TbEnterprise;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_goods_transit -- 审核商户在APP端发布的商品
@@ -21,6 +33,9 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 	@Autowired
 	TbGoodsTransitMapper tbGoodsTransitMapper;
 
+	@Autowired
+	private MethodGoodsTransitService methodGoodsTransitService;
+
 	/** 增 */
 	void add(TbGoodsTransit t){
 		save(t);
@@ -46,6 +61,111 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 	List<TbGoodsTransit> getList(SoMap so) { 
 		return tbGoodsTransitMapper.getList(so);	
 	}
-	
+
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodGoodsTransitService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		List<TbGoodsTransit> selectedList = tbGoodsTransitMapper.selectList(new LambdaQueryWrapper<TbGoodsTransit>().eq(StringUtils.isNoneBlank(keyword), TbGoodsTransit::getMerchantName, keyword));
+		if(selectedList.size() == 0)return "没有可导出的数据。";
+		//建立excel对象封装数据
+		HSSFWorkbook workbook = new HSSFWorkbook();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("商户编号");
+		row.createCell(2).setCellValue("商户名称");
+		row.createCell(3).setCellValue("商品类型");
+		row.createCell(4).setCellValue("商品名称");
+		row.createCell(5).setCellValue("商品单位");
+		row.createCell(6).setCellValue("商品价格");
+		row.createCell(7).setCellValue("产地(国家)");
+		row.createCell(8).setCellValue("商品描述");
+		row.createCell(9).setCellValue("库存数量");
+		row.createCell(10).setCellValue("商品状态");
+		row.createCell(11).setCellValue("审核状态");
+		row.createCell(12).setCellValue("审核时间");
+		row.createCell(13).setCellValue("审核意见");
+		row.createCell(14).setCellValue("创建时间");
+		row.createCell(15).setCellValue("创建人编号");
+		row.createCell(16).setCellValue("创建人名称");
+		row.createCell(17).setCellValue("更新时间");
+		row.createCell(18).setCellValue("更新人编号");
+		row.createCell(19).setCellValue("更新人名称");
+		row.createCell(20).setCellValue("删除状态");
+
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getMerchantId() + "").equals("null")? "": selectedList.get(i).getMerchantId() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getMerchantName() + "").equals("null")? "": selectedList.get(i).getMerchantName() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getGoodsType() + "").equals("null")? "": selectedList.get(i).getGoodsType() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getGoodsName() + "").equals("null")? "": selectedList.get(i).getGoodsName() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getGoodsUnits() + "").equals("null")? "": selectedList.get(i).getGoodsUnits() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getPrice() + "").equals("null")? "": selectedList.get(i).getPrice() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getPlaceOrigin() + "").equals("null")? "": selectedList.get(i).getPlaceOrigin() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getDescription() + "" ).equals("null")? "": selectedList.get(i).getDescription() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getStock() + "").equals("null")? "": selectedList.get(i).getStock() + "");
+			sheetRow.createCell(10).setCellValue((selectedList.get(i).getGoodsStatus() + "").equals("null")? "": selectedList.get(i).getGoodsStatus() + "");
+			sheetRow.createCell(11).setCellValue((selectedList.get(i).getAuditStatus() + "").equals("null")? "": selectedList.get(i).getAuditStatus() + "");
+			sheetRow.createCell(12).setCellValue((selectedList.get(i).getAuditTime() + "").equals("null")? "": selectedList.get(i).getAuditTime() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getRemark() + "").equals("null")? "": selectedList.get(i).getRemark() + "");
+			//公共字段
+			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			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() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
 
 }

+ 85 - 85
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitUtil.java

@@ -1,85 +1,85 @@
-package com.pj.tb_goods_transit;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-
-/**
- * 工具类:tb_goods_transit -- 审核商户在APP端发布的商品
- * @author qzy 
- *
- */
-@Component
-public class TbGoodsTransitUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbGoodsTransitMapper tbGoodsTransitMapper;
-	@Autowired
-	private void setTbGoodsTransitMapper(TbGoodsTransitMapper tbGoodsTransitMapper) {
-		TbGoodsTransitUtil.tbGoodsTransitMapper = tbGoodsTransitMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbGoodsTransit 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbGoodsTransit t) {
-		AjaxError.throwByIsNull(t.getId(), "[在销商品表主键] 不能为空");		// 验证: 在销商品表主键 
-		AjaxError.throwByIsNull(t.getMerchantId(), "[商户编号] 不能为空");		// 验证: 商户编号 
-		AjaxError.throwByIsNull(t.getMerchantName(), "[商户名称] 不能为空");		// 验证: 商户名称 
-		AjaxError.throwByIsNull(t.getGoodsType(), "[商品类型] 不能为空");		// 验证: 商品类型 
-		AjaxError.throwByIsNull(t.getGoodsName(), "[商品名称] 不能为空");		// 验证: 商品名称 
-		AjaxError.throwByIsNull(t.getGoodsUnits(), "[商品单位] 不能为空");		// 验证: 商品单位(吨、kg、个、柜) 
-		AjaxError.throwByIsNull(t.getPrice(), "[商品价格] 不能为空");		// 验证: 商品价格 
-		AjaxError.throwByIsNull(t.getPlaceOrigin(), "[产地] 不能为空");		// 验证: 产地(国家) 
-		AjaxError.throwByIsNull(t.getDiscription(), "[商品描述] 不能为空");		// 验证: 商品描述 
-		AjaxError.throwByIsNull(t.getStock(), "[库存数量] 不能为空");		// 验证: 库存数量 
-		AjaxError.throwByIsNull(t.getGoodsStatus(), "[商品状态] 不能为空");		// 验证: 商品状态(0=下架,1=在售) 
-		AjaxError.throwByIsNull(t.getAuditStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=待审核,1=通过,2=不通过) 
-		AjaxError.throwByIsNull(t.getAuditTime(), "[审核时间] 不能为空");		// 验证: 审核时间 
-		AjaxError.throwByIsNull(t.getRemark(), "[审核意见] 不能为空");		// 验证: 审核意见 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称 
-		AjaxError.throwByIsNull(t.getDelStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用) 
-	}
-
-	/** 
-	 * 获取一个TbGoodsTransit (方便复制代码用) [G] 
-	 */ 
-	static TbGoodsTransit getTbGoodsTransit() {
-		TbGoodsTransit t = new TbGoodsTransit();	// 声明对象 
-		t.setId(0L);		// 在销商品表主键 
-		t.setMerchantId("");		// 商户编号 
-		t.setMerchantName("");		// 商户名称 
-		t.setGoodsType("");		// 商品类型 
-		t.setGoodsName("");		// 商品名称 
-		t.setGoodsUnits("");		// 商品单位(吨、kg、个、柜) 
-		t.setPrice(0.0);		// 商品价格 
-		t.setPlaceOrigin("");		// 产地(国家) 
-		t.setDiscription("");		// 商品描述 
-		t.setStock(0);		// 库存数量 
-		t.setGoodsStatus(0);		// 商品状态(0=下架,1=在售) 
-		t.setAuditStatus(0);		// 审核状态(0=待审核,1=通过,2=不通过) 
-		t.setAuditTime("");		// 审核时间 
-		t.setRemark("");		// 审核意见 
-		t.setCreateTime("");		// 创建时间 
-		t.setCreateBy("");		// 创建人编号 
-		t.setCreateName("");		// 创建人名称 
-		t.setUpdateTime("");		// 更新时间 
-		t.setUpdateBy("");		// 更新人编号 
-		t.setUpdateName("");		// 更新人名称 
-		t.setDelStatus(0);		// 删除状态(0=禁用,1=启用) 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_goods_transit;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//
+///**
+// * 工具类:tb_goods_transit -- 审核商户在APP端发布的商品
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbGoodsTransitUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbGoodsTransitMapper tbGoodsTransitMapper;
+//	@Autowired
+//	private void setTbGoodsTransitMapper(TbGoodsTransitMapper tbGoodsTransitMapper) {
+//		TbGoodsTransitUtil.tbGoodsTransitMapper = tbGoodsTransitMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbGoodsTransit 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbGoodsTransit t) {
+//		AjaxError.throwByIsNull(t.getId(), "[在销商品表主键] 不能为空");		// 验证: 在销商品表主键
+//		AjaxError.throwByIsNull(t.getMerchantId(), "[商户编号] 不能为空");		// 验证: 商户编号
+//		AjaxError.throwByIsNull(t.getMerchantName(), "[商户名称] 不能为空");		// 验证: 商户名称
+//		AjaxError.throwByIsNull(t.getGoodsType(), "[商品类型] 不能为空");		// 验证: 商品类型
+//		AjaxError.throwByIsNull(t.getGoodsName(), "[商品名称] 不能为空");		// 验证: 商品名称
+//		AjaxError.throwByIsNull(t.getGoodsUnits(), "[商品单位] 不能为空");		// 验证: 商品单位(吨、kg、个、柜)
+//		AjaxError.throwByIsNull(t.getPrice(), "[商品价格] 不能为空");		// 验证: 商品价格
+//		AjaxError.throwByIsNull(t.getPlaceOrigin(), "[产地] 不能为空");		// 验证: 产地(国家)
+//		AjaxError.throwByIsNull(t.getDiscription(), "[商品描述] 不能为空");		// 验证: 商品描述
+//		AjaxError.throwByIsNull(t.getStock(), "[库存数量] 不能为空");		// 验证: 库存数量
+//		AjaxError.throwByIsNull(t.getGoodsStatus(), "[商品状态] 不能为空");		// 验证: 商品状态(0=下架,1=在售)
+//		AjaxError.throwByIsNull(t.getAuditStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=待审核,1=通过,2=不通过)
+//		AjaxError.throwByIsNull(t.getAuditTime(), "[审核时间] 不能为空");		// 验证: 审核时间
+//		AjaxError.throwByIsNull(t.getRemark(), "[审核意见] 不能为空");		// 验证: 审核意见
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称
+//		AjaxError.throwByIsNull(t.getDelStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用)
+//	}
+//
+//	/**
+//	 * 获取一个TbGoodsTransit (方便复制代码用) [G]
+//	 */
+//	static TbGoodsTransit getTbGoodsTransit() {
+//		TbGoodsTransit t = new TbGoodsTransit();	// 声明对象
+//		t.setId(0L);		// 在销商品表主键
+//		t.setMerchantId("");		// 商户编号
+//		t.setMerchantName("");		// 商户名称
+//		t.setGoodsType("");		// 商品类型
+//		t.setGoodsName("");		// 商品名称
+//		t.setGoodsUnits("");		// 商品单位(吨、kg、个、柜)
+//		t.setPrice(0.0);		// 商品价格
+//		t.setPlaceOrigin("");		// 产地(国家)
+//		t.setDiscription("");		// 商品描述
+//		t.setStock(0);		// 库存数量
+//		t.setGoodsStatus(0);		// 商品状态(0=下架,1=在售)
+//		t.setAuditStatus(0);		// 审核状态(0=待审核,1=通过,2=不通过)
+//		t.setAuditTime("");		// 审核时间
+//		t.setRemark("");		// 审核意见
+//		t.setCreateTime("");		// 创建时间
+//		t.setCreateBy("");		// 创建人编号
+//		t.setCreateName("");		// 创建人名称
+//		t.setUpdateTime("");		// 更新时间
+//		t.setUpdateBy("");		// 更新人编号
+//		t.setUpdateName("");		// 更新人名称
+//		t.setDelStatus(0);		// 删除状态(0=禁用,1=启用)
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 80 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/MethodGoodsTypeService.java

@@ -0,0 +1,80 @@
+package com.pj.tb_goods_type;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 17 16
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodGoodsTypeService {
+
+
+    @Autowired
+    private TbGoodsTypeMapper tbGoodsTypeMapper;
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbGoodsType tbGoodsType = new TbGoodsType();
+            //解析数据
+            if(row.getCell(1) != null)
+                tbGoodsType.setName(row.getCell(1).getStringCellValue());
+
+            HSSFCell cell8 = row.getCell(2);
+            if (cell8 != null && (cell8.getCellType() == CellType.NUMERIC || cell8.getCellType() == CellType.FORMULA))
+                tbGoodsType.setSort((int) cell8.getNumericCellValue());
+
+            if(row.getCell(3) != null)
+                tbGoodsType.setNo(row.getCell(3).getStringCellValue());
+
+            //公共字段
+            HSSFCell cell2 = row.getCell(4);
+            if (cell2 != null && cell2.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell2)) {
+                tbGoodsType.setCreateTime(cell2.getDateCellValue());
+            }
+
+            if(row.getCell(5) != null && !row.getCell(5).toString().trim().equals(""))
+                tbGoodsType.setCreateBy(row.getCell(5).getStringCellValue());
+
+            if(row.getCell(6) != null && !row.getCell(6).toString().trim().equals(""))
+                tbGoodsType.setCreateName(row.getCell(6).getStringCellValue());
+
+            if(row.getCell(7) != null && !row.getCell(7).toString().trim().equals(""))
+                tbGoodsType.setUpdateBy(row.getCell(7).getStringCellValue());
+
+            if(row.getCell(8) != null && !row.getCell(8).toString().trim().equals(""))
+                tbGoodsType.setUpdateName(row.getCell(8).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(9);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbGoodsType.setUpdateTime(row.getCell(9).getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbGoodsType.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbGoodsType);
+            int insert = tbGoodsTypeMapper.insert(tbGoodsType);
+            count += insert;
+        }
+        return count;
+    }
+}

+ 8 - 3
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsType.java

@@ -1,8 +1,11 @@
 package com.pj.tb_goods_type;
 
 import java.io.Serializable;
+import java.util.Date;
+
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -43,7 +46,7 @@ public class TbGoodsType extends Model<TbGoodsType> implements Serializable {
 	 * 主键 
 	 */
 	@TableId(type = IdType.AUTO)
-	private String id;	
+	private Long id;
 
 	/**
 	 * 名称 
@@ -63,7 +66,8 @@ public class TbGoodsType extends Model<TbGoodsType> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
-	private String createTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date createTime;
 
 	/**
 	 * 创建人编号 
@@ -78,7 +82,8 @@ public class TbGoodsType extends Model<TbGoodsType> implements Serializable {
 	/**
 	 * 更新时间 
 	 */
-	private String updateTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date updateTime;
 
 	/**
 	 * 更新人编号 

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

@@ -1,5 +1,6 @@
 package com.pj.tb_goods_type;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -85,11 +87,47 @@ public class TbGoodsTypeController {
 		int line = SP.publicMapper.updateColumnById(TbGoodsType.TABLE_NAME, "delete_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	
 
-	
-	
-	
+
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("goodsTypeImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbGoodsTypeService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("goodsTypeOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbGoodsTypeService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
+
 
 }

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

@@ -1,13 +1,25 @@
 package com.pj.tb_goods_type;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.tb_goods.TbGoods;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_goods_type -- 商品分类
@@ -21,6 +33,9 @@ public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsTy
 	@Autowired
 	TbGoodsTypeMapper tbGoodsTypeMapper;
 
+	@Autowired
+	private MethodGoodsTypeService methodGoodsTypeService;
+
 	/** 增 */
 	void add(TbGoodsType t){
 		save(t);
@@ -46,6 +61,91 @@ public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsTy
 	List<TbGoodsType> getList(SoMap so) { 
 		return tbGoodsTypeMapper.getList(so);	
 	}
-	
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodGoodsTypeService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		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();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("名称");
+		row.createCell(2).setCellValue("排序");
+		row.createCell(3).setCellValue("编号");
+		row.createCell(12).setCellValue("创建时间");
+		row.createCell(13).setCellValue("创建人编号");
+		row.createCell(14).setCellValue("创建人名称");
+		row.createCell(15).setCellValue("更新时间");
+		row.createCell(16).setCellValue("更新人编号");
+		row.createCell(17).setCellValue("更新人名称");
+		row.createCell(18).setCellValue("删除状态");
+
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getSort() + "").equals("null")? "": selectedList.get(i).getSort() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getNo() + "").equals("null")? "": selectedList.get(i).getNo() + "");
+			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			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() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
+
+
 
 }

+ 65 - 65
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeUtil.java

@@ -1,65 +1,65 @@
-package com.pj.tb_goods_type;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-
-/**
- * 工具类:tb_goods_type -- 商品分类
- * @author qzy 
- *
- */
-@Component
-public class TbGoodsTypeUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbGoodsTypeMapper tbGoodsTypeMapper;
-	@Autowired
-	private void setTbGoodsTypeMapper(TbGoodsTypeMapper tbGoodsTypeMapper) {
-		TbGoodsTypeUtil.tbGoodsTypeMapper = tbGoodsTypeMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbGoodsType 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbGoodsType t) {
-		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
-		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称 
-		AjaxError.throwByIsNull(t.getSort(), "[排序] 不能为空");		// 验证: 排序 
-		AjaxError.throwByIsNull(t.getNo(), "[编号] 不能为空");		// 验证: 编号 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称 
-		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用) 
-	}
-
-	/** 
-	 * 获取一个TbGoodsType (方便复制代码用) [G] 
-	 */ 
-	static TbGoodsType getTbGoodsType() {
-		TbGoodsType t = new TbGoodsType();	// 声明对象 
-		t.setId("");		// 主键 
-		t.setName("");		// 名称 
-		t.setSort(0);		// 排序 
-		t.setNo("");		// 编号 
-		t.setCreateTime("");		// 创建时间 
-		t.setCreateBy("");		// 创建人编号 
-		t.setCreateName("");		// 创建人名称 
-		t.setUpdateTime("");		// 更新时间 
-		t.setUpdateBy("");		// 更新人编号 
-		t.setUpdateName("");		// 更新人名称 
-		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用) 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_goods_type;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//
+///**
+// * 工具类:tb_goods_type -- 商品分类
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbGoodsTypeUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbGoodsTypeMapper tbGoodsTypeMapper;
+//	@Autowired
+//	private void setTbGoodsTypeMapper(TbGoodsTypeMapper tbGoodsTypeMapper) {
+//		TbGoodsTypeUtil.tbGoodsTypeMapper = tbGoodsTypeMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbGoodsType 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbGoodsType t) {
+//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
+//		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称
+//		AjaxError.throwByIsNull(t.getSort(), "[排序] 不能为空");		// 验证: 排序
+//		AjaxError.throwByIsNull(t.getNo(), "[编号] 不能为空");		// 验证: 编号
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称
+//		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用)
+//	}
+//
+//	/**
+//	 * 获取一个TbGoodsType (方便复制代码用) [G]
+//	 */
+//	static TbGoodsType getTbGoodsType() {
+//		TbGoodsType t = new TbGoodsType();	// 声明对象
+//		t.setId("");		// 主键
+//		t.setName("");		// 名称
+//		t.setSort(0);		// 排序
+//		t.setNo("");		// 编号
+//		t.setCreateTime("");		// 创建时间
+//		t.setCreateBy("");		// 创建人编号
+//		t.setCreateName("");		// 创建人名称
+//		t.setUpdateTime("");		// 更新时间
+//		t.setUpdateBy("");		// 更新人编号
+//		t.setUpdateName("");		// 更新人名称
+//		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用)
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 73 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/MethodGoodsUnitsService.java

@@ -0,0 +1,73 @@
+package com.pj.tb_goods_units;
+
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 17 30
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodGoodsUnitsService {
+    
+    @Autowired
+    private TbGoodsUnitsMapper tbGoodsUnitsMapper;
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbGoodsUnits tbGoodsUnits = new TbGoodsUnits();
+            //解析数据
+            if(row.getCell(1) != null)
+                tbGoodsUnits.setUnitsNo(row.getCell(1).getStringCellValue());
+
+            if(row.getCell(1) != null)
+                tbGoodsUnits.setUnits(row.getCell(2).getStringCellValue());
+
+
+//            //公共字段
+//            HSSFCell cell2 = row.getCell(4);
+//            if (cell2 != null && cell2.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell2)) {
+//                tbGoodsUnits.setCreateTime(cell2.getDateCellValue());
+//            }
+//
+//            if(row.getCell(5) != null && !row.getCell(5).toString().trim().equals(""))
+//                tbGoodsUnits.setCreateBy(row.getCell(5).getStringCellValue());
+//
+//            if(row.getCell(6) != null && !row.getCell(6).toString().trim().equals(""))
+//                tbGoodsUnits.setCreateName(row.getCell(6).getStringCellValue());
+//
+//            if(row.getCell(7) != null && !row.getCell(7).toString().trim().equals(""))
+//                tbGoodsUnits.setUpdateBy(row.getCell(7).getStringCellValue());
+//
+//            if(row.getCell(8) != null && !row.getCell(8).toString().trim().equals(""))
+//                tbGoodsUnits.setUpdateName(row.getCell(8).getStringCellValue());
+//
+//            HSSFCell cell3 = row.getCell(9);
+//            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+//                tbGoodsUnits.setUpdateTime(row.getCell(9).getDateCellValue());
+//            }
+//            //删除状态,默认可用
+//            tbGoodsUnits.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbGoodsUnits);
+            int insert = tbGoodsUnitsMapper.insert(tbGoodsUnits);
+            count += insert;
+        }
+        return count;
+    }
+}

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

@@ -1,5 +1,6 @@
 package com.pj.tb_goods_units;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,6 +10,7 @@ import com.pj.utils.sg.*;
 import com.pj.project4sp.SP;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -73,13 +75,47 @@ public class TbGoodsUnitsController {
 		List<TbGoodsUnits> list = tbGoodsUnitsService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
-	
-	
-	
-	
 
-	
-	
-	
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("goodsUnitsImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbGoodsUnitsService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("goodsUnitsOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbGoodsUnitsService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
+
+
 
 }

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

@@ -1,12 +1,24 @@
 package com.pj.tb_goods_units;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.tb_goods_type.TbGoodsType;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_goods_units -- 商品单位
@@ -20,6 +32,9 @@ public class TbGoodsUnitsService extends ServiceImpl<TbGoodsUnitsMapper, TbGoods
 	@Autowired
 	TbGoodsUnitsMapper tbGoodsUnitsMapper;
 
+	@Autowired
+	private MethodGoodsUnitsService methodGoodsUnitsService;
+
 	/** 增 */
 	void add(TbGoodsUnits t){
 		save(t);
@@ -45,6 +60,76 @@ public class TbGoodsUnitsService extends ServiceImpl<TbGoodsUnitsMapper, TbGoods
 	List<TbGoodsUnits> getList(SoMap so) { 
 		return tbGoodsUnitsMapper.getList(so);	
 	}
-	
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodGoodsUnitsService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		List<TbGoodsUnits> selectedList = tbGoodsUnitsMapper.selectList(new LambdaQueryWrapper<TbGoodsUnits>().eq(StringUtils.isNoneBlank(keyword), TbGoodsUnits::getUnits, keyword));
+		if(selectedList.size() == 0)return "没有可导出的数据。";
+		//建立excel对象封装数据
+		HSSFWorkbook workbook = new HSSFWorkbook();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("食品单位编号");
+		row.createCell(2).setCellValue("管理商品的单位");
+
+
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getUnitsNo() + "").equals("null")? "": selectedList.get(i).getUnitsNo() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getUnits() + "").equals("null")? "": selectedList.get(i).getUnits() + "");
+					}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
+
+
 
 }

+ 49 - 49
sp-service/level-one-server/src/main/java/com/pj/tb_goods_units/TbGoodsUnitsUtil.java

@@ -1,49 +1,49 @@
-package com.pj.tb_goods_units;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-
-/**
- * 工具类:tb_goods_units -- 商品单位
- * @author qzy 
- *
- */
-@Component
-public class TbGoodsUnitsUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbGoodsUnitsMapper tbGoodsUnitsMapper;
-	@Autowired
-	private void setTbGoodsUnitsMapper(TbGoodsUnitsMapper tbGoodsUnitsMapper) {
-		TbGoodsUnitsUtil.tbGoodsUnitsMapper = tbGoodsUnitsMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbGoodsUnits 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbGoodsUnits t) {
-		AjaxError.throwByIsNull(t.getId(), "[商品主键] 不能为空");		// 验证: 商品主键 
-		AjaxError.throwByIsNull(t.getUnitsNo(), "[商品单位编号] 不能为空");		// 验证: 商品单位编号 
-		AjaxError.throwByIsNull(t.getUnits(), "[管理商品的单位,比如吨、kg、个、柜;主要字段,名称,编号] 不能为空");		// 验证: 管理商品的单位,比如吨、kg、个、柜;主要字段,名称,编号 
-	}
-
-	/** 
-	 * 获取一个TbGoodsUnits (方便复制代码用) [G] 
-	 */ 
-	static TbGoodsUnits getTbGoodsUnits() {
-		TbGoodsUnits t = new TbGoodsUnits();	// 声明对象 
-		t.setId(0L);		// 商品主键 
-		t.setUnitsNo("");		// 商品单位编号 
-		t.setUnits("");		// 管理商品的单位,比如吨、kg、个、柜;主要字段,名称,编号 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_goods_units;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//
+///**
+// * 工具类:tb_goods_units -- 商品单位
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbGoodsUnitsUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbGoodsUnitsMapper tbGoodsUnitsMapper;
+//	@Autowired
+//	private void setTbGoodsUnitsMapper(TbGoodsUnitsMapper tbGoodsUnitsMapper) {
+//		TbGoodsUnitsUtil.tbGoodsUnitsMapper = tbGoodsUnitsMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbGoodsUnits 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbGoodsUnits t) {
+//		AjaxError.throwByIsNull(t.getId(), "[商品主键] 不能为空");		// 验证: 商品主键
+//		AjaxError.throwByIsNull(t.getUnitsNo(), "[商品单位编号] 不能为空");		// 验证: 商品单位编号
+//		AjaxError.throwByIsNull(t.getUnits(), "[管理商品的单位,比如吨、kg、个、柜;主要字段,名称,编号] 不能为空");		// 验证: 管理商品的单位,比如吨、kg、个、柜;主要字段,名称,编号
+//	}
+//
+//	/**
+//	 * 获取一个TbGoodsUnits (方便复制代码用) [G]
+//	 */
+//	static TbGoodsUnits getTbGoodsUnits() {
+//		TbGoodsUnits t = new TbGoodsUnits();	// 声明对象
+//		t.setId(0L);		// 商品主键
+//		t.setUnitsNo("");		// 商品单位编号
+//		t.setUnits("");		// 管理商品的单位,比如吨、kg、个、柜;主要字段,名称,编号
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 102 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_group/MethodGroupService.java

@@ -0,0 +1,102 @@
+package com.pj.tb_group;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 17 38
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodGroupService {
+    
+    @Autowired
+    private TbGroupMapper tbGroupMapper;
+
+
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbGroup tbGroup = new TbGroup();
+            //解析数据
+            if(row.getCell(1) != null && !row.getCell(1).toString().trim().equals(""))
+                tbGroup.setAddressIds(row.getCell(1).getStringCellValue());
+
+            if(row.getCell(2) != null && !row.getCell(2).toString().trim().equals(""))
+                tbGroup.setAddress(row.getCell(2).getStringCellValue());
+
+            if(row.getCell(3) != null && !row.getCell(3).toString().trim().equals(""))
+                tbGroup.setDetailAddress(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(4) != null && !row.getCell(4).toString().trim().equals(""))
+                tbGroup.setName(row.getCell(4).getStringCellValue());
+
+
+            HSSFCell cell6 = row.getCell(5);
+            if (cell6 != null && (cell6.getCellType() == CellType.NUMERIC || cell6.getCellType() == CellType.FORMULA))
+                tbGroup.setLeaderId((long) cell6.getNumericCellValue());
+
+            if(row.getCell(6) != null && !row.getCell(6).toString().trim().equals(""))
+                tbGroup.setLeaderName(row.getCell(6).getStringCellValue());
+
+            if(row.getCell(7) != null && !row.getCell(7).toString().trim().equals(""))
+                tbGroup.setLeaderPhone(row.getCell(7).getStringCellValue());
+
+            if(row.getCell(8) != null && !row.getCell(8).toString().trim().equals(""))
+                tbGroup.setCode(row.getCell(8).getStringCellValue()   );
+
+            HSSFCell cell9 = row.getCell(9);
+            if (cell9 != null && (cell9.getCellType() == CellType.NUMERIC || cell9.getCellType() == CellType.FORMULA))
+                tbGroup.setLeftPrice(cell9.getNumericCellValue());
+
+
+          //公共字段
+            HSSFCell cell4 = row.getCell(10);
+            if (cell4 != null && cell4.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell4)) {
+                tbGroup.setCreateTime(cell4.getDateCellValue());
+            }
+
+            if(row.getCell(11) != null && !row.getCell(11).toString().trim().equals(""))
+                tbGroup.setCreateBy(row.getCell(11).getStringCellValue());
+
+            if(row.getCell(12) != null && !row.getCell(12).toString().trim().equals(""))
+                tbGroup.setCreateName(row.getCell(12).getStringCellValue());
+
+            if(row.getCell(13) != null && !row.getCell(13).toString().trim().equals(""))
+                tbGroup.setUpdateBy(row.getCell(13).getStringCellValue());
+
+            if(row.getCell(14) != null && !row.getCell(14).toString().trim().equals(""))
+                tbGroup.setUpdateName(row.getCell(14).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(15);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbGroup.setUpdateTime(cell3.getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbGroup.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbGroup);
+            int insert = tbGroupMapper.insert(tbGroup);
+            count += insert;
+        }
+        return count;
+    }
+}

+ 8 - 3
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroup.java

@@ -1,8 +1,11 @@
 package com.pj.tb_group;
 
 import java.io.Serializable;
+import java.util.Date;
+
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -43,7 +46,7 @@ public class TbGroup extends Model<TbGroup> implements Serializable {
 	 *  
 	 */
 	@TableId(type = IdType.AUTO)
-	private String id;	
+	private Long id;
 
 	/**
 	 *  
@@ -93,7 +96,8 @@ public class TbGroup extends Model<TbGroup> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
-	private String createTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date createTime;
 
 	/**
 	 * 创建人编号 
@@ -108,7 +112,8 @@ public class TbGroup extends Model<TbGroup> implements Serializable {
 	/**
 	 * 更新时间 
 	 */
-	private String updateTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date updateTime;
 
 	/**
 	 * 更新人编号 

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

@@ -1,5 +1,6 @@
 package com.pj.tb_group;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -85,11 +87,47 @@ public class TbGroupController {
 		int line = SP.publicMapper.updateColumnById(TbGroup.TABLE_NAME, "delete_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	
 
-	
-	
-	
+
+
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("groupImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbGroupService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("groupOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbGroupService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
 
 }

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

@@ -1,13 +1,25 @@
 package com.pj.tb_group;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.tb_goods_transit.TbGoodsTransit;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_group -- 互助组
@@ -21,6 +33,8 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
 	@Autowired
 	TbGroupMapper tbGroupMapper;
 
+	@Autowired
+	private MethodGroupService methodGroupService;
 	/** 增 */
 	void add(TbGroup t){
 		save(t);
@@ -46,6 +60,106 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
 	List<TbGroup> getList(SoMap so) { 
 		return tbGroupMapper.getList(so);	
 	}
-	
+
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodGroupService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		List<TbGroup> selectedList = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(StringUtils.isNoneBlank(keyword), TbGroup::getName, keyword));
+		if(selectedList.size() == 0)return "没有可导出的数据。";
+		//建立excel对象封装数据
+		HSSFWorkbook workbook = new HSSFWorkbook();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("IDs");
+		row.createCell(2).setCellValue("地址");
+		row.createCell(3).setCellValue("详细地址");
+		row.createCell(4).setCellValue("组名称");
+		row.createCell(5).setCellValue("组长ID");
+		row.createCell(6).setCellValue("组长名");
+		row.createCell(7).setCellValue("组长电话");
+		row.createCell(8).setCellValue("编码");
+		row.createCell(9).setCellValue("当天该组剩余额度");
+
+		row.createCell(14).setCellValue("创建时间");
+		row.createCell(15).setCellValue("创建人编号");
+		row.createCell(16).setCellValue("创建人名称");
+		row.createCell(17).setCellValue("更新时间");
+		row.createCell(18).setCellValue("更新人编号");
+		row.createCell(19).setCellValue("更新人名称");
+		row.createCell(20).setCellValue("删除状态");
+
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null")? "": selectedList.get(i).getDetailAddress() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getLeaderId() + "").equals("null")? "": selectedList.get(i).getLeaderId() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getLeaderName() + "").equals("null")? "": selectedList.get(i).getLeaderName() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getLeaderPhone() + "").equals("null")? "": selectedList.get(i).getLeaderPhone() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getCode() + "" ).equals("null")? "": selectedList.get(i).getCode() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getLeftPrice() + "").equals("null")? "": selectedList.get(i).getLeftPrice() + "");
+
+			//公共字段
+			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			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() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
+
 
 }

+ 77 - 77
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupUtil.java

@@ -1,77 +1,77 @@
-package com.pj.tb_group;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-
-/**
- * 工具类:tb_group -- 互助组
- * @author qzy 
- *
- */
-@Component
-public class TbGroupUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbGroupMapper tbGroupMapper;
-	@Autowired
-	private void setTbGroupMapper(TbGroupMapper tbGroupMapper) {
-		TbGroupUtil.tbGroupMapper = tbGroupMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbGroup 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbGroup t) {
-		AjaxError.throwByIsNull(t.getId(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getAddressIds(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getAddress(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getDetailAddress(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称 
-		AjaxError.throwByIsNull(t.getLeaderId(), "[组长ID] 不能为空");		// 验证: 组长ID 
-		AjaxError.throwByIsNull(t.getLeaderName(), "[组长名] 不能为空");		// 验证: 组长名 
-		AjaxError.throwByIsNull(t.getLeaderPhone(), "[组长电话] 不能为空");		// 验证: 组长电话 
-		AjaxError.throwByIsNull(t.getCode(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getLeftPrice(), "[当天该组剩余额度] 不能为空");		// 验证: 当天该组剩余额度 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称 
-		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用) 
-	}
-
-	/** 
-	 * 获取一个TbGroup (方便复制代码用) [G] 
-	 */ 
-	static TbGroup getTbGroup() {
-		TbGroup t = new TbGroup();	// 声明对象 
-		t.setId("");		//  
-		t.setAddressIds("");		//  
-		t.setAddress("");		//  
-		t.setDetailAddress("");		//  
-		t.setName("");		// 名称 
-		t.setLeaderId(0L);		// 组长ID 
-		t.setLeaderName("");		// 组长名 
-		t.setLeaderPhone("");		// 组长电话 
-		t.setCode("");		//  
-		t.setLeftPrice(0.0);		// 当天该组剩余额度 
-		t.setCreateTime("");		// 创建时间 
-		t.setCreateBy("");		// 创建人编号 
-		t.setCreateName("");		// 创建人名称 
-		t.setUpdateTime("");		// 更新时间 
-		t.setUpdateBy("");		// 更新人编号 
-		t.setUpdateName("");		// 更新人名称 
-		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用) 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_group;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//
+///**
+// * 工具类:tb_group -- 互助组
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbGroupUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbGroupMapper tbGroupMapper;
+//	@Autowired
+//	private void setTbGroupMapper(TbGroupMapper tbGroupMapper) {
+//		TbGroupUtil.tbGroupMapper = tbGroupMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbGroup 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbGroup t) {
+//		AjaxError.throwByIsNull(t.getId(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getAddressIds(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getAddress(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getDetailAddress(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称
+//		AjaxError.throwByIsNull(t.getLeaderId(), "[组长ID] 不能为空");		// 验证: 组长ID
+//		AjaxError.throwByIsNull(t.getLeaderName(), "[组长名] 不能为空");		// 验证: 组长名
+//		AjaxError.throwByIsNull(t.getLeaderPhone(), "[组长电话] 不能为空");		// 验证: 组长电话
+//		AjaxError.throwByIsNull(t.getCode(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getLeftPrice(), "[当天该组剩余额度] 不能为空");		// 验证: 当天该组剩余额度
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称
+//		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用)
+//	}
+//
+//	/**
+//	 * 获取一个TbGroup (方便复制代码用) [G]
+//	 */
+//	static TbGroup getTbGroup() {
+//		TbGroup t = new TbGroup();	// 声明对象
+//		t.setId("");		//
+//		t.setAddressIds("");		//
+//		t.setAddress("");		//
+//		t.setDetailAddress("");		//
+//		t.setName("");		// 名称
+//		t.setLeaderId(0L);		// 组长ID
+//		t.setLeaderName("");		// 组长名
+//		t.setLeaderPhone("");		// 组长电话
+//		t.setCode("");		//
+//		t.setLeftPrice(0.0);		// 当天该组剩余额度
+//		t.setCreateTime("");		// 创建时间
+//		t.setCreateBy("");		// 创建人编号
+//		t.setCreateName("");		// 创建人名称
+//		t.setUpdateTime("");		// 更新时间
+//		t.setUpdateBy("");		// 更新人编号
+//		t.setUpdateName("");		// 更新人名称
+//		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用)
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 171 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_people/MethodPeopleService.java

@@ -0,0 +1,171 @@
+package com.pj.tb_people;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 17 52
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodPeopleService {
+    
+    @Autowired
+    private TbPeopleMapper tbPeopleMapper;
+
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbPeople tbPeople = new TbPeople();
+            //解析数据
+            if(row.getCell(1) != null)
+                tbPeople.setName(row.getCell(1).getStringCellValue());
+
+            if(row.getCell(2) != null)
+                tbPeople.setCode(row.getCell(2).getStringCellValue());
+
+            HSSFCell cell8 = row.getCell(3);
+            if (cell8 != null && (cell8.getCellType() == CellType.NUMERIC || cell8.getCellType() == CellType.FORMULA))
+                tbPeople.setSex((int) cell8.getNumericCellValue());
+
+            HSSFCell cell4 = row.getCell(4);
+            if (cell4 != null && (cell4.getCellType() == CellType.NUMERIC || cell4.getCellType() == CellType.FORMULA))
+                tbPeople.setAge((int) cell4.getNumericCellValue());
+
+            if(row.getCell(5) != null)
+                tbPeople.setIdCard(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(6) != null)
+                tbPeople.setIdCardImg(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(7) != null)
+                tbPeople.setPhone(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(8) != null)
+                tbPeople.setBankNo(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(9) != null)
+                tbPeople.setBankCode(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(10) != null)
+                tbPeople.setBankName(row.getCell(3).getStringCellValue());
+
+            HSSFCell cell11 = row.getCell(11);
+            if (cell11 != null && (cell11.getCellType() == CellType.NUMERIC || cell11.getCellType() == CellType.FORMULA))
+                tbPeople.setGroupId((long) cell11.getNumericCellValue());
+
+            if(row.getCell(12) != null)
+                tbPeople.setGroupName(row.getCell(3).getStringCellValue());
+
+            HSSFCell cell13 = row.getCell(13);
+            if (cell13 != null && (cell13.getCellType() == CellType.NUMERIC || cell13.getCellType() == CellType.FORMULA))
+                tbPeople.setStatus((int) cell13.getNumericCellValue());
+
+            HSSFCell cell14 = row.getCell(14);
+            if (cell14 != null && (cell14.getCellType() == CellType.NUMERIC || cell14.getCellType() == CellType.FORMULA))
+                tbPeople.setRole((int) cell14.getNumericCellValue());
+
+            HSSFCell cell15 = row.getCell(15);
+            if (cell15 != null && (cell15.getCellType() == CellType.NUMERIC || cell15.getCellType() == CellType.FORMULA))
+                tbPeople.setLng((double) cell15.getNumericCellValue());
+
+            HSSFCell cell16 = row.getCell(16);
+            if (cell16 != null && (cell16.getCellType() == CellType.NUMERIC || cell16.getCellType() == CellType.FORMULA))
+                tbPeople.setLat((double) cell16.getNumericCellValue());
+
+            if(row.getCell(17) != null)
+                tbPeople.setLastLocation(row.getCell(17).getStringCellValue());
+
+            if(row.getCell(18) != null)
+                tbPeople.setAddress(row.getCell(18).getStringCellValue());
+
+
+            if(row.getCell(19) != null)
+                tbPeople.setAddressIds(row.getCell(19).getStringCellValue());
+
+
+            if(row.getCell(20) != null)
+                tbPeople.setDetailAddress(row.getCell(20).getStringCellValue());
+
+
+            HSSFCell cell21 = row.getCell(21);
+            if (cell21 != null && (cell21.getCellType() == CellType.NUMERIC || cell21.getCellType() == CellType.FORMULA))
+                tbPeople.setIsLock((int) cell21.getNumericCellValue());
+
+            HSSFCell cell22 = row.getCell(22);
+            if (cell22 != null && (cell22.getCellType() == CellType.NUMERIC || cell22.getCellType() == CellType.FORMULA))
+                tbPeople.setLeftPrice((double) cell22.getNumericCellValue());
+
+            HSSFCell cell23 = row.getCell(23);
+            if (cell23 != null && (cell23.getCellType() == CellType.NUMERIC || cell23.getCellType() == CellType.FORMULA))
+                tbPeople.setJudgeStatus((int) cell23.getNumericCellValue());
+
+            if(row.getCell(24) != null)
+                tbPeople.setJudgeContent(row.getCell(24).getStringCellValue());
+
+
+            HSSFCell cel25 = row.getCell(25);
+            if (cel25 != null && cel25.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cel25)) {
+                tbPeople.setRegisterTime(cel25.getDateCellValue());
+            }
+
+            HSSFCell cell26 = row.getCell(26);
+            if (cell26 != null && cell26.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell26)) {
+                tbPeople.setJudgeTime(cell26.getDateCellValue());
+            }
+
+            if(row.getCell(27) != null)
+                tbPeople.setPersonId(row.getCell(27).getStringCellValue());
+
+
+            //公共字段
+            HSSFCell cell2 = row.getCell(28);
+            if (cell2 != null && cell2.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell2)) {
+                tbPeople.setCreateTime(cell2.getDateCellValue());
+            }
+
+            if(row.getCell(29) != null && !row.getCell(29).toString().trim().equals(""))
+                tbPeople.setCreateBy(row.getCell(29).getStringCellValue());
+
+            if(row.getCell(30) != null && !row.getCell(30).toString().trim().equals(""))
+                tbPeople.setCreateName(row.getCell(30).getStringCellValue());
+
+            if(row.getCell(31) != null && !row.getCell(31).toString().trim().equals(""))
+                tbPeople.setUpdateBy(row.getCell(31).getStringCellValue());
+
+            if(row.getCell(32) != null && !row.getCell(32).toString().trim().equals(""))
+                tbPeople.setUpdateName(row.getCell(32).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(33);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbPeople.setUpdateTime(cell3.getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbPeople.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbPeople);
+            int insert = tbPeopleMapper.insert(tbPeople);
+            count += insert;
+        }
+        return count;
+    }
+    
+}

+ 18 - 11
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeople.java

@@ -1,8 +1,11 @@
 package com.pj.tb_people;
 
 import java.io.Serializable;
+import java.util.Date;
+
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -43,7 +46,7 @@ public class TbPeople extends Model<TbPeople> implements Serializable {
 	 * 主键 
 	 */
 	@TableId(type = IdType.AUTO)
-	private String id;	
+	private Long id;
 
 	/**
 	 * 姓名 
@@ -58,7 +61,7 @@ public class TbPeople extends Model<TbPeople> implements Serializable {
 	/**
 	 * 性别(1=男,2=女) 
 	 */
-	private String sex;	
+	private Integer sex;
 
 	/**
 	 * 年龄 
@@ -108,12 +111,12 @@ public class TbPeople extends Model<TbPeople> implements Serializable {
 	/**
 	 * 是否可用(0=否,1=是) 
 	 */
-	private String status;	
+	private Integer status;
 
 	/**
 	 * 角色(1=普通边民,2=兼组长) 
 	 */
-	private String role;	
+	private Integer role;
 
 	/**
 	 * 经度 
@@ -148,7 +151,7 @@ public class TbPeople extends Model<TbPeople> implements Serializable {
 	/**
 	 * 是否锁定 
 	 */
-	private String isLock;	
+	private Integer isLock;
 
 	/**
 	 * 当天剩余额度 
@@ -158,7 +161,7 @@ public class TbPeople extends Model<TbPeople> implements Serializable {
 	/**
 	 *  
 	 */
-	private String judgeStatus;	
+	private Integer judgeStatus;
 
 	/**
 	 *  
@@ -166,14 +169,16 @@ public class TbPeople extends Model<TbPeople> implements Serializable {
 	private String judgeContent;	
 
 	/**
-	 *  
+	 *  注册时间
 	 */
-	private String registerTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date registerTime;
 
 	/**
 	 *  
 	 */
-	private String judgeTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date judgeTime;
 
 	/**
 	 *  
@@ -183,7 +188,8 @@ public class TbPeople extends Model<TbPeople> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
-	private String createTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date createTime;
 
 	/**
 	 * 创建人编号 
@@ -198,7 +204,8 @@ public class TbPeople extends Model<TbPeople> implements Serializable {
 	/**
 	 * 更新时间 
 	 */
-	private String updateTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date updateTime;
 
 	/**
 	 * 更新人编号 

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

@@ -1,5 +1,6 @@
 package com.pj.tb_people;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -85,11 +87,47 @@ public class TbPeopleController {
 		int line = SP.publicMapper.updateColumnById(TbPeople.TABLE_NAME, "delete_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	
 
-	
-	
-	
+
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("peopleImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbPeopleService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("peopleOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbPeopleService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
+
 
 }

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

@@ -1,13 +1,25 @@
 package com.pj.tb_people;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.tb_goods_transit.TbGoodsTransit;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_people -- 边民
@@ -21,6 +33,9 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 	@Autowired
 	TbPeopleMapper tbPeopleMapper;
 
+	@Autowired
+	private MethodPeopleService methodPeopleService;
+
 	/** 增 */
 	void add(TbPeople t){
 		save(t);
@@ -46,6 +61,136 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 	List<TbPeople> getList(SoMap so) { 
 		return tbPeopleMapper.getList(so);	
 	}
-	
 
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodPeopleService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		List<TbPeople> selectedList = tbPeopleMapper.selectList(new LambdaQueryWrapper<TbPeople>().eq(StringUtils.isNoneBlank(keyword), TbPeople::getName, keyword));
+		if(selectedList.size() == 0)return "没有可导出的数据。";
+		//建立excel对象封装数据
+		HSSFWorkbook workbook = new HSSFWorkbook();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("姓名");
+		row.createCell(2).setCellValue("边民号");
+		row.createCell(3).setCellValue("性别");
+		row.createCell(4).setCellValue("年龄");
+		row.createCell(5).setCellValue("身份证");
+		row.createCell(6).setCellValue("身份证复印件");
+		row.createCell(7).setCellValue("手机号码");
+		row.createCell(8).setCellValue("银行编号");
+		row.createCell(9).setCellValue("银行卡号");
+		row.createCell(10).setCellValue("银行名称");
+		row.createCell(11).setCellValue("所属互助组");
+		row.createCell(12).setCellValue("互助组名称");
+		row.createCell(13).setCellValue("是否可用");
+		row.createCell(14).setCellValue("角色");
+		row.createCell(15).setCellValue("经度");
+		row.createCell(16).setCellValue("维度");
+		row.createCell(17).setCellValue("最后一次下单定位");
+		row.createCell(18).setCellValue("联系地址");
+		row.createCell(19).setCellValue("地址ID");
+		row.createCell(20).setCellValue("详细地址");
+		row.createCell(21).setCellValue("是否锁定");
+		row.createCell(22).setCellValue("当天剩余额度");
+		row.createCell(23).setCellValue("judge_status");
+		row.createCell(24).setCellValue("judge_content");
+		row.createCell(25).setCellValue("注册时间");
+		row.createCell(26).setCellValue("judge_time");
+		row.createCell(27).setCellValue("person_id");
+		row.createCell(28).setCellValue("创建时间");
+		row.createCell(29).setCellValue("创建人编号");
+		row.createCell(30).setCellValue("创建人名称");
+		row.createCell(31).setCellValue("更新时间");
+		row.createCell(32).setCellValue("更新人编号");
+		row.createCell(33).setCellValue("更新人名称");
+		row.createCell(34).setCellValue("删除状态");
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getCode() + "").equals("null")? "": selectedList.get(i).getCode() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getSex() + "").equals("null")? "": selectedList.get(i).getSex() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getAge() + "").equals("null")? "": selectedList.get(i).getAge() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getIdCard() + "").equals("null")? "": selectedList.get(i).getIdCard() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getIdCardImg() + "").equals("null")? "": selectedList.get(i).getIdCardImg() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getPhone() + "").equals("null")? "": selectedList.get(i).getPhone() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getBankNo() + "" ).equals("null")? "": selectedList.get(i).getBankNo() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getBankCode() + "").equals("null")? "": selectedList.get(i).getBankCode() + "");
+			sheetRow.createCell(10).setCellValue((selectedList.get(i).getBankName() + "").equals("null")? "": selectedList.get(i).getBankName() + "");
+			sheetRow.createCell(11).setCellValue((selectedList.get(i).getGroupId() + "").equals("null")? "": selectedList.get(i).getGroupId() + "");
+			sheetRow.createCell(12).setCellValue((selectedList.get(i).getGroupName() + "").equals("null")? "": selectedList.get(i).getGroupName() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getStatus() + "").equals("null")? "": selectedList.get(i).getStatus() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getRole() + "").equals("null")? "": selectedList.get(i).getRole() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getLng() + "").equals("null")? "": selectedList.get(i).getLng() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getLat() + "").equals("null")? "": selectedList.get(i).getLat() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getLastLocation() + "").equals("null")? "": selectedList.get(i).getLastLocation() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null")? "": selectedList.get(i).getDetailAddress() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getIsLock() + "").equals("null")? "": selectedList.get(i).getIsLock() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getLeftPrice() + "").equals("null")? "": selectedList.get(i).getLeftPrice() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getJudgeStatus() + "").equals("null")? "": selectedList.get(i).getJudgeStatus() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getJudgeContent() + "").equals("null")? "": selectedList.get(i).getJudgeContent() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getRegisterTime() + "").equals("null")? "": selectedList.get(i).getRegisterTime() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getJudgeTime() + "").equals("null")? "": selectedList.get(i).getJudgeTime() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getPersonId() + "").equals("null")? "": selectedList.get(i).getPersonId() + "");
+			//公共字段
+			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			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() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
 }

+ 113 - 113
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleUtil.java

@@ -1,113 +1,113 @@
-package com.pj.tb_people;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-
-/**
- * 工具类:tb_people -- 边民
- * @author qzy 
- *
- */
-@Component
-public class TbPeopleUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbPeopleMapper tbPeopleMapper;
-	@Autowired
-	private void setTbPeopleMapper(TbPeopleMapper tbPeopleMapper) {
-		TbPeopleUtil.tbPeopleMapper = tbPeopleMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbPeople 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbPeople t) {
-		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
-		AjaxError.throwByIsNull(t.getName(), "[姓名] 不能为空");		// 验证: 姓名 
-		AjaxError.throwByIsNull(t.getCode(), "[边民号] 不能为空");		// 验证: 边民号 
-		AjaxError.throwByIsNull(t.getSex(), "[性别] 不能为空");		// 验证: 性别(1=男,2=女) 
-		AjaxError.throwByIsNull(t.getAge(), "[年龄] 不能为空");		// 验证: 年龄 
-		AjaxError.throwByIsNull(t.getIdCard(), "[身份证] 不能为空");		// 验证: 身份证 
-		AjaxError.throwByIsNull(t.getIdCardImg(), "[身份证复印件] 不能为空");		// 验证: 身份证复印件 
-		AjaxError.throwByIsNull(t.getPhone(), "[手机号码] 不能为空");		// 验证: 手机号码 
-		AjaxError.throwByIsNull(t.getBankNo(), "[银行编号] 不能为空");		// 验证: 银行编号 
-		AjaxError.throwByIsNull(t.getBankCode(), "[银行卡号] 不能为空");		// 验证: 银行卡号 
-		AjaxError.throwByIsNull(t.getBankName(), "[银行名称] 不能为空");		// 验证: 银行名称 
-		AjaxError.throwByIsNull(t.getGroupId(), "[所属互助组] 不能为空");		// 验证: 所属互助组(1=测试组) 
-		AjaxError.throwByIsNull(t.getGroupName(), "[互助组名称] 不能为空");		// 验证: 互助组名称 
-		AjaxError.throwByIsNull(t.getStatus(), "[是否可用] 不能为空");		// 验证: 是否可用(0=否,1=是) 
-		AjaxError.throwByIsNull(t.getRole(), "[角色] 不能为空");		// 验证: 角色(1=普通边民,2=兼组长) 
-		AjaxError.throwByIsNull(t.getLng(), "[经度] 不能为空");		// 验证: 经度 
-		AjaxError.throwByIsNull(t.getLat(), "[纬度] 不能为空");		// 验证: 纬度 
-		AjaxError.throwByIsNull(t.getLastLocation(), "[最后一次下单定位] 不能为空");		// 验证: 最后一次下单定位 
-		AjaxError.throwByIsNull(t.getAddress(), "[联系地址] 不能为空");		// 验证: 联系地址 
-		AjaxError.throwByIsNull(t.getAddressIds(), "[地址ID] 不能为空");		// 验证: 地址ID 
-		AjaxError.throwByIsNull(t.getDetailAddress(), "[详细地址] 不能为空");		// 验证: 详细地址 
-		AjaxError.throwByIsNull(t.getIsLock(), "[是否锁定] 不能为空");		// 验证: 是否锁定 
-		AjaxError.throwByIsNull(t.getLeftPrice(), "[当天剩余额度] 不能为空");		// 验证: 当天剩余额度 
-		AjaxError.throwByIsNull(t.getJudgeStatus(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getJudgeContent(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getRegisterTime(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getJudgeTime(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getPersonId(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称 
-		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用) 
-	}
-
-	/** 
-	 * 获取一个TbPeople (方便复制代码用) [G] 
-	 */ 
-	static TbPeople getTbPeople() {
-		TbPeople t = new TbPeople();	// 声明对象 
-		t.setId("");		// 主键 
-		t.setName("");		// 姓名 
-		t.setCode("");		// 边民号 
-		t.setSex("");		// 性别(1=男,2=女) 
-		t.setAge(0);		// 年龄 
-		t.setIdCard("");		// 身份证 
-		t.setIdCardImg("");		// 身份证复印件 
-		t.setPhone("");		// 手机号码 
-		t.setBankNo("");		// 银行编号 
-		t.setBankCode("");		// 银行卡号 
-		t.setBankName("");		// 银行名称 
-		t.setGroupId(0L);		// 所属互助组(1=测试组) 
-		t.setGroupName("");		// 互助组名称 
-		t.setStatus("");		// 是否可用(0=否,1=是) 
-		t.setRole("");		// 角色(1=普通边民,2=兼组长) 
-		t.setLng(0.0);		// 经度 
-		t.setLat(0.0);		// 纬度 
-		t.setLastLocation("");		// 最后一次下单定位 
-		t.setAddress("");		// 联系地址 
-		t.setAddressIds("");		// 地址ID 
-		t.setDetailAddress("");		// 详细地址 
-		t.setIsLock("");		// 是否锁定 
-		t.setLeftPrice(0.0);		// 当天剩余额度 
-		t.setJudgeStatus("");		//  
-		t.setJudgeContent("");		//  
-		t.setRegisterTime("");		//  
-		t.setJudgeTime("");		//  
-		t.setPersonId("");		//  
-		t.setCreateTime("");		// 创建时间 
-		t.setCreateBy("");		// 创建人编号 
-		t.setCreateName("");		// 创建人名称 
-		t.setUpdateTime("");		// 更新时间 
-		t.setUpdateBy("");		// 更新人编号 
-		t.setUpdateName("");		// 更新人名称 
-		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用) 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_people;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//
+///**
+// * 工具类:tb_people -- 边民
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbPeopleUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbPeopleMapper tbPeopleMapper;
+//	@Autowired
+//	private void setTbPeopleMapper(TbPeopleMapper tbPeopleMapper) {
+//		TbPeopleUtil.tbPeopleMapper = tbPeopleMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbPeople 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbPeople t) {
+//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
+//		AjaxError.throwByIsNull(t.getName(), "[姓名] 不能为空");		// 验证: 姓名
+//		AjaxError.throwByIsNull(t.getCode(), "[边民号] 不能为空");		// 验证: 边民号
+//		AjaxError.throwByIsNull(t.getSex(), "[性别] 不能为空");		// 验证: 性别(1=男,2=女)
+//		AjaxError.throwByIsNull(t.getAge(), "[年龄] 不能为空");		// 验证: 年龄
+//		AjaxError.throwByIsNull(t.getIdCard(), "[身份证] 不能为空");		// 验证: 身份证
+//		AjaxError.throwByIsNull(t.getIdCardImg(), "[身份证复印件] 不能为空");		// 验证: 身份证复印件
+//		AjaxError.throwByIsNull(t.getPhone(), "[手机号码] 不能为空");		// 验证: 手机号码
+//		AjaxError.throwByIsNull(t.getBankNo(), "[银行编号] 不能为空");		// 验证: 银行编号
+//		AjaxError.throwByIsNull(t.getBankCode(), "[银行卡号] 不能为空");		// 验证: 银行卡号
+//		AjaxError.throwByIsNull(t.getBankName(), "[银行名称] 不能为空");		// 验证: 银行名称
+//		AjaxError.throwByIsNull(t.getGroupId(), "[所属互助组] 不能为空");		// 验证: 所属互助组(1=测试组)
+//		AjaxError.throwByIsNull(t.getGroupName(), "[互助组名称] 不能为空");		// 验证: 互助组名称
+//		AjaxError.throwByIsNull(t.getStatus(), "[是否可用] 不能为空");		// 验证: 是否可用(0=否,1=是)
+//		AjaxError.throwByIsNull(t.getRole(), "[角色] 不能为空");		// 验证: 角色(1=普通边民,2=兼组长)
+//		AjaxError.throwByIsNull(t.getLng(), "[经度] 不能为空");		// 验证: 经度
+//		AjaxError.throwByIsNull(t.getLat(), "[纬度] 不能为空");		// 验证: 纬度
+//		AjaxError.throwByIsNull(t.getLastLocation(), "[最后一次下单定位] 不能为空");		// 验证: 最后一次下单定位
+//		AjaxError.throwByIsNull(t.getAddress(), "[联系地址] 不能为空");		// 验证: 联系地址
+//		AjaxError.throwByIsNull(t.getAddressIds(), "[地址ID] 不能为空");		// 验证: 地址ID
+//		AjaxError.throwByIsNull(t.getDetailAddress(), "[详细地址] 不能为空");		// 验证: 详细地址
+//		AjaxError.throwByIsNull(t.getIsLock(), "[是否锁定] 不能为空");		// 验证: 是否锁定
+//		AjaxError.throwByIsNull(t.getLeftPrice(), "[当天剩余额度] 不能为空");		// 验证: 当天剩余额度
+//		AjaxError.throwByIsNull(t.getJudgeStatus(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getJudgeContent(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getRegisterTime(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getJudgeTime(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getPersonId(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称
+//		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用)
+//	}
+//
+//	/**
+//	 * 获取一个TbPeople (方便复制代码用) [G]
+//	 */
+//	static TbPeople getTbPeople() {
+//		TbPeople t = new TbPeople();	// 声明对象
+//		t.setId("");		// 主键
+//		t.setName("");		// 姓名
+//		t.setCode("");		// 边民号
+//		t.setSex("");		// 性别(1=男,2=女)
+//		t.setAge(0);		// 年龄
+//		t.setIdCard("");		// 身份证
+//		t.setIdCardImg("");		// 身份证复印件
+//		t.setPhone("");		// 手机号码
+//		t.setBankNo("");		// 银行编号
+//		t.setBankCode("");		// 银行卡号
+//		t.setBankName("");		// 银行名称
+//		t.setGroupId(0L);		// 所属互助组(1=测试组)
+//		t.setGroupName("");		// 互助组名称
+//		t.setStatus("");		// 是否可用(0=否,1=是)
+//		t.setRole("");		// 角色(1=普通边民,2=兼组长)
+//		t.setLng(0.0);		// 经度
+//		t.setLat(0.0);		// 纬度
+//		t.setLastLocation("");		// 最后一次下单定位
+//		t.setAddress("");		// 联系地址
+//		t.setAddressIds("");		// 地址ID
+//		t.setDetailAddress("");		// 详细地址
+//		t.setIsLock("");		// 是否锁定
+//		t.setLeftPrice(0.0);		// 当天剩余额度
+//		t.setJudgeStatus("");		//
+//		t.setJudgeContent("");		//
+//		t.setRegisterTime("");		//
+//		t.setJudgeTime("");		//
+//		t.setPersonId("");		//
+//		t.setCreateTime("");		// 创建时间
+//		t.setCreateBy("");		// 创建人编号
+//		t.setCreateName("");		// 创建人名称
+//		t.setUpdateTime("");		// 更新时间
+//		t.setUpdateBy("");		// 更新人编号
+//		t.setUpdateName("");		// 更新人名称
+//		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用)
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 108 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_shop/MethodShopService.java

@@ -0,0 +1,108 @@
+package com.pj.tb_shop;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 20 37
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodShopService {
+    
+    @Autowired
+    private TbShopMapper tbShopMapper;
+
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbShop tbShop = new TbShop();
+            //解析数据
+            HSSFCell cell8 = row.getCell(1);
+            if (cell8 != null && (cell8.getCellType() == CellType.NUMERIC || cell8.getCellType() == CellType.FORMULA))
+                tbShop.setEnterpriseId((long) cell8.getNumericCellValue());
+
+            HSSFCell cell2 = row.getCell(2);
+            if (cell2 != null && (cell2.getCellType() == CellType.NUMERIC || cell2.getCellType() == CellType.FORMULA))
+                tbShop.setTradeAreaId((long) cell2.getNumericCellValue());
+
+            if(row.getCell(3) != null)
+                tbShop.setTradeAreaName(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(4) != null)
+                tbShop.setAddress(row.getCell(4).getStringCellValue());
+
+            if(row.getCell(5) != null)
+                tbShop.setAddressIds(row.getCell(5).getStringCellValue());
+
+            if(row.getCell(6) != null)
+                tbShop.setName(row.getCell(6).getStringCellValue());
+
+            if(row.getCell(7) != null)
+                tbShop.setNo(row.getCell(7).getStringCellValue());
+
+            if(row.getCell(8) != null)
+                tbShop.setArea(row.getCell(8).getStringCellValue());
+
+            HSSFCell cell19 = row.getCell(9);
+            if (cell19 != null && (cell19.getCellType() == CellType.NUMERIC || cell19.getCellType() == CellType.FORMULA))
+                tbShop.setStatus(Integer.valueOf(cell19.getStringCellValue()));
+
+            if(row.getCell(10) != null)
+                tbShop.setRemark(row.getCell(10).getStringCellValue());
+
+            if(row.getCell(11) != null)
+                tbShop.setEnterpriseName(row.getCell(11).getStringCellValue());
+
+
+            //公共字段
+            HSSFCell cell12 = row.getCell(12);
+            if (cell12 != null && cell12.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell12)) {
+                tbShop.setCreateTime(cell12.getDateCellValue());
+            }
+
+            if(row.getCell(13) != null && !row.getCell(13).toString().trim().equals(""))
+                tbShop.setCreateBy(row.getCell(13).getStringCellValue());
+
+            if(row.getCell(14) != null && !row.getCell(14).toString().trim().equals(""))
+                tbShop.setCreateName(row.getCell(14).getStringCellValue());
+
+            if(row.getCell(15) != null && !row.getCell(15).toString().trim().equals(""))
+                tbShop.setUpdateBy(row.getCell(15).getStringCellValue());
+
+            if(row.getCell(16) != null && !row.getCell(16).toString().trim().equals(""))
+                tbShop.setUpdateName(row.getCell(16).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(17);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbShop.setUpdateTime(cell3.getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbShop.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbShop);
+            int insert = tbShopMapper.insert(tbShop);
+            count += insert;
+        }
+        return count;
+    }
+    
+}

+ 6 - 3
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShop.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.*;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -44,7 +45,7 @@ public class TbShop extends Model<TbShop> implements Serializable {
 	 * 主键 
 	 */
 	@TableId(type = IdType.AUTO)
-	private String id;	
+	private Long id;
 
 	/**
 	 *  
@@ -69,6 +70,7 @@ public class TbShop extends Model<TbShop> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date createTime;	
 
 	/**
@@ -79,6 +81,7 @@ public class TbShop extends Model<TbShop> implements Serializable {
 	/**
 	 * 更新时间 
 	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date updateTime;	
 
 	/**
@@ -119,7 +122,7 @@ public class TbShop extends Model<TbShop> implements Serializable {
 	/**
 	 * 是否可用(0=否,1=是) 
 	 */
-	private String status;	
+	private Integer status;
 
 	/**
 	 *  
@@ -134,7 +137,7 @@ public class TbShop extends Model<TbShop> implements Serializable {
 	/**
 	 * 删除状态 
 	 */
-	private String deleteStatus;	
+	private Integer deleteStatus;
 
 
 

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

@@ -1,5 +1,6 @@
 package com.pj.tb_shop;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -86,11 +88,47 @@ public class TbShopController {
 		int line = SP.publicMapper.updateColumnById(TbShop.TABLE_NAME, "status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	
 
-	
-	
-	
+
+
+
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("shopImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbShopService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("shopOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbShopService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
 
 }

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

@@ -1,13 +1,23 @@
 package com.pj.tb_shop;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
-import com.pj.utils.sg.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_shop -- 铺位
@@ -21,6 +31,9 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 	@Autowired
 	TbShopMapper tbShopMapper;
 
+	@Autowired
+	private MethodShopService methodShopService;
+
 	/** 增 */
 	void add(TbShop t){
 		save(t);
@@ -46,6 +59,107 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 	List<TbShop> getList(SoMap so) { 
 		return tbShopMapper.getList(so);	
 	}
-	
+
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodShopService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		List<TbShop> selectedList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(StringUtils.isNoneBlank(keyword), TbShop::getName, keyword));
+		if(selectedList.size() == 0)return "没有可导出的数据。";
+		//建立excel对象封装数据
+		HSSFWorkbook workbook = new HSSFWorkbook();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("enterprise_id");
+		row.createCell(2).setCellValue("交易地区ID");
+		row.createCell(3).setCellValue("交易地区名称");
+		row.createCell(4).setCellValue("地址");
+		row.createCell(5).setCellValue("地址ID");
+		row.createCell(6).setCellValue("名称");
+		row.createCell(7).setCellValue("编号");
+		row.createCell(8).setCellValue("区域");
+		row.createCell(9).setCellValue("是否可用");
+		row.createCell(10).setCellValue("备注");
+		row.createCell(11).setCellValue("enterprise_name");
+
+		row.createCell(28).setCellValue("创建时间");
+		row.createCell(29).setCellValue("创建人编号");
+		row.createCell(30).setCellValue("创建人名称");
+		row.createCell(31).setCellValue("更新时间");
+		row.createCell(32).setCellValue("更新人编号");
+		row.createCell(33).setCellValue("更新人名称");
+		row.createCell(34).setCellValue("删除状态");
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getEnterpriseId() + "").equals("null")? "": selectedList.get(i).getEnterpriseId() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getTradeAreaId() + "").equals("null")? "": selectedList.get(i).getTradeAreaId() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getTradeAreaName() + "").equals("null")? "": selectedList.get(i).getTradeAreaName() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getNo() + "").equals("null")? "": selectedList.get(i).getNo() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getArea() + "" ).equals("null")? "": selectedList.get(i).getArea() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getStatus() + "").equals("null")? "": selectedList.get(i).getStatus() + "");
+			sheetRow.createCell(10).setCellValue((selectedList.get(i).getRemark() + "").equals("null")? "": selectedList.get(i).getRemark() + "");
+			sheetRow.createCell(11).setCellValue((selectedList.get(i).getEnterpriseName() + "").equals("null")? "": selectedList.get(i).getEnterpriseName() + "");
+			//公共字段
+			sheetRow.createCell(12).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(14).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(15).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			sheetRow.createCell(16).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
+			sheetRow.createCell(17).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
+			sheetRow.createCell(18).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null")? "": selectedList.get(i).getDeleteStatus() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
 
 }

+ 80 - 80
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopUtil.java

@@ -1,80 +1,80 @@
-package com.pj.tb_shop;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-import java.util.*;
-
-/**
- * 工具类:tb_shop -- 铺位
- * @author qzy 
- *
- */
-@Component
-public class TbShopUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbShopMapper tbShopMapper;
-	@Autowired
-	private void setTbShopMapper(TbShopMapper tbShopMapper) {
-		TbShopUtil.tbShopMapper = tbShopMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbShop 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbShop t) {
-		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
-		AjaxError.throwByIsNull(t.getEnterpriseId(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建者名称] 不能为空");		// 验证: 创建者名称 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getTradeAreaId(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getTradeAreaName(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getAddress(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getAddressIds(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称 
-		AjaxError.throwByIsNull(t.getNo(), "[编号] 不能为空");		// 验证: 编号 
-		AjaxError.throwByIsNull(t.getArea(), "[区域] 不能为空");		// 验证: 区域(A区=A区,B区=B区,C区=C区) 
-		AjaxError.throwByIsNull(t.getStatus(), "[是否可用] 不能为空");		// 验证: 是否可用(0=否,1=是) 
-		AjaxError.throwByIsNull(t.getRemark(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getEnterpriseName(), "[] 不能为空");		// 验证:  
-	}
-
-	/** 
-	 * 获取一个TbShop (方便复制代码用) [G] 
-	 */ 
-	static TbShop getTbShop() {
-		TbShop t = new TbShop();	// 声明对象 
-		t.setId("");		// 主键 
-		t.setEnterpriseId(0L);		//  
-		t.setCreateBy("");		// 创建者id 
-		t.setCreateName("");		// 创建者名称 
-		t.setUpdateName("");		// 更新者名称 
-		t.setCreateTime(new Date());		// 创建时间 
-		t.setUpdateBy("");		// 更新者id 
-		t.setUpdateTime(new Date());		// 更新时间 
-		t.setTradeAreaId(0L);		//  
-		t.setTradeAreaName("");		//  
-		t.setAddress("");		//  
-		t.setAddressIds("");		//  
-		t.setName("");		// 名称 
-		t.setNo("");		// 编号 
-		t.setArea("");		// 区域(A区=A区,B区=B区,C区=C区) 
-		t.setStatus("");		// 是否可用(0=否,1=是) 
-		t.setRemark("");		//  
-		t.setEnterpriseName("");		//  
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_shop;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//import java.util.*;
+//
+///**
+// * 工具类:tb_shop -- 铺位
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbShopUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbShopMapper tbShopMapper;
+//	@Autowired
+//	private void setTbShopMapper(TbShopMapper tbShopMapper) {
+//		TbShopUtil.tbShopMapper = tbShopMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbShop 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbShop t) {
+//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
+//		AjaxError.throwByIsNull(t.getEnterpriseId(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建者名称] 不能为空");		// 验证: 创建者名称
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getTradeAreaId(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getTradeAreaName(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getAddress(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getAddressIds(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称
+//		AjaxError.throwByIsNull(t.getNo(), "[编号] 不能为空");		// 验证: 编号
+//		AjaxError.throwByIsNull(t.getArea(), "[区域] 不能为空");		// 验证: 区域(A区=A区,B区=B区,C区=C区)
+//		AjaxError.throwByIsNull(t.getStatus(), "[是否可用] 不能为空");		// 验证: 是否可用(0=否,1=是)
+//		AjaxError.throwByIsNull(t.getRemark(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getEnterpriseName(), "[] 不能为空");		// 验证:
+//	}
+//
+//	/**
+//	 * 获取一个TbShop (方便复制代码用) [G]
+//	 */
+//	static TbShop getTbShop() {
+//		TbShop t = new TbShop();	// 声明对象
+//		t.setId("");		// 主键
+//		t.setEnterpriseId(0L);		//
+//		t.setCreateBy("");		// 创建者id
+//		t.setCreateName("");		// 创建者名称
+//		t.setUpdateName("");		// 更新者名称
+//		t.setCreateTime(new Date());		// 创建时间
+//		t.setUpdateBy("");		// 更新者id
+//		t.setUpdateTime(new Date());		// 更新时间
+//		t.setTradeAreaId(0L);		//
+//		t.setTradeAreaName("");		//
+//		t.setAddress("");		//
+//		t.setAddressIds("");		//
+//		t.setName("");		// 名称
+//		t.setNo("");		// 编号
+//		t.setArea("");		// 区域(A区=A区,B区=B区,C区=C区)
+//		t.setStatus("");		// 是否可用(0=否,1=是)
+//		t.setRemark("");		//
+//		t.setEnterpriseName("");		//
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 84 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/MethodTradeAreaService.java

@@ -0,0 +1,84 @@
+package com.pj.tb_trade_area;
+
+import com.pj.tb_people.tbTradeArea;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 21 01
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodTradeAreaService {
+    
+    @Autowired
+    private TbTradeAreaMapper tbTradeAreaMapper;
+
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbTradeArea tbTradeArea = new TbTradeArea();
+            //解析数据
+            if(row.getCell(1) != null)
+                tbTradeArea.setName(row.getCell(1).getStringCellValue());
+
+            if(row.getCell(2) != null)
+                tbTradeArea.setAddressIds(row.getCell(2).getStringCellValue());
+
+            if(row.getCell(3) != null)
+                tbTradeArea.setDetailAddress(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(4) != null)
+                tbTradeArea.setAddress(row.getCell(4).getStringCellValue());
+
+            //公共字段
+            HSSFCell cell2 = row.getCell(5);
+            if (cell2 != null && cell2.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell2)) {
+                tbTradeArea.setCreateTime(cell2.getDateCellValue());
+            }
+
+            if(row.getCell(6) != null && !row.getCell(6).toString().trim().equals(""))
+                tbTradeArea.setCreateBy(row.getCell(6).getStringCellValue());
+
+            if(row.getCell(7) != null && !row.getCell(7).toString().trim().equals(""))
+                tbTradeArea.setCreateName(row.getCell(7).getStringCellValue());
+
+            if(row.getCell(8) != null && !row.getCell(8).toString().trim().equals(""))
+                tbTradeArea.setUpdateBy(row.getCell(8).getStringCellValue());
+
+            if(row.getCell(9) != null && !row.getCell(9).toString().trim().equals(""))
+                tbTradeArea.setUpdateName(row.getCell(9).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(10);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbTradeArea.setUpdateTime(cell3.getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbTradeArea.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbTradeArea);
+            int insert = tbTradeAreaMapper.insert(tbTradeArea);
+            count += insert;
+        }
+        return count;
+    }
+    
+}

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

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.*;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -44,7 +45,7 @@ public class TbTradeArea extends Model<TbTradeArea> implements Serializable {
 	 * 主键 
 	 */
 	@TableId(type = IdType.AUTO)
-	private String id;	
+	private Long id;
 
 	/**
 	 * 名称 
@@ -69,6 +70,7 @@ public class TbTradeArea extends Model<TbTradeArea> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date createTime;	
 
 	/**
@@ -94,12 +96,13 @@ public class TbTradeArea extends Model<TbTradeArea> implements Serializable {
 	/**
 	 * 更新时间 
 	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date updateTime;	
 
 	/**
 	 * 删除状态 
 	 */
-	private String deleteStatus;	
+	private Integer deleteStatus;
 
 
 

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

@@ -1,5 +1,6 @@
 package com.pj.tb_trade_area;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -76,13 +78,49 @@ public class TbTradeAreaController {
 		List<TbTradeArea> list = tbTradeAreaService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
-	
-	
-	
-	
 
-	
-	
-	
+
+
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("tradeAreaImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbTradeAreaService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("tradeAreaOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbTradeAreaService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
+
+
 
 }

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

@@ -1,13 +1,25 @@
 package com.pj.tb_trade_area;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.tb_people.TbPeople;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import com.pj.utils.sg.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_trade_area -- 贸易区域
@@ -20,6 +32,8 @@ public class TbTradeAreaService extends ServiceImpl<TbTradeAreaMapper, TbTradeAr
 	/** 底层 Mapper 对象 */
 	@Autowired
 	TbTradeAreaMapper tbTradeAreaMapper;
+	@Autowired
+	private MethodTradeAreaService methodTradeAreaService;
 
 	/** 增 */
 	void add(TbTradeArea t){
@@ -46,6 +60,94 @@ public class TbTradeAreaService extends ServiceImpl<TbTradeAreaMapper, TbTradeAr
 	List<TbTradeArea> getList(SoMap so) { 
 		return tbTradeAreaMapper.getList(so);	
 	}
-	
+
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodTradeAreaService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		List<TbTradeArea> selectedList = tbTradeAreaMapper.selectList(new LambdaQueryWrapper<TbTradeArea>().eq(StringUtils.isNoneBlank(keyword), TbTradeArea::getName, keyword));
+		if(selectedList.size() == 0)return "没有可导出的数据。";
+		//建立excel对象封装数据
+		HSSFWorkbook workbook = new HSSFWorkbook();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("区域名称");
+		row.createCell(2).setCellValue("区域IDs");
+		row.createCell(3).setCellValue("地址详情");
+		row.createCell(4).setCellValue("地址");
+
+		row.createCell(28).setCellValue("创建时间");
+		row.createCell(29).setCellValue("创建人编号");
+		row.createCell(30).setCellValue("创建人名称");
+		row.createCell(31).setCellValue("更新时间");
+		row.createCell(32).setCellValue("更新人编号");
+		row.createCell(33).setCellValue("更新人名称");
+		row.createCell(34).setCellValue("删除状态");
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null")? "": selectedList.get(i).getDetailAddress() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
+
+			//公共字段
+			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			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() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
 
 }

+ 66 - 66
sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaUtil.java

@@ -1,66 +1,66 @@
-package com.pj.tb_trade_area;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-import java.util.*;
-
-/**
- * 工具类:tb_trade_area -- 贸易区域
- * @author qzy 
- *
- */
-@Component
-public class TbTradeAreaUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbTradeAreaMapper tbTradeAreaMapper;
-	@Autowired
-	private void setTbTradeAreaMapper(TbTradeAreaMapper tbTradeAreaMapper) {
-		TbTradeAreaUtil.tbTradeAreaMapper = tbTradeAreaMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbTradeArea 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbTradeArea t) {
-		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
-		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称 
-		AjaxError.throwByIsNull(t.getAddressIds(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(t.getDetailAddress(), "[地址详情] 不能为空");		// 验证: 地址详情 
-		AjaxError.throwByIsNull(t.getAddress(), "[地址] 不能为空");		// 验证: 地址 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建者名称] 不能为空");		// 验证: 创建者名称 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-	}
-
-	/** 
-	 * 获取一个TbTradeArea (方便复制代码用) [G] 
-	 */ 
-	static TbTradeArea getTbTradeArea() {
-		TbTradeArea t = new TbTradeArea();	// 声明对象 
-		t.setId("");		// 主键 
-		t.setName("");		// 名称 
-		t.setAddressIds("");		//  
-		t.setDetailAddress("");		// 地址详情 
-		t.setAddress("");		// 地址 
-		t.setCreateTime(new Date());		// 创建时间 
-		t.setCreateBy("");		// 创建者id 
-		t.setCreateName("");		// 创建者名称 
-		t.setUpdateBy("");		// 更新者id 
-		t.setUpdateName("");		// 更新者名称 
-		t.setUpdateTime(new Date());		// 更新时间 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_trade_area;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//import java.util.*;
+//
+///**
+// * 工具类:tb_trade_area -- 贸易区域
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbTradeAreaUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbTradeAreaMapper tbTradeAreaMapper;
+//	@Autowired
+//	private void setTbTradeAreaMapper(TbTradeAreaMapper tbTradeAreaMapper) {
+//		TbTradeAreaUtil.tbTradeAreaMapper = tbTradeAreaMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbTradeArea 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbTradeArea t) {
+//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
+//		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称
+//		AjaxError.throwByIsNull(t.getAddressIds(), "[] 不能为空");		// 验证:
+//		AjaxError.throwByIsNull(t.getDetailAddress(), "[地址详情] 不能为空");		// 验证: 地址详情
+//		AjaxError.throwByIsNull(t.getAddress(), "[地址] 不能为空");		// 验证: 地址
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建者名称] 不能为空");		// 验证: 创建者名称
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//	}
+//
+//	/**
+//	 * 获取一个TbTradeArea (方便复制代码用) [G]
+//	 */
+//	static TbTradeArea getTbTradeArea() {
+//		TbTradeArea t = new TbTradeArea();	// 声明对象
+//		t.setId("");		// 主键
+//		t.setName("");		// 名称
+//		t.setAddressIds("");		//
+//		t.setDetailAddress("");		// 地址详情
+//		t.setAddress("");		// 地址
+//		t.setCreateTime(new Date());		// 创建时间
+//		t.setCreateBy("");		// 创建者id
+//		t.setCreateName("");		// 创建者名称
+//		t.setUpdateBy("");		// 更新者id
+//		t.setUpdateName("");		// 更新者名称
+//		t.setUpdateTime(new Date());		// 更新时间
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 125 - 0
sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/MethodPurchaserService.java

@@ -0,0 +1,125 @@
+package com.pj.tb_purchaser;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 07 21 21 13
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodPurchaserService {
+    
+    @Autowired
+    private TbPurchaserMapper tbPurchaserMapper;
+
+    /**
+     * 方法抽取  导入
+     * @param row
+     * @param sheet
+     * @param count
+     * @return
+     */
+    public int importMethod(HSSFRow row, HSSFSheet sheet, int count){
+
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            //封装数据到行对象
+            row = sheet.getRow(i);
+            //定义返回值实体
+            TbPurchaser tbPurchaser = new TbPurchaser();
+            //解析数据
+            if(row.getCell(1) != null)
+                tbPurchaser.setName(row.getCell(1).getStringCellValue());
+
+            if(row.getCell(2) != null)
+                tbPurchaser.setLegalPerson(row.getCell(2).getStringCellValue());
+
+            if(row.getCell(3) != null)
+                tbPurchaser.setIdCard(row.getCell(3).getStringCellValue());
+
+            if(row.getCell(4) != null)
+                tbPurchaser.setContact(row.getCell(4).getStringCellValue());
+
+            if(row.getCell(5) != null)
+                tbPurchaser.setBusinessLicense(row.getCell(5).getStringCellValue());
+
+            if(row.getCell(6) != null)
+                tbPurchaser.setBankNo(row.getCell(6).getStringCellValue());
+
+            if(row.getCell(7) != null)
+                tbPurchaser.setBankName(row.getCell(7).getStringCellValue());
+
+            if(row.getCell(8) != null)
+                tbPurchaser.setBankAccount(row.getCell(8).getStringCellValue());
+
+            if(row.getCell(9) != null)
+                tbPurchaser.setDutyParagraph(row.getCell(9).getStringCellValue());
+
+            if(row.getCell(10) != null)
+                tbPurchaser.setAddressIds(row.getCell(10).getStringCellValue());
+
+            if(row.getCell(11) != null)
+                tbPurchaser.setAddress(row.getCell(11).getStringCellValue());
+
+            if(row.getCell(12) != null)
+                tbPurchaser.setIdCard(row.getCell(12).getStringCellValue());
+
+            HSSFCell cell21 = row.getCell(13);
+            if (cell21 != null && (cell21.getCellType() == CellType.NUMERIC || cell21.getCellType() == CellType.FORMULA))
+                tbPurchaser.setJudgeStatus((int) cell21.getNumericCellValue());
+
+            if(row.getCell(14) != null)
+                tbPurchaser.setJudgeContent(row.getCell(14).getStringCellValue());
+
+            HSSFCell cell2 = row.getCell(15);
+            if (cell2 != null && cell2.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell2)) {
+                tbPurchaser.setJudgeTime(cell2.getDateCellValue());
+            }
+
+            HSSFCell cell16 = row.getCell(16);
+            if (cell16 != null && cell16.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell16)) {
+                tbPurchaser.setRegisterTime(cell16.getDateCellValue());
+            }
+
+            if(row.getCell(17) != null)
+                tbPurchaser.setPersonId(row.getCell(17).getStringCellValue());
+
+            //公共字段
+            HSSFCell cell18 = row.getCell(18);
+            if (cell18 != null && cell18.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell18)) {
+                tbPurchaser.setCreateTime(cell18.getDateCellValue());
+            }
+
+            if(row.getCell(19) != null && !row.getCell(19).toString().trim().equals(""))
+                tbPurchaser.setCreateBy(row.getCell(19).getStringCellValue());
+
+            if(row.getCell(20) != null && !row.getCell(20).toString().trim().equals(""))
+                tbPurchaser.setCreateName(row.getCell(20).getStringCellValue());
+
+            if(row.getCell(21) != null && !row.getCell(21).toString().trim().equals(""))
+                tbPurchaser.setUpdateBy(row.getCell(21).getStringCellValue());
+
+            if(row.getCell(22) != null && !row.getCell(22).toString().trim().equals(""))
+                tbPurchaser.setUpdateName(row.getCell(22).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(23);
+            if (cell3 != null && cell3.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell3)) {
+                tbPurchaser.setUpdateTime(cell3.getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbPurchaser.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbPurchaser);
+            int insert = tbPurchaserMapper.insert(tbPurchaser);
+            count += insert;
+        }
+        return count;
+    }
+}

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

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.*;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
@@ -104,7 +105,7 @@ public class TbPurchaser extends Model<TbPurchaser> implements Serializable {
 	/**
 	 * 审核状态(0=未通过,1=已通过) 
 	 */
-	private String judgeStatus;	
+	private Integer judgeStatus;
 
 	/**
 	 * 审核意见 
@@ -114,11 +115,13 @@ public class TbPurchaser extends Model<TbPurchaser> implements Serializable {
 	/**
 	 * 上次审核时间 
 	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date judgeTime;	
 
 	/**
 	 * 注册时间 
 	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date registerTime;	
 
 	/**
@@ -129,7 +132,8 @@ public class TbPurchaser extends Model<TbPurchaser> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
-	private String createTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date createTime;
 
 	/**
 	 * 创建人编号 
@@ -144,7 +148,8 @@ public class TbPurchaser extends Model<TbPurchaser> implements Serializable {
 	/**
 	 * 更新时间 
 	 */
-	private String updateTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date updateTime;
 
 	/**
 	 * 更新人编号 

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

@@ -1,5 +1,6 @@
 package com.pj.tb_purchaser;
 
+import java.io.IOException;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,6 +10,7 @@ import com.pj.utils.sg.*;
 import com.pj.project4sp.SP;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -83,11 +85,45 @@ public class TbPurchaserController {
 		int line = SP.publicMapper.updateColumnById(TbPurchaser.TABLE_NAME, "delete_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	
 
-	
-	
-	
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("purchaserImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbPurchaserService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("purchaserOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbPurchaserService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
 
 }

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

@@ -1,12 +1,23 @@
 package com.pj.tb_purchaser;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.pj.utils.so.SoMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Service: tb_purchaser -- 收购商
@@ -20,6 +31,9 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 	@Autowired
 	TbPurchaserMapper tbPurchaserMapper;
 
+	@Autowired
+	private MethodPurchaserService methodPurchaserService;
+
 	/** 增 */
 	void add(TbPurchaser t){
 		save(t);
@@ -45,6 +59,117 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 	List<TbPurchaser> getList(SoMap so) { 
 		return tbPurchaserMapper.getList(so);	
 	}
-	
 
+
+	/**
+	 * 导入
+	 * @param file excel文件
+	 * @return
+	 * @throws IOException
+	 */
+	public String importData(MultipartFile file) throws IOException {
+		System.out.println("\n开始执行文件上传....\n");
+
+		//判空
+		if(file.isEmpty()) return "文件为空,无法执行上传...";
+		//获取文件上传数据
+		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+		//获取第一页sheet
+		HSSFSheet sheet = wb.getSheetAt(0);
+		//定义计数器
+		int count = 0;
+		//定义行对象
+		HSSFRow row = null;
+		//解析数据封装到集合
+		count = methodPurchaserService.importMethod(row, sheet, count);
+		wb.close();
+		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+		return "上传完成,共上传"  + count + "条"  + "数据。";
+	}
+
+	/**
+	 * 导出 excel文件
+	 * @param keyword
+	 * @return
+	 */
+	public String outportExcel(String keyword) 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";
+		//根据需求查询数据
+		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();
+		//创建excel表格右下角的sheet页名称
+		HSSFSheet sheet = workbook.createSheet("1");
+		//创建表头
+		HSSFRow row = sheet.createRow(0);
+		row.createCell(0).setCellValue("序号");
+		row.createCell(1).setCellValue("名称");
+		row.createCell(2).setCellValue("法人");
+		row.createCell(3).setCellValue("身份证");
+		row.createCell(4).setCellValue("手机号码");
+		row.createCell(5).setCellValue("营业执照");
+		row.createCell(6).setCellValue("银行编号");
+		row.createCell(7).setCellValue("银行名称");
+		row.createCell(8).setCellValue("银行账号");
+		row.createCell(9).setCellValue("税号");
+		row.createCell(10).setCellValue("地址编号");
+		row.createCell(10).setCellValue("地址");
+		row.createCell(11).setCellValue("审核状态");
+		row.createCell(13).setCellValue("审核意见");
+		row.createCell(12).setCellValue("上次审核时间");
+		row.createCell(12).setCellValue("注册时间");
+		row.createCell(12).setCellValue("人脸编号");
+
+		row.createCell(14).setCellValue("创建时间");
+		row.createCell(15).setCellValue("创建人编号");
+		row.createCell(16).setCellValue("创建人名称");
+		row.createCell(17).setCellValue("更新时间");
+		row.createCell(18).setCellValue("更新人编号");
+		row.createCell(19).setCellValue("更新人名称");
+		row.createCell(20).setCellValue("删除状态");
+
+		//遍历集合
+		for (int i = 0; i < selectedList.size(); i++) {
+			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+			sheetRow.createCell(0).setCellValue(i + 1);
+			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getLegalPerson() + "").equals("null")? "": selectedList.get(i).getLegalPerson() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getIdCard() + "").equals("null")? "": selectedList.get(i).getIdCard() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getContact() + "").equals("null")? "": selectedList.get(i).getContact() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getBusinessLicense() + "").equals("null")? "": selectedList.get(i).getBusinessLicense() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getBankNo() + "").equals("null")? "": selectedList.get(i).getBankNo() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getBankName() + "").equals("null")? "": selectedList.get(i).getBankName() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getBankAccount() + "" ).equals("null")? "": selectedList.get(i).getBankAccount() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getDutyParagraph() + "").equals("null")? "": selectedList.get(i).getDutyParagraph() + "");
+			sheetRow.createCell(10).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
+			sheetRow.createCell(11).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
+			sheetRow.createCell(12).setCellValue((selectedList.get(i).getJudgeStatus() + "").equals("null")? "": selectedList.get(i).getJudgeStatus() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getJudgeContent() + "").equals("null")? "": selectedList.get(i).getJudgeContent() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getJudgeTime() + "").equals("null")? "": selectedList.get(i).getJudgeTime() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getRegisterTime() + "").equals("null")? "": selectedList.get(i).getRegisterTime() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getPersonId() + "").equals("null")? "": selectedList.get(i).getPersonId() + "");
+			//公共字段
+			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			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() + "");
+		}
+		//建立输出流,输出文件
+		FileOutputStream fos = new FileOutputStream(filepath);
+
+		workbook.write(fos);
+		fos.flush();
+		//关闭输出流
+		fos.close();
+		workbook.close();
+		System.out.println("\n数据导出完成!");
+		return "数据导出完成!";
+	}
 }

+ 92 - 92
sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserUtil.java

@@ -1,92 +1,92 @@
-package com.pj.tb_purchaser;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-import java.util.*;
-
-/**
- * 工具类:tb_purchaser -- 收购商
- * @author qzy 
- *
- */
-@Component
-public class TbPurchaserUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbPurchaserMapper tbPurchaserMapper;
-	@Autowired
-	private void setTbPurchaserMapper(TbPurchaserMapper tbPurchaserMapper) {
-		TbPurchaserUtil.tbPurchaserMapper = tbPurchaserMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbPurchaser 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbPurchaser t) {
-		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
-		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称 
-		AjaxError.throwByIsNull(t.getLegalPerson(), "[法人] 不能为空");		// 验证: 法人 
-		AjaxError.throwByIsNull(t.getIdCard(), "[身份证号] 不能为空");		// 验证: 身份证号 
-		AjaxError.throwByIsNull(t.getContact(), "[手机号码] 不能为空");		// 验证: 手机号码 
-		AjaxError.throwByIsNull(t.getBusinessLicense(), "[营业执照] 不能为空");		// 验证: 营业执照 
-		AjaxError.throwByIsNull(t.getBankNo(), "[银行编号] 不能为空");		// 验证: 银行编号 
-		AjaxError.throwByIsNull(t.getBankName(), "[银行名称] 不能为空");		// 验证: 银行名称 
-		AjaxError.throwByIsNull(t.getBankAccount(), "[银行账号] 不能为空");		// 验证: 银行账号 
-		AjaxError.throwByIsNull(t.getDutyParagraph(), "[税号] 不能为空");		// 验证: 税号 
-		AjaxError.throwByIsNull(t.getAddressIds(), "[地址编号] 不能为空");		// 验证: 地址编号 
-		AjaxError.throwByIsNull(t.getAddress(), "[地址] 不能为空");		// 验证: 地址 
-		AjaxError.throwByIsNull(t.getJudgeStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=未通过,1=已通过) 
-		AjaxError.throwByIsNull(t.getJudgeContent(), "[审核意见] 不能为空");		// 验证: 审核意见 
-		AjaxError.throwByIsNull(t.getJudgeTime(), "[上次审核时间] 不能为空");		// 验证: 上次审核时间 
-		AjaxError.throwByIsNull(t.getRegisterTime(), "[注册时间] 不能为空");		// 验证: 注册时间 
-		AjaxError.throwByIsNull(t.getPersonId(), "[人脸编号] 不能为空");		// 验证: 人脸编号 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称 
-		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用) 
-	}
-
-	/** 
-	 * 获取一个TbPurchaser (方便复制代码用) [G] 
-	 */ 
-	static TbPurchaser getTbPurchaser() {
-		TbPurchaser t = new TbPurchaser();	// 声明对象 
-		t.setId(0L);		// 主键 
-		t.setName("");		// 名称 
-		t.setLegalPerson("");		// 法人 
-		t.setIdCard("");		// 身份证号 
-		t.setContact("");		// 手机号码 
-		t.setBusinessLicense("");		// 营业执照 
-		t.setBankNo("");		// 银行编号 
-		t.setBankName("");		// 银行名称 
-		t.setBankAccount("");		// 银行账号 
-		t.setDutyParagraph("");		// 税号 
-		t.setAddressIds("");		// 地址编号 
-		t.setAddress("");		// 地址 
-		t.setJudgeStatus("");		// 审核状态(0=未通过,1=已通过) 
-		t.setJudgeContent("");		// 审核意见 
-		t.setJudgeTime(new Date());		// 上次审核时间 
-		t.setRegisterTime(new Date());		// 注册时间 
-		t.setPersonId("");		// 人脸编号 
-		t.setCreateTime("");		// 创建时间 
-		t.setCreateBy("");		// 创建人编号 
-		t.setCreateName("");		// 创建人名称 
-		t.setUpdateTime("");		// 更新时间 
-		t.setUpdateBy("");		// 更新人编号 
-		t.setUpdateName("");		// 更新人名称 
-		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用) 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.tb_purchaser;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//import java.util.*;
+//
+///**
+// * 工具类:tb_purchaser -- 收购商
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbPurchaserUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbPurchaserMapper tbPurchaserMapper;
+//	@Autowired
+//	private void setTbPurchaserMapper(TbPurchaserMapper tbPurchaserMapper) {
+//		TbPurchaserUtil.tbPurchaserMapper = tbPurchaserMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbPurchaser 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbPurchaser t) {
+//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
+//		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称
+//		AjaxError.throwByIsNull(t.getLegalPerson(), "[法人] 不能为空");		// 验证: 法人
+//		AjaxError.throwByIsNull(t.getIdCard(), "[身份证号] 不能为空");		// 验证: 身份证号
+//		AjaxError.throwByIsNull(t.getContact(), "[手机号码] 不能为空");		// 验证: 手机号码
+//		AjaxError.throwByIsNull(t.getBusinessLicense(), "[营业执照] 不能为空");		// 验证: 营业执照
+//		AjaxError.throwByIsNull(t.getBankNo(), "[银行编号] 不能为空");		// 验证: 银行编号
+//		AjaxError.throwByIsNull(t.getBankName(), "[银行名称] 不能为空");		// 验证: 银行名称
+//		AjaxError.throwByIsNull(t.getBankAccount(), "[银行账号] 不能为空");		// 验证: 银行账号
+//		AjaxError.throwByIsNull(t.getDutyParagraph(), "[税号] 不能为空");		// 验证: 税号
+//		AjaxError.throwByIsNull(t.getAddressIds(), "[地址编号] 不能为空");		// 验证: 地址编号
+//		AjaxError.throwByIsNull(t.getAddress(), "[地址] 不能为空");		// 验证: 地址
+//		AjaxError.throwByIsNull(t.getJudgeStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=未通过,1=已通过)
+//		AjaxError.throwByIsNull(t.getJudgeContent(), "[审核意见] 不能为空");		// 验证: 审核意见
+//		AjaxError.throwByIsNull(t.getJudgeTime(), "[上次审核时间] 不能为空");		// 验证: 上次审核时间
+//		AjaxError.throwByIsNull(t.getRegisterTime(), "[注册时间] 不能为空");		// 验证: 注册时间
+//		AjaxError.throwByIsNull(t.getPersonId(), "[人脸编号] 不能为空");		// 验证: 人脸编号
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称
+//		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用)
+//	}
+//
+//	/**
+//	 * 获取一个TbPurchaser (方便复制代码用) [G]
+//	 */
+//	static TbPurchaser getTbPurchaser() {
+//		TbPurchaser t = new TbPurchaser();	// 声明对象
+//		t.setId(0L);		// 主键
+//		t.setName("");		// 名称
+//		t.setLegalPerson("");		// 法人
+//		t.setIdCard("");		// 身份证号
+//		t.setContact("");		// 手机号码
+//		t.setBusinessLicense("");		// 营业执照
+//		t.setBankNo("");		// 银行编号
+//		t.setBankName("");		// 银行名称
+//		t.setBankAccount("");		// 银行账号
+//		t.setDutyParagraph("");		// 税号
+//		t.setAddressIds("");		// 地址编号
+//		t.setAddress("");		// 地址
+//		t.setJudgeStatus("");		// 审核状态(0=未通过,1=已通过)
+//		t.setJudgeContent("");		// 审核意见
+//		t.setJudgeTime(new Date());		// 上次审核时间
+//		t.setRegisterTime(new Date());		// 注册时间
+//		t.setPersonId("");		// 人脸编号
+//		t.setCreateTime("");		// 创建时间
+//		t.setCreateBy("");		// 创建人编号
+//		t.setCreateName("");		// 创建人名称
+//		t.setUpdateTime("");		// 更新时间
+//		t.setUpdateBy("");		// 更新人编号
+//		t.setUpdateName("");		// 更新人名称
+//		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用)
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}