瀏覽代碼

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

zdm 5 年之前
父節點
當前提交
26c64d66cb
共有 18 個文件被更改,包括 766 次插入45 次删除
  1. 21 0
      business/base-service/src/main/java/com/yihu/jw/hospital/doctor/dao/WlyyDoctorOnlineTimeDao.java
  2. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java
  3. 123 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  4. 4 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  5. 1 1
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  6. 88 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/WlyyDoctorOnlineTimeDO.java
  7. 60 0
      common/common-entity/src/main/java/com/yihu/jw/entity/wlyyinfo/OauthWlyyConfigDO.java
  8. 20 34
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  9. 4 0
      gateway/ag-basic/pom.xml
  10. 11 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/OauthWlyyConfigDao.java
  11. 26 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorDao.java
  12. 29 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorHospitalDao.java
  13. 30 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorRoleDao.java
  14. 56 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java
  15. 87 3
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  16. 162 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWlyyConfigService.java
  17. 8 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  18. 35 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

+ 21 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/doctor/dao/WlyyDoctorOnlineTimeDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.hospital.doctor.dao;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorOnlineTimeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
 * Created by Trick on 2019/7/31.
 */
public interface WlyyDoctorOnlineTimeDao extends PagingAndSortingRepository<WlyyDoctorOnlineTimeDO, String>, JpaSpecificationExecutor<WlyyDoctorOnlineTimeDO> {
    @Query("from WlyyDoctorOnlineTimeDO a where a.doctor = ?1 and (a.startTime <= ?2 AND a.endTime <= ?2 )OR (a.startTime <= ?3 AND a.endTime <= ?3)")
    List<WlyyDoctorOnlineTimeDO> findWorkExistList(String doctor, Date startDate,Date endDate);
    @Query("from WlyyDoctorOnlineTimeDO a where a.doctor = ?1 and a.startTime >= ?2 AND a.startTime <= ?3 order By a.startTime ASC)")
    List<WlyyDoctorOnlineTimeDO> findWorkList(String doctor, Date startDate,Date endDate);
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java

@ -93,7 +93,7 @@ public class PatientMappingService {
            return mappingCode;
        }else{
            throw new RuntimeException("获取his居民信息失败!");
            return null;
        }
    }
}

+ 123 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -15,6 +15,7 @@ import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorOnlineTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
@ -26,6 +27,7 @@ import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.doctor.dao.DoctorWorkTimeDao;
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.doctor.dao.WlyyDoctorOnlineTimeDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
@ -40,6 +42,7 @@ import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
import com.yihu.jw.restmodel.hospital.doctor.WlyyDoctorWorkTimeVO;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
@ -130,6 +133,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private PrescriptionExpressageService sfexpressService;
    @Autowired
    private WlyyDoctorOnlineTimeDao wlyyDoctorOnlineTimeDao;
    
@ -148,6 +153,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public  List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag)throws Exception{
        logger.info("findOutpatientList patient:"+patient);
        String patNo =patientMappingService.findHisPatNoByPatient(patient);
        if(StringUtils.isBlank(patNo)){
            return null;
        }
        logger.info("findOutpatientList patNo "+patNo);
        return entranceService.BS30025(patNo,null,startTime,endTime,demoFlag);
    }
