Ver código fonte

7.22 补:基础资料的上传和导出

Mechrevo 2 anos atrás
pai
commit
158693795c

+ 144 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_driver/MethodDriverService.java

@@ -0,0 +1,144 @@
+package com.pj.project.tb_driver;
+
+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 22 12 08
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodDriverService {
+    
+    @Autowired
+    private TbDriverMapper tbDriverMapper;
+
+
+
+    /**
+     * 方法抽取  导入
+     * @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);
+            //定义返回值实体
+            TbDriver tbDriver = new TbDriver();
+            //解析数据
+            if(row.getCell(1) != null)
+                tbDriver.setName(row.getCell(1).getStringCellValue());
+
+            HSSFCell cell21 = row.getCell(2);
+            if (cell21 != null && (cell21.getCellType() == CellType.NUMERIC || cell21.getCellType() == CellType.FORMULA))
+                tbDriver.setAge((int) cell21.getNumericCellValue());
+
+            HSSFCell cell3 = row.getCell(3);
+            if (cell3 != null && (cell3.getCellType() == CellType.NUMERIC || cell3.getCellType() == CellType.FORMULA))
+                tbDriver.setSex((int) cell3.getNumericCellValue());
+
+            if(row.getCell(4) != null)
+                tbDriver.setPhone(row.getCell(4).getStringCellValue());
+
+            if(row.getCell(5) != null)
+                tbDriver.setAddress(row.getCell(5).getStringCellValue());
+
+            if(row.getCell(6) != null)
+                tbDriver.setBankCode(row.getCell(6).getStringCellValue());
+
+            if(row.getCell(7) != null)
+                tbDriver.setBankName(row.getCell(7).getStringCellValue());
+
+            if(row.getCell(8) != null)
+                tbDriver.setIdCard(row.getCell(8).getStringCellValue());
+
+            if(row.getCell(9) != null)
+                tbDriver.setIdCardImg(row.getCell(9).getStringCellValue());
+
+            if(row.getCell(10) != null)
+                tbDriver.setDrivingLicenseId(row.getCell(10).getStringCellValue());
+
+            if(row.getCell(11) != null)
+                tbDriver.setDrivingLicenseImg(row.getCell(11).getStringCellValue());
+
+            if(row.getCell(12) != null)
+                tbDriver.setIdCard(row.getCell(12).getStringCellValue());
+
+            if(row.getCell(13) != null)
+                tbDriver.setVehicleDrivingId(row.getCell(13).getStringCellValue());
+
+            if(row.getCell(14) != null)
+                tbDriver.setVehicleDrivingImg(row.getCell(14).getStringCellValue());
+
+            if(row.getCell(15) != null)
+                tbDriver.setVehicleImg(row.getCell(15).getStringCellValue());
+
+
+            HSSFCell cell16 = row.getCell(16);
+            if (cell16 != null && cell16.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell16)) {
+                tbDriver.setRegisterTime(cell16.getDateCellValue());
+            }
+
+            HSSFCell cell7 = row.getCell(17);
+            if (cell7 != null && (cell7.getCellType() == CellType.NUMERIC || cell7.getCellType() == CellType.FORMULA))
+                tbDriver.setIsLock((int) cell7.getNumericCellValue());
+
+            if(row.getCell(18) != null)
+                tbDriver.setNopassReason(row.getCell(18).getStringCellValue());
+
+            HSSFCell cell9 = row.getCell(19);
+            if (cell9 != null && (cell9.getCellType() == CellType.NUMERIC || cell9.getCellType() == CellType.FORMULA))
+                tbDriver.setAuditStatus((int) cell9.getNumericCellValue());
+
+            if(row.getCell(20) != null)
+                tbDriver.setAuditBy(row.getCell(20).getStringCellValue());
+
+            HSSFCell cell121 = row.getCell(21);
+            if (cell121 != null && cell121.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell121)) {
+                tbDriver.setAuditTime(cell121.getDateCellValue());
+            }
+
+            //公共字段
+            HSSFCell cell18 = row.getCell(22);
+            if (cell18 != null && cell18.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell18)) {
+                tbDriver.setCreateTime(cell18.getDateCellValue());
+            }
+
+            if(row.getCell(23) != null && !row.getCell(23).toString().trim().equals(""))
+                tbDriver.setCreateBy(row.getCell(23).getStringCellValue());
+
+            if(row.getCell(24) != null && !row.getCell(24).toString().trim().equals(""))
+                tbDriver.setCreateName(row.getCell(24).getStringCellValue());
+
+            if(row.getCell(25) != null && !row.getCell(25).toString().trim().equals(""))
+                tbDriver.setUpdateBy(row.getCell(25).getStringCellValue());
+
+            if(row.getCell(26) != null && !row.getCell(26).toString().trim().equals(""))
+                tbDriver.setUpdateName(row.getCell(26).getStringCellValue());
+
+            HSSFCell cell27 = row.getCell(27);
+            if (cell27 != null && cell27.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell27)) {
+                tbDriver.setUpdateTime(cell27.getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbDriver.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbDriver);
+            int insert = tbDriverMapper.insert(tbDriver);
+            count += insert;
+        }
+        return count;
+    }
+    
+}

+ 20 - 13
sp-service/transport-server/src/main/java/com/pj/project/tb_driver/TbDriver.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;
@@ -59,7 +60,7 @@ public class TbDriver extends Model<TbDriver> implements Serializable {
 	/**
 	 * 性别性别(1=男,2=女) 
 	 */
-	private String sex;	
+	private Integer sex;
 
 	/**
 	 * 手机号 
@@ -119,12 +120,13 @@ public class TbDriver extends Model<TbDriver> implements Serializable {
 	/**
 	 * 注册时间 
 	 */
-	private String registerTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date registerTime;
 
 	/**
 	 * 是否被锁定 
 	 */
-	private String isLock;	
+	private Integer isLock;
 
 	/**
 	 * 创建者id 
@@ -139,7 +141,13 @@ public class TbDriver extends Model<TbDriver> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
-	private Date createTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date createTime;
+
+	/**
+	 * 审核不通过原因
+	 */
+	private String nopassReason;
 
 	/**
 	 * 更新者id 
@@ -154,12 +162,10 @@ public class TbDriver extends Model<TbDriver> implements Serializable {
 	/**
 	 * 更新时间 
 	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date updateTime;	
 
-	/**
-	 * 删除状态 
-	 */
-	private String deleteStatus;	
+
 
 	/**
 	 * 审核状态(0=待审核,1=已通过,2=不通过) 
@@ -174,18 +180,19 @@ public class TbDriver extends Model<TbDriver> implements Serializable {
 	/**
 	 * 审核时间 
 	 */
-	private String auditTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date auditTime;
+
+
 
 	/**
-	 * 审核不通过原因 
+	 * 删除状态
 	 */
-	private String nopassReason;	
-
+	private Integer deleteStatus;
 
 
 
 
-	
 
 
 }

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

