Update import templates and relation query fields
This commit is contained in:
@@ -33,6 +33,10 @@ public class CcdiCustFmyRelationQueryDTO implements Serializable {
|
||||
@Schema(description = "关系人姓名")
|
||||
private String relationName;
|
||||
|
||||
/** 关系人身份证号 */
|
||||
@Schema(description = "关系人身份证号")
|
||||
private String relationCertNo;
|
||||
|
||||
/** 状态 */
|
||||
@Schema(description = "状态:0-无效,1-有效")
|
||||
private Integer status;
|
||||
|
||||
@@ -37,6 +37,10 @@ public class CcdiStaffFmyRelationQueryDTO implements Serializable {
|
||||
@Schema(description = "关系人姓名")
|
||||
private String relationName;
|
||||
|
||||
/** 关系人身份证号 */
|
||||
@Schema(description = "关系人身份证号")
|
||||
private String relationCertNo;
|
||||
|
||||
/** 状态 */
|
||||
@Schema(description = "状态:0-无效,1-有效")
|
||||
private Integer status;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.info.collection.domain.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.ruoyi.common.annotation.Required;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -17,17 +18,19 @@ public class CcdiIntermediaryEnterpriseRelationExcel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 中介本人证件号码 */
|
||||
@ExcelProperty(value = "中介本人证件号码*", index = 0)
|
||||
@ExcelProperty(value = "中介本人证件号码", index = 0)
|
||||
@ColumnWidth(24)
|
||||
@Required
|
||||
private String ownerPersonId;
|
||||
|
||||
/** 统一社会信用代码 */
|
||||
@ExcelProperty(value = "统一社会信用代码*", index = 1)
|
||||
@ExcelProperty(value = "统一社会信用代码", index = 1)
|
||||
@ColumnWidth(24)
|
||||
@Required
|
||||
private String socialCreditCode;
|
||||
|
||||
/** 关联人职务 */
|
||||
@ExcelProperty(value = "关联人职务", index = 2)
|
||||
/** 关联职务 */
|
||||
@ExcelProperty(value = "关联职务", index = 2)
|
||||
@ColumnWidth(20)
|
||||
private String relationPersonPost;
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ public class CcdiStaffRecruitmentExcel implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 招聘项目编号 */
|
||||
@ExcelProperty(value = "招聘项目编号", index = 0)
|
||||
/** 招聘记录编号 */
|
||||
@ExcelProperty(value = "招聘记录编号", index = 0)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
private String recruitId;
|
||||
@@ -51,66 +51,72 @@ public class CcdiStaffRecruitmentExcel implements Serializable {
|
||||
@Required
|
||||
private String posDesc;
|
||||
|
||||
/** 应聘人员姓名 */
|
||||
@ExcelProperty(value = "应聘人员姓名", index = 5)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String candName;
|
||||
|
||||
/** 应聘人员学历 */
|
||||
@ExcelProperty(value = "应聘人员学历", index = 6)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String candEdu;
|
||||
|
||||
/** 应聘人员证件号码 */
|
||||
@ExcelProperty(value = "应聘人员证件号码", index = 7)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
private String candId;
|
||||
|
||||
/** 应聘人员毕业院校 */
|
||||
@ExcelProperty(value = "应聘人员毕业院校", index = 8)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
private String candSchool;
|
||||
|
||||
/** 应聘人员专业 */
|
||||
@ExcelProperty(value = "应聘人员专业", index = 9)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String candMajor;
|
||||
|
||||
/** 应聘人员毕业年月 */
|
||||
@ExcelProperty(value = "应聘人员毕业年月", index = 10)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String candGrad;
|
||||
|
||||
/** 录用情况 */
|
||||
@ExcelProperty(value = "录用情况", index = 11)
|
||||
@ExcelProperty(value = "录用情况", index = 5)
|
||||
@ColumnWidth(10)
|
||||
@DictDropdown(dictType = "ccdi_admit_status")
|
||||
@Required
|
||||
private String admitStatus;
|
||||
|
||||
/** 候选人姓名 */
|
||||
@ExcelProperty(value = "候选人姓名", index = 6)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String candName;
|
||||
|
||||
/** 招聘类型 */
|
||||
@ExcelProperty(value = "招聘类型", index = 7)
|
||||
@ColumnWidth(12)
|
||||
@Required
|
||||
private String recruitType;
|
||||
|
||||
/** 应聘人员学历 */
|
||||
@ExcelProperty(value = "学历", index = 8)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String candEdu;
|
||||
|
||||
/** 应聘人员证件号码 */
|
||||
@ExcelProperty(value = "证件号码", index = 9)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
private String candId;
|
||||
|
||||
/** 应聘人员毕业年月 */
|
||||
@ExcelProperty(value = "毕业年月", index = 10)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String candGrad;
|
||||
|
||||
/** 应聘人员毕业院校 */
|
||||
@ExcelProperty(value = "毕业院校", index = 11)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
private String candSchool;
|
||||
|
||||
/** 应聘人员专业 */
|
||||
@ExcelProperty(value = "专业", index = 12)
|
||||
@ColumnWidth(15)
|
||||
@Required
|
||||
private String candMajor;
|
||||
|
||||
/** 面试官1姓名 */
|
||||
@ExcelProperty(value = "面试官1姓名", index = 12)
|
||||
@ExcelProperty(value = "面试官1姓名", index = 13)
|
||||
@ColumnWidth(15)
|
||||
private String interviewerName1;
|
||||
|
||||
/** 面试官1工号 */
|
||||
@ExcelProperty(value = "面试官1工号", index = 13)
|
||||
@ExcelProperty(value = "面试官1工号", index = 14)
|
||||
@ColumnWidth(15)
|
||||
private String interviewerId1;
|
||||
|
||||
/** 面试官2姓名 */
|
||||
@ExcelProperty(value = "面试官2姓名", index = 14)
|
||||
@ExcelProperty(value = "面试官2姓名", index = 15)
|
||||
@ColumnWidth(15)
|
||||
private String interviewerName2;
|
||||
|
||||
/** 面试官2工号 */
|
||||
@ExcelProperty(value = "面试官2工号", index = 15)
|
||||
@ExcelProperty(value = "面试官2工号", index = 16)
|
||||
@ColumnWidth(15)
|
||||
private String interviewerId2;
|
||||
}
|
||||
|
||||
@@ -61,20 +61,20 @@ public class CcdiStaffRecruitmentWorkExcel implements Serializable {
|
||||
@ColumnWidth(18)
|
||||
private String departmentName;
|
||||
|
||||
/** 岗位 */
|
||||
@ExcelProperty(value = "岗位", index = 7)
|
||||
/** 岗位名称 */
|
||||
@ExcelProperty(value = "岗位名称", index = 7)
|
||||
@ColumnWidth(20)
|
||||
@Required
|
||||
private String positionName;
|
||||
|
||||
/** 入职年月 */
|
||||
@ExcelProperty(value = "入职年月", index = 8)
|
||||
@ExcelProperty(value = "入职时间", index = 8)
|
||||
@ColumnWidth(12)
|
||||
@Required
|
||||
private String jobStartMonth;
|
||||
|
||||
/** 离职年月 */
|
||||
@ExcelProperty(value = "离职年月", index = 9)
|
||||
@ExcelProperty(value = "离职时间", index = 9)
|
||||
@ColumnWidth(12)
|
||||
private String jobEndMonth;
|
||||
|
||||
@@ -83,8 +83,8 @@ public class CcdiStaffRecruitmentWorkExcel implements Serializable {
|
||||
@ColumnWidth(30)
|
||||
private String departureReason;
|
||||
|
||||
/** 工作内容 */
|
||||
@ExcelProperty(value = "工作内容", index = 11)
|
||||
/** 主要工作内容 */
|
||||
@ExcelProperty(value = "主要工作内容", index = 11)
|
||||
@ColumnWidth(35)
|
||||
private String workContent;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class IntermediaryEnterpriseRelationImportFailureVO implements Serializab
|
||||
@Schema(description = "统一社会信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
@Schema(description = "关联人职务")
|
||||
@Schema(description = "关联职务")
|
||||
private String relationPersonPost;
|
||||
|
||||
@Schema(description = "备注")
|
||||
|
||||
@@ -79,12 +79,14 @@ public class CcdiIntermediaryEnterpriseRelationImportServiceImpl implements ICcd
|
||||
try {
|
||||
validateExcel(excel);
|
||||
|
||||
String ownerBizId = ownerBizIdByPersonId.get(excel.getOwnerPersonId());
|
||||
String ownerPersonId = trim(excel.getOwnerPersonId());
|
||||
String socialCreditCode = trim(excel.getSocialCreditCode());
|
||||
String ownerBizId = ownerBizIdByPersonId.get(ownerPersonId);
|
||||
if (StringUtils.isEmpty(ownerBizId)) {
|
||||
throw new RuntimeException("中介本人不存在,请先导入或维护中介本人信息");
|
||||
}
|
||||
|
||||
String combination = ownerBizId + "|" + excel.getSocialCreditCode();
|
||||
String combination = ownerBizId + "|" + socialCreditCode;
|
||||
if (existingCombinations.contains(combination)) {
|
||||
throw new RuntimeException("中介实体关联关系已存在,请勿重复导入");
|
||||
}
|
||||
@@ -95,6 +97,9 @@ public class CcdiIntermediaryEnterpriseRelationImportServiceImpl implements ICcd
|
||||
CcdiIntermediaryEnterpriseRelation relation = new CcdiIntermediaryEnterpriseRelation();
|
||||
BeanUtils.copyProperties(excel, relation);
|
||||
relation.setIntermediaryBizId(ownerBizId);
|
||||
relation.setSocialCreditCode(socialCreditCode);
|
||||
relation.setRelationPersonPost(trim(excel.getRelationPersonPost()));
|
||||
relation.setRemark(trim(excel.getRemark()));
|
||||
relation.setCreatedBy(userName);
|
||||
relation.setUpdatedBy(userName);
|
||||
successRecords.add(relation);
|
||||
@@ -165,6 +170,7 @@ public class CcdiIntermediaryEnterpriseRelationImportServiceImpl implements ICcd
|
||||
private Map<String, String> getOwnerBizIdByPersonId(List<CcdiIntermediaryEnterpriseRelationExcel> excelList) {
|
||||
List<String> ownerPersonIds = excelList.stream()
|
||||
.map(CcdiIntermediaryEnterpriseRelationExcel::getOwnerPersonId)
|
||||
.map(this::trim)
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
@@ -183,11 +189,12 @@ public class CcdiIntermediaryEnterpriseRelationImportServiceImpl implements ICcd
|
||||
List<CcdiIntermediaryEnterpriseRelationExcel> excelList) {
|
||||
List<String> combinations = excelList.stream()
|
||||
.map(excel -> {
|
||||
String ownerBizId = ownerBizIdByPersonId.get(excel.getOwnerPersonId());
|
||||
if (StringUtils.isEmpty(ownerBizId) || StringUtils.isEmpty(excel.getSocialCreditCode())) {
|
||||
String ownerBizId = ownerBizIdByPersonId.get(trim(excel.getOwnerPersonId()));
|
||||
String socialCreditCode = trim(excel.getSocialCreditCode());
|
||||
if (StringUtils.isEmpty(ownerBizId) || StringUtils.isEmpty(socialCreditCode)) {
|
||||
return null;
|
||||
}
|
||||
return ownerBizId + "|" + excel.getSocialCreditCode();
|
||||
return ownerBizId + "|" + socialCreditCode;
|
||||
})
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.distinct()
|
||||
@@ -199,24 +206,33 @@ public class CcdiIntermediaryEnterpriseRelationImportServiceImpl implements ICcd
|
||||
}
|
||||
|
||||
private void validateExcel(CcdiIntermediaryEnterpriseRelationExcel excel) {
|
||||
if (StringUtils.isEmpty(excel.getOwnerPersonId())) {
|
||||
String ownerPersonId = trim(excel.getOwnerPersonId());
|
||||
String socialCreditCode = trim(excel.getSocialCreditCode());
|
||||
String relationPersonPost = trim(excel.getRelationPersonPost());
|
||||
String remark = trim(excel.getRemark());
|
||||
|
||||
if (StringUtils.isEmpty(ownerPersonId)) {
|
||||
throw new RuntimeException("中介本人证件号码不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(excel.getSocialCreditCode())) {
|
||||
if (StringUtils.isEmpty(socialCreditCode)) {
|
||||
throw new RuntimeException("统一社会信用代码不能为空");
|
||||
}
|
||||
String ownerPersonIdError = IdCardUtil.getErrorMessage(excel.getOwnerPersonId());
|
||||
String ownerPersonIdError = IdCardUtil.getErrorMessage(ownerPersonId);
|
||||
if (ownerPersonIdError != null) {
|
||||
throw new RuntimeException("中介本人证件号码" + ownerPersonIdError);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(excel.getRelationPersonPost()) && excel.getRelationPersonPost().length() > 100) {
|
||||
throw new RuntimeException("关联人职务长度不能超过100个字符");
|
||||
if (StringUtils.isNotEmpty(relationPersonPost) && relationPersonPost.length() > 100) {
|
||||
throw new RuntimeException("关联职务长度不能超过100个字符");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(excel.getRemark()) && excel.getRemark().length() > 500) {
|
||||
if (StringUtils.isNotEmpty(remark) && remark.length() > 500) {
|
||||
throw new RuntimeException("备注长度不能超过500个字符");
|
||||
}
|
||||
}
|
||||
|
||||
private String trim(String value) {
|
||||
return value == null ? null : value.trim();
|
||||
}
|
||||
|
||||
private IntermediaryEnterpriseRelationImportFailureVO createFailureVO(CcdiIntermediaryEnterpriseRelationExcel excel,
|
||||
String errorMessage) {
|
||||
IntermediaryEnterpriseRelationImportFailureVO failure = new IntermediaryEnterpriseRelationImportFailureVO();
|
||||
|
||||
@@ -178,7 +178,7 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
try {
|
||||
CcdiStaffRecruitmentAddDTO addDTO = new CcdiStaffRecruitmentAddDTO();
|
||||
BeanUtils.copyProperties(excel, addDTO);
|
||||
addDTO.setRecruitType(RecruitType.inferCode(addDTO.getRecruitName()));
|
||||
addDTO.setRecruitType(normalizeRecruitType(excel.getRecruitType()));
|
||||
|
||||
validateRecruitmentData(addDTO, mainRow.sheetRowNum());
|
||||
|
||||
@@ -376,22 +376,22 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "职位描述不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getCandName())) {
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "应聘人员姓名不能为空");
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "候选人姓名不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getCandEdu())) {
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "应聘人员学历不能为空");
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "学历不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getCandId())) {
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "证件号码不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getCandSchool())) {
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "应聘人员毕业院校不能为空");
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "毕业院校不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getCandMajor())) {
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "应聘人员专业不能为空");
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "专业不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getCandGrad())) {
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "应聘人员毕业年月不能为空");
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "毕业年月不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(addDTO.getAdmitStatus())) {
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "录用情况不能为空");
|
||||
@@ -414,10 +414,23 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
}
|
||||
|
||||
if (RecruitType.getDescByCode(addDTO.getRecruitType()) == null) {
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "招聘类型只能填写'SOCIAL'或'CAMPUS'");
|
||||
throw buildValidationException(MAIN_SHEET_NAME, List.of(sheetRowNum), "招聘类型只能填写'SOCIAL/社招'或'CAMPUS/校招'");
|
||||
}
|
||||
}
|
||||
|
||||
private String normalizeRecruitType(String recruitType) {
|
||||
String value = trim(recruitType);
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
return value;
|
||||
}
|
||||
for (RecruitType type : RecruitType.values()) {
|
||||
if (type.getCode().equals(value) || type.getDesc().equals(value)) {
|
||||
return type.getCode();
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private void validateWorkGroup(List<WorkImportRow> workRows, CcdiStaffRecruitment recruitment) {
|
||||
Set<Integer> processedSortOrders = new HashSet<>();
|
||||
for (WorkImportRow workRow : workRows) {
|
||||
@@ -451,14 +464,14 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
throw buildValidationException(WORK_SHEET_NAME, List.of(sheetRowNum), "工作单位不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(trim(excel.getPositionName()))) {
|
||||
throw buildValidationException(WORK_SHEET_NAME, List.of(sheetRowNum), "岗位不能为空");
|
||||
throw buildValidationException(WORK_SHEET_NAME, List.of(sheetRowNum), "岗位名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(trim(excel.getJobStartMonth()))) {
|
||||
throw buildValidationException(WORK_SHEET_NAME, List.of(sheetRowNum), "入职年月不能为空");
|
||||
throw buildValidationException(WORK_SHEET_NAME, List.of(sheetRowNum), "入职时间不能为空");
|
||||
}
|
||||
validateMonth(excel.getJobStartMonth(), "入职年月", sheetRowNum);
|
||||
validateMonth(excel.getJobStartMonth(), "入职时间", sheetRowNum);
|
||||
if (StringUtils.isNotEmpty(trim(excel.getJobEndMonth()))) {
|
||||
validateMonth(excel.getJobEndMonth(), "离职年月", sheetRowNum);
|
||||
validateMonth(excel.getJobEndMonth(), "离职时间", sheetRowNum);
|
||||
}
|
||||
if (recruitment == null) {
|
||||
throw buildValidationException(WORK_SHEET_NAME, List.of(sheetRowNum), "招聘记录编号不存在,请先维护招聘主信息");
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.relationCertNo != null and query.relationCertNo != ''">
|
||||
AND r.relation_cert_no LIKE CONCAT('%', #{query.relationCertNo}, '%')
|
||||
</if>
|
||||
ORDER BY r.create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.relationCertNo != null and query.relationCertNo != ''">
|
||||
AND r.relation_cert_no LIKE CONCAT('%', #{query.relationCertNo}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND r.status = #{query.status}
|
||||
</if>
|
||||
@@ -115,6 +118,9 @@
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.relationCertNo != null and query.relationCertNo != ''">
|
||||
AND r.relation_cert_no LIKE CONCAT('%', #{query.relationCertNo}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND r.status = #{query.status}
|
||||
</if>
|
||||
|
||||
@@ -96,6 +96,26 @@ class CcdiAssetInfoImportServiceImplTest {
|
||||
assertEquals("320101199001010011", captor.getValue().get(0).getPersonId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void importAssetInfoSync_shouldResolveFamilyIdFromCurrentWorkbookRelation() {
|
||||
CcdiAssetInfoExcel excel = buildExcel("320101199001010033", "股权");
|
||||
when(redisTemplate.opsForHash()).thenReturn(hashOperations);
|
||||
when(assetInfoMapper.selectOwnerCandidatesByRelationCertNos(List.of("320101199001010033")))
|
||||
.thenReturn(List.of());
|
||||
|
||||
service.importAssetInfoSync(
|
||||
List.of(excel),
|
||||
"task-current-workbook",
|
||||
"tester",
|
||||
Map.of("320101199001010033", Set.of("320101199009090099"))
|
||||
);
|
||||
|
||||
ArgumentCaptor<List<CcdiAssetInfo>> captor = ArgumentCaptor.forClass(List.class);
|
||||
verify(assetInfoMapper).insertBatch(captor.capture());
|
||||
assertEquals("320101199009090099", captor.getValue().get(0).getFamilyId());
|
||||
assertEquals("320101199001010033", captor.getValue().get(0).getPersonId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void importAssetInfoAsync_shouldFailWhenEmployeeIdCardIsUsedForFamilyAssetImport() {
|
||||
CcdiAssetInfoExcel excel = buildExcel("320101199001010011", "房产");
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.springframework.data.redis.core.ValueOperations;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -79,6 +80,26 @@ class CcdiBaseStaffAssetImportServiceImplTest {
|
||||
assertEquals("320101199001010011", captor.getValue().get(0).getPersonId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void importAssetInfoSync_shouldImportWhenOwnerComesFromCurrentWorkbook() {
|
||||
CcdiBaseStaffAssetInfoExcel excel = buildExcel("320101199001010033", "存款");
|
||||
when(redisTemplate.opsForHash()).thenReturn(hashOperations);
|
||||
when(assetInfoMapper.selectOwnerCandidatesByBaseStaffIdCards(List.of("320101199001010033")))
|
||||
.thenReturn(List.of());
|
||||
|
||||
service.importAssetInfoSync(
|
||||
List.of(excel),
|
||||
"task-current-workbook",
|
||||
"tester",
|
||||
Map.of("320101199001010033", Set.of("320101199001010033"))
|
||||
);
|
||||
|
||||
ArgumentCaptor<List<CcdiAssetInfo>> captor = ArgumentCaptor.forClass(List.class);
|
||||
verify(assetInfoMapper).insertBatch(captor.capture());
|
||||
assertEquals("320101199001010033", captor.getValue().get(0).getFamilyId());
|
||||
assertEquals("320101199001010033", captor.getValue().get(0).getPersonId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void importAssetInfoAsync_shouldFailWhenFamilyCertificateIsUsed() {
|
||||
CcdiBaseStaffAssetInfoExcel excel = buildExcel("320101199201010022", "车辆");
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ruoyi.info.collection.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.info.collection.domain.CcdiStaffEnterpriseRelation;
|
||||
import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffEnterpriseRelationAddDTO;
|
||||
@@ -10,8 +12,10 @@ 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 com.ruoyi.info.collection.service.support.EnterpriseAutoFillService;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -20,13 +24,17 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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.argThat;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -55,8 +63,17 @@ class CcdiStaffEnterpriseRelationServiceImplTest {
|
||||
@Mock
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Mock
|
||||
private EnterpriseAutoFillService enterpriseAutoFillService;
|
||||
|
||||
@AfterEach
|
||||
void clearSecurityContext() {
|
||||
SecurityContextHolder.clearContext();
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertRelation_shouldAllowValidFamily() {
|
||||
mockLoginUser("tester");
|
||||
CcdiStaffEnterpriseRelationAddDTO addDTO = buildAddDto();
|
||||
CcdiStaffFmyRelation familyRelation = new CcdiStaffFmyRelation();
|
||||
familyRelation.setRelationCertNo(addDTO.getPersonId());
|
||||
@@ -75,6 +92,13 @@ class CcdiStaffEnterpriseRelationServiceImplTest {
|
||||
assertEquals(1, captor.getValue().getStatus());
|
||||
assertEquals("MANUAL", captor.getValue().getDataSource());
|
||||
assertEquals(1, captor.getValue().getIsEmpFamily());
|
||||
verify(enterpriseAutoFillService).ensureExists(argThat(item ->
|
||||
"91310000123456789A".equals(item.socialCreditCode())
|
||||
&& "测试企业".equals(item.enterpriseName())
|
||||
&& "EMP_RELATION".equals(item.entSource())
|
||||
&& "MANUAL".equals(item.dataSource())
|
||||
&& "tester".equals(item.userName())
|
||||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -153,4 +177,13 @@ class CcdiStaffEnterpriseRelationServiceImplTest {
|
||||
assistant.setCurrentNamespace(namespace);
|
||||
TableInfoHelper.initTableInfo(assistant, entityClass);
|
||||
}
|
||||
|
||||
private void mockLoginUser(String userName) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserName(userName);
|
||||
LoginUser loginUser = new LoginUser(1L, 1L, user, Set.of());
|
||||
UsernamePasswordAuthenticationToken authentication =
|
||||
new UsernamePasswordAuthenticationToken(loginUser, null, List.of());
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user