@ -161,6 +169,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public WlyyOutpatientVO findOutpatientInfo(String patient,String conNo)throws Exception{
        logger.info("findOutpatientList patient:"+patient);
        String patNo =patientMappingService.findHisPatNoByPatient(patient);
        if(StringUtils.isBlank(patNo)){
            return null;
        }
        logger.info("findOutpatientList patNo:"+patNo);
        List<WlyyOutpatientVO> list = entranceService.BS30025(patNo,conNo,null,null,demoFlag);
@ -179,7 +190,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     */
    public List<WlyyPrescriptionVO> findOriginPrescriptionList(String registerSn,String patient,String admNo,boolean demoFlag)throws Exception{
        String patNo =patientMappingService.findHisPatNoByPatient(patient);
        if(StringUtils.isBlank(patNo)){
            return null;
        }
        //BS16017(String REGISTER_SN,String realOrder,String PAT_NO,String ADM_NO,boolean demoFlag) throws Exception {
        logger.info("findOriginPrescriptionList: registerSn:"+registerSn+" patient"+patient+" patNo:"+patNo+" admNo:"+admNo);
        return entranceService.BS16017(registerSn,null,patNo,admNo,demoFlag);
    }
@ -528,6 +543,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        outpatientDO.setStatus("0");
        outpatientDO.setCreateTime(new Date());
        outpatientDO.setIdcard(patientDO.getIdcard());
        outpatientDO.setOutpatientType("1");
        outpatientDO.setCreateTime(new Date());
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
@ -559,6 +575,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return outpatient;
    }
    /**
     * 创建候诊室
     * @param outpatientDO
@ -573,11 +590,19 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        waitingRoom.setHospital(outpatientDO.getHospital());
        waitingRoom.setHospitalName(outpatientDO.getHospitalName());
        //是否是有协同门诊医生
        if(StringUtils.isNotBlank(outpatientDO.getDoctor())){
            waitingRoom.setGeneralDoctor(outpatientDO.getGeneralDoctor());
            waitingRoom.setGeneralDoctorName(outpatientDO.getGeneralDoctorName());
        }
        waitingRoom.setPatientId(outpatientDO.getPatient());
        waitingRoom.setPatientName(outpatientDO.getPatientName());
        waitingRoom.setReservationTime(outpatientDO.getRegisterDate());
        waitingRoom.setVisitStatus(0);
        waitingRoom.setReservationType(1);
        //设置复诊类型
        waitingRoom.setReservationType(StringUtils.isNotBlank(outpatientDO.getOutpatientType())?Integer.parseInt(outpatientDO.getOutpatientType()):1);
        waitingRoom.setSort(0);
        waitingRoom.setConsultType(Integer.parseInt(outpatientDO.getType()));
        if(StringUtils.isNotBlank(outpatientDO.getDoctor())){
@ -1889,6 +1914,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS time," +
                "outpatient.disease_img AS disease_img," +
                "outpatient.description AS description," +
                "room.reservation_type AS reservation_type," +
                "outpatient.origin_con_no AS origin_con_no " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
@ -2158,7 +2184,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public List<Map<String,Object>> findDoctorByHospitalAndDiseaseAndDept(String orgCode, String dept,
                                                                          String diseaseKey, String doctorNameKey,
                                                                          String jobTitleNameKey, String outpatientType,
                                                                          String keyName, String workingTime, String consutlSort) {
                                                                          String keyName, String workingTime, String consultStatus,String consutlSort,Integer page,Integer pagesize) {
    
        if(page >=1){
            page --;
        }
    
        if (pagesize <= 0) {
            pagesize = 10;
        }
    
        String sql ="SELECT " +
                " d.id, " +
@ -2209,7 +2243,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            sql+=" AND wk.date = '"+workingTime+"' ";
        }
    
        sql += " order by a.total "+ consutlSort;
    
        if(StringUtils.isNotBlank(consultStatus)){
            sql+=" AND d.consult_status = '"+consultStatus+"' ";
        }
    
        sql += " order by a.total "+ consutlSort +" limit "+page * pagesize +","+pagesize;
        
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
    
@ -2548,7 +2587,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "room.reservation_type AS reservation_type," +
                "outpatient.disease_img AS disease_img," +
                "outpatient.description AS description," +
                "outpatient.origin_con_no AS origin_con_no " +
                "outpatient.origin_con_no AS origin_con_no, " +
                "room.reservation_type AS reservation_type " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
@ -2753,4 +2793,83 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    
        return waitVideoCount;
    }
    /**
     * 保存在线排班
     * @param onlineWorkJson
     * @return
     * @throws Exception
     */
    public Envelop saveDoctorOnlineWork(String onlineWorkJson)throws Exception{
        WlyyDoctorOnlineTimeDO timeDO = objectMapper.readValue(onlineWorkJson,WlyyDoctorOnlineTimeDO.class);
        List<WlyyDoctorOnlineTimeDO> list = wlyyDoctorOnlineTimeDao.findWorkExistList(timeDO.getDoctor(),timeDO.getStartTime(),timeDO.getEndTime());
        if(list!=null&&list.size()>0){
            return Envelop.getError("排班已存在",-1);
        }
        timeDO.setCreateTime(new Date());
        return Envelop.getSuccess("保存成功");
    }
    /**
     * 删除在线排班
     * @param id
     * @return
     * @throws Exception
     */
    public Envelop delDoctorOnlineWork(String id)throws Exception{
        wlyyDoctorOnlineTimeDao.delete(id);
        return Envelop.getSuccess("删除成功");
    }
    /**
     * 查询医生在线排班
     * @param doctor
     * @param startDate
     * @param endDate
     * @return
     */
    public List<WlyyDoctorOnlineTimeDO> findDoctorOnlineWorkList(String doctor,String startDate,String endDate){
        return wlyyDoctorOnlineTimeDao.findWorkList(doctor,DateUtil.stringToDate(startDate+" 00:00:00","yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate+" 23:59:59","yyyy-MM-dd HH:mm:ss"));
    }
    /**
     * 发起图文和视频复诊
     * @param outpatientJson
     * @return
     * @throws Exception
     */
    public WlyyOutpatientDO cooperativeOutpatient(String outpatientJson,String registerJson)throws Exception{
        //1.保存就诊实体
        WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson,WlyyOutpatientDO.class);
        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
        outpatientDO.setMjz("mz");
        outpatientDO.setStatus("0");
        outpatientDO.setCreateTime(new Date());
        outpatientDO.setIdcard(patientDO.getIdcard());
        outpatientDO.setOutpatientType("2");
        outpatientDO.setCreateTime(new Date());
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
        WlyyPatientRegisterTimeDO registerTimeDO = null;
        try {
            //如果是视频预约咨询
            if(StringUtils.isNotBlank(registerJson)){
                registerTimeDO = objectMapper.readValue(registerJson,WlyyPatientRegisterTimeDO.class);
                registerTimeDO.setOutpatientId(outpatient.getId());
                registerTimeDO.setCreateTime(new Date());
                patientRegisterTimeDao.save(registerTimeDO);
            }
        }catch (Exception e){
            throw new RuntimeException("号源已经被预约,请选择其他号源");
        }
        //3.创建候诊室
        createRoom(outpatient);
        return outpatient;
    }
}

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -348,6 +348,8 @@ public class EntranceService {
    public List<WlyyPrescriptionVO>  BS16017(String REGISTER_SN,String realOrder,String PAT_NO,String ADM_NO,boolean demoFlag) throws Exception {
        String fid=BS16017;
        String resp = "";
        logger.info("BS16017: REGISTER_SN:"+REGISTER_SN+" realOrder"+realOrder+" PAT_NO:"+PAT_NO+" ADM_NO:"+ADM_NO);
        if (demoFlag) {
            resp = getJosnFileResullt(fid);
        } else {
@ -373,6 +375,8 @@ public class EntranceService {
            //查询信息结束
            sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            logger.info("resp "+resp);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
        }
        return convertWlyyPrescriptionVOInBodyRow(resp);

+ 1 - 1
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -193,7 +193,7 @@ public class ImService {
		if (!StringUtils.isEmpty(id)) {
			sql += " and a.id = '" + id + "'";
		}
		sql += " ORDER BY a.czrq desc limit "+page+","+pagesize+"";
		sql += " ORDER BY a.czrq desc limit "+page * pagesize+","+pagesize+"";
		
		result = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ConsultVO.class));
		

+ 88 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/WlyyDoctorOnlineTimeDO.java

@ -0,0 +1,88 @@
package com.yihu.jw.entity.hospital.doctor;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2019/7/31.
 */
@Entity
@Table(name = "wlyy_doctor_online_time")
public class WlyyDoctorOnlineTimeDO extends UuidIdentityEntity {
    private String doctor;//医生ID',
    private String doctorName;//医生姓名',
    private Date startTime;//开始时间',
    private Date endTime;//结束时间',
    private String type;//1 上午,2.中午,3.下午,4.晚上',
    private String date;//日期',
    private String remark;//备注',
    private Date createTime;//创建时间',
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 60 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/wlyyinfo/OauthWlyyConfigDO.java

@ -0,0 +1,60 @@
package com.yihu.jw.entity.wlyyinfo;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Trick on 2019/8/7.
 */
@Entity
@Table(name = "oauth_wlyy_config")
public class OauthWlyyConfigDO extends UuidIdentityEntity {
    private String appId;//appid',
    private String appSecret;//app秘钥',
    private String tokenUrl;//获取token接口地址',
    private String url;//获取基本信息接口地址',
    private String remark;//备注接口地址',
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getAppSecret() {
        return appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
    public String getTokenUrl() {
        return tokenUrl;
    }
    public void setTokenUrl(String tokenUrl) {
        this.tokenUrl = tokenUrl;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 20 - 34
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -200,7 +200,26 @@ public class BaseHospitalRequestMapping {
        /**
         * 获取居民基础信息
         */
        public static final String findPatientInfo ="/findPatientInfo";
        public static final String findPatientInfo = "/findPatientInfo";
        /**
         * 保存医生在线排班
         */
        public static final String saveDoctorOnlineWork = "/saveDoctorOnlineWork";
        /**
         * 删除医生在线排班
         */
        public static final String delDoctorOnlineWork = "/delDoctorOnlineWork";
        /**
         *查询医生在线排班列表
         */
        public static final String findDoctorOnlineWorkList = "/findDoctorOnlineWorkList";
        /**
         * 发起协同门诊
         */
        public static final String cooperativeOutpatient = "/cooperativeOutpatient";
        //=================end=======================================
@ -226,44 +245,11 @@ public class BaseHospitalRequestMapping {
         */
        public static final String checkPrescription = "/checkPrescription";
        /**
         * 获取医生及号员信息
         */
        public static final String findDoctorList = "/findDoctorList";
        /**
         * 进入候诊室
         */
        public static final String enterWaitingRoom = "/enterWaitingRoom";
        /**
         * 进入诊疗室
         */
        public static final String enterConsultingRoom = "/enterConsultingRoom";
        /**
         * 居民取消续方
         */
        public static final String cancelPrescription ="/cancelPrescription";
        /**
         * 支付续方
         */
        public static final String payOrder = "/payOrder";
        /**
         * 转物流
         */
        public static final String switchExpress ="/switchExpress";
        /**
         * 评价医生
         */
        public static final String evaluateDoctor = "/evaluateDoctor";
        //确认收货
        public static final String confirmReceipt ="/confirmReceipt";
        //医生下诊断
        public static final String diagnose ="/diagnose";
    }

+ 4 - 0
gateway/ag-basic/pom.xml

@ -57,6 +57,10 @@
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.retry</groupId>
            <artifactId>spring-retry</artifactId>
        </dependency>
        <!--<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>

+ 11 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/OauthWlyyConfigDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.security.dao;
import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2019/8/7.
 */
public interface OauthWlyyConfigDao extends PagingAndSortingRepository<OauthWlyyConfigDO, String>, JpaSpecificationExecutor<OauthWlyyConfigDO> {
}

+ 26 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorDao.java

@ -0,0 +1,26 @@
package com.yihu.jw.security.dao.doctor;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 *
 * 医生基础信息 数据库访问层
 *
 * @version
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO, String>, JpaSpecificationExecutor<BaseDoctorDO>  {
    BaseDoctorDO findById(String id);
    BaseDoctorDO findByIdcard(String idcard);
}

+ 29 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorHospitalDao.java

@ -0,0 +1,29 @@
package com.yihu.jw.security.dao.doctor;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface BaseDoctorHospitalDao extends PagingAndSortingRepository<BaseDoctorHospitalDO, Integer>, JpaSpecificationExecutor<BaseDoctorHospitalDO> {
    List<BaseDoctorHospitalDO> findByOrgCodeAndDoctorCode(String orgCode, String doctorCode);
    @Query("select id from BaseDoctorHospitalDO where doctorCode = ?1")
    Set<Object> findIdListByOrgCodeAndDoctorCode(String doctorCode);
    @Query(value = "select org_code as orgCode,org_name as orgName,doctor_duty_code as doctorDutyCode ,doctor_duty_name as doctorDutyName from base_doctor_hospital where doctor_code = ?1 GROUP BY orgCode ORDER BY orgName DESC",nativeQuery = true)
    List<Map<String,Object>> getOrgAndDutyByDoctorCode(String doctorCode);
    List<BaseDoctorHospitalDO> findByDoctorCode(String doctorCode);
    List<BaseDoctorHospitalDO> findByOrgCodeAndDeptCode(String orgCode, String deptCode);
    @Query("select bdo from BaseDoctorHospitalDO bdo where bdo.orgCode=?1 and bdo.deptCode=?2 and bdo.doctorCode = ?3 and bdo.del=1")
    List<BaseDoctorHospitalDO> findByOrgCodeAndDeptCodeAndDoctorCode(String orgCode, String deptCode, String doctorCode);
}

+ 30 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorRoleDao.java

@ -0,0 +1,30 @@
package com.yihu.jw.security.dao.doctor;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.Set;
/**
 * 
 * 医生与业务模块角色关联信息 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年10月25日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorRoleDao extends PagingAndSortingRepository<BaseDoctorRoleDO, Integer>, JpaSpecificationExecutor<BaseDoctorRoleDO>  {
    @Query("select id from BaseDoctorRoleDO where doctorCode = ?1")
    Set<Object> findIdListByDoctorCode(String doctorCode);
    List<BaseDoctorRoleDO> findByDoctorCode(String doctorCode);
}

+ 56 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -88,6 +88,14 @@ public class WlyyTokenGranter implements TokenGranter {
                        requestFactory,
                        userDetailsService
                ));
        tokenGranters.put(IhealthDoctorOwnerCodeTokenGranter.GRANT_TYPE,
                new IhealthDoctorOwnerCodeTokenGranter(
                        authenticationManager,
                        tokenServices,
                        clientDetailsService,
                        requestFactory,
                        userDetailsService
                ));
    }
    public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
@ -388,6 +396,54 @@ public class WlyyTokenGranter implements TokenGranter {
            if (!userDetails.isAccountNonLocked()) {
                throw new InvalidGrantException("User account is locked");
            }
//            parameters.put("password",userDetails.getPassword());
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }
    }
    public static class IhealthDoctorOwnerCodeTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "ihealthDcotor";
        private final AuthenticationManager authenticationManager;
        private final UserDetailsService userDetailsService;
        private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
        public IhealthDoctorOwnerCodeTokenGranter(AuthenticationManager authenticationManager,
                                            AuthorizationServerTokenServices tokenServices,
                                            ClientDetailsService clientDetailsService,
                                            OAuth2RequestFactory requestFactory,
                                            UserDetailsService userDetailsService) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, userDetailsService, GRANT_TYPE);
        }
        protected IhealthDoctorOwnerCodeTokenGranter(AuthenticationManager authenticationManager,
                                               AuthorizationServerTokenServices tokenServices,
                                               ClientDetailsService clientDetailsService,
                                               OAuth2RequestFactory requestFactory,
                                               UserDetailsService userDetailsService,
                                               String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authenticationManager = authenticationManager;
            this.userDetailsService = userDetailsService;
        }
        @Override
        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
            String username = parameters.get("username");
            SaltUser userDetails = (SaltUser)userDetailsService.loadUserByUsername(username);
            if (!userDetails.isEnabled()) {
                throw new InvalidGrantException("User is disabled");
            }
            if (!userDetails.isAccountNonLocked()) {
                throw new InvalidGrantException("User account is locked");
            }
//            parameters.put("password",userDetails.getPassword());
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);

+ 87 - 3
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -6,6 +6,7 @@ import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.restmodel.ResultStatus;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.dao.OauthKeypairDao;
@ -14,6 +15,7 @@ import com.yihu.jw.security.model.*;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.service.OauthWlyyConfigService;
import com.yihu.jw.security.service.OauthYlzConfigService;
import com.yihu.jw.security.utils.SerializeUtil;
import com.yihu.utils.security.RSAUtils;
@ -69,7 +71,7 @@ import com.alibaba.fastjson.JSON;
 * </p>
 *
 * @author Progr1mmer
 * @created on 2018/8/29.
 * @created on 2018/8/29
 */
@RestController
public class WlyyLoginEndpoint extends AbstractEndpoint {
@ -103,6 +105,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private OauthKeypairDao oauthKeypairDao;
    @Autowired
    private OauthYlzConfigService oauthYlzConfigService;
    @Autowired
    private OauthWlyyConfigService oauthWlyyConfigService;
    @PostConstruct
    private void init() {
@ -630,7 +634,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    @RequestMapping(value = "/oauth/getHwlyyDecrypt", method = RequestMethod.POST)
    public ObjEnvelop getHwlyyDecrypt(String openid,String idcard,String wechatId){
    public ObjEnvelop getHwlyyDecrypt(String openid,String idcard,String wechatId,String code){
        Map<String,Object> rs = new HashedMap();
        try{
            OauthKeypairDO keypairDO = oauthKeypairDao.findByCode("hwlyyKey");
@ -641,6 +645,14 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            }else {
                rs.put("idcard",idcard);
            }
            //解析code
            if(org.apache.commons.lang3.StringUtils.isNotBlank(code)){
                rs.put("code",com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair));
            }else {
                rs.put("code",code);
            }
            //解密wechatId
            if(org.apache.commons.lang3.StringUtils.isNotBlank(wechatId)){
                String wxid =com.yihu.jw.security.utils.RSAUtils.decryptBase64(wechatId, keyPair);
@ -725,7 +737,79 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        baseLoginLogService.save(baseLoginLogDO);
        map.put("WlyyUserSimple",wlyyUserSimple);
        map.remove("patient");
        return ObjEnvelop.getSuccess("error",map);
        return ObjEnvelop.getSuccess("success",map);
    }
    /**
     * I健康医生端授权登录
     * @param code 医生code
     * @param client_id
     * @param login_type 3
     * @param httpSession
     * @return
     */
    @RequestMapping(value = "/oauth/checkWlyyLogin", method = RequestMethod.POST)
    public ObjEnvelop checkQRCodeLogin(String code,String client_id,String login_type,HttpSession httpSession){
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
        }
        if (StringUtils.isEmpty(code)) {
            throw new InvalidRequestException("doctor is null");
        }
        KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
        String doctorCode = com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair);
        JSONObject map = null;
        try{
            map= oauthWlyyConfigService.checkWlyyDoctor(doctorCode);
        }catch (Exception e){
            logger.error(e);
            return ObjEnvelop.getError("授权失败");
        }
        String authCode = map.getString("authCode");
        if(!"1".equals(authCode)){
            map.remove("doctor");
            return ObjEnvelop.getError("授权失败");
        }
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        JSONObject doctor = map.getJSONObject("doctor");
        Map<String, String> parameters = new HashedMap();
        parameters.put("login_type","2");
        parameters.put("username",doctor.getString("idcard"));
        parameters.put("grant_type", "ihealthDcotor");
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        if (authenticatedClient != null) {
            oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        }
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());
        wlyyUserSimple.setExpiresIn(token.getExpiresIn());
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        String loginType = parameters.get("login_type");
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
        baseLoginLogDO.setUserId(wlyyUserSimple.getId());
        baseLoginLogDO.setCreateTime(new Date());
        String userAgent = JSONObject.toJSONString(wlyyUserSimple);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogService.save(baseLoginLogDO);
        map.put("WlyyUserSimple",wlyyUserSimple);
        map.remove("doctor");
        return ObjEnvelop.getSuccess("success",map);
    }
}

+ 162 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWlyyConfigService.java

@ -0,0 +1,162 @@
package com.yihu.jw.security.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
import com.yihu.jw.security.dao.OauthWlyyConfigDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorHospitalDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorRoleDao;
import com.yihu.jw.security.utils.HttpClientUtil;
import com.yihu.utils.security.MD5;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
 * Created by Trick on 2019/8/6
 */
@Service
@Transactional
public class OauthWlyyConfigService {
    private static final Logger logger = LoggerFactory.getLogger(OauthWlyyConfigService.class);
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private OauthWlyyConfigDao oauthWlyyConfigDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private BaseDoctorRoleDao baseDoctorRoleDao;
    public JSONObject checkWlyyDoctor(String code)throws Exception{
        OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("wlyyConfig");
        //token获取accesstoken
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("appid", oauthWlyyConfigDO.getAppId()));
        params.add(new BasicNameValuePair("appSecret", oauthWlyyConfigDO.getAppSecret()));
        String res = httpClientUtil.post(oauthWlyyConfigDO.getTokenUrl(),params,"UTF-8");
        String token = null;
        JSONObject rsjson = JSONObject.parseObject(res);
        logger.info("checkWlyyDoctor token :"+rsjson.toString());
        Integer status = rsjson.getInteger("status");
        if(status==10000){
            //设置入参
            List<NameValuePair> p = new ArrayList<>();
            p.add(new BasicNameValuePair("doctor", code));
            //设置头部
            token = rsjson.getJSONObject("result").getString("accesstoken");
            Map<String,Object> headerMap = new HashedMap();
            headerMap.put("accesstoken",token);
            String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
            JSONObject auth = JSONObject.parseObject(rs);
            Integer s = auth.getInteger("status");
            logger.info("checkWlyyDoctor doctorInfo :"+s.toString());
            if(s == 200){
                JSONObject data = auth.getJSONObject("data");
                String authCode =  data.getString("authCode");
                if("1".equals(authCode)){
                    JSONObject doctorJson = data.getJSONObject("doctor");
                    String idcard = doctorJson.getString("idcard");
                    if(StringUtils.isBlank(idcard)){
                        data.put("authCode","-3");
                        data.put("mes","I健康账户信息不完整,授权失败");
                        return data;
                    }
                    BaseDoctorDO doctorDO = baseDoctorDao.findByIdcard(idcard);
                    if(doctorDO!=null){
                        return data;
                    }else{
                        //存储医生全科医生信息
                        BaseDoctorDO doctor = new BaseDoctorDO();
                        doctor.setId(doctorJson.getString("code"));
                        doctor.setName(doctorJson.getString("name"));
                        doctor.setIdcard(doctorJson.getString("idcard"));
                        doctor.setMobile(doctorJson.getString("mobile"));
                        doctor.setSex(doctorJson.getInteger("sex"));
                        doctor.setBirthday(doctorJson.getDate("birthday"));
                        doctor.setProvinceCode(doctorJson.getString("province"));
                        doctor.setProvinceName(doctorJson.getString("provinceName"));
                        doctor.setCityCode(doctorJson.getString("city"));
                        doctor.setCityName(doctorJson.getString("cityName"));
                        //认证信息设置
                        String salt = randomString(5);
                        String pw = idcard.substring(idcard.length()-6);
                        doctor.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                        doctor.setDel("1");
                        doctor.setEnabled(1);
                        doctor.setLocked(0);
                        doctor.setCreateTime(new Date());
                        baseDoctorDao.save(doctor);
                        //机构信息
                        BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
                        hospitalDO.setDoctorCode(doctorJson.getString("code"));
                        hospitalDO.setOrgCode(doctorJson.getString("hospital"));
                        hospitalDO.setOrgName(doctorJson.getString("hospitalName"));
                        hospitalDO.setDel("1");
                        baseDoctorHospitalDao.save(hospitalDO);
                        BaseDoctorRoleDO role = new BaseDoctorRoleDO();
                        role.setDoctorCode(doctorJson.getString("code"));
                        role.setRoleCode("generalDoctor");
                        baseDoctorRoleDao.save(role);
                        return data;
                    }
                }else{
                    return data;
                }
            }else{
                //请求异常
                JSONObject data = new JSONObject();
                data.put("authCode","-2");
                return data;
            }
        }else {
            //请求异常
            JSONObject data = new JSONObject();
            data.put("authCode","-2");
            return data;
        }
    }
    public String randomString(int length) {
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        StringBuffer buffer = new StringBuffer();
        Random random = new Random();
        for(int i = 0; i < length; ++i) {
            int pos = random.nextInt(str.length());
            buffer.append(str.charAt(pos));
        }
        return buffer.toString();
    }
}

+ 8 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -208,14 +208,20 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
                                                   @RequestParam(value = "keyName", required = false)String keyName,
                                                   @ApiParam(name = "workingTime", value = "排班时间YYYY-MM-DD")
	                                               @RequestParam(value = "workingTime", required = false)String workingTime,
	                                               @ApiParam(name = "consultStatus", value = "在线状态")
	                                               @RequestParam(value = "consultStatus", required = false,defaultValue = "")String consultStatus,
                                                   @ApiParam(name = "consutlSort", value = "咨询量排序")
                                                   @RequestParam(value = "consutlSort", required = true,defaultValue = "DESC")String consutlSort
                                                   @RequestParam(value = "consutlSort", required = true,defaultValue = "DESC")String consutlSort,
	                                                 @ApiParam(name = "page", value = "第几页")
	                                                     @RequestParam(value = "page",required = false) Integer page,
	                                                 @ApiParam(name = "pagesize", value = "分页大小")
	                                                     @RequestParam(value = "pagesize",required = false) Integer pagesize
	) throws Exception{
		return success(prescriptionService.findDoctorByHospitalAndDiseaseAndDept(
				orgCode,dept,
				diseaseKey,doctorNameKey,
				jobTitleNameKey,outpatientType,
				keyName,workingTime,consutlSort));
				keyName,workingTime,consultStatus,consutlSort,page,pagesize));
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.Prescription.findHotDeptAndDiseaseDict)

+ 35 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -492,6 +492,41 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success(prescriptionService.findPatientInfo(patient));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.saveDoctorOnlineWork)
    @ApiOperation(value = "保存在线排班", notes = "保存在线排班")
    public Envelop saveDoctorOnlineWork(@ApiParam(name = "onlineWorkJson", value = "保存在线排班json")
                                        @RequestParam(value = "onlineWorkJson", required = true)String onlineWorkJson)throws Exception {
        return prescriptionService.saveDoctorOnlineWork(onlineWorkJson);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.delDoctorOnlineWork)
    @ApiOperation(value = "删除在线排班", notes = "删除在线排班")
    public Envelop delDoctorOnlineWork(@ApiParam(name = "id", value = "保存在线排班ID")
                                       @RequestParam(value = "id", required = true)String id)throws Exception {
        return prescriptionService.delDoctorOnlineWork(id);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorOnlineWorkList)
    @ApiOperation(value = "查询医生在线排班", notes = "查询医生在线排班")
    public ListEnvelop findDoctorOnlineWorkList(@ApiParam(name = "doctor", value = "医生code")
                                                @RequestParam(value = "doctor", required = true)String doctor,
                                                @ApiParam(name = "startDate", value = "开始时间,YYYY-MM-dd")
                                                @RequestParam(value = "startDate", required = true)String startDate,
                                                @ApiParam(name = "endDate", value = "结束时间,YYYY-MM-dd")
                                                @RequestParam(value = "endDate", required = true)String endDate)throws Exception {
        return success(prescriptionService.findDoctorOnlineWorkList(doctor,startDate,endDate));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.cooperativeOutpatient)
    @ApiOperation(value = "发起图文和视频复诊", notes = "发起图文和视频复诊")
    public ObjEnvelop cooperativeOutpatient(@ApiParam(name = "outpatientJson", value = "复诊实体json")
                                            @RequestParam(value = "outpatientJson", required = true)String outpatientJson,
                                            @ApiParam(name = "registerJson", value = "预约实体json")
                                            @RequestParam(value = "registerJson", required = false)String registerJson)throws Exception {
        return success(prescriptionService.cooperativeOutpatient(outpatientJson,registerJson));
    }
    //===========