feat 员工亲属关系
This commit is contained in:
@@ -0,0 +1,195 @@
|
||||
package com.ruoyi.ccdi.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationEditDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiStaffFmyRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.CcdiStaffFmyRelationVO;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportResultVO;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportStatusVO;
|
||||
import com.ruoyi.ccdi.domain.vo.StaffFmyRelationImportFailureVO;
|
||||
import com.ruoyi.ccdi.service.ICcdiStaffFmyRelationImportService;
|
||||
import com.ruoyi.ccdi.service.ICcdiStaffFmyRelationService;
|
||||
import com.ruoyi.ccdi.utils.EasyExcelUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
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 io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工亲属关系Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Tag(name = "员工亲属关系管理")
|
||||
@RestController
|
||||
@RequestMapping("/ccdi/staffFmyRelation")
|
||||
public class CcdiStaffFmyRelationController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ICcdiStaffFmyRelationService relationService;
|
||||
|
||||
@Resource
|
||||
private ICcdiStaffFmyRelationImportService relationImportService;
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系列表
|
||||
*/
|
||||
@Operation(summary = "查询员工亲属关系列表")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CcdiStaffFmyRelationQueryDTO queryDTO) {
|
||||
// 使用MyBatis Plus分页
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Page<CcdiStaffFmyRelationVO> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||
Page<CcdiStaffFmyRelationVO> result = relationService.selectRelationPage(page, queryDTO);
|
||||
return getDataTable(result.getRecords(), result.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出员工亲属关系列表
|
||||
*/
|
||||
@Operation(summary = "导出员工亲属关系列表")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:export')")
|
||||
@Log(title = "员工亲属关系", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CcdiStaffFmyRelationQueryDTO queryDTO) {
|
||||
List<CcdiStaffFmyRelationExcel> list = relationService.selectRelationListForExport(queryDTO);
|
||||
EasyExcelUtil.exportExcel(response, list, CcdiStaffFmyRelationExcel.class, "员工亲属关系信息");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取员工亲属关系详细信息
|
||||
*/
|
||||
@Operation(summary = "获取员工亲属关系详细信息")
|
||||
@Parameter(name = "id", description = "主键ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable Long id) {
|
||||
return success(relationService.selectRelationById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增员工亲属关系
|
||||
*/
|
||||
@Operation(summary = "新增员工亲属关系")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:add')")
|
||||
@Log(title = "员工亲属关系", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody CcdiStaffFmyRelationAddDTO addDTO) {
|
||||
return toAjax(relationService.insertRelation(addDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改员工亲属关系
|
||||
*/
|
||||
@Operation(summary = "修改员工亲属关系")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:edit')")
|
||||
@Log(title = "员工亲属关系", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody CcdiStaffFmyRelationEditDTO editDTO) {
|
||||
return toAjax(relationService.updateRelation(editDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除员工亲属关系
|
||||
*/
|
||||
@Operation(summary = "删除员工亲属关系")
|
||||
@Parameter(name = "ids", description = "主键ID数组", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:remove')")
|
||||
@Log(title = "员工亲属关系", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(relationService.deleteRelationByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载带字典下拉框的导入模板
|
||||
* 使用@DictDropdown注解自动添加下拉框
|
||||
*/
|
||||
@Operation(summary = "下载导入模板")
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
EasyExcelUtil.importTemplateWithDictDropdown(response, CcdiStaffFmyRelationExcel.class, "员工亲属关系信息");
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步导入员工亲属关系
|
||||
*/
|
||||
@Operation(summary = "异步导入员工亲属关系")
|
||||
@Parameter(name = "file", description = "导入文件", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:import')")
|
||||
@Log(title = "员工亲属关系", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(@Parameter(description = "导入文件") MultipartFile file) throws Exception {
|
||||
List<CcdiStaffFmyRelationExcel> list = EasyExcelUtil.importExcel(file.getInputStream(), CcdiStaffFmyRelationExcel.class);
|
||||
|
||||
if (list == null || list.isEmpty()) {
|
||||
return error("至少需要一条数据");
|
||||
}
|
||||
|
||||
// 提交异步任务
|
||||
String taskId = relationService.importRelation(list);
|
||||
|
||||
// 立即返回,不等待后台任务完成
|
||||
ImportResultVO result = new ImportResultVO();
|
||||
result.setTaskId(taskId);
|
||||
result.setStatus("PROCESSING");
|
||||
result.setMessage("导入任务已提交,正在后台处理");
|
||||
|
||||
return AjaxResult.success("导入任务已提交,正在后台处理", result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入状态
|
||||
*/
|
||||
@Operation(summary = "查询导入状态")
|
||||
@Parameter(name = "taskId", description = "任务ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:import')")
|
||||
@GetMapping("/importStatus/{taskId}")
|
||||
public AjaxResult getImportStatus(@PathVariable String taskId) {
|
||||
ImportStatusVO statusVO = relationImportService.getImportStatus(taskId);
|
||||
return success(statusVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入失败记录
|
||||
*/
|
||||
@Operation(summary = "查询导入失败记录")
|
||||
@Parameter(name = "taskId", description = "任务ID", required = true)
|
||||
@Parameter(name = "pageNum", description = "页码", required = false)
|
||||
@Parameter(name = "pageSize", description = "每页条数", required = false)
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:import')")
|
||||
@GetMapping("/importFailures/{taskId}")
|
||||
public TableDataInfo getImportFailures(
|
||||
@PathVariable String taskId,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
|
||||
List<StaffFmyRelationImportFailureVO> failures = relationImportService.getImportFailures(taskId);
|
||||
|
||||
// 手动分页
|
||||
int fromIndex = (pageNum - 1) * pageSize;
|
||||
int toIndex = Math.min(fromIndex + pageSize, failures.size());
|
||||
|
||||
List<StaffFmyRelationImportFailureVO> pageData = failures.subList(fromIndex, toIndex);
|
||||
|
||||
return getDataTable(pageData, failures.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.ccdi.domain;
|
||||
|
||||
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 lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工亲属关系对象 ccdi_staff_fmy_relation
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Data
|
||||
public class CcdiStaffFmyRelation implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 员工身份证号 */
|
||||
private String personId;
|
||||
|
||||
/** 关系类型 */
|
||||
private String relationType;
|
||||
|
||||
/** 关系人姓名 */
|
||||
private String relationName;
|
||||
|
||||
/** 性别:M-男,F-女,O-其他 */
|
||||
private String gender;
|
||||
|
||||
/** 出生日期 */
|
||||
private Date birthDate;
|
||||
|
||||
/** 关系人证件类型 */
|
||||
private String relationCertType;
|
||||
|
||||
/** 关系人证件号码 */
|
||||
private String relationCertNo;
|
||||
|
||||
/** 手机号码1 */
|
||||
private String mobilePhone1;
|
||||
|
||||
/** 手机号码2 */
|
||||
private String mobilePhone2;
|
||||
|
||||
/** 微信名称1 */
|
||||
private String wechatNo1;
|
||||
|
||||
/** 微信名称2 */
|
||||
private String wechatNo2;
|
||||
|
||||
/** 微信名称3 */
|
||||
private String wechatNo3;
|
||||
|
||||
/** 详细联系地址 */
|
||||
private String contactAddress;
|
||||
|
||||
/** 关系详细描述 */
|
||||
private String relationDesc;
|
||||
|
||||
/** 生效日期 */
|
||||
private Date effectiveDate;
|
||||
|
||||
/** 失效日期 */
|
||||
private Date invalidDate;
|
||||
|
||||
/** 状态:0-无效,1-有效 */
|
||||
private Integer status;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 数据来源:MANUAL-手工录入,IMPORT-导入 */
|
||||
private String dataSource;
|
||||
|
||||
/** 是否是员工亲属:0-否,1-是 */
|
||||
private Boolean isEmpFamily;
|
||||
|
||||
/** 是否是客户亲属:0-否,1-是 */
|
||||
private Boolean isCustFamily;
|
||||
|
||||
/** 创建时间 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/** 创建人 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createdBy;
|
||||
|
||||
/** 更新人 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String updatedBy;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.ruoyi.ccdi.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工亲属关系新增DTO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "员工亲属关系新增")
|
||||
public class CcdiStaffFmyRelationAddDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 员工身份证号 */
|
||||
@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}[\\dXx]$", message = "员工身份证号格式不正确")
|
||||
@Schema(description = "员工身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 关系类型 */
|
||||
@NotBlank(message = "关系类型不能为空")
|
||||
@Size(max = 50, message = "关系类型长度不能超过50个字符")
|
||||
@Schema(description = "关系类型")
|
||||
private String relationType;
|
||||
|
||||
/** 关系人姓名 */
|
||||
@NotBlank(message = "关系人姓名不能为空")
|
||||
@Size(max = 100, message = "关系人姓名长度不能超过100个字符")
|
||||
@Schema(description = "关系人姓名")
|
||||
private String relationName;
|
||||
|
||||
/** 性别 */
|
||||
@Pattern(regexp = "^[MFO]$", message = "性别只能是M、F或O")
|
||||
@Schema(description = "性别:M-男,F-女,O-其他")
|
||||
private String gender;
|
||||
|
||||
/** 出生日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "出生日期")
|
||||
private Date birthDate;
|
||||
|
||||
/** 关系人证件类型 */
|
||||
@NotBlank(message = "关系人证件类型不能为空")
|
||||
@Size(max = 50, message = "关系人证件类型长度不能超过50个字符")
|
||||
@Schema(description = "关系人证件类型")
|
||||
private String relationCertType;
|
||||
|
||||
/** 关系人证件号码 */
|
||||
@NotBlank(message = "关系人证件号码不能为空")
|
||||
@Size(max = 100, message = "关系人证件号码长度不能超过100个字符")
|
||||
@Schema(description = "关系人证件号码")
|
||||
private String relationCertNo;
|
||||
|
||||
/** 手机号码1 */
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码1格式不正确")
|
||||
@Schema(description = "手机号码1")
|
||||
private String mobilePhone1;
|
||||
|
||||
/** 手机号码2 */
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码2格式不正确")
|
||||
@Schema(description = "手机号码2")
|
||||
private String mobilePhone2;
|
||||
|
||||
/** 微信名称1 */
|
||||
@Size(max = 50, message = "微信名称1长度不能超过50个字符")
|
||||
@Schema(description = "微信名称1")
|
||||
private String wechatNo1;
|
||||
|
||||
/** 微信名称2 */
|
||||
@Size(max = 50, message = "微信名称2长度不能超过50个字符")
|
||||
@Schema(description = "微信名称2")
|
||||
private String wechatNo2;
|
||||
|
||||
/** 微信名称3 */
|
||||
@Size(max = 50, message = "微信名称3长度不能超过50个字符")
|
||||
@Schema(description = "微信名称3")
|
||||
private String wechatNo3;
|
||||
|
||||
/** 详细联系地址 */
|
||||
@Size(max = 500, message = "详细联系地址长度不能超过500个字符")
|
||||
@Schema(description = "详细联系地址")
|
||||
private String contactAddress;
|
||||
|
||||
/** 关系详细描述 */
|
||||
@Size(max = 500, message = "关系详细描述长度不能超过500个字符")
|
||||
@Schema(description = "关系详细描述")
|
||||
private String relationDesc;
|
||||
|
||||
/** 生效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "生效日期")
|
||||
private Date effectiveDate;
|
||||
|
||||
/** 失效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "失效日期")
|
||||
private Date invalidDate;
|
||||
|
||||
/** 状态 */
|
||||
@Schema(description = "状态:0-无效,1-有效")
|
||||
private Integer status;
|
||||
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.ruoyi.ccdi.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工亲属关系编辑DTO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "员工亲属关系编辑")
|
||||
public class CcdiStaffFmyRelationEditDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@NotNull(message = "ID不能为空")
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/** 员工身份证号 */
|
||||
@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}[\\dXx]$", message = "员工身份证号格式不正确")
|
||||
@Schema(description = "员工身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 关系类型 */
|
||||
@NotBlank(message = "关系类型不能为空")
|
||||
@Size(max = 50, message = "关系类型长度不能超过50个字符")
|
||||
@Schema(description = "关系类型")
|
||||
private String relationType;
|
||||
|
||||
/** 关系人姓名 */
|
||||
@NotBlank(message = "关系人姓名不能为空")
|
||||
@Size(max = 100, message = "关系人姓名长度不能超过100个字符")
|
||||
@Schema(description = "关系人姓名")
|
||||
private String relationName;
|
||||
|
||||
/** 性别 */
|
||||
@Pattern(regexp = "^[MFO]$", message = "性别只能是M、F或O")
|
||||
@Schema(description = "性别:M-男,F-女,O-其他")
|
||||
private String gender;
|
||||
|
||||
/** 出生日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "出生日期")
|
||||
private Date birthDate;
|
||||
|
||||
/** 关系人证件类型 */
|
||||
@NotBlank(message = "关系人证件类型不能为空")
|
||||
@Size(max = 50, message = "关系人证件类型长度不能超过50个字符")
|
||||
@Schema(description = "关系人证件类型")
|
||||
private String relationCertType;
|
||||
|
||||
/** 关系人证件号码 */
|
||||
@NotBlank(message = "关系人证件号码不能为空")
|
||||
@Size(max = 100, message = "关系人证件号码长度不能超过100个字符")
|
||||
@Schema(description = "关系人证件号码")
|
||||
private String relationCertNo;
|
||||
|
||||
/** 手机号码1 */
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码1格式不正确")
|
||||
@Schema(description = "手机号码1")
|
||||
private String mobilePhone1;
|
||||
|
||||
/** 手机号码2 */
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码2格式不正确")
|
||||
@Schema(description = "手机号码2")
|
||||
private String mobilePhone2;
|
||||
|
||||
/** 微信名称1 */
|
||||
@Size(max = 50, message = "微信名称1长度不能超过50个字符")
|
||||
@Schema(description = "微信名称1")
|
||||
private String wechatNo1;
|
||||
|
||||
/** 微信名称2 */
|
||||
@Size(max = 50, message = "微信名称2长度不能超过50个字符")
|
||||
@Schema(description = "微信名称2")
|
||||
private String wechatNo2;
|
||||
|
||||
/** 微信名称3 */
|
||||
@Size(max = 50, message = "微信名称3长度不能超过50个字符")
|
||||
@Schema(description = "微信名称3")
|
||||
private String wechatNo3;
|
||||
|
||||
/** 详细联系地址 */
|
||||
@Size(max = 500, message = "详细联系地址长度不能超过500个字符")
|
||||
@Schema(description = "详细联系地址")
|
||||
private String contactAddress;
|
||||
|
||||
/** 关系详细描述 */
|
||||
@Size(max = 500, message = "关系详细描述长度不能超过500个字符")
|
||||
@Schema(description = "关系详细描述")
|
||||
private String relationDesc;
|
||||
|
||||
/** 生效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "生效日期")
|
||||
private Date effectiveDate;
|
||||
|
||||
/** 失效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "失效日期")
|
||||
private Date invalidDate;
|
||||
|
||||
/** 状态 */
|
||||
@Schema(description = "状态:0-无效,1-有效")
|
||||
private Integer status;
|
||||
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ruoyi.ccdi.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工亲属关系查询DTO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "员工亲属关系查询")
|
||||
public class CcdiStaffFmyRelationQueryDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 员工身份证号 */
|
||||
@Schema(description = "员工身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 员工姓名 */
|
||||
@Schema(description = "员工姓名")
|
||||
private String personName;
|
||||
|
||||
/** 关系类型 */
|
||||
@Schema(description = "关系类型")
|
||||
private String relationType;
|
||||
|
||||
/** 关系人姓名 */
|
||||
@Schema(description = "关系人姓名")
|
||||
private String relationName;
|
||||
|
||||
/** 状态 */
|
||||
@Schema(description = "状态:0-无效,1-有效")
|
||||
private Integer status;
|
||||
|
||||
/** 数据来源 */
|
||||
@Schema(description = "数据来源")
|
||||
private String dataSource;
|
||||
|
||||
/** 生效日期开始 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "生效日期开始")
|
||||
private Date effectiveDateStart;
|
||||
|
||||
/** 生效日期结束 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "生效日期结束")
|
||||
private Date effectiveDateEnd;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.ruoyi.ccdi.domain.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.ruoyi.common.annotation.DictDropdown;
|
||||
import com.ruoyi.common.annotation.Required;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 员工亲属关系Excel导入导出对象
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Data
|
||||
public class CcdiStaffFmyRelationExcel implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 员工身份证号 */
|
||||
@ExcelProperty(value = "员工身份证号*", index = 0)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
private String personId;
|
||||
|
||||
/** 关系类型 */
|
||||
@ExcelProperty(value = "关系类型*", index = 1)
|
||||
@ColumnWidth(15)
|
||||
@DictDropdown(dictType = "ccdi_relation_type")
|
||||
@Required
|
||||
private String relationType;
|
||||
|
||||
/** 关系人姓名 */
|
||||
@ExcelProperty(value = "关系人姓名*", index = 2)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String relationName;
|
||||
|
||||
/** 性别 */
|
||||
@ExcelProperty(value = "性别", index = 3)
|
||||
@ColumnWidth(10)
|
||||
@DictDropdown(dictType = "ccdi_indiv_gender")
|
||||
private String gender;
|
||||
|
||||
/** 关系人证件类型 */
|
||||
@ExcelProperty(value = "关系人证件类型*", index = 4)
|
||||
@ColumnWidth(15)
|
||||
@DictDropdown(dictType = "ccdi_certificate_type")
|
||||
@Required
|
||||
private String relationCertType;
|
||||
|
||||
/** 关系人证件号码 */
|
||||
@ExcelProperty(value = "关系人证件号码*", index = 5)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
private String relationCertNo;
|
||||
|
||||
/** 手机号码1 */
|
||||
@ExcelProperty(value = "手机号码1", index = 6)
|
||||
@ColumnWidth(15)
|
||||
private String mobilePhone1;
|
||||
|
||||
/** 手机号码2 */
|
||||
@ExcelProperty(value = "手机号码2", index = 7)
|
||||
@ColumnWidth(15)
|
||||
private String mobilePhone2;
|
||||
|
||||
/** 微信名称1 */
|
||||
@ExcelProperty(value = "微信名称1", index = 8)
|
||||
@ColumnWidth(15)
|
||||
private String wechatNo1;
|
||||
|
||||
/** 微信名称2 */
|
||||
@ExcelProperty(value = "微信名称2", index = 9)
|
||||
@ColumnWidth(15)
|
||||
private String wechatNo2;
|
||||
|
||||
/** 微信名称3 */
|
||||
@ExcelProperty(value = "微信名称3", index = 10)
|
||||
@ColumnWidth(15)
|
||||
private String wechatNo3;
|
||||
|
||||
/** 详细联系地址 */
|
||||
@ExcelProperty(value = "详细联系地址", index = 11)
|
||||
@ColumnWidth(30)
|
||||
private String contactAddress;
|
||||
|
||||
/** 关系详细描述 */
|
||||
@ExcelProperty(value = "关系详细描述", index = 12)
|
||||
@ColumnWidth(30)
|
||||
private String relationDesc;
|
||||
|
||||
/** 生效日期 */
|
||||
@ExcelProperty(value = "生效日期", index = 13)
|
||||
@ColumnWidth(15)
|
||||
private String effectiveDate;
|
||||
|
||||
/** 失效日期 */
|
||||
@ExcelProperty(value = "失效日期", index = 14)
|
||||
@ColumnWidth(15)
|
||||
private String invalidDate;
|
||||
|
||||
/** 状态 */
|
||||
@ExcelProperty(value = "状态", index = 15)
|
||||
@ColumnWidth(10)
|
||||
private Integer status;
|
||||
|
||||
/** 备注 */
|
||||
@ExcelProperty(value = "备注", index = 16)
|
||||
@ColumnWidth(30)
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.ruoyi.ccdi.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工亲属关系VO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "员工亲属关系")
|
||||
public class CcdiStaffFmyRelationVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/** 员工身份证号 */
|
||||
@Schema(description = "员工身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 员工姓名 */
|
||||
@Schema(description = "员工姓名")
|
||||
private String personName;
|
||||
|
||||
/** 关系类型 */
|
||||
@Schema(description = "关系类型")
|
||||
private String relationType;
|
||||
|
||||
/** 关系人姓名 */
|
||||
@Schema(description = "关系人姓名")
|
||||
private String relationName;
|
||||
|
||||
/** 性别 */
|
||||
@Schema(description = "性别")
|
||||
private String gender;
|
||||
|
||||
/** 性别名称 */
|
||||
@Schema(description = "性别名称")
|
||||
private String genderName;
|
||||
|
||||
/** 出生日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "出生日期")
|
||||
private Date birthDate;
|
||||
|
||||
/** 关系人证件类型 */
|
||||
@Schema(description = "关系人证件类型")
|
||||
private String relationCertType;
|
||||
|
||||
/** 关系人证件号码 */
|
||||
@Schema(description = "关系人证件号码")
|
||||
private String relationCertNo;
|
||||
|
||||
/** 手机号码1 */
|
||||
@Schema(description = "手机号码1")
|
||||
private String mobilePhone1;
|
||||
|
||||
/** 手机号码2 */
|
||||
@Schema(description = "手机号码2")
|
||||
private String mobilePhone2;
|
||||
|
||||
/** 微信名称1 */
|
||||
@Schema(description = "微信名称1")
|
||||
private String wechatNo1;
|
||||
|
||||
/** 微信名称2 */
|
||||
@Schema(description = "微信名称2")
|
||||
private String wechatNo2;
|
||||
|
||||
/** 微信名称3 */
|
||||
@Schema(description = "微信名称3")
|
||||
private String wechatNo3;
|
||||
|
||||
/** 详细联系地址 */
|
||||
@Schema(description = "详细联系地址")
|
||||
private String contactAddress;
|
||||
|
||||
/** 关系详细描述 */
|
||||
@Schema(description = "关系详细描述")
|
||||
private String relationDesc;
|
||||
|
||||
/** 生效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "生效日期")
|
||||
private Date effectiveDate;
|
||||
|
||||
/** 失效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "失效日期")
|
||||
private Date invalidDate;
|
||||
|
||||
/** 状态 */
|
||||
@Schema(description = "状态")
|
||||
private Integer status;
|
||||
|
||||
/** 状态名称 */
|
||||
@Schema(description = "状态名称")
|
||||
private String statusName;
|
||||
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/** 数据来源 */
|
||||
@Schema(description = "数据来源")
|
||||
private String dataSource;
|
||||
|
||||
/** 是否是员工亲属 */
|
||||
@Schema(description = "是否是员工亲属")
|
||||
private Boolean isEmpFamily;
|
||||
|
||||
/** 是否是客户亲属 */
|
||||
@Schema(description = "是否是客户亲属")
|
||||
private Boolean isCustFamily;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/** 创建人 */
|
||||
@Schema(description = "创建人")
|
||||
private String createdBy;
|
||||
|
||||
/** 更新人 */
|
||||
@Schema(description = "更新人")
|
||||
private String updatedBy;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ruoyi.ccdi.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.ccdi.domain.CcdiStaffFmyRelation;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||
import com.ruoyi.ccdi.domain.vo.CcdiStaffFmyRelationVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工亲属关系 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
public interface CcdiStaffFmyRelationMapper extends BaseMapper<CcdiStaffFmyRelation> {
|
||||
|
||||
/**
|
||||
* 分页查询员工亲属关系列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工亲属关系VO分页结果
|
||||
*/
|
||||
Page<CcdiStaffFmyRelationVO> selectRelationPage(@Param("page") Page<CcdiStaffFmyRelationVO> page,
|
||||
@Param("query") CcdiStaffFmyRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 员工亲属关系VO
|
||||
*/
|
||||
CcdiStaffFmyRelationVO selectRelationById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工亲属关系VO列表
|
||||
*/
|
||||
List<CcdiStaffFmyRelationVO> selectRelationListForExport(@Param("query") CcdiStaffFmyRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 批量插入员工亲属关系数据
|
||||
*
|
||||
* @param list 员工亲属关系列表
|
||||
* @return 插入行数
|
||||
*/
|
||||
int insertBatch(@Param("list") List<CcdiStaffFmyRelation> list);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ruoyi.ccdi.service;
|
||||
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiStaffFmyRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportStatusVO;
|
||||
import com.ruoyi.ccdi.domain.vo.StaffFmyRelationImportFailureVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工亲属关系异步导入 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
public interface ICcdiStaffFmyRelationImportService {
|
||||
|
||||
/**
|
||||
* 异步导入员工亲属关系数据
|
||||
*
|
||||
* @param excelList Excel实体列表
|
||||
* @param taskId 任务ID
|
||||
* @param userName 用户名
|
||||
*/
|
||||
void importRelationAsync(List<CcdiStaffFmyRelationExcel> excelList, String taskId, String userName);
|
||||
|
||||
/**
|
||||
* 查询导入失败记录
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 失败记录列表
|
||||
*/
|
||||
List<StaffFmyRelationImportFailureVO> getImportFailures(String taskId);
|
||||
|
||||
/**
|
||||
* 查询导入状态
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 导入状态信息
|
||||
*/
|
||||
ImportStatusVO getImportStatus(String taskId);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.ruoyi.ccdi.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationEditDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiStaffFmyRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.CcdiStaffFmyRelationVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工亲属关系 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
public interface ICcdiStaffFmyRelationService {
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系列表
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工亲属关系VO集合
|
||||
*/
|
||||
List<CcdiStaffFmyRelationVO> selectRelationList(CcdiStaffFmyRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 分页查询员工亲属关系列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工亲属关系VO分页结果
|
||||
*/
|
||||
Page<CcdiStaffFmyRelationVO> selectRelationPage(Page<CcdiStaffFmyRelationVO> page, CcdiStaffFmyRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 员工亲属关系VO
|
||||
*/
|
||||
CcdiStaffFmyRelationVO selectRelationById(Long id);
|
||||
|
||||
/**
|
||||
* 新增员工亲属关系
|
||||
*
|
||||
* @param addDTO 新增DTO
|
||||
* @return 结果
|
||||
*/
|
||||
int insertRelation(CcdiStaffFmyRelationAddDTO addDTO);
|
||||
|
||||
/**
|
||||
* 修改员工亲属关系
|
||||
*
|
||||
* @param editDTO 编辑DTO
|
||||
* @return 结果
|
||||
*/
|
||||
int updateRelation(CcdiStaffFmyRelationEditDTO editDTO);
|
||||
|
||||
/**
|
||||
* 批量删除员工亲属关系
|
||||
*
|
||||
* @param ids 需要删除的主键ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRelationByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工亲属关系Excel实体集合
|
||||
*/
|
||||
List<CcdiStaffFmyRelationExcel> selectRelationListForExport(CcdiStaffFmyRelationQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 导入员工亲属关系数据(异步)
|
||||
*
|
||||
* @param excelList Excel实体列表
|
||||
* @return 任务ID
|
||||
*/
|
||||
String importRelation(List<CcdiStaffFmyRelationExcel> excelList);
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package com.ruoyi.ccdi.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.ccdi.domain.CcdiStaffFmyRelation;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiStaffFmyRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportResult;
|
||||
import com.ruoyi.ccdi.domain.vo.ImportStatusVO;
|
||||
import com.ruoyi.ccdi.domain.vo.StaffFmyRelationImportFailureVO;
|
||||
import com.ruoyi.ccdi.mapper.CcdiStaffFmyRelationMapper;
|
||||
import com.ruoyi.ccdi.service.ICcdiStaffFmyRelationImportService;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 员工亲属关系异步导入服务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Service
|
||||
@EnableAsync
|
||||
public class CcdiStaffFmyRelationImportServiceImpl implements ICcdiStaffFmyRelationImportService {
|
||||
|
||||
@Resource
|
||||
private CcdiStaffFmyRelationMapper relationMapper;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
@Transactional
|
||||
public void importRelationAsync(List<CcdiStaffFmyRelationExcel> excelList, String taskId, String userName) {
|
||||
List<CcdiStaffFmyRelation> newRecords = new ArrayList<>();
|
||||
List<StaffFmyRelationImportFailureVO> failures = new ArrayList<>();
|
||||
|
||||
// 用于跟踪Excel文件内已处理的唯一键(personId + relationCertNo)
|
||||
Set<String> processedKeys = new HashSet<>();
|
||||
|
||||
// 分类数据
|
||||
for (int i = 0; i < excelList.size(); i++) {
|
||||
CcdiStaffFmyRelationExcel excel = excelList.get(i);
|
||||
|
||||
try {
|
||||
// 转换为AddDTO进行验证
|
||||
CcdiStaffFmyRelationAddDTO addDTO = new CcdiStaffFmyRelationAddDTO();
|
||||
BeanUtils.copyProperties(excel, addDTO);
|
||||
|
||||
// 验证数据
|
||||
validateRelationData(addDTO);
|
||||
|
||||
// 生成唯一键
|
||||
String uniqueKey = excel.getPersonId() + "|" + excel.getRelationCertNo();
|
||||
|
||||
// 检查是否在文件内重复
|
||||
if (processedKeys.contains(uniqueKey)) {
|
||||
throw new RuntimeException(String.format("员工[%s]的关系人[%s]在导入文件中重复", excel.getPersonId(), excel.getRelationCertNo()));
|
||||
}
|
||||
|
||||
CcdiStaffFmyRelation relation = new CcdiStaffFmyRelation();
|
||||
BeanUtils.copyProperties(excel, relation);
|
||||
|
||||
relation.setCreatedBy(userName);
|
||||
relation.setUpdatedBy(userName);
|
||||
relation.setIsEmpFamily(true);
|
||||
relation.setIsCustFamily(false);
|
||||
relation.setDataSource("IMPORT");
|
||||
if (relation.getStatus() == null) {
|
||||
relation.setStatus(1);
|
||||
}
|
||||
|
||||
newRecords.add(relation);
|
||||
processedKeys.add(uniqueKey);
|
||||
|
||||
} catch (Exception e) {
|
||||
StaffFmyRelationImportFailureVO failure = new StaffFmyRelationImportFailureVO();
|
||||
BeanUtils.copyProperties(excel, failure);
|
||||
failure.setErrorMessage(e.getMessage());
|
||||
failures.add(failure);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量插入新数据
|
||||
if (!newRecords.isEmpty()) {
|
||||
saveBatch(newRecords, 500);
|
||||
}
|
||||
|
||||
// 保存失败记录到Redis
|
||||
if (!failures.isEmpty()) {
|
||||
String failuresKey = "import:staffFmyRelation:" + taskId + ":failures";
|
||||
redisTemplate.opsForValue().set(failuresKey, failures, 7, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
ImportResult result = new ImportResult();
|
||||
result.setTotalCount(excelList.size());
|
||||
result.setSuccessCount(newRecords.size());
|
||||
result.setFailureCount(failures.size());
|
||||
|
||||
// 更新最终状态
|
||||
String finalStatus = result.getFailureCount() == 0 ? "SUCCESS" : "PARTIAL_SUCCESS";
|
||||
updateImportStatus(taskId, finalStatus, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入失败记录
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 失败记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<StaffFmyRelationImportFailureVO> getImportFailures(String taskId) {
|
||||
String key = "import:staffFmyRelation:" + taskId + ":failures";
|
||||
Object failuresObj = redisTemplate.opsForValue().get(key);
|
||||
|
||||
if (failuresObj == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return JSON.parseArray(JSON.toJSONString(failuresObj), StaffFmyRelationImportFailureVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入状态
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 导入状态信息
|
||||
*/
|
||||
@Override
|
||||
public ImportStatusVO getImportStatus(String taskId) {
|
||||
String key = "import:staffFmyRelation:" + taskId;
|
||||
Boolean hasKey = redisTemplate.hasKey(key);
|
||||
|
||||
if (Boolean.FALSE.equals(hasKey)) {
|
||||
throw new RuntimeException("任务不存在或已过期");
|
||||
}
|
||||
|
||||
Map<Object, Object> statusMap = redisTemplate.opsForHash().entries(key);
|
||||
|
||||
ImportStatusVO statusVO = new ImportStatusVO();
|
||||
statusVO.setTaskId((String) statusMap.get("taskId"));
|
||||
statusVO.setStatus((String) statusMap.get("status"));
|
||||
statusVO.setTotalCount((Integer) statusMap.get("totalCount"));
|
||||
statusVO.setSuccessCount((Integer) statusMap.get("successCount"));
|
||||
statusVO.setFailureCount((Integer) statusMap.get("failureCount"));
|
||||
statusVO.setProgress((Integer) statusMap.get("progress"));
|
||||
statusVO.setStartTime((Long) statusMap.get("startTime"));
|
||||
statusVO.setEndTime((Long) statusMap.get("endTime"));
|
||||
statusVO.setMessage((String) statusMap.get("message"));
|
||||
|
||||
return statusVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新导入状态
|
||||
*/
|
||||
private void updateImportStatus(String taskId, String status, ImportResult result) {
|
||||
String key = "import:staffFmyRelation:" + taskId;
|
||||
Map<String, Object> statusData = new HashMap<>();
|
||||
statusData.put("status", status);
|
||||
statusData.put("successCount", result.getSuccessCount());
|
||||
statusData.put("failureCount", result.getFailureCount());
|
||||
statusData.put("progress", 100);
|
||||
statusData.put("endTime", System.currentTimeMillis());
|
||||
|
||||
if ("SUCCESS".equals(status)) {
|
||||
statusData.put("message", "全部成功!共导入" + result.getTotalCount() + "条数据");
|
||||
} else {
|
||||
statusData.put("message", "成功" + result.getSuccessCount() + "条,失败" + result.getFailureCount() + "条");
|
||||
}
|
||||
|
||||
redisTemplate.opsForHash().putAll(key, statusData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存
|
||||
*/
|
||||
private void saveBatch(List<CcdiStaffFmyRelation> list, int batchSize) {
|
||||
// 使用真正的批量插入,分批次执行以提高性能
|
||||
for (int i = 0; i < list.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, list.size());
|
||||
List<CcdiStaffFmyRelation> subList = list.subList(i, end);
|
||||
relationMapper.insertBatch(subList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证员工亲属关系数据
|
||||
*
|
||||
* @param addDTO 新增DTO
|
||||
*/
|
||||
private void validateRelationData(CcdiStaffFmyRelationAddDTO addDTO) {
|
||||
// 验证必填字段
|
||||
if (StringUtils.isEmpty(addDTO.getPersonId())) {
|
||||
throw new RuntimeException("员工身份证号不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getRelationType())) {
|
||||
throw new RuntimeException("关系类型不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getRelationName())) {
|
||||
throw new RuntimeException("关系人姓名不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getRelationCertType())) {
|
||||
throw new RuntimeException("关系人证件类型不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getRelationCertNo())) {
|
||||
throw new RuntimeException("关系人证件号码不能为空");
|
||||
}
|
||||
|
||||
// 验证身份证号格式
|
||||
if (!addDTO.getPersonId().matches("^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[\\dXx]$")) {
|
||||
throw new RuntimeException("员工身份证号格式不正确");
|
||||
}
|
||||
|
||||
// 验证手机号格式(如果提供)
|
||||
if (StringUtils.isNotEmpty(addDTO.getMobilePhone1()) && !addDTO.getMobilePhone1().matches("^1[3-9]\\d{9}$")) {
|
||||
throw new RuntimeException("手机号码1格式不正确");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(addDTO.getMobilePhone2()) && !addDTO.getMobilePhone2().matches("^1[3-9]\\d{9}$")) {
|
||||
throw new RuntimeException("手机号码2格式不正确");
|
||||
}
|
||||
|
||||
// 验证性别值(如果提供)
|
||||
if (StringUtils.isNotEmpty(addDTO.getGender()) && !addDTO.getGender().matches("^[MFO]$")) {
|
||||
throw new RuntimeException("性别只能是M、F或O");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.ruoyi.ccdi.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.ccdi.domain.CcdiStaffFmyRelation;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationEditDTO;
|
||||
import com.ruoyi.ccdi.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||
import com.ruoyi.ccdi.domain.excel.CcdiStaffFmyRelationExcel;
|
||||
import com.ruoyi.ccdi.domain.vo.CcdiStaffFmyRelationVO;
|
||||
import com.ruoyi.ccdi.mapper.CcdiStaffFmyRelationMapper;
|
||||
import com.ruoyi.ccdi.service.ICcdiStaffFmyRelationImportService;
|
||||
import com.ruoyi.ccdi.service.ICcdiStaffFmyRelationService;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 员工亲属关系 服务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
@Service
|
||||
public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationService {
|
||||
|
||||
@Resource
|
||||
private CcdiStaffFmyRelationMapper relationMapper;
|
||||
|
||||
@Resource
|
||||
private ICcdiStaffFmyRelationImportService relationImportService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系列表
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工亲属关系VO集合
|
||||
*/
|
||||
@Override
|
||||
public java.util.List<CcdiStaffFmyRelationVO> selectRelationList(CcdiStaffFmyRelationQueryDTO queryDTO) {
|
||||
Page<CcdiStaffFmyRelationVO> page = new Page<>(1, Integer.MAX_VALUE);
|
||||
Page<CcdiStaffFmyRelationVO> resultPage = relationMapper.selectRelationPage(page, queryDTO);
|
||||
return resultPage.getRecords();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询员工亲属关系列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工亲属关系VO分页结果
|
||||
*/
|
||||
@Override
|
||||
public Page<CcdiStaffFmyRelationVO> selectRelationPage(Page<CcdiStaffFmyRelationVO> page, CcdiStaffFmyRelationQueryDTO queryDTO) {
|
||||
return relationMapper.selectRelationPage(page, queryDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系列表(用于导出)
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 员工亲属关系Excel实体集合
|
||||
*/
|
||||
@Override
|
||||
public java.util.List<CcdiStaffFmyRelationExcel> selectRelationListForExport(CcdiStaffFmyRelationQueryDTO queryDTO) {
|
||||
return relationMapper.selectRelationListForExport(queryDTO).stream().map(vo -> {
|
||||
CcdiStaffFmyRelationExcel excel = new CcdiStaffFmyRelationExcel();
|
||||
BeanUtils.copyProperties(vo, excel);
|
||||
return excel;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 员工亲属关系VO
|
||||
*/
|
||||
@Override
|
||||
public CcdiStaffFmyRelationVO selectRelationById(Long id) {
|
||||
return relationMapper.selectRelationById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增员工亲属关系
|
||||
*
|
||||
* @param addDTO 新增DTO
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertRelation(CcdiStaffFmyRelationAddDTO addDTO) {
|
||||
CcdiStaffFmyRelation relation = new CcdiStaffFmyRelation();
|
||||
BeanUtils.copyProperties(addDTO, relation);
|
||||
|
||||
// 设置默认值
|
||||
relation.setIsEmpFamily(true);
|
||||
relation.setIsCustFamily(false);
|
||||
relation.setDataSource("MANUAL");
|
||||
if (relation.getStatus() == null) {
|
||||
relation.setStatus(1);
|
||||
}
|
||||
|
||||
int result = relationMapper.insert(relation);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改员工亲属关系
|
||||
*
|
||||
* @param editDTO 编辑DTO
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateRelation(CcdiStaffFmyRelationEditDTO editDTO) {
|
||||
CcdiStaffFmyRelation relation = new CcdiStaffFmyRelation();
|
||||
BeanUtils.copyProperties(editDTO, relation);
|
||||
int result = relationMapper.updateById(relation);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除员工亲属关系
|
||||
*
|
||||
* @param ids 需要删除的主键ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteRelationByIds(Long[] ids) {
|
||||
return relationMapper.deleteBatchIds(java.util.List.of(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入员工亲属关系数据(异步)
|
||||
*
|
||||
* @param excelList Excel实体列表
|
||||
* @return 任务ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public String importRelation(java.util.List<CcdiStaffFmyRelationExcel> excelList) {
|
||||
if (StringUtils.isNull(excelList) || excelList.isEmpty()) {
|
||||
throw new RuntimeException("至少需要一条数据");
|
||||
}
|
||||
|
||||
// 生成任务ID
|
||||
String taskId = UUID.randomUUID().toString();
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// 获取当前用户名
|
||||
String userName = SecurityUtils.getUsername();
|
||||
|
||||
// 初始化Redis状态
|
||||
String statusKey = "import:staffFmyRelation:" + taskId;
|
||||
Map<String, Object> statusData = new HashMap<>();
|
||||
statusData.put("taskId", taskId);
|
||||
statusData.put("status", "PROCESSING");
|
||||
statusData.put("totalCount", excelList.size());
|
||||
statusData.put("successCount", 0);
|
||||
statusData.put("failureCount", 0);
|
||||
statusData.put("progress", 0);
|
||||
statusData.put("startTime", startTime);
|
||||
statusData.put("message", "正在处理...");
|
||||
|
||||
redisTemplate.opsForHash().putAll(statusKey, statusData);
|
||||
redisTemplate.expire(statusKey, 7, TimeUnit.DAYS);
|
||||
|
||||
// 调用异步导入服务
|
||||
relationImportService.importRelationAsync(excelList, taskId, userName);
|
||||
|
||||
return taskId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ccdi.mapper.CcdiStaffFmyRelationMapper">
|
||||
|
||||
<!-- 员工亲属关系ResultMap -->
|
||||
<resultMap type="com.ruoyi.ccdi.domain.vo.CcdiStaffFmyRelationVO" id="CcdiStaffFmyRelationVOResult">
|
||||
<id property="id" column="id"/>
|
||||
<result property="personId" column="person_id"/>
|
||||
<result property="personName" column="person_name"/>
|
||||
<result property="relationType" column="relation_type"/>
|
||||
<result property="relationName" column="relation_name"/>
|
||||
<result property="gender" column="gender"/>
|
||||
<result property="birthDate" column="birth_date"/>
|
||||
<result property="relationCertType" column="relation_cert_type"/>
|
||||
<result property="relationCertNo" column="relation_cert_no"/>
|
||||
<result property="mobilePhone1" column="mobile_phone1"/>
|
||||
<result property="mobilePhone2" column="mobile_phone2"/>
|
||||
<result property="wechatNo1" column="wechat_no1"/>
|
||||
<result property="wechatNo2" column="wechat_no2"/>
|
||||
<result property="wechatNo3" column="wechat_no3"/>
|
||||
<result property="contactAddress" column="contact_address"/>
|
||||
<result property="relationDesc" column="relation_desc"/>
|
||||
<result property="effectiveDate" column="effective_date"/>
|
||||
<result property="invalidDate" column="invalid_date"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="dataSource" column="data_source"/>
|
||||
<result property="isEmpFamily" column="is_emp_family"/>
|
||||
<result property="isCustFamily" column="is_cust_family"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="createdBy" column="created_by"/>
|
||||
<result property="updatedBy" column="updated_by"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 分页查询员工亲属关系列表 -->
|
||||
<select id="selectRelationPage" resultMap="CcdiStaffFmyRelationVOResult">
|
||||
SELECT
|
||||
r.id, r.person_id, s.name as person_name, r.relation_type, r.relation_name,
|
||||
r.gender, r.birth_date, r.relation_cert_type, r.relation_cert_no,
|
||||
r.mobile_phone1, r.mobile_phone2, r.wechat_no1, r.wechat_no2, r.wechat_no3,
|
||||
r.contact_address, r.relation_desc, r.effective_date, r.invalid_date,
|
||||
r.status, r.remark, r.data_source, r.is_emp_family, r.is_cust_family,
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time
|
||||
FROM ccdi_staff_fmy_relation r
|
||||
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
||||
<where>
|
||||
r.is_emp_family = 1
|
||||
<if test="query.personId != null and query.personId != ''">
|
||||
AND r.person_id = #{query.personId}
|
||||
</if>
|
||||
<if test="query.personName != null and query.personName != ''">
|
||||
AND s.name LIKE CONCAT('%', #{query.personName}, '%')
|
||||
</if>
|
||||
<if test="query.relationType != null and query.relationType != ''">
|
||||
AND r.relation_type = #{query.relationType}
|
||||
</if>
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND r.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.dataSource != null and query.dataSource != ''">
|
||||
AND r.data_source = #{query.dataSource}
|
||||
</if>
|
||||
<if test="query.effectiveDateStart != null">
|
||||
AND r.effective_date >= #{query.effectiveDateStart}
|
||||
</if>
|
||||
<if test="query.effectiveDateEnd != null">
|
||||
AND r.effective_date <= #{query.effectiveDateEnd}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY r.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询员工亲属关系详情 -->
|
||||
<select id="selectRelationById" resultMap="CcdiStaffFmyRelationVOResult">
|
||||
SELECT
|
||||
r.id, r.person_id, s.name as person_name, r.relation_type, r.relation_name,
|
||||
r.gender, r.birth_date, r.relation_cert_type, r.relation_cert_no,
|
||||
r.mobile_phone1, r.mobile_phone2, r.wechat_no1, r.wechat_no2, r.wechat_no3,
|
||||
r.contact_address, r.relation_desc, r.effective_date, r.invalid_date,
|
||||
r.status, r.remark, r.data_source, r.is_emp_family, r.is_cust_family,
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time
|
||||
FROM ccdi_staff_fmy_relation r
|
||||
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
||||
WHERE r.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 查询员工亲属关系列表(用于导出) -->
|
||||
<select id="selectRelationListForExport" resultMap="CcdiStaffFmyRelationVOResult">
|
||||
SELECT
|
||||
r.id, r.person_id, s.name as person_name, r.relation_type, r.relation_name,
|
||||
r.gender, r.birth_date, r.relation_cert_type, r.relation_cert_no,
|
||||
r.mobile_phone1, r.mobile_phone2, r.wechat_no1, r.wechat_no2, r.wechat_no3,
|
||||
r.contact_address, r.relation_desc, r.effective_date, r.invalid_date,
|
||||
r.status, r.remark, r.data_source, r.is_emp_family, r.is_cust_family,
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time
|
||||
FROM ccdi_staff_fmy_relation r
|
||||
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
||||
<where>
|
||||
r.is_emp_family = 1
|
||||
<if test="query.personId != null and query.personId != ''">
|
||||
AND r.person_id = #{query.personId}
|
||||
</if>
|
||||
<if test="query.personName != null and query.personName != ''">
|
||||
AND s.name LIKE CONCAT('%', #{query.personName}, '%')
|
||||
</if>
|
||||
<if test="query.relationType != null and query.relationType != ''">
|
||||
AND r.relation_type = #{query.relationType}
|
||||
</if>
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND r.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.dataSource != null and query.dataSource != ''">
|
||||
AND r.data_source = #{query.dataSource}
|
||||
</if>
|
||||
<if test="query.effectiveDateStart != null">
|
||||
AND r.effective_date >= #{query.effectiveDateStart}
|
||||
</if>
|
||||
<if test="query.effectiveDateEnd != null">
|
||||
AND r.effective_date <= #{query.effectiveDateEnd}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY r.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 批量插入员工亲属关系数据 -->
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO ccdi_staff_fmy_relation
|
||||
(person_id, relation_type, relation_name, gender, birth_date, relation_cert_type, relation_cert_no,
|
||||
mobile_phone1, mobile_phone2, wechat_no1, wechat_no2, wechat_no3, contact_address, relation_desc,
|
||||
effective_date, invalid_date, status, remark, data_source, is_emp_family, is_cust_family,
|
||||
created_by, create_time, updated_by, update_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.personId}, #{item.relationType}, #{item.relationName}, #{item.gender},
|
||||
#{item.birthDate}, #{item.relationCertType}, #{item.relationCertNo}, #{item.mobilePhone1},
|
||||
#{item.mobilePhone2}, #{item.wechatNo1}, #{item.wechatNo2}, #{item.wechatNo3}, #{item.contactAddress},
|
||||
#{item.relationDesc}, #{item.effectiveDate}, #{item.invalidDate}, #{item.status}, #{item.remark},
|
||||
#{item.dataSource}, #{item.isEmpFamily}, #{item.isCustFamily}, #{item.createdBy}, NOW(), #{item.updatedBy}, NOW())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user