修改问题岗位-保存联系人
This commit is contained in:
@@ -421,32 +421,75 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
int i=jobMapper.updateById(job);
|
||||
//修改岗位联系人列表
|
||||
if(i>0){
|
||||
LambdaUpdateWrapper<JobContact> updateWrapper = Wrappers.<JobContact>lambdaUpdate()
|
||||
.eq(JobContact::getJobId, job.getJobId())
|
||||
.set(JobContact::getDelFlag, Constants.Del_FLAG_DELETE);
|
||||
|
||||
JobContact emptyEntity = new JobContact();
|
||||
jobContactMapper.update(emptyEntity, updateWrapper);
|
||||
List<JobContact> jobContactList = job.getJobContactList() != null ? job.getJobContactList() : Collections.emptyList();
|
||||
List<JobContact> insertList = jobContactList.stream()
|
||||
.filter(Objects::nonNull).map(x -> {
|
||||
JobContact jobContact = new JobContact();
|
||||
jobContact.setJobId(job.getJobId());
|
||||
return jobContact;
|
||||
}).collect(Collectors.toList());
|
||||
if (!insertList.isEmpty()) {
|
||||
jobContactMapper.batchInsert(insertList);
|
||||
}
|
||||
// 处理联系人
|
||||
handleJobContact(job);
|
||||
//添加附件
|
||||
List<File> filesList = job.getFilesList() != null ? job.getFilesList() : Collections.emptyList();
|
||||
List<Long> longs = filesList.stream().filter(Objects::nonNull).map(File::getBussinessid).collect(Collectors.toList());
|
||||
if(!longs.isEmpty()){
|
||||
fileMapper.updateBussinessids(longs,job.getJobId());
|
||||
}
|
||||
handleJobFile(job);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理联系人
|
||||
* @param job
|
||||
*/
|
||||
private void handleJobContact(Job job) {
|
||||
List<JobContact> jobContactList = Optional.ofNullable(job.getJobContactList()).orElse(Collections.emptyList());
|
||||
if (CollectionUtils.isEmpty(jobContactList)) {
|
||||
return;
|
||||
}
|
||||
List<JobContact> insertList = new ArrayList<>();
|
||||
List<JobContact> updateList = new ArrayList<>();
|
||||
|
||||
for (JobContact originContact : jobContactList) {
|
||||
if (originContact == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JobContact targetContact = new JobContact();
|
||||
targetContact.setJobId(job.getJobId());
|
||||
targetContact.setContactPerson(originContact.getContactPerson());
|
||||
targetContact.setContactPersonPhone(originContact.getContactPersonPhone());
|
||||
targetContact.setPosition(originContact.getPosition());
|
||||
|
||||
if (originContact.getId() == null) {
|
||||
insertList.add(targetContact);
|
||||
} else {
|
||||
targetContact.setId(originContact.getId());
|
||||
updateList.add(targetContact);
|
||||
}
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(insertList)) {
|
||||
jobContactMapper.batchInsert(insertList);
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(updateList)) {
|
||||
updateList.forEach(contact -> {
|
||||
LambdaUpdateWrapper<JobContact> updateWrapper = Wrappers.<JobContact>lambdaUpdate()
|
||||
.eq(JobContact::getId, contact.getId());
|
||||
jobContactMapper.update(contact, updateWrapper);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理附件
|
||||
* @param job
|
||||
*/
|
||||
private void handleJobFile(Job job) {
|
||||
List<File> filesList = Optional.ofNullable(job.getFilesList()).orElse(Collections.emptyList());
|
||||
List<Long> fileIds = filesList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(File::getBussinessid)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(fileIds)) {
|
||||
fileMapper.updateBussinessids(fileIds, job.getJobId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除岗位
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user