完成员工亲属实体关联改造并清理旧数据
This commit is contained in:
@@ -5,6 +5,7 @@ import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
|||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationOptionVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.ImportResultVO;
|
import com.ruoyi.info.collection.domain.vo.ImportResultVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
||||||
@@ -33,12 +34,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息Controller
|
* 员工亲属实体关联Controller
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
*/
|
*/
|
||||||
@Tag(name = "员工实体关系信息管理")
|
@Tag(name = "员工亲属实体关联管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/ccdi/staffEnterpriseRelation")
|
@RequestMapping("/ccdi/staffEnterpriseRelation")
|
||||||
public class CcdiStaffEnterpriseRelationController extends BaseController {
|
public class CcdiStaffEnterpriseRelationController extends BaseController {
|
||||||
@@ -50,9 +51,9 @@ public class CcdiStaffEnterpriseRelationController extends BaseController {
|
|||||||
private ICcdiStaffEnterpriseRelationImportService relationImportService;
|
private ICcdiStaffEnterpriseRelationImportService relationImportService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工实体关系列表
|
* 查询员工亲属实体关联列表
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "查询员工实体关系列表")
|
@Operation(summary = "查询员工亲属实体关联列表")
|
||||||
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:list')")
|
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(CcdiStaffEnterpriseRelationQueryDTO queryDTO) {
|
public TableDataInfo list(CcdiStaffEnterpriseRelationQueryDTO queryDTO) {
|
||||||
@@ -64,9 +65,20 @@ public class CcdiStaffEnterpriseRelationController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取员工实体关系详细信息
|
* 查询有效员工亲属下拉列表
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "获取员工实体关系详细信息")
|
@Operation(summary = "查询有效员工亲属下拉列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:list')")
|
||||||
|
@GetMapping("/familyOptions")
|
||||||
|
public AjaxResult familyOptions(@RequestParam(required = false) String query) {
|
||||||
|
List<CcdiStaffEnterpriseRelationOptionVO> list = relationService.selectFamilyOptions(query);
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取员工亲属实体关联详细信息
|
||||||
|
*/
|
||||||
|
@Operation(summary = "获取员工亲属实体关联详细信息")
|
||||||
@Parameter(name = "id", description = "主键ID", required = true)
|
@Parameter(name = "id", description = "主键ID", required = true)
|
||||||
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:query')")
|
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:query')")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@@ -75,34 +87,34 @@ public class CcdiStaffEnterpriseRelationController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增员工实体关系
|
* 新增员工亲属实体关联
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "新增员工实体关系")
|
@Operation(summary = "新增员工亲属实体关联")
|
||||||
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:add')")
|
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:add')")
|
||||||
@Log(title = "员工实体关系信息", businessType = BusinessType.INSERT)
|
@Log(title = "员工亲属实体关联", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody CcdiStaffEnterpriseRelationAddDTO addDTO) {
|
public AjaxResult add(@Validated @RequestBody CcdiStaffEnterpriseRelationAddDTO addDTO) {
|
||||||
return toAjax(relationService.insertRelation(addDTO));
|
return toAjax(relationService.insertRelation(addDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改员工实体关系
|
* 修改员工亲属实体关联
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "修改员工实体关系")
|
@Operation(summary = "修改员工亲属实体关联")
|
||||||
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:edit')")
|
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:edit')")
|
||||||
@Log(title = "员工实体关系信息", businessType = BusinessType.UPDATE)
|
@Log(title = "员工亲属实体关联", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody CcdiStaffEnterpriseRelationEditDTO editDTO) {
|
public AjaxResult edit(@Validated @RequestBody CcdiStaffEnterpriseRelationEditDTO editDTO) {
|
||||||
return toAjax(relationService.updateRelation(editDTO));
|
return toAjax(relationService.updateRelation(editDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除员工实体关系
|
* 删除员工亲属实体关联
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "删除员工实体关系")
|
@Operation(summary = "删除员工亲属实体关联")
|
||||||
@Parameter(name = "ids", description = "主键ID数组", required = true)
|
@Parameter(name = "ids", description = "主键ID数组", required = true)
|
||||||
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:remove')")
|
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:remove')")
|
||||||
@Log(title = "员工实体关系信息", businessType = BusinessType.DELETE)
|
@Log(title = "员工亲属实体关联", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
return toAjax(relationService.deleteRelationByIds(ids));
|
return toAjax(relationService.deleteRelationByIds(ids));
|
||||||
@@ -115,16 +127,16 @@ public class CcdiStaffEnterpriseRelationController extends BaseController {
|
|||||||
@Operation(summary = "下载导入模板")
|
@Operation(summary = "下载导入模板")
|
||||||
@PostMapping("/importTemplate")
|
@PostMapping("/importTemplate")
|
||||||
public void importTemplate(HttpServletResponse response) {
|
public void importTemplate(HttpServletResponse response) {
|
||||||
EasyExcelUtil.importTemplateWithDictDropdown(response, CcdiStaffEnterpriseRelationExcel.class, "员工实体关系信息");
|
EasyExcelUtil.importTemplateWithDictDropdown(response, CcdiStaffEnterpriseRelationExcel.class, "员工亲属实体关联");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步导入员工实体关系
|
* 异步导入员工亲属实体关联
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "异步导入员工实体关系")
|
@Operation(summary = "异步导入员工亲属实体关联")
|
||||||
@Parameter(name = "file", description = "导入文件", required = true)
|
@Parameter(name = "file", description = "导入文件", required = true)
|
||||||
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:import')")
|
@PreAuthorize("@ss.hasPermi('ccdi:staffEnterpriseRelation:import')")
|
||||||
@Log(title = "员工实体关系信息", businessType = BusinessType.IMPORT)
|
@Log(title = "员工亲属实体关联", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/importData")
|
@PostMapping("/importData")
|
||||||
public AjaxResult importData(@Parameter(description = "导入文件") MultipartFile file) throws Exception {
|
public AjaxResult importData(@Parameter(description = "导入文件") MultipartFile file) throws Exception {
|
||||||
List<CcdiStaffEnterpriseRelationExcel> list = EasyExcelUtil.importExcel(file.getInputStream(), CcdiStaffEnterpriseRelationExcel.class);
|
List<CcdiStaffEnterpriseRelationExcel> list = EasyExcelUtil.importExcel(file.getInputStream(), CcdiStaffEnterpriseRelationExcel.class);
|
||||||
@@ -140,9 +152,9 @@ public class CcdiStaffEnterpriseRelationController extends BaseController {
|
|||||||
ImportResultVO result = new ImportResultVO();
|
ImportResultVO result = new ImportResultVO();
|
||||||
result.setTaskId(taskId);
|
result.setTaskId(taskId);
|
||||||
result.setStatus("PROCESSING");
|
result.setStatus("PROCESSING");
|
||||||
result.setMessage("导入任务已提交,正在后台处理");
|
result.setMessage("员工亲属实体关联导入任务已提交,正在后台处理");
|
||||||
|
|
||||||
return AjaxResult.success("导入任务已提交,正在后台处理", result);
|
return AjaxResult.success("员工亲属实体关联导入任务已提交,正在后台处理", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,22 +10,22 @@ import java.io.Serial;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息新增DTO
|
* 员工亲属实体关联新增DTO
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "员工实体关系信息新增")
|
@Schema(description = "员工亲属实体关联新增")
|
||||||
public class CcdiStaffEnterpriseRelationAddDTO implements Serializable {
|
public class CcdiStaffEnterpriseRelationAddDTO implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 身份证号 */
|
/** 亲属身份证号 */
|
||||||
@NotBlank(message = "身份证号不能为空")
|
@NotBlank(message = "亲属身份证号不能为空")
|
||||||
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$", message = "身份证号格式不正确")
|
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$", message = "亲属身份证号格式不正确")
|
||||||
@Schema(description = "身份证号")
|
@Schema(description = "亲属身份证号")
|
||||||
private String personId;
|
private String personId;
|
||||||
|
|
||||||
/** 关联人在企业的职务 */
|
/** 关联人在企业的职务 */
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ import java.io.Serial;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息编辑DTO
|
* 员工亲属实体关联编辑DTO
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "员工实体关系信息编辑")
|
@Schema(description = "员工亲属实体关联编辑")
|
||||||
public class CcdiStaffEnterpriseRelationEditDTO implements Serializable {
|
public class CcdiStaffEnterpriseRelationEditDTO implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
@@ -27,8 +27,8 @@ public class CcdiStaffEnterpriseRelationEditDTO implements Serializable {
|
|||||||
@Schema(description = "主键ID")
|
@Schema(description = "主键ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 身份证号 */
|
/** 亲属身份证号 */
|
||||||
@Schema(description = "身份证号(不可修改)")
|
@Schema(description = "亲属身份证号(不可修改)")
|
||||||
private String personId;
|
private String personId;
|
||||||
|
|
||||||
/** 关联人在企业的职务 */
|
/** 关联人在企业的职务 */
|
||||||
|
|||||||
@@ -7,22 +7,30 @@ import java.io.Serial;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息查询DTO
|
* 员工亲属实体关联查询DTO
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "员工实体关系信息查询条件")
|
@Schema(description = "员工亲属实体关联查询条件")
|
||||||
public class CcdiStaffEnterpriseRelationQueryDTO implements Serializable {
|
public class CcdiStaffEnterpriseRelationQueryDTO implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 身份证号 */
|
/** 亲属身份证号 */
|
||||||
@Schema(description = "身份证号")
|
@Schema(description = "亲属身份证号")
|
||||||
private String personId;
|
private String personId;
|
||||||
|
|
||||||
|
/** 亲属姓名 */
|
||||||
|
@Schema(description = "亲属姓名")
|
||||||
|
private String relationName;
|
||||||
|
|
||||||
|
/** 关联员工 */
|
||||||
|
@Schema(description = "关联员工")
|
||||||
|
private String staffPersonName;
|
||||||
|
|
||||||
/** 统一社会信用代码 */
|
/** 统一社会信用代码 */
|
||||||
@Schema(description = "统一社会信用代码")
|
@Schema(description = "统一社会信用代码")
|
||||||
private String socialCreditCode;
|
private String socialCreditCode;
|
||||||
|
|||||||
@@ -10,23 +10,23 @@ import java.io.Serial;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息Excel导入导出对象
|
* 员工亲属实体关联Excel导入导出对象
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "员工实体关系信息Excel导入导出对象")
|
@Schema(description = "员工亲属实体关联Excel导入导出对象")
|
||||||
public class CcdiStaffEnterpriseRelationExcel implements Serializable {
|
public class CcdiStaffEnterpriseRelationExcel implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 身份证号 */
|
/** 亲属身份证号 */
|
||||||
@ExcelProperty(value = "身份证号", index = 0)
|
@ExcelProperty(value = "亲属身份证号", index = 0)
|
||||||
@ColumnWidth(20)
|
@ColumnWidth(20)
|
||||||
@Required
|
@Required
|
||||||
@Schema(description = "身份证号")
|
@Schema(description = "亲属身份证号")
|
||||||
private String personId;
|
private String personId;
|
||||||
|
|
||||||
/** 统一社会信用代码 */
|
/** 统一社会信用代码 */
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.ruoyi.info.collection.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工亲属实体关联下拉选项VO
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-04-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "员工亲属实体关联下拉选项")
|
||||||
|
public class CcdiStaffEnterpriseRelationOptionVO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 亲属身份证号 */
|
||||||
|
@Schema(description = "亲属身份证号")
|
||||||
|
private String relationCertNo;
|
||||||
|
|
||||||
|
/** 亲属姓名 */
|
||||||
|
@Schema(description = "亲属姓名")
|
||||||
|
private String relationName;
|
||||||
|
|
||||||
|
/** 关联员工身份证号 */
|
||||||
|
@Schema(description = "关联员工身份证号")
|
||||||
|
private String staffPersonId;
|
||||||
|
|
||||||
|
/** 关联员工姓名 */
|
||||||
|
@Schema(description = "关联员工姓名")
|
||||||
|
private String staffPersonName;
|
||||||
|
}
|
||||||
@@ -9,13 +9,13 @@ import java.io.Serializable;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息VO
|
* 员工亲属实体关联VO
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "员工实体关系信息")
|
@Schema(description = "员工亲属实体关联")
|
||||||
public class CcdiStaffEnterpriseRelationVO implements Serializable {
|
public class CcdiStaffEnterpriseRelationVO implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
@@ -25,13 +25,21 @@ public class CcdiStaffEnterpriseRelationVO implements Serializable {
|
|||||||
@Schema(description = "主键ID")
|
@Schema(description = "主键ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 身份证号 */
|
/** 亲属身份证号 */
|
||||||
@Schema(description = "身份证号")
|
@Schema(description = "亲属身份证号")
|
||||||
private String personId;
|
private String personId;
|
||||||
|
|
||||||
/** 员工姓名 */
|
/** 亲属姓名 */
|
||||||
@Schema(description = "员工姓名")
|
@Schema(description = "亲属姓名")
|
||||||
private String personName;
|
private String relationName;
|
||||||
|
|
||||||
|
/** 关联员工身份证号 */
|
||||||
|
@Schema(description = "关联员工身份证号")
|
||||||
|
private String staffPersonId;
|
||||||
|
|
||||||
|
/** 关联员工姓名 */
|
||||||
|
@Schema(description = "关联员工姓名")
|
||||||
|
private String staffPersonName;
|
||||||
|
|
||||||
/** 关联人在企业的职务 */
|
/** 关联人在企业的职务 */
|
||||||
@Schema(description = "关联人在企业的职务")
|
@Schema(description = "关联人在企业的职务")
|
||||||
|
|||||||
@@ -7,22 +7,26 @@ import java.io.Serial;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息导入失败记录VO
|
* 员工亲属实体关联导入失败记录VO
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "员工实体关系信息导入失败记录")
|
@Schema(description = "员工亲属实体关联导入失败记录")
|
||||||
public class StaffEnterpriseRelationImportFailureVO implements Serializable {
|
public class StaffEnterpriseRelationImportFailureVO implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 身份证号 */
|
/** 亲属身份证号 */
|
||||||
@Schema(description = "身份证号")
|
@Schema(description = "亲属身份证号")
|
||||||
private String personId;
|
private String personId;
|
||||||
|
|
||||||
|
/** 亲属姓名 */
|
||||||
|
@Schema(description = "亲属姓名")
|
||||||
|
private String relationName;
|
||||||
|
|
||||||
/** 统一社会信用代码 */
|
/** 统一社会信用代码 */
|
||||||
@Schema(description = "统一社会信用代码")
|
@Schema(description = "统一社会信用代码")
|
||||||
private String socialCreditCode;
|
private String socialCreditCode;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationOptionVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@@ -38,6 +39,14 @@ public interface CcdiStaffEnterpriseRelationMapper extends BaseMapper<CcdiStaffE
|
|||||||
*/
|
*/
|
||||||
CcdiStaffEnterpriseRelationVO selectRelationById(@Param("id") Long id);
|
CcdiStaffEnterpriseRelationVO selectRelationById(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询有效员工亲属下拉选项
|
||||||
|
*
|
||||||
|
* @param query 搜索关键词
|
||||||
|
* @return 下拉选项
|
||||||
|
*/
|
||||||
|
List<CcdiStaffEnterpriseRelationOptionVO> selectFamilyOptions(@Param("query") String query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断身份证号和统一社会信用代码的组合是否已存在
|
* 判断身份证号和统一社会信用代码的组合是否已存在
|
||||||
*
|
*
|
||||||
@@ -57,6 +66,14 @@ public interface CcdiStaffEnterpriseRelationMapper extends BaseMapper<CcdiStaffE
|
|||||||
*/
|
*/
|
||||||
Set<String> batchExistsByCombinations(@Param("combinations") List<String> combinations);
|
Set<String> batchExistsByCombinations(@Param("combinations") List<String> combinations);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据亲属身份证号批量置无效
|
||||||
|
*
|
||||||
|
* @param personId 亲属身份证号
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int invalidateByFamilyCertNo(@Param("personId") String personId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入员工实体关系数据
|
* 批量插入员工实体关系数据
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.ruoyi.info.collection.domain.vo.StaffEnterpriseRelationImportFailureV
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息异步导入服务层
|
* 员工亲属实体关联异步导入服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
|||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationOptionVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -42,6 +43,14 @@ public interface ICcdiStaffEnterpriseRelationService {
|
|||||||
*/
|
*/
|
||||||
List<CcdiStaffEnterpriseRelationExcel> selectRelationListForExport(CcdiStaffEnterpriseRelationQueryDTO queryDTO);
|
List<CcdiStaffEnterpriseRelationExcel> selectRelationListForExport(CcdiStaffEnterpriseRelationQueryDTO queryDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询有效员工亲属下拉选项
|
||||||
|
*
|
||||||
|
* @param query 搜索关键词
|
||||||
|
* @return 下拉选项
|
||||||
|
*/
|
||||||
|
List<CcdiStaffEnterpriseRelationOptionVO> selectFamilyOptions(String query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工实体关系详情
|
* 查询员工实体关系详情
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package com.ruoyi.info.collection.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.ruoyi.info.collection.domain.CcdiBaseStaff;
|
|
||||||
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
||||||
|
import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
||||||
import com.ruoyi.info.collection.domain.vo.ImportResult;
|
import com.ruoyi.info.collection.domain.vo.ImportResult;
|
||||||
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.StaffEnterpriseRelationImportFailureVO;
|
import com.ruoyi.info.collection.domain.vo.StaffEnterpriseRelationImportFailureVO;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiBaseStaffMapper;
|
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
||||||
import com.ruoyi.info.collection.service.ICcdiStaffEnterpriseRelationImportService;
|
import com.ruoyi.info.collection.service.ICcdiStaffEnterpriseRelationImportService;
|
||||||
import com.ruoyi.info.collection.utils.ImportLogUtils;
|
import com.ruoyi.info.collection.utils.ImportLogUtils;
|
||||||
@@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工实体关系信息异步导入服务层处理
|
* 员工亲属实体关联异步导入服务层处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-02-09
|
* @date 2026-02-09
|
||||||
@@ -47,7 +47,7 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CcdiBaseStaffMapper baseStaffMapper;
|
private CcdiStaffFmyRelationMapper familyRelationMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Async
|
@Async
|
||||||
@@ -56,37 +56,48 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
// 记录导入开始
|
// 记录导入开始
|
||||||
ImportLogUtils.logImportStart(log, taskId, "员工实体关系", excelList.size(), userName);
|
ImportLogUtils.logImportStart(log, taskId, "员工亲属实体关联", excelList.size(), userName);
|
||||||
|
|
||||||
List<CcdiStaffEnterpriseRelation> newRecords = new ArrayList<>();
|
List<CcdiStaffEnterpriseRelation> newRecords = new ArrayList<>();
|
||||||
List<StaffEnterpriseRelationImportFailureVO> failures = new ArrayList<>();
|
List<StaffEnterpriseRelationImportFailureVO> failures = new ArrayList<>();
|
||||||
|
|
||||||
// 批量验证员工身份证号是否存在
|
|
||||||
Set<String> excelPersonIds = excelList.stream()
|
Set<String> excelPersonIds = excelList.stream()
|
||||||
.map(CcdiStaffEnterpriseRelationExcel::getPersonId)
|
.map(CcdiStaffEnterpriseRelationExcel::getPersonId)
|
||||||
.filter(StringUtils::isNotEmpty)
|
.filter(StringUtils::isNotEmpty)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
Set<String> existingPersonIds = new HashSet<>();
|
Map<String, CcdiStaffFmyRelation> validFamilies = new HashMap<>();
|
||||||
|
Set<String> knownFamilyCertNos = new HashSet<>();
|
||||||
|
Map<String, String> familyNameMap = new HashMap<>();
|
||||||
if (!excelPersonIds.isEmpty()) {
|
if (!excelPersonIds.isEmpty()) {
|
||||||
ImportLogUtils.logBatchQueryStart(log, taskId, "员工身份证号", excelPersonIds.size());
|
ImportLogUtils.logBatchQueryStart(log, taskId, "员工亲属关系", excelPersonIds.size());
|
||||||
|
|
||||||
LambdaQueryWrapper<CcdiBaseStaff> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<CcdiStaffFmyRelation> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.select(CcdiBaseStaff::getIdCard)
|
wrapper.select(
|
||||||
.in(CcdiBaseStaff::getIdCard, excelPersonIds);
|
CcdiStaffFmyRelation::getRelationCertNo,
|
||||||
|
CcdiStaffFmyRelation::getRelationName,
|
||||||
|
CcdiStaffFmyRelation::getPersonId,
|
||||||
|
CcdiStaffFmyRelation::getStatus,
|
||||||
|
CcdiStaffFmyRelation::getIsEmpFamily
|
||||||
|
)
|
||||||
|
.in(CcdiStaffFmyRelation::getRelationCertNo, excelPersonIds);
|
||||||
|
|
||||||
List<CcdiBaseStaff> existingStaff = baseStaffMapper.selectList(wrapper);
|
List<CcdiStaffFmyRelation> familyRelations = familyRelationMapper.selectList(wrapper);
|
||||||
existingPersonIds = existingStaff.stream()
|
for (CcdiStaffFmyRelation familyRelation : familyRelations) {
|
||||||
.map(CcdiBaseStaff::getIdCard)
|
knownFamilyCertNos.add(familyRelation.getRelationCertNo());
|
||||||
.collect(Collectors.toSet());
|
familyNameMap.putIfAbsent(familyRelation.getRelationCertNo(), familyRelation.getRelationName());
|
||||||
|
if (Boolean.TRUE.equals(familyRelation.getIsEmpFamily()) && Integer.valueOf(1).equals(familyRelation.getStatus())) {
|
||||||
|
validFamilies.putIfAbsent(familyRelation.getRelationCertNo(), familyRelation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImportLogUtils.logBatchQueryComplete(log, taskId, "员工身份证号", existingPersonIds.size());
|
ImportLogUtils.logBatchQueryComplete(log, taskId, "员工亲属关系", familyRelations.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量查询已存在的person_id + social_credit_code组合
|
// 批量查询已存在的person_id + social_credit_code组合
|
||||||
ImportLogUtils.logBatchQueryStart(log, taskId, "已存在的员工企业关系组合", excelList.size());
|
ImportLogUtils.logBatchQueryStart(log, taskId, "已存在的员工亲属实体关联组合", excelList.size());
|
||||||
Set<String> existingCombinations = getExistingCombinations(excelList);
|
Set<String> existingCombinations = getExistingCombinations(excelList);
|
||||||
ImportLogUtils.logBatchQueryComplete(log, taskId, "员工企业关系组合", existingCombinations.size());
|
ImportLogUtils.logBatchQueryComplete(log, taskId, "员工亲属实体关联组合", existingCombinations.size());
|
||||||
|
|
||||||
// 用于跟踪Excel文件内已处理的组合
|
// 用于跟踪Excel文件内已处理的组合
|
||||||
Set<String> processedCombinations = new HashSet<>();
|
Set<String> processedCombinations = new HashSet<>();
|
||||||
@@ -103,41 +114,18 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
// 验证数据
|
// 验证数据
|
||||||
validateRelationData(addDTO);
|
validateRelationData(addDTO);
|
||||||
|
|
||||||
// 身份证号存在性检查(在基本验证之后)
|
CcdiStaffFmyRelation familyRelation = validFamilies.get(excel.getPersonId());
|
||||||
if (!existingPersonIds.contains(excel.getPersonId())) {
|
CcdiStaffEnterpriseRelation relation = validateAndBuildEntity(
|
||||||
throw new RuntimeException(String.format(
|
excel,
|
||||||
"第%d行: 身份证号[%s]不存在于员工信息表中,请先添加员工信息",
|
familyRelation,
|
||||||
i + 1, excel.getPersonId()));
|
knownFamilyCertNos,
|
||||||
}
|
existingCombinations,
|
||||||
|
processedCombinations,
|
||||||
String combination = excel.getPersonId() + "|" + excel.getSocialCreditCode();
|
userName
|
||||||
|
);
|
||||||
CcdiStaffEnterpriseRelation relation = new CcdiStaffEnterpriseRelation();
|
|
||||||
BeanUtils.copyProperties(excel, relation);
|
|
||||||
|
|
||||||
if (existingCombinations.contains(combination)) {
|
|
||||||
// 组合已存在,直接报错
|
|
||||||
throw new RuntimeException(String.format("身份证号[%s]和统一社会信用代码[%s]的组合已存在,请勿重复导入",
|
|
||||||
excel.getPersonId(), excel.getSocialCreditCode()));
|
|
||||||
} else if (processedCombinations.contains(combination)) {
|
|
||||||
// Excel文件内部重复
|
|
||||||
throw new RuntimeException(String.format("身份证号[%s]和统一社会信用代码[%s]的组合在导入文件中重复,已跳过此条记录",
|
|
||||||
excel.getPersonId(), excel.getSocialCreditCode()));
|
|
||||||
} else {
|
|
||||||
relation.setCreatedBy(userName);
|
|
||||||
relation.setUpdatedBy(userName);
|
|
||||||
|
|
||||||
// 设置默认值
|
|
||||||
relation.setStatus(1);
|
|
||||||
relation.setIsEmployee(0);
|
|
||||||
relation.setIsEmpFamily(1);
|
|
||||||
relation.setIsCustomer(0);
|
|
||||||
relation.setIsCustFamily(0);
|
|
||||||
relation.setDataSource("IMPORT");
|
|
||||||
|
|
||||||
newRecords.add(relation);
|
newRecords.add(relation);
|
||||||
processedCombinations.add(combination); // 标记为已处理
|
processedCombinations.add(excel.getPersonId() + "|" + excel.getSocialCreditCode());
|
||||||
}
|
|
||||||
|
|
||||||
// 记录进度
|
// 记录进度
|
||||||
ImportLogUtils.logProgress(log, taskId, i + 1, excelList.size(),
|
ImportLogUtils.logProgress(log, taskId, i + 1, excelList.size(),
|
||||||
@@ -146,11 +134,12 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
StaffEnterpriseRelationImportFailureVO failure = new StaffEnterpriseRelationImportFailureVO();
|
StaffEnterpriseRelationImportFailureVO failure = new StaffEnterpriseRelationImportFailureVO();
|
||||||
BeanUtils.copyProperties(excel, failure);
|
BeanUtils.copyProperties(excel, failure);
|
||||||
|
failure.setRelationName(familyNameMap.get(excel.getPersonId()));
|
||||||
failure.setErrorMessage(e.getMessage());
|
failure.setErrorMessage(e.getMessage());
|
||||||
failures.add(failure);
|
failures.add(failure);
|
||||||
|
|
||||||
// 记录验证失败日志
|
// 记录验证失败日志
|
||||||
String keyData = String.format("身份证号=%s, 统一社会信用代码=%s, 企业名称=%s",
|
String keyData = String.format("亲属身份证号=%s, 统一社会信用代码=%s, 企业名称=%s",
|
||||||
excel.getPersonId(), excel.getSocialCreditCode(), excel.getEnterpriseName());
|
excel.getPersonId(), excel.getSocialCreditCode(), excel.getEnterpriseName());
|
||||||
ImportLogUtils.logValidationError(log, taskId, i + 1, e.getMessage(), keyData);
|
ImportLogUtils.logValidationError(log, taskId, i + 1, e.getMessage(), keyData);
|
||||||
}
|
}
|
||||||
@@ -185,7 +174,7 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
|
|
||||||
// 记录导入完成
|
// 记录导入完成
|
||||||
long duration = System.currentTimeMillis() - startTime;
|
long duration = System.currentTimeMillis() - startTime;
|
||||||
ImportLogUtils.logImportComplete(log, taskId, "员工实体关系",
|
ImportLogUtils.logImportComplete(log, taskId, "员工亲属实体关联",
|
||||||
excelList.size(), result.getSuccessCount(), result.getFailureCount(), duration);
|
excelList.size(), result.getSuccessCount(), result.getFailureCount(), duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,9 +240,9 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
statusData.put("endTime", System.currentTimeMillis());
|
statusData.put("endTime", System.currentTimeMillis());
|
||||||
|
|
||||||
if ("SUCCESS".equals(status)) {
|
if ("SUCCESS".equals(status)) {
|
||||||
statusData.put("message", "全部成功!共导入" + result.getTotalCount() + "条数据");
|
statusData.put("message", "员工亲属实体关联导入全部成功!共导入" + result.getTotalCount() + "条数据");
|
||||||
} else {
|
} else {
|
||||||
statusData.put("message", "成功" + result.getSuccessCount() + "条,失败" + result.getFailureCount() + "条");
|
statusData.put("message", "员工亲属实体关联导入成功" + result.getSuccessCount() + "条,失败" + result.getFailureCount() + "条");
|
||||||
}
|
}
|
||||||
|
|
||||||
redisTemplate.opsForHash().putAll(key, statusData);
|
redisTemplate.opsForHash().putAll(key, statusData);
|
||||||
@@ -297,14 +286,14 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证员工实体关系数据
|
* 验证员工亲属实体关联基础数据
|
||||||
*
|
*
|
||||||
* @param addDTO 新增DTO
|
* @param addDTO 新增DTO
|
||||||
*/
|
*/
|
||||||
private void validateRelationData(CcdiStaffEnterpriseRelationAddDTO addDTO) {
|
private void validateRelationData(CcdiStaffEnterpriseRelationAddDTO addDTO) {
|
||||||
// 验证必填字段
|
// 验证必填字段
|
||||||
if (StringUtils.isEmpty(addDTO.getPersonId())) {
|
if (StringUtils.isEmpty(addDTO.getPersonId())) {
|
||||||
throw new RuntimeException("身份证号不能为空");
|
throw new RuntimeException("亲属身份证号不能为空");
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(addDTO.getSocialCreditCode())) {
|
if (StringUtils.isEmpty(addDTO.getSocialCreditCode())) {
|
||||||
throw new RuntimeException("统一社会信用代码不能为空");
|
throw new RuntimeException("统一社会信用代码不能为空");
|
||||||
@@ -313,9 +302,9 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
throw new RuntimeException("企业名称不能为空");
|
throw new RuntimeException("企业名称不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证身份证号格式(18位)
|
// 验证亲属身份证号格式(18位)
|
||||||
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}[0-9Xx]$")) {
|
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}[0-9Xx]$")) {
|
||||||
throw new RuntimeException("身份证号格式不正确,必须为18位有效身份证号");
|
throw new RuntimeException("亲属身份证号格式不正确,必须为18位有效身份证号");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证统一社会信用代码格式(18位)
|
// 验证统一社会信用代码格式(18位)
|
||||||
@@ -331,4 +320,38 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
throw new RuntimeException("企业名称长度不能超过200个字符");
|
throw new RuntimeException("企业名称长度不能超过200个字符");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CcdiStaffEnterpriseRelation validateAndBuildEntity(CcdiStaffEnterpriseRelationExcel excel,
|
||||||
|
CcdiStaffFmyRelation familyRelation,
|
||||||
|
Set<String> knownFamilyCertNos,
|
||||||
|
Set<String> existingCombinations,
|
||||||
|
Set<String> processedCombinations,
|
||||||
|
String userName) {
|
||||||
|
String combination = excel.getPersonId() + "|" + excel.getSocialCreditCode();
|
||||||
|
|
||||||
|
if (familyRelation == null) {
|
||||||
|
if (knownFamilyCertNos.contains(excel.getPersonId())) {
|
||||||
|
throw new RuntimeException("亲属身份证号[" + excel.getPersonId() + "]不是有效员工亲属,请先维护有效的员工亲属关系");
|
||||||
|
}
|
||||||
|
throw new RuntimeException("亲属身份证号[" + excel.getPersonId() + "]不存在,请先维护员工亲属关系");
|
||||||
|
}
|
||||||
|
if (existingCombinations.contains(combination)) {
|
||||||
|
throw new RuntimeException("亲属身份证号[" + excel.getPersonId() + "]和统一社会信用代码[" + excel.getSocialCreditCode() + "]的组合已存在,请勿重复导入");
|
||||||
|
}
|
||||||
|
if (processedCombinations.contains(combination)) {
|
||||||
|
throw new RuntimeException("亲属身份证号[" + excel.getPersonId() + "]和统一社会信用代码[" + excel.getSocialCreditCode() + "]的组合在导入文件中重复,已跳过此条记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
CcdiStaffEnterpriseRelation relation = new CcdiStaffEnterpriseRelation();
|
||||||
|
BeanUtils.copyProperties(excel, relation);
|
||||||
|
relation.setCreatedBy(userName);
|
||||||
|
relation.setUpdatedBy(userName);
|
||||||
|
relation.setStatus(1);
|
||||||
|
relation.setIsEmployee(0);
|
||||||
|
relation.setIsEmpFamily(1);
|
||||||
|
relation.setIsCustomer(0);
|
||||||
|
relation.setIsCustFamily(0);
|
||||||
|
relation.setDataSource("IMPORT");
|
||||||
|
return relation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ package com.ruoyi.info.collection.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
||||||
|
import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationOptionVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO;
|
||||||
|
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
||||||
import com.ruoyi.info.collection.service.ICcdiStaffEnterpriseRelationImportService;
|
import com.ruoyi.info.collection.service.ICcdiStaffEnterpriseRelationImportService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiStaffEnterpriseRelationService;
|
import com.ruoyi.info.collection.service.ICcdiStaffEnterpriseRelationService;
|
||||||
@@ -37,6 +40,9 @@ public class CcdiStaffEnterpriseRelationServiceImpl implements ICcdiStaffEnterpr
|
|||||||
@Resource
|
@Resource
|
||||||
private CcdiStaffEnterpriseRelationMapper relationMapper;
|
private CcdiStaffEnterpriseRelationMapper relationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CcdiStaffFmyRelationMapper familyRelationMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ICcdiStaffEnterpriseRelationImportService relationImportService;
|
private ICcdiStaffEnterpriseRelationImportService relationImportService;
|
||||||
|
|
||||||
@@ -86,6 +92,11 @@ public class CcdiStaffEnterpriseRelationServiceImpl implements ICcdiStaffEnterpr
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.util.List<CcdiStaffEnterpriseRelationOptionVO> selectFamilyOptions(String query) {
|
||||||
|
return relationMapper.selectFamilyOptions(query);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工实体关系详情
|
* 查询员工实体关系详情
|
||||||
*
|
*
|
||||||
@@ -106,16 +117,15 @@ public class CcdiStaffEnterpriseRelationServiceImpl implements ICcdiStaffEnterpr
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int insertRelation(CcdiStaffEnterpriseRelationAddDTO addDTO) {
|
public int insertRelation(CcdiStaffEnterpriseRelationAddDTO addDTO) {
|
||||||
// 检查身份证号+统一社会信用代码唯一性
|
validateEffectiveFamily(addDTO.getPersonId());
|
||||||
|
|
||||||
if (relationMapper.existsByPersonIdAndSocialCreditCode(addDTO.getPersonId(), addDTO.getSocialCreditCode())) {
|
if (relationMapper.existsByPersonIdAndSocialCreditCode(addDTO.getPersonId(), addDTO.getSocialCreditCode())) {
|
||||||
throw new RuntimeException("该身份证号和统一社会信用代码组合已存在");
|
throw new RuntimeException("该亲属身份证号和统一社会信用代码组合已存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
CcdiStaffEnterpriseRelation relation = new CcdiStaffEnterpriseRelation();
|
CcdiStaffEnterpriseRelation relation = new CcdiStaffEnterpriseRelation();
|
||||||
BeanUtils.copyProperties(addDTO, relation);
|
BeanUtils.copyProperties(addDTO, relation);
|
||||||
|
|
||||||
// 设置默认值
|
|
||||||
// 新增时强制设置状态为有效
|
|
||||||
relation.setStatus(1);
|
relation.setStatus(1);
|
||||||
|
|
||||||
if (relation.getIsEmployee() == null) {
|
if (relation.getIsEmployee() == null) {
|
||||||
@@ -159,7 +169,7 @@ public class CcdiStaffEnterpriseRelationServiceImpl implements ICcdiStaffEnterpr
|
|||||||
updateWrapper.set(editDTO.getRemark() != null, CcdiStaffEnterpriseRelation::getRemark, editDTO.getRemark());
|
updateWrapper.set(editDTO.getRemark() != null, CcdiStaffEnterpriseRelation::getRemark, editDTO.getRemark());
|
||||||
|
|
||||||
// 注意:以下字段不可修改
|
// 注意:以下字段不可修改
|
||||||
// - personId(身份证号,业务主键)
|
// - personId(亲属身份证号,业务主键)
|
||||||
// - socialCreditCode(统一社会信用代码,业务主键)
|
// - socialCreditCode(统一社会信用代码,业务主键)
|
||||||
// - dataSource(数据来源,系统字段)
|
// - dataSource(数据来源,系统字段)
|
||||||
// - isEmployee(是否为员工,系统字段)
|
// - isEmployee(是否为员工,系统字段)
|
||||||
@@ -224,4 +234,28 @@ public class CcdiStaffEnterpriseRelationServiceImpl implements ICcdiStaffEnterpr
|
|||||||
|
|
||||||
return taskId;
|
return taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CcdiStaffFmyRelation validateEffectiveFamily(String familyCertNo) {
|
||||||
|
CcdiStaffFmyRelation validFamily = familyRelationMapper.selectOne(
|
||||||
|
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<CcdiStaffFmyRelation>()
|
||||||
|
.eq(CcdiStaffFmyRelation::getRelationCertNo, familyCertNo)
|
||||||
|
.eq(CcdiStaffFmyRelation::getIsEmpFamily, Boolean.TRUE)
|
||||||
|
.eq(CcdiStaffFmyRelation::getStatus, 1)
|
||||||
|
.last("LIMIT 1")
|
||||||
|
);
|
||||||
|
if (validFamily != null) {
|
||||||
|
return validFamily;
|
||||||
|
}
|
||||||
|
|
||||||
|
CcdiStaffFmyRelation existingFamily = familyRelationMapper.selectOne(
|
||||||
|
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<CcdiStaffFmyRelation>()
|
||||||
|
.select(CcdiStaffFmyRelation::getId)
|
||||||
|
.eq(CcdiStaffFmyRelation::getRelationCertNo, familyCertNo)
|
||||||
|
.last("LIMIT 1")
|
||||||
|
);
|
||||||
|
if (existingFamily == null) {
|
||||||
|
throw new RuntimeException("亲属身份证号[" + familyCertNo + "]不存在,请先维护员工亲属关系");
|
||||||
|
}
|
||||||
|
throw new RuntimeException("亲属身份证号[" + familyCertNo + "]不是有效员工亲属,请先维护有效的员工亲属关系");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package com.ruoyi.info.collection.service.impl;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.info.collection.domain.CcdiAssetInfo;
|
import com.ruoyi.info.collection.domain.CcdiAssetInfo;
|
||||||
import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiAssetInfoVO;
|
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiStaffFmyRelationExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffFmyRelationExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CcdiAssetInfoVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
||||||
|
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
||||||
import com.ruoyi.info.collection.service.ICcdiAssetInfoService;
|
import com.ruoyi.info.collection.service.ICcdiAssetInfoService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationImportService;
|
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationImportService;
|
||||||
@@ -50,6 +51,9 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
|||||||
@Resource
|
@Resource
|
||||||
private ICcdiAssetInfoService assetInfoService;
|
private ICcdiAssetInfoService assetInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CcdiStaffEnterpriseRelationMapper staffEnterpriseRelationMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工亲属关系列表
|
* 查询员工亲属关系列表
|
||||||
*
|
*
|
||||||
@@ -161,6 +165,9 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
|||||||
CcdiStaffFmyRelation relation = new CcdiStaffFmyRelation();
|
CcdiStaffFmyRelation relation = new CcdiStaffFmyRelation();
|
||||||
BeanUtils.copyProperties(editDTO, relation);
|
BeanUtils.copyProperties(editDTO, relation);
|
||||||
int result = relationMapper.updateById(relation);
|
int result = relationMapper.updateById(relation);
|
||||||
|
if (Integer.valueOf(1).equals(existing.getStatus()) && Integer.valueOf(0).equals(editDTO.getStatus())) {
|
||||||
|
staffEnterpriseRelationMapper.invalidateByFamilyCertNo(existing.getRelationCertNo());
|
||||||
|
}
|
||||||
assetInfoService.replaceByFamilyIdAndPersonId(editDTO.getPersonId(), editDTO.getRelationCertNo(), editDTO.getAssetInfoList());
|
assetInfoService.replaceByFamilyIdAndPersonId(editDTO.getPersonId(), editDTO.getRelationCertNo(), editDTO.getAssetInfoList());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
<resultMap type="com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO" id="CcdiStaffEnterpriseRelationVOResult">
|
<resultMap type="com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationVO" id="CcdiStaffEnterpriseRelationVOResult">
|
||||||
<id property="id" column="id"/>
|
<id property="id" column="id"/>
|
||||||
<result property="personId" column="person_id"/>
|
<result property="personId" column="person_id"/>
|
||||||
<result property="personName" column="person_name"/>
|
<result property="relationName" column="relation_name"/>
|
||||||
|
<result property="staffPersonId" column="staff_person_id"/>
|
||||||
|
<result property="staffPersonName" column="staff_person_name"/>
|
||||||
<result property="relationPersonPost" column="relation_person_post"/>
|
<result property="relationPersonPost" column="relation_person_post"/>
|
||||||
<result property="socialCreditCode" column="social_credit_code"/>
|
<result property="socialCreditCode" column="social_credit_code"/>
|
||||||
<result property="enterpriseName" column="enterprise_name"/>
|
<result property="enterpriseName" column="enterprise_name"/>
|
||||||
@@ -28,17 +30,28 @@
|
|||||||
<!-- 分页查询员工实体关系列表 -->
|
<!-- 分页查询员工实体关系列表 -->
|
||||||
<select id="selectRelationPage" resultMap="CcdiStaffEnterpriseRelationVOResult">
|
<select id="selectRelationPage" resultMap="CcdiStaffEnterpriseRelationVOResult">
|
||||||
SELECT
|
SELECT
|
||||||
ser.id, ser.person_id, bs.name as person_name, ser.relation_person_post,
|
ser.id, ser.person_id, sfr.relation_name, sfr.person_id AS staff_person_id, bs.name AS staff_person_name,
|
||||||
|
ser.relation_person_post,
|
||||||
ser.social_credit_code, ser.enterprise_name, ser.status, ser.remark,
|
ser.social_credit_code, ser.enterprise_name, ser.status, ser.remark,
|
||||||
ser.data_source, ser.is_employee, ser.is_emp_family, ser.is_customer,
|
ser.data_source, ser.is_employee, ser.is_emp_family, ser.is_customer,
|
||||||
ser.is_cust_family, ser.created_by, ser.create_time, ser.updated_by,
|
ser.is_cust_family, ser.created_by, ser.create_time, ser.updated_by,
|
||||||
ser.update_time
|
ser.update_time
|
||||||
FROM ccdi_staff_enterprise_relation ser
|
FROM ccdi_staff_enterprise_relation ser
|
||||||
LEFT JOIN ccdi_base_staff bs ON ser.person_id = bs.id_card
|
LEFT JOIN ccdi_staff_fmy_relation sfr
|
||||||
|
ON ser.person_id = sfr.relation_cert_no
|
||||||
|
AND sfr.is_emp_family = 1
|
||||||
|
LEFT JOIN ccdi_base_staff bs ON sfr.person_id = bs.id_card
|
||||||
<where>
|
<where>
|
||||||
<if test="query.personId != null and query.personId != ''">
|
<if test="query.personId != null and query.personId != ''">
|
||||||
AND ser.person_id LIKE CONCAT('%', #{query.personId}, '%')
|
AND ser.person_id LIKE CONCAT('%', #{query.personId}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="query.relationName != null and query.relationName != ''">
|
||||||
|
AND sfr.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="query.staffPersonName != null and query.staffPersonName != ''">
|
||||||
|
AND (sfr.person_id LIKE CONCAT('%', #{query.staffPersonName}, '%')
|
||||||
|
OR bs.name LIKE CONCAT('%', #{query.staffPersonName}, '%'))
|
||||||
|
</if>
|
||||||
<if test="query.socialCreditCode != null and query.socialCreditCode != ''">
|
<if test="query.socialCreditCode != null and query.socialCreditCode != ''">
|
||||||
AND ser.social_credit_code LIKE CONCAT('%', #{query.socialCreditCode}, '%')
|
AND ser.social_credit_code LIKE CONCAT('%', #{query.socialCreditCode}, '%')
|
||||||
</if>
|
</if>
|
||||||
@@ -55,16 +68,40 @@
|
|||||||
<!-- 查询员工实体关系详情 -->
|
<!-- 查询员工实体关系详情 -->
|
||||||
<select id="selectRelationById" resultMap="CcdiStaffEnterpriseRelationVOResult">
|
<select id="selectRelationById" resultMap="CcdiStaffEnterpriseRelationVOResult">
|
||||||
SELECT
|
SELECT
|
||||||
ser.id, ser.person_id, bs.name as person_name, ser.relation_person_post,
|
ser.id, ser.person_id, sfr.relation_name, sfr.person_id AS staff_person_id, bs.name AS staff_person_name,
|
||||||
|
ser.relation_person_post,
|
||||||
ser.social_credit_code, ser.enterprise_name, ser.status, ser.remark,
|
ser.social_credit_code, ser.enterprise_name, ser.status, ser.remark,
|
||||||
ser.data_source, ser.is_employee, ser.is_emp_family, ser.is_customer,
|
ser.data_source, ser.is_employee, ser.is_emp_family, ser.is_customer,
|
||||||
ser.is_cust_family, ser.created_by, ser.create_time, ser.updated_by,
|
ser.is_cust_family, ser.created_by, ser.create_time, ser.updated_by,
|
||||||
ser.update_time
|
ser.update_time
|
||||||
FROM ccdi_staff_enterprise_relation ser
|
FROM ccdi_staff_enterprise_relation ser
|
||||||
LEFT JOIN ccdi_base_staff bs ON ser.person_id = bs.id_card
|
LEFT JOIN ccdi_staff_fmy_relation sfr
|
||||||
|
ON ser.person_id = sfr.relation_cert_no
|
||||||
|
AND sfr.is_emp_family = 1
|
||||||
|
LEFT JOIN ccdi_base_staff bs ON sfr.person_id = bs.id_card
|
||||||
WHERE ser.id = #{id}
|
WHERE ser.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询有效员工亲属下拉选项 -->
|
||||||
|
<select id="selectFamilyOptions" resultType="com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationOptionVO">
|
||||||
|
SELECT
|
||||||
|
sfr.relation_cert_no AS relationCertNo,
|
||||||
|
sfr.relation_name AS relationName,
|
||||||
|
sfr.person_id AS staffPersonId,
|
||||||
|
bs.name AS staffPersonName
|
||||||
|
FROM ccdi_staff_fmy_relation sfr
|
||||||
|
LEFT JOIN ccdi_base_staff bs ON sfr.person_id = bs.id_card
|
||||||
|
<where>
|
||||||
|
sfr.is_emp_family = 1
|
||||||
|
AND sfr.status = 1
|
||||||
|
<if test="query != null and query != ''">
|
||||||
|
AND sfr.relation_cert_no LIKE CONCAT('%', #{query}, '%')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY sfr.create_time DESC
|
||||||
|
LIMIT 100
|
||||||
|
</select>
|
||||||
|
|
||||||
<!-- 判断身份证号和统一社会信用代码的组合是否已存在 -->
|
<!-- 判断身份证号和统一社会信用代码的组合是否已存在 -->
|
||||||
<select id="existsByPersonIdAndSocialCreditCode" resultType="boolean">
|
<select id="existsByPersonIdAndSocialCreditCode" resultType="boolean">
|
||||||
SELECT COUNT(1) > 0
|
SELECT COUNT(1) > 0
|
||||||
@@ -84,6 +121,14 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="invalidateByFamilyCertNo">
|
||||||
|
UPDATE ccdi_staff_enterprise_relation
|
||||||
|
SET status = 0,
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE person_id = #{personId}
|
||||||
|
AND status != 0
|
||||||
|
</update>
|
||||||
|
|
||||||
<!-- 批量插入员工实体关系数据 -->
|
<!-- 批量插入员工实体关系数据 -->
|
||||||
<insert id="insertBatch">
|
<insert id="insertBatch">
|
||||||
INSERT INTO ccdi_staff_enterprise_relation
|
INSERT INTO ccdi_staff_enterprise_relation
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
package com.ruoyi.info.collection.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.github.pagehelper.parser.defaults.DefaultCountSqlParser;
|
||||||
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationQueryDTO;
|
||||||
|
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
|
||||||
|
import org.apache.ibatis.mapping.BoundSql;
|
||||||
|
import org.apache.ibatis.mapping.Environment;
|
||||||
|
import org.apache.ibatis.mapping.MappedStatement;
|
||||||
|
import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver;
|
||||||
|
import org.apache.ibatis.session.Configuration;
|
||||||
|
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
|
||||||
|
import org.apache.ibatis.type.TypeAliasRegistry;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
class CcdiStaffEnterpriseRelationMapperTest {
|
||||||
|
|
||||||
|
private static final String RESOURCE = "mapper/info/collection/CcdiStaffEnterpriseRelationMapper.xml";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void selectRelationPage_shouldJoinFamilyRelationAndStaff() throws Exception {
|
||||||
|
MappedStatement mappedStatement = loadMappedStatement(
|
||||||
|
"com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper.selectRelationPage");
|
||||||
|
|
||||||
|
CcdiStaffEnterpriseRelationQueryDTO queryDTO = new CcdiStaffEnterpriseRelationQueryDTO();
|
||||||
|
queryDTO.setRelationName("李");
|
||||||
|
queryDTO.setStaffPersonName("张");
|
||||||
|
String sql = renderSql(mappedStatement, Map.of(
|
||||||
|
"page", new Page<>(1, 10),
|
||||||
|
"query", queryDTO
|
||||||
|
));
|
||||||
|
String countSql = normalizeSql(new DefaultCountSqlParser().getSmartCountSql(sql, "0"));
|
||||||
|
|
||||||
|
assertTrue(sql.contains("LEFT JOIN ccdi_staff_fmy_relation sfr"), sql);
|
||||||
|
assertTrue(sql.contains("LEFT JOIN ccdi_base_staff bs ON sfr.person_id = bs.id_card"), sql);
|
||||||
|
assertTrue(sql.contains("sfr.relation_name"), sql);
|
||||||
|
assertTrue(sql.contains("staff_person_id"), sql);
|
||||||
|
assertTrue(sql.contains("bs.name AS staff_person_name"), sql);
|
||||||
|
assertTrue(sql.contains("sfr.relation_name LIKE CONCAT('%', ?, '%')"), sql);
|
||||||
|
assertTrue(sql.contains("bs.name LIKE CONCAT('%', ?, '%')"), sql);
|
||||||
|
assertFalse(countSql.contains("1AND"), countSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void selectFamilyOptions_shouldOnlyQueryEffectiveEmployeeFamilies() throws Exception {
|
||||||
|
MappedStatement mappedStatement = loadMappedStatement(
|
||||||
|
"com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper.selectFamilyOptions");
|
||||||
|
|
||||||
|
String sql = renderSql(mappedStatement, Map.of("query", "320101"));
|
||||||
|
|
||||||
|
assertTrue(sql.contains("sfr.is_emp_family = 1"), sql);
|
||||||
|
assertTrue(sql.contains("sfr.status = 1"), sql);
|
||||||
|
assertTrue(sql.contains("sfr.relation_cert_no LIKE CONCAT('%', ?, '%')"), sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mapperXml_shouldContainInvalidateByFamilyCertNo() throws Exception {
|
||||||
|
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(RESOURCE)) {
|
||||||
|
String xml = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
|
||||||
|
assertTrue(xml.contains("<update id=\"invalidateByFamilyCertNo\">"), xml);
|
||||||
|
assertTrue(xml.contains("WHERE person_id = #{personId}"), xml);
|
||||||
|
assertTrue(xml.contains("SET status = 0"), xml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private MappedStatement loadMappedStatement(String statementId) throws Exception {
|
||||||
|
Configuration configuration = new Configuration();
|
||||||
|
configuration.setEnvironment(new Environment("test", new JdbcTransactionFactory(), new NoOpDataSource()));
|
||||||
|
registerTypeAliases(configuration.getTypeAliasRegistry());
|
||||||
|
configuration.getLanguageRegistry().register(XMLLanguageDriver.class);
|
||||||
|
configuration.addMapper(CcdiStaffEnterpriseRelationMapper.class);
|
||||||
|
|
||||||
|
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(RESOURCE)) {
|
||||||
|
XMLMapperBuilder xmlMapperBuilder =
|
||||||
|
new XMLMapperBuilder(inputStream, configuration, RESOURCE, configuration.getSqlFragments());
|
||||||
|
xmlMapperBuilder.parse();
|
||||||
|
}
|
||||||
|
return configuration.getMappedStatement(statementId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String renderSql(MappedStatement mappedStatement, Map<String, Object> params) {
|
||||||
|
BoundSql boundSql = mappedStatement.getBoundSql(new HashMap<>(params));
|
||||||
|
return normalizeSql(boundSql.getSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizeSql(String sql) {
|
||||||
|
return sql.replaceAll("\\s+", " ").trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerTypeAliases(TypeAliasRegistry typeAliasRegistry) {
|
||||||
|
typeAliasRegistry.registerAlias("map", Map.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class NoOpDataSource implements DataSource {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.sql.Connection getConnection() {
|
||||||
|
throw new UnsupportedOperationException("Not required for SQL rendering tests");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.sql.Connection getConnection(String username, String password) {
|
||||||
|
throw new UnsupportedOperationException("Not required for SQL rendering tests");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.io.PrintWriter getLogWriter() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogWriter(java.io.PrintWriter out) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLoginTimeout(int seconds) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLoginTimeout() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.util.logging.Logger getParentLogger() {
|
||||||
|
return java.util.logging.Logger.getGlobal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T unwrap(Class<T> iface) {
|
||||||
|
throw new UnsupportedOperationException("Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWrapperFor(Class<?> iface) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
package com.ruoyi.info.collection.service;
|
||||||
|
|
||||||
|
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
||||||
|
import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffEnterpriseRelationExcel;
|
||||||
|
import com.ruoyi.info.collection.service.impl.CcdiStaffEnterpriseRelationImportServiceImpl;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
class CcdiStaffEnterpriseRelationImportServiceImplTest {
|
||||||
|
|
||||||
|
private final CcdiStaffEnterpriseRelationImportServiceImpl service = new CcdiStaffEnterpriseRelationImportServiceImpl();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void validateAndBuildEntity_shouldBuildImportEntityForValidFamily() throws Exception {
|
||||||
|
CcdiStaffEnterpriseRelationExcel excel = buildExcel();
|
||||||
|
CcdiStaffFmyRelation familyRelation = buildFamily();
|
||||||
|
|
||||||
|
CcdiStaffEnterpriseRelation entity = invokeValidateAndBuildEntity(
|
||||||
|
excel,
|
||||||
|
familyRelation,
|
||||||
|
Set.of(excel.getPersonId()),
|
||||||
|
Set.of(),
|
||||||
|
new HashSet<>(),
|
||||||
|
"admin"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals("IMPORT", entity.getDataSource());
|
||||||
|
assertEquals(1, entity.getStatus());
|
||||||
|
assertEquals(1, entity.getIsEmpFamily());
|
||||||
|
assertEquals("admin", entity.getCreatedBy());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void validateAndBuildEntity_shouldRejectWhenFamilyDoesNotExist() throws Exception {
|
||||||
|
CcdiStaffEnterpriseRelationExcel excel = buildExcel();
|
||||||
|
|
||||||
|
RuntimeException exception = assertThrows(RuntimeException.class,
|
||||||
|
() -> invokeValidateAndBuildEntity(excel, null, Set.of(), Set.of(), new HashSet<>(), "admin"));
|
||||||
|
|
||||||
|
assertEquals("亲属身份证号[" + excel.getPersonId() + "]不存在,请先维护员工亲属关系", exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void validateAndBuildEntity_shouldRejectWhenFamilyIsInvalid() throws Exception {
|
||||||
|
CcdiStaffEnterpriseRelationExcel excel = buildExcel();
|
||||||
|
|
||||||
|
RuntimeException exception = assertThrows(RuntimeException.class,
|
||||||
|
() -> invokeValidateAndBuildEntity(excel, null, Set.of(excel.getPersonId()), Set.of(), new HashSet<>(), "admin"));
|
||||||
|
|
||||||
|
assertEquals("亲属身份证号[" + excel.getPersonId() + "]不是有效员工亲属,请先维护有效的员工亲属关系", exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void validateAndBuildEntity_shouldRejectWhenCombinationAlreadyExistsInDatabase() throws Exception {
|
||||||
|
CcdiStaffEnterpriseRelationExcel excel = buildExcel();
|
||||||
|
CcdiStaffFmyRelation familyRelation = buildFamily();
|
||||||
|
String combination = excel.getPersonId() + "|" + excel.getSocialCreditCode();
|
||||||
|
|
||||||
|
RuntimeException exception = assertThrows(RuntimeException.class,
|
||||||
|
() -> invokeValidateAndBuildEntity(excel, familyRelation, Set.of(excel.getPersonId()), Set.of(combination), new HashSet<>(), "admin"));
|
||||||
|
|
||||||
|
assertEquals("亲属身份证号[" + excel.getPersonId() + "]和统一社会信用代码[" + excel.getSocialCreditCode() + "]的组合已存在,请勿重复导入", exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void validateAndBuildEntity_shouldRejectWhenCombinationAlreadyExistsInExcel() throws Exception {
|
||||||
|
CcdiStaffEnterpriseRelationExcel excel = buildExcel();
|
||||||
|
CcdiStaffFmyRelation familyRelation = buildFamily();
|
||||||
|
String combination = excel.getPersonId() + "|" + excel.getSocialCreditCode();
|
||||||
|
|
||||||
|
RuntimeException exception = assertThrows(RuntimeException.class,
|
||||||
|
() -> invokeValidateAndBuildEntity(excel, familyRelation, Set.of(excel.getPersonId()), Set.of(), new HashSet<>(Set.of(combination)), "admin"));
|
||||||
|
|
||||||
|
assertEquals("亲属身份证号[" + excel.getPersonId() + "]和统一社会信用代码[" + excel.getSocialCreditCode() + "]的组合在导入文件中重复,已跳过此条记录", exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
private CcdiStaffEnterpriseRelation invokeValidateAndBuildEntity(CcdiStaffEnterpriseRelationExcel excel,
|
||||||
|
CcdiStaffFmyRelation familyRelation,
|
||||||
|
Set<String> knownFamilyCertNos,
|
||||||
|
Set<String> existingCombinations,
|
||||||
|
Set<String> processedCombinations,
|
||||||
|
String userName) throws Exception {
|
||||||
|
Method method = CcdiStaffEnterpriseRelationImportServiceImpl.class.getDeclaredMethod(
|
||||||
|
"validateAndBuildEntity",
|
||||||
|
CcdiStaffEnterpriseRelationExcel.class,
|
||||||
|
CcdiStaffFmyRelation.class,
|
||||||
|
Set.class,
|
||||||
|
Set.class,
|
||||||
|
Set.class,
|
||||||
|
String.class
|
||||||
|
);
|
||||||
|
method.setAccessible(true);
|
||||||
|
try {
|
||||||
|
return (CcdiStaffEnterpriseRelation) method.invoke(
|
||||||
|
service,
|
||||||
|
excel,
|
||||||
|
familyRelation,
|
||||||
|
knownFamilyCertNos,
|
||||||
|
existingCombinations,
|
||||||
|
processedCombinations,
|
||||||
|
userName
|
||||||
|
);
|
||||||
|
} catch (InvocationTargetException ex) {
|
||||||
|
Throwable targetException = ex.getTargetException();
|
||||||
|
if (targetException instanceof RuntimeException runtimeException) {
|
||||||
|
throw runtimeException;
|
||||||
|
}
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CcdiStaffEnterpriseRelationExcel buildExcel() {
|
||||||
|
CcdiStaffEnterpriseRelationExcel excel = new CcdiStaffEnterpriseRelationExcel();
|
||||||
|
excel.setPersonId("320101199001010022");
|
||||||
|
excel.setSocialCreditCode("91310000123456789A");
|
||||||
|
excel.setEnterpriseName("测试企业");
|
||||||
|
excel.setRelationPersonPost("董事");
|
||||||
|
return excel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CcdiStaffFmyRelation buildFamily() {
|
||||||
|
CcdiStaffFmyRelation familyRelation = new CcdiStaffFmyRelation();
|
||||||
|
familyRelation.setPersonId("320101199001010011");
|
||||||
|
familyRelation.setRelationCertNo("320101199001010022");
|
||||||
|
familyRelation.setRelationName("李四");
|
||||||
|
familyRelation.setStatus(1);
|
||||||
|
familyRelation.setIsEmpFamily(true);
|
||||||
|
return familyRelation;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
package com.ruoyi.info.collection.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
||||||
|
import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
||||||
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationEditDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffEnterpriseRelationOptionVO;
|
||||||
|
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
||||||
|
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
||||||
|
import com.ruoyi.info.collection.service.impl.CcdiStaffEnterpriseRelationServiceImpl;
|
||||||
|
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||||
|
import org.apache.ibatis.session.Configuration;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class CcdiStaffEnterpriseRelationServiceImplTest {
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initTableInfo() {
|
||||||
|
registerTableInfo(CcdiStaffEnterpriseRelation.class, CcdiStaffEnterpriseRelationMapper.class.getName());
|
||||||
|
registerTableInfo(CcdiStaffFmyRelation.class, CcdiStaffFmyRelationMapper.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private CcdiStaffEnterpriseRelationServiceImpl service;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private CcdiStaffEnterpriseRelationMapper relationMapper;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private CcdiStaffFmyRelationMapper familyRelationMapper;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private ICcdiStaffEnterpriseRelationImportService relationImportService;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void insertRelation_shouldAllowValidFamily() {
|
||||||
|
CcdiStaffEnterpriseRelationAddDTO addDTO = buildAddDto();
|
||||||
|
CcdiStaffFmyRelation familyRelation = new CcdiStaffFmyRelation();
|
||||||
|
familyRelation.setRelationCertNo(addDTO.getPersonId());
|
||||||
|
familyRelation.setRelationName("李四");
|
||||||
|
familyRelation.setPersonId("320101199001010011");
|
||||||
|
|
||||||
|
when(familyRelationMapper.selectOne(any())).thenReturn(familyRelation);
|
||||||
|
when(relationMapper.existsByPersonIdAndSocialCreditCode(addDTO.getPersonId(), addDTO.getSocialCreditCode())).thenReturn(false);
|
||||||
|
when(relationMapper.insert(any(CcdiStaffEnterpriseRelation.class))).thenReturn(1);
|
||||||
|
|
||||||
|
int result = service.insertRelation(addDTO);
|
||||||
|
|
||||||
|
assertEquals(1, result);
|
||||||
|
ArgumentCaptor<CcdiStaffEnterpriseRelation> captor = ArgumentCaptor.forClass(CcdiStaffEnterpriseRelation.class);
|
||||||
|
verify(relationMapper).insert(captor.capture());
|
||||||
|
assertEquals(1, captor.getValue().getStatus());
|
||||||
|
assertEquals("MANUAL", captor.getValue().getDataSource());
|
||||||
|
assertEquals(1, captor.getValue().getIsEmpFamily());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void insertRelation_shouldRejectInvalidFamily() {
|
||||||
|
CcdiStaffEnterpriseRelationAddDTO addDTO = buildAddDto();
|
||||||
|
|
||||||
|
when(familyRelationMapper.selectOne(any()))
|
||||||
|
.thenReturn(null)
|
||||||
|
.thenReturn(new CcdiStaffFmyRelation());
|
||||||
|
|
||||||
|
RuntimeException exception = assertThrows(RuntimeException.class, () -> service.insertRelation(addDTO));
|
||||||
|
|
||||||
|
assertEquals("亲属身份证号[" + addDTO.getPersonId() + "]不是有效员工亲属,请先维护有效的员工亲属关系", exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void insertRelation_shouldRejectMissingFamily() {
|
||||||
|
CcdiStaffEnterpriseRelationAddDTO addDTO = buildAddDto();
|
||||||
|
|
||||||
|
when(familyRelationMapper.selectOne(any())).thenReturn(null);
|
||||||
|
|
||||||
|
RuntimeException exception = assertThrows(RuntimeException.class, () -> service.insertRelation(addDTO));
|
||||||
|
|
||||||
|
assertEquals("亲属身份证号[" + addDTO.getPersonId() + "]不存在,请先维护员工亲属关系", exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void updateRelation_shouldExecuteEditFlow() {
|
||||||
|
CcdiStaffEnterpriseRelationEditDTO editDTO = new CcdiStaffEnterpriseRelationEditDTO();
|
||||||
|
editDTO.setId(1L);
|
||||||
|
editDTO.setPersonId("320101199001010022");
|
||||||
|
editDTO.setSocialCreditCode("91310000123456789A");
|
||||||
|
editDTO.setEnterpriseName("测试企业");
|
||||||
|
editDTO.setRelationPersonPost("董事");
|
||||||
|
editDTO.setStatus(0);
|
||||||
|
editDTO.setRemark("测试备注");
|
||||||
|
|
||||||
|
when(relationMapper.update(isNull(), any(LambdaUpdateWrapper.class))).thenReturn(1);
|
||||||
|
|
||||||
|
int result = service.updateRelation(editDTO);
|
||||||
|
|
||||||
|
assertEquals(1, result);
|
||||||
|
verify(relationMapper).update(isNull(), any(LambdaUpdateWrapper.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void selectFamilyOptions_shouldDelegateToMapper() {
|
||||||
|
CcdiStaffEnterpriseRelationOptionVO option = new CcdiStaffEnterpriseRelationOptionVO();
|
||||||
|
option.setRelationCertNo("320101199001010022");
|
||||||
|
option.setRelationName("李四");
|
||||||
|
option.setStaffPersonId("320101199001010011");
|
||||||
|
option.setStaffPersonName("张三");
|
||||||
|
List<CcdiStaffEnterpriseRelationOptionVO> expected = List.of(option);
|
||||||
|
|
||||||
|
when(relationMapper.selectFamilyOptions("320101")).thenReturn(expected);
|
||||||
|
|
||||||
|
List<CcdiStaffEnterpriseRelationOptionVO> result = service.selectFamilyOptions("320101");
|
||||||
|
|
||||||
|
assertSame(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CcdiStaffEnterpriseRelationAddDTO buildAddDto() {
|
||||||
|
CcdiStaffEnterpriseRelationAddDTO addDTO = new CcdiStaffEnterpriseRelationAddDTO();
|
||||||
|
addDTO.setPersonId("320101199001010022");
|
||||||
|
addDTO.setSocialCreditCode("91310000123456789A");
|
||||||
|
addDTO.setEnterpriseName("测试企业");
|
||||||
|
addDTO.setRelationPersonPost("董事");
|
||||||
|
return addDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerTableInfo(Class<?> entityClass, String namespace) {
|
||||||
|
if (TableInfoHelper.getTableInfo(entityClass) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MapperBuilderAssistant assistant = new MapperBuilderAssistant(new Configuration(), "");
|
||||||
|
assistant.setCurrentNamespace(namespace);
|
||||||
|
TableInfoHelper.initTableInfo(assistant, entityClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import com.ruoyi.info.collection.domain.dto.CcdiAssetInfoDTO;
|
|||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
||||||
|
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
||||||
import com.ruoyi.info.collection.service.impl.CcdiStaffFmyRelationServiceImpl;
|
import com.ruoyi.info.collection.service.impl.CcdiStaffFmyRelationServiceImpl;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -46,6 +47,9 @@ class CcdiStaffFmyRelationServiceImplTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private ICcdiAssetInfoService assetInfoService;
|
private ICcdiAssetInfoService assetInfoService;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private CcdiStaffEnterpriseRelationMapper staffEnterpriseRelationMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void selectRelationById_shouldAggregateAssetInfoList() {
|
void selectRelationById_shouldAggregateAssetInfoList() {
|
||||||
CcdiStaffFmyRelationVO relationVO = new CcdiStaffFmyRelationVO();
|
CcdiStaffFmyRelationVO relationVO = new CcdiStaffFmyRelationVO();
|
||||||
@@ -171,6 +175,36 @@ class CcdiStaffFmyRelationServiceImplTest {
|
|||||||
verify(assetInfoService).replaceByFamilyIdAndPersonId("320101199001010011", "A123456789", editDTO.getAssetInfoList());
|
verify(assetInfoService).replaceByFamilyIdAndPersonId("320101199001010011", "A123456789", editDTO.getAssetInfoList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void updateRelation_shouldInvalidateEnterpriseRelationsWhenFamilyBecomesInvalid() {
|
||||||
|
CcdiStaffFmyRelation existing = new CcdiStaffFmyRelation();
|
||||||
|
existing.setId(10L);
|
||||||
|
existing.setRelationCertType("护照");
|
||||||
|
existing.setRelationCertNo("A123456789");
|
||||||
|
existing.setStatus(1);
|
||||||
|
|
||||||
|
CcdiStaffFmyRelationEditDTO editDTO = new CcdiStaffFmyRelationEditDTO();
|
||||||
|
editDTO.setId(10L);
|
||||||
|
editDTO.setPersonId("320101199001010011");
|
||||||
|
editDTO.setRelationType("配偶");
|
||||||
|
editDTO.setRelationName("李四");
|
||||||
|
editDTO.setRelationCertType("护照");
|
||||||
|
editDTO.setRelationCertNo("A123456789");
|
||||||
|
editDTO.setStatus(0);
|
||||||
|
editDTO.setAssetInfoList(List.of(buildAssetDto("车辆")));
|
||||||
|
|
||||||
|
when(relationMapper.selectById(10L)).thenReturn(existing);
|
||||||
|
when(relationMapper.updateById(any(CcdiStaffFmyRelation.class))).thenReturn(1);
|
||||||
|
|
||||||
|
int result = service.updateRelation(editDTO);
|
||||||
|
|
||||||
|
assertEquals(1, result);
|
||||||
|
var order = inOrder(relationMapper, staffEnterpriseRelationMapper, assetInfoService);
|
||||||
|
order.verify(relationMapper).updateById(any(CcdiStaffFmyRelation.class));
|
||||||
|
order.verify(staffEnterpriseRelationMapper).invalidateByFamilyCertNo("A123456789");
|
||||||
|
order.verify(assetInfoService).replaceByFamilyIdAndPersonId("320101199001010011", "A123456789", editDTO.getAssetInfoList());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void deleteRelationByIds_shouldDeleteRelativeAssetsBeforeDeletingRelations() {
|
void deleteRelationByIds_shouldDeleteRelativeAssetsBeforeDeletingRelations() {
|
||||||
CcdiStaffFmyRelation relation1 = new CcdiStaffFmyRelation();
|
CcdiStaffFmyRelation relation1 = new CcdiStaffFmyRelation();
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
# 员工亲属实体关联实施记录
|
||||||
|
|
||||||
|
## 1. 变更背景
|
||||||
|
|
||||||
|
根据以下实施计划执行员工亲属实体关联改造:
|
||||||
|
|
||||||
|
- 后端计划:`docs/plans/backend/2026-04-23-staff-family-enterprise-relation-backend-implementation.md`
|
||||||
|
- 前端计划:`docs/plans/frontend/2026-04-23-staff-family-enterprise-relation-frontend-implementation.md`
|
||||||
|
|
||||||
|
本次改造目标是在不新增平行模块和表结构的前提下,将原员工实体关系维护切换为员工亲属实体关联维护。
|
||||||
|
|
||||||
|
## 2. 后端实施内容
|
||||||
|
|
||||||
|
### 2.1 契约对象调整
|
||||||
|
|
||||||
|
- 调整 `CcdiStaffEnterpriseRelationQueryDTO`,新增亲属姓名、关联员工查询字段
|
||||||
|
- 调整 `CcdiStaffEnterpriseRelationAddDTO` / `CcdiStaffEnterpriseRelationEditDTO` 的注释与校验提示,明确 `personId` 为亲属身份证号
|
||||||
|
- 调整 `CcdiStaffEnterpriseRelationVO`,新增:
|
||||||
|
- `relationName`
|
||||||
|
- `staffPersonId`
|
||||||
|
- `staffPersonName`
|
||||||
|
- 新增 `CcdiStaffEnterpriseRelationOptionVO` 作为有效亲属下拉返回对象
|
||||||
|
- 调整 `StaffEnterpriseRelationImportFailureVO`,补充 `relationName`
|
||||||
|
- 调整 `CcdiStaffEnterpriseRelationExcel`,将模板列头切换为亲属语义
|
||||||
|
|
||||||
|
### 2.2 Mapper 与查询链路
|
||||||
|
|
||||||
|
- 在 `CcdiStaffEnterpriseRelationMapper` 中新增:
|
||||||
|
- `selectFamilyOptions`
|
||||||
|
- `invalidateByFamilyCertNo`
|
||||||
|
- 重写 `CcdiStaffEnterpriseRelationMapper.xml` 中的列表与详情 SQL
|
||||||
|
- 查询链路改为:
|
||||||
|
- `ccdi_staff_enterprise_relation`
|
||||||
|
- `LEFT JOIN ccdi_staff_fmy_relation`
|
||||||
|
- `LEFT JOIN ccdi_base_staff`
|
||||||
|
- 查询条件支持:
|
||||||
|
- 亲属身份证号
|
||||||
|
- 亲属姓名
|
||||||
|
- 关联员工姓名/身份证号
|
||||||
|
- 统一社会信用代码
|
||||||
|
- 企业名称
|
||||||
|
- 状态
|
||||||
|
|
||||||
|
### 2.3 Service / Controller 改造
|
||||||
|
|
||||||
|
- `CcdiStaffEnterpriseRelationServiceImpl` 新增有效亲属校验逻辑
|
||||||
|
- 新增有效亲属下拉接口 `/ccdi/staffEnterpriseRelation/familyOptions`
|
||||||
|
- 新增和导入均改为以有效员工亲属为准入条件
|
||||||
|
- 控制器 Swagger 标题、日志标题、模板标题和导入返回文案切换为员工亲属实体关联口径
|
||||||
|
|
||||||
|
### 2.4 异步导入改造
|
||||||
|
|
||||||
|
- 导入逻辑取消对 `ccdi_base_staff` 的存在性校验
|
||||||
|
- 改为批量读取 `ccdi_staff_fmy_relation`,区分:
|
||||||
|
- 亲属不存在
|
||||||
|
- 亲属无效
|
||||||
|
- 库内重复
|
||||||
|
- 文件内重复
|
||||||
|
- 失败记录中回填亲属姓名
|
||||||
|
- 导入状态文案切换为员工亲属实体关联口径
|
||||||
|
|
||||||
|
### 2.5 亲属失效联动
|
||||||
|
|
||||||
|
- 在 `CcdiStaffFmyRelationServiceImpl.updateRelation` 中识别“有效 -> 无效”状态变更
|
||||||
|
- 当亲属关系失效时,调用 `invalidateByFamilyCertNo` 将对应实体关联批量置为无效
|
||||||
|
- 不实现“无效 -> 有效”反向恢复
|
||||||
|
|
||||||
|
## 3. 前端实施内容
|
||||||
|
|
||||||
|
### 3.1 API 与页面语义切换
|
||||||
|
|
||||||
|
- `ruoyi-ui/src/api/ccdiStaffEnterpriseRelation.js` 新增 `listFamilyOptions(query)`
|
||||||
|
- `ruoyi-ui/src/views/ccdiStaffEnterpriseRelation/index.vue` 切换为员工亲属实体关联页面
|
||||||
|
|
||||||
|
### 3.2 页面改造点
|
||||||
|
|
||||||
|
- 查询区切换为:
|
||||||
|
- 亲属身份证号
|
||||||
|
- 亲属姓名
|
||||||
|
- 关联员工
|
||||||
|
- 统一社会信用代码
|
||||||
|
- 企业名称
|
||||||
|
- 状态
|
||||||
|
- 列表列切换为:
|
||||||
|
- 亲属身份证号
|
||||||
|
- 亲属姓名
|
||||||
|
- 关联员工
|
||||||
|
- 企业名称
|
||||||
|
- 关联人在企业的职务
|
||||||
|
- 状态
|
||||||
|
- 数据来源
|
||||||
|
- 创建时间
|
||||||
|
- 新增/编辑弹窗切换为有效亲属远程下拉选择
|
||||||
|
- 选中亲属后自动带出亲属姓名和关联员工
|
||||||
|
- 详情弹窗切换为亲属口径展示
|
||||||
|
- 导入标题、模板文件名、通知文案、失败记录标题切换为亲属语义
|
||||||
|
- 本地缓存 key 切换为 `staff_family_enterprise_relation_import_last_task`
|
||||||
|
- 新增菜单迁移脚本 `sql/migration/2026-04-23-rename-staff-enterprise-relation-menu.sql`
|
||||||
|
- 将 `sys_menu` 中“员工实体关系/员工实体关系维护”主菜单改名为“员工亲属实体关联”
|
||||||
|
- 将对应查询、新增、修改、删除、导入、导出按钮权限菜单名称同步切换为亲属语义
|
||||||
|
|
||||||
|
## 4. 验证结果
|
||||||
|
|
||||||
|
### 4.1 后端验证
|
||||||
|
|
||||||
|
- 通过定向测试:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn -pl ccdi-info-collection -am -Dtest=CcdiStaffEnterpriseRelationServiceImplTest,CcdiStaffEnterpriseRelationImportServiceImplTest,CcdiStaffFmyRelationServiceImplTest,CcdiStaffEnterpriseRelationMapperTest -Dsurefire.failIfNoSpecifiedTests=false test
|
||||||
|
```
|
||||||
|
|
||||||
|
- 通过编译验证:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn -pl ccdi-info-collection -am -DskipTests compile
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4.2 前端验证
|
||||||
|
|
||||||
|
- 通过 Node 版本校验:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ruoyi-ui
|
||||||
|
source ~/.nvm/nvm.sh && nvm use
|
||||||
|
```
|
||||||
|
|
||||||
|
- 通过前端构建:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
- 已完成真实页面基础访问与展示项核对,详见:
|
||||||
|
|
||||||
|
`docs/tests/records/2026-04-23-staff-family-enterprise-relation-browser-test-record.md`
|
||||||
|
|
||||||
|
### 4.3 旧数据清理
|
||||||
|
|
||||||
|
- 新增并执行脚本:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bin/mysql_utf8_exec.sh sql/migration/2026-04-23-clean-legacy-staff-enterprise-relation-data.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
- 清理口径:
|
||||||
|
- 删除 `ccdi_staff_enterprise_relation` 中无法匹配任何 `ccdi_staff_fmy_relation.is_emp_family = 1` 记录的旧数据
|
||||||
|
- 本次清理结果:
|
||||||
|
- 清理前总数:15
|
||||||
|
- 可匹配亲属数:0
|
||||||
|
- 清理后剩余总数:0
|
||||||
|
|
||||||
|
## 5. 风险与后续
|
||||||
|
|
||||||
|
- 历史员工本人语义数据未迁移,列表中旧记录的亲属姓名和关联员工可能为空,符合本次设计范围
|
||||||
|
- 浏览器导入实操验证受后端测试进程稳定性影响,尚未完成完整上传闭环
|
||||||
|
- 若继续补齐导入实操测试,需要先确保后端测试进程在桌面会话中可稳定保活
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# 员工亲属实体关联浏览器测试记录
|
||||||
|
|
||||||
|
## 1. 测试目标
|
||||||
|
|
||||||
|
- 验证员工实体关系页面已切换为员工亲属实体关联页面
|
||||||
|
- 验证查询区、列表列、详情弹窗、导入入口文案是否已切换为亲属语义
|
||||||
|
- 验证页面通过真实前端服务和真实后端服务访问,不使用 prototype 页面
|
||||||
|
|
||||||
|
## 2. 测试环境
|
||||||
|
|
||||||
|
- 测试时间:2026-04-23
|
||||||
|
- 前端:`ruoyi-ui`
|
||||||
|
- 前端 Node 版本:`v14.21.3`
|
||||||
|
- 前端访问地址:
|
||||||
|
- 首次稳定访问:`http://localhost:1025/`
|
||||||
|
- 后续 dev server 热重启后访问:`http://127.0.0.1:1027/`
|
||||||
|
- 后端访问地址:`http://localhost:62318`
|
||||||
|
- 浏览器驱动:Playwright CLI
|
||||||
|
|
||||||
|
## 3. 执行过程
|
||||||
|
|
||||||
|
### 3.1 前端构建
|
||||||
|
|
||||||
|
- 执行 `source ~/.nvm/nvm.sh && nvm use`
|
||||||
|
- 执行 `npm run build:prod`
|
||||||
|
- 构建结果:成功
|
||||||
|
- 备注:存在既有包体积告警,不影响本次功能构建结果
|
||||||
|
|
||||||
|
### 3.2 真实页面访问
|
||||||
|
|
||||||
|
- 使用 Playwright 打开真实前端页面并进入系统首页
|
||||||
|
- 通过菜单进入“信息维护”
|
||||||
|
- 成功访问员工实体关系业务页,页面地址为 `/maintain/staffEnterpriseRelation`
|
||||||
|
|
||||||
|
### 3.3 已验证项
|
||||||
|
|
||||||
|
- 查询区已切换为以下字段:
|
||||||
|
- 亲属身份证号
|
||||||
|
- 亲属姓名
|
||||||
|
- 关联员工
|
||||||
|
- 统一社会信用代码
|
||||||
|
- 企业名称
|
||||||
|
- 状态
|
||||||
|
- 列表表头已切换为以下字段:
|
||||||
|
- 亲属身份证号
|
||||||
|
- 亲属姓名
|
||||||
|
- 关联员工
|
||||||
|
- 企业名称
|
||||||
|
- 关联人在企业的职务
|
||||||
|
- 状态
|
||||||
|
- 数据来源
|
||||||
|
- 创建时间
|
||||||
|
- 页面按钮文案已切换为亲属语义:
|
||||||
|
- 新增
|
||||||
|
- 导入
|
||||||
|
- 查看导入失败记录
|
||||||
|
- 后端日志已确认列表查询走新 SQL:
|
||||||
|
- `ccdi_staff_enterprise_relation ser`
|
||||||
|
- `LEFT JOIN ccdi_staff_fmy_relation sfr ON ser.person_id = sfr.relation_cert_no AND sfr.is_emp_family = 1`
|
||||||
|
- `LEFT JOIN ccdi_base_staff bs ON sfr.person_id = bs.id_card`
|
||||||
|
|
||||||
|
## 4. 结果与发现
|
||||||
|
|
||||||
|
### 4.1 页面表现
|
||||||
|
|
||||||
|
- 页面主体已按本次需求切换为员工亲属实体关联口径
|
||||||
|
- 历史数据因未迁移旧员工本人语义记录,当前列表中的亲属姓名和关联员工存在空值/`-`
|
||||||
|
- 该现象符合设计文档中“不迁移旧的员工本人实体关联历史数据、不设计旧数据兼容展示逻辑”的范围说明
|
||||||
|
|
||||||
|
### 4.2 阻塞项
|
||||||
|
|
||||||
|
- 浏览器测试阶段,后端通过 `bin/restart_java_backend.sh` 启动后可正常服务,但在桌面会话中会跟随当前测试会话退出,导致后端在一段时间后自动关闭
|
||||||
|
- 受该稳定性问题影响,本轮未能完成以下真实页面闭环验证:
|
||||||
|
- 新增弹窗中的有效亲属下拉选择
|
||||||
|
- 编辑弹窗完整提交流程
|
||||||
|
- 通过页面下载模板并完成三类导入样本上传
|
||||||
|
- 失败记录弹窗完整回查
|
||||||
|
|
||||||
|
## 5. 结论
|
||||||
|
|
||||||
|
- 已完成真实页面基础访问与核心展示项核对,确认本次前端改造已切换到亲属语义
|
||||||
|
- 后续若继续执行导入实操验证,需先确保后端测试进程在桌面会话中可稳定保活,再继续完成导入样本生成、上传与回收验证
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 查询员工实体关系列表
|
// 查询员工亲属实体关系列表
|
||||||
export function listRelation(query) {
|
export function listRelation(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/ccdi/staffEnterpriseRelation/list',
|
url: '/ccdi/staffEnterpriseRelation/list',
|
||||||
@@ -9,7 +9,16 @@ export function listRelation(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询员工实体关系详情
|
// 查询有效员工亲属下拉选项
|
||||||
|
export function listFamilyOptions(query) {
|
||||||
|
return request({
|
||||||
|
url: '/ccdi/staffEnterpriseRelation/familyOptions',
|
||||||
|
method: 'get',
|
||||||
|
params: { query }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询员工亲属实体关系详情
|
||||||
export function getRelation(id) {
|
export function getRelation(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/ccdi/staffEnterpriseRelation/' + id,
|
url: '/ccdi/staffEnterpriseRelation/' + id,
|
||||||
@@ -17,7 +26,7 @@ export function getRelation(id) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增员工实体关系
|
// 新增员工亲属实体关系
|
||||||
export function addRelation(data) {
|
export function addRelation(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/ccdi/staffEnterpriseRelation',
|
url: '/ccdi/staffEnterpriseRelation',
|
||||||
@@ -26,7 +35,7 @@ export function addRelation(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改员工实体关系
|
// 修改员工亲属实体关系
|
||||||
export function updateRelation(data) {
|
export function updateRelation(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/ccdi/staffEnterpriseRelation',
|
url: '/ccdi/staffEnterpriseRelation',
|
||||||
@@ -35,7 +44,7 @@ export function updateRelation(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除员工实体关系
|
// 删除员工亲属实体关系
|
||||||
export function delRelation(ids) {
|
export function delRelation(ids) {
|
||||||
return request({
|
return request({
|
||||||
url: '/ccdi/staffEnterpriseRelation/' + ids,
|
url: '/ccdi/staffEnterpriseRelation/' + ids,
|
||||||
@@ -51,7 +60,7 @@ export function importTemplate() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导入员工实体关系
|
// 导入员工亲属实体关系
|
||||||
export function importData(file) {
|
export function importData(file) {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
|
|||||||
@@ -1,39 +1,73 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
|
<el-form :model="queryParams" ref="queryForm" size="small" v-show="showSearch" label-width="120px" class="query-form">
|
||||||
<el-form-item label="身份证号" prop="personId">
|
<el-row :gutter="16">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="亲属身份证号" prop="personId">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.personId"
|
v-model="queryParams.personId"
|
||||||
placeholder="请输入身份证号"
|
placeholder="请输入亲属身份证号"
|
||||||
clearable
|
clearable
|
||||||
style="width: 240px"
|
style="width: 100%"
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="亲属姓名" prop="relationName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.relationName"
|
||||||
|
placeholder="请输入亲属姓名"
|
||||||
|
clearable
|
||||||
|
style="width: 100%"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="关联员工" prop="staffPersonName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.staffPersonName"
|
||||||
|
placeholder="请输入关联员工姓名或身份证号"
|
||||||
|
clearable
|
||||||
|
style="width: 100%"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="16">
|
||||||
|
<el-col :span="8">
|
||||||
<el-form-item label="统一社会信用代码" prop="socialCreditCode">
|
<el-form-item label="统一社会信用代码" prop="socialCreditCode">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.socialCreditCode"
|
v-model="queryParams.socialCreditCode"
|
||||||
placeholder="请输入统一社会信用代码"
|
placeholder="请输入统一社会信用代码"
|
||||||
clearable
|
clearable
|
||||||
style="width: 240px"
|
style="width: 100%"
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
<el-form-item label="企业名称" prop="enterpriseName">
|
<el-form-item label="企业名称" prop="enterpriseName">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.enterpriseName"
|
v-model="queryParams.enterpriseName"
|
||||||
placeholder="请输入企业名称"
|
placeholder="请输入企业名称"
|
||||||
clearable
|
clearable
|
||||||
style="width: 240px"
|
style="width: 100%"
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 240px">
|
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 100%">
|
||||||
<el-option label="有效" :value="1" />
|
<el-option label="有效" :value="1" />
|
||||||
<el-option label="无效" :value="0" />
|
<el-option label="无效" :value="0" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
@@ -82,8 +116,13 @@
|
|||||||
|
|
||||||
<el-table v-loading="loading" :data="relationList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="relationList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<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="personId" width="180" :show-overflow-tooltip="true"/>
|
||||||
<el-table-column label="员工姓名" align="center" prop="personName" width="100" />
|
<el-table-column label="亲属姓名" align="center" prop="relationName" width="120" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="关联员工" align="center" min-width="220">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ formatStaffPerson(scope.row) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="企业名称" align="center" prop="enterpriseName" :show-overflow-tooltip="true"/>
|
<el-table-column label="企业名称" align="center" prop="enterpriseName" :show-overflow-tooltip="true"/>
|
||||||
<el-table-column label="关联人在企业的职务" align="center" prop="relationPersonPost" width="150" :show-overflow-tooltip="true"/>
|
<el-table-column label="关联人在企业的职务" align="center" prop="relationPersonPost" width="150" :show-overflow-tooltip="true"/>
|
||||||
<el-table-column label="状态" align="center" prop="status" width="100">
|
<el-table-column label="状态" align="center" prop="status" width="100">
|
||||||
@@ -141,32 +180,45 @@
|
|||||||
<el-form ref="form" :model="form" :rules="rules" label-width="160px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="160px">
|
||||||
<el-row :gutter="16">
|
<el-row :gutter="16">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="身份证号" prop="personId">
|
<el-form-item label="亲属身份证号" prop="personId">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="form.personId"
|
v-model="form.personId"
|
||||||
filterable
|
filterable
|
||||||
remote
|
remote
|
||||||
reserve-keyword
|
reserve-keyword
|
||||||
placeholder="请输入身份证号搜索员工"
|
placeholder="请输入亲属身份证号搜索有效亲属"
|
||||||
:remote-method="searchStaff"
|
:remote-method="searchFamilyOptions"
|
||||||
:loading="staffLoading"
|
:loading="familyLoading"
|
||||||
:disabled="!isAdd"
|
:disabled="!isAdd"
|
||||||
@focus="handleSelectFocus"
|
@focus="handleSelectFocus"
|
||||||
|
@change="handleFamilyChange"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in staffOptions"
|
v-for="item in familyOptions"
|
||||||
:key="item.idCard"
|
:key="item.relationCertNo"
|
||||||
:label="item.idCard + ' - ' + item.name"
|
:label="formatFamilyOptionLabel(item)"
|
||||||
:value="item.idCard"
|
:value="item.relationCertNo"
|
||||||
>
|
>
|
||||||
<span style="float: left">{{ item.idCard }}</span>
|
<span style="float: left">{{ item.relationCertNo }}</span>
|
||||||
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.name }}</span>
|
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.relationName }} / {{ item.staffPersonName || '-' }}</span>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-row :gutter="16">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="亲属姓名">
|
||||||
|
<el-input v-model="form.relationName" disabled placeholder="选择亲属后自动带出" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="关联员工">
|
||||||
|
<el-input :value="formatStaffPerson(form)" disabled placeholder="选择亲属后自动带出" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
<el-row :gutter="16">
|
<el-row :gutter="16">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="统一社会信用代码" prop="socialCreditCode">
|
<el-form-item label="统一社会信用代码" prop="socialCreditCode">
|
||||||
@@ -209,11 +261,13 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 详情对话框 -->
|
<!-- 详情对话框 -->
|
||||||
<el-dialog title="员工实体关系详情" :visible.sync="detailOpen" width="900px" append-to-body>
|
<el-dialog title="员工亲属实体关联详情" :visible.sync="detailOpen" width="900px" append-to-body>
|
||||||
<div class="detail-container">
|
<div class="detail-container">
|
||||||
<el-divider content-position="left">基本信息</el-divider>
|
<el-divider content-position="left">基本信息</el-divider>
|
||||||
<el-descriptions :column="2" border>
|
<el-descriptions :column="2" border>
|
||||||
<el-descriptions-item label="身份证号">{{ relationDetail.personId || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="亲属身份证号">{{ relationDetail.personId || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="亲属姓名">{{ relationDetail.relationName || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="关联员工" :span="2">{{ formatStaffPerson(relationDetail) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="统一社会信用代码">{{ relationDetail.socialCreditCode || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="统一社会信用代码">{{ relationDetail.socialCreditCode || '-' }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="企业名称" :span="2">{{ relationDetail.enterpriseName || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="企业名称" :span="2">{{ relationDetail.enterpriseName || '-' }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="关联人在企业的职务">{{ relationDetail.relationPersonPost || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="关联人在企业的职务">{{ relationDetail.relationPersonPost || '-' }}</el-descriptions-item>
|
||||||
@@ -286,13 +340,13 @@
|
|||||||
<import-result-dialog
|
<import-result-dialog
|
||||||
:visible.sync="importResultVisible"
|
:visible.sync="importResultVisible"
|
||||||
:content="importResultContent"
|
:content="importResultContent"
|
||||||
title="导入结果"
|
title="员工亲属实体关联导入结果"
|
||||||
@close="handleImportResultClose"
|
@close="handleImportResultClose"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 导入失败记录对话框 -->
|
<!-- 导入失败记录对话框 -->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
title="导入失败记录"
|
title="员工亲属实体关联导入失败记录"
|
||||||
:visible.sync="failureDialogVisible"
|
:visible.sync="failureDialogVisible"
|
||||||
width="1200px"
|
width="1200px"
|
||||||
append-to-body
|
append-to-body
|
||||||
@@ -306,7 +360,8 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<el-table :data="failureList" v-loading="failureLoading">
|
<el-table :data="failureList" v-loading="failureLoading">
|
||||||
<el-table-column label="身份证号" prop="personId" align="center" width="180" />
|
<el-table-column label="亲属身份证号" prop="personId" align="center" width="180" />
|
||||||
|
<el-table-column label="亲属姓名" prop="relationName" align="center" width="120" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="企业名称" prop="enterpriseName" align="center" :show-overflow-tooltip="true"/>
|
<el-table-column label="企业名称" prop="enterpriseName" align="center" :show-overflow-tooltip="true"/>
|
||||||
<el-table-column label="统一社会信用代码" prop="socialCreditCode" align="center" width="180" :show-overflow-tooltip="true"/>
|
<el-table-column label="统一社会信用代码" prop="socialCreditCode" align="center" width="180" :show-overflow-tooltip="true"/>
|
||||||
<el-table-column label="失败原因" prop="errorMessage" align="center" min-width="200" :show-overflow-tooltip="true" />
|
<el-table-column label="失败原因" prop="errorMessage" align="center" min-width="200" :show-overflow-tooltip="true" />
|
||||||
@@ -335,15 +390,15 @@ import {
|
|||||||
getImportFailures,
|
getImportFailures,
|
||||||
getImportStatus,
|
getImportStatus,
|
||||||
getRelation,
|
getRelation,
|
||||||
|
listFamilyOptions,
|
||||||
listRelation,
|
listRelation,
|
||||||
updateRelation
|
updateRelation
|
||||||
} from "@/api/ccdiStaffEnterpriseRelation";
|
} from "@/api/ccdiStaffEnterpriseRelation";
|
||||||
import {listBaseStaff} from "@/api/ccdiBaseStaff";
|
|
||||||
import {getToken} from "@/utils/auth";
|
import {getToken} from "@/utils/auth";
|
||||||
import ImportResultDialog from "@/components/ImportResultDialog.vue";
|
import ImportResultDialog from "@/components/ImportResultDialog.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "StaffEnterpriseRelation",
|
name: "StaffFamilyEnterpriseRelation",
|
||||||
dicts: ['ccdi_relation_status', 'ccdi_data_source'],
|
dicts: ['ccdi_relation_status', 'ccdi_data_source'],
|
||||||
components: { ImportResultDialog },
|
components: { ImportResultDialog },
|
||||||
data() {
|
data() {
|
||||||
@@ -360,7 +415,7 @@ export default {
|
|||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// 员工实体关系表格数据
|
// 员工亲属实体关联表格数据
|
||||||
relationList: [],
|
relationList: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: "",
|
||||||
@@ -368,7 +423,7 @@ export default {
|
|||||||
open: false,
|
open: false,
|
||||||
// 是否显示详情弹出层
|
// 是否显示详情弹出层
|
||||||
detailOpen: false,
|
detailOpen: false,
|
||||||
// 员工实体关系详情
|
// 员工亲属实体关联详情
|
||||||
relationDetail: {},
|
relationDetail: {},
|
||||||
// 是否为新增操作
|
// 是否为新增操作
|
||||||
isAdd: false,
|
isAdd: false,
|
||||||
@@ -377,6 +432,8 @@ export default {
|
|||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
personId: null,
|
personId: null,
|
||||||
|
relationName: null,
|
||||||
|
staffPersonName: null,
|
||||||
socialCreditCode: null,
|
socialCreditCode: null,
|
||||||
enterpriseName: null,
|
enterpriseName: null,
|
||||||
status: null
|
status: null
|
||||||
@@ -386,8 +443,8 @@ export default {
|
|||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
personId: [
|
personId: [
|
||||||
{ required: true, message: "身份证号不能为空", trigger: "blur" },
|
{ required: true, message: "亲属身份证号不能为空", trigger: "blur" },
|
||||||
{ pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: "请输入正确的18位身份证号", trigger: "blur" }
|
{ pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: "请输入正确的18位亲属身份证号", trigger: "blur" }
|
||||||
],
|
],
|
||||||
socialCreditCode: [
|
socialCreditCode: [
|
||||||
{ required: true, message: "统一社会信用代码不能为空", trigger: "blur" },
|
{ required: true, message: "统一社会信用代码不能为空", trigger: "blur" },
|
||||||
@@ -407,9 +464,9 @@ export default {
|
|||||||
{ max: 500, message: "补充说明长度不能超过500个字符", trigger: "blur" }
|
{ max: 500, message: "补充说明长度不能超过500个字符", trigger: "blur" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// 员工选项
|
// 有效员工亲属选项
|
||||||
staffOptions: [],
|
familyOptions: [],
|
||||||
staffLoading: false,
|
familyLoading: false,
|
||||||
// 导入参数
|
// 导入参数
|
||||||
upload: {
|
upload: {
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
@@ -467,7 +524,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询员工实体关系列表 */
|
/** 查询员工亲属实体关系列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listRelation(this.queryParams).then(response => {
|
listRelation(this.queryParams).then(response => {
|
||||||
@@ -476,25 +533,57 @@ export default {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 搜索员工 */
|
/** 搜索有效员工亲属 */
|
||||||
searchStaff(query) {
|
searchFamilyOptions(query) {
|
||||||
this.staffLoading = true;
|
this.familyLoading = true;
|
||||||
// 如果输入为空,查询所有员工;否则根据身份证号模糊查询
|
listFamilyOptions(query || '').then(response => {
|
||||||
const params = query !== '' ? { idCard: query, pageNum: 1, pageSize: 10 } : { pageNum: 1, pageSize: 10 };
|
this.familyOptions = response.data || [];
|
||||||
listBaseStaff(params).then(response => {
|
this.familyLoading = false;
|
||||||
this.staffOptions = response.rows;
|
|
||||||
this.staffLoading = false;
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.staffLoading = false;
|
this.familyLoading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 下拉框获得焦点时加载员工列表 */
|
/** 下拉框获得焦点时加载有效员工亲属列表 */
|
||||||
handleSelectFocus() {
|
handleSelectFocus() {
|
||||||
// 如果选项列表为空,自动加载所有员工
|
if (!this.familyOptions || this.familyOptions.length === 0) {
|
||||||
if (!this.staffOptions || this.staffOptions.length === 0) {
|
this.searchFamilyOptions('');
|
||||||
this.searchStaff('');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/** 选中亲属后带出亲属姓名和关联员工 */
|
||||||
|
handleFamilyChange(value) {
|
||||||
|
if (!value) {
|
||||||
|
this.form.relationName = null;
|
||||||
|
this.form.staffPersonId = null;
|
||||||
|
this.form.staffPersonName = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const selected = this.familyOptions.find(item => item.relationCertNo === value);
|
||||||
|
if (!selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.form.relationName = selected.relationName;
|
||||||
|
this.form.staffPersonId = selected.staffPersonId;
|
||||||
|
this.form.staffPersonName = selected.staffPersonName;
|
||||||
|
},
|
||||||
|
formatFamilyOptionLabel(item) {
|
||||||
|
return `${item.relationCertNo} - ${item.relationName || '-'} / ${item.staffPersonName || '-'}`;
|
||||||
|
},
|
||||||
|
formatStaffPerson(row) {
|
||||||
|
if (!row || (!row.staffPersonName && !row.staffPersonId)) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
if (row.staffPersonName && row.staffPersonId) {
|
||||||
|
return `${row.staffPersonName}(${row.staffPersonId})`;
|
||||||
|
}
|
||||||
|
return row.staffPersonName || row.staffPersonId;
|
||||||
|
},
|
||||||
|
buildSubmitPayload() {
|
||||||
|
const payload = { ...this.form };
|
||||||
|
delete payload.relationName;
|
||||||
|
delete payload.staffPersonId;
|
||||||
|
delete payload.staffPersonName;
|
||||||
|
return payload;
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 恢复导入状态
|
* 恢复导入状态
|
||||||
* 在created()钩子中调用
|
* 在created()钩子中调用
|
||||||
@@ -537,13 +626,16 @@ export default {
|
|||||||
this.form = {
|
this.form = {
|
||||||
id: null,
|
id: null,
|
||||||
personId: null,
|
personId: null,
|
||||||
|
relationName: null,
|
||||||
|
staffPersonId: null,
|
||||||
|
staffPersonName: null,
|
||||||
relationPersonPost: null,
|
relationPersonPost: null,
|
||||||
socialCreditCode: null,
|
socialCreditCode: null,
|
||||||
enterpriseName: null,
|
enterpriseName: null,
|
||||||
status: 1, // 数字类型,与后端保持一致
|
status: 1, // 数字类型,与后端保持一致
|
||||||
remark: null
|
remark: null
|
||||||
};
|
};
|
||||||
this.staffOptions = [];
|
this.familyOptions = [];
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
@@ -566,7 +658,7 @@ export default {
|
|||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "添加员工实体关系";
|
this.title = "添加员工亲属实体关联";
|
||||||
this.isAdd = true;
|
this.isAdd = true;
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
@@ -575,12 +667,16 @@ export default {
|
|||||||
const id = row.id || this.ids[0];
|
const id = row.id || this.ids[0];
|
||||||
getRelation(id).then(response => {
|
getRelation(id).then(response => {
|
||||||
this.form = response.data;
|
this.form = response.data;
|
||||||
// 加载员工信息以支持下拉显示
|
|
||||||
if (this.form.personId) {
|
if (this.form.personId) {
|
||||||
this.searchStaff(this.form.personId);
|
this.familyOptions = [{
|
||||||
|
relationCertNo: this.form.personId,
|
||||||
|
relationName: this.form.relationName,
|
||||||
|
staffPersonId: this.form.staffPersonId,
|
||||||
|
staffPersonName: this.form.staffPersonName
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "修改员工实体关系";
|
this.title = "修改员工亲属实体关联";
|
||||||
this.isAdd = false;
|
this.isAdd = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -596,14 +692,15 @@ export default {
|
|||||||
submitForm() {
|
submitForm() {
|
||||||
this.$refs["form"].validate(valid => {
|
this.$refs["form"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
const payload = this.buildSubmitPayload();
|
||||||
if (this.isAdd) {
|
if (this.isAdd) {
|
||||||
addRelation(this.form).then(response => {
|
addRelation(payload).then(() => {
|
||||||
this.$modal.msgSuccess("新增成功");
|
this.$modal.msgSuccess("新增成功");
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
updateRelation(this.form).then(response => {
|
updateRelation(payload).then(() => {
|
||||||
this.$modal.msgSuccess("修改成功");
|
this.$modal.msgSuccess("修改成功");
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
@@ -624,12 +721,12 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导入按钮操作 */
|
/** 导入按钮操作 */
|
||||||
handleImport() {
|
handleImport() {
|
||||||
this.upload.title = "员工实体关系数据导入";
|
this.upload.title = "员工亲属实体关联数据导入";
|
||||||
this.upload.open = true;
|
this.upload.open = true;
|
||||||
},
|
},
|
||||||
/** 下载模板操作 */
|
/** 下载模板操作 */
|
||||||
importTemplate() {
|
importTemplate() {
|
||||||
this.download('ccdi/staffEnterpriseRelation/importTemplate', {}, `员工实体关系导入模板_${new Date().getTime()}.xlsx`);
|
this.download('ccdi/staffEnterpriseRelation/importTemplate', {}, `员工亲属实体关联导入模板_${new Date().getTime()}.xlsx`);
|
||||||
},
|
},
|
||||||
// 文件上传中处理
|
// 文件上传中处理
|
||||||
handleFileUploadProgress(event, file, fileList) {
|
handleFileUploadProgress(event, file, fileList) {
|
||||||
@@ -673,7 +770,7 @@ export default {
|
|||||||
|
|
||||||
// 显示后台处理提示(不是弹窗,是通知)
|
// 显示后台处理提示(不是弹窗,是通知)
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '导入任务已提交',
|
title: '员工亲属实体关联导入任务已提交',
|
||||||
message: '正在后台处理中,处理完成后将通知您',
|
message: '正在后台处理中,处理完成后将通知您',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
duration: 3000
|
duration: 3000
|
||||||
@@ -772,7 +869,7 @@ export default {
|
|||||||
// 全部成功
|
// 全部成功
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '导入完成',
|
title: '导入完成',
|
||||||
message: `全部成功!共导入${statusResult.totalCount}条数据`,
|
message: `员工亲属实体关联全部成功!共导入${statusResult.totalCount}条数据`,
|
||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 5000
|
duration: 5000
|
||||||
});
|
});
|
||||||
@@ -782,7 +879,7 @@ export default {
|
|||||||
// 部分失败
|
// 部分失败
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '导入完成',
|
title: '导入完成',
|
||||||
message: `成功${statusResult.successCount}条,失败${statusResult.failureCount}条`,
|
message: `员工亲属实体关联成功${statusResult.successCount}条,失败${statusResult.failureCount}条`,
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
duration: 5000
|
duration: 5000
|
||||||
});
|
});
|
||||||
@@ -819,7 +916,7 @@ export default {
|
|||||||
...taskData,
|
...taskData,
|
||||||
saveTime: Date.now()
|
saveTime: Date.now()
|
||||||
};
|
};
|
||||||
localStorage.setItem('staff_enterprise_relation_import_last_task', JSON.stringify(data));
|
localStorage.setItem('staff_family_enterprise_relation_import_last_task', JSON.stringify(data));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('保存导入任务状态失败:', error);
|
console.error('保存导入任务状态失败:', error);
|
||||||
}
|
}
|
||||||
@@ -830,7 +927,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
getImportTaskFromStorage() {
|
getImportTaskFromStorage() {
|
||||||
try {
|
try {
|
||||||
const data = localStorage.getItem('staff_enterprise_relation_import_last_task');
|
const data = localStorage.getItem('staff_family_enterprise_relation_import_last_task');
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
|
|
||||||
const task = JSON.parse(data);
|
const task = JSON.parse(data);
|
||||||
@@ -883,7 +980,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
clearImportTaskFromStorage() {
|
clearImportTaskFromStorage() {
|
||||||
try {
|
try {
|
||||||
localStorage.removeItem('staff_enterprise_relation_import_last_task');
|
localStorage.removeItem('staff_family_enterprise_relation_import_last_task');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('清除导入任务状态失败:', error);
|
console.error('清除导入任务状态失败:', error);
|
||||||
}
|
}
|
||||||
@@ -893,6 +990,19 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.query-form ::v-deep .el-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-form ::v-deep .el-col {
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-form ::v-deep .el-form-item {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.detail-container {
|
.detail-container {
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
-- 清理员工实体关系历史旧数据
|
||||||
|
-- 说明:删除当前无法匹配任何员工亲属关系(is_emp_family = 1)的旧实体关联记录
|
||||||
|
-- 执行方式:bin/mysql_utf8_exec.sh sql/migration/2026-04-23-clean-legacy-staff-enterprise-relation-data.sql
|
||||||
|
|
||||||
|
DELETE ser
|
||||||
|
FROM ccdi_staff_enterprise_relation ser
|
||||||
|
LEFT JOIN ccdi_staff_fmy_relation sfr
|
||||||
|
ON ser.person_id = sfr.relation_cert_no
|
||||||
|
AND sfr.is_emp_family = 1
|
||||||
|
WHERE sfr.id IS NULL;
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
-- 员工实体关系菜单改名为员工亲属实体关联
|
||||||
|
-- 执行方式:bin/mysql_utf8_exec.sh sql/migration/2026-04-23-rename-staff-enterprise-relation-menu.sql
|
||||||
|
|
||||||
|
UPDATE sys_menu
|
||||||
|
SET menu_name = '员工亲属实体关联',
|
||||||
|
remark = '员工亲属实体关联菜单',
|
||||||
|
update_by = 'admin',
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE perms = 'ccdi:staffEnterpriseRelation:list'
|
||||||
|
OR path = 'staffEnterpriseRelation'
|
||||||
|
OR menu_name IN ('员工实体关系', '员工实体关系维护');
|
||||||
|
|
||||||
|
UPDATE sys_menu
|
||||||
|
SET menu_name = CASE perms
|
||||||
|
WHEN 'ccdi:staffEnterpriseRelation:query' THEN '员工亲属实体关联查询'
|
||||||
|
WHEN 'ccdi:staffEnterpriseRelation:add' THEN '员工亲属实体关联新增'
|
||||||
|
WHEN 'ccdi:staffEnterpriseRelation:edit' THEN '员工亲属实体关联修改'
|
||||||
|
WHEN 'ccdi:staffEnterpriseRelation:remove' THEN '员工亲属实体关联删除'
|
||||||
|
WHEN 'ccdi:staffEnterpriseRelation:import' THEN '员工亲属实体关联导入'
|
||||||
|
WHEN 'ccdi:staffEnterpriseRelation:export' THEN '员工亲属实体关联导出'
|
||||||
|
ELSE menu_name
|
||||||
|
END,
|
||||||
|
update_by = 'admin',
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE perms IN (
|
||||||
|
'ccdi:staffEnterpriseRelation:query',
|
||||||
|
'ccdi:staffEnterpriseRelation:add',
|
||||||
|
'ccdi:staffEnterpriseRelation:edit',
|
||||||
|
'ccdi:staffEnterpriseRelation:remove',
|
||||||
|
'ccdi:staffEnterpriseRelation:import',
|
||||||
|
'ccdi:staffEnterpriseRelation:export'
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user