Browse Source

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

# Conflicts:
#	business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java
#	svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java
wangzhinan 4 years ago
parent
commit
3c704e23f9

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java

@ -1282,14 +1282,14 @@ public class XzzxEntranceService{
    }
    /**
     * 互联网医院开处方信息更新到his
     * 互联网医院删除处方信息更新到his
     * @param IoFlag  门诊住院标志
     * @param PayCardNo 就诊卡号
     * @param NullahNumber 挂号流水号
     * @param ApplyDept 执行科室
     * @param ApplyDoctor 开单医生
     * @param ExecuteDept 执行科室(药房)
     * @param presNo 必填,医嘱号
     * @param PresNo 必填,医嘱号
     * @return
     * @throws Exception
     */

+ 12 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -244,6 +244,10 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
     * 上线下线状态
     */
    private String online;//1上线0下线
    /**
     * ca标识
     */
    private Integer caFlag;
    @Column(name = "popularity")
    public Integer getPopularity() {
@ -620,4 +624,12 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.online = online;
    }
    @Column(name = "ca_flag")
    public Integer getCaFlag() {
        return caFlag;
    }
    public void setCaFlag(Integer caFlag) {
        this.caFlag = caFlag;
    }
}

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

@ -2,6 +2,7 @@ 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.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -27,4 +28,7 @@ public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO,
    List<BaseDoctorDO> findByMobile(String mobile);
    @Query("from BaseDoctorDO d where  d.del ='1'")
    List<BaseDoctorDO> findByDel();
}

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

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.restmodel.ResultStatus;
@ -35,6 +36,7 @@ import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.*;
import org.springframework.security.authentication.AuthenticationManager;
@ -136,6 +138,10 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private BasePatientDao basePatientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Value("${wechat.id}")
    private String wechatId;
    @Autowired
    private XzzxService xzzxService;
    @PostConstruct
    private void init() {
@ -925,8 +931,16 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @RequestMapping(value = "/oauth/getCaQRCode", method = RequestMethod.GET)
    public ObjEnvelop getCaQRCode(){
        logger.info("/oauth/getCaQRCode");
        String sys ="JKZLHLWYLJKGLPT";
        return ObjEnvelop.getSuccess("success", oauthCaConfigSerivce.getQRCode(sys));
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            String sys ="JKZLHLWYLJKGLPT";
            return ObjEnvelop.getSuccess("success", oauthCaConfigSerivce.getQRCode(sys));
        }else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            String sys ="2017070411003376";
            return ObjEnvelop.getSuccess("success", xzzxService.getQRCode(sys));
        }else {
            return ObjEnvelop.getSuccess("success", null);
        }
    }
    /**
@ -942,18 +956,37 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
        }
        String username = null;
        JSONObject rs = new JSONObject();
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            rs = oauthCaConfigSerivce.getQueryQRCode(qrcode);
            JSONObject data = rs.getJSONObject("data");
            String qrCodeStatus = data.getString("qrCodeStatus");
            if(!"LoginQrCodeBeenScan".equals(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            }
            username = data.getString("userIdCardNum");
        }else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            rs = xzzxService.getTokeninfo("2017070411003376",qrcode);
            JSONObject jsonObject = rs.getJSONObject("data");
            logger.info("查询登录信息"+rs);
            String qrCodeStatus = rs.getString("status");
            if(!"0".equals(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            }
            username = jsonObject.getString("userIdcardNum");
        }
        JSONObject rs = oauthCaConfigSerivce.getQueryQRCode(qrcode);
        JSONObject data = rs.getJSONObject("data");
        String qrCodeStatus = data.getString("qrCodeStatus");
        if(!"LoginQrCodeBeenScan".equals(qrCodeStatus)){
            return ObjEnvelop.getSuccess("error",rs);
        if (org.apache.commons.lang.StringUtils.isNotBlank(username)){
            BaseDoctorDO doctorDO = doctorDao.findByIdcard(username);
            doctorDO.setCaFlag(1);
            doctorDao.save(doctorDO);
        }
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        Map<String, String> parameters = new HashedMap();
        parameters.put("username",data.getString("userIdCardNum"));
        parameters.put("username",username);
        parameters.put("login_type","2");
        parameters.put("grant_type", "ihealthDcotor");

+ 3 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthCaConfigSerivce.java

@ -26,7 +26,8 @@ public class OauthCaConfigSerivce {
    private OauthCaConfigDao oauthCaConfigDao;
    /**
     * 生成二维码
     *
     * 中山生成二维码
     * @param sys
     * @return
     */
@ -44,6 +45,7 @@ public class OauthCaConfigSerivce {
        return null;
    }
    /**
     * 查询二维码授权结果
     * @param qrcode

+ 162 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/service/XzzxService.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.ca.OauthCaConfigDO;
import com.yihu.jw.security.dao.OauthCaConfigDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorHospitalDao;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 心脏中心医院
 * Created by wangzhinan on 2020/10/20.
 *
 * @author yeshijie.
 */
