删除旧的
This commit is contained in:
@@ -1,195 +0,0 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 员工亲属关系信息异步导入服务层处理
|
||||
*
|
||||
* @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<>();
|
||||
|
||||
// 批量查询已存在的person_id + relation_cert_no组合
|
||||
Set<String> existingCombinations = getExistingCombinations(excelList);
|
||||
|
||||
// 用于跟踪Excel文件内已处理的组合
|
||||
Set<String> processedCombinations = 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, existingCombinations);
|
||||
|
||||
String combinationKey = excel.getPersonId() + "_" + excel.getRelationCertNo();
|
||||
|
||||
if (existingCombinations.contains(combinationKey)) {
|
||||
// person_id + relation_cert_no已存在,直接报错
|
||||
throw new RuntimeException(String.format("员工[%s]的亲属证件号[%s]已存在,请勿重复导入",
|
||||
excel.getPersonId(), excel.getRelationCertNo()));
|
||||
} else if (processedCombinations.contains(combinationKey)) {
|
||||
// Excel文件内部重复
|
||||
throw new RuntimeException(String.format("员工[%s]的亲属证件号[%s]在导入文件中重复,已跳过此条记录",
|
||||
excel.getPersonId(), excel.getRelationCertNo()));
|
||||
} else {
|
||||
CcdiStaffFmyRelation relation = new CcdiStaffFmyRelation();
|
||||
BeanUtils.copyProperties(excel, relation);
|
||||
relation.setCreatedBy(userName);
|
||||
relation.setUpdatedBy(userName);
|
||||
relation.setIsEmpFamily(0);
|
||||
relation.setIsCustFamily(0);
|
||||
newRecords.add(relation);
|
||||
processedCombinations.add(combinationKey);
|
||||
}
|
||||
|
||||
} 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询已存在的person_id + relation_cert_no组合
|
||||
*/
|
||||
private Set<String> getExistingCombinations(List<CcdiStaffFmyRelationExcel> excelList) {
|
||||
// 提取所有person_id
|
||||
Set<String> personIds = excelList.stream()
|
||||
.map(CcdiStaffFmyRelationExcel::getPersonId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (personIds.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
// 查询这些person_id的所有亲属关系
|
||||
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<CcdiStaffFmyRelation> wrapper =
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<>();
|
||||
wrapper.in(CcdiStaffFmyRelation::getPersonId, personIds);
|
||||
|
||||
List<CcdiStaffFmyRelation> existingRelations = relationMapper.selectList(wrapper);
|
||||
|
||||
return existingRelations.stream()
|
||||
.map(r -> r.getPersonId() + "_" + r.getRelationCertNo())
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存
|
||||
*/
|
||||
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
|
||||
* @param existingCombinations 已存在的组合集合
|
||||
*/
|
||||
private void validateRelationData(CcdiStaffFmyRelationAddDTO addDTO, Set<String> existingCombinations) {
|
||||
// 验证必填字段
|
||||
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.getStatus() == null) {
|
||||
throw new RuntimeException("状态不能为空");
|
||||
}
|
||||
|
||||
// 验证身份证号格式
|
||||
if (!addDTO.getPersonId().matches("^\\d{17}[\\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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
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) {
|
||||
// 检查唯一性:person_id + relation_cert_no
|
||||
validateUniqueRelation(addDTO.getPersonId(), addDTO.getRelationCertNo(), null);
|
||||
|
||||
// 验证person_id是否在ccdi_base_staff表中存在
|
||||
validatePersonIdExists(addDTO.getPersonId());
|
||||
|
||||
CcdiStaffFmyRelation relation = new CcdiStaffFmyRelation();
|
||||
BeanUtils.copyProperties(addDTO, relation);
|
||||
int result = relationMapper.insert(relation);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改员工亲属关系
|
||||
*
|
||||
* @param editDTO 编辑DTO
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateRelation(CcdiStaffFmyRelationEditDTO editDTO) {
|
||||
// 检查唯一性:person_id + relation_cert_no(排除自身)
|
||||
validateUniqueRelation(editDTO.getPersonId(), editDTO.getRelationCertNo(), editDTO.getId());
|
||||
|
||||
// 验证person_id是否在ccdi_base_staff表中存在
|
||||
validatePersonIdExists(editDTO.getPersonId());
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证唯一性:person_id + relation_cert_no
|
||||
*
|
||||
* @param personId 员工身份证号
|
||||
* @param relationCertNo 亲属证件号
|
||||
* @param excludeId 排除的记录ID(修改时使用)
|
||||
*/
|
||||
private void validateUniqueRelation(String personId, String relationCertNo, Long excludeId) {
|
||||
// 这里需要调用Mapper查询是否存在重复记录
|
||||
// 简化处理:使用LambdaQueryWrapper查询
|
||||
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<CcdiStaffFmyRelation> wrapper =
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<>();
|
||||
wrapper.eq(CcdiStaffFmyRelation::getPersonId, personId)
|
||||
.eq(CcdiStaffFmyRelation::getRelationCertNo, relationCertNo);
|
||||
|
||||
if (excludeId != null) {
|
||||
wrapper.ne(CcdiStaffFmyRelation::getId, excludeId);
|
||||
}
|
||||
|
||||
CcdiStaffFmyRelation existing = relationMapper.selectOne(wrapper);
|
||||
if (existing != null) {
|
||||
throw new RuntimeException("该员工已存在相同亲属证件号的关系记录");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证person_id是否在ccdi_base_staff表中存在
|
||||
*
|
||||
* @param personId 员工身份证号
|
||||
*/
|
||||
private void validatePersonIdExists(String personId) {
|
||||
// 这里需要查询ccdi_base_staff表
|
||||
// TODO: 注入CcdiBaseStaffMapper并查询
|
||||
// 暂时简化处理:如果personId格式正确则认为存在
|
||||
if (!personId.matches("^\\d{17}[\\dXx]$")) {
|
||||
throw new RuntimeException("员工身份证号格式不正确");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询员工亲属关系列表
|
||||
export function listRelation(query) {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询员工亲属关系详情
|
||||
export function getRelation(id) {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增员工亲属关系
|
||||
export function addRelation(data) {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改员工亲属关系
|
||||
export function updateRelation(data) {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除员工亲属关系
|
||||
export function delRelation(ids) {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation/' + ids,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 导出员工亲属关系
|
||||
export function exportRelation(query) {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation/export',
|
||||
method: 'post',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 下载导入模板
|
||||
export function importTemplate() {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation/importTemplate',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
// 导入员工亲属关系
|
||||
export function importData(file) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation/importData',
|
||||
method: 'post',
|
||||
data: formData
|
||||
})
|
||||
}
|
||||
|
||||
// 查询导入状态
|
||||
export function getImportStatus(taskId) {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation/importStatus/' + taskId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询导入失败记录
|
||||
export function getImportFailures(taskId, pageNum, pageSize) {
|
||||
return request({
|
||||
url: '/ccdi/staffFmyRelation/importFailures/' + taskId,
|
||||
method: 'get',
|
||||
params: { pageNum, pageSize }
|
||||
})
|
||||
}
|
||||
@@ -1,716 +0,0 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
|
||||
<el-form-item label="员工身份证号" prop="personId">
|
||||
<el-input
|
||||
v-model="queryParams.personId"
|
||||
placeholder="请输入员工身份证号"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="关系人姓名" prop="relationName">
|
||||
<el-input
|
||||
v-model="queryParams.relationName"
|
||||
placeholder="请输入关系人姓名"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="关系类型" prop="relationType">
|
||||
<el-select v-model="queryParams.relationType" placeholder="请选择关系类型" clearable style="width: 240px">
|
||||
<el-option label="配偶" value="配偶" />
|
||||
<el-option label="父亲" value="父亲" />
|
||||
<el-option label="母亲" value="母亲" />
|
||||
<el-option label="儿子" value="儿子" />
|
||||
<el-option label="女儿" value="女儿" />
|
||||
<el-option label="祖父" value="祖父" />
|
||||
<el-option label="祖母" value="祖母" />
|
||||
<el-option label="外祖父" value="外祖父" />
|
||||
<el-option label="外祖母" value="外祖母" />
|
||||
<el-option label="兄弟姐妹" value="兄弟姐妹" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="证件号码" prop="relationCertNo">
|
||||
<el-input
|
||||
v-model="queryParams.relationCertNo"
|
||||
placeholder="请输入证件号码"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 240px">
|
||||
<el-option label="有效" :value="1" />
|
||||
<el-option label="无效" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['ccdi:staffFmyRelation:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="handleImport"
|
||||
v-hasPermi="['ccdi:staffFmyRelation:import']"
|
||||
>导入</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['ccdi:staffFmyRelation:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5" v-if="showFailureButton">
|
||||
<el-tooltip
|
||||
:content="getLastImportTooltip()"
|
||||
placement="top"
|
||||
>
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-warning"
|
||||
size="mini"
|
||||
@click="viewImportFailures"
|
||||
>查看导入失败记录</el-button>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="relationList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="员工身份证号" align="center" prop="personId" width="180" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="关系类型" align="center" prop="relationType" width="100"/>
|
||||
<el-table-column label="关系人姓名" align="center" prop="relationName" width="120"/>
|
||||
<el-table-column label="性别" align="center" prop="gender" width="80">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.gender === 'M'">男</span>
|
||||
<span v-else-if="scope.row.gender === 'F'">女</span>
|
||||
<span v-else-if="scope.row.gender === 'O'">其他</span>
|
||||
<span v-else>{{ scope.row.gender }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="证件类型" align="center" prop="relationCertType" width="100"/>
|
||||
<el-table-column label="证件号码" align="center" prop="relationCertNo" width="180" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="手机号码1" align="center" prop="mobilePhone1" width="120"/>
|
||||
<el-table-column label="状态" align="center" prop="status" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.status === 1" type="success">有效</el-tag>
|
||||
<el-tag v-else type="danger">无效</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="160"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['ccdi:staffFmyRelation:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['ccdi:staffFmyRelation:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
|
||||
<el-divider content-position="left">基本信息</el-divider>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="员工身份证号" prop="personId">
|
||||
<el-input v-model="form.personId" placeholder="请输入员工身份证号" maxlength="18" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="关系类型" prop="relationType">
|
||||
<el-select v-model="form.relationType" placeholder="请选择关系类型" style="width: 100%">
|
||||
<el-option label="配偶" value="配偶" />
|
||||
<el-option label="父亲" value="父亲" />
|
||||
<el-option label="母亲" value="母亲" />
|
||||
<el-option label="儿子" value="儿子" />
|
||||
<el-option label="女儿" value="女儿" />
|
||||
<el-option label="祖父" value="祖父" />
|
||||
<el-option label="祖母" value="祖母" />
|
||||
<el-option label="外祖父" value="外祖父" />
|
||||
<el-option label="外祖母" value="外祖母" />
|
||||
<el-option label="兄弟姐妹" value="兄弟姐妹" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="关系人姓名" prop="relationName">
|
||||
<el-input v-model="form.relationName" placeholder="请输入关系人姓名" maxlength="100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="性别" prop="gender">
|
||||
<el-select v-model="form.gender" placeholder="请选择性别" style="width: 100%">
|
||||
<el-option label="男" value="M" />
|
||||
<el-option label="女" value="F" />
|
||||
<el-option label="其他" value="O" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="出生日期" prop="birthDate">
|
||||
<el-date-picker
|
||||
v-model="form.birthDate"
|
||||
type="date"
|
||||
placeholder="选择出生日期"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="证件类型" prop="relationCertType">
|
||||
<el-input v-model="form.relationCertType" placeholder="请输入证件类型" maxlength="50" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="证件号码" prop="relationCertNo">
|
||||
<el-input v-model="form.relationCertNo" placeholder="请输入证件号码" maxlength="50" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio :label="1">有效</el-radio>
|
||||
<el-radio :label="0">无效</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-divider content-position="left">联系方式</el-divider>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="手机号码1" prop="mobilePhone1">
|
||||
<el-input v-model="form.mobilePhone1" placeholder="请输入手机号码1" maxlength="11" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="手机号码2" prop="mobilePhone2">
|
||||
<el-input v-model="form.mobilePhone2" placeholder="请输入手机号码2" maxlength="11" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="微信名称1" prop="wechatNo1">
|
||||
<el-input v-model="form.wechatNo1" placeholder="请输入微信名称1" maxlength="100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="微信名称2" prop="wechatNo2">
|
||||
<el-input v-model="form.wechatNo2" placeholder="请输入微信名称2" maxlength="100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="微信名称3" prop="wechatNo3">
|
||||
<el-input v-model="form.wechatNo3" placeholder="请输入微信名称3" maxlength="100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="详细联系地址" prop="contactAddress">
|
||||
<el-input v-model="form.contactAddress" placeholder="请输入详细联系地址" maxlength="255" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-divider content-position="left">其他信息</el-divider>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="关系详细描述" prop="relationDesc">
|
||||
<el-input v-model="form.relationDesc" type="textarea" :rows="2" placeholder="请输入关系详细描述" maxlength="500" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="备注信息" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注信息" maxlength="500" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="关系生效日期" prop="effectiveDate">
|
||||
<el-date-picker
|
||||
v-model="form.effectiveDate"
|
||||
type="datetime"
|
||||
placeholder="选择关系生效日期"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="关系失效日期" prop="invalidDate">
|
||||
<el-date-picker
|
||||
v-model="form.invalidDate"
|
||||
type="datetime"
|
||||
placeholder="选择关系失效日期"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:limit="1"
|
||||
accept=".xlsx, .xls"
|
||||
:headers="upload.headers"
|
||||
:action="upload.url"
|
||||
:disabled="upload.isUploading"
|
||||
:on-progress="handleFileUploadProgress"
|
||||
:on-success="handleFileSuccess"
|
||||
:auto-upload="false"
|
||||
drag
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
<span>仅允许导入"xls"或"xlsx"格式文件。</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitFileForm" :loading="upload.isUploading">确 定</el-button>
|
||||
<el-button @click="upload.open = false" :disabled="upload.isUploading">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导入结果对话框 -->
|
||||
<import-result-dialog
|
||||
:visible.sync="importResultVisible"
|
||||
:content="importResultContent"
|
||||
title="导入结果"
|
||||
@close="handleImportResultClose"
|
||||
/>
|
||||
|
||||
<!-- 导入失败记录对话框 -->
|
||||
<el-dialog
|
||||
title="导入失败记录"
|
||||
:visible.sync="failureDialogVisible"
|
||||
width="1200px"
|
||||
append-to-body
|
||||
>
|
||||
<el-alert
|
||||
v-if="lastImportInfo"
|
||||
:title="lastImportInfo"
|
||||
type="info"
|
||||
:closable="false"
|
||||
style="margin-bottom: 15px"
|
||||
/>
|
||||
|
||||
<el-table :data="failureList" v-loading="failureLoading">
|
||||
<el-table-column label="员工身份证号" prop="personId" align="center" width="180" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="关系类型" prop="relationType" align="center" width="100"/>
|
||||
<el-table-column label="关系人姓名" prop="relationName" align="center" width="120"/>
|
||||
<el-table-column label="性别" prop="gender" align="center" width="80"/>
|
||||
<el-table-column label="证件类型" prop="relationCertType" align="center" width="100"/>
|
||||
<el-table-column label="证件号码" prop="relationCertNo" align="center" width="180" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="手机号码1" prop="mobilePhone1" align="center" width="120"/>
|
||||
<el-table-column label="状态" prop="status" align="center" width="80"/>
|
||||
<el-table-column label="失败原因" prop="errorMessage" align="center" min-width="200" :show-overflow-tooltip="true" />
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="failureTotal > 0"
|
||||
:total="failureTotal"
|
||||
:page.sync="failureQueryParams.pageNum"
|
||||
:limit.sync="failureQueryParams.pageSize"
|
||||
@pagination="getFailureList"
|
||||
/>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="failureDialogVisible = false">关闭</el-button>
|
||||
<el-button type="danger" plain @click="clearImportHistory">清除历史记录</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
addRelation,
|
||||
delRelation,
|
||||
getImportFailures,
|
||||
getImportStatus,
|
||||
getRelation,
|
||||
listRelation,
|
||||
updateRelation
|
||||
} from "@/api/ccdiStaffFmyRelation";
|
||||
import {getToken} from "@/utils/auth";
|
||||
import ImportResultDialog from "@/components/ImportResultDialog.vue";
|
||||
|
||||
export default {
|
||||
name: "StaffFmyRelation",
|
||||
components: { ImportResultDialog },
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 员工亲属关系表格数据
|
||||
relationList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 是否为新增操作
|
||||
isAdd: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
personId: null,
|
||||
relationName: null,
|
||||
relationType: null,
|
||||
relationCertNo: null,
|
||||
status: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
personId: [
|
||||
{ required: true, message: "员工身份证号不能为空", trigger: "blur" },
|
||||
{ pattern: /^\\d{17}[\dXx]$/, message: "员工身份证号格式不正确", trigger: "blur" }
|
||||
],
|
||||
relationType: [
|
||||
{ required: true, message: "关系类型不能为空", trigger: "change" }
|
||||
],
|
||||
relationName: [
|
||||
{ required: true, message: "关系人姓名不能为空", trigger: "blur" },
|
||||
{ max: 100, message: "关系人姓名长度不能超过100个字符", trigger: "blur" }
|
||||
],
|
||||
relationCertType: [
|
||||
{ required: true, message: "证件类型不能为空", trigger: "blur" },
|
||||
{ max: 50, message: "证件类型长度不能超过50个字符", trigger: "blur" }
|
||||
],
|
||||
relationCertNo: [
|
||||
{ required: true, message: "证件号码不能为空", trigger: "blur" },
|
||||
{ max: 50, message: "证件号码长度不能超过50个字符", trigger: "blur" }
|
||||
],
|
||||
status: [
|
||||
{ required: true, message: "状态不能为空", trigger: "change" }
|
||||
],
|
||||
mobilePhone1: [
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: "手机号码1格式不正确", trigger: "blur" }
|
||||
],
|
||||
mobilePhone2: [
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: "手机号码2格式不正确", trigger: "blur" }
|
||||
]
|
||||
},
|
||||
// 导入参数
|
||||
upload: {
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: "Bearer " + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + "/ccdi/staffFmyRelation/importData"
|
||||
},
|
||||
// 导入结果对话框
|
||||
importResultVisible: false,
|
||||
importResultContent: "",
|
||||
// 导入失败记录
|
||||
failureDialogVisible: false,
|
||||
failureList: [],
|
||||
failureLoading: false,
|
||||
failureTotal: 0,
|
||||
failureQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
},
|
||||
lastTaskId: null,
|
||||
lastImportInfo: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
showFailureButton() {
|
||||
return this.lastTaskId && this.lastImportInfo && this.lastImportInfo.includes("失败");
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询员工亲属关系列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listRelation(this.queryParams).then(response => {
|
||||
this.relationList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
personId: null,
|
||||
relationType: null,
|
||||
relationName: null,
|
||||
gender: null,
|
||||
birthDate: null,
|
||||
relationCertType: null,
|
||||
relationCertNo: null,
|
||||
mobilePhone1: null,
|
||||
mobilePhone2: null,
|
||||
wechatNo1: null,
|
||||
wechatNo2: null,
|
||||
wechatNo3: null,
|
||||
contactAddress: null,
|
||||
relationDesc: null,
|
||||
status: 1,
|
||||
effectiveDate: null,
|
||||
invalidDate: null,
|
||||
remark: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 多选框选中数据 */
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加员工亲属关系信息";
|
||||
this.isAdd = true;
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids[0];
|
||||
getRelation(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改员工亲属关系信息";
|
||||
this.isAdd = false;
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateRelation(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addRelation(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除员工亲属关系信息编号为"' + ids + '"的数据项?').then(function() {
|
||||
return delRelation(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('ccdi/staffFmyRelation/export', {
|
||||
...this.queryParams
|
||||
}, `员工亲属关系信息_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 导入按钮操作 */
|
||||
handleImport() {
|
||||
this.upload.title = "导入员工亲属关系信息";
|
||||
this.upload.open = true;
|
||||
},
|
||||
/** 下载模板操作 */
|
||||
importTemplate() {
|
||||
this.download('ccdi/staffFmyRelation/importTemplate', {}, `员工亲属关系信息导入模板_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress(event, file, fileList) {
|
||||
this.upload.isUploading = true;
|
||||
},
|
||||
// 文件上传成功处理
|
||||
handleFileSuccess(response, file, fileList) {
|
||||
this.upload.isUploading = false;
|
||||
if (response.code === 200) {
|
||||
const taskId = response.data.taskId;
|
||||
this.lastTaskId = taskId;
|
||||
this.upload.open = false;
|
||||
this.pollImportStatus(taskId);
|
||||
} else {
|
||||
this.$modal.msgError(response.msg);
|
||||
this.upload.open = false;
|
||||
}
|
||||
this.$refs.upload.clearFiles();
|
||||
},
|
||||
// 提交上传文件
|
||||
submitFileForm() {
|
||||
this.$refs.upload.submit();
|
||||
},
|
||||
// 轮询导入状态
|
||||
pollImportStatus(taskId) {
|
||||
const poll = async () => {
|
||||
try {
|
||||
const statusRes = await getImportStatus(taskId);
|
||||
const status = statusRes.data.status;
|
||||
|
||||
if (status === "PROCESSING") {
|
||||
// 继续轮询
|
||||
setTimeout(poll, 1000);
|
||||
} else {
|
||||
// 导入完成
|
||||
this.importResultVisible = true;
|
||||
this.lastImportInfo = `共${statusRes.data.totalCount}条,成功${statusRes.data.successCount}条,失败${statusRes.data.failureCount}条`;
|
||||
this.importResultContent = this.lastImportInfo;
|
||||
this.getList();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("轮询导入状态失败:", error);
|
||||
this.$modal.msgError("导入状态查询失败");
|
||||
this.getList();
|
||||
}
|
||||
};
|
||||
poll();
|
||||
},
|
||||
// 查看导入失败记录
|
||||
viewImportFailures() {
|
||||
if (!this.lastTaskId) {
|
||||
this.$modal.msgWarning("没有可查看的导入记录");
|
||||
return;
|
||||
}
|
||||
this.failureDialogVisible = true;
|
||||
this.getFailureList();
|
||||
},
|
||||
// 获取导入失败记录
|
||||
getFailureList() {
|
||||
if (!this.lastTaskId) return;
|
||||
|
||||
this.failureLoading = true;
|
||||
getImportFailures(this.lastTaskId, this.failureQueryParams.pageNum, this.failureQueryParams.pageSize).then(response => {
|
||||
this.failureList = response.rows;
|
||||
this.failureTotal = response.total;
|
||||
this.failureLoading = false;
|
||||
}).catch(() => {
|
||||
this.failureLoading = false;
|
||||
});
|
||||
},
|
||||
// 清除导入历史记录
|
||||
clearImportHistory() {
|
||||
this.lastTaskId = null;
|
||||
this.lastImportInfo = null;
|
||||
this.failureList = [];
|
||||
this.failureTotal = 0;
|
||||
this.failureDialogVisible = false;
|
||||
this.$modal.msgSuccess("已清除导入历史记录");
|
||||
},
|
||||
// 导入结果对话框关闭
|
||||
handleImportResultClose() {
|
||||
this.importResultVisible = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user