@@ -1,5 +1,6 @@
 package com.pj.project.tb_driver;
 
+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 TbDriverController {
 		List<TbDriver> list = tbDriverService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
-	
-	
-	
-	
 
-	
-	
-	
+
+
+
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("driverImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbDriverService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("driverOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbDriverService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
+
 
 }

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

@@ -1,13 +1,24 @@
 package com.pj.project.tb_driver;
 
+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_driver -- 司机
@@ -21,6 +32,9 @@ public class TbDriverService extends ServiceImpl<TbDriverMapper, TbDriver> imple
 	@Autowired
 	TbDriverMapper tbDriverMapper;
 
+	@Autowired
+	private MethodDriverService methodDriverService;
+
 	/** 增 */
 	void add(TbDriver t){
 		save(t);
@@ -46,6 +60,123 @@ public class TbDriverService extends ServiceImpl<TbDriverMapper, TbDriver> imple
 	List<TbDriver> getList(SoMap so) { 
 		return tbDriverMapper.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 = methodDriverService.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<TbDriver> selectedList = tbDriverMapper.selectList(new LambdaQueryWrapper<TbDriver>().eq(StringUtils.isNoneBlank(keyword), TbDriver::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(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("审核时间");
+
+		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("删除状态");
+
+		//遍历集合
+		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).getAge() + "").equals("null")? "": selectedList.get(i).getAge() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getSex() + "").equals("null")? "": selectedList.get(i).getSex() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getPhone() + "").equals("null")? "": selectedList.get(i).getPhone() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getBankCode() + "").equals("null")? "": selectedList.get(i).getBankCode() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getBankName() + "").equals("null")? "": selectedList.get(i).getBankName() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getIdCard() + "" ).equals("null")? "": selectedList.get(i).getIdCard() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getIdCardImg() + "").equals("null")? "": selectedList.get(i).getIdCardImg() + "");
+			sheetRow.createCell(10).setCellValue((selectedList.get(i).getDrivingLicenseId() + "").equals("null")? "": selectedList.get(i).getDrivingLicenseId() + "");
+			sheetRow.createCell(11).setCellValue((selectedList.get(i).getDrivingLicenseImg() + "").equals("null")? "": selectedList.get(i).getDrivingLicenseImg() + "");
+			sheetRow.createCell(12).setCellValue((selectedList.get(i).getVehicleDrivingId() + "").equals("null")? "": selectedList.get(i).getVehicleDrivingId() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getVehicleDrivingImg() + "").equals("null")? "": selectedList.get(i).getVehicleDrivingImg() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getRegisterTime() + "").equals("null")? "": selectedList.get(i).getRegisterTime() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getIsLock() + "").equals("null")? "": selectedList.get(i).getIsLock() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getNopassReason() + "").equals("null")? "": selectedList.get(i).getNopassReason() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getAuditStatus() + "").equals("null")? "": selectedList.get(i).getAuditStatus() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getAuditBy() + "").equals("null")? "": selectedList.get(i).getAuditBy() + "");
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getAuditTime() + "").equals("null")? "": selectedList.get(i).getAuditTime() + "");
+			//公共字段
+			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 "数据导出完成!";
+	}
 
 }