@Service
public class XzzxService {
    private Logger logger = LoggerFactory.getLogger(XzzxService.class);
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private OauthCaConfigDao oauthCaConfigDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    /**
     * OAuth登陆-认证请求接口
     * @param sys
     * @return
     */
    public String getQRCode(String sys) {
        try {
            logger.info("生成二维码 getQRCode :"+sys);
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/oauth/authorize?responseType=code&clientId="+sys;
            }
            String response = httpClientUtil.get(url,"utf-8");
            JSONObject rs = new JSONObject();
            JSONObject data = new JSONObject();
            String res = "";
            if (StringUtils.isNotBlank(response)){
                JSONObject object = JSONObject.parseObject(response);
                String status = object.getString("status");
                if (status.equalsIgnoreCase("0")){
                    JSONObject jsonObject = object.getJSONObject("data");
                    String imgBase64 = jsonObject.getString("imgBase64");
                    data.put("resultCode",0);
                    data.put("resultMsg","Success");
                    data.put("qrCodeImg",imgBase64);
                    data.put("qrCode",jsonObject.getString("requestId"));
                    rs.put("code",1000);
                    rs.put("msg","成功");
                    rs.put("data",data);
                }else {
                    rs.put("code",-1);
                    rs.put("msg",object.getString("message"));
                }
            }
            return rs.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * OAuth登陆-获取用户信息
     * @param clientId
     * @param requestId
     * @return
     */
    public JSONObject getTokeninfo(String clientId,String requestId){
        try {
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/oauth/tokeninfo?clientId="+clientId+"&requestId="+requestId+"";
            }
            String response = httpClientUtil.get(url,"utf-8");
            logger.info("验证二维码 getQueryQRCode :"+response);
            return JSONObject.parseObject(response);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    public String synDoctorToCa(String clientId,String requestId,String doctorId){
        try {
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/doctor/synDoctor";
            }
            if (StringUtils.isNotBlank(doctorId)){
                BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
                List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
                JSONObject body = new JSONObject();
                JSONObject head = new JSONObject();
                head.put("clientId","2017070411003376");
                head.put("clientSecret","2017070411003360");
                body.put("head",head);
                JSONObject by= new JSONObject();
                by.put("uid",doctorDO.getIdcard());
                by.put("uidCardType","SF");
                by.put("doctorName",doctorDO.getName());
                by.put("phone",doctorDO.getMobile());
                if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
                    by.put("department",doctorHospitalDOS.get(0).getOrgName());
                    by.put("department",doctorHospitalDOS.get(0).getDeptName());
                }
                body.put("body",by);
                String response = httpClientUtil.sendPost(url,body.toJSONString());
                logger.info("同步医生信息"+response);
                return  response;
            }else {
                List<BaseDoctorDO> doctorDOList = doctorDao.findByDel();
                for (BaseDoctorDO doctorDO:doctorDOList){
                    List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(doctorDO.getId());
                    JSONObject body = new JSONObject();
                    JSONObject head = new JSONObject();
                    head.put("clientId","2017070411003376");
                    head.put("clientSecret","2017070411003360");
                    body.put("head",head);
                    JSONObject by= new JSONObject();
                    by.put("uid",doctorDO.getIdcard());
                    by.put("uidCardType","SF");
                    by.put("doctorName",doctorDO.getName());
                    by.put("phone",doctorDO.getMobile());
                    if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
                        by.put("orgName",doctorHospitalDOS.get(0).getOrgName());
                        by.put("department",doctorHospitalDOS.get(0).getDeptName());
                    }
                    body.put("body",by);
                    String response = httpClientUtil.sendPost(url,body.toJSONString());
                    logger.info("同步医生信息"+response);
                }
            }
            return null;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}

+ 26 - 1
server/svr-authentication/src/main/resources/application.yml

@ -78,6 +78,9 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: jwtest
@ -104,6 +107,9 @@ testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: jwOracleTest
@ -141,6 +147,9 @@ testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: iottest
@ -167,6 +176,9 @@ testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: iotyanshi
@ -192,6 +204,8 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: jwprod
@ -217,6 +231,8 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
## 心脏中心外网
spring:
@ -243,6 +259,8 @@ wlyy:
testPattern:
  sign: 2
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_xzzx_wx  # base库中,wx_wechat 的id字段
---
## 卫计委
spring:
@ -269,6 +287,8 @@ wlyy:
testPattern:
  sign: 1
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ihealth_wx  # base库中,wx_wechat 的id字段
---
spring:
@ -294,6 +314,8 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
---
@ -320,4 +342,7 @@ wlyy:
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段