员工代码
This commit is contained in:
@@ -8,13 +8,14 @@ import com.ruoyi.common.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.page.TableSupport;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.dpc.domain.DpcEmployee;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeAddDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeEditDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeQueryDTO;
|
||||
import com.ruoyi.dpc.domain.excel.DpcEmployeeExcel;
|
||||
import com.ruoyi.dpc.domain.vo.DpcEmployeeVO;
|
||||
import com.ruoyi.dpc.service.IDpcEmployeeService;
|
||||
import com.ruoyi.dpc.utils.EasyExcelUtil;
|
||||
import com.ruoyi.dpc.utils.handler.EmployeeStatusSheetWriteHandler;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -49,7 +50,7 @@ public class DpcEmployeeController extends BaseController {
|
||||
public TableDataInfo list(DpcEmployeeQueryDTO queryDTO) {
|
||||
// 使用MyBatis Plus分页
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Page<DpcEmployee> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||
Page<DpcEmployeeVO> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||
Page<DpcEmployeeVO> result = employeeService.selectEmployeePage(page, queryDTO);
|
||||
return getDataTable(result.getRecords(), result.getTotal());
|
||||
}
|
||||
@@ -62,9 +63,8 @@ public class DpcEmployeeController extends BaseController {
|
||||
@Log(title = "员工信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DpcEmployeeQueryDTO queryDTO) {
|
||||
List<DpcEmployee> list = employeeService.selectEmployeeListForExport(queryDTO);
|
||||
ExcelUtil<DpcEmployee> util = new ExcelUtil<>(DpcEmployee.class);
|
||||
util.exportExcel(response, list, "员工信息数据");
|
||||
List<DpcEmployeeExcel> list = employeeService.selectEmployeeListForExport(queryDTO);
|
||||
EasyExcelUtil.exportExcel(response, list, DpcEmployeeExcel.class, "员工信息");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +116,7 @@ public class DpcEmployeeController extends BaseController {
|
||||
@Operation(summary = "下载导入模板")
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil<DpcEmployee> util = new ExcelUtil<>(DpcEmployee.class);
|
||||
util.importTemplateExcel(response, "员工信息数据");
|
||||
EasyExcelUtil.importTemplateExcel(response, DpcEmployeeExcel.class, "员工信息", new EmployeeStatusSheetWriteHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,27 +127,8 @@ public class DpcEmployeeController extends BaseController {
|
||||
@Log(title = "员工信息", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelUtil<DpcEmployee> util = new ExcelUtil<>(DpcEmployee.class);
|
||||
List<DpcEmployee> list = util.importExcel(file.getInputStream());
|
||||
List<DpcEmployeeAddDTO> addDTOList = convertToAddDTOList(list);
|
||||
String message = employeeService.importEmployee(addDTOList, updateSupport);
|
||||
List<DpcEmployeeExcel> list = EasyExcelUtil.importExcel(file.getInputStream(), DpcEmployeeExcel.class);
|
||||
String message = employeeService.importEmployee(list, updateSupport);
|
||||
return success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为AddDTO列表
|
||||
*/
|
||||
private List<DpcEmployeeAddDTO> convertToAddDTOList(List<DpcEmployee> list) {
|
||||
return list.stream().map(entity -> {
|
||||
DpcEmployeeAddDTO dto = new DpcEmployeeAddDTO();
|
||||
dto.setName(entity.getName());
|
||||
dto.setTellerNo(entity.getTellerNo());
|
||||
dto.setDeptId(entity.getDeptId());
|
||||
dto.setIdCard(entity.getIdCard());
|
||||
dto.setPhone(entity.getPhone());
|
||||
dto.setHireDate(entity.getHireDate());
|
||||
dto.setStatus(entity.getStatus());
|
||||
return dto;
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,14 @@ import com.ruoyi.common.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.page.TableSupport;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.dpc.domain.DpcIntermediaryBlacklist;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistAddDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistEditDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistQueryDTO;
|
||||
import com.ruoyi.dpc.domain.excel.DpcIntermediaryBlacklistExcel;
|
||||
import com.ruoyi.dpc.domain.vo.DpcIntermediaryBlacklistVO;
|
||||
import com.ruoyi.dpc.service.IDpcIntermediaryBlacklistService;
|
||||
import com.ruoyi.dpc.utils.EasyExcelUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -62,9 +63,8 @@ public class DpcIntermediaryBlacklistController extends BaseController {
|
||||
@Log(title = "中介黑名单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DpcIntermediaryBlacklistQueryDTO queryDTO) {
|
||||
List<DpcIntermediaryBlacklist> list = intermediaryService.selectIntermediaryListForExport(queryDTO);
|
||||
ExcelUtil<DpcIntermediaryBlacklist> util = new ExcelUtil<>(DpcIntermediaryBlacklist.class);
|
||||
util.exportExcel(response, list, "中介黑名单数据");
|
||||
List<DpcIntermediaryBlacklistExcel> list = intermediaryService.selectIntermediaryListForExport(queryDTO);
|
||||
EasyExcelUtil.exportExcel(response, list, DpcIntermediaryBlacklistExcel.class, "中介黑名单");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +116,7 @@ public class DpcIntermediaryBlacklistController extends BaseController {
|
||||
@Operation(summary = "下载导入模板")
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil<DpcIntermediaryBlacklist> util = new ExcelUtil<>(DpcIntermediaryBlacklist.class);
|
||||
util.importTemplateExcel(response, "中介黑名单数据");
|
||||
EasyExcelUtil.importTemplateExcel(response, DpcIntermediaryBlacklistExcel.class, "中介黑名单");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,25 +127,8 @@ public class DpcIntermediaryBlacklistController extends BaseController {
|
||||
@Log(title = "中介黑名单", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelUtil<DpcIntermediaryBlacklist> util = new ExcelUtil<>(DpcIntermediaryBlacklist.class);
|
||||
List<DpcIntermediaryBlacklist> list = util.importExcel(file.getInputStream());
|
||||
List<DpcIntermediaryBlacklistAddDTO> addDTOList = convertToAddDTOList(list);
|
||||
String message = intermediaryService.importIntermediary(addDTOList, updateSupport);
|
||||
List<DpcIntermediaryBlacklistExcel> list = EasyExcelUtil.importExcel(file.getInputStream(), DpcIntermediaryBlacklistExcel.class);
|
||||
String message = intermediaryService.importIntermediary(list, updateSupport);
|
||||
return success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为AddDTO列表
|
||||
*/
|
||||
private List<DpcIntermediaryBlacklistAddDTO> convertToAddDTOList(List<DpcIntermediaryBlacklist> list) {
|
||||
return list.stream().map(entity -> {
|
||||
DpcIntermediaryBlacklistAddDTO dto = new DpcIntermediaryBlacklistAddDTO();
|
||||
dto.setName(entity.getName());
|
||||
dto.setCertificateNo(entity.getCertificateNo());
|
||||
dto.setIntermediaryType(entity.getIntermediaryType());
|
||||
dto.setStatus(entity.getStatus());
|
||||
dto.setRemark(entity.getRemark());
|
||||
return dto;
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -28,31 +27,24 @@ public class DpcEmployee implements Serializable {
|
||||
private Long employeeId;
|
||||
|
||||
/** 姓名 */
|
||||
@Excel(name = "姓名")
|
||||
private String name;
|
||||
|
||||
/** 柜员号 */
|
||||
@Excel(name = "柜员号")
|
||||
private String tellerNo;
|
||||
|
||||
/** 所属部门ID */
|
||||
@Excel(name = "所属部门ID")
|
||||
private Long deptId;
|
||||
|
||||
/** 身份证号 */
|
||||
@Excel(name = "身份证号")
|
||||
private String idCard;
|
||||
|
||||
/** 电话 */
|
||||
@Excel(name = "电话")
|
||||
private String phone;
|
||||
|
||||
/** 入职时间 */
|
||||
@Excel(name = "入职时间", dateFormat = "yyyy-MM-dd")
|
||||
private Date hireDate;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态", readConverterExp = "0=在职,1=离职")
|
||||
private String status;
|
||||
|
||||
/** 创建者 */
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -31,19 +30,15 @@ public class DpcEmployeeRelative implements Serializable {
|
||||
private Long employeeId;
|
||||
|
||||
/** 亲属姓名 */
|
||||
@Excel(name = "亲属姓名")
|
||||
private String relativeName;
|
||||
|
||||
/** 亲属身份证号 */
|
||||
@Excel(name = "亲属身份证号")
|
||||
private String relativeIdCard;
|
||||
|
||||
/** 亲属手机号 */
|
||||
@Excel(name = "亲属手机号")
|
||||
private String relativePhone;
|
||||
|
||||
/** 与员工关系 */
|
||||
@Excel(name = "与员工关系")
|
||||
private String relationship;
|
||||
|
||||
/** 创建者 */
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -28,23 +27,18 @@ public class DpcIntermediaryBlacklist implements Serializable {
|
||||
private Long intermediaryId;
|
||||
|
||||
/** 姓名/机构名称 */
|
||||
@Excel(name = "姓名/机构名称")
|
||||
private String name;
|
||||
|
||||
/** 证件号 */
|
||||
@Excel(name = "证件号")
|
||||
private String certificateNo;
|
||||
|
||||
/** 中介类型 */
|
||||
@Excel(name = "中介类型", readConverterExp = "1=个人,2=机构")
|
||||
private String intermediaryType;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
/** 创建者 */
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.dpc.domain.dto;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -24,38 +23,31 @@ public class DpcEmployeeAddDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 姓名 */
|
||||
@Excel(name = "姓名")
|
||||
@NotBlank(message = "姓名不能为空")
|
||||
@Size(max = 100, message = "姓名长度不能超过100个字符")
|
||||
private String name;
|
||||
|
||||
/** 柜员号 */
|
||||
@Excel(name = "柜员号")
|
||||
@NotBlank(message = "柜员号不能为空")
|
||||
@Size(max = 50, message = "柜员号长度不能超过50个字符")
|
||||
private String tellerNo;
|
||||
|
||||
/** 所属部门ID */
|
||||
@Excel(name = "所属部门ID")
|
||||
private Long deptId;
|
||||
|
||||
/** 身份证号 */
|
||||
@Excel(name = "身份证号")
|
||||
@NotBlank(message = "身份证号不能为空")
|
||||
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$", message = "身份证号格式不正确")
|
||||
private String idCard;
|
||||
|
||||
/** 电话 */
|
||||
@Excel(name = "电话")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "电话格式不正确")
|
||||
private String phone;
|
||||
|
||||
/** 入职时间 */
|
||||
@Excel(name = "入职时间", dateFormat = "yyyy-MM-dd")
|
||||
private Date hireDate;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态", readConverterExp = "0=在职,1=离职")
|
||||
@NotBlank(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.dpc.domain.dto;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -28,35 +27,28 @@ public class DpcEmployeeEditDTO implements Serializable {
|
||||
private Long employeeId;
|
||||
|
||||
/** 姓名 */
|
||||
@Excel(name = "姓名")
|
||||
@Size(max = 100, message = "姓名长度不能超过100个字符")
|
||||
private String name;
|
||||
|
||||
/** 柜员号 */
|
||||
@Excel(name = "柜员号")
|
||||
@Size(max = 50, message = "柜员号长度不能超过50个字符")
|
||||
private String tellerNo;
|
||||
|
||||
/** 所属部门ID */
|
||||
@Excel(name = "所属部门ID")
|
||||
private Long deptId;
|
||||
|
||||
/** 身份证号 */
|
||||
@Excel(name = "身份证号")
|
||||
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$", message = "身份证号格式不正确")
|
||||
private String idCard;
|
||||
|
||||
/** 电话 */
|
||||
@Excel(name = "电话")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "电话格式不正确")
|
||||
private String phone;
|
||||
|
||||
/** 入职时间 */
|
||||
@Excel(name = "入职时间", dateFormat = "yyyy-MM-dd")
|
||||
private Date hireDate;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态", readConverterExp = "0=在职,1=离职")
|
||||
private String status;
|
||||
|
||||
/** 亲属列表 */
|
||||
|
||||
@@ -26,7 +26,7 @@ public class DpcEmployeeQueryDTO implements Serializable {
|
||||
/** 所属部门ID */
|
||||
private Long deptId;
|
||||
|
||||
/** 身份证号(精确查询) */
|
||||
/** 身份证号(模糊查询) */
|
||||
private String idCard;
|
||||
|
||||
/** 状态 */
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.dpc.domain.dto;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -22,23 +21,19 @@ public class DpcEmployeeRelativeAddDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 亲属姓名 */
|
||||
@Excel(name = "亲属姓名")
|
||||
@NotBlank(message = "亲属姓名不能为空")
|
||||
@Size(max = 100, message = "亲属姓名长度不能超过100个字符")
|
||||
private String relativeName;
|
||||
|
||||
/** 亲属身份证号 */
|
||||
@Excel(name = "亲属身份证号")
|
||||
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$", message = "亲属身份证号格式不正确")
|
||||
private String relativeIdCard;
|
||||
|
||||
/** 亲属手机号 */
|
||||
@Excel(name = "亲属手机号")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "亲属手机号格式不正确")
|
||||
private String relativePhone;
|
||||
|
||||
/** 与员工关系 */
|
||||
@Excel(name = "与员工关系")
|
||||
@NotBlank(message = "与员工关系不能为空")
|
||||
@Size(max = 50, message = "与员工关系长度不能超过50个字符")
|
||||
private String relationship;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.dpc.domain.dto;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
@@ -19,28 +18,23 @@ public class DpcIntermediaryBlacklistAddDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 姓名/机构名称 */
|
||||
@Excel(name = "姓名/机构名称")
|
||||
@NotBlank(message = "姓名/机构名称不能为空")
|
||||
@Size(min = 1, max = 100, message = "姓名/机构名称长度不能超过100个字符")
|
||||
private String name;
|
||||
|
||||
/** 证件号 */
|
||||
@Excel(name = "证件号")
|
||||
@Size(max = 50, message = "证件号长度不能超过50个字符")
|
||||
private String certificateNo;
|
||||
|
||||
/** 中介类型 */
|
||||
@Excel(name = "中介类型", readConverterExp = "1=个人,2=机构")
|
||||
@NotBlank(message = "中介类型不能为空")
|
||||
private String intermediaryType;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
@NotBlank(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
@Size(max = 500, message = "备注长度不能超过500个字符")
|
||||
private String remark;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.dpc.domain.dto;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -24,28 +23,23 @@ public class DpcIntermediaryBlacklistEditDTO implements Serializable {
|
||||
private Long intermediaryId;
|
||||
|
||||
/** 姓名/机构名称 */
|
||||
@Excel(name = "姓名/机构名称")
|
||||
@NotBlank(message = "姓名/机构名称不能为空")
|
||||
@Size(min = 1, max = 100, message = "姓名/机构名称长度不能超过100个字符")
|
||||
private String name;
|
||||
|
||||
/** 证件号 */
|
||||
@Excel(name = "证件号")
|
||||
@Size(max = 50, message = "证件号长度不能超过50个字符")
|
||||
private String certificateNo;
|
||||
|
||||
/** 中介类型 */
|
||||
@Excel(name = "中介类型", readConverterExp = "1=个人,2=机构")
|
||||
@NotBlank(message = "中介类型不能为空")
|
||||
private String intermediaryType;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
@NotBlank(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
@Size(max = 500, message = "备注长度不能超过500个字符")
|
||||
private String remark;
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.ruoyi.dpc.domain.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.ruoyi.dpc.utils.converter.EmployeeStatusConverter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工信息Excel导入导出对象
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-28
|
||||
*/
|
||||
@Data
|
||||
public class DpcEmployeeExcel implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 姓名 */
|
||||
@ExcelProperty(value = "姓名", index = 0)
|
||||
@ColumnWidth(15)
|
||||
private String name;
|
||||
|
||||
/** 柜员号 */
|
||||
@ExcelProperty(value = "柜员号", index = 1)
|
||||
@ColumnWidth(15)
|
||||
private String tellerNo;
|
||||
|
||||
/** 所属部门ID */
|
||||
@ExcelProperty(value = "所属部门ID", index = 2)
|
||||
@ColumnWidth(15)
|
||||
private Long deptId;
|
||||
|
||||
/** 身份证号 */
|
||||
@ExcelProperty(value = "身份证号", index = 3)
|
||||
@ColumnWidth(20)
|
||||
private String idCard;
|
||||
|
||||
/** 电话 */
|
||||
@ExcelProperty(value = "电话", index = 4)
|
||||
@ColumnWidth(15)
|
||||
private String phone;
|
||||
|
||||
/** 入职时间 */
|
||||
@ExcelProperty(value = "入职时间", index = 5)
|
||||
@ColumnWidth(15)
|
||||
private Date hireDate;
|
||||
|
||||
/** 状态 */
|
||||
@ExcelProperty(value = "状态", converter = EmployeeStatusConverter.class, index = 6)
|
||||
@ColumnWidth(10)
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ruoyi.dpc.domain.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 员工亲属Excel导入导出对象
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-28
|
||||
*/
|
||||
@Data
|
||||
public class DpcEmployeeRelativeExcel implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 亲属姓名 */
|
||||
@ExcelProperty(value = "亲属姓名", index = 0)
|
||||
@ColumnWidth(15)
|
||||
private String relativeName;
|
||||
|
||||
/** 亲属身份证号 */
|
||||
@ExcelProperty(value = "亲属身份证号", index = 1)
|
||||
@ColumnWidth(20)
|
||||
private String relativeIdCard;
|
||||
|
||||
/** 亲属手机号 */
|
||||
@ExcelProperty(value = "亲属手机号", index = 2)
|
||||
@ColumnWidth(15)
|
||||
private String relativePhone;
|
||||
|
||||
/** 与员工关系 */
|
||||
@ExcelProperty(value = "与员工关系", index = 3)
|
||||
@ColumnWidth(15)
|
||||
private String relationship;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.ruoyi.dpc.domain.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.ruoyi.dpc.utils.converter.IntermediaryStatusConverter;
|
||||
import com.ruoyi.dpc.utils.converter.IntermediaryTypeConverter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 中介人员黑名单Excel导入导出对象
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-27
|
||||
*/
|
||||
@Data
|
||||
public class DpcIntermediaryBlacklistExcel implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 姓名/机构名称 */
|
||||
@ExcelProperty(value = "姓名/机构名称", index = 0)
|
||||
@ColumnWidth(20)
|
||||
private String name;
|
||||
|
||||
/** 证件号 */
|
||||
@ExcelProperty(value = "证件号", index = 1)
|
||||
@ColumnWidth(20)
|
||||
private String certificateNo;
|
||||
|
||||
/** 中介类型 */
|
||||
@ExcelProperty(value = "中介类型", converter = IntermediaryTypeConverter.class, index = 2)
|
||||
@ColumnWidth(15)
|
||||
private String intermediaryType;
|
||||
|
||||
/** 状态 */
|
||||
@ExcelProperty(value = "状态", converter = IntermediaryStatusConverter.class, index = 3)
|
||||
@ColumnWidth(10)
|
||||
private String status;
|
||||
|
||||
/** 备注 */
|
||||
@ExcelProperty(value = "备注", index = 4)
|
||||
@ColumnWidth(30)
|
||||
private String remark;
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.ruoyi.dpc.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.dpc.domain.DpcEmployee;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeAddDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeEditDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeQueryDTO;
|
||||
import com.ruoyi.dpc.domain.excel.DpcEmployeeExcel;
|
||||
import com.ruoyi.dpc.domain.vo.DpcEmployeeVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -32,15 +32,15 @@ public interface IDpcEmployeeService {
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工VO分页结果
|
||||
*/
|
||||
Page<DpcEmployeeVO> selectEmployeePage(Page<DpcEmployee> page, DpcEmployeeQueryDTO queryDTO);
|
||||
Page<DpcEmployeeVO> selectEmployeePage(Page<DpcEmployeeVO> page, DpcEmployeeQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 查询员工列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工实体集合
|
||||
* @return 员工Excel实体集合
|
||||
*/
|
||||
List<DpcEmployee> selectEmployeeListForExport(DpcEmployeeQueryDTO queryDTO);
|
||||
List<DpcEmployeeExcel> selectEmployeeListForExport(DpcEmployeeQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 查询员工详情
|
||||
@@ -77,9 +77,9 @@ public interface IDpcEmployeeService {
|
||||
/**
|
||||
* 导入员工数据
|
||||
*
|
||||
* @param addDTOList 新增DTO列表
|
||||
* @param excelList Excel实体列表
|
||||
* @param isUpdateSupport 是否更新支持
|
||||
* @return 结果
|
||||
*/
|
||||
String importEmployee(List<DpcEmployeeAddDTO> addDTOList, Boolean isUpdateSupport);
|
||||
String importEmployee(List<DpcEmployeeExcel> excelList, Boolean isUpdateSupport);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.ruoyi.dpc.domain.DpcIntermediaryBlacklist;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistAddDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistEditDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistQueryDTO;
|
||||
import com.ruoyi.dpc.domain.excel.DpcIntermediaryBlacklistExcel;
|
||||
import com.ruoyi.dpc.domain.vo.DpcIntermediaryBlacklistVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,9 +39,9 @@ public interface IDpcIntermediaryBlacklistService {
|
||||
* 查询中介黑名单列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 中介黑名单实体集合
|
||||
* @return 中介黑名单Excel实体集合
|
||||
*/
|
||||
List<DpcIntermediaryBlacklist> selectIntermediaryListForExport(DpcIntermediaryBlacklistQueryDTO queryDTO);
|
||||
List<DpcIntermediaryBlacklistExcel> selectIntermediaryListForExport(DpcIntermediaryBlacklistQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 查询中介黑名单详细
|
||||
@@ -77,9 +78,9 @@ public interface IDpcIntermediaryBlacklistService {
|
||||
/**
|
||||
* 导入中介黑名单数据
|
||||
*
|
||||
* @param addDTOList 新增DTO列表
|
||||
* @param excelList Excel实体列表
|
||||
* @param isUpdateSupport 是否更新支持
|
||||
* @return 结果
|
||||
*/
|
||||
String importIntermediary(List<DpcIntermediaryBlacklistAddDTO> addDTOList, Boolean isUpdateSupport);
|
||||
String importIntermediary(List<DpcIntermediaryBlacklistExcel> excelList, Boolean isUpdateSupport);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.dpc.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.utils.IdCardUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.dpc.domain.DpcEmployee;
|
||||
import com.ruoyi.dpc.domain.DpcEmployeeRelative;
|
||||
@@ -9,6 +10,7 @@ import com.ruoyi.dpc.domain.dto.DpcEmployeeAddDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeEditDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeQueryDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcEmployeeRelativeAddDTO;
|
||||
import com.ruoyi.dpc.domain.excel.DpcEmployeeExcel;
|
||||
import com.ruoyi.dpc.domain.vo.DpcEmployeeVO;
|
||||
import com.ruoyi.dpc.mapper.DpcEmployeeMapper;
|
||||
import com.ruoyi.dpc.mapper.DpcEmployeeRelativeMapper;
|
||||
@@ -20,7 +22,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 员工信息 服务层处理
|
||||
@@ -62,7 +63,7 @@ public class DpcEmployeeServiceImpl implements IDpcEmployeeService {
|
||||
* @return 员工VO分页结果
|
||||
*/
|
||||
@Override
|
||||
public Page<DpcEmployeeVO> selectEmployeePage(Page<DpcEmployee> page, DpcEmployeeQueryDTO queryDTO) {
|
||||
public Page<DpcEmployeeVO> selectEmployeePage(Page<DpcEmployeeVO> page, DpcEmployeeQueryDTO queryDTO) {
|
||||
// 使用关联查询获取部门名称
|
||||
Page<DpcEmployeeVO> voPage = new Page<>(page.getCurrent(), page.getSize());
|
||||
Page<DpcEmployeeVO> resultPage = employeeMapper.selectEmployeePageWithDept(voPage, queryDTO);
|
||||
@@ -83,12 +84,17 @@ public class DpcEmployeeServiceImpl implements IDpcEmployeeService {
|
||||
* 查询员工列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工实体集合
|
||||
* @return 员工Excel实体集合
|
||||
*/
|
||||
@Override
|
||||
public List<DpcEmployee> selectEmployeeListForExport(DpcEmployeeQueryDTO queryDTO) {
|
||||
public List<DpcEmployeeExcel> selectEmployeeListForExport(DpcEmployeeQueryDTO queryDTO) {
|
||||
LambdaQueryWrapper<DpcEmployee> wrapper = buildQueryWrapper(queryDTO);
|
||||
return employeeMapper.selectList(wrapper);
|
||||
List<DpcEmployee> list = employeeMapper.selectList(wrapper);
|
||||
return list.stream().map(employee -> {
|
||||
DpcEmployeeExcel excel = new DpcEmployeeExcel();
|
||||
BeanUtils.copyProperties(employee, excel);
|
||||
return excel;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,14 +220,14 @@ public class DpcEmployeeServiceImpl implements IDpcEmployeeService {
|
||||
/**
|
||||
* 导入员工数据
|
||||
*
|
||||
* @param addDTOList 新增DTO列表
|
||||
* @param excelList Excel实体列表
|
||||
* @param isUpdateSupport 是否更新支持
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public String importEmployee(List<DpcEmployeeAddDTO> addDTOList, Boolean isUpdateSupport) {
|
||||
if (StringUtils.isNull(addDTOList) || addDTOList.isEmpty()) {
|
||||
public String importEmployee(List<DpcEmployeeExcel> excelList, Boolean isUpdateSupport) {
|
||||
if (StringUtils.isNull(excelList) || excelList.isEmpty()) {
|
||||
return "至少需要一条数据";
|
||||
}
|
||||
|
||||
@@ -230,8 +236,12 @@ public class DpcEmployeeServiceImpl implements IDpcEmployeeService {
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
|
||||
for (DpcEmployeeAddDTO addDTO : addDTOList) {
|
||||
for (DpcEmployeeExcel excel : excelList) {
|
||||
try {
|
||||
// 转换为AddDTO
|
||||
DpcEmployeeAddDTO addDTO = new DpcEmployeeAddDTO();
|
||||
BeanUtils.copyProperties(excel, addDTO);
|
||||
|
||||
// 验证数据
|
||||
validateEmployeeData(addDTO, isUpdateSupport);
|
||||
|
||||
@@ -243,7 +253,7 @@ public class DpcEmployeeServiceImpl implements IDpcEmployeeService {
|
||||
successMsg.append("<br/>").append(successNum).append("、").append(addDTO.getName()).append(" 导入成功");
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、").append(addDTO.getName()).append(" 导入失败:");
|
||||
failureMsg.append("<br/>").append(failureNum).append("、").append(excel.getName()).append(" 导入失败:");
|
||||
failureMsg.append(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -265,7 +275,7 @@ public class DpcEmployeeServiceImpl implements IDpcEmployeeService {
|
||||
wrapper.like(StringUtils.isNotEmpty(queryDTO.getName()), DpcEmployee::getName, queryDTO.getName())
|
||||
.eq(StringUtils.isNotEmpty(queryDTO.getTellerNo()), DpcEmployee::getTellerNo, queryDTO.getTellerNo())
|
||||
.eq(queryDTO.getDeptId() != null, DpcEmployee::getDeptId, queryDTO.getDeptId())
|
||||
.eq(StringUtils.isNotEmpty(queryDTO.getIdCard()), DpcEmployee::getIdCard, queryDTO.getIdCard())
|
||||
.like(StringUtils.isNotEmpty(queryDTO.getIdCard()), DpcEmployee::getIdCard, queryDTO.getIdCard())
|
||||
.eq(StringUtils.isNotEmpty(queryDTO.getStatus()), DpcEmployee::getStatus, queryDTO.getStatus())
|
||||
.orderByDesc(DpcEmployee::getCreateTime);
|
||||
return wrapper;
|
||||
@@ -275,6 +285,26 @@ public class DpcEmployeeServiceImpl implements IDpcEmployeeService {
|
||||
* 验证员工数据
|
||||
*/
|
||||
private void validateEmployeeData(DpcEmployeeAddDTO addDTO, Boolean isUpdateSupport) {
|
||||
// 验证必填字段
|
||||
if (StringUtils.isEmpty(addDTO.getName())) {
|
||||
throw new RuntimeException("姓名不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getTellerNo())) {
|
||||
throw new RuntimeException("柜员号不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getIdCard())) {
|
||||
throw new RuntimeException("身份证号不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getStatus())) {
|
||||
throw new RuntimeException("状态不能为空");
|
||||
}
|
||||
|
||||
// 验证身份证号格式
|
||||
String idCardError = IdCardUtil.getErrorMessage(addDTO.getIdCard());
|
||||
if (idCardError != null) {
|
||||
throw new RuntimeException(idCardError);
|
||||
}
|
||||
|
||||
// 检查柜员号唯一性
|
||||
LambdaQueryWrapper<DpcEmployee> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(DpcEmployee::getTellerNo, addDTO.getTellerNo());
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ruoyi.dpc.domain.DpcIntermediaryBlacklist;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistAddDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistEditDTO;
|
||||
import com.ruoyi.dpc.domain.dto.DpcIntermediaryBlacklistQueryDTO;
|
||||
import com.ruoyi.dpc.domain.excel.DpcIntermediaryBlacklistExcel;
|
||||
import com.ruoyi.dpc.domain.vo.DpcIntermediaryBlacklistVO;
|
||||
import com.ruoyi.dpc.mapper.DpcIntermediaryBlacklistMapper;
|
||||
import com.ruoyi.dpc.service.IDpcIntermediaryBlacklistService;
|
||||
@@ -66,12 +67,17 @@ public class DpcIntermediaryBlacklistServiceImpl implements IDpcIntermediaryBlac
|
||||
* 查询中介黑名单列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 中介黑名单实体集合
|
||||
* @return 中介黑名单Excel实体集合
|
||||
*/
|
||||
@Override
|
||||
public List<DpcIntermediaryBlacklist> selectIntermediaryListForExport(DpcIntermediaryBlacklistQueryDTO queryDTO) {
|
||||
public List<DpcIntermediaryBlacklistExcel> selectIntermediaryListForExport(DpcIntermediaryBlacklistQueryDTO queryDTO) {
|
||||
LambdaQueryWrapper<DpcIntermediaryBlacklist> wrapper = buildQueryWrapper(queryDTO);
|
||||
return intermediaryMapper.selectList(wrapper);
|
||||
List<DpcIntermediaryBlacklist> list = intermediaryMapper.selectList(wrapper);
|
||||
return list.stream().map(entity -> {
|
||||
DpcIntermediaryBlacklistExcel excel = new DpcIntermediaryBlacklistExcel();
|
||||
BeanUtils.copyProperties(entity, excel);
|
||||
return excel;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,13 +132,13 @@ public class DpcIntermediaryBlacklistServiceImpl implements IDpcIntermediaryBlac
|
||||
/**
|
||||
* 导入中介黑名单数据
|
||||
*
|
||||
* @param addDTOList 新增DTO列表
|
||||
* @param excelList Excel实体列表
|
||||
* @param isUpdateSupport 是否更新支持
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String importIntermediary(List<DpcIntermediaryBlacklistAddDTO> addDTOList, Boolean isUpdateSupport) {
|
||||
if (addDTOList == null || addDTOList.isEmpty()) {
|
||||
public String importIntermediary(List<DpcIntermediaryBlacklistExcel> excelList, Boolean isUpdateSupport) {
|
||||
if (excelList == null || excelList.isEmpty()) {
|
||||
return "至少需要一条数据";
|
||||
}
|
||||
|
||||
@@ -141,8 +147,12 @@ public class DpcIntermediaryBlacklistServiceImpl implements IDpcIntermediaryBlac
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
|
||||
for (DpcIntermediaryBlacklistAddDTO addDTO : addDTOList) {
|
||||
for (DpcIntermediaryBlacklistExcel excel : excelList) {
|
||||
try {
|
||||
// 转换为AddDTO
|
||||
DpcIntermediaryBlacklistAddDTO addDTO = new DpcIntermediaryBlacklistAddDTO();
|
||||
BeanUtils.copyProperties(excel, addDTO);
|
||||
|
||||
// 验证数据
|
||||
validateIntermediaryData(addDTO);
|
||||
|
||||
@@ -154,7 +164,7 @@ public class DpcIntermediaryBlacklistServiceImpl implements IDpcIntermediaryBlac
|
||||
successMsg.append("<br/>").append(successNum).append("、").append(addDTO.getName()).append(" 导入成功");
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、").append(addDTO.getName()).append(" 导入失败:");
|
||||
failureMsg.append("<br/>").append(failureNum).append("、").append(excel.getName()).append(" 导入失败:");
|
||||
failureMsg.append(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -185,6 +195,17 @@ public class DpcIntermediaryBlacklistServiceImpl implements IDpcIntermediaryBlac
|
||||
* 验证中介数据
|
||||
*/
|
||||
private void validateIntermediaryData(DpcIntermediaryBlacklistAddDTO addDTO) {
|
||||
// 验证必填字段
|
||||
if (StringUtils.isEmpty(addDTO.getName())) {
|
||||
throw new RuntimeException("姓名/机构名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getIntermediaryType())) {
|
||||
throw new RuntimeException("中介类型不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getStatus())) {
|
||||
throw new RuntimeException("状态不能为空");
|
||||
}
|
||||
|
||||
// 验证中介类型
|
||||
if (!"1".equals(addDTO.getIntermediaryType()) && !"2".equals(addDTO.getIntermediaryType())) {
|
||||
throw new RuntimeException("中介类型只能填写'个人'或'机构'");
|
||||
|
||||
157
ruoyi-dpc/src/main/java/com/ruoyi/dpc/utils/EasyExcelUtil.java
Normal file
157
ruoyi-dpc/src/main/java/com/ruoyi/dpc/utils/EasyExcelUtil.java
Normal file
@@ -0,0 +1,157 @@
|
||||
package com.ruoyi.dpc.utils;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.handler.WriteHandler;
|
||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* EasyExcel工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class EasyExcelUtil {
|
||||
|
||||
/**
|
||||
* 导出Excel
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @param list 数据列表
|
||||
* @param clazz 实体类
|
||||
* @param sheetName 工作表名称
|
||||
* @param <T> 泛型
|
||||
*/
|
||||
public static <T> void exportExcel(HttpServletResponse response, List<T> list, Class<T> clazz, String sheetName) {
|
||||
try {
|
||||
setResponseHeader(response, sheetName);
|
||||
EasyExcel.write(response.getOutputStream(), clazz)
|
||||
.sheet(sheetName)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.doWrite(list);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("导出Excel失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel(指定数据)
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @param list 数据列表
|
||||
* @param clazz 实体类
|
||||
* @param sheetName 工作表名称
|
||||
* @param fileName 文件名称
|
||||
* @param <T> 泛型
|
||||
*/
|
||||
public static <T> void exportExcel(HttpServletResponse response, List<T> list, Class<T> clazz, String sheetName, String fileName) {
|
||||
try {
|
||||
setResponseHeader(response, fileName);
|
||||
EasyExcel.write(response.getOutputStream(), clazz)
|
||||
.sheet(sheetName)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.doWrite(list);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("导出Excel失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入Excel
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @param clazz 实体类
|
||||
* @param <T> 泛型
|
||||
* @return 数据列表
|
||||
*/
|
||||
public static <T> List<T> importExcel(String fileName, Class<T> clazz) {
|
||||
try {
|
||||
return EasyExcel.read(fileName).head(clazz).sheet().doReadSync();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("导入Excel失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入Excel(通过输入流)
|
||||
*
|
||||
* @param inputStream 输入流
|
||||
* @param clazz 实体类
|
||||
* @param <T> 泛型
|
||||
* @return 数据列表
|
||||
*/
|
||||
public static <T> List<T> importExcel(java.io.InputStream inputStream, Class<T> clazz) {
|
||||
try {
|
||||
return EasyExcel.read(inputStream).head(clazz).sheet().doReadSync();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("导入Excel失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @param clazz 实体类
|
||||
* @param sheetName 工作表名称
|
||||
* @param <T> 泛型
|
||||
*/
|
||||
public static <T> void importTemplateExcel(HttpServletResponse response, Class<T> clazz, String sheetName) {
|
||||
try {
|
||||
setResponseHeader(response, sheetName + "模板");
|
||||
EasyExcel.write(response.getOutputStream(), clazz)
|
||||
.sheet(sheetName)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.doWrite(List.of());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("下载导入模板失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载导入模板(带自定义处理器)
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @param clazz 实体类
|
||||
* @param sheetName 工作表名称
|
||||
* @param handlers 自定义写入处理器
|
||||
* @param <T> 泛型
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> void importTemplateExcel(HttpServletResponse response, Class<T> clazz, String sheetName,
|
||||
WriteHandler... handlers) {
|
||||
try {
|
||||
setResponseHeader(response, sheetName + "模板");
|
||||
var writerBuilder = EasyExcel.write(response.getOutputStream(), clazz)
|
||||
.sheet(sheetName)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy());
|
||||
// 注册所有自定义处理器
|
||||
for (WriteHandler handler : handlers) {
|
||||
writerBuilder.registerWriteHandler(handler);
|
||||
}
|
||||
writerBuilder.doWrite(List.of());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("下载导入模板失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置响应头
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @param fileName 文件名
|
||||
*/
|
||||
private static void setResponseHeader(HttpServletResponse response, String fileName) {
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + encodedFileName + ".xlsx");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.dpc.utils.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 员工状态转换器
|
||||
* 0=在职, 1=离职
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class EmployeeStatusConverter implements Converter<String> {
|
||||
|
||||
private static final Map<String, String> CODE_TO_DESC = new HashMap<>();
|
||||
private static final Map<String, String> DESC_TO_CODE = new HashMap<>();
|
||||
|
||||
static {
|
||||
CODE_TO_DESC.put("0", "在职");
|
||||
CODE_TO_DESC.put("1", "离职");
|
||||
DESC_TO_CODE.put("在职", "0");
|
||||
DESC_TO_CODE.put("离职", "1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> supportJavaTypeKey() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
String value = cellData.getStringValue();
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
// 支持中文和代码两种格式
|
||||
if (DESC_TO_CODE.containsKey(value)) {
|
||||
return DESC_TO_CODE.get(value);
|
||||
}
|
||||
// 如果是纯数字,直接返回
|
||||
if (value.matches("\\d")) {
|
||||
return value;
|
||||
}
|
||||
throw new IllegalArgumentException("无效的员工状态: " + value + ", 请使用: 在职/离职 或 0/1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
String desc = CODE_TO_DESC.getOrDefault(value, value);
|
||||
return new WriteCellData<>(desc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.dpc.utils.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 中介黑名单状态转换器
|
||||
* 0=正常, 1=停用
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class IntermediaryStatusConverter implements Converter<String> {
|
||||
|
||||
private static final Map<String, String> CODE_TO_DESC = new HashMap<>();
|
||||
private static final Map<String, String> DESC_TO_CODE = new HashMap<>();
|
||||
|
||||
static {
|
||||
CODE_TO_DESC.put("0", "正常");
|
||||
CODE_TO_DESC.put("1", "停用");
|
||||
DESC_TO_CODE.put("正常", "0");
|
||||
DESC_TO_CODE.put("停用", "1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> supportJavaTypeKey() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
String value = cellData.getStringValue();
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
// 支持中文和代码两种格式
|
||||
if (DESC_TO_CODE.containsKey(value)) {
|
||||
return DESC_TO_CODE.get(value);
|
||||
}
|
||||
// 如果是纯数字,直接返回
|
||||
if (value.matches("\\d")) {
|
||||
return value;
|
||||
}
|
||||
throw new IllegalArgumentException("无效的状态: " + value + ", 请使用: 正常/停用 或 0/1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
String desc = CODE_TO_DESC.getOrDefault(value, value);
|
||||
return new WriteCellData<>(desc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.dpc.utils.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 中介类型转换器
|
||||
* 1=个人, 2=机构
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class IntermediaryTypeConverter implements Converter<String> {
|
||||
|
||||
private static final Map<String, String> CODE_TO_DESC = new HashMap<>();
|
||||
private static final Map<String, String> DESC_TO_CODE = new HashMap<>();
|
||||
|
||||
static {
|
||||
CODE_TO_DESC.put("1", "个人");
|
||||
CODE_TO_DESC.put("2", "机构");
|
||||
DESC_TO_CODE.put("个人", "1");
|
||||
DESC_TO_CODE.put("机构", "2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> supportJavaTypeKey() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
String value = cellData.getStringValue();
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
// 支持中文和代码两种格式
|
||||
if (DESC_TO_CODE.containsKey(value)) {
|
||||
return DESC_TO_CODE.get(value);
|
||||
}
|
||||
// 如果是纯数字,直接返回
|
||||
if (value.matches("\\d")) {
|
||||
return value;
|
||||
}
|
||||
throw new IllegalArgumentException("无效的中介类型: " + value + ", 请使用: 个人/机构 或 1/2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
String desc = CODE_TO_DESC.getOrDefault(value, value);
|
||||
return new WriteCellData<>(desc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.ruoyi.dpc.utils.handler;
|
||||
|
||||
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
|
||||
import org.apache.poi.ss.usermodel.DataValidation;
|
||||
import org.apache.poi.ss.usermodel.DataValidationHelper;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
|
||||
/**
|
||||
* 员工状态下拉框处理器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class EmployeeStatusSheetWriteHandler implements SheetWriteHandler {
|
||||
|
||||
@Override
|
||||
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||
Sheet sheet = writeSheetHolder.getSheet();
|
||||
Workbook workbook = writeWorkbookHolder.getWorkbook();
|
||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||
|
||||
// 创建下拉框数据列表
|
||||
String[] statusList = {"在职", "离职"};
|
||||
|
||||
// 设置状态下拉框,从第2行开始(第1行是表头),第7列(状态列,索引为6)
|
||||
CellRangeAddressList addressList = new CellRangeAddressList(1, 10000, 6, 6);
|
||||
|
||||
// 创建显式列表约束
|
||||
DataValidation validation = helper.createValidation(
|
||||
helper.createExplicitListConstraint(statusList),
|
||||
addressList
|
||||
);
|
||||
|
||||
// 设置提示信息
|
||||
validation.createPromptBox("状态选择", "请选择员工状态:在职或离职");
|
||||
validation.setShowPromptBox(true);
|
||||
|
||||
// 设置错误提示
|
||||
validation.createErrorBox("状态错误", "请从下拉框中选择有效的状态值!");
|
||||
validation.setShowErrorBox(true);
|
||||
|
||||
sheet.addValidationData(validation);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.dpc.mapper.DpcEmployeeMapper">
|
||||
|
||||
<!-- 员工基本信息ResultMap(用于列表查询,不包含亲属) -->
|
||||
<resultMap type="com.ruoyi.dpc.domain.vo.DpcEmployeeVO" id="DpcEmployeeVOResult">
|
||||
<id property="employeeId" column="employee_id"/>
|
||||
<result property="name" column="name"/>
|
||||
@@ -15,7 +16,11 @@
|
||||
<result property="hireDate" column="hire_date"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<collection property="relatives" ofType="com.ruoyi.dpc.domain.vo.DpcEmployeeRelativeVO">
|
||||
</resultMap>
|
||||
|
||||
<!-- 员工详情ResultMap(包含亲属信息) -->
|
||||
<resultMap type="com.ruoyi.dpc.domain.vo.DpcEmployeeVO" id="DpcEmployeeWithRelativesResult" extends="DpcEmployeeVOResult">
|
||||
<collection property="relatives" ofType="DpcEmployeeRelativeVO" notNullColumn="relative_id">
|
||||
<id property="relativeId" column="relative_id"/>
|
||||
<result property="employeeId" column="employee_id"/>
|
||||
<result property="relativeName" column="relative_name"/>
|
||||
@@ -42,7 +47,7 @@
|
||||
AND e.dept_id = #{query.deptId}
|
||||
</if>
|
||||
<if test="query.idCard != null and query.idCard != ''">
|
||||
AND e.id_card = #{query.idCard}
|
||||
AND e.id_card LIKE CONCAT('%', #{query.idCard}, '%')
|
||||
</if>
|
||||
<if test="query.status != null and query.status != ''">
|
||||
AND e.status = #{query.status}
|
||||
@@ -51,11 +56,13 @@
|
||||
ORDER BY e.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectEmployeeWithRelatives" parameterType="Long" resultMap="DpcEmployeeVOResult">
|
||||
<select id="selectEmployeeWithRelatives" parameterType="Long" resultMap="DpcEmployeeWithRelativesResult">
|
||||
SELECT
|
||||
e.employee_id, e.name, e.teller_no, e.dept_id, e.id_card, e.phone, e.hire_date, e.status, e.create_time,
|
||||
d.dept_name,
|
||||
r.relative_id, r.employee_id, r.relative_name, r.relative_id_card, r.relative_phone, r.relationship
|
||||
FROM dpc_employee e
|
||||
LEFT JOIN sys_dept d ON e.dept_id = d.dept_id
|
||||
LEFT JOIN dpc_employee_relative r ON e.employee_id = r.employee_id
|
||||
WHERE e.employee_id = #{employeeId}
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user