修改excel上传问题
This commit is contained in:
@@ -1193,6 +1193,9 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
BeanUtils.copyProperties(it, job);
|
||||
//字典转换
|
||||
String education = DictUtils.getDictValue("education", it.getEducation());
|
||||
if (education == null || education.trim().isEmpty()) {
|
||||
education = StringUtil.getEduCodeByDesc(it.getEducation());
|
||||
}
|
||||
String experience = DictUtils.getDictValue("experience", it.getExperience());
|
||||
String jobType = DictUtils.getDictValue("job_type", it.getJobType());
|
||||
String type = DictUtils.getDictValue("position_type", it.getType());
|
||||
@@ -1259,11 +1262,65 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
continue;
|
||||
}
|
||||
|
||||
JobContact contact = new JobContact();
|
||||
contact.setJobId(matchedJob.getJobId());
|
||||
contact.setContactPerson(vo.getContactPerson());
|
||||
contact.setContactPersonPhone(vo.getContactPersonPhone());
|
||||
contactList.add(contact);
|
||||
List<String> contactNames = StringUtil.splitCellMultiLineData(vo.getContactPerson());
|
||||
List<String> contactPhones = StringUtil.splitContactPhones(vo.getContactPersonPhone());
|
||||
|
||||
if (contactNames.isEmpty() || contactPhones.isEmpty()) {
|
||||
System.out.printf(
|
||||
"警告:岗位【%s】的联系人姓名或手机号为空!姓名:%s,手机号:%s,跳过该组数据%n",
|
||||
matchedJob.getJobTitle(), vo.getContactPerson(), vo.getContactPersonPhone()
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
int nameSize = contactNames.size();
|
||||
int phoneSize = contactPhones.size();
|
||||
int phoneIndex = 0;
|
||||
|
||||
for (int nameIdx = 0; nameIdx < nameSize; nameIdx++) {
|
||||
String currentName = contactNames.get(nameIdx).trim();
|
||||
if (StringUtils.isBlank(currentName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int phonesForCurrentName;
|
||||
if (nameSize == 1) {
|
||||
phonesForCurrentName = phoneSize - phoneIndex;
|
||||
} else {
|
||||
phonesForCurrentName = 1;
|
||||
}
|
||||
|
||||
// 避免索引越界,修正实际可匹配的手机号数量
|
||||
int actualPhoneCount = Math.min(phonesForCurrentName, phoneSize - phoneIndex);
|
||||
if (actualPhoneCount <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// 为当前姓名分配对应的手机号(1个或多个)
|
||||
for (int p = 0; p < actualPhoneCount; p++) {
|
||||
String currentPhone = contactPhones.get(phoneIndex).trim();
|
||||
if (StringUtils.isBlank(currentPhone)) {
|
||||
phoneIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 封装联系人数据
|
||||
JobContact contact = new JobContact();
|
||||
contact.setJobId(matchedJob.getJobId());
|
||||
contact.setContactPerson(currentName);
|
||||
contact.setContactPersonPhone(currentPhone);
|
||||
contactList.add(contact);
|
||||
|
||||
phoneIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
if (phoneIndex < phoneSize) {
|
||||
System.out.printf(
|
||||
"提示:岗位【%s】有 %d 个手机号未分配对应姓名,已忽略%n",
|
||||
matchedJob.getJobTitle(), phoneSize - phoneIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return contactList;
|
||||
|
||||
Reference in New Issue
Block a user