|
|
|
@ -1,17 +1,24 @@ |
|
|
|
package com.hxhq.business.service.impl; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hxhq.business.domain.Study; |
|
|
|
import com.hxhq.business.domain.StudySubject; |
|
|
|
import com.hxhq.business.enums.zykgl.JcgjlxEnum; |
|
|
|
import com.hxhq.business.enums.zykgl.JcmcysEnum; |
|
|
|
import com.hxhq.business.form.study.StudySubjectUserSaveForm; |
|
|
|
import com.hxhq.business.service.IStudyJcgjService; |
|
|
|
import com.hxhq.business.service.IStudyService; |
|
|
|
import com.hxhq.business.service.IStudySubjectService; |
|
|
|
import com.hxhq.business.utils.JctUtil; |
|
|
|
import com.hxhq.common.core.exception.ServiceException; |
|
|
|
import com.hxhq.common.security.utils.SecurityUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.hxhq.business.mapper.StudySubjectUserMapper; |
|
|
|
@ -31,6 +38,10 @@ public class StudySubjectUserServiceImpl extends ServiceImpl |
|
|
|
{ |
|
|
|
@Autowired |
|
|
|
private IStudySubjectService studySubjectService; |
|
|
|
@Autowired |
|
|
|
private IStudyService studyService; |
|
|
|
@Autowired |
|
|
|
private IStudyJcgjService studyJcgjService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<StudySubjectUser> getListByStudySubjectId(Long studySubjectId) { |
|
|
|
@ -46,6 +57,7 @@ public class StudySubjectUserServiceImpl extends ServiceImpl |
|
|
|
if(studySubject==null){ |
|
|
|
throw new ServiceException("试验学科不存在"); |
|
|
|
} |
|
|
|
studyService.checkPassword(form.getSign()); |
|
|
|
//传入的成员信息 |
|
|
|
List<StudySubjectUser> itemList = form.getSubjectUserList(); |
|
|
|
//已经设置的学科信息 |
|
|
|
@ -54,20 +66,31 @@ public class StudySubjectUserServiceImpl extends ServiceImpl |
|
|
|
List<StudySubjectUser> addList = new ArrayList<>(); |
|
|
|
List<StudySubjectUser> modifyList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<String> addNameList = new ArrayList<>(); |
|
|
|
List<String> deleteNameList = new ArrayList<>(); |
|
|
|
|
|
|
|
for(StudySubjectUser item : itemList){ |
|
|
|
List<StudySubjectUser> existsList = oldList.stream().filter(o->o.getUserId().equals(item.getUserId())).collect(Collectors.toList()); |
|
|
|
if(existsList.size()==0){ |
|
|
|
item.setStudySubjectId(form.getStudySubjectId()); |
|
|
|
addList.add(item); |
|
|
|
|
|
|
|
addNameList.add(item.getUserName()); |
|
|
|
}else{ |
|
|
|
item.setId(existsList.get(0).getId()); |
|
|
|
modifyList.add(item); |
|
|
|
|
|
|
|
if(!existsList.get(0).getUserName().equals(item.getUserName())){ |
|
|
|
addNameList.add(item.getUserName()); |
|
|
|
deleteNameList.add(existsList.get(0).getUserName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for(StudySubjectUser old : oldList){ |
|
|
|
if(itemList.stream().filter(o->o.getUserId().equals(old.getUserId())).collect(Collectors.toList()).size()==0){ |
|
|
|
deleteList.add(old); |
|
|
|
deleteNameList.add(old.getUserName()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(addList.size()>0){ |
|
|
|
@ -79,6 +102,17 @@ public class StudySubjectUserServiceImpl extends ServiceImpl |
|
|
|
if(deleteList.size()>0){ |
|
|
|
removeBatchByIds(deleteList); |
|
|
|
} |
|
|
|
|
|
|
|
if(deleteNameList.size()>0 || addNameList.size()>0){ |
|
|
|
Map<String, String> formData = new LinkedHashMap<>(); |
|
|
|
if(addNameList.size()>0){ |
|
|
|
formData.put("新增人员", String.join(",",addNameList)); |
|
|
|
} |
|
|
|
if(deleteNameList.size()>0){ |
|
|
|
formData.put("删除人员", String.join(",",deleteNameList)); |
|
|
|
} |
|
|
|
studyJcgjService.saveInfo(studySubject.getStudyId(), JcgjlxEnum.ry, JcmcysEnum.blue,"人员变更", JctUtil.formatStr(formData), SecurityUtils.getUserId(),SecurityUtils.getNickName(),form.getSign().getRemark()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|