Prechádzať zdrojové kódy

Merge branch 'srdev' of chenweida/patient-co-management into srdev

chenweida 7 rokov pred
rodič
commit
d62994d094

+ 8 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorDao.java

@ -13,6 +13,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -22,6 +23,8 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.patient.Patient;
import javax.persistence.LockModeType;
public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, JpaSpecificationExecutor<Doctor> {
    Doctor findByName(String name);
@ -166,4 +169,9 @@ public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, Jpa
//    @Query("select a from RoleWithAuthorityCheck a , WlyyUserRole b where a.userRoleId = b.id and  b.user=?1 and b.role=?2 ")
    @Query(value = "select a.* from wlyy_edu_role_authority a,wlyy_user_role b where a.user_role_id=b.id and b.user=?1 and b.role=?2 " ,nativeQuery = true)
    List<RoleWithAuthorityCheck> findEduAuthority(String userCode,String operatorRoleCode);
    @Lock(value = LockModeType.PESSIMISTIC_WRITE )
    @Query("select p from Doctor p where p.code = ?1")
    Doctor findByCodeWithLock(String doctorCode);
}

+ 11 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/concern/ConcernService.java

@ -50,7 +50,7 @@ public class ConcernService extends BaseService {
    public boolean addConcern(
            String patientCode, String doctorCode, Integer concernSource) {
        Patient patient = patientDao.findByCode(patientCode);
        Doctor doctor = doctorDao.findByCode(doctorCode);
        Doctor doctor = doctorDao.findByCodeWithLock(doctorCode);
        //新增关注
        ConcernDO concern = new ConcernDO();
@ -90,6 +90,10 @@ public class ConcernService extends BaseService {
        concern.setStatus(1);
        concern.setConcernSource(concernSource);
        concernDao.save(concern);
        //更新医生关注人数+1
        Integer num=doctor.getConcernNum();
        doctor.setConcernNum(num+1);
        return true;
    }
@ -102,12 +106,15 @@ public class ConcernService extends BaseService {
    @Transactional
    public boolean deleteConcern(String concernCode) {
        ConcernDO concern = concernDao.findByCode(concernCode);
        Doctor doctor = doctorDao.findByCodeWithLock(concern.getConcernDoctorCode());
        //删除关注
        concern.setStatus(-1);
        //删除团队
        doctorTeamDao.deleteTeam(concern.getTeamCode());
        //删除团队成员
        doctorTeamDoctorDao.deleteMember(concern.getTeamCode());
        //更新医生关注人数-1
        doctor.setConcernNum(doctor.getConcernNum()-1);
        return true;
    }
@ -121,12 +128,15 @@ public class ConcernService extends BaseService {
    @Transactional
    public void deleteConcern(String patientCode, String doctorCode) {
        ConcernDO concern = concernDao.findByPatientAndDoctor(patientCode, doctorCode);
        Doctor doctor = doctorDao.findByCodeWithLock(doctorCode);
        //删除关注
        concern.setStatus(-1);
        //删除团队
        doctorTeamDao.deleteTeam(concern.getTeamCode());
        //删除团队成员
        doctorTeamDoctorDao.deleteMember(concern.getTeamCode());
        //更新医生关注人数-1
        doctor.setConcernNum(doctor.getConcernNum()-1);
    }