fix: 调整身份证号验证顺序,避免空指针风险
- 将身份证号存在性检查移到基本数据验证之后 - 此时 personId 已确保不为空且格式正确 - 错误信息更准确,包含操作建议
This commit is contained in:
@@ -96,13 +96,6 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
CcdiStaffEnterpriseRelationExcel excel = excelList.get(i);
|
CcdiStaffEnterpriseRelationExcel excel = excelList.get(i);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 身份证号存在性检查
|
|
||||||
if (!existingPersonIds.contains(excel.getPersonId())) {
|
|
||||||
throw new RuntimeException(String.format(
|
|
||||||
"第%d行: 身份证号[%s]不存在于员工信息表中",
|
|
||||||
i + 1, excel.getPersonId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 转换为AddDTO进行验证
|
// 转换为AddDTO进行验证
|
||||||
CcdiStaffEnterpriseRelationAddDTO addDTO = new CcdiStaffEnterpriseRelationAddDTO();
|
CcdiStaffEnterpriseRelationAddDTO addDTO = new CcdiStaffEnterpriseRelationAddDTO();
|
||||||
BeanUtils.copyProperties(excel, addDTO);
|
BeanUtils.copyProperties(excel, addDTO);
|
||||||
@@ -110,6 +103,13 @@ public class CcdiStaffEnterpriseRelationImportServiceImpl implements ICcdiStaffE
|
|||||||
// 验证数据
|
// 验证数据
|
||||||
validateRelationData(addDTO);
|
validateRelationData(addDTO);
|
||||||
|
|
||||||
|
// 身份证号存在性检查(在基本验证之后)
|
||||||
|
if (!existingPersonIds.contains(excel.getPersonId())) {
|
||||||
|
throw new RuntimeException(String.format(
|
||||||
|
"第%d行: 身份证号[%s]不存在于员工信息表中,请先添加员工信息",
|
||||||
|
i + 1, excel.getPersonId()));
|
||||||
|
}
|
||||||
|
|
||||||
String combination = excel.getPersonId() + "|" + excel.getSocialCreditCode();
|
String combination = excel.getPersonId() + "|" + excel.getSocialCreditCode();
|
||||||
|
|
||||||
CcdiStaffEnterpriseRelation relation = new CcdiStaffEnterpriseRelation();
|
CcdiStaffEnterpriseRelation relation = new CcdiStaffEnterpriseRelation();
|
||||||
|
|||||||
Reference in New Issue
Block a user