ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLargeKeyGridUserController.java
@@ -13,6 +13,7 @@ import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.WebUtils; import com.ruoyi.system.export.LargeKeyGridPointUserImport; import com.ruoyi.system.export.LargeKeyGridUserImport; import com.ruoyi.system.model.TLargeKeyGridUser; import com.ruoyi.system.model.TLargeKeyPersonnelType; @@ -140,7 +141,7 @@ return R.ok(largeKeyGridUserService.removeByIds(ids)); } @ApiOperation(value = "重点人员-网格人员导入模板下载") @ApiOperation(value = "网格人员导入模板下载") @GetMapping("/import-template") public void importTemplate() { List<LargeKeyGridUserImport> largeLargeKeyGridUserImports = new ArrayList<>(); @@ -150,7 +151,7 @@ HttpServletResponse response = WebUtils.response(); ServletOutputStream outputStream = null; try { String fileName = URLEncoder.encode("重点人员-网格人员信息导入模板.xls", "utf-8"); String fileName = URLEncoder.encode("网格人员信息导入模板.xls", "utf-8"); response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("Pragma", "no-cache"); @@ -159,7 +160,35 @@ workbook.write(outputStream); } catch (IOException e) { e.printStackTrace(); System.out.println("重点人员-网格人员导入模板下载失败!"); System.out.println("网格人员导入模板下载失败!"); } finally { try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } @ApiOperation(value = "重点人员导入模板下载") @GetMapping("/import-point-template") public void importPointTemplate() { List<LargeKeyGridPointUserImport> largeKeyGridPointUserImports = new ArrayList<>(); LargeKeyGridPointUserImport largeKeyGridPointUserImport = new LargeKeyGridPointUserImport(); largeKeyGridPointUserImports.add(largeKeyGridPointUserImport); Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), LargeKeyGridPointUserImport.class, largeKeyGridPointUserImports); HttpServletResponse response = WebUtils.response(); ServletOutputStream outputStream = null; try { String fileName = URLEncoder.encode("重点人员信息导入模板.xls", "utf-8"); response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); outputStream = response.getOutputStream(); workbook.write(outputStream); } catch (IOException e) { e.printStackTrace(); System.out.println("重点人员导入模板下载失败!"); } finally { try { outputStream.close(); @@ -337,6 +366,11 @@ i++; continue; } if (!StringUtils.hasLength(largeKeyGridUserImport.getRegisteredResidence())){ result.append("第"+i+"行:[", "户籍地"+"]不能为空"); i++; continue; } if (!StringUtils.hasLength(largeKeyGridUserImport.getBuildingInfo())){ result.append("第"+i+"行:[", "楼栋信息"+"]不能为空"); i++; ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLargeVolunteerController.java
@@ -218,21 +218,21 @@ i++; continue; } if (!StringUtils.hasLength(largeVolunteerImport.getRegisterDateStr())){ result.append("第"+i+"行:[", "注册日期"+"]不能为空"); i++; continue; } // if (!StringUtils.hasLength(largeVolunteerImport.getRegisterDateStr())){ // result.append("第"+i+"行:[", "注册日期"+"]不能为空"); // i++; // continue; // } if (Objects.isNull(largeVolunteerImport.getTotalServiceDuration())){ result.append("第"+i+"行:[", "总服务时长"+"]不能为空"); i++; continue; } if (!StringUtils.hasLength(largeVolunteerImport.getJoinTeamDateStr())){ result.append("第"+i+"行:[", "加入队伍时间"+"]不能为空"); i++; continue; } // if (!StringUtils.hasLength(largeVolunteerImport.getJoinTeamDateStr())){ // result.append("第"+i+"行:[", "加入队伍时间"+"]不能为空"); // i++; // continue; // } TLargeVolunteer largeVolunteer = new TLargeVolunteer(); BeanUtils.copyProperties(largeVolunteerImport, largeVolunteer); @@ -255,20 +255,20 @@ i++; continue; } try{ largeVolunteer.setRegisterDate(DateUtils.stringToLocalDateTime(largeVolunteerImport.getRegisterDateStr())); }catch (Exception e){ result.append("第"+i+"行:[", "注册日期"+"]格式错误"); i++; continue; } try{ largeVolunteer.setJoinTeamDate(DateUtils.stringToLocalDateTime(largeVolunteerImport.getJoinTeamDateStr())); }catch (Exception e){ result.append("第"+i+"行:[", "加入队伍时间"+"]格式错误"); i++; continue; } // try{ // largeVolunteer.setRegisterDate(DateUtils.stringToLocalDateTime(largeVolunteerImport.getRegisterDateStr())); // }catch (Exception e){ // result.append("第"+i+"行:[", "注册日期"+"]格式错误"); // i++; // continue; // } // try{ // largeVolunteer.setJoinTeamDate(DateUtils.stringToLocalDateTime(largeVolunteerImport.getJoinTeamDateStr())); // }catch (Exception e){ // result.append("第"+i+"行:[", "加入队伍时间"+"]格式错误"); // i++; // continue; // } largeVolunteers.add(largeVolunteer); i++; } ruoyi-system/src/main/java/com/ruoyi/system/export/LargeKeyGridPointUserImport.java
New file @@ -0,0 +1,49 @@ package com.ruoyi.system.export; import cn.afterturn.easypoi.excel.annotation.Excel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @Data @ApiModel(value = "重点人员导入对象LargeKeyGridUserImport") public class LargeKeyGridPointUserImport implements Serializable { @Excel(name = "网格", width = 20) private String gridInfo; @Excel(name = "小区名称(居住地)", width = 20) private String communityName; @Excel(name = "楼栋信息", width = 20) private String buildingInfo; @Excel(name = "单元号", width = 20) private String unitNumber; @Excel(name = "门牌号", width = 20) private String houseNumber; @Excel(name = "姓名", width = 20) private String userName; @Excel(name = "性别[男|女]", width = 20) private String userSexStr; private Integer userSex; @Excel(name = "身份证号", width = 20) private String idCard; @Excel(name = "联系电话", width = 20) private String contactNumber; @Excel(name = "类型名称", width = 20) private String typeName; private String typeId; @ApiModelProperty(name = "人员类型 1=重点人员,2=网格人员]") private Integer userType; } ruoyi-system/src/main/java/com/ruoyi/system/export/LargeKeyGridUserImport.java
@@ -14,7 +14,7 @@ @Excel(name = "网格", width = 20) private String gridInfo; @Excel(name = "小区名称", width = 20) @Excel(name = "小区名称(居住地)", width = 20) private String communityName; @Excel(name = "楼栋信息", width = 20) @@ -26,6 +26,9 @@ @Excel(name = "门牌号", width = 20) private String houseNumber; @Excel(name = "户籍地") private String registeredResidence; @Excel(name = "姓名", width = 20) private String userName; ruoyi-system/src/main/java/com/ruoyi/system/export/LargeVolunteerImport.java
@@ -30,14 +30,14 @@ @Excel(name = "服务区域", width = 20) private String serviceArea; @Excel(name = "注册日期[yyyy-mm-dd hh:mm:ss]", width = 20) // @Excel(name = "注册日期[yyyy-mm-dd hh:mm:ss]", width = 20) private String registerDateStr; private LocalDateTime registerDate; @Excel(name = "总服务时长", width = 20) private BigDecimal totalServiceDuration; @Excel(name = "加入队伍时间[yyyy-mm-dd hh:mm:ss]", width = 20) // @Excel(name = "加入队伍时间[yyyy-mm-dd hh:mm:ss]", width = 20) private String joinTeamDateStr; private LocalDateTime joinTeamDate; ruoyi-system/src/main/java/com/ruoyi/system/model/TLargeKeyGridUser.java
@@ -37,7 +37,7 @@ private String gridInfo; @Length(max = 40,message = "小区名称不能超过40个字符") @ApiModelProperty(value = "小区名称") @ApiModelProperty(value = "小区名称(居住地)") @TableField("community_name") private String communityName;