| 
					
				 | 
			
			
				@ -6,7 +6,10 @@ import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.patient.Patient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.DoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.BaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.tuple.ImmutablePair; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.tuple.Pair; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Page; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -26,12 +29,18 @@ import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Component 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class AdminTeamService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    DoctorDao doctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    DoctorAdminTeamDao teamDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    DoctorAdminTeamMemberDao memberDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    DoctorTeamMemberDao signingTeamMemberDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取团队数量。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -150,18 +159,40 @@ public class AdminTeamService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 移除成员。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * <p> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 如果成员已经有跟团队内的某医生合作与患者签约,那么不能移除,必须等签约患者交接后才可以。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 移除成员逻辑: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 1、判断团队内是否有三师签约关系,如果有不能删除。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 2、若没有三师签约关系,判断是否为专科医生,如果是,直接删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 3、若不是,则判断健康管理师或全科医生是否有签约人,有的话提示先转移居民。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param teamId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctorCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Pair<Integer, String> removeMember(long teamId, String doctorCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(signingTeamMemberDao.isSanShiSigning(doctorCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return new ImmutablePair<>(403, "三师签约医生,不能删除"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Doctor doctor = doctorDao.findByCode(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!doctor.isProfessionalDoctor()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (doctor.isGeneralDoctor()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Doctor> doctorList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doctorList.add(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer count = getMemberSigningCount(teamId, doctorList).get(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (count != null || count > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (doctor.isGeneralDoctor()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return new ImmutablePair<>(403, "全科医生有签约关系,不可删除"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (doctor.isHealthDoctor()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return new ImmutablePair<>(403, "健康管理师仍有签约居民,请先转移签约居民"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        AdminTeamMember member = memberDao.findByTeamIdAndDoctorCodeOrderByDoctorCodeAsc(teamId, doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (member != null) memberDao.delete(member); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return new ImmutablePair<>(200, "OK"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Doctor> getMembers(long teamId) { 
			 |