+ 98 - 98
sp-service/transport-server/src/main/java/com/pj/project/tb_driver/TbDriverUtil.java

@@ -1,98 +1,98 @@
-package com.pj.project.tb_driver;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-import java.util.*;
-
-/**
- * 工具类:tb_driver -- 司机
- * @author qzy 
- *
- */
-@Component
-public class TbDriverUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbDriverMapper tbDriverMapper;
-	@Autowired
-	private void setTbDriverMapper(TbDriverMapper tbDriverMapper) {
-		TbDriverUtil.tbDriverMapper = tbDriverMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbDriver 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbDriver t) {
-		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
-		AjaxError.throwByIsNull(t.getName(), "[姓名] 不能为空");		// 验证: 姓名 
-		AjaxError.throwByIsNull(t.getAge(), "[年龄] 不能为空");		// 验证: 年龄 
-		AjaxError.throwByIsNull(t.getSex(), "[性别性别] 不能为空");		// 验证: 性别性别(1=男,2=女) 
-		AjaxError.throwByIsNull(t.getPhone(), "[手机号] 不能为空");		// 验证: 手机号 
-		AjaxError.throwByIsNull(t.getAddress(), "[联系地址] 不能为空");		// 验证: 联系地址 
-		AjaxError.throwByIsNull(t.getBankCode(), "[银行卡号] 不能为空");		// 验证: 银行卡号 
-		AjaxError.throwByIsNull(t.getBankName(), "[银行名称] 不能为空");		// 验证: 银行名称 
-		AjaxError.throwByIsNull(t.getIdCard(), "[身份证号] 不能为空");		// 验证: 身份证号 
-		AjaxError.throwByIsNull(t.getIdCardImg(), "[身份证照片] 不能为空");		// 验证: 身份证照片 
-		AjaxError.throwByIsNull(t.getDrivingLicenseId(), "[驾驶证号] 不能为空");		// 验证: 驾驶证号 
-		AjaxError.throwByIsNull(t.getDrivingLicenseImg(), "[驾驶证照片] 不能为空");		// 验证: 驾驶证照片 
-		AjaxError.throwByIsNull(t.getVehicleDrivingId(), "[车辆行驶证号] 不能为空");		// 验证: 车辆行驶证号 
-		AjaxError.throwByIsNull(t.getVehicleDrivingImg(), "[车辆行驶证照片] 不能为空");		// 验证: 车辆行驶证照片 
-		AjaxError.throwByIsNull(t.getVehicleImg(), "[车辆前脸照] 不能为空");		// 验证: 车辆前脸照 
-		AjaxError.throwByIsNull(t.getRegisterTime(), "[注册时间] 不能为空");		// 验证: 注册时间 
-		AjaxError.throwByIsNull(t.getIsLock(), "[是否被锁定] 不能为空");		// 验证: 是否被锁定 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建者名称] 不能为空");		// 验证: 创建者名称 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getAuditStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=待审核,1=已通过,2=不通过) 
-		AjaxError.throwByIsNull(t.getAuditBy(), "[审核人] 不能为空");		// 验证: 审核人 
-		AjaxError.throwByIsNull(t.getAuditTime(), "[审核时间] 不能为空");		// 验证: 审核时间 
-		AjaxError.throwByIsNull(t.getNopassReason(), "[审核不通过原因] 不能为空");		// 验证: 审核不通过原因 
-	}
-
-	/** 
-	 * 获取一个TbDriver (方便复制代码用) [G] 
-	 */ 
-	static TbDriver getTbDriver() {
-		TbDriver t = new TbDriver();	// 声明对象 
-		t.setId(0L);		// 主键 
-		t.setName("");		// 姓名 
-		t.setAge(0);		// 年龄 
-		t.setSex("");		// 性别性别(1=男,2=女) 
-		t.setPhone("");		// 手机号 
-		t.setAddress("");		// 联系地址 
-		t.setBankCode("");		// 银行卡号 
-		t.setBankName("");		// 银行名称 
-		t.setIdCard("");		// 身份证号 
-		t.setIdCardImg("");		// 身份证照片 
-		t.setDrivingLicenseId("");		// 驾驶证号 
-		t.setDrivingLicenseImg("");		// 驾驶证照片 
-		t.setVehicleDrivingId("");		// 车辆行驶证号 
-		t.setVehicleDrivingImg("");		// 车辆行驶证照片 
-		t.setVehicleImg("");		// 车辆前脸照 
-		t.setRegisterTime("");		// 注册时间 
-		t.setIsLock("");		// 是否被锁定 
-		t.setCreateBy("");		// 创建者id 
-		t.setCreateName("");		// 创建者名称 
-		t.setCreateTime(new Date());		// 创建时间 
-		t.setUpdateBy("");		// 更新者id 
-		t.setUpdateName("");		// 更新者名称 
-		t.setUpdateTime(new Date());		// 更新时间 
-		t.setAuditStatus(0);		// 审核状态(0=待审核,1=已通过,2=不通过) 
-		t.setAuditBy("");		// 审核人 
-		t.setAuditTime("");		// 审核时间 
-		t.setNopassReason("");		// 审核不通过原因 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.project.tb_driver;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//import java.util.*;
+//
+///**
+// * 工具类:tb_driver -- 司机
+// * @author qzy
+// *
+// */
+//@Component
+//public class TbDriverUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbDriverMapper tbDriverMapper;
+//	@Autowired
+//	private void setTbDriverMapper(TbDriverMapper tbDriverMapper) {
+//		TbDriverUtil.tbDriverMapper = tbDriverMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbDriver 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbDriver t) {
+//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
+//		AjaxError.throwByIsNull(t.getName(), "[姓名] 不能为空");		// 验证: 姓名
+//		AjaxError.throwByIsNull(t.getAge(), "[年龄] 不能为空");		// 验证: 年龄
+//		AjaxError.throwByIsNull(t.getSex(), "[性别性别] 不能为空");		// 验证: 性别性别(1=男,2=女)
+//		AjaxError.throwByIsNull(t.getPhone(), "[手机号] 不能为空");		// 验证: 手机号
+//		AjaxError.throwByIsNull(t.getAddress(), "[联系地址] 不能为空");		// 验证: 联系地址
+//		AjaxError.throwByIsNull(t.getBankCode(), "[银行卡号] 不能为空");		// 验证: 银行卡号
+//		AjaxError.throwByIsNull(t.getBankName(), "[银行名称] 不能为空");		// 验证: 银行名称
+//		AjaxError.throwByIsNull(t.getIdCard(), "[身份证号] 不能为空");		// 验证: 身份证号
+//		AjaxError.throwByIsNull(t.getIdCardImg(), "[身份证照片] 不能为空");		// 验证: 身份证照片
+//		AjaxError.throwByIsNull(t.getDrivingLicenseId(), "[驾驶证号] 不能为空");		// 验证: 驾驶证号
+//		AjaxError.throwByIsNull(t.getDrivingLicenseImg(), "[驾驶证照片] 不能为空");		// 验证: 驾驶证照片
+//		AjaxError.throwByIsNull(t.getVehicleDrivingId(), "[车辆行驶证号] 不能为空");		// 验证: 车辆行驶证号
+//		AjaxError.throwByIsNull(t.getVehicleDrivingImg(), "[车辆行驶证照片] 不能为空");		// 验证: 车辆行驶证照片
+//		AjaxError.throwByIsNull(t.getVehicleImg(), "[车辆前脸照] 不能为空");		// 验证: 车辆前脸照
+//		AjaxError.throwByIsNull(t.getRegisterTime(), "[注册时间] 不能为空");		// 验证: 注册时间
+//		AjaxError.throwByIsNull(t.getIsLock(), "[是否被锁定] 不能为空");		// 验证: 是否被锁定
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建者名称] 不能为空");		// 验证: 创建者名称
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getAuditStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=待审核,1=已通过,2=不通过)
+//		AjaxError.throwByIsNull(t.getAuditBy(), "[审核人] 不能为空");		// 验证: 审核人
+//		AjaxError.throwByIsNull(t.getAuditTime(), "[审核时间] 不能为空");		// 验证: 审核时间
+//		AjaxError.throwByIsNull(t.getNopassReason(), "[审核不通过原因] 不能为空");		// 验证: 审核不通过原因
+//	}
+//
+//	/**
+//	 * 获取一个TbDriver (方便复制代码用) [G]
+//	 */
+//	static TbDriver getTbDriver() {
+//		TbDriver t = new TbDriver();	// 声明对象
+//		t.setId(0L);		// 主键
+//		t.setName("");		// 姓名
+//		t.setAge(0);		// 年龄
+//		t.setSex("");		// 性别性别(1=男,2=女)
+//		t.setPhone("");		// 手机号
+//		t.setAddress("");		// 联系地址
+//		t.setBankCode("");		// 银行卡号
+//		t.setBankName("");		// 银行名称
+//		t.setIdCard("");		// 身份证号
+//		t.setIdCardImg("");		// 身份证照片
+//		t.setDrivingLicenseId("");		// 驾驶证号
+//		t.setDrivingLicenseImg("");		// 驾驶证照片
+//		t.setVehicleDrivingId("");		// 车辆行驶证号
+//		t.setVehicleDrivingImg("");		// 车辆行驶证照片
+//		t.setVehicleImg("");		// 车辆前脸照
+//		t.setRegisterTime("");		// 注册时间
+//		t.setIsLock("");		// 是否被锁定
+//		t.setCreateBy("");		// 创建者id
+//		t.setCreateName("");		// 创建者名称
+//		t.setCreateTime(new Date());		// 创建时间
+//		t.setUpdateBy("");		// 更新者id
+//		t.setUpdateName("");		// 更新者名称
+//		t.setUpdateTime(new Date());		// 更新时间
+//		t.setAuditStatus(0);		// 审核状态(0=待审核,1=已通过,2=不通过)
+//		t.setAuditBy("");		// 审核人
+//		t.setAuditTime("");		// 审核时间
+//		t.setNopassReason("");		// 审核不通过原因
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}

+ 113 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/MethodVehicleService.java

@@ -0,0 +1,113 @@
+package com.pj.project.tb_vehicle;
+
+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 22 12 32
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodVehicleService {
+
+    @Autowired
+    private TbVehicleMapper tbVehicleMapper;
+
+    /**
+     * 方法抽取  导入
+     * @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);
+            //定义返回值实体
+            TbVehicle tbVehicle = new TbVehicle();
+            //解析数据
+            if(row.getCell(1) != null)
+                tbVehicle.setVehiclePlate(row.getCell(1).getStringCellValue());
+
+            if(row.getCell(2) != null)
+                tbVehicle.setOwner(row.getCell(2).getStringCellValue());
+
+            HSSFCell cell3 = row.getCell(3);
+            if (cell3 != null && (cell3.getCellType() == CellType.NUMERIC || cell3.getCellType() == CellType.FORMULA))
+                tbVehicle.setVehicleType((int) cell3.getNumericCellValue());
+
+            HSSFCell cell4 = row.getCell(4);
+            if (cell4 != null && (cell4.getCellType() == CellType.NUMERIC || cell4.getCellType() == CellType.FORMULA))
+                tbVehicle.setParentId((int) cell4.getNumericCellValue());
+
+            if(row.getCell(5) != null)
+                tbVehicle.setVehicleSize(row.getCell(5).getStringCellValue());
+
+            if(row.getCell(6) != null)
+                tbVehicle.setVehicleModel(row.getCell(6).getStringCellValue());
+
+            if(row.getCell(7) != null)
+                tbVehicle.setVehicleLoad(row.getCell(7).getStringCellValue());
+
+            if(row.getCell(8) != null)
+                tbVehicle.setVehicleWeight(row.getCell(8).getStringCellValue());
+
+            HSSFCell cell9 = row.getCell(9);
+            if (cell9 != null && (cell9.getCellType() == CellType.NUMERIC || cell9.getCellType() == CellType.FORMULA))
+                tbVehicle.setAuditStatus((int) cell9.getNumericCellValue());
+
+            if(row.getCell(10) != null)
+                tbVehicle.setAuditBy(row.getCell(10).getStringCellValue());
+
+            if(row.getCell(11) != null)
+                tbVehicle.setNopassReason(row.getCell(11).getStringCellValue());
+
+            HSSFCell cell12 = row.getCell(12);
+            if (cell12 != null && cell12.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell12)) {
+                tbVehicle.setAuditTime(cell12.getDateCellValue());
+            }
+
+
+
+            //公共字段
+            HSSFCell cell18 = row.getCell(13);
+            if (cell18 != null && cell18.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell18)) {
+                tbVehicle.setCreateTime(cell18.getDateCellValue());
+            }
+
+            if(row.getCell(14) != null && !row.getCell(14).toString().trim().equals(""))
+                tbVehicle.setCreateBy(row.getCell(14).getStringCellValue());
+
+            if(row.getCell(15) != null && !row.getCell(15).toString().trim().equals(""))
+                tbVehicle.setCreateName(row.getCell(15).getStringCellValue());
+
+            if(row.getCell(16) != null && !row.getCell(16).toString().trim().equals(""))
+                tbVehicle.setUpdateBy(row.getCell(16).getStringCellValue());
+
+            if(row.getCell(17) != null && !row.getCell(17).toString().trim().equals(""))
+                tbVehicle.setUpdateName(row.getCell(17).getStringCellValue());
+
+            HSSFCell cell27 = row.getCell(18);
+            if (cell27 != null && cell27.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell27)) {
+                tbVehicle.setUpdateTime(cell27.getDateCellValue());
+            }
+            //删除状态,默认可用
+            tbVehicle.setDeleteStatus(1);
+//			//添加到集合
+//			list.add(tbVehicle);
+            int insert = tbVehicleMapper.insert(tbVehicle);
+            count += insert;
+        }
+        return count;
+    }
+
+}

+ 5 - 2
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicle.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;
@@ -99,6 +100,7 @@ public class TbVehicle extends Model<TbVehicle> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date createTime;	
 
 	/**
@@ -119,7 +121,7 @@ public class TbVehicle extends Model<TbVehicle> implements Serializable {
 	/**
 	 * 删除状态 
 	 */
-	private String deleteStatus;	
+	private Integer deleteStatus;
 
 	/**
 	 * 审核状态(0=待审核,1=已通过,2=不通过) 
@@ -139,7 +141,8 @@ public class TbVehicle extends Model<TbVehicle> implements Serializable {
 	/**
 	 * 审核时间 
 	 */
-	private String auditTime;	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date auditTime;
 
 
 

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

@@ -1,5 +1,6 @@
 package com.pj.project.tb_vehicle;
 
+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,48 @@ public class TbVehicleController {
 		List<TbVehicle> list = tbVehicleService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
-	
-	
-	
-	
 
-	
-	
-	
+
+
+
+	/**
+	 * 数据导入接口
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping("vehicleImport")
+	@ResponseBody
+	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
+		try {
+			String importData = tbVehicleService.importData(file);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+	/**
+	 * 导出
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping("vehicleOutport")
+	@ResponseBody
+	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword){
+		try {
+			String importData = tbVehicleService.outportExcel(keyword);
+			AjaxJson.getSuccess(importData);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		return AjaxJson.getError();
+	}
+
+
+
+
+
+
 
 }

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

@@ -1,13 +1,25 @@
 package com.pj.project.tb_vehicle;
 
+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.project.tb_driver.TbDriver;
 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_vehicle -- 车辆
@@ -21,6 +33,9 @@ public class TbVehicleService extends ServiceImpl<TbVehicleMapper, TbVehicle> im
 	@Autowired
 	TbVehicleMapper tbVehicleMapper;
 
+	@Autowired
+	private MethodVehicleService methodVehicleService;
+
 	/** 增 */
 	void add(TbVehicle t){
 		save(t);
@@ -46,6 +61,108 @@ public class TbVehicleService extends ServiceImpl<TbVehicleMapper, TbVehicle> im
 	List<TbVehicle> getList(SoMap so) { 
 		return tbVehicleMapper.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 = methodVehicleService.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<TbVehicle> selectedList = tbVehicleMapper.selectList(new LambdaQueryWrapper<TbVehicle>().eq(StringUtils.isNoneBlank(keyword), TbVehicle::getOwner, 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("类型父id");
+		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("删除状态");
+
+		//遍历集合
+		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).getVehiclePlate() + "").equals("null")? "": selectedList.get(i).getVehiclePlate() + "");
+			sheetRow.createCell(2).setCellValue((selectedList.get(i).getOwner() + "").equals("null")? "": selectedList.get(i).getOwner() + "");
+			sheetRow.createCell(3).setCellValue((selectedList.get(i).getVehicleType() + "").equals("null")? "": selectedList.get(i).getVehicleType() + "");
+			sheetRow.createCell(4).setCellValue((selectedList.get(i).getParentId() + "").equals("null")? "": selectedList.get(i).getParentId() + "");
+			sheetRow.createCell(5).setCellValue((selectedList.get(i).getVehicleSize() + "").equals("null")? "": selectedList.get(i).getVehicleSize() + "");
+			sheetRow.createCell(6).setCellValue((selectedList.get(i).getVehicleModel() + "").equals("null")? "": selectedList.get(i).getVehicleModel() + "");
+			sheetRow.createCell(7).setCellValue((selectedList.get(i).getVehicleLoad() + "").equals("null")? "": selectedList.get(i).getVehicleLoad() + "");
+			sheetRow.createCell(8).setCellValue((selectedList.get(i).getVehicleWeight() + "" ).equals("null")? "": selectedList.get(i).getVehicleWeight() + "");
+			sheetRow.createCell(9).setCellValue((selectedList.get(i).getAuditStatus() + "").equals("null")? "": selectedList.get(i).getAuditStatus() + "");
+			sheetRow.createCell(10).setCellValue((selectedList.get(i).getAuditBy() + "").equals("null")? "": selectedList.get(i).getAuditBy() + "");
+			sheetRow.createCell(11).setCellValue((selectedList.get(i).getNopassReason() + "").equals("null")? "": selectedList.get(i).getNopassReason() + "");
+			sheetRow.createCell(12).setCellValue((selectedList.get(i).getAuditTime() + "").equals("null")? "": selectedList.get(i).getAuditTime() + "");
+			//公共字段
+			sheetRow.createCell(13).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
+			sheetRow.createCell(14).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
+			sheetRow.createCell(15).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
+			sheetRow.createCell(16).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
+			sheetRow.createCell(17).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
+			sheetRow.createCell(18).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
+			sheetRow.createCell(19).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 "数据导出完成!";
+	}
 }

+ 82 - 82
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleUtil.java

@@ -1,82 +1,82 @@
-package com.pj.project.tb_vehicle;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-import java.util.*;
-
-/**
- * 工具类:tb_vehicle -- 车辆
- * @author loovi 
- *
- */
-@Component
-public class TbVehicleUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static TbVehicleMapper tbVehicleMapper;
-	@Autowired
-	private void setTbVehicleMapper(TbVehicleMapper tbVehicleMapper) {
-		TbVehicleUtil.tbVehicleMapper = tbVehicleMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 TbVehicle 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(TbVehicle t) {
-		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
-		AjaxError.throwByIsNull(t.getVehiclePlate(), "[车牌] 不能为空");		// 验证: 车牌 
-		AjaxError.throwByIsNull(t.getOwner(), "[所有人] 不能为空");		// 验证: 所有人 
-		AjaxError.throwByIsNull(t.getVehicleType(), "[车辆类型] 不能为空");		// 验证: 车辆类型 
-		AjaxError.throwByIsNull(t.getParentId(), "[类型父id] 不能为空");		// 验证: 类型父id 
-		AjaxError.throwByIsNull(t.getVehicleSize(), "[车辆尺寸] 不能为空");		// 验证: 车辆尺寸 
-		AjaxError.throwByIsNull(t.getVehicleModel(), "[车辆品牌型号] 不能为空");		// 验证: 车辆品牌型号 
-		AjaxError.throwByIsNull(t.getVehicleLoad(), "[核定载质量] 不能为空");		// 验证: 核定载质量 
-		AjaxError.throwByIsNull(t.getVehicleWeight(), "[车辆自重] 不能为空");		// 验证: 车辆自重 
-		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id 
-		AjaxError.throwByIsNull(t.getCreateName(), "[创建者姓名] 不能为空");		// 验证: 创建者姓名 
-		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
-		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id 
-		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称 
-		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
-		AjaxError.throwByIsNull(t.getAuditStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=待审核,1=已通过,2=不通过) 
-		AjaxError.throwByIsNull(t.getAuditBy(), "[审核人] 不能为空");		// 验证: 审核人 
-		AjaxError.throwByIsNull(t.getNopassReason(), "[审核不通过原因] 不能为空");		// 验证: 审核不通过原因 
-		AjaxError.throwByIsNull(t.getAuditTime(), "[审核时间] 不能为空");		// 验证: 审核时间 
-	}
-
-	/** 
-	 * 获取一个TbVehicle (方便复制代码用) [G] 
-	 */ 
-	static TbVehicle getTbVehicle() {
-		TbVehicle t = new TbVehicle();	// 声明对象 
-		t.setId(0L);		// 主键 
-		t.setVehiclePlate("");		// 车牌 
-		t.setOwner("");		// 所有人 
-		t.setVehicleType(0);		// 车辆类型 
-		t.setParentId(0);		// 类型父id 
-		t.setVehicleSize("");		// 车辆尺寸 
-		t.setVehicleModel("");		// 车辆品牌型号 
-		t.setVehicleLoad("");		// 核定载质量 
-		t.setVehicleWeight("");		// 车辆自重 
-		t.setCreateBy("");		// 创建者id 
-		t.setCreateName("");		// 创建者姓名 
-		t.setCreateTime(new Date());		// 创建时间 
-		t.setUpdateBy("");		// 更新者id 
-		t.setUpdateName("");		// 更新者名称 
-		t.setUpdateTime(new Date());		// 更新时间 
-		t.setAuditStatus(0);		// 审核状态(0=待审核,1=已通过,2=不通过) 
-		t.setAuditBy("");		// 审核人 
-		t.setNopassReason("");		// 审核不通过原因 
-		t.setAuditTime("");		// 审核时间 
-		return t;
-	}
-	
-	
-	
-	
-	
-}
+//package com.pj.project.tb_vehicle;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import com.pj.utils.sg.*;
+//import java.util.*;
+//
+///**
+// * 工具类:tb_vehicle -- 车辆
+// * @author loovi
+// *
+// */
+//@Component
+//public class TbVehicleUtil {
+//
+//
+//	/** 底层 Mapper 对象 */
+//	public static TbVehicleMapper tbVehicleMapper;
+//	@Autowired
+//	private void setTbVehicleMapper(TbVehicleMapper tbVehicleMapper) {
+//		TbVehicleUtil.tbVehicleMapper = tbVehicleMapper;
+//	}
+//
+//
+//	/**
+//	 * 将一个 TbVehicle 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
+//	 */
+//	static void check(TbVehicle t) {
+//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
+//		AjaxError.throwByIsNull(t.getVehiclePlate(), "[车牌] 不能为空");		// 验证: 车牌
+//		AjaxError.throwByIsNull(t.getOwner(), "[所有人] 不能为空");		// 验证: 所有人
+//		AjaxError.throwByIsNull(t.getVehicleType(), "[车辆类型] 不能为空");		// 验证: 车辆类型
+//		AjaxError.throwByIsNull(t.getParentId(), "[类型父id] 不能为空");		// 验证: 类型父id
+//		AjaxError.throwByIsNull(t.getVehicleSize(), "[车辆尺寸] 不能为空");		// 验证: 车辆尺寸
+//		AjaxError.throwByIsNull(t.getVehicleModel(), "[车辆品牌型号] 不能为空");		// 验证: 车辆品牌型号
+//		AjaxError.throwByIsNull(t.getVehicleLoad(), "[核定载质量] 不能为空");		// 验证: 核定载质量
+//		AjaxError.throwByIsNull(t.getVehicleWeight(), "[车辆自重] 不能为空");		// 验证: 车辆自重
+//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id
+//		AjaxError.throwByIsNull(t.getCreateName(), "[创建者姓名] 不能为空");		// 验证: 创建者姓名
+//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
+//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id
+//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称
+//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
+//		AjaxError.throwByIsNull(t.getAuditStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=待审核,1=已通过,2=不通过)
+//		AjaxError.throwByIsNull(t.getAuditBy(), "[审核人] 不能为空");		// 验证: 审核人
+//		AjaxError.throwByIsNull(t.getNopassReason(), "[审核不通过原因] 不能为空");		// 验证: 审核不通过原因
+//		AjaxError.throwByIsNull(t.getAuditTime(), "[审核时间] 不能为空");		// 验证: 审核时间
+//	}
+//
+//	/**
+//	 * 获取一个TbVehicle (方便复制代码用) [G]
+//	 */
+//	static TbVehicle getTbVehicle() {
+//		TbVehicle t = new TbVehicle();	// 声明对象
+//		t.setId(0L);		// 主键
+//		t.setVehiclePlate("");		// 车牌
+//		t.setOwner("");		// 所有人
+//		t.setVehicleType(0);		// 车辆类型
+//		t.setParentId(0);		// 类型父id
+//		t.setVehicleSize("");		// 车辆尺寸
+//		t.setVehicleModel("");		// 车辆品牌型号
+//		t.setVehicleLoad("");		// 核定载质量
+//		t.setVehicleWeight("");		// 车辆自重
+//		t.setCreateBy("");		// 创建者id
+//		t.setCreateName("");		// 创建者姓名
+//		t.setCreateTime(new Date());		// 创建时间
+//		t.setUpdateBy("");		// 更新者id
+//		t.setUpdateName("");		// 更新者名称
+//		t.setUpdateTime(new Date());		// 更新时间
+//		t.setAuditStatus(0);		// 审核状态(0=待审核,1=已通过,2=不通过)
+//		t.setAuditBy("");		// 审核人
+//		t.setNopassReason("");		// 审核不通过原因
+//		t.setAuditTime("");		// 审核时间
+//		return t;
+//	}
+//
+//
+//
+//
+//
+//}