Selaa lähdekoodia

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

Shi Kejing 4 vuotta sitten
vanhempi
commit
283cdb87fb
62 muutettua tiedostoa jossa 5940 lisäystä ja 1793 poistoa
  1. 2 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/PrivateDictDao.java
  2. 3 3
      business/base-service/src/main/java/com/yihu/jw/dict/service/PrivateDictService.java
  3. 88 21
      business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java
  4. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/family/dao/BasePatientMemberDictDao.java
  5. 9 0
      business/base-service/src/main/java/com/yihu/jw/hospital/family/dao/WlyyPatientFamilyMemberDao.java
  6. 417 83
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  7. 30 0
      business/base-service/src/main/java/com/yihu/jw/hospital/httplog/service/WlyyHttpLogService.java
  8. 18 13
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseUserMsgService.java
  9. 2 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java
  10. 410 60
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  11. 531 48
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java
  12. 70 6
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  13. 97 0
      business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java
  14. 42 40
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java
  15. 937 838
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetService.java
  16. 99 52
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  17. 7 3
      business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java
  18. 22 3
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  19. 773 431
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  20. 25 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java
  21. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  22. 19 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/family/WlyyPatientFamilyMemberDO.java
  23. 24 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java
  24. 4 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  25. 18 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyOutpatientVO.java
  26. 6 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  27. 10 4
      common/common-util/src/main/java/com/yihu/jw/util/wechat/WeixinMessagePushUtils.java
  28. 1 1
      gateway/ag-basic/pom.xml
  29. 2 1
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  30. 25 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  31. 14 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/patient/WlyyPatientFamilyMemberDao.java
  32. 472 36
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  33. 38 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthSsoService.java
  34. 37 7
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthYlzConfigService.java
  35. 48 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/RegisterService.java
  36. 31 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/XzzxService.java
  37. 243 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/YkyyService.java
  38. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/sync/BaseSyncDataService.java
  39. 83 1
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java
  40. 30 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/PrescriptionAutoDeleteJob.java
  41. 1 7
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/UnSettledHISPrescriptionJob.java
  42. 73 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionDeleteService.java
  43. 100 71
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java
  44. 13 5
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  45. 6 2
      svr/svr-internet-hospital-job/src/main/resources/application.yml
  46. 2 0
      svr/svr-internet-hospital-job/src/main/resources/system.properties
  47. 36 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/Xzyy/XzyyController.java
  48. 3 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java
  49. 29 9
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  50. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  51. 2 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/dict/PrivateDictEndpoint.java
  52. 66 14
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java
  53. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/internet/InternetController.java
  54. 66 9
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  55. 44 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  56. 261 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/wechat/WechatCoreController.java
  57. 79 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/wechat/WechatMenuController.java
  58. 171 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/QrcodeService.java
  59. 105 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/wechat/WeiXinCoreService.java
  60. 120 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/wechat/WeiXinEventProcess.java
  61. 1 1
      svr/svr-internet-hospital/src/main/resources/application.yml
  62. 60 0
      svr/svr-internet-hospital/src/main/resources/wechat/weixin_menu.txt

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/PrivateDictDao.java

@ -13,4 +13,6 @@ public interface PrivateDictDao extends PagingAndSortingRepository<PrivateDictDO
    List<PrivateDictDO> findoneByCodeAndWechatId(String hospitalCode, String dictCode);
    @Query("from PrivateDictDO t where t.isDel = 1")
    List<PrivateDictDO> findALL();
    @Query("from PrivateDictDO t where t.dictCode= ?1 and t.isDel = 1")
    List<PrivateDictDO> findoneByCode(String dictCode);
}

+ 3 - 3
business/base-service/src/main/java/com/yihu/jw/dict/service/PrivateDictService.java

@ -22,9 +22,9 @@ public class PrivateDictService extends BaseJpaService<PrivateDictDO, PrivateDic
    @Autowired
    private HibenateUtils hibenateUtils;
    //查找隐私策略
    public List<PrivateDictDO> findByHospitalCodeAndDictCode(String hospitalCode,String dictCode){
        if (StringUtils.isNotBlank(hospitalCode)&&StringUtils.isNotBlank(dictCode)){
            return privateDictDao.findoneByCodeAndWechatId(hospitalCode,dictCode);
    public List<PrivateDictDO> findByHospitalCodeAndDictCode(String dictCode){
        if (StringUtils.isNotBlank(dictCode)){
            return privateDictDao.findoneByCode(dictCode);
        }else {
            return privateDictDao.findALL();
        }

+ 88 - 21
business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java

@ -9,13 +9,20 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.doctor.DoctorSpecialDiseaseDo;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
@ -23,17 +30,16 @@ import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.*;
@Service
public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoctorDao> {
@ -54,7 +60,15 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private BaseDoctorRoleDao baseDoctorRoleDao;
    @Autowired
    private WlyyChargeDictDao wlyyChargeDictDao;
    @Value("${wechat.id}")
    private String wechatId;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private static String yktUrl_90 = "http://www.yanketong.com:90/";
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    /**
     * 查询医生信息分页列表.
     * @param city
@ -120,7 +134,8 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
                " a.outpatient_type AS \"outpatientType\", " +
                " a.del AS \"del\", " +
                " b.dept_name AS \"deptName\", " +
                " e.req_fee AS \"money\" " +
                " e.req_fee AS \"money\", " +
                " a.charge_type as \"chargeType\" "+
                " FROM " +
                " base_doctor a " +
                " JOIN base_doctor_hospital b ON a.id = b.doctor_code " +
@ -152,7 +167,6 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
        logger.info("queryList sql:"+sql);
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params,page,pageSize);
        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, pageSize, count);
    }
@ -305,25 +319,78 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
    public void updateStatus(String doctorId,String status)throws Exception{
        baseDoctorDao.updateStatus(doctorId,status);
    }
    /**修改眼科通密码信息
     *
     * @param doctorId
     * @param password
     * @param oldpassword
     * @return
     */
    public String resetYktPwdByPwd(String doctorId,String password,String oldpassword,String vercode){
        String response="";
        Map headermap = new HashMap();
        headermap.put("verifyCode",vercode);
        String url = yktUrl_90+"api/share/PasswordReset?doctorId="+doctorId+"&password="+password+"&oldpassword="+oldpassword;
        logger.info("url"+url);
        response = httpClientUtil.get(url,"utf-8",headermap);
        logger.info("修改眼科同密码后的信息:"+response);
        return response;
    }
    public Boolean updateDoctorPw(String id,String pw,String orgPw){
        BaseDoctorDO doctorDO = baseDoctorDao.findOne(id);
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            BaseDoctorDO doctorDOs = baseDoctorDao.findById(id);
            String res = "";
            if (null!=doctorDOs){
                res =resetYktPwdByPwd(doctorDOs.getYktDoctorId(),pw,orgPw,doctorDOs.getVerifyCode());
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(res)) {
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(res);
                if (object.getString("code").equalsIgnoreCase("10000")) {
                    return true;
                } else {
                    return false;
                }
            }else {
                return false;
            }
        }else if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
            BaseDoctorDO doctorDO = baseDoctorDao.findOne(id);
        String orgPwMd5 = MD5.md5Hex(orgPw + "{" + doctorDO.getSalt() + "}");
        if(!orgPwMd5.equals(doctorDO.getPassword())){
            return false;
        }
        //认证信息设置
        String salt = randomString(5);
        doctorDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
        doctorDO.setSalt(salt);
            String orgPwMd5 = MD5.md5Hex(orgPw + "{" + doctorDO.getSalt() + "}");
            if(!orgPwMd5.equals(doctorDO.getPassword())){
                return false;
            }
            //认证信息设置
            String salt = randomString(5);
            doctorDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            doctorDO.setSalt(salt);
        baseDoctorDao.save(doctorDO);
            baseDoctorDao.save(doctorDO);
        //设置更新时间
        saveDoctorPwlimitDate(id);
            //设置更新时间
            saveDoctorPwlimitDate(id);
            return true;
        }else {
            BaseDoctorDO doctorDO = baseDoctorDao.findOne(id);
            String orgPwMd5 = MD5.md5Hex(orgPw + "{" + doctorDO.getSalt() + "}");
            if(!orgPwMd5.equals(doctorDO.getPassword())){
                return false;
            }
            //认证信息设置
            String salt = randomString(5);
            doctorDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            doctorDO.setSalt(salt);
            baseDoctorDao.save(doctorDO);
            //设置更新时间
            saveDoctorPwlimitDate(id);
            return true;
        }
        return true;
    }
    public String randomString(int length) {

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/family/dao/BasePatientMemberDictDao.java

@ -12,4 +12,7 @@ import java.util.List;
public interface BasePatientMemberDictDao extends PagingAndSortingRepository<BasePatientMemberDictDO, String>, JpaSpecificationExecutor<BasePatientMemberDictDO> {
    @Query("from BasePatientMemberDictDO t where t.isDel = 1")
    List<BasePatientMemberDictDO> findDictAll();
    @Query("from BasePatientMemberDictDO t where t.relationName = ?1 and t.isDel = 1")
    BasePatientMemberDictDO findByRelationName(String illness);
}

+ 9 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/family/dao/WlyyPatientFamilyMemberDao.java

@ -1,10 +1,19 @@
package com.yihu.jw.hospital.family.dao;
import com.yihu.jw.entity.hospital.family.BasePatientMemberDictDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface WlyyPatientFamilyMemberDao extends PagingAndSortingRepository<WlyyPatientFamilyMemberDO, String>, JpaSpecificationExecutor<WlyyPatientFamilyMemberDO> {
    @Query("from WlyyPatientFamilyMemberDO t where t.patient=?1 and t.familyRelation=?2 and t.isDel = 1")
    List<WlyyPatientFamilyMemberDO> findByPatientAndFamilyRelation(String patient,String familyRelation);
    @Query("from WlyyPatientFamilyMemberDO t where t.id=?1  and t.isDel = 1")
    WlyyPatientFamilyMemberDO findByIdAndDel(String id);
    @Query("from WlyyPatientFamilyMemberDO t where t.cardNo=?1 and t.patient=?2  and t.isDel =1")
    WlyyPatientFamilyMemberDO findbyCardNoAndPatient(String idCard,String patient);
}

+ 417 - 83
business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java

@ -2,24 +2,36 @@ package com.yihu.jw.hospital.family.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.family.BasePatientMemberDictDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.family.dao.BasePatientMemberDictDao;
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import jdk.management.resource.internal.inst.SocketOutputStreamRMHooks;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -42,9 +54,24 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
    private BasePatientDao basePatientDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private BasePatientMedicareCardDao basePatientMedicareCardDao;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private YkyyService ykyyService;
    @Value("${wechat.id}")
    private String wxId;
    //添加关联家属
    @Transactional
    public MixEnvelop addFamily(String id,String patientId, String familyName, String dictId, String cardType, String idCard, String phoneNum,boolean demo) throws Exception {
    public MixEnvelop addFamily(String id,String patientId, String familyName, String dictId, String cardType, String idCard, String phoneNum,boolean demo,String medicareType,String medicare,String clinicId) throws Exception {
        MixEnvelop mixEnvelop = new MixEnvelop();
        try{
        BasePatientMemberDictDO basePatientMemberDictDO = basePatientMemberDictDao.findOne(dictId);
        BasePatientDO basePatientDO = basePatientDao.findByIdcard(idCard);
        Map<String,Object> resultMap = new HashMap<>();
@ -59,109 +86,387 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
        if (StringUtils.isNotBlank(id)){
            result = wlyyPatientFamilyMemberDao.findOne(id);
        }
        MixEnvelop mixEnvelop = new MixEnvelop();
        String dictName = "";
        if (null!=basePatientMemberDictDO){
            dictName = basePatientMemberDictDO.getRelationName();
        }
        String familyId="";
        String birth = "";
        String yktFamilyId = "";
        int sex=3;
        //获取his家属数据
        JSONArray jsonArray = entranceService.BS10008(idCard,"","","","","",demo);
        if(jsonArray!=null&&jsonArray.size()>0){
            net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
            String familyId="";
            //如果病人id为空则没有就诊记录
            if (null!=jsonObject.get("Patient_Id")){
                familyId = jsonObject.getString("Patient_Id");
                String Pat_name = jsonObject.getString("Pat_Name");
                if (null!=jsonObject.get("Phone_Number_Business")){
                    String Next_Of_Kin_Phone = jsonObject.get("Phone_Number_Business").toString();
                    if(!Next_Of_Kin_Phone.equalsIgnoreCase(phoneNum)){
        JSONArray jsonArray = new JSONArray();
        if("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            jsonArray = ykyyEntranceService.findHisPatientBymMedicare(medicare,clinicId,false);
            if(jsonArray!=null&&jsonArray.size()>0){
                net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
                if (null!=jsonObject.get("brid")){
                    String Pat_name = jsonObject.getString("brxm");
                    if (!Pat_name.equalsIgnoreCase(familyName)) {
                        mixEnvelop.setStatus(408);
                        mixEnvelop.setMessage("您所添加的家属的电话有误,无法添加");
                        mixEnvelop.setMessage("您所添加的家属的名称有误,无法添加");
                        return mixEnvelop;
                    }
                }
                if(!Pat_name.equalsIgnoreCase(familyName)){
                    familyId= jsonObject.getString("brid");
                    birth= jsonObject.getString("csny");
                    long lt = new Long(birth);
                    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
                    birth = sf.format(lt);
                    String familySex = IdCardUtil.getSexForIdcard(idCard);
                    if (familySex.equalsIgnoreCase("男")){
                        familySex= "1";
                    }else if (familySex.equalsIgnoreCase("女")){
                        familySex = "0";
                    }else {
                        familySex = "2";
                    }
                    String familyAge = String.valueOf(IdCardUtil.getAgeForIdcard(idCard));
                    BasePatientMemberDictDO basePatientMemberDictDO1 = basePatientMemberDictDao.findOne(dictId);
                    String relationName = "";
                    if (null!=basePatientMemberDictDO1){
                        relationName=basePatientMemberDictDO1.getRelationName();
                    }
                    BasePatientDO basePatientDO1  = basePatientDao.findById(patientId);
                    String res = "";
                    //id不为空则为修改家人关系
                    if (StringUtils.isNotBlank(id)){
                        if (null!=basePatientDO1){
                            res = ykyyService.updateYktFamily(familyName,idCard, familySex,familyAge,phoneNum,medicare,relationName,clinicId,result.getYktFamilyId(),birth);
                        }
                        if (StringUtils.isNotEmpty(res)){
                            JSONObject jsonObject1 = JSONObject.parseObject(res);
                            if ("200".equalsIgnoreCase(jsonObject1.getString("code"))){
                                /*JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.getString("data"));
                                yktFamilyId = jsonObject2.getString("ID");*/
                            }else {
                                mixEnvelop.setStatus(408);
                                mixEnvelop.setMessage("更新家人关系至眼科通失败");
                                return mixEnvelop;
                            }
                        }else {
                            mixEnvelop.setStatus(408);
                            mixEnvelop.setMessage("更新家人关系至眼科通失败");
                            return mixEnvelop;
                        }
                    }else {
                        if (null!=basePatientDO1){
                            res = ykyyService.addYktFamily(familyName,idCard, familySex,familyAge,phoneNum,medicare,relationName,"1",basePatientDO1.getUserId(),birth);
                        }
                        if (StringUtils.isNotEmpty(res)){
                            JSONObject jsonObject1 = JSONObject.parseObject(res);
                            if ("200".equalsIgnoreCase(jsonObject1.getString("code"))){
                                JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.getString("data"));
                                yktFamilyId = jsonObject2.getString("ID");
                            }else {
                                mixEnvelop.setStatus(408);
                                mixEnvelop.setMessage("添加家人关系至眼科通失败");
                                return mixEnvelop;
                            }
                        }else {
                            mixEnvelop.setStatus(408);
                            mixEnvelop.setMessage("添加家人关系至眼科通失败");
                            return mixEnvelop;
                        }
                    }
                    System.out.println("眼科转换后的csny"+birth);
                }else {
                    mixEnvelop.setStatus(408);
                    mixEnvelop.setMessage("您所添加的家属的名称有误,无法添加");
                    mixEnvelop.setMessage("您所添加的家属无就诊记录无法添加");
                    return mixEnvelop;
                }
                result.setFamilyRelation(dictId);
                result.setFamilyRelationName(dictName);
                result.setIsDel(1);
                result.setPatient(patientId);
                result.setCardNo(idCard);
                result.setCardType(cardType);
                //保存到base_patient表中
                basePatientDO.setMobile(phoneNum);
                if(null!=jsonObject.get("Birth_Date")){
                    String birth = jsonObject.get("Birth_Date").toString();
                    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
                    Date saveBirth = sf.parse(birth);
                    basePatientDO.setBirthday(saveBirth);
            }else {
                mixEnvelop.setStatus(408);
                mixEnvelop.setMessage("您所添加的家属无就诊记录无法添加");
                return mixEnvelop;
            }
        }else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            jsonArray = entranceService.BS10008(idCard, "", "", "", "", "", demo);
            if (jsonArray != null && jsonArray.size() > 0) {
                net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
                //如果病人id为空则没有就诊记录
                if (null != jsonObject.get("Patient_Id")) {
                    familyId = jsonObject.getString("Patient_Id");
                    String Pat_name = jsonObject.getString("Pat_Name");
                    if (null != jsonObject.get("Phone_Number_Business")) {
                        String Next_Of_Kin_Phone = jsonObject.get("Phone_Number_Business").toString();
                        if (!Next_Of_Kin_Phone.equalsIgnoreCase(phoneNum)) {
                            mixEnvelop.setStatus(408);
                            mixEnvelop.setMessage("您所添加的家属的电话有误,无法添加");
                            return mixEnvelop;
                        }
                    }
                    if (!Pat_name.equalsIgnoreCase(familyName)) {
                        mixEnvelop.setStatus(408);
                        mixEnvelop.setMessage("您所添加的家属的名称有误,无法添加");
                        return mixEnvelop;
                    }
                    if(null!=jsonObject.get("Birth_Date")){
                        birth = jsonObject.get("Birth_Date").toString();
                    }
                    if(null!=jsonObject.get("Sex")){
                        sex = Integer.parseInt(jsonObject.get("Sex").toString());
                    }
                }else {
                mixEnvelop.setStatus(408);
                mixEnvelop.setMessage("您所添加的家属无就诊记录,无法添加");
            }
            }
        }else {
            com.alibaba.fastjson.JSONArray jsonArray1 = xzzxEntranceService.selectPateintCardByIdCard(idCard);
            if (null!=jsonArray1&&jsonArray1.size()>0){
                for (int i=0;i<jsonArray1.size();i++){
                    JSONObject jsonObject = jsonArray1.getJSONObject(i);
                    String xzcardType = jsonObject.getString("CARD_TYPE");
                    WlyyHospitalSysDictDO hospitalSysDictDO = wlyyHospitalSysDictDao.findByHospitalAndDictCode("350211A5010",jsonObject.getString("CARD_TYPE"));
                    if (hospitalSysDictDO!=null){
                        jsonObject.put("CARD_TYPE",hospitalSysDictDO.getDictValue());
                        jsonObject.put("CARD_TYPE_HIS",cardType);
                    }else {
                        jsonObject.put("CARD_TYPE",null);
                        jsonObject.put("CARD_TYPE_HIS",cardType);
                    }
                }
                basePatientDO.setName(familyName);
                basePatientDO.setIdcard(idCard);
                basePatientDO.setRegister("0");
                basePatientDO.setDel("1");
                if(null!=jsonObject.get("Sex")){
                    basePatientDO.setSex(Integer.parseInt(jsonObject.get("Sex").toString()));
            }
        }
        basePatientDO.setSex(sex);
        SimpleDateFormat sf3 = new SimpleDateFormat("yyyy-MM-dd");
        Date saveBirth1 = sf3.parse(birth);
        System.out.println("====="+saveBirth1);
        basePatientDO.setBirthday(saveBirth1);
        result.setFamilyRelation(dictId);
        result.setFamilyRelationName(dictName);
        result.setYktFamilyId(yktFamilyId);
        result.setIsDel(1);
        result.setPatient(patientId);
        result.setCardNo(idCard);
        result.setCardType(cardType);
        //保存到base_patient表中
        basePatientDO.setMobile(phoneNum);
        basePatientDO.setName(familyName);
        basePatientDO.setIdcard(idCard);
        basePatientDO.setRegister("0");
        basePatientDO.setDel("1");
        BasePatientDO sucessPatient= basePatientDao.save(basePatientDO);
        String patientNewId= "";
        if (sucessPatient!=null){
            patientNewId=sucessPatient.getId();
        }
            result.setFamilyMember(patientNewId);
            wlyyPatientFamilyMemberDao.save(result);
            patientMappingDO.setIdcard(idCard);
            patientMappingDO.setSource("1");
            patientMappingDO.setPatientName(familyName);
            patientMappingDO.setMappingCode(familyId);
            patientMappingDO.setPatient(patientNewId);
            patientMappingDO.setCreateTime(new Date());
            patientMappingDao.save(patientMappingDO);
            resultMap.put("patientId",patientId);
            resultMap.put("familyMember",patientNewId);
            resultMap.put("idCard",idCard);
            resultMap.put("phoneNum",phoneNum);
            resultMap.put("relationName",dictName);
            resultMap.put("name",familyName);
            resultMap.put("cardType",cardType);
            List<Map<String,Object>> resultList = new ArrayList();
            resultList.add(resultMap);
            mixEnvelop.setStatus(200);
            mixEnvelop.setMessage("添加成功");
            mixEnvelop.setDetailModelList(resultList);
            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByCode(medicare);
                if (null==patientMedicareCardDO){
                    patientMedicareCardDO = new PatientMedicareCardDO();
                }
                BasePatientDO sucessPatient= basePatientDao.save(basePatientDO);
                String patientNewId= "";
                if (sucessPatient!=null){
                    patientNewId=sucessPatient.getId();
                if (null!=patientMedicareCardDO){
                    if (!patientMedicareCardDO.getPatientCode().equalsIgnoreCase(sucessPatient.getId())){
                        mixEnvelop.setStatus(408);
                        mixEnvelop.setMessage("请确认该就诊卡为当前家人的就诊卡");
                        return mixEnvelop;
                    }
                }
                result.setFamilyMember(patientNewId);
                wlyyPatientFamilyMemberDao.save(result);
                patientMappingDO.setIdcard(idCard);
                patientMappingDO.setSource("1");
                patientMappingDO.setPatientName(familyName);
                patientMappingDO.setMappingCode(familyId);
                patientMappingDO.setPatient(patientNewId);
                patientMappingDO.setCreateTime(new Date());
                patientMappingDao.save(patientMappingDO);
                resultMap.put("patientId",patientId);
                resultMap.put("familyId",patientNewId);
                resultMap.put("idCard",idCard);
                resultMap.put("phoneNum",phoneNum);
                resultMap.put("relationName",dictName);
                List<Map<String,Object>> resultList = new ArrayList();
                resultList.add(resultMap);
                mixEnvelop.setStatus(200);
                mixEnvelop.setMessage("添加成功");
                mixEnvelop.setDetailModelList(resultList);
                patientMedicareCardDO.setCode(medicare);
                //patientMedicareCardDO.setType(medicareType);
                patientMedicareCardDO.setPatientCode(patientNewId);
                patientMedicareCardDO.setDel("1");
                basePatientMedicareCardDao.save(patientMedicareCardDO);
            }
        }
        else {
        }catch (Exception e){
            e.printStackTrace();
            mixEnvelop.setStatus(408);
            mixEnvelop.setMessage("您所添加的家属无就诊记录,无法添加");
            mixEnvelop.setMessage("添加失败");
        }
        return mixEnvelop;
    }
    //眼科同步家人信息
    public void saveYktFamily(String patientId) throws Exception{
        try {
            String userId="";
            BasePatientDO basePatientDO = basePatientDao.findById(patientId);
            if (null!=basePatientDO){
                userId = basePatientDO.getUserId();
            }
            List<Map<String, String>> list=new ArrayList<Map<String, String>>();
            String res  = ykyyService.findYktFamily(userId);
            if (StringUtils.isNotEmpty(res)){
                JSONObject jsonObject = JSONObject.parseObject(res);
                if ("200".equalsIgnoreCase(jsonObject.getString("code"))){
                    JSONObject data = JSONObject.parseObject(jsonObject.getString("data"));
                    JSONArray jsonArray = JSONArray.fromObject(data.get("list"));
                    if(jsonArray!=null && jsonArray.size()>0) {
                        for (int i = 0; i < jsonArray.size(); i++) {
                            JSONObject jsonObject1 = JSONObject.parseObject(jsonArray.get(i).toString());
                            System.out.println("==="+jsonArray.get(i).toString());
                            if (StringUtils.isNotEmpty(jsonObject1.getString("IDCARD"))){
                                System.out.println("同步的身份证号:"+jsonObject1.getString("IDCARD"));
                                BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(jsonObject1.getString("IDCARD"),"1");
                                if (null==patientDO){
                                    patientDO = new BasePatientDO();
                                }
                                patientDO.setMobile(jsonObject1.getString("TEL"));
                                if(StringUtils.isNotBlank(jsonObject1.getString("BIRTHDAY"))){
                                    patientDO.setBirthday(DateUtil.strToDate(jsonObject1.getString("BIRTHDAY")));
                                }
                                patientDO.setIdcard(jsonObject1.getString("IDCARD"));
                                patientDO.setName(jsonObject1.getString("NAME"));
                                patientDO.setSex(jsonObject1.getInteger("SEX"));
                                patientDO.setDel("1");
                                patientDO.setEnabled(1);
                                patientDO.setLocked(0);
                                patientDO.setCreateTime(new Date());
                                patientDO = basePatientDao.save(patientDO);
                                //取his中的病人code
                                JSONArray hisArray = ykyyEntranceService.findHisPatientBymMedicare(jsonObject1.getString("MEDICALCARD"),jsonObject1.getString("CLINICID"),false);
                                if(hisArray!=null&&hisArray.size()>0) {
                                    net.sf.json.JSONObject hisObject = net.sf.json.JSONObject.fromObject(hisArray.get(0).toString());
                                    PatientMappingDO patientMappingDO = patientMappingDao.findByIdcard(patientDO.getIdcard());
                                    if(null==patientMappingDO){
                                        patientMappingDO= new PatientMappingDO();
                                    }
                                    patientMappingDO.setPatientName(jsonObject1.getString("NAME"));
                                    patientMappingDO.setPatient(patientDO.getId());
                                    patientMappingDO.setMappingCode(hisObject.getString("brid"));
                                    patientMappingDO.setSource("1");
                                    patientMappingDO.setCreateTime(new Date());
                                    patientMappingDO.setIdcard(patientDO.getIdcard());
                                    patientMappingDao.save(patientMappingDO);
                                }
                                WlyyPatientFamilyMemberDO wlyyPatientFamilyMemberDO = wlyyPatientFamilyMemberDao.findbyCardNoAndPatient(patientDO.getIdcard(),patientId);
                                if (null==wlyyPatientFamilyMemberDO){
                                    wlyyPatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                                }
                                BasePatientMemberDictDO basePatientMemberDictDO =basePatientMemberDictDao.findByRelationName(jsonObject1.getString("ILLNESS"));
                                if (null!=basePatientMemberDictDO){
                                    wlyyPatientFamilyMemberDO.setIsDel(1);
                                    wlyyPatientFamilyMemberDO.setPatient(patientId);
                                    wlyyPatientFamilyMemberDO.setClinicid(jsonObject1.getString("CLINICID"));
                                    wlyyPatientFamilyMemberDO.setCardType("身份证");
                                    wlyyPatientFamilyMemberDO.setFamilyMember(patientDO.getId());
                                    wlyyPatientFamilyMemberDO.setFamilyRelation(basePatientMemberDictDO.getId());
                                    wlyyPatientFamilyMemberDO.setFamilyRelationName(basePatientMemberDictDO.getRelationName());
                                    wlyyPatientFamilyMemberDO.setCardNo(jsonObject1.getString("IDCARD"));
                                    wlyyPatientFamilyMemberDO.setYktFamilyId(jsonObject1.getString("ID"));
                                    wlyyPatientFamilyMemberDao.save(wlyyPatientFamilyMemberDO);
                                }
                                if(null!=jsonObject1.get("MEDICALCARD")){
                                    PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByCode(jsonObject1.getString("MEDICALCARD"));
                                    if (null==patientMedicareCardDO){
                                        patientMedicareCardDO = new PatientMedicareCardDO();
                                    }
                                    patientMedicareCardDO.setCode(jsonObject1.getString("MEDICALCARD"));
                                    //patientMedicareCardDO.setType(medicareType);
                                    patientMedicareCardDO.setPatientCode(patientDO.getId());
                                    patientMedicareCardDO.setDel("1");
                                    basePatientMedicareCardDao.save(patientMedicareCardDO);
                                }
                            }
                        }
                    }
                }
            }
        } catch (ParseException e) {
            e.printStackTrace();
            System.out.println("同步家人关系失败");
        }
    }
    //根据患者id查询关联家属
    public List<Map<String,Object>> findFamilyByPatientId(String patientId) throws ParseException {
        String sql = "select t.id as \"id\",t.card_type as \"cardType\", " +
                "t.patient as \"patient\",b.name as \"name\",b.sex as \"sex\","+
                "b.birthday as\"birthday\",b.idcard as \"idcard\"," +
                "t.family_member as \"familyMember\",c.relation_name as \"relationName\" "+
                " from wlyy_patient_family_member t left join base_patient b" +
                " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id where 1=1";
        if (StringUtils.isNotBlank(patientId)){
            sql += " and t.patient = '"+patientId+"'";
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        if (list!=null&&list.size()>0){
            for (Map<String,Object> map:list){
                if (map.get("birthday")!=null){
                    SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
                    int age = getAgeByBirth(sp.parse(map.get("birthday").toString()));
                    map.put("age",age);
        if("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            try {
                saveYktFamily(patientId);
            }catch (Exception e){
                e.printStackTrace();
            }
            String sql = "select t.id as \"id\",t.card_type as \"cardType\", " +
                    "t.patient as \"patient\",b.name as \"name\",b.sex as \"sex\","+
                    "to_char(b.birthday,'yyyy-MM-dd') as\"birthday\",b.idcard as \"idcard\",t.clinicid as \"clinicid\"," +
                    "t.family_member as \"familyMember\",c.relation_name as \"relationName\" "+
                    " from wlyy_patient_family_member t left join base_patient b" +
                    " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id where 1=1 and t.is_del=1 ";
            if (StringUtils.isNotBlank(patientId)){
                sql += " and t.patient = '"+patientId+"'";
            }
            List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
            if (list!=null&&list.size()>0){
                for (Map<String,Object> map:list){
                    if (null!=map.get("idcard")){
                        map.put("age",IdCardUtil.getAgeForIdcard(map.get("idcard").toString()));
                    }
                    if (null!=map.get("birthday")){
                        System.out.println("birthday:"+map.get("birthday").toString());
                    }
                    List<PatientMedicareCardDO> list1 = basePatientMedicareCardDao.findByPatientCode(patientId);
                    if (null!=list1&&list.size()>0){
                        map.put("card",list1.get(0));
                    }else {
                        map.put("card","");
                    }
                }
            }
            return list;
        }else {
            String sql = "select t.id as \"id\",t.card_type as \"cardType\", " +
                    "t.patient as \"patient\",b.name as \"name\",b.sex as \"sex\","+
                    "b.birthday as\"birthday\",b.idcard as \"idcard\"," +
                    "t.family_member as \"familyMember\",c.relation_name as \"relationName\" "+
                    " from wlyy_patient_family_member t left join base_patient b" +
                    " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id where 1=1 and t.is_del=1 ";
            if (StringUtils.isNotBlank(patientId)){
                sql += " and t.patient = '"+patientId+"'";
            }
            List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
            if (list!=null&&list.size()>0){
                for (Map<String,Object> map:list){
                    if (map.get("birthday")!=null){
                        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
                        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                            map.put("birthday",sp.parse(map.get("birthday").toString()));
                        }
                        int age = getAgeByBirth(sp.parse(map.get("birthday").toString()));
                        map.put("age",age);
                    }
                    List<PatientMedicareCardDO> list1 = basePatientMedicareCardDao.findByPatientCode(patientId);
                    map.put("cardList",list1);
                }
            }
            return list;
        }
        return list;
    }
    public static void main(String[] args) {
        String ss ="561657600000";
        Date da = new Date(Long.parseLong(ss));
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(simpleDateFormat.format(da));
    }
    private static int getAgeByBirth(Date birthday) {
        int age = 0;
@ -190,7 +495,26 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
        Envelop envelop = new Envelop();
        WlyyPatientFamilyMemberDO wlyyPatientFamilyMemberDO = wlyyPatientFamilyMemberDao.findOne(id);
        if (wlyyPatientFamilyMemberDO!=null){
            wlyyPatientFamilyMemberDao.delete(id);
            wlyyPatientFamilyMemberDO.setIsDel(0);
            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                //删除眼科通的家人关系
                String res = ykyyService.deleteYktFamily(wlyyPatientFamilyMemberDO.getYktFamilyId());
                if (StringUtils.isNotEmpty(res)){
                    JSONObject jsonObject = JSONObject.parseObject(res);
                    if ("200".equalsIgnoreCase(jsonObject.getString("code"))){
                        envelop.setMessage("删除成功");
                    }else {
                        envelop.setMessage("删除失败");
                        envelop.setStatus(-1);
                        return envelop;
                    }
                }else {
                    envelop.setMessage("删除失败");
                    envelop.setStatus(-1);
                    return envelop;
                }
            }
            wlyyPatientFamilyMemberDao.save(wlyyPatientFamilyMemberDO);
            envelop.setMessage("删除成功");
            return envelop;
        }else {
@ -203,11 +527,11 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
    public List<Map<String,Object>>  findMemberById(String id) throws ParseException {
        String sql="select t.id as \"id\",t.card_type as \"cardType\"," +
                "t.family_member as \"familyMember\",t.patient as \"patient\"," +
                "b.name as \"name\",b.idcard as \"idcard\",b.mobile as \"mobile\"," +
                "b.name as \"name\",b.idcard as \"idcard\",b.mobile as \"mobile\",t.clinicid as \"clinicid\"," +
                "c.relation_name \"relationName\",b.birthday as\"birthday\",b.sex as\"sex\"" +
                " from wlyy_patient_family_member t left join base_patient b" +
                " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id " +
                " where 1=1";
                " where 1=1 and t.is_del = 1 ";
        if (StringUtils.isNotBlank(id)){
            sql+=" and t.id='"+id+"'";
        }
@ -219,6 +543,16 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                    int age = getAgeByBirth(sp.parse(map.get("birthday").toString()));
                    map.put("age",age);
                }
                if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                    if(null!=map.get("familyMember")){
                        List<PatientMedicareCardDO> list1 = basePatientMedicareCardDao.findByPatientCode(map.get("familyMember").toString());
                        if (null!=list1&&list.size()>0){
                            map.put("card",list1.get(0));
                        }else {
                            map.put("card","");
                        }
                    }
                }
            }
        }
        return list;

+ 30 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/httplog/service/WlyyHttpLogService.java

@ -0,0 +1,30 @@
package com.yihu.jw.hospital.httplog.service;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class WlyyHttpLogService  extends BaseJpaService<WlyyHttpLogDO, WlyyHttpLogDao> {
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    //保存http日志接口
    public  void  saveHttpLog(String code,String name,String patient,String doctor,String request,String response,String status ){
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode(code);
        wlyyHttpLogDO.setName(name);
        wlyyHttpLogDO.setPatient(patient);
        wlyyHttpLogDO.setDoctor(doctor);
        wlyyHttpLogDO.setRequest(request);
        wlyyHttpLogDO.setResponse(response);
        wlyyHttpLogDO.setStatus(status);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDao.save(wlyyHttpLogDO);
    }
}

+ 18 - 13
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseUserMsgService.java

@ -26,6 +26,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
@ -209,7 +210,7 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
            sql.append("date_format(t.update_time,'%Y-%m-%d %H:%i:%S' )  AS \"update_time\"");
        }*/
        sql.append(" from base_user_message t where 1 = 1");
        sql.append(" from base_user_message t where 1 = 1 and t.del = 1");
        if (StringUtils.isNotEmpty(doctor)) {
            sql.append(" and t.receiver = '" + doctor + "'");
        }
@ -257,17 +258,17 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        List<Map<String, Object>> returnList = new ArrayList<>();
        for (Map<String, Object> map : list) {
            Map<String,Object> returnMap = new HashMap<>();
            String relationCode = map.get("relation_code").toString();
            String id =  map.get("id").toString();
            String patientID = map.get("sender").toString();
            String relationCode = null==map.get("relation_code")?"":map.get("relation_code").toString();
            String id =  null==map.get("id")?"":map.get("id").toString();
            String patientID = null==map.get("sender")?"":map.get("sender").toString();
            BaseUserMessageDO baseUserMsgDO =new BaseUserMessageDO();
            baseUserMsgDO.setId(id);
            if (map.get("type")!=null){
                baseUserMsgDO.setType(Integer.valueOf(map.get("type").toString()));
            }
            baseUserMsgDO.setReceiver(map.get("receiver").toString());
            baseUserMsgDO.setReceiverName(map.get("receiver_name").toString());
            baseUserMsgDO.setSender(map.get("sender").toString());
            baseUserMsgDO.setReceiver(null==map.get("receiver")?"":map.get("receiver").toString());
            baseUserMsgDO.setReceiverName(null==map.get("receiver_name")?"":map.get("receiver_name").toString());
            baseUserMsgDO.setSender(null==map.get("sender")?"":map.get("sender").toString());
            List<BaseSensitiveDO> baseSensitiveDOS = baseSensitiveDao.getSensitiveWords();
            String content = map.get("content")==null?"":map.get("content").toString();
            for (BaseSensitiveDO sensitiveDO:baseSensitiveDOS){
@ -279,11 +280,11 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
            }
            baseUserMsgDO.setContent(content);
            baseUserMsgDO.setRelationCode(map.get("relation_code").toString());
            baseUserMsgDO.setRelationType(Integer.valueOf(map.get("relation_type").toString()));
            baseUserMsgDO.setRelationName(map.get("relation_name").toString());
            baseUserMsgDO.setStatus(Integer.valueOf(map.get("status").toString()));
            BasePatientDO patientDO = basePatientDao.findById(map.get("sender").toString());
            baseUserMsgDO.setRelationCode(null==map.get("relation_code")?"":map.get("relation_code").toString());
            baseUserMsgDO.setRelationType(null==map.get("relation_type")?0:Integer.valueOf(map.get("relation_type").toString()));
            baseUserMsgDO.setRelationName(null==map.get("relation_name")?"":map.get("relation_name").toString());
            baseUserMsgDO.setStatus(null==map.get("status")?0:Integer.valueOf(map.get("status").toString()));
            BasePatientDO patientDO = basePatientDao.findById(null==map.get("sender")?"":map.get("sender").toString());
            List<BaseBannerDoctorDO> ba =  baseBannerDoctorDao.getBanners(baseUserMsgDO.getReceiver(),baseUserMsgDO.getSender(),baseUserMsgDO.getRelationCode());
            if(ba.size()>0){
                List<BaseBannerDO> bannerLits= new ArrayList<>();
@ -390,7 +391,7 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        map.put("relationCode",baseUserMessageDO.getRelationCode());
        map.put("relationType",baseUserMessageDO.getRelationType());
        map.put("status",baseUserMessageDO.getStatus());
        map.put("updateTime",DateUtil.dateToStrLong(DateUtil.strToDateLong(baseUserMessageDO.getUpdateUserName())));
        map.put("updateTime",DateUtil.dateToStrLong(baseUserMessageDO.getUpdateTime()));
        map.put("relationName",baseUserMessageDO.getRelationName());
        map.put("contentlist",contentlist);
        returnResult.add(map);
@ -527,4 +528,8 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        return true;
    }
    public static void main(String[] args) throws Exception {
        String sex = IdCardUtil.getSexForIdcard_new("411526199410084833");
        System.out.println(sex);
    }
}

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java

@ -60,5 +60,7 @@ public interface PrescriptionDao extends PagingAndSortingRepository<WlyyPrescrip
    List<WlyyPrescriptionDO> findByOutPatientIdList(String outpatientId);
    List<WlyyPrescriptionDO> findByDoctorAndCreateTimeAndRemark(String doctor,Date createTime,String remark);
    @Query("select a from WlyyPrescriptionDO a where a.createTime>?1 and  a.createTime <?2 and a.status <30 and a.status>=0")
    List<WlyyPrescriptionDO> findListByCheckStatus(Date startTime,Date endTime);
}

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

@ -78,13 +78,13 @@ import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.utils.Pkis.PKIService_PortType;
import com.yihu.jw.utils.Pkis.PKIService_ServiceLocator;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.enterprise.EnterpriseService;
import com.yihu.jw.wechat.service.BaseSensitiveFilterWordsService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.mysql.query.BaseJpaService;
@ -104,6 +104,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
@ -256,15 +257,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private PrescriptionSignDao prescriptionSignDao;
    @Autowired
    private EnterpriseService enterpriseService;
    @Autowired
    private PrescriptionDiagnosisDao  prescriptionDiagnosisDao;
    @Autowired
    private XzyyPrescriptionService xzyyPrescriptionService;
    @Value("${demo.flag}")
    private boolean demoFlag;
    @Value("${wechat.id}")
@ -448,7 +446,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " o.disease_img AS \"diseaseImg\"," +
                " o.consumer as \"consumer\"," +
                " o.consumer_name as \"consumerName\"," +
                " o.consumer_mobile as \"consumerMobile\", ";
                " o.consumer_mobile as \"consumerMobile\", "+
                " o.fee as \"fee\", ";
        if ("xm_ykyy_wx".equals(wechatId)) {
            if (flag){
                sql = sql + "date_format(o.create_time ,'%Y-%m-%d %H:%i:%S' ) AS createTime,";
@ -510,6 +509,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("patientCancelRemark", outpatientDO.getPatientCancelRemark());
        rs.put("operator",outpatientDO.getOperator());
        rs.put("status",outpatientDO.getStatus());
        rs.put("fee",outpatientDO.getFee());
        rs.put("createTime",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));
        //居民详情
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
@ -573,6 +573,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        //电子病历
                        vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO);
                    }
                } else if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
                    WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO1 = prescriptionEmrDao.findEmrByPrescriptionId(vo.getId());
                    if (wlyyPrescriptionEmrDO1 != null) {
                        vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO1);
                    } else {
                        List<WlyyPrescriptionEmrDO> listEmr = xzzxEntranceService.selectHistoryEmr(hisPatient,"");
                        if (null!=listEmr&&listEmr.size()>0){
                            vo.setWlyyPrescriptionEmrDO(listEmr.get(0));
                        }
                    }
                }
                //支付信息
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(vo.getId());
@ -904,6 +914,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            prescriptionExpressageDao.save(expressageDO);
        }
        if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            logger.info("心脏中心同步患者开始");
            xzzxEntranceService.updatePatientMapping(outpatient.getConsumer(),outpatient.getCardNo());
            logger.info("同步患者id成功");
        }
@ -1121,23 +1132,39 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    public Map<String, Object> checkOutpatient(String patient,String wxId) throws Exception {
    public Map<String, Object> checkOutpatient(String patient,String wxId,boolean flag) throws Exception {
        //-1卡余额不足,,-2 存在未结束的诊断热 1成功
        Map<String, Object> rs = new HashedMap();
        //1.余额判断改到前端判断
        //net.sf.json.JSONObject json = entranceService.qutpatientBalance(cardNo,demoFlag);
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            List<WlyyOutpatientDO> outpatientDOS = outpatientDao.findByPatientListByStatus(patient);
            if (outpatientDOS!=null&&outpatientDOS.size()!=0){
                WlyyOutpatientDO outpatientDO = outpatientDOS.get(0);
                if (outpatientDO.getHisStatus()!=null){
                    logger.info("您上一次就诊进入"+outpatientDO.getHisStatus());
                    if(outpatientDO.getHisStatus()!=1&&outpatientDO.getHisStatus()!=-1){
                        logger.info("您上一次就诊进入======"+outpatientDO.getHisStatus());
        if (flag){
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                List<WlyyOutpatientDO> outpatientDOS = outpatientDao.findByPatientListByStatus(patient);
                if (outpatientDOS!=null&&outpatientDOS.size()!=0){
                    WlyyOutpatientDO outpatientDO = outpatientDOS.get(0);
                    if (outpatientDO.getHisStatus()!=null){
                        logger.info("您上一次就诊进入"+outpatientDO.getHisStatus());
                        if(outpatientDO.getHisStatus()!=1&&outpatientDO.getHisStatus()!=-1){
                            logger.info("您上一次就诊进入======"+outpatientDO.getHisStatus());
                            rs.put("outpatient", outpatientDO);
                            rs.put("code", -3);
                            rs.put("mes", "您上一次就诊未结算,请结算后才能发起复诊。");
                            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wxId, patient);
                            if (patientWechatDos == null || patientWechatDos.size() == 0) {
                                throw new Exception("openid不存在!");
                            }
                            WxWechatDO wxWechatDO = wechatDao.findById(wxId);
                            BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                            String payUrl = ylzPayService.createSicardPayUrl(wxWechatDO.getAppOriginId(),patientWechatDo.getOpenid(),outpatientDO.getCardNo(),"WX");
                            rs.put("payUrl",payUrl);
                            return rs;
                        }
                    }else if (outpatientDO.getHisStatus()==null){
                        rs.put("outpatient", outpatientDO);
                        rs.put("code", -3);
                        rs.put("mes", "您上一次就诊未结算,请结算后才能发起复诊。");
                        List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wxId, patient);
                        List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getConsumer());
                        if (patientWechatDos == null || patientWechatDos.size() == 0) {
                            throw new Exception("openid不存在!");
                        }
@ -1147,26 +1174,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        rs.put("payUrl",payUrl);
                        return rs;
                    }
                }else if (outpatientDO.getHisStatus()==null){
                    rs.put("outpatient", outpatientDO);
                    rs.put("code", -3);
                    rs.put("mes", "您上一次就诊未结算,请结算后才能发起复诊。");
                    List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getConsumer());
                    if (patientWechatDos == null || patientWechatDos.size() == 0) {
                        throw new Exception("openid不存在!");
                    }
                    WxWechatDO wxWechatDO = wechatDao.findById(wxId);
                    BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                    String payUrl = ylzPayService.createSicardPayUrl(wxWechatDO.getAppOriginId(),patientWechatDo.getOpenid(),outpatientDO.getCardNo(),"WX");
                    rs.put("payUrl",payUrl);
                    return rs;
                }
            }
        }
        //2.判断是否有未结束的
        List<WlyyOutpatientDO> list = outpatientDao.findByPatientList(patient);
        if (list != null && list.size() > 0) {
@ -1494,6 +1508,38 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                String id = (String) doctor.get("id");
                List<WlyyDoctorWorkTimeVO> times = findDoctorWorkTime(id, orgCode);
                doctor.put("workTime", times);
                String deptTyepCode = "";
                if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
                    deptTyepCode = "6";
                    List<BaseDoctorHospitalDO> depts = baseDoctorHospitalDao.findByDoctorCode(id);
                    if (null!=depts&&depts.size()>0){
                        BaseDoctorHospitalDO baseDoctorHospitalDO = depts.get(0);
                        String deptcode =  baseDoctorHospitalDO.getDeptCode();
                        String hosptitalCode = baseDoctorHospitalDO.getOrgCode();
                        List<DictHospitalDeptDO> dictHospitalDeptDO = dictHospitalDeptDao.findByOrgCodeAndCode(hosptitalCode,deptcode);
                        if(null!=dictHospitalDeptDO&&dictHospitalDeptDO.size()>0){
                            if (StringUtils.isNotBlank(dictHospitalDeptDO.get(0).getDeptTypeCode())){
                                deptTyepCode = dictHospitalDeptDO.get(0).getDeptTypeCode();
                            }
                        }
                    }
                }
                List<Map<String,Object>> chargeDictDOLists = new ArrayList<>();
                if (null!=doctor.get("chargeType")){
                    String chargeTypeList = doctor.get("chargeType").toString();
                    if (chargeType.contains(",")){
                        chargeTypeList = chargeType.replace(",","','");
                    }
                    String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
                            "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
                            " from wlyy_charge_dict where 1=1";
                    sqlCharge+=" and charge_type in ( '"+chargeTypeList+"')";
                    if (StringUtils.isNoneBlank(deptTyepCode)){
                        sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')";
                    }
                    chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
                }
                doctor.put("chargeTypeList",chargeDictDOLists);
            }
            if (StringUtils.isNotBlank(doctorCode)) {
                //排序
@ -1543,7 +1589,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return null;
    }
    /**
     * 查询医生列表带月份排班状态
     *
@ -1739,7 +1784,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //下载银医通
        net.sf.json.JSONObject object1 = entranceService.qutpatientBalance(outpatientDO.getCardNo(), demoFlag);
        logger.info("下载银医通");
        net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(), doctorMappingDO.getMappingCode(), outpatientDO.getDept(), null, outpatientDO.getWinNo(), demoFlag);
        String chargeType = null;
        if (StringUtils.isNoneBlank(outpatientDO.getChargeType())){
            if (outpatientDO.getChargeType().equalsIgnoreCase("33")){
                chargeType = outpatientDO.getChargeType();
            }
        }
        net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(), doctorMappingDO.getMappingCode(), outpatientDO.getDept(), chargeType, outpatientDO.getWinNo(), demoFlag);
        net.sf.json.JSONObject res = rs.getJSONObject("resquest");
        logger.info("挂号结果 res: " + res.toString());
        String rsCode = res.getString("@RESULT");
@ -2361,7 +2412,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDOList.get(0);
                        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                        logger.info("cfsb", wlyyPrescriptionDO.getRealOrder());
                        ykyyService.updateDrugorderInfo(businessOrderDO.getOrderNo(), wlyyPrescriptionDO.getOrderId(), wlyyPrescriptionDO.getRealOrder());
                        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
                        if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                        } else {
                            ykyyService.updateDrugorderInfo(businessOrderDO.getOrderNo(), wlyyPrescriptionDO.getOrderId(), wlyyPrescriptionDO.getRealOrder());
                        }
                    }
                }
@ -3334,7 +3390,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public Map<String, Object> findDoctorInfo(String doctor, String withWork,String patient) {
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
        Map<String, Object> rs = new HashedMap();
        if (doctorDO != null) {
            rs.put("doctor", doctor);
@ -3367,8 +3422,40 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            rs.put("sex",doctorDO.getSex());
            rs.put("popularity",doctorDO.getPopularity());
            rs.put("qrcode",doctorDO.getQrcode());
            //号别
            String deptTyepCode = "";
            if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
                deptTyepCode = "6";
                List<BaseDoctorHospitalDO> depts = baseDoctorHospitalDao.findByDoctorCode(doctor);
                if (null!=depts&&depts.size()>0){
                    BaseDoctorHospitalDO baseDoctorHospitalDO = depts.get(0);
                    String deptcode =  baseDoctorHospitalDO.getDeptCode();
                    String hosptitalCode = baseDoctorHospitalDO.getOrgCode();
                    List<DictHospitalDeptDO> dictHospitalDeptDO = dictHospitalDeptDao.findByOrgCodeAndCode(hosptitalCode,deptcode);
                    if(null!=dictHospitalDeptDO&&dictHospitalDeptDO.size()>0){
                        if (StringUtils.isNotBlank(dictHospitalDeptDO.get(0).getDeptTypeCode())){
                            deptTyepCode = dictHospitalDeptDO.get(0).getDeptTypeCode();
                        }
                    }
                }
            }
            List<Map<String,Object>> chargeDictDOLists = new ArrayList<>();
            String chargeType = doctorDO.getChargeType();
            if (StringUtils.isNotBlank(chargeType)){
                if (chargeType.contains(",")){
                    chargeType = chargeType.replace(",","','");
                }
                String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
                        "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
                        " from wlyy_charge_dict where 1=1";
                sqlCharge+=" and charge_type in ( '"+chargeType+"')";
                if (StringUtils.isNoneBlank(deptTyepCode)){
                    sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')";
                }
                chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
            }
            rs.put("chargeTypeList",chargeDictDOLists);
            //机构科室信息
            List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
            if (hospitalDOs != null && hospitalDOs.size() > 0) {
@ -3602,7 +3689,40 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            rs.put("learning",doctorDO.getLearning());
            rs.put("sex",doctorDO.getSex());
            rs.put("qrcode",doctorDO.getQrcode());
            //号别
            String deptTyepCode = "";
            if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
                deptTyepCode = "6";
                List<BaseDoctorHospitalDO> depts = baseDoctorHospitalDao.findByDoctorCode(doctor);
                if (null!=depts&&depts.size()>0){
                    BaseDoctorHospitalDO baseDoctorHospitalDO = depts.get(0);
                    String deptcode =  baseDoctorHospitalDO.getDeptCode();
                    String hosptitalCode = baseDoctorHospitalDO.getOrgCode();
                    List<DictHospitalDeptDO> dictHospitalDeptDO = dictHospitalDeptDao.findByOrgCodeAndCode(hosptitalCode,deptcode);
                    if(null!=dictHospitalDeptDO&&dictHospitalDeptDO.size()>0){
                        if (StringUtils.isNotBlank(dictHospitalDeptDO.get(0).getDeptTypeCode())){
                            deptTyepCode = dictHospitalDeptDO.get(0).getDeptTypeCode();
                        }
                    }
                }
            }
            List<Map<String,Object>> chargeDictDOLists = new ArrayList<>();
            String chargeType = doctorDO.getChargeType();
            if (StringUtils.isNotBlank(chargeType)){
                if (chargeType.contains(",")){
                    chargeType = chargeType.replace(",","','");
                }
                String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
                        "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
                        " from wlyy_charge_dict where 1=1";
                sqlCharge+=" and charge_type in ( '"+chargeType+"')";
                if(StringUtils.isNoneBlank(deptTyepCode)){
                    sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')";
                }
                chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
            }
            rs.put("chargeTypeList",chargeDictDOLists);
            //机构科室信息
            List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
            List<BaseDoctorHospitalDO> hospitalDOList = new ArrayList<>();
@ -4175,7 +4295,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            String responseMsg="";
            //String prefix="https://www.xmheart.com";
            String prefix = "https://ih.xmheart.com";
            String prefix = "https://ih.xmheart.com/hlwyy";
            if(StringUtils.isNotEmpty(outpatientId)){
                responseMsg = xzzxEntranceService.sendXCXMes(wxId,
                        patientDO.getId(),
@ -4328,7 +4448,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "outpatient.consumer_name as \"consumerName\"," +
                "outpatient.consumer_mobile as \"consumerMobile\", ";
        if ("xm_ykyy_wx".equals(wechatId)) {
            flag =true;
            if(flag){
                sql += "date_format(room.reservation_time ,'yyyy-MM-dd hh24:mi:ss' ) AS \"timedate_format\",";
            }else {
@ -4866,12 +4985,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
      /*  if(page >=1){
            page --;
        }
        if (pagesize <= 0) {
            pagesize = 10;
        }*/
        String sql = "SELECT " +
                " d.id AS \"id\", " +
                " d.photo AS \"photo\", " +
@ -4897,6 +5014,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        Date date = new Date();
        sql+="LEFT JOIN (SELECT  COUNT(t1.doctor) as workTotal, t1.doctor FROM  wlyy_doctor_work_time t1   WHERE   " +
                "t1.start_time <=:startTime  AND t1.end_time >=:endTime GROUP BY t1.doctor) dw ON dw.doctor=d.id ";
        sql+="LEFT JOIN (\n" +
                "\tSELECT\n" +
                "\t\tAVG(a.score) AS score,\n" +
                "\t\tb.doctor AS doctor\n" +
                "\tFROM\n" +
                "\t\tbase_evaluate a,\n" +
                "\t\tbase_evaluate_score b\n" +
                "\tWHERE\n" +
                "\t\ta.relation_code = b.id\n" +
                "\tGROUP BY\n" +
                "\t\tb.doctor\n" +
                ") evaluate ON evaluate.doctor = d.id";
        params.put("startTime", date);
        params.put("endTime", date);
        if ("1".equalsIgnoreCase(isAttention)) {
@ -5010,13 +5139,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            if (flag){
                sql += " and d.del='1' order by dw.workTotal desc ,d.consult_status DESC ,a.total " + consutlSort;
                sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort;
            }else{
                sql += " and d.del='1' order by dw.workTotal desc nulls last,d.consult_status desc nulls last ,a.total " + consutlSort;
                sql += " and d.del='1' order by d.consult_status desc nulls last ,evaluate.score desc nulls last ,a.total " + consutlSort;
            }
        }else {
            sql += " and d.del='1' order by dw.workTotal desc ,d.consult_status DESC ,a.total " + consutlSort;
            sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort;
        }
        String sqlCount = "select count(1) as \"total\" from ( "+sql+" ) t";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, pagesize);
@ -5031,6 +5159,40 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        list.stream().sorted(Comparator.comparing((Map<String, Object> h) -> ((String) h.get("workTotal"))).reversed().thenComparing(Comparator.comparing((Map<String, Object> h) -> ((String) h.get("consultStatus")))).reversed());*/
        for (Map<String,Object> map:list){
            String doctor = map.get("id").toString();
            //号别
            String deptTyepCode = "";
            if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
                deptTyepCode = "6";
                List<BaseDoctorHospitalDO> depts = baseDoctorHospitalDao.findByDoctorCode(doctor);
                if (null!=depts&&depts.size()>0){
                    BaseDoctorHospitalDO baseDoctorHospitalDO = depts.get(0);
                    String deptcode =  baseDoctorHospitalDO.getDeptCode();
                    String hosptitalCode = baseDoctorHospitalDO.getOrgCode();
                    List<DictHospitalDeptDO> dictHospitalDeptDO = dictHospitalDeptDao.findByOrgCodeAndCode(hosptitalCode,deptcode);
                    if(null!=dictHospitalDeptDO&&dictHospitalDeptDO.size()>0){
                        if (StringUtils.isNotBlank(dictHospitalDeptDO.get(0).getDeptTypeCode())){
                            deptTyepCode = dictHospitalDeptDO.get(0).getDeptTypeCode();
                        }
                    }
                }
            }
            List<Map<String,Object>> chargeDictDOLists = new ArrayList<>();
            if(null!=map.get("chargeType")){
                String chargeType = map.get("chargeType").toString();
                if (chargeType.contains(",")){
                    chargeType = chargeType.replace(",","','");
                }
                String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
                        "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
                        " from wlyy_charge_dict where 1=1";
                sqlCharge+=" and charge_type in ( '"+chargeType+"')";
                if (StringUtils.isNoneBlank(deptTyepCode)){
                    sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')";
                }
                chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
            }
            map.put("chargeTypeList",chargeDictDOLists);
            //查询医生各项评价平均分
            String sqlscore = "SELECT " +
                    "AVG(a.score) AS \"score\"," +
@ -5576,7 +5738,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     */
    public List<Map<String, Object>> getVideoPrescriptionByDoctor(String doctor, String general_doctor, String wxId) {
        String condition = "";
        if ("xm_ykyy_wx".equals(wxId)) {
        /*if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
                condition += "date_format(room.reservation_time,'YYYY-MM-DD hh24:mi:ss')  AS \"time\",";
            }else {
@ -5585,7 +5747,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        } else {
            condition += "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS \"time\",";
        }
        }*/
        String sql = "SELECT " +
                "room.outpatient_id AS \"id\"," +
                "room.patient_id AS \"patient_id\"," +
@ -5595,7 +5757,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "patient.photo AS \"photo\"," +
                "patient.birthday AS \"birthday\"," +
                "patient.mobile AS \"mobile\"," +
                "room.consult_type AS \"consult_type\"," + condition +
                "room.consult_type AS \"consult_type\"," + "room.reservation_time as \"time\", " +
                "room.reservation_type AS \"reservation_type\"," +
                "outpatient.disease_img AS \"disease_img\"," +
                "outpatient.description AS \"description\"," +
@ -5629,7 +5791,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                String idcard = (String) outpatient.get("idcard");
                String patient_id = (String) outpatient.get("patient_id");
                outpatient.put("age", DateUtil.getAgeForIdcard(idcard));
                //转换日期格式
                outpatient.put("time",null==outpatient.get("time")?"":DateUtil.dateToStrLong(DateUtil.strToDateLong(outpatient.get("time").toString())));
                String outpatient_id = (String) outpatient.get("id");
                String isAlert = redisTemplate.opsForValue().get("patient_alert_" + patient_id);
@ -5718,7 +5881,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        String condition = "";
        if ("xm_ykyy_wx".equals(wxId)) {
            if(flag){
                condition += "date_format(room.reservation_time,'YYYY-MM-DD hh24:mi:ss')  AS \"time\",";
                condition += "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' )  AS \"time\",";
                condition += "date_format(room.reservation_time,'YYYY-MM-DD')  AS \"group_date\",";
            }else{
                condition += "to_char(room.reservation_time,'YYYY-MM-DD hh24:mi:ss')  AS \"time\",";
@ -5726,7 +5889,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
        } else {
            condition += "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS \"time\",";
                condition += "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS \"time\",";
            condition += "date_format(room.reservation_time ,'%Y-%m-%d' ) AS \"group_date\",";
        }
        String sql = "SELECT " +
@ -7523,9 +7686,63 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    xzyyPrescriptionService.SOF_SignDataWithExtraInfo(wlyyPrescriptionDO);
                    //同步电子病历
                    WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
                    if (prescriptionEmrDO != null) {
                        logger.info("电子病历签名");
                        xzyyPrescriptionService.SOF_SignDataWithExtraInfoEmr(wlyyPrescriptionDO);
                    try {
                        if (prescriptionEmrDO != null) {
                            logger.info("电子病历同步");
                            xzzxEntranceService.saveEmrToEntrance(prescriptionId);
                            logger.info("电子病历同步");
                            logger.info("电子病历签名");
                            xzyyPrescriptionService.SOF_SignDataWithExtraInfoEmr(wlyyPrescriptionDO);
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    try {
                        if (object!=null){
                            if (object.getString("code").equalsIgnoreCase("0")){
                                //  * @param applyDepaName @param applyDoctorName
                                WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
                                String patientCode = outpatientDO.getConsumer();
                                String realerOrder = prescriptionDO.getRealOrder();
                                String recipeTime = DateUtil.dateToStr(prescriptionDO.getCreateTime(), "yyyyMMddHHmmss");
                                List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(prescriptionDO.getDoctor());
                                String applyDepaName = null;
                                if (doctorHospitalDOS != null && doctorHospitalDOS.size() != 0) {
                                    applyDepaName = doctorHospitalDOS.get(0).getDeptName();
                                }
                                String voucherNo = outpatientDO.getRegisterNo();
                                String applyDoctorName = prescriptionDO.getDoctorName();
                                BasePatientDO patientDO = basePatientDao.findById(patientCode);
                                String userName = null;
                                String idcard = null;
                                if (patientDO != null) {
                                    userName = patientDO.getName();
                                    idcard = patientDO.getIdcard();
                                }
                                PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patientCode);
                                String userNo = null;
                                if (patientMappingDO != null) {
                                    userNo = patientMappingDO.getMappingCode();
                                }
                                String cardNo = null;
                                if (StringUtils.isNoneBlank(outpatientDO.getCardNo())) {
                                    cardNo = outpatientDO.getCardNo();
                                }
                                logger.info("cardNo:" + cardNo);
                               /* JSONObject jsonObject =entranceService.BS15054(patientMappingDO.getMappingCode(),prescriptionDO.getRealOrder(),demoFlag);
                                net.sf.json.JSONObject res = jsonObject.getJSONObject("resquest");
                                logger.info("获取待结算数据 res: " + res.toString());
                                String rsCode = res.getString("@RESULT");
                                String free= 0+"";
                                if ("0".equals(rsCode)) {
                                    free = res.getString("@total_charge");
                                }*/
                                ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, "", "");
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } catch (Exception e) {
@ -7571,7 +7788,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            wlyyPrescriptionDO.setId(prescriptionId);
            wlyyPrescriptionDO.setCheckStatus(status);
            wlyyPrescriptionDO.setCheckReason(reason);
            wlyyPrescriptionDO.setStatus(11);
            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                wlyyPrescriptionDO.setStatus(10);
            }else{
                wlyyPrescriptionDO.setStatus(11);
            }
        }
        prescriptionDao.save(wlyyPrescriptionDO);
        if (status == 2 || status == 1) {
@ -7673,11 +7895,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            JSONObject data = new JSONObject();
            Integer age = 0;
            String gender = "";
            if (StringUtils.isNoneBlank(prescriptionDO.getIdcard())) {
                age = IdCardUtil.getAgeForIdcard(prescriptionDO.getIdcard());
                gender = IdCardUtil.getSexForIdcard(prescriptionDO.getIdcard());
            }
            BasePatientDO patientDO = basePatientDao.findById(prescriptionDO.getPatientCode());
            if (null!=patientDO&&StringUtils.isNotBlank(patientDO.getIdcard())) {
                age = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
                gender = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            }
            data.put("name", prescriptionDO.getPatientName());
            data.put("age", age);
            data.put("gender", gender);
@ -8313,8 +8535,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        String uid = userAgent.getUID();
        StringBuffer sql = new StringBuffer(" SELECT b.*, c.oneself_pickup_flg,f.job_title_code,f.job_title_name  FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
        StringBuffer countSql = new StringBuffer("select COUNT(b.id) count FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
        sql.append(uid).append("') b LEFT JOIN wlyy_prescription_info d ON b.id = d.prescription_id LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  ");
        countSql.append(uid).append("') b LEFT JOIN wlyy_prescription_info d ON b.id = d.prescription_id LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  ");
        sql.append(uid).append("') b  LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  ");
        countSql.append(uid).append("') b  LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  ");
        if (StringUtils.isNotEmpty(status)) {
            status = status.substring(1, status.length() - 1);
@ -8377,8 +8599,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            logger.info("MySql=" + sql.toString());
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
        }
        for (WlyyPrescriptionVO singlePre:list){
            List<WlyyPrescriptionInfoDO> infoDOs = prescriptionInfoDao.findByPrescriptionId(singlePre.getId(),1);
            List<WlyyPrescriptionInfoVO> infoVOS = new ArrayList<>();
            BeanUtils.copyProperties(infoDOs,infoVOS);
            singlePre.setInfoVOs(infoVOS);
        }
//        List<WlyyPrescriptionVO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
        logger.info("countSql=" + countSql.toString());
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(countSql.toString());
@ -8675,4 +8901,128 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
       }
       return envelop;
    }
    //应声开具处方管理
    public MixEnvelop prescriptionManage(String keyWord,String doctorId,String startTime,String endTime,String checkStatus,Integer page,Integer pageSize){
        String sql = " select p.create_time as \"createTime\"," +
                " p.patient_name as \"patientName\"," +
                " p.idcard as \"idcard\"," +
                " o.card_no as \"cardNo\"," +
                " p.check_status as \"checkStatus\"," +
                " p.id as \"id\"," +
                " p.check_reason as \"checkReason\" " +
                " from wlyy_prescription p left join wlyy_outpatient o on p.outpatient_id  = o.id" +
                " where  1=1 ";
        if (StringUtils.isNotBlank(keyWord)){
            sql+=" and (p.patient_name like '%"+keyWord+"%' or p.idcard = '"+keyWord+"'" +
                    " or o.card_no = '"+keyWord+"')";
        }
        if(StringUtils.isNotBlank(checkStatus)){
            sql+=" and p.check_status ="+checkStatus;
        }else {
            sql+=" and p.check_status != 4";
        }
        if(StringUtils.isNotBlank(doctorId)){
            sql+=" and p.doctor = '"+doctorId+"'";
        }
        if(StringUtils.isNotBlank(startTime)){
            if("xm_ykyy_wx".equals(wechatId)){
                if (flag){
                    sql+=" and p.create_time > '" + startTime + " 00:00:00'";
                }else {
                    sql+=" and p.create_time > to_date('" + startTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') ";
                }
            }else{
                sql+=" and p.create_time > '" + startTime + " 00:00:00' ";
            }
        }
        if(StringUtils.isNotBlank(endTime)){
            if("xm_ykyy_wx".equals(wechatId)){
                if (flag){
                    sql+="  and p.create_time<'" + endTime + " 23:59:59'";
                }else {
                    sql+=" and p.create_time< to_date('" + endTime + " 23:59:59','yyyy-mm-dd hh24:mi:ss')";
                }
            }else{
                sql+="  and p.create_time<'" + endTime + " 23:59:59'";
            }
        }
        sql+=" order by p.create_time desc";
        String sqlcount = "SELECT COUNT(1) AS \"total\" FROM ("+sql+") q";
        Long count = 0L;
        List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sqlcount);
        if(total!=null){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            count = hibenateUtils.objTransformLong(total.get(0).get("total"));
        }
        List<Map<String,Object>> resultList = hibenateUtils.createSQLQuery(sql,page,pageSize);
        for (Map<String,Object> map:resultList){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            map.put("createTime",null==map.get("createTime")?"":DateUtil.dateToStrLong(DateUtil.strToDateLong(map.get("createTime").toString())));
            String prescriptionId = map.get("id").toString();
            //获取处方信息
            List<WlyyPrescriptionDO> prescriptionDOs = null;
            prescriptionDOs = prescriptionDao.findById(prescriptionId);
            List<WlyyPrescriptionVO> prescriptionVOs = new ArrayList<>();
            List<BusinessOrderDO> businessOrders = new ArrayList<>();
            if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
                convertToModels(prescriptionDOs, prescriptionVOs, WlyyPrescriptionVO.class);
                for (WlyyPrescriptionVO vo : prescriptionVOs) {
                    List<WlyyPrescriptionCheckDO> prescriptionCheckDO = prescriptionCheckDao.findByPrescriptionId(vo.getId());
                    //疾病信息
                    vo.setDiagnosisVOs(findDiagnosisById(vo.getId()));
                    if(null!=prescriptionCheckDO&&prescriptionCheckDO.size()>0){
                        vo.setDispUser(prescriptionCheckDO.get(0).getOperate());
                        vo.setDispUserName(prescriptionCheckDO.get(0).getOperateName());
                    }
                    //药品信息
                    List<WlyyPrescriptionInfoVO> infoVOs = new ArrayList<>();
                    System.out.println("=====PrescriptionId======"+vo.getId());
                    convertToModels(prescriptionInfoDao.findByPrescriptionId(vo.getId(), 1), infoVOs, WlyyPrescriptionInfoVO.class);
                    vo.setInfoVOs(infoVOs);
                    //检查检验信息
                    List<WlyyInspectionVO> inspectionVOs = new ArrayList<>();
                    vo.setInspectionVOs(convertToModels(wlyyInspectionDao.findByPrescriptionId(vo.getId(), 1), inspectionVOs, WlyyInspectionVO.class));
                    //支付信息
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(vo.getId());
                    if (null!=businessOrderDO){
                        businessOrders.add(businessOrderDO);
                    }
                }
            }
            map.put("prescriptions",prescriptionVOs);
        }
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setDetailModelList(resultList);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setTotalCount(count.intValue());
        return  mixEnvelop;
    }
    //作废处方
    public String disablePrescription(String prescriptionId) throws  Exception{
        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
        if (null!=prescriptionDO){
            String hisId = prescriptionDO.getHisId();
            if("xm_xzzx_wx".equalsIgnoreCase(wechatId)){
                List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOs = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionId,1);
                if (null!=wlyyPrescriptionDiagnosisDOs&&wlyyPrescriptionDiagnosisDOs.size()>0){
                    xzzxEntranceService.deleteCheckInputInfo(hisId,"0",prescriptionDO.getDoctor(),prescriptionDO.getPatientCode(),wlyyPrescriptionDiagnosisDOs);
                    if (StringUtils.isNotBlank(prescriptionDO.getRealOrder())){
                        xzzxEntranceService.deletePrescriptionToEntrance(prescriptionDO.getRealOrder());
                    }
                }
            }
            prescriptionDO.setStatus(-1);
            prescriptionDO.setCheckStatus(4);
            prescriptionDO.setCheckReason("已删除");
            prescriptionDao.save(prescriptionDO);
            return "删除成功";
        }else {
            return "删除失败";
        }
    }
}

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

@ -151,6 +151,14 @@ public class XzzxEntranceService{
        return url;
    }
    public String getOperateSmsUrl(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("xzzxWebOperateSmsService");
        String url = list.get(0).getDictCode();
        return url;
    }
    public String getWXTokenUrl(){
        WlyyHospitalSysDictDO sysDictDO = wlyyHospitalSysDictDao.findById("getXzToken");
        return sysDictDO.getDictCode();
@ -264,7 +272,6 @@ public class XzzxEntranceService{
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("getDoctorInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
@ -277,6 +284,38 @@ public class XzzxEntranceService{
        return json;
    }
    /**
     * 查询医生信息
     * @return
     */
    public String selectDoctorInfo(String idcard)throws Exception{
        String api = "GetDoctorInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(idcard)){
            condition = "<Idcard>"+idcard+"</Idcard>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("getDoctorInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getDoctorInfo json:"+json);
        return json;
    }
    public String findWlyyDoctor(JSONArray doctors)throws Exception{
        logger.info("doctors size:"+doctors.size());
        if(doctors!=null&&doctors.size()>0){
@ -567,14 +606,19 @@ public class XzzxEntranceService{
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("findPatientCard params:"+params.toString());
        wlyyHttpLogDO.setRequest(params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        wlyyHttpLogDO.setResponse(json);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setName("查询患者就诊卡");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info("findPatientCard json:"+json);
        return json;
    }
@ -606,18 +650,72 @@ public class XzzxEntranceService{
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("getCardInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        wlyyHttpLogDO.setResponse(json);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setName("获取卡信息");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info("getCardInfo json:"+json);
        return json;
    }
    /**
     *
     *  发送短信验证码
     *
     * @param json
     * @return
     * @throws Exception
     */
    public String SendSms(String json)throws Exception{
        String api = "SendSms";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(json)){
            JSONObject object = JSONObject.parseObject(json);
            condition = "<content>"+object+"</content>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("SendSms params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateSmsUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String jsonObject = xmlSerializer.read(xml).toString();
        wlyyHttpLogDO.setResponse(jsonObject);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setName("短信验证码发送");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info("SendSms json:"+jsonObject);
        return jsonObject;
    }
    /**
     * 获取单条门诊就诊记录
     * @param patient 居民id
@ -920,12 +1018,19 @@ public class XzzxEntranceService{
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("registered params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        wlyyHttpLogDO.setResponse(json);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setDoctor(doctor);
        wlyyHttpLogDO.setName("挂号(调his后台包)");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info("registered json:"+json);
        return json;
    }
@ -1272,12 +1377,19 @@ public class XzzxEntranceService{
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("savePrescriptionToHospital params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        wlyyHttpLogDO.setResponse(json);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setDoctor(ApplyDoctor);
        wlyyHttpLogDO.setName("互联网医院开处方信息更新到his");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info(" savePrescriptionToHospital json:"+json);
        return json;
    }
@ -1311,12 +1423,12 @@ public class XzzxEntranceService{
        if (!StringUtils.isEmpty(PayCardNo)){
            condition += "<PayCardNo>"+PayCardNo+"</PayCardNo>";
        }
        if (!StringUtils.isEmpty(NullahNumber)){
            condition += "<NullahNumber>"+NullahNumber+"</NullahNumber>";
        }
        if (!StringUtils.isEmpty(ApplyDept)){
            condition += "<ApplyDept>"+ApplyDept+"</ApplyDept>";
        }
        if (!StringUtils.isEmpty(NullahNumber)){
            condition += "<NullahNumber>"+NullahNumber+"</NullahNumber>";
        }
        if (!StringUtils.isEmpty(ApplyDoctor)){
            condition += "<ApplyDoctor>"+ApplyDoctor+"</ApplyDoctor>";
        }
@ -1330,12 +1442,18 @@ public class XzzxEntranceService{
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("delHisPrescriptionByHisNo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        wlyyHttpLogDO.setResponse(json);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setName("互联网医院删除处方信息更新到his");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info("delHisPrescriptionByHisNo json:"+json);
        return json;
    }
@ -1379,14 +1497,19 @@ public class XzzxEntranceService{
        condition+="<ChnDiagnosisName>"+"</ChnDiagnosisName>";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("saveDiagnosis params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        wlyyHttpLogDO.setResponse(json);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setName("保存入门诊断信息到his");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info(" saveDiagnosis json:"+json);
        return json;
    }
@ -1416,14 +1539,19 @@ public class XzzxEntranceService{
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("refundConsultation params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        wlyyHttpLogDO.setResponse(json);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setName("发送退号信息到his");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info("refundConsultation json:"+json);
        return json;
    }
@ -1548,8 +1676,8 @@ public class XzzxEntranceService{
        wlyyHttpLogDO.setDoctor(patientAndDoctor.getString("doctorId"));
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setRequest(postBody);
        wlyyHttpLogDO.setName("合理用药审核接口");
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
        return  res;
    }
    /*
@ -1564,8 +1692,9 @@ public class XzzxEntranceService{
        wlyyHttpLogDO.setDoctor(patientAndDoctor.getString("doctorId"));
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setRequest(postBody);
        wlyyHttpLogDO.setName("合理用药保存接口");
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        return  res;
    }
    /*
@ -1582,7 +1711,8 @@ public class XzzxEntranceService{
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setRequest(postBody);
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
        wlyyHttpLogDO.setName("合理用药作废接口");
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        return  res;
    }
    public List<Map<String,Object>> transXmlCommen(String xml){
@ -1653,6 +1783,9 @@ public class XzzxEntranceService{
        }
        return personInfoVOS;
    }
    public String replaceHtml(String demoData,String oldChar,String newChar){
        return demoData.replace(oldChar,null==newChar?"无":newChar);
    }
    /**
     * 同步门诊病历
     * @return
@ -1672,22 +1805,22 @@ public class XzzxEntranceService{
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("EMRHTMLDEMO");
            if (null!=wlyyHospitalSysDictDO){
                htmlDeo = wlyyHospitalSysDictDO.getDictValue();
                htmlDeo = htmlDeo.replace("@patientName@",jsonObject.getString("patientName"));
                htmlDeo = htmlDeo.replace("@patientAge@",jsonObject.getString("patientAge"));
                htmlDeo = htmlDeo.replace("@patientsex@",jsonObject.getString("patientsex"));
                htmlDeo = htmlDeo.replace("@deptCode@",jsonObject.getString("deptCode"));
                htmlDeo = htmlDeo.replace("@r+outpatientCode@",jsonObject.getString("outpatientCode"));
                htmlDeo = htmlDeo.replace("@patientClan@",jsonObject.getString("patientClan"));
                htmlDeo = htmlDeo.replace("@Special@",prescriptionEmrDO.getSpecialHistory());
                htmlDeo = replaceHtml(htmlDeo,"@patientName@",jsonObject.getString("patientName"));
                htmlDeo = replaceHtml(htmlDeo,"@patientAge@",jsonObject.getString("patientAge"));
                htmlDeo = replaceHtml(htmlDeo,"@patientsex@",jsonObject.getString("patientsex"));
                htmlDeo = replaceHtml(htmlDeo,"@deptCode@",jsonObject.getString("deptCode"));
                htmlDeo = replaceHtml(htmlDeo,"@r+outpatientCode@",jsonObject.getString("outpatientCode"));
                htmlDeo = replaceHtml(htmlDeo,"@patientClan@",jsonObject.getString("patientClan"));
                htmlDeo = replaceHtml(htmlDeo,"@Special@",prescriptionEmrDO.getSpecialHistory());
                SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd hh:MM");
                htmlDeo = htmlDeo.replace("@createTime@",sf.format(prescriptionEmrDO.getCreateTime()));
                htmlDeo = htmlDeo.replace("@complaint@",prescriptionEmrDO.getComplaint());
                htmlDeo = htmlDeo.replace("@medicalHistory@",prescriptionEmrDO.getMedicalHistory());
                htmlDeo = htmlDeo.replace("@popularHistory@",prescriptionEmrDO.getPopularHistory());
                htmlDeo = htmlDeo.replace("@pastHistory@",prescriptionEmrDO.getPastHistory());
                htmlDeo = htmlDeo.replace("@allergicHistory@",prescriptionEmrDO.getAllergicHistory());
                htmlDeo = htmlDeo.replace("@physicalExamination@",prescriptionEmrDO.getPhysicalExamination());
                htmlDeo = htmlDeo.replace("@assistExamination@",prescriptionEmrDO.getAssistExamination());
                htmlDeo = replaceHtml(htmlDeo,"@createTime@",sf.format(prescriptionEmrDO.getCreateTime()));
                htmlDeo = replaceHtml(htmlDeo,"@complaint@",prescriptionEmrDO.getComplaint());
                htmlDeo = replaceHtml(htmlDeo,"@medicalHistory@",prescriptionEmrDO.getMedicalHistory());
                htmlDeo = replaceHtml(htmlDeo,"@popularHistory@",prescriptionEmrDO.getPopularHistory());
                htmlDeo = replaceHtml(htmlDeo,"@pastHistory@",prescriptionEmrDO.getPastHistory());
                htmlDeo = replaceHtml(htmlDeo,"@allergicHistory@",prescriptionEmrDO.getAllergicHistory());
                htmlDeo = replaceHtml(htmlDeo,"@physicalExamination@",prescriptionEmrDO.getPhysicalExamination());
                htmlDeo = replaceHtml(htmlDeo,"@assistExamination@",prescriptionEmrDO.getAssistExamination());
                condition+="<content>"+htmlDeo+"</content>";
            }
        }
@ -1726,10 +1859,177 @@ public class XzzxEntranceService{
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setRequest(msgBody);
        wlyyHttpLogDO.setName("保存电子病历");
        wlyyHttpLogDO.setCreateTime(new Date());
        logger.info("returnEmrHtmlByHLW params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        logger.info("returnEmrHtmlByHLW json:"+xml);
        wlyyHttpLogDO.setResponse(xml);
        return xml;
    }
    /**
     *
     *  获取历史病历
     *
     * @param patientId
     * @param eventNo
     * @return
     * @throws Exception
     */
    public String SelectEmrInfo(String patientId,String eventNo)throws Exception{
        String api = "SelectEmrInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(patientId)){
            condition += "<patientId>"+patientId+"</patientId>";
        }
        if (StringUtils.isNotBlank(eventNo)&&!"null".equalsIgnoreCase(eventNo)){
            condition += "<eventNo>"+eventNo+"</eventNo>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("SelectEmrInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("SelectEmrInfo json:"+json);
        return json;
    }
    /**
     *
     *  获取历史病历
     *
     * @param patientId
     * @param eventNo
     * @return
     * @throws Exception
     */
    public String SelectEmrDispRecord(String templateId,String patientId,String eventNo)throws Exception{
        String api = "SelectEmrDispRecord";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(templateId)){
            condition += "<template_id>"+templateId+"</template_id>";
        }
        if (!StringUtils.isEmpty(patientId)){
            condition += "<patientId>"+patientId+"</patientId>";
        }
        if (!StringUtils.isEmpty(eventNo)){
            condition += "<eventNo>"+eventNo+"</eventNo>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("SelectEmrDispRecord params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
       /* XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();*/
        logger.info("SelectEmrDispRecord json:"+xml);
        return xml;
    }
    /**
     *
     *  查询病历文书列表
     *
     * @param patientId
     * @param eventNo
     * @return
     * @throws Exception
     */
    public String GetEMRList(String patientId,String eventNo)throws Exception{
        String api = "GetEMRList";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(patientId)){
            condition += "<patientId>"+patientId+"</patientId>";
        }
        if (!StringUtils.isEmpty(eventNo)){
            condition += "<eventNo>"+eventNo+"</eventNo>";
        }
        condition +="<lngCatalogID>50</lngCatalogID>";
        condition +="<lngEMRType>93</lngEMRType>";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetEMRList params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
       /* XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();*/
        logger.info("GetEMRList json:"+xml);
        return xml;
    }
    /**
     *
     *  查询病历文书列表
     *
     * @return
     * @throws Exception
     */
    public String BrowseSingleEMR(String bstrEmrID)throws Exception{
        String api = "BrowseSingleEMR";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(bstrEmrID)){
            condition += "<bstrEmrID>"+bstrEmrID+"</bstrEmrID>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("BrowseSingleEMR params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
      /*  XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();*/
        logger.info("BrowseSingleEMR json:"+xml);
        return xml;
    }
//=====================微信模板消息推送===================================
@ -1882,7 +2182,19 @@ public class XzzxEntranceService{
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            if (array!=null&&array.size()!=0){
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                String cardType = jsonObject.getString("CARD_TYPE");
                WlyyHospitalSysDictDO hospitalSysDictDO = wlyyHospitalSysDictDao.findByHospitalAndDictCode("350211A5010",jsonObject.getString("CARD_TYPE"));
                if (hospitalSysDictDO!=null){
                    jsonObject.put("CARD_TYPE",hospitalSysDictDO.getDictValue());
                    jsonObject.put("CARD_TYPE_HIS",cardType);
                }else {
                    jsonObject.put("CARD_TYPE",null);
                    jsonObject.put("CARD_TYPE_HIS",cardType);
                }
            }
            /*if (array!=null&&array.size()!=0){
                JSONObject object1 = array.getJSONObject(0);
                if (patientMappingDO==null){
                    patientMappingDO = new PatientMappingDO();
@ -1896,7 +2208,39 @@ public class XzzxEntranceService{
                    patientMappingDO.setMappingCode(object1.getString("SICKID"));
                }
                patientMappingDao.save(patientMappingDO);
            }
            }*/
            return array;
        }
        return null;
    }
    /**
     * 查询患者就诊卡
     * @param idCard 居民code
     * @return
     */
    public JSONArray selectPateintCardByIdCard(String idCard) throws Exception {
        String response="";
        String url = entranceUrl+"findPatientCard?idCard="+idCard;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            /*if (array!=null&&array.size()!=0){
                JSONObject object1 = array.getJSONObject(0);
                if (patientMappingDO==null){
                    patientMappingDO = new PatientMappingDO();
                    patientMappingDO.setIdcard(patientDO.getIdcard());
                    patientMappingDO.setPatientName(patientDO.getName());
                    patientMappingDO.setPatient(patientDO.getId());
                    patientMappingDO.setCreateTime(new Date());
                    patientMappingDO.setSource("1");
                    patientMappingDO.setMappingCode(object1.getString("SICKID"));
                }else {
                    patientMappingDO.setMappingCode(object1.getString("SICKID"));
                }
                patientMappingDao.save(patientMappingDO);
            }*/
            return array;
        }
        return null;
@ -2000,7 +2344,6 @@ public class XzzxEntranceService{
        }
        return jsonObject;
    }
    public String savePatientMapping(String patient){
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
@ -2030,7 +2373,6 @@ public class XzzxEntranceService{
        }
        return patientMappingDO.getMappingCode();
    }
    public String updatePatientMapping(String patient,String cardNo){
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
@ -2044,7 +2386,9 @@ public class XzzxEntranceService{
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject object1 = array.getJSONObject(i);
                logger.info("判断卡号是否相同:"+object1.getString("CARD_NO")+"cardNo:"+cardNo);
                if (object1.getString("CARD_NO").equalsIgnoreCase(cardNo)){
                    logger.info("卡号相同");
                    if (patientMappingDO==null){
                        patientMappingDO = new PatientMappingDO();
                        patientMappingDO.setIdcard(patientDO.getIdcard());
@ -2069,16 +2413,11 @@ public class XzzxEntranceService{
     * @param patient 居民id
     * @return
     */
    public List<WlyyOutpatientVO> selectOutpatientList(String patient,String startTime,String endTime){
    public List<WlyyOutpatientVO> selectOutpatientList(String patient,String startTime,String endTime,String cardNo) throws Exception {
        List<WlyyOutpatientVO> wlyyOutpatientVOList = new ArrayList<>();
        JSONArray array = new JSONArray();
        String response="";
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO!=null){
            patient = patientMappingDO.getMappingCode();
        }else {
            patient = savePatientMapping(patient);
        }
        patient = updatePatientMapping(patient,cardNo);
        String url = entranceUrl+"findOutpatientInfo?patient="+patient+"&startTime="+startTime+"&endTime="+endTime;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
@ -2423,6 +2762,14 @@ public class XzzxEntranceService{
                    }
                    wlyyPrescriptionVO.setInspectionVOs(wlyyInspectionVOList);
                }
                try {
                    List<WlyyPrescriptionEmrDO> listEmr = selectHistoryEmr(patNo,"");
                    if (null!=listEmr&&listEmr.size()>0){
                        wlyyPrescriptionVO.setWlyyPrescriptionEmrDO(listEmr.get(0));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                prescriptionVOList.add(wlyyPrescriptionVO);
            }
        }
@ -2662,6 +3009,7 @@ public class XzzxEntranceService{
        return jsonArray;
    }
    /**
     * 获取药品字典
     * @param spellCode 拼音码
@ -3043,12 +3391,12 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            if (null!=wlyyOutpatientDO){
                params.put("PayCardNo",wlyyOutpatientDO.getCardNo());
                params.put("NullahNumber",wlyyOutpatientDO.getRegisterNo());
                params.put("ApplyDept",wlyyOutpatientDO.getDept());
                params.put("NullahNumber",wlyyOutpatientDO.getRegisterNo());
            }
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(wlyyPrescriptionDO.getDoctor());
            if (null!=doctorMappingDO){
                params.put("ApplyDoctor",doctorMappingDO.getMappingCode());
                params.put("ApplyDoctor",doctorMappingDO.getDoctorName()+"/"+doctorMappingDO.getMappingCode());
            }
            params.put("ExecuteDept","50100");
            params.put("PresNo",realOrder);
@ -3071,7 +3419,7 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
     * @return
     * @throws Exception
     */
    public JSONObject saveEmrToEntrance(String prescriptionId) throws Exception {
    public String  saveEmrToEntrance(String prescriptionId) throws Exception {
        Map<String,String> params = new HashedMap();
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
        JSONObject paramRequest = new JSONObject();
@ -3084,8 +3432,24 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
            if(null!=patientMappingDO){
                paramRequest.put("patientid",patientMappingDO.getMappingCode());
            }
            //获取医生编号
            BaseDoctorDO doctorDO = doctorDao.findById(wlyyOutpatientDO.getDoctor());
            String operatorId = null;
            if (doctorDO!=null){
                String url = entranceUrl+"selectDoctorInfo?idCard="+doctorDO.getIdcard();
                String response = httpClientUtil.get(url,"GBK");
                JSONObject object = JSONObject.parseObject(response);
                if(object.getInteger("status")==200){
                    String obj = object.getString("obj");
                    JSONArray array = JSONArray.parseArray(obj);
                    if (array!=null&&array.size()!=0){
                        JSONObject jsonObject = array.getJSONObject(0);
                        operatorId = jsonObject.getString("staffNo");
                    }
                }
            }
            if(null!=doctorMappingDO){
                paramRequest.put("operatorid",doctorMappingDO.getMappingCode());
                paramRequest.put("operatorid",operatorId);
                paramRequest.put("operatorname",wlyyPrescriptionDO.getDoctorName());
            }
            paramRequest.put("type","2");
@ -3098,34 +3462,149 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
                paramRequest.put("patientAge",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
                paramRequest.put("patientsex",IdCardUtil.getSexForIdcard(basePatientDO.getIdcard()));
                paramRequest.put("patientName",basePatientDO.getName());
                paramRequest.put("patientClan","0");
            }
                paramRequest.put("patientClan","0"); }
            if (null!=wlyyOutpatientDO){
                paramRequest.put("deptCode",wlyyOutpatientDO.getDept());
                paramRequest.put("outpatientCode","R"+wlyyOutpatientDO.getRegisterNo());
                paramRequest.put("eventno","R"+wlyyOutpatientDO.getRegisterNo());
            }
            paramRequest.put("templateid","662");
            paramRequest.put("templateid","1158");
            paramRequest.put("catalogid","50");
            paramRequest.put("emrtype","0");
            paramRequest.put("emrtype","93");
            paramRequest.put("emrtitle","互联网医院");
        }
        params.put("jsonInfo",paramRequest.toJSONString());
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"returnEmrHtmlByHLW";
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("保存电子病历"+response);
        if (response.contains("error")||response.contains("ERROR")){
            return "faild";
        }else {
            return "success";
        }
    }
    /**
     * 获取历史病历
     * @param patientId 病人id
     * @param eventNo 病人住院号
     * @return
     */
    public List<WlyyPrescriptionEmrDO> selectHistoryEmr(String patientId,String eventNo) throws Exception {
        String response="";
        String url = entranceUrl+"selectEmrInfo?patientId="+patientId+"&eventNo="+eventNo;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        List<WlyyPrescriptionEmrDO> wlyyPrescriptionEmrDOList = new ArrayList<>();
        if(object.getInteger("status")==200){
            jsonObject = object.getJSONObject("obj");
            String obj = object.getString("obj");
            if("[[]]".equalsIgnoreCase(obj)||"[]".equalsIgnoreCase(obj)||StringUtils.isBlank(obj)){
                return null;
            }else {
                logger.info("obj:" + obj);
                JSONArray array = JSONArray.parseArray(obj.replace("[]", "\"\"")).getJSONArray(0);
                logger.info("arrayResponse:" + array.toJSONString());
                for (int i = 0; i < array.size(); i++) {
                    JSONObject jsonObject = array.getJSONObject(i);
                    logger.info("jsonObject:" + jsonObject);
                    WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = new WlyyPrescriptionEmrDO();
                    wlyyPrescriptionEmrDO.setComplaint(null == jsonObject.get("CHIEF_COMPLAINT") ? "" : jsonObject.get("CHIEF_COMPLAINT").toString());
                    wlyyPrescriptionEmrDO.setMedicalHistory(null == jsonObject.get("PRESENT_ILLNESS") ? "" : jsonObject.get("PRESENT_ILLNESS").toString());
                    wlyyPrescriptionEmrDO.setPastHistory(null == jsonObject.get("PAST_HISTORY") ? "" : jsonObject.get("PAST_HISTORY").toString());
                    wlyyPrescriptionEmrDO.setPhysicalExamination(null == jsonObject.get("PHYSICAL_EXAMINATION") ? "" : jsonObject.get("PHYSICAL_EXAMINATION").toString());
                    wlyyPrescriptionEmrDO.setAssistExamination(null == jsonObject.get("OBSERVE_RESULT") ? "" : jsonObject.get("OBSERVE_RESULT").toString());
                    wlyyPrescriptionEmrDO.setAllergicHistory(null == jsonObject.get("ALLERGY_HISTORY") ? "" : jsonObject.get("ALLERGY_HISTORY").toString());
                    wlyyPrescriptionEmrDOList.add(wlyyPrescriptionEmrDO);
                }
            }
        }
        return wlyyPrescriptionEmrDOList;
    }
    /**
     * 查询历次就诊门诊病历文书
     * @param templateId
     * @param patientId 病人id
     * @param eventNo 病人住院号
     * @return
     */
    public String selectHistoryEmrRecord(String templateId,String patientId,String eventNo) throws Exception {
        String response="";
        String url = entranceUrl+"selectEmrDispRecord?templateId="+templateId+"&patientId="+patientId+"&eventNo="+eventNo;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            return obj;
        }else {
            return "获取失败";
        }
    }
    public JSONArray selectHistoryEmrFromEntrance(String patientId,String eventNo) throws Exception {
        String response="";
        JSONArray jsonArray = new JSONArray();
        PatientMappingDO mappingDO = patientMappingDao.findByPatient(patientId);
        String patient = null;
        if (mappingDO!=null){
            patient = mappingDO.getMappingCode();
        }
        String url = entranceUrl+"selectEmrInfo?patientId="+patient+"&eventNo="+eventNo;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        List<WlyyPrescriptionEmrDO> wlyyPrescriptionEmrDOList = new ArrayList<>();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            if("[[]]".equalsIgnoreCase(obj)||"[]".equalsIgnoreCase(obj)||StringUtils.isBlank(obj)){
                return null;
            }else {
            logger.info("obj:"+obj);
            JSONArray array = JSONArray.parseArray(obj.replace("[]","\"\"")).getJSONArray(0);
            logger.info("arrayResponse:"+array.toJSONString());
            for (int j=0;j<array.size();j++){
                JSONObject object1 = array.getJSONObject(j);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("DEPT_NAME",object1.getString("DEPT_NAME"));
                jsonObject.put("TREAT_DATE_TIME",DateUtil.getYyyymmddhhmmss(DateUtil.strToDateLong(object1.getString("VISIT_TIME"))));
                jsonObject.put("OPID",object1.getString("EMR_ID"));
                String firstFlag = object1.getString("FIRST_FLAG");
                if (firstFlag.equalsIgnoreCase("复诊")){
                    jsonObject.put("TREAT_DOCTOR_NAME",object1.getString("RETURN_DOC_SIGN"));
                }else if (firstFlag.equalsIgnoreCase("初诊")){
                    jsonObject.put("TREAT_DOCTOR_NAME",object1.getString("DOCTOR_SIGNATURE"));
                }
                jsonArray.add(jsonObject);
            }
            return jsonArray;
            }
        }else {
            return null;
        }
    }
    /**
     * 查询病历文书html信息
     * @param bstrEmrID
     * @return
     */
    public String selectBrowseSingleEMR(String bstrEmrID) throws Exception {
        String response="";
        String url = entranceUrl+"browseSingleEMR?bstrEmrID="+bstrEmrID;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            return obj;
        }else {
            return "获取失败";
        }
        return jsonObject;
    }
//=====================hospital应用调用entrance应用============end=================
@ -3525,7 +4004,11 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        if (null != patientMappingDO && null != basePatientDO) {
            jsonObject.put("PATIENT_ID", patientMappingDO.getMappingCode());
            jsonObject.put("GENDER", basePatientDO.getSex()==1?"男":"女");
            if (null!=basePatientDO.getSex()){
                jsonObject.put("GENDER", 1==basePatientDO.getSex()?"男":"女");
            }else{
                jsonObject.put("GENDER", "男");
            }
            jsonObject.put("BIRTH", sdf.format(basePatientDO.getBirthday()));
        }
        jsonObject.put("FEE_TYPE", "1".equalsIgnoreCase(payType) ? "医保" : "自费");

+ 70 - 6
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -445,11 +445,10 @@ public class YkyyEntranceService {
        }
        List<WlyyOutpatientVO> wlyyOutpatientVOS = new ArrayList<>();
        WlyyOutpatientVO wlyyOutpatientVO;
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObjectMgsInfo = jsonArray.getJSONObject(i);
            if (null != jsonObjectMgsInfo) {
                wlyyOutpatientVO = new WlyyOutpatientVO();
                WlyyOutpatientVO wlyyOutpatientVO = new WlyyOutpatientVO();
                wlyyOutpatientVO.setHospital(orgCode);
                wlyyOutpatientVO.setHospitalName(orgName);
                wlyyOutpatientVO.setWinNo("6");
@ -484,7 +483,6 @@ public class YkyyEntranceService {
                String conDate = null == jsonObjectMgsInfo.get("KSSJ") ? "" : jsonObjectMgsInfo.get("KSSJ") + "";
                wlyyOutpatientVO.setAdmDate(DateUtil.strToDate(admDate, DateUtil.YYYY_MM_DD_HH_MM_SS_));
                wlyyOutpatientVO.setConDate(DateUtil.strToDate(conDate, DateUtil.YYYY_MM_DD_HH_MM_SS_));
                wlyyOutpatientVOS.add(wlyyOutpatientVO);
                List<WlyyInspectionVO> inspectionVOList = new ArrayList<>();
                JSONArray array = findV_ZKSG_JCCX(PAT_NO,wlyyOutpatientVO.getAdmNo(),demoFlag);
                for (int j=0;j<array.size();j++){
@ -504,7 +502,7 @@ public class YkyyEntranceService {
                    inspectionVOList.add(wlyyInspectionVO);
                }
                wlyyOutpatientVO.setInspectionVOS(inspectionVOList);
                wlyyOutpatientVOS.add(wlyyOutpatientVO);
            }
        }
        return wlyyOutpatientVOS;
@ -532,7 +530,6 @@ public class YkyyEntranceService {
        return new JSONArray();
    }
    /**
     * 查找眼科his 审方失败
     * @throws Exception
@ -880,8 +877,11 @@ public class YkyyEntranceService {
        return wlyyPrescriptionVOList;
    }
    public String updateYkyyDoctor()throws Exception{
    public String updateYkyyDoctor(String idCard)throws Exception{
        String sql ="select y.code AS \"code\",y.name AS \"name\",y.expertise AS \"expertise\",y.introduce AS \"introduce\",y.mobile AS \"mobile\",y.idCard AS \"idcard\",y.jobtitlecode AS \"jobTitleCode\",y.jobTitleName AS \"jobTitleName\",y.dept AS \"dept\",y.deptName AS \"deptName\" from v_Hlw_Ysxx y where y.idcard is not null";
        if (StringUtils.isNoneBlank(idCard)){
            sql +=" and y.idcard ='"+idCard+"' ";
        }
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        HttpResponse response = HttpUtils.doGet(url,params);
@ -1549,6 +1549,70 @@ public class YkyyEntranceService {
        return array;
    }
    /**
     * 获取his病人信息
     * @param medicare
     * @return
     * @throws Exception
     */
    public net.sf.json.JSONArray findHisPatientBymMedicare(String medicare,String mzhm,boolean demoFlag) throws Exception {
        String sql = "SELECT\n" +
                "\tx.brid AS \"brid\",\n" +
                "\tx.mzhm AS \"mzhm\",\n" +
                "\tx.brxm AS \"brxm\",\n" +
                "\tx.sfzh AS \"sfzh\",\n" +
                "\tx.brxz AS \"brxz\",\n" +
                "\tx.brxb AS \"brxb\",\n" +
                "\tx.csny as \"csny\",\n" +
                "\tx.jzkh AS \"jzkh\",\n" +
                "\tx.jdsj AS \"jdsj\",\n" +
                "\tx.sjhm AS \"sjhm\",\n" +
                "\tx.fzxmc AS \"fzxmc\",\n" +
                "\tx.gzztmc AS \"gzztmc\",\n" +
                "\tx.lxdz AS \"lxdz\"\n" +
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE 1=1" ;
        if (StringUtils.isNotBlank(medicare)&&StringUtils.isNotBlank(mzhm)){
            sql+=" and (x.jzkh = '"+medicare+"' or x.mzhm = '"+mzhm+"')";
        }else if (StringUtils.isNotBlank(medicare)&&!StringUtils.isNotBlank(mzhm)){
            sql+=" and x.jzkh = '"+medicare+"' ";
        }else if (!StringUtils.isNotBlank(medicare)&&StringUtils.isNotBlank(mzhm)){
            sql+=" and x.mzhm = '"+mzhm+"' ";
        }else {
            sql+=" and x.brid is is null";
        }
        net.sf.json.JSONArray array = new net.sf.json.JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("idcard:"+sql);
        if (demoFlag){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("brid","1168517");
            jsonObject.put("mzhm","0502452155");
            jsonObject.put("brxm","于小童");
            jsonObject.put("sfzh","450521199405092535");
            jsonObject.put("brxz","自费");
            jsonObject.put("brxb","男");
            jsonObject.put("csny","1994-05-09");
            jsonObject.put("jzkh","2396501");
            jsonObject.put("jdsj","2020-06-28 15:15:35");
            jsonObject.put("gzztmc","一般");
            jsonObject.put("lxdz","厦门市五缘湾");
            array.add(jsonObject);
        }else  {
            HttpResponse response = HttpUtils.doGet(url,params);
            String content = response.getContent();
            logger.info("response:"+content);
            net.sf.json.JSONObject rs = net.sf.json.JSONObject.fromObject(content);
            Integer status = rs.getInt("status");
            if (status==200){
                array = rs.getJSONArray("detailModelList");
            }
        }
        return array;
    }
    /**

+ 97 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java

@ -440,6 +440,23 @@ public class YkyyService {
        logger.info("获取眼科通忘记密码信息:"+response);
        return response;
    }
    /**获取眼科通忘记密码信息
     *
     * @param tel
     * @param password
     * @param vercode
     * @return
     */
    public String  updatePatientPassword(String tel,String password,String vercode){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginid",tel);
        jsonObject.put("password",password);
        String url = "http://www.yanketong.com:90/api/Patient/ForgotPassword4Jkzl";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("获取眼科通忘记密码信息:"+response);
        return response;
    }
    /**
     * 同步眼科通数据
@ -644,4 +661,84 @@ public class YkyyService {
    }
    /**
     * 医生端眼科通登陆
     * @param loginId 账户
     * @param password 密码
     * @return
     */
    public String DoctorLogin(String loginId,String password){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginId",loginId);//账户
        jsonObject.put("password",password);//密码
        String url = "http://www.yanketong.com:90/api/Doctor/DoctorLogin";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("医生端登陆:"+response);
        return response;
    }
    /*
     *查询眼科通家人关系
     */
    public String findYktFamily(String yktUserId){
        String response="";
        String url="http://www.yanketong.com:133/api/doc_jkzl/get_family_list?";
        url+="user_id="+yktUserId;
        logger.info("查询眼科通家人关系="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("查询眼科通家人关系结果"+response);
        return response;
    }
    /*
     *删除家人关系
     */
        public String deleteYktFamily(String yktFamilyId){
        String response="";
        String url="http://www.yanketong.com:133/api/patient/delete_family?";
        url+="id="+yktFamilyId;
        logger.info("删除眼科通家人关系="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("删除眼科通家人关系结果"+response);
        return response;
    }
    //添加家人关系
    public String addYktFamily(String name,String id_card,String sex,String age,String tel,String medical_card,String illness,String clinic_id,String ass_user_id,String birth){
        String response="";
        String url="http://www.yanketong.com:133/api/doc_jkzl/add_family?";
        url+="name="+name;
        url+="&id_card="+id_card;
        url+="&sex="+sex;
        url+="&age="+age;
        url+="&tel="+tel;
        url+="&medical_card="+medical_card;
        url+="&illness="+illness;
        url+="&clinic_id="+clinic_id;
        url+="&ass_user_id="+ass_user_id;
        url+="&birth="+birth;
        logger.info("添加眼科通家人关系="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("添加眼科通家人关系结果"+response);
        return response;
    }
    //修改家人关系
    public String updateYktFamily(String name,String id_card,String sex,String age,String tel,String medical_card,String illness,String clinic_id,String id,String birth){
        String response="";
        String url="http://www.yanketong.com:133/api/patient/update_family?";
        url+="name="+name;
        url+="&id_card="+id_card;
        url+="&sex="+sex;
        url+="&age="+age;
        url+="&tel="+tel;
        url+="&medical_card="+medical_card;
        url+="&illness="+illness;
        url+="&clinic_id="+clinic_id;
        url+="&id="+id;
        url+="&birth="+birth;
        logger.info("修改眼科通家人关系="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("修改眼科通家人关系结果"+response);
        return response;
    }
}

+ 42 - 40
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java

@ -92,7 +92,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
    public String orgSub ;
    public String imgUrl;
    static String imgPath =File.separator+"data1"+File.separator+"ehr"+File.separator+"svr-internet-hospital-job"+File.separator+"img"+File.separator;
    static String imgPath =File.separator+"usr"+File.separator+"local"+File.separator+"hospital"+File.separator+"svr-internet-hospital-job"+File.separator+"img"+File.separator;
    public ObjectMapper objectMapper;
@ -361,7 +361,11 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("belong_dept_name", info.get("dept_name"));
                jb.put("doo_tel", info.get("mobile")== null ? "":info.get("mobile"));
                jb.put("title_rec_date", getDateString(info.get("fzrq").toString()));
                jb.put("prac_type", "1");   // 因为上传的是医师的信息,所以该字段全部默认设置为 1 医师
                if (info.get("idcard").toString().equalsIgnoreCase("350524198906247742")){
                    jb.put("prac_type", "2");   // 因为上传的是医师的信息,所以该字段全部默认设置为 1 医师
                }else {
                    jb.put("prac_type", "1");   // 因为上传的是医师的信息,所以该字段全部默认设置为 1 医师
                }
                jb.put("title_code", dutyInfo.length>=1?dutyInfo[0]:"");  // 需要与监管平台的字典进行映射
                jb.put("first_compeny_code", orgCode);
                jb.put("first_compeny_name", orgName);
@ -673,49 +677,47 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
            Boolean errorFlag = false;
            JSONObject jb = new JSONObject();
            String interId = "";
            try{
                String idCard = info.get("docIdCard") == null ? "0":info.get("docIdCard").toString();
                if( info.get("docIdCard") == null){
                    interId = "0";
                }else {
                    interId = achNsDoctorRecord(idCard);
                }
            String idCard = info.get("docIdCard") == null ? "0":info.get("docIdCard").toString();
            if( info.get("docIdCard") == null){
                interId = "0";
            }else {
                interId = achNsDoctorRecord(idCard);
                try{
//                String[] dept = depToSubject(info.get("dept_code").toString());
                jb.put("id",interId +"_"+ (String)info.get("relationCode"));
                jb.put("id_doctor",interId == null ? "0":interId);
                jb.put("organ_code",orgCode);
                jb.put("organ_name", orgName);
                jb.put("net_service", "4");
                jb.put("net_service_name","在线复诊");
                jb.put("val_score",info.get("score") == null ? "0": info.get("score"));
                jb.put("grader",info.get("patient_name") == null ? "0": info.get("patient_name"));
                jb.put("dt_grade",DateUtil.dateToStrLong((Date)info.get("create_time")));
                jb.put("grade_content", info.get("content") == null ? "0": info.get("content"));
                jb.put("crt_date", DateUtil.dateToStrLong(DateUtil.getNow()));
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"7",(String)info.get("id"),"医生评价信息格式错误",2);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                if (!interId.equalsIgnoreCase("0")&&!interId.equalsIgnoreCase("")){
                    JSONArray jsonArray = new JSONArray();
                    jsonArray.add(jb);
                    res = postToInter(token,api, jsonArray,url);
                    JSONObject resJson = (JSONObject) JSONObject.parse(res);
                    if("200".equals(resJson.get("msg").toString())){
                        success++;
                    }else{
                        saveErrorLog(upid,"7",info.get("id").toString(),res,2);
                        error++;
                    jb.put("id",interId +"_"+ (String)info.get("relationCode"));
                    jb.put("id_doctor",interId == null ? "0":interId);
                    jb.put("organ_code",orgCode);
                    jb.put("organ_name", orgName);
                    jb.put("net_service", "4");
                    jb.put("net_service_name","在线复诊");
                    jb.put("val_score",info.get("score") == null ? "0": info.get("score"));
                    jb.put("grader",info.get("patient_name") == null ? "0": info.get("patient_name"));
                    jb.put("dt_grade",DateUtil.dateToStrLong((Date)info.get("create_time")));
                    jb.put("grade_content", info.get("content") == null ? "0": info.get("content"));
                    jb.put("crt_date", DateUtil.dateToStrLong(DateUtil.getNow()));
                }catch (Exception e){
                    errorFlag = true;
                    saveErrorLog(upid,"7",(String)info.get("id"),"医生评价信息格式错误",2);
                    dataError++;
                    logger.error(e.toString());
                }
                if(!errorFlag){
                    if (!interId.equalsIgnoreCase("0")&&!interId.equalsIgnoreCase("")){
                        JSONArray jsonArray = new JSONArray();
                        jsonArray.add(jb);
                        res = postToInter(token,api, jsonArray,url);
                        JSONObject resJson = (JSONObject) JSONObject.parse(res);
                        if("200".equals(resJson.get("msg").toString())){
                            success++;
                        }else{
                            saveErrorLog(upid,"7",info.get("id").toString(),res,2);
                            error++;
                        }
                    }
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"7",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 937 - 838
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetService.java


+ 99 - 52
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -149,12 +149,12 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(wlyyPrescriptionDO.getId());
            if (businessOrderDO==null){
            if (businessOrderDO==null) {
                businessOrderDO = new BusinessOrderDO();
                businessOrderDO.setCreateTime(new Date());
                businessOrderDO.setUpdateTime(new Date());
                businessOrderDO.setStatus(0);
                businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
                businessOrderDO.setOrderNo("HLWYY" + System.currentTimeMillis() + (int) (Math.random() * 900) + 100);
                businessOrderDO.setUploadStatus(0);
                businessOrderDO.setPayType(1);
                businessOrderDO.setRelationCode(code);
@ -175,49 +175,58 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                wlyyPrescriptionDO.setOrderId(getCode());
                wlyyPrescriptionDO = prescriptionDao.save(wlyyPrescriptionDO);
                JSONArray array = new JSONArray();
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(code,1);
                for (WlyyPrescriptionInfoDO prescriptionInfoDO:wlyyPrescriptionInfoDOS){
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(code, 1);
                WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
                for (WlyyPrescriptionInfoDO prescriptionInfoDO : wlyyPrescriptionInfoDOS) {
                    JSONObject object = new JSONObject();
                    //{"commodityName":"","commodityPrice":"","DrugUnit":"","MedicineDoctor":""}
                    object.put("commodityName",prescriptionInfoDO.getDrugName());
                    object.put("commodityPrice",prescriptionInfoDO.getPackRetprice());
                    object.put("DrugUnit",prescriptionInfoDO.getPackUnitName());
                    object.put("commodityName", prescriptionInfoDO.getDrugName());
                    object.put("commodityPrice", prescriptionInfoDO.getPackRetprice());
                    object.put("DrugUnit", prescriptionInfoDO.getPackUnitName());
                    DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
                    String yktDoctor ="";
                    if (doctorMappingDO!=null&&StringUtils.isNoneBlank(doctorMappingDO.getMappingCode())){
                        String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
                        JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
                        if (jsonObject.getInteger("code")==200){
                            JSONArray array1 = jsonObject.getJSONArray("data");
                            if (array1!=null&&array1.size()!=0){
                                yktDoctor=array1.getJSONObject(0).getString("DOCTORUSERID");
                    String yktDoctor = "";
                    if (doctorMappingDO != null && StringUtils.isNoneBlank(doctorMappingDO.getMappingCode())) {
                        System.out.println("----------------"+hospitalSysDictDO.getDictValue());
                        if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                        } else {
                            String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
                            JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
                            if (jsonObject.getInteger("code") == 200) {
                                JSONArray array1 = jsonObject.getJSONArray("data");
                                if (array1 != null && array1.size() != 0) {
                                    yktDoctor = array1.getJSONObject(0).getString("DOCTORUSERID");
                                }
                            }
                        }
                    }else {
                    } else {
                        throw new Exception("医生映射表不存在!");
                    }
                    object.put("MedicineDoctor",yktDoctor);
                    object.put("MedicineDoctor", yktDoctor);
                    array.add(object);
                }
                BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
                String userId =null;
                if (patientDO!=null){
                String userId = null;
                if (patientDO != null) {
                    userId = patientDO.getUserId();
                }
                String response = ykyyService.addOrder4Jkzl("1",wlyyPrescriptionDO.getOrderId(),businessOrderDO.getOrderNo(),userId,array);
                if (StringUtils.isNoneBlank(response)){
                    JSONObject jsonObject = JSONObject.parseObject(response);
                    if (jsonObject.getString("code").equalsIgnoreCase("10000")){
                        String orderId = jsonObject.getString("orderId");
                        String orderNo = jsonObject.getString("orderNo");
                        businessOrderDO.setYkOrderId(orderId);
                        businessOrderDO.setYkOrderNo(orderNo);
                        businessOrderDO.setUploadStatus(1);
                        businessOrderDao.save(businessOrderDO);
                if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                } else {
                    String response = ykyyService.addOrder4Jkzl("1", wlyyPrescriptionDO.getOrderId(), businessOrderDO.getOrderNo(), userId, array);
                    if (StringUtils.isNoneBlank(response)) {
                        JSONObject jsonObject = JSONObject.parseObject(response);
                        if (jsonObject.getString("code").equalsIgnoreCase("10000")) {
                            String orderId = jsonObject.getString("orderId");
                            String orderNo = jsonObject.getString("orderNo");
                            businessOrderDO.setYkOrderId(orderId);
                            businessOrderDO.setYkOrderNo(orderNo);
                            businessOrderDO.setUploadStatus(1);
                            businessOrderDao.save(businessOrderDO);
                        }
                    }
                }
            }
        }
        return businessOrderDOS;
    }
@ -242,6 +251,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            businessOrderDO.setPcCallbackUrl("https://intel.yanketong.com/ims-web/#/yk/consult/record?outpatientId="+businessOrderDO.getRelationCode()+"&verifyCode=");
        }
        List<WlyyHospitalSysDictDO> hospitalSysDictDOS = hospitalSysDictDao.findByDictName("WX_MONEY");
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
        String totalFee = null;
        if (hospitalSysDictDOS!=null&&hospitalSysDictDOS.size()!=0){
            totalFee= hospitalSysDictDOS.get(0).getDictValue();
@ -255,7 +265,11 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (StringUtils.isNoneBlank(basePatientDO.getYktId())){
            patientId = basePatientDO.getYktId();
        }else {
            patientId = ykyyService.registerYkt(basePatientDO.getId());
            if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
            } else {
                patientId = ykyyService.registerYkt(basePatientDO.getId());
            }
        }
        String orderAmout = businessOrderDO.getPayPrice()/100+"";
        String description = businessOrderDO.getDescription();
@ -268,25 +282,36 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        String pcCallBack=businessOrderDO.getPcCallbackUrl();
        String appCallBack = businessOrderDO.getAppCallbackUrl();
        String yktDoctor ="";
        if (doctorMappingDO!=null&&StringUtils.isNoneBlank(doctorMappingDO.getMappingCode())){
            String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
            JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
            if (jsonObject.getInteger("code")==200){
                JSONArray array = jsonObject.getJSONArray("data");
                if (array!=null&&array.size()!=0){
                    yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
            if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
            } else {
                String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
                System.out.println("Continue");
                JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
                if (jsonObject.getInteger("code")==200){
                    JSONArray array = jsonObject.getJSONArray("data");
                    if (array!=null&&array.size()!=0){
                        yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
                    }
                }
            }
        }else {
            /*throw new Exception("医生映射表不存在!");*/
            yktDoctor="hlwyymrys001";
        }
        String remark = businessOrderDO.getRematk();
        String response=ykyyService.addYktOrder(orderNo,patientId,orderAmout,remark,state,orderType,yktDoctor,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("code")==200){
            businessOrderDO.setUploadStatus(1);
            businessOrderDao.save(businessOrderDO);
        if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
        } else {
            String response=ykyyService.addYktOrder(orderNo,patientId,orderAmout,remark,state,orderType,yktDoctor,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
            JSONObject object = JSONObject.parseObject(response);
            if (object.getInteger("code")==200){
                businessOrderDO.setUploadStatus(1);
                businessOrderDao.save(businessOrderDO);
            }
        }
        return businessOrderDO;
    }
@ -335,7 +360,13 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (doctorMappingDO!=null){
            doctorId = doctorMappingDO.getMappingCode();
        }
        ykyyService.addYktOrder(orderNo,patientId,orderAmout,description,state,orderType,doctorId,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
        if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
        } else {
            ykyyService.addYktOrder(orderNo,patientId,orderAmout,description,state,orderType,doctorId,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
        }
        return map;
    }
@ -708,6 +739,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            //更改业务状态,做日志保存等操作
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(seqNo);
            businessOrderDO.setPayTime(DateUtil.strToDate(timeEnd,DateUtil.YYYY_MM_DD_HH_MM_SS));
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
            if (businessOrderDO!=null){
                if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")){
                    ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
@ -770,20 +802,29 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                    }
                }else if (businessOrderDO!=null&&businessOrderDO.getOrderCategory().equalsIgnoreCase("5")){
                    String price = Integer.parseInt(totalFee)/100+"";
                    if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                    if (businessOrderDO.getOrderType()==10){
                        String re = ykyyService.upRecharge4Jkzl(businessOrderDO.getYkOrderNo(), Integer.parseInt(price), 0);
                        logger.info("调用结果="+re);
                    }
                    if (businessOrderDO.getOrderType()==11){
                        String re = ykyyService.upRecharge4Jkzl(businessOrderDO.getYkOrderNo(), Integer.parseInt(price), 1);
                        logger.info("调用结果="+re);
                    } else {
                        if (businessOrderDO.getOrderType()==10){
                            String re = ykyyService.upRecharge4Jkzl(businessOrderDO.getYkOrderNo(), Integer.parseInt(price), 0);
                            logger.info("调用结果="+re);
                        }
                        if (businessOrderDO.getOrderType()==11){
                            String re = ykyyService.upRecharge4Jkzl(businessOrderDO.getYkOrderNo(), Integer.parseInt(price), 1);
                            logger.info("调用结果="+re);
                        }
                    }
                }
            }
            if (businessOrderDO!=null&&!businessOrderDO.getOrderCategory().equalsIgnoreCase("5")&&businessOrderDO.getStatus()!=1){
                ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"1");
                if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                } else {
                    ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"1");
                }
            }
            businessOrderDO.setStatus(1);
            businessOrderDao.save(businessOrderDO);
@ -1357,7 +1398,13 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        businessOrderDO.setPayType(5);
        businessOrderDao.save(businessOrderDO);
        String totalFee =(int)(businessOrderDO.getPayPrice()*100)+"";
        return ykyyService.getPayCDATA4Jkzl(businessOrderDO.getRematk(),businessOrderDO.getOrderNo(),totalFee,serverIp,notifyUrl);
        WlyyHospitalSysDictDO hospitalSysD2ictDO = hospitalSysDictDao.findById("YKTCONTROL");
        if (null != hospitalSysD2ictDO && "0".equalsIgnoreCase(hospitalSysD2ictDO.getDictValue())) {
            return null;
        } else {
            return ykyyService.getPayCDATA4Jkzl(businessOrderDO.getRematk(),businessOrderDO.getOrderNo(),totalFee,serverIp,notifyUrl);
        }
    }

+ 7 - 3
business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java

@ -268,7 +268,6 @@ public class YlzPayService {
        String encryptType = oauthYlzConfigDO.getEncType();
        HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
        JSONObject jsonObject = new JSONObject();
        Double free = Double.parseDouble(fee);
        try {
            jsonObject.put("cardType",cardType);//卡类型01 社保卡 06 临时卡
            jsonObject.put("cardNo",cardNo);//卡号
@ -282,8 +281,13 @@ public class YlzPayService {
            jsonObject.put("applyDepaName",applyDepaName);//申请科室名称
            jsonObject.put("applyDoctorName",applyDoctorName);//申请医生姓名
            jsonObject.put("recipeTime",recipeTime);//处方时间yyyyMMddHHmmss
            jsonObject.put("fee",free);//总费用
            jsonObject.put("recipeNum",recipeNum);//处方数
            if (StringUtils.isNoneBlank(fee)){
                Double free = Double.parseDouble(fee);
                jsonObject.put("fee",free);//总费用
            }
            if (StringUtils.isNoneBlank(recipeNum)){
                jsonObject.put("recipeNum",recipeNum);//处方数
            }
            System.out.println("推送模板消息参数"+jsonObject.toJSONString());
            //jsonObject.put("extra")
            ResponseParams<MmpPushResult> response = onepayClient.mmpMsgPush(jsonObject);

+ 22 - 3
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -14,6 +15,7 @@ import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.repository.CrudRepository;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -55,7 +57,10 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private YkyyService ykyyService;
    @Value("${wechat.id}")
    private String wxId;
    /**
     * 居民id
@ -239,11 +244,25 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    public Boolean updatePatientPw(String id,String pw,String orgPw){
        BasePatientDO patientDO = basePatientDao.findOne(id);
      /*  String orgPwMd5 = MD5.md5Hex(orgPw + "{" + patientDO.getSalt() + "}");
        String orgPwMd5 = MD5.md5Hex(orgPw + "{" + patientDO.getSalt() + "}");
        if(!orgPwMd5.equals(patientDO.getPassword())){
            return false;
        }*/
        }
        //认证信息设置
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            String response =ykyyService.updatePatientPassword(patientDO.getMobile(),pw,"");
            if (StringUtils.isNoneBlank(response)&&response.contains("10000")){
                String salt = randomString(5);
                patientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patientDO.setSalt(salt);
                basePatientDao.save(patientDO);
                /*//设置更新时间
                saveDoctorPwlimitDate(id);*/
                return true;
            }
        }
        String salt = randomString(5);
        patientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
        patientDO.setSalt(salt);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 773 - 431
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java


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

@ -248,6 +248,31 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
     * ca标识
     */
    private Integer caFlag;
    /**
     *身份验证秘钥
     */
    private String verifyCode;
    /**
     *眼科同医生id
     */
    private String yktDoctorId;
    @Column(name = "YKT_DOCTOR_ID")
    public String getYktDoctorId() {
        return yktDoctorId;
    }
    public void setYktDoctorId(String yktDoctorId) {
        this.yktDoctorId = yktDoctorId;
    }
    @Column(name = "verify_code")
    public String getVerifyCode() {
        return verifyCode;
    }
    public void setVerifyCode(String verifyCode) {
        this.verifyCode = verifyCode;
    }
    @Column(name = "popularity")
    public Integer getPopularity() {

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -242,6 +242,15 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String register;
    private String phone;
    private String openid;
    @Column(name = "openid")
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
    /**
     * 上线下线状态

+ 19 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/family/WlyyPatientFamilyMemberDO.java

@ -38,6 +38,25 @@ public class WlyyPatientFamilyMemberDO extends UuidIdentityEntityWithOperator {
    private String cardType;
    private String cardNo;
    private String yktFamilyId;
    private String clinicid;
    public String getClinicid() {
        return clinicid;
    }
    public void setClinicid(String clinicid) {
        this.clinicid = clinicid;
    }
    public String getYktFamilyId() {
        return yktFamilyId;
    }
    public void setYktFamilyId(String yktFamilyId) {
        this.yktFamilyId = yktFamilyId;
    }
    public String getCardType() {
        return cardType;
    }

+ 24 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java

@ -266,7 +266,31 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
     * 处方号
     */
    private String realOrder;
    /**
     * 金额
     */
    private Double fee;
    /**
     * 处方号
     */
    private String chargeType;
    @Column(name = "charge_type")
    public String getChargeType() {
        return chargeType;
    }
    public void setChargeType(String chargeType) {
        this.chargeType = chargeType;
    }
    @Column(name = "fee")
    public Double getFee() {
        return fee;
    }
    public void setFee(Double fee) {
        this.fee = fee;
    }
    @Column(name = "remind_count")
    public Integer getRemindCount() {

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

@ -483,8 +483,12 @@ public class BaseHospitalRequestMapping {
        public static final String saveEmrToEntrance="/saveEmrToEntrance";
        //处方管理
        public static final String prescriptionManage="/prescriptionManage";
        public static final String findEmrByPrescriptionId="/findEmrByPrescriptionId";
        //作废处方
        public static final String disablePrescription="/disablePrescription";
        /*
        关注医生信息

+ 18 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyOutpatientVO.java

@ -228,8 +228,26 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
    @ApiModelProperty(value = "代接诊人手机号", example = "代接诊人手机号")
    private String consumerMobile;
    @ApiModelProperty(value = "费用", example = "费用")
    private Double fee;
    @ApiModelProperty(value = "号别", example = "号别")
    private String chargeType;
    public Double getFee() {
        return fee;
    }
    public void setFee(Double fee) {
        this.fee = fee;
    }
    public String getChargeType() {
        return chargeType;
    }
    public void setChargeType(String chargeType) {
        this.chargeType = chargeType;
    }
    public String getAdmNo() {
        return admNo;

+ 6 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -163,6 +163,12 @@ public class DateUtil {
        return formatter.format(currentTime);
    }
    public static String getYyyymmddhhmmss(Date date) {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat(YYYYMMDDHHMMSS);
        return formatter.format(currentTime);
    }
    /**
     * 获取现在时间
     *

+ 10 - 4
common/common-util/src/main/java/com/yihu/jw/util/wechat/WeixinMessagePushUtils.java

@ -1,15 +1,16 @@
package com.yihu.jw.util.wechat;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.entity.base.wx.Miniprogram;
import com.yihu.jw.entity.base.wx.WechatTemplateDO;
import com.yihu.jw.entity.base.wx.WechatTemplateDataDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@ -86,7 +87,12 @@ public class WeixinMessagePushUtils {
        //发送微信模板地址
        String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+token;
        //微信消息参数
        String params = getWxParam(mes);
        String params = null;
        if(StringUtils.isNoneBlank(wxtemp.getFirst())){
            params = getWxParam(mes);
        }else {
            params = wxtemp.getRemark();
        }
        if(StringUtils.isBlank(params)){
            logger.info("wechat params is null");
            return false;

+ 1 - 1
gateway/ag-basic/pom.xml

@ -12,7 +12,7 @@
    <artifactId>ag-basic</artifactId>
    <version>${parent.version}</version>
    <packaging>war</packaging>
    <packaging>jar</packaging>
    <dependencies>
        <!-- 支持Tomcat启动 -->

+ 2 - 1
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -103,7 +103,8 @@ public class BasicZuulFilter extends ZuulFilter {
                || url.contains("/sms_gateway/send")//发送短信
                || url.contains("/accountAppeal/create")
                || url.contains("/open/")//开放接口
                || url.contains("/image/")) {//获取默认图片
                || url.contains("/image/")//获取默认图片
                ||url.contains("/weixin")) {
            return true;
        }
        System.out.println("进入token验证");

+ 25 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -3,9 +3,11 @@ package com.yihu.jw.security.core.userdetails.jdbc;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.dao.patient.BasePatientWechatDao;
import com.yihu.jw.security.dao.patient.WlyyPatientFamilyMemberDao;
import com.yihu.jw.security.model.WlyyUserDetails;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.security.utils.IdCardUtil;
@ -86,6 +88,9 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private WlyyPatientFamilyMemberDao familyMemberDao;
    public WlyyUserDetailsService(DataSource dataSource) {
        this.setDataSource(dataSource);
    }
@ -171,6 +176,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
            users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class),username,getIdcard());
            if (null == users || users.size() == 0) {
                String idcard = null;
                //厦门I健康账号同步
                if("xm_ihealth_wx".equals(getWechatId())){
                    List<NameValuePair> params = new ArrayList<>();
@ -197,7 +203,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                    try {
                        String salt = randomString(5);
                        String idcard = patient.getString("idcard");
                        idcard = patient.getString("idcard");
                        String pw = idcard.substring(idcard.length()-6);
                        this.getJdbcTemplate().update(DEFAULT_PATIENT_INSERT_STATEMENT,
@ -279,6 +285,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                    if (null != object1&&null!=object1.get("status") && "200".equals(object1.get("status").toString())) {
                        JSONObject patient = object1.getJSONObject("userinfo");
                        String salt = randomString(5);
                        idcard = patient.getString("idcard");
                        String mobile = patient.getString("mobile");
                        String pw = mobile.substring(mobile.length()-6);
                        try {
@ -335,6 +342,22 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                    }
                }
                BasePatientDO patientDO = patientDao.findByIdcardAndDel(idcard,"1");
                WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patientDO.getId(),"7");
                if (basePatientFamilyMemberDO==null){
                    basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                    basePatientFamilyMemberDO.setPatient(patientDO.getId());
                    basePatientFamilyMemberDO.setFamilyRelation("7");
                    basePatientFamilyMemberDO.setFamilyRelationName("自己");
                    basePatientFamilyMemberDO.setCardType("身份证");
                    basePatientFamilyMemberDO.setCardNo(patientDO.getIdcard());
                    basePatientFamilyMemberDO.setCreateTime(new Date());
                    basePatientFamilyMemberDO.setUpdateTime(new Date());
                    basePatientFamilyMemberDO.setIsAuthorize(1);
                    basePatientFamilyMemberDO.setIsDel(1);
                    basePatientFamilyMemberDO.setFamilyMember(patientDO.getId());
                    familyMemberDao.save(basePatientFamilyMemberDO);
                }
            }
        }
        return users;
@ -547,7 +570,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String wechatId = request.getParameter("wechat_id");
        String wechatId = request.getParameter("wechatId");
        return wechatId;
    }

+ 14 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/patient/WlyyPatientFamilyMemberDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.security.dao.patient;
import com.yihu.jw.entity.hospital.family.BasePatientMemberDictDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface WlyyPatientFamilyMemberDao extends PagingAndSortingRepository<WlyyPatientFamilyMemberDO, String>, JpaSpecificationExecutor<WlyyPatientFamilyMemberDO> {
    @Query("from WlyyPatientFamilyMemberDO t where t.patient = ?1 and t.familyRelation =?2 and t.isDel = 1 ")
    WlyyPatientFamilyMemberDO findFamilyMemberByPatientAndRelationCode(String patient,String familyRelation);
}

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

@ -32,6 +32,7 @@ import com.yihu.utils.security.MD5;
import com.yihu.utils.security.RSAUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -508,6 +509,62 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        throw new IllegalStateException("验证码发送失败!");
    }
    /**
     * 心脏医院短信接口
     * @param parameters
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/sendXZCaptcha", method = RequestMethod.GET)
    public ResponseEntity<Oauth2Envelop<Captcha>> sendXZCaptcha(@RequestParam Map<String, String> parameters) throws Exception {
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
        }
        if (username.length()>12){
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        //验证请求间隔超时,防止频繁获取验证码
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(client_id, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        //发送短信获取验证码
        String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
        JSONObject object = new JSONObject();
        object.put("operatetel","18788888888");
        object.put("interfaceid","jcpt");
        object.put("interfacepwd","jcpt");
        object.put("operator","xxgwxgzh");
        object.put("operateid","xxgwxgzh");
        JSONArray array = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("content","您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。");
        jsonObject.put("sendtel",username);
        jsonObject.put("sendtime",DateUtil.dateToStrLong(new Date()));
        array.add(jsonObject);
        object.put("messageinfo",array);
        int result =  xzzxService.SendSms(object.toJSONString());
        if (0 == result) {
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setExpiresIn(300);
            wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, null);
            HttpHeaders headers = new HttpHeaders();
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }
        throw new IllegalStateException("验证码发送失败!");
    }
    @RequestMapping(value = "/oauth/sendCaptcha", method = RequestMethod.GET)
    public ResponseEntity<Oauth2Envelop<Captcha>> sendCaptcha(@RequestParam Map<String, String> parameters) throws Exception {
        String wxId = parameters.get("wxId");
@ -515,6 +572,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
           return sendYKCaptcha(parameters);
        }else if("xm_zsyy_wx".equals(wxId)){
           return sendZSCaptcha(parameters);
        }else if ("xm_xzzx_wx".equals(wxId)){
            return sendXZCaptcha(parameters);
        }
        throw new IllegalStateException("验证码发送失败");
    }
@ -525,6 +584,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        String type = parameters.get("type");
        String isDoctor = parameters.get("isDoctor");
        String msg="";
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
@ -535,31 +596,89 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(client_id, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        //发送短信获取验证码
        String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
        ResultMsg result= null;
        if(StringUtils.isEmpty(type)){
            result =  ykyySMSService.ykyySendSMS(username,"您好,您的手机登录短信验证码是:"+captcha+",5分钟内有效。");
        }else if("1".equals(type)){
            result = ykyySMSService.ykyySendSMS(username,"您好,您的手机登录短信验证码是:"+captcha+",5分钟内有效。");
        }else if("2".equals(type)){
            result = ykyySMSService.ykyySendSMS(username,"您好,您正在进行找回密码操作,您的短信验证码是:"+captcha+",请勿将验证码告诉他人,5分钟内有效。");
        }
        if (result.isSuccess()) {
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setExpiresIn(300);
            wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
        if ("1".equalsIgnoreCase(isDoctor)){
            String res = ykyyService.getResetCode("4",username);
            String resltCode ="";
            String captcha = "";
            if (!StringUtils.isEmpty(res)){
                JSONObject jsonObject = JSONObject.parseObject(res);
                if ("10000".equalsIgnoreCase(jsonObject.getString("code"))){
                    captcha = jsonObject.getString("value");
                    resltCode = jsonObject.getString("code");
                }
            }
            if ("10000".equalsIgnoreCase(resltCode)) {
                Captcha _captcha = new Captcha();
                _captcha.setCode(captcha);
                _captcha.setExpiresIn(300);
                wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
                Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
            throw new IllegalStateException("验证码发送失败!");
            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
            HttpHeaders headers = new HttpHeaders();
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            ResultMsg result= null;
            if(StringUtils.isEmpty(type)){
                String  res = ykyyService.getShortMessage("1",username);
                String resltCode ="";
                String captcha1 = "";
                if (!StringUtils.isEmpty(res)){
                    JSONObject jsonObject = JSONObject.parseObject(res);
                    if ("10000".equalsIgnoreCase(jsonObject.getString("code"))){
                        captcha1 = jsonObject.getString("value");
                        resltCode = jsonObject.getString("code");
                    }else if("199".equalsIgnoreCase(jsonObject.getString("code"))){
                        msg = jsonObject.getString("msg");
                        Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, 199);
                        return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
                    }else {
                        msg="发送失败";
                        Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, -1);
                        return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
                    }
                }
                if ("10000".equalsIgnoreCase(resltCode)) {
                    Captcha _captcha = new Captcha();
                    _captcha.setCode(captcha1);
                    _captcha.setExpiresIn(300);
                    wlyyRedisVerifyCodeService.store(client_id, username, captcha1, 300);
                    Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
                    HttpHeaders headers = new HttpHeaders();
                    headers.set("Cache-Control", "no-store");
                    headers.set("Pragma", "no-cache");
                    return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                }
            }else if("1".equals(type)){
                result = ykyySMSService.ykyySendSMS(username,"您好,您的手机登录短信验证码是:"+captcha+",5分钟内有效。");
            }else if("2".equals(type)) {
                result = ykyySMSService.ykyySendSMS(username, "您好,您正在进行找回密码操作,您的短信验证码是:" + captcha + ",请勿将验证码告诉他人,5分钟内有效。");
            }
            if (result.isSuccess()) {
                Captcha _captcha = new Captcha();
                _captcha.setCode(captcha);
                _captcha.setExpiresIn(300);
                wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
                Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, 200);
            return new ResponseEntity<>(oauth2Envelop, HttpStatus.OK);
        }
        throw new IllegalStateException("验证码发送失败!");
    }
    /**
@ -1295,7 +1414,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    @RequestMapping(value = "/oauth/registerPatientAndLogin", method = RequestMethod.POST)
    /*@RequestMapping(value = "/oauth/registerPatientAndLogin", method = RequestMethod.POST)
    public ObjEnvelop registerPatientAndLogin(String name, String mobile, String idcard, String ssc, String pw,String client_id,String login_type,String captcha,String openid,String wxId)throws Exception{
        if (StringUtils.isEmpty(client_id)) {
@ -1362,37 +1481,199 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            e.printStackTrace();
        }
        return ObjEnvelop.getError("登录失败!");
    }
    }*/
    @RequestMapping(value = "/oauth/registerPatientAndLogin", method = RequestMethod.POST)
    public ObjEnvelop registerPatientAndLogin(String name, String mobile, String idcard, String ssc, String pw,String client_id,String login_type,String captcha,String openid,String wxId)throws Exception{
    @RequestMapping(value = "/oauth/findPatientPw", method = RequestMethod.POST)
    public Envelop findPatientPw(String mobile,String client_id,String login_type,String captcha,String pw)throws Exception {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
        }
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
            //验证码正确
        } else {
            return ObjEnvelop.getError("验证码错误!");
        }
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            try {
                List<BasePatientDO> basePatientDOS =basePatientDao.findByMobileAndDel(mobile,"1");
                boolean localFlag = false;
                boolean ykFlag = false;
                String msg = "";
                if (null!=basePatientDOS&&basePatientDOS.size()>0){
                    localFlag = true;
        String rs = registerService.updatePatientPw(pw,mobile);
        if("ok".equals(rs)){
            return ObjEnvelop.getSuccess("修改成功!");
                }
                BasePatientDO basePatientDO = new BasePatientDO();
                String r =ykyyService.getRegisterUser(mobile,pw,captcha,"a01522","xmijk","xmijk");
                if (!StringUtils.isEmpty(r)){
                    JSONObject jsonObject = JSONObject.parseObject(r);
                    if (null!=jsonObject.get("code")&&"200".equalsIgnoreCase(jsonObject.get("code").toString())){
                        JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("data").toString());
                        basePatientDO.setUserId(jsonObject1.getString("ID"));
                    }else if (null!=jsonObject.get("code")&&"199".equalsIgnoreCase(jsonObject.get("code").toString())){
                        msg = jsonObject.getString("msg");
                        ykFlag = true;
                    }
                }
                basePatientDO.setMobile(mobile);
                String salt = UUID.randomUUID().toString().substring(0,5);
                basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                basePatientDO.setSalt(salt);
                basePatientDO.setDel("1");
                basePatientDO.setEnabled(1);
                basePatientDO.setLocked(0);
                basePatientDO.setCreateTime(new Date());
                basePatientDO.setUpdateTime(new Date());
                BasePatientDO patientDO = basePatientDao.save(basePatientDO);
                if (localFlag&&ykFlag){
                    return ObjEnvelop.getError("该手机号已经注册过");
                }
                ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
                Map<String, String> parameters = new HashedMap();
                parameters.put("username",patientDO.getMobile());
                parameters.put("grant_type", "ihealthCode");
                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);
                return ObjEnvelop.getSuccess("success",wlyyUserSimple);
            }catch (Exception e){
                e.printStackTrace();
            }
        }else {
            try {
                Map<String,Object> rs = registerService.registerPatient(mobile,pw);
                String code = rs.get("code").toString();
                if(!"1".equals(code)){
                    ObjEnvelop objEnvelop = new ObjEnvelop();
                    objEnvelop.setObj(rs);
                    objEnvelop.setStatus(-1);
                    objEnvelop.setMessage(rs.get("mes")+"");
                    return objEnvelop;
                }
                BasePatientDO patientDO = (BasePatientDO)rs.get("patient");
                ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
                Map<String, String> parameters = new HashedMap();
                parameters.put("username",patientDO.getMobile());
                parameters.put("grant_type", "ihealthCode");
                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);
                return ObjEnvelop.getSuccess("success",wlyyUserSimple);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return ObjEnvelop.getError("手机号未注册!");
        return ObjEnvelop.getError("登录失败!");
    }
    @RequestMapping(value = "/oauth/findDoctorPw", method = RequestMethod.POST)
    public Envelop findDoctorPw(String mobile,String client_id,String captcha,String pw){
    @RequestMapping(value = "/oauth/findPatientPw", method = RequestMethod.POST)
    public Envelop findPatientPw(String mobile,String client_id,String login_type,String captcha,String pw)throws Exception {
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
            //验证码正确
        } else {
            return ObjEnvelop.getError("验证码错误!");
        }
        String rs = registerService.updateDoctorPw(mobile,pw);
        String rs = registerService.updatePatientPw(pw,mobile);
        if("ok".equals(rs)){
            return ObjEnvelop.getSuccess("修改成功!");
        }
        return ObjEnvelop.getError("手机号未注册!");
    }
    @RequestMapping(value = "/oauth/findDoctorPw", method = RequestMethod.POST)
    public Envelop findDoctorPw(String mobile,String client_id,String captcha,String pw) throws Exception{
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
           String response =  ykyyService.ResetPwd(mobile,pw,captcha);
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(response)){
                JSONObject object = JSONObject.parseObject(response);
                if (object.getString("code").equalsIgnoreCase("10000")){
                    return ObjEnvelop.getSuccess("修改成功!");
                }else {
                    return ObjEnvelop.getError("修改失败!");
                }
            }else {
                return ObjEnvelop.getError("修改失败!");
            }
        }else if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
            if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                //验证码正确
            } else {
                return ObjEnvelop.getError("验证码错误!");
            }
            String rs = registerService.updateDoctorPw(mobile,pw,wechatId);
            if("ok".equals(rs)){
                return ObjEnvelop.getSuccess("修改成功!");
            }
            return ObjEnvelop.getError("手机号未注册!");
        }else {
            return ObjEnvelop.getError("暂未开放");
        }
    }
    @RequestMapping(value = "/oauth/updateDoctorMoble", method = RequestMethod.POST)
@ -1434,12 +1715,13 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        //图形验证码验证
        String key = parameters.get("key");
        String text = parameters.get("text");
        String captcha = parameters.get("captcha");
        String loginType = parameters.get("login_type");
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
                throw new ImgCaptchaException("img_captcha error");
            }
        }
        String username = parameters.get("username");
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
@ -1531,6 +1813,10 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                    }
                }
                parameters.remove("password");
            } else if (!StringUtils.isEmpty(loginType)&&"3".equalsIgnoreCase(loginType)){
                if (wlyyRedisVerifyCodeService.verification(client_id, username, captcha)) {
                    //验证码正确
                }
            } else {
                //第三方同步账号模式登录
                parameters.put("grant_type", "ihealthCode");
@ -1568,7 +1854,6 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        wlyyUserSimple.setState(parameters.get("state"));
        String loginType = parameters.get("login_type");
        String openid = parameters.get("openid");
        //更新患者openId
@ -1619,5 +1904,156 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        return ObjEnvelop.getError("手机号未注册!");
    }
    /*
     *眼科通修改密码发送的验证码
     */
    @RequestMapping(value = "/oauth/yktGetResetCode", method = RequestMethod.POST)
    public ObjEnvelop yktGetResetCode(@ApiParam(name = "loginid", value = "注册的电话号码", required = true)
                                      @RequestParam(value = "loginid",required = true)String loginid,
                                      @ApiParam(name = "type", value = "验证码类型 1、患者注册 2、患者找回密码 3、医生注册 4、医生找回密码", required = true)
                                      @RequestParam(value = "type",required = false)String type){
        try {
            return ObjEnvelop.getSuccess("ok",ykyyService.getResetCode(type,loginid));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    /**
     * 登陆
     *
     * @param parameters  不定入参:
     *                    client_id 应用标识
     *                    captcha 验证码
     *                    password 密码
     *                    username 用户名/手机/身份证号
     *                    key 图形验证码键值
     *                    text 用户输入的图形验证码
     *                    login_type 用户类型 1或默认为user,2:医生登录,3:患者登录,4:第三方同步账号登录,5.易联众居民健康卡授权登录
     * @param httpSession
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/ykDoctorlogin", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> ykDoctorlogin(@RequestParam Map<String, String> parameters, HttpSession httpSession) throws Exception {
        logger.info("login:登录进入1");
        //图形验证码验证
        String key = parameters.get("key");
        String text = parameters.get("text");
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
                throw new ImgCaptchaException("img_captcha error");
            }
        }
        logger.info("login:登录进入2");
        String username = parameters.get("username");
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
        }
        String client_id = parameters.get("client_id");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "ihealthDcotor");
            //解密密码
            if (parameters.get("password") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                logger.info("password:"+password);
                String response = ykyyService.DoctorLogin(parameters.get("username"),password);
                if (!StringUtils.isEmpty(response)){
                    JSONObject object = JSONObject.parseObject(response);
                    logger.info("眼科通登陆返回参数:"+object);
                    if (!object.getString("code").equalsIgnoreCase("10000")){
                        WlyyUserSimple userSimple = new WlyyUserSimple();
                        return getFailedResponse(object.getString("message"),-1,userSimple);
                    }else {
                        JSONObject jsonObject = object.getJSONObject("value");
                        if (jsonObject!=null) {
                            String idCard = jsonObject.getString("idCard");
                            String verifyCode = jsonObject.getString("verifyCode");
                            String yktDoctorId= jsonObject.getString("id");
                            if (idCard==null||idCard==""){
                                logger.info("身份证为空");
                            }else {
                                ykyyService.updateYkyyDoctor(idCard,verifyCode,yktDoctorId);
                            }
                        }
                    }
                }
                parameters.remove("password");
            } else {
                //第三方同步账号模式登录
                parameters.put("grant_type", "ihealthDcotor");
            }
        } else {
            parameters.put("grant_type", "captcha");
        }
        logger.info("login:登录进入3");
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        if (null == authenticatedClient) {
            throw new InvalidRequestException("client_id");
        }
        logger.info("login:登录进入4"+authenticatedClient.getClientId());
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        /*如果是移动端登陆则移除之前的token,
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
            tokenStore.removeAccessToken(token.getValue());
            tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
            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"));
        wlyyUserSimple.setState(parameters.get("state"));
        String loginType = parameters.get("login_type");
        String openid = parameters.get("openid");
        String wechatId = parameters.get("wechatId");
        logger.info("login:登录进入7");
        //更新患者openId
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        logger.info("gengxin开始");
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
            baseLoginLogDO.setOpenid(openid);
            logger.info("gengxin进入"+openid);
            userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
            if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                logger.info("gengxin进入"+wechatId);
                userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
            }
        }
        if (parameters.get("password") != null) {
            //使用密码登录成功后, 更新失败次数为 0
            userDetailsService.addFailureCount(username, 0);
        }
        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);
        return getResponse(wlyyUserSimple);
    }
}

+ 38 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthSsoService.java

@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.auth.OauthRsaKeyDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.security.dao.OauthRsaKeyDao;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.dao.patient.BasePatientWechatDao;
import com.yihu.jw.security.dao.patient.WlyyPatientFamilyMemberDao;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.jw.security.utils.RSAEncrypt;
import com.yihu.utils.security.MD5;
@ -19,8 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -44,6 +44,9 @@ public class OauthSsoService {
    @Autowired
    private  BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private WlyyPatientFamilyMemberDao familyMemberDao;
    public static String getAuthCode()throws Exception{
@ -140,6 +143,23 @@ public class OauthSsoService {
                        basePatientWechatDao.save(wechatDo);
                    }
                    //保存就诊人信息
                    WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(basePatientDO.getId(),"7");
                    if (basePatientFamilyMemberDO==null){
                        basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                        basePatientFamilyMemberDO.setPatient(basePatientDO.getId());
                        basePatientFamilyMemberDO.setFamilyRelation("7");
                        basePatientFamilyMemberDO.setFamilyRelationName("自己");
                        basePatientFamilyMemberDO.setCardType("身份证");
                        basePatientFamilyMemberDO.setCardNo(basePatientDO.getIdcard());
                        basePatientFamilyMemberDO.setCreateTime(new Date());
                        basePatientFamilyMemberDO.setUpdateTime(new Date());
                        basePatientFamilyMemberDO.setIsAuthorize(1);
                        basePatientFamilyMemberDO.setIsDel(1);
                        basePatientFamilyMemberDO.setFamilyMember(basePatientDO.getId());
                        familyMemberDao.save(basePatientFamilyMemberDO);
                    }
                    return rs;
                }
@ -171,6 +191,22 @@ public class OauthSsoService {
                wechatDo.setWechatId(appId);
                basePatientWechatDao.save(wechatDo);
                //保存就诊人信息
                WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(temp.getId(),"7");
                if (basePatientFamilyMemberDO==null){
                    basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                    basePatientFamilyMemberDO.setPatient(temp.getId());
                    basePatientFamilyMemberDO.setFamilyRelation("7");
                    basePatientFamilyMemberDO.setFamilyRelationName("自己");
                    basePatientFamilyMemberDO.setCardType("身份证");
                    basePatientFamilyMemberDO.setCardNo(temp.getIdcard());
                    basePatientFamilyMemberDO.setCreateTime(new Date());
                    basePatientFamilyMemberDO.setUpdateTime(new Date());
                    basePatientFamilyMemberDO.setIsAuthorize(1);
                    basePatientFamilyMemberDO.setIsDel(1);
                    basePatientFamilyMemberDO.setFamilyMember(temp.getId());
                    familyMemberDao.save(basePatientFamilyMemberDO);
                }
                rs.put("code",1);
                rs.put("mes","获取居民信息成功");
                rs.put("patient",temp);

+ 37 - 7
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthYlzConfigService.java

@ -4,13 +4,15 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.security.dao.OauthYlzConfigDao;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.dao.patient.WlyyPatientFamilyMemberDao;
import com.yihu.jw.security.utils.ByteToInputStream;
import com.yihu.jw.security.utils.DateUtil;
import com.yihu.jw.security.utils.QrcodeUtil;
import com.yihu.jw.util.idcard.IdCardUtil;
import com.yihu.utils.security.MD5;
import com.ylzinfo.ehc.EhcHandler;
import com.ylzinfo.ehc.common.utils.DateUtils;
@ -21,12 +23,8 @@ import org.apache.commons.lang3.StringUtils;
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.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import java.io.InputStream;
import java.util.Date;
@ -45,6 +43,8 @@ public class OauthYlzConfigService {
    private OauthYlzConfigDao oauthYlzConfigDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private WlyyPatientFamilyMemberDao familyMemberDao;
//    @Value("${fastDFS.fastdfs_file_url}")
//    private String fastdfs_file_url;
@ -233,16 +233,46 @@ public class OauthYlzConfigService {
                        patient.setDel("1");
                        patient.setEnabled(1);
                        patient.setLocked(0);
                        patient.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard)));
                        patient.setCreateTime(new Date());
                        patient.setUpdateTime(new Date());
                        patient.setBirthday(DateUtil.strToDate(biz.getString("birthday"),"yyyyMMdd"));
                        basePatientDao.save(patient);
                        patientDO = basePatientDao.save(patient);
                        WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patientDO.getId(),"7");
                        if (basePatientFamilyMemberDO==null){
                            basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                            basePatientFamilyMemberDO.setPatient(patientDO.getId());
                            basePatientFamilyMemberDO.setFamilyRelation("7");
                            basePatientFamilyMemberDO.setFamilyRelationName("自己");
                            basePatientFamilyMemberDO.setCardType("身份证");
                            basePatientFamilyMemberDO.setCardNo(patientDO.getIdcard());
                            basePatientFamilyMemberDO.setCreateTime(new Date());
                            basePatientFamilyMemberDO.setUpdateTime(new Date());
                            basePatientFamilyMemberDO.setIsAuthorize(1);
                            basePatientFamilyMemberDO.setIsDel(1);
                            basePatientFamilyMemberDO.setFamilyMember(patientDO.getId());
                            familyMemberDao.save(basePatientFamilyMemberDO);
                        }
                        rsMap.put("sCode",auth_status);
                        rsMap.put("sMes","success");
                        rsMap.put("patient",patient);
                        return rsMap;
                    }else{
                        WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patientDO.getId(),"7");
                        if (basePatientFamilyMemberDO==null){
                            basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                            basePatientFamilyMemberDO.setPatient(patientDO.getId());
                            basePatientFamilyMemberDO.setFamilyRelation("7");
                            basePatientFamilyMemberDO.setFamilyRelationName("自己");
                            basePatientFamilyMemberDO.setCardType("身份证");
                            basePatientFamilyMemberDO.setCardNo(patientDO.getIdcard());
                            basePatientFamilyMemberDO.setCreateTime(new Date());
                            basePatientFamilyMemberDO.setUpdateTime(new Date());
                            basePatientFamilyMemberDO.setIsAuthorize(1);
                            basePatientFamilyMemberDO.setIsDel(1);
                            basePatientFamilyMemberDO.setFamilyMember(patientDO.getId());
                            familyMemberDao.save(basePatientFamilyMemberDO);
                        }
                        rsMap.put("sCode",auth_status);
                        rsMap.put("sMes","success");
                        rsMap.put("patient",patientDO);

+ 48 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/service/RegisterService.java

@ -98,9 +98,54 @@ public class RegisterService {
                wechatDo.setPatientId(temp.getId());
                basePatientWechatDao.save(wechatDo);
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(wxId)&&wxId.equalsIgnoreCase("xm_ykyy_wx")){
            /*if (org.apache.commons.lang3.StringUtils.isNoneBlank(wxId)&&wxId.equalsIgnoreCase("xm_ykyy_wx")){
                ykyyService.registerYkt(temp.getId(),pw,captcha);
            }*/
            rs.put("code","1");
            rs.put("mes","ok");
            rs.put("patient",temp);
            return rs;
        }catch (Exception e){
            e.printStackTrace();
        }
        rs.put("code","-3");
        rs.put("mes","保存用户信息失败");
        return rs;
    }
    public Map<String,Object> registerPatient(String mobile,String pw)throws Exception{
        Map<String,Object> rs = new HashedMap();
        try{
            List<BasePatientDO> p2 = basePatientDao.findByMobileAndDel(mobile,"1");
            if(p2!=null&&p2.size()>0){
                rs.put("code","-2");
                rs.put("mes","手机号已经存在");
                return rs;
            }
            BasePatientDO patient = new BasePatientDO();
            String salt = UUID.randomUUID().toString().substring(0,5);
            patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            patient.setSalt(salt);
            patient.setMobile(mobile);
            patient.setDel("1");
            patient.setEnabled(1);
            patient.setLocked(0);
            patient.setCreateTime(new Date());
            patient.setUpdateTime(new Date());
            BasePatientDO temp = basePatientDao.save(patient);
            PatientMedicareCardDO medicareCardDO = new PatientMedicareCardDO();
            medicareCardDO.setDel("1");
            medicareCardDO.setParentType("A");
            medicareCardDO.setType("A_01");
            medicareCardDO.setPatientCode(temp.getId());
            basePatientMedicareCardDao.save(medicareCardDO);
            /*if (org.apache.commons.lang3.StringUtils.isNoneBlank(wxId)&&wxId.equalsIgnoreCase("xm_ykyy_wx")){
                ykyyService.registerYkt(temp.getId(),pw,captcha);
            }*/
            rs.put("code","1");
            rs.put("mes","ok");
@ -139,7 +184,7 @@ public class RegisterService {
        return true;
    }
    public String updateDoctorPw(String mobile,String pw){
    public String updateDoctorPw(String mobile,String pw,String wxId){
        List<BaseDoctorDO> list = baseDoctorDao.findByMobile(mobile);
        if(list!=null&&list.size()>0){
            for(BaseDoctorDO doctorDO:list){
@ -158,6 +203,7 @@ public class RegisterService {
        return "ok";
    }
    public String updateDoctorMoble(String id,String mobile){
        BaseDoctorDO doctorDO = baseDoctorDao.findOne(id);
        //认证信息设置

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

@ -1,5 +1,6 @@
package com.yihu.jw.security.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
@ -8,6 +9,7 @@ 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.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * 心脏中心医院
@ -34,6 +37,7 @@ public class XzzxService {
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    public static String entranceUrl = "http://172.16.100.240:10023/xzzx/";
    /**
     * OAuth登陆-认证请求接口
@ -158,4 +162,31 @@ public class XzzxService {
        return null;
    }
    /**
     * 发送短信验证码
     * @return
     * @throws Exception
     */
    public Integer SendSms(String json) throws Exception {
        int result = 0;
        String response="";
        String url = entranceUrl+"SendSms";
        Map<String,String> map = new HashedMap();
        map.put("json",json);
        response = httpClientUtil.httpPost(url,map);
        logger.info("返回参数:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            JSONArray jsonArray= JSONArray.parseArray(object.getString("obj"));
            if (jsonArray!=null&&jsonArray.size()!=0){
                JSONObject jsonObject = jsonArray.getJSONObject(0);
                if (jsonObject.getString("code").equalsIgnoreCase("10000")){
                    result=0;
                }
            }
        }
        return result;
    }
}

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

@ -1,21 +1,39 @@
package com.yihu.jw.security.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
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.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
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.dao.doctor.DoctorMappingDao;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.idcard.IdCardUtil;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.security.MD5;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
import java.util.List;
import static com.yihu.jw.util.common.PwdUtil.randomString;
/**
 * 眼科医院
 * Created by yeshijie on 2020/4/24.
@ -35,6 +53,24 @@ public class YkyyService {
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private BaseDoctorRoleDao baseDoctorRoleDao;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    private final static String orgCode ="350211A5004";
    private final static String orgName ="厦门大学附属厦门眼科中心";
    private final static String url="http://192.168.20.55:10023/ykyy/createSQLQuery";
    private static String yktUrl = "http://www.yanketong.com:133/api/";
    /**
@ -106,6 +142,68 @@ public class YkyyService {
        logger.info("眼科通验证码:"+response);
        return response;
    }
    /**
     * 获取眼科通修改密码验证码
     * @param type
     * @param phone
     * @return
     */
    public String getResetCode(String type,String phone) throws  Exception{
        String response="";
        String codeResponse = getVerificationReal(phone,type,"");
        String veryCode = "";
        if (StringUtils.isNoneBlank(codeResponse)){
            JSONObject jsonObject = JSONObject.parseObject(codeResponse);
            if ("10000".equalsIgnoreCase(jsonObject.getString("code"))){
                veryCode =  jsonObject.getString("value");
            }
        }
        String url = yktUrl1+"api/Doctor/GetVerificationCode";
        Map param = new HashMap();
        param.put("loginid",phone);
        param.put("type",type);
        param.put("VerificationReal",veryCode);
        logger.info("请求参数:"+param.toString());
        response = httpClientUtil.httpPost(url,param);
        logger.info("眼科通验证码:"+response);
        return response;
    }
    /**获取图形验证码
     *
     * @param loginid
     * @param type
     * @param IPAddress
     * @return
     */
    public String getVerificationReal(String loginid,String type,String IPAddress) throws  Exception{
        String response="";
        Map map = new HashMap();
        map.put("loginid",loginid);
        map.put("type",type);
        map.put("IPAddress",IPAddress);
        String url = yktUrl1+"api/Share/GetVerificationReal";
        response = httpClientUtil.httpPost(url,map);
        logger.info("修改眼科同密码后的信息:"+response);
        return response;
    }
    /**
     * 忘记密码修改
     * @param loginid
     * @param password
     * @return
     */
    public String ResetPwd(String loginid,String password,String verCode) throws  Exception{
        String response="";
        String url = yktUrl1+"api/Doctor/ResetPassword";
        Map param = new HashMap();
        param.put("loginid",loginid);
        param.put("password",password);
        param.put("verCode",verCode);
        logger.info("请求参数:"+param.toString());
        response = httpClientUtil.httpPost(url,param);
        logger.info("眼科通验证码:"+response);
        return response;
    }
    /**
     * 增加家庭成员
@ -135,7 +233,7 @@ public class YkyyService {
     * @param vercode
     * @return
     */
    public String forgetPassword(String tel,String password,String vercode){
    public String   forgetPassword(String tel,String password,String vercode){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginid",tel);
@ -288,4 +386,148 @@ public class YkyyService {
        }
    }
    /**
     * 医生端眼科通登陆
     * @param loginId 账户
     * @param password 密码
     * @return
     */
    public String DoctorLogin(String loginId,String password){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginId",loginId);//账户
        jsonObject.put("password",password);//密码
        String url = "http://www.yanketong.com:90/api/Doctor/DoctorLogin";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("医生端登陆:"+response);
        return response;
    }
    public String updateYkyyDoctor(String idCard,String verifyCode,String yktDoctorId)throws Exception{
        String sql ="select y.code AS \"code\",y.name AS \"name\",y.expertise AS \"expertise\",y.introduce AS \"introduce\",y.mobile AS \"mobile\",y.idCard AS \"idcard\",y.jobtitlecode AS \"jobTitleCode\",y.jobTitleName AS \"jobTitleName\",y.dept AS \"dept\",y.deptName AS \"deptName\" from v_Hlw_Ysxx y where y.idcard is not null";
        sql +=" and y.idcard ='"+idCard+"' ";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            JSONArray array = rs.getJSONArray("detailModelList");
            logger.info("doctor size:"+array.size());
            if(array!=null&&array.size()>0) {
                for (int i = 0; i < array.size(); i++) {
                    JSONObject doctorJson = array.getJSONObject(i);
                    String idcard = doctorJson.getString("idcard");
                    //过滤身份证脏数据
                    if(idcard.length()>=15){
                        BaseDoctorDO doctorDOs = baseDoctorDao.findByIdcard(idcard);
                        if(doctorDOs!=null){
                            BaseDoctorDO doctor = doctorDOs;
                            String salt = randomString(5);
                            String pw = idcard.substring(idcard.length() - 6);
                            doctor.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                            doctor.setSalt(salt);
                            doctor.setJobTitleCode(doctorJson.getString("jobtitlecode"));
                            doctor.setJobTitleName(doctorJson.getString("jobTitleName"));
                            doctor.setVerifyCode(verifyCode);
                            doctor.setYktDoctorId(yktDoctorId);
//                            doctor.setExpertise(doctorJson.getString("expertise"));
//                            doctor.setIntroduce(doctorJson.getString("introduce"));
//                            doctor.setMobile(doctorJson.getString("mobile"));
                            BaseDoctorDO temp = baseDoctorDao.save(doctor);
                            List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByOrgCodeAndDeptCodeAndDoctorCode(orgCode,doctorJson.getString("dept"),doctor.getId());
                            if(hospitalDOs!=null&&hospitalDOs.size()>0){
                                //机构信息部门信息
                                BaseDoctorHospitalDO hospitalDO = hospitalDOs.get(0);
                                hospitalDO.setDeptCode(doctorJson.getString("dept"));
                                hospitalDO.setDeptName(doctorJson.getString("deptName"));
                                hospitalDO.setDel("1");
                                baseDoctorHospitalDao.save(hospitalDO);
                            }
                        }else{
                            //新增医生
                            BaseDoctorDO doctor = new BaseDoctorDO();
                            doctor.setName(doctorJson.getString("name"));
                            doctor.setIdcard(idcard);
                            doctor.setSex(Integer.parseInt(com.yihu.jw.util.common.IdCardUtil.getSexForIdcard_new(idcard)));
                            doctor.setBirthday(com.yihu.jw.util.common.IdCardUtil.getBirthdayForIdcard(idcard));
                            doctor.setProvinceCode("350000");
                            doctor.setProvinceName("福建省");
                            doctor.setTownCode("350203");
                            doctor.setTownName("思明区");
                            doctor.setCityCode("350200");
                            doctor.setCityName("厦门市");
                            doctor.setVerifyCode(verifyCode);
                            doctor.setYktDoctorId(yktDoctorId);
//                            doctor.setExpertise(doctorJson.getString("expertise"));
//                            doctor.setIntroduce(doctorJson.getString("introduce"));
//                            doctor.setMobile(doctorJson.getString("mobile"));
                            //认证信息设置
                            String salt = randomString(5);
                            String pw = idcard.substring(idcard.length() - 6);
                            doctor.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                            doctor.setSalt(salt);
                            doctor.setDel("1");
                            doctor.setEnabled(1);
                            doctor.setLocked(0);
                            doctor.setCreateTime(new Date());
                            doctor.setJobTitleCode(doctorJson.getString("jobtitlecode"));
                            doctor.setJobTitleName(doctorJson.getString("jobTitleName"));
                            BaseDoctorDO temp = baseDoctorDao.save(doctor);
                            //机构信息部门信息
                            BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
                            hospitalDO.setDoctorCode(temp.getId());
                            hospitalDO.setOrgCode(orgCode);
                            hospitalDO.setOrgName(orgName);
                            hospitalDO.setDeptCode(doctorJson.getString("dept"));
                            hospitalDO.setDeptName(doctorJson.getString("deptName"));
                            hospitalDO.setDel("1");
                            baseDoctorHospitalDao.save(hospitalDO);
                            //保存角色
                            BaseDoctorRoleDO role = new BaseDoctorRoleDO();
                            role.setDoctorCode(temp.getId());
                            role.setRoleCode("specialist");
                            baseDoctorRoleDao.save(role);
                            //保存mapping
                            DoctorMappingDO mappingDO = new DoctorMappingDO();
                            mappingDO.setIdcard(idcard);
                            mappingDO.setDoctor(temp.getId());
                            mappingDO.setDoctorName(temp.getName());
                            mappingDO.setOrgCode(orgCode);
                            mappingDO.setOrgName(orgName);
                            mappingDO.setMappingCode(doctorJson.getString("code"));
                            mappingDO.setMappingName(temp.getName());
                            mappingDO.setCreateTime(new Date());
                            doctorMappingDao.save(mappingDO);
                        }
                    }
                }
            }
        }
        return "success";
    }
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/sync/BaseSyncDataService.java

@ -139,7 +139,7 @@ public class BaseSyncDataService extends BaseJpaService<BaseSyncDataDO, BaseSync
                    logger.info("======================同步科室信息失败========================");
                }
                String re = ykyyEntranceService.updateYkyyDoctor();
                String re = ykyyEntranceService.updateYkyyDoctor(null);
                if (re.equalsIgnoreCase("success")){
                    logger.info("======================同步医生信息成功========================");
                }else {

+ 83 - 1
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java

@ -52,12 +52,19 @@ public class XzzxCotroller extends EnvelopRestEndpoint {
    @GetMapping(value = "/getDoctorInfo")
    @ApiOperation(value = "获取医生信息", notes = "获取医生信息")
    @ApiOperation(value = "同步医生信息", notes = "同步医生信息")
    public ObjEnvelop getDoctorInfo(@ApiParam(name = "idCard", value = "身份证号", required = false)
                                        @RequestParam(value = "idCard",required = false)String idcard)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.getDoctorInfo(idcard));
    }
    @GetMapping(value = "/selectDoctorInfo")
    @ApiOperation(value = "获取医生信息", notes = "获取医生信息")
    public ObjEnvelop selectDoctorInfo(@ApiParam(name = "idCard", value = "身份证号", required = false)
                                    @RequestParam(value = "idCard",required = false)String idcard)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.selectDoctorInfo(idcard));
    }
    @GetMapping(value = "/getJobTitle")
    @ApiOperation(value = "同步职称", notes = "同步职称")
    public ObjEnvelop getJobTitle()throws Exception{
@ -96,6 +103,18 @@ public class XzzxCotroller extends EnvelopRestEndpoint {
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.getCardInfo(cardNo));
    }
    /**
     * 获取卡信息
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/SendSms")
    @ApiOperation(value = "发送短信验证码", notes = "发送短信验证码")
    public ObjEnvelop SendSms(@ApiParam(name = "json", value = "验证码内容", required = false)
                                  @RequestParam(value = "json",required = false)String json)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.SendSms(json));
    }
    /**
     * 获取单条门诊就诊记录
@ -605,5 +624,68 @@ public class XzzxCotroller extends EnvelopRestEndpoint {
        WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = toEntity(emrInfo,WlyyPrescriptionEmrDO.class);
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.returnEmrHtmlByHLW(jsonObject,wlyyPrescriptionEmrDO));
    }
    /**
     * 查询历史就诊病历
     * @param patientId 病人id(必填)
     * @param eventNo 住院号
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/selectEmrInfo")
    @ApiOperation(value = "查询历史就诊病历", notes = "查询历史就诊病历")
    public ObjEnvelop findHistoryEmr (@ApiParam(name = "patientId", value = "病人id", required = false)
                                      @RequestParam(value = "patientId",required = false)String patientId,
                                      @ApiParam(name = "eventNo", value = "住院号", required = false)
                                      @RequestParam(value = "eventNo",required = false)String eventNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.SelectEmrInfo(patientId,eventNo));
    }
    /**
     * 查询历次就诊门诊病历文书
     * @param patientId 病人id(必填)
     * @param eventNo 住院号
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/selectEmrDispRecord")
    @ApiOperation(value = "查询历次就诊门诊病历文书", notes = "查询历次就诊门诊病历文书")
    public ObjEnvelop SelectEmrDispRecord (@ApiParam(name = "templateId", value = "模板id", required = false)
                                               @RequestParam(value = "templateId",required = false)String templateId,
                                        @ApiParam(name = "patientId", value = "病人id", required = false)
                                      @RequestParam(value = "patientId",required = false)String patientId,
                                      @ApiParam(name = "eventNo", value = "住院号", required = false)
                                      @RequestParam(value = "eventNo",required = false)String eventNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.SelectEmrDispRecord(templateId,patientId,eventNo));
    }
    /**
     * 查询病历文书列表
     * @param patientId 病人id(必填)
     * @param eventNo 住院号
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/selectEmrList")
    @ApiOperation(value = "查询病历文书列表", notes = "查询病历文书列表")
    public ObjEnvelop SelectEmrList(@ApiParam(name = "patientId", value = "病人id", required = false)
                                           @RequestParam(value = "patientId",required = false)String patientId,
                                           @ApiParam(name = "eventNo", value = "住院号", required = false)
                                           @RequestParam(value = "eventNo",required = false)String eventNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.GetEMRList(patientId,eventNo));
    }
    /**
     * 查询病历文书html信息
     * @param bstrEmrID 文书id号
     *
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/browseSingleEMR")
    @ApiOperation(value = "查询病历文书html信息", notes = "查询病历文书html信息")
    public ObjEnvelop BrowseSingleEMR(@ApiParam(name = "bstrEmrID", value = "文书id号", required = false)
                                    @RequestParam(value = "bstrEmrID",required = false)String bstrEmrID)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.BrowseSingleEMR(bstrEmrID));
    }
}

+ 30 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/PrescriptionAutoDeleteJob.java

@ -0,0 +1,30 @@
package com.yihu.jw.job;
import com.yihu.jw.service.channel.PrescriptionDeleteService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Trigger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class PrescriptionAutoDeleteJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(PrescriptionAutoDeleteJob.class);
    @Autowired
    private PrescriptionDeleteService prescriptionDeleteService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========PrescriptionAutoDeleteJob========");
        try {
            Trigger trigger =jobExecutionContext.getTrigger();
            System.out.println("执行时间为"+trigger.getNextFireTime());
            prescriptionDeleteService.deletePrescription();
            logger.info("END========PrescriptionAutoDeleteJob========");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("END===ERROE===PrescriptionAutoDeleteJob,message:"+e.getMessage());
        }
    }
}

+ 1 - 7
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/UnSettledHISPrescriptionJob.java

@ -1,13 +1,7 @@
package com.yihu.jw.job.ykyy;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.job.DataUploadJob;
import com.yihu.jw.service.channel.UnSettledHISPrescriptionService;
import com.yihu.jw.util.wechat.WeiXinMessageUtils;
import com.yihu.jw.wechat.service.WxTemplateService;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;

+ 73 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionDeleteService.java

@ -0,0 +1,73 @@
package com.yihu.jw.service.channel;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Component
@Transactional
public class PrescriptionDeleteService {
    private static Logger logger = LoggerFactory.getLogger(PrescriptionDeleteService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${wechat.ids}")
    private String wechatId;
    @Value("${hlwyyEntrance.url}")
    private String hlwyyEntranceUrl;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    //定时作废处方
    public void deletePrescription() throws Exception{
        Calendar ca = Calendar.getInstance();//得到一个Calendar的实例
        ca.setTime(new Date()); //设置时间为当前时间
        ca.add(Calendar.DATE, -1); //天数减1
        Date d = ca.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String s = sdf.format(d);
        logger.info("开始日期:"+s);
        List<WlyyPrescriptionDO> prescriptionDOS = prescriptionDao.findListByCheckStatus(DateUtil.strToDate(s+" 00:00:00"),DateUtil.strToDate(s+" 23:59:59"));
        if (null!=prescriptionDOS&&prescriptionDOS.size()>0){
            for (WlyyPrescriptionDO prescriptionDO:prescriptionDOS){
                logger.info("处方删除时间满足条件");
                String hisId = prescriptionDO.getHisId();
                if("xm_xzzx_wx".equalsIgnoreCase(wechatId)){
                    List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOs = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionDO.getId(),1);
                    if (null!=wlyyPrescriptionDiagnosisDOs&&wlyyPrescriptionDiagnosisDOs.size()>0){
                        xzzxEntranceService.deleteCheckInputInfo(hisId,"0",prescriptionDO.getDoctor(),prescriptionDO.getPatientCode(),wlyyPrescriptionDiagnosisDOs);
                        if (StringUtils.isNotBlank(prescriptionDO.getRealOrder())){
                            xzzxEntranceService.deletePrescriptionToEntrance(prescriptionDO.getRealOrder());
                        }
                    }
                }
                prescriptionDO.setStatus(-1);
                prescriptionDO.setCheckStatus(4);
                prescriptionDO.setCheckReason("已删除");
                logger.info("处方:"+prescriptionDO.getId()+"已删除");
                prescriptionDao.save(prescriptionDO);
            }
        }
    }
}

+ 100 - 71
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java

@ -1,5 +1,7 @@
package com.yihu.jw.service.channel;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
@ -16,6 +18,8 @@ import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
@ -72,6 +76,10 @@ public class TimeoutOverDueService {
    private PrescriptionService prescriptionService;
    @Autowired
    private SystemMessageService systemMessageService;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private ConsultDao consultDao;
    /**
     *  取消未结束门诊
     */
@ -89,82 +97,103 @@ public class TimeoutOverDueService {
                        if (currentTime-outpatientTime>24*60*60*1000){
                            logger.info("时间满足条件");
                            String outPatientId = wlyyOutpatientDO.getId();
                            //判断医生是否接诊
                            List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                            if (roomDOs != null && roomDOs.size() > 0) {
                                for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                    if (roomDO.getVisitStatus() == 2) {
                                        logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                    } else {
                                        roomDO.setVisitStatus(-1);
                                        logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                        hospitalWaitingRoomDao.save(roomDO);
                            String consultCode ="";
                            try {
                                consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
                                logger.info("consultCode"+consultCode);
                                if(StringUtils.isNoneBlank(consultCode)){
                                    imService.finish(consultCode,"admin",2);
                                    //医生未回复可以退费
                                    businessOrderService.consultRefund(consultCode,wechatId);
                                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                                    wlyyOutpatientDO.setDoctorCancelType("6");
                                    wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                                    wlyyOutpatientDO.setEndTime(new Date());
                                    wlyyOutpatientDO.setOperator("system");
                                    outpatientDao.save(wlyyOutpatientDO);
                                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                                }else{
                                    //判断医生是否接诊
                                    List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                                    if (roomDOs != null && roomDOs.size() > 0) {
                                        for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                            if (roomDO.getVisitStatus() == 2) {
                                                logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                            } else {
                                                roomDO.setVisitStatus(-1);
                                                logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                                hospitalWaitingRoomDao.save(roomDO);
                                            }
                                        }
                                    }
                                }
                            }
                            //更改门诊状态
                            wlyyOutpatientDO.setStatus("-1");
                            String description = null;
                            wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                            wlyyOutpatientDO.setDoctorCancelType("6");
                            wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                            wlyyOutpatientDO.setEndTime(new Date());
                            wlyyOutpatientDO.setOperator("system");
                            description = cancelValue;
                            //系统消息
                            SystemMessageDO messageDO = new SystemMessageDO();
                            messageDO.setTitle("超时订单系统自动取消");
                            messageDO.setType("13");
                            messageDO.setSender(wlyyOutpatientDO.getDoctor());
                            messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                            messageDO.setRelationCode(wlyyOutpatientDO.getId());
                            messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                            messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                            net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                            data.put("name", wlyyOutpatientDO.getPatientName());
                            data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                            data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                            data.put("question", wlyyOutpatientDO.getIcd10Name());
                            String msg = "";
                            if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                data.put("type", "9");
                                msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                            }
                            if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                data.put("type", "16");
                                msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                            }
                            data.put("msg", msg);
                            messageDO.setData(data.toString());
                            systemMessageService.saveMessage(messageDO);
                            //推送消息到眼科通
                            BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                                logger.info("推送消息到眼科通");
                                ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                            }
                            logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                            //删除门诊号源
                            List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                            if (list != null && list.size() > 0) {
                                patientRegisterTimeDao.delete(list);
                            }
                            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                                //眼科接诊时更新眼科通状态
                                if (businessOrderDO!=null){
                                    ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                                }
                            } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                                    //更改门诊状态
                                    wlyyOutpatientDO.setStatus("-1");
                                    String description = null;
                                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                                    wlyyOutpatientDO.setDoctorCancelType("6");
                                    wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                                    wlyyOutpatientDO.setEndTime(new Date());
                                    wlyyOutpatientDO.setOperator("system");
                                    description = cancelValue;
                                    //系统消息
                                    SystemMessageDO messageDO = new SystemMessageDO();
                                    messageDO.setTitle("超时订单系统自动取消");
                                    messageDO.setType("13");
                                    messageDO.setSender(wlyyOutpatientDO.getDoctor());
                                    messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                                    messageDO.setRelationCode(wlyyOutpatientDO.getId());
                                    messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                                    messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                                    net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                                    data.put("name", wlyyOutpatientDO.getPatientName());
                                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                                    data.put("question", wlyyOutpatientDO.getIcd10Name());
                                    String msg = "";
                                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                        data.put("type", "9");
                                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                                    }
                                    if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                        data.put("type", "16");
                                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                                    }
                                    data.put("msg", msg);
                                    messageDO.setData(data.toString());
                                    systemMessageService.saveMessage(messageDO);
                                    //推送消息到眼科通
                                    BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                                    if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                                        logger.info("推送消息到眼科通");
                                        ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                                    }
                                    //删除门诊号源
                                    List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                                    if (list != null && list.size() > 0) {
                                        patientRegisterTimeDao.delete(list);
                                    }
                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                                    if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                        businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                                        //眼科接诊时更新眼科通状态
                                        if (businessOrderDO!=null){
                                            ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                                        }
                                    } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
        /*
                            businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
        */
                                    }
                                    outpatientDao.save(wlyyOutpatientDO);
                                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                                }
                            }catch(Exception e)  {
                                e.printStackTrace();
                                logger.info("自动结束咨询报错 consultCode: "+consultCode);
                            }
                            outpatientDao.save(wlyyOutpatientDO);
                            logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();

+ 13 - 5
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -15,10 +15,7 @@ import com.yihu.jw.repository.job.QuartzJobConfigDao;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.channel.PrescriptionStatusUpdateService;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.AutoTimeOutRemind;
import com.yihu.jw.util.OverdueJob;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.util.TimeoutOverDueJob;
import com.yihu.jw.util.*;
import com.yihu.jw.web.BaseController;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
@ -200,6 +197,17 @@ public class JobController extends BaseController {
                        logger.info("CSTXJOB  job exist");
                    }
                    break;
                case "prescription_auto_delete_job" :
                    //互联网医院 监管平台上报
                    if (!quartzHelper.isExistJob("prescription_auto_delete_job")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prescription_auto_delete_job");
                        quartzHelper.addJob(PrescriptionAutoDeleteJob.class, trigger, "prescription_auto_delete_job", new HashMap<String, Object>());
                        logger.info("prescription_auto_delete_job  job success");
                    } else {
                        logger.info("prescription_auto_delete_job  job exist");
                    }
                    break;
                default :
            }
@ -385,7 +393,7 @@ public class JobController extends BaseController {
                case "2.3" :
                    // 2、分步执行需要JOB执行的服务
                    logger.info("START========2.3 医师基本信息========");
                    res = internetService.upNsDoctorRecord(startDate,endDate,keyId);
                    res = internetService.upNsDoctorRecord(keyId);
                    logger.info("END==========2.3 医师基本信息 ========" + res);
                    break; 
                case "2.5" :

+ 6 - 2
svr/svr-internet-hospital-job/src/main/resources/application.yml

@ -265,7 +265,7 @@ jobs:
spring:
  profiles: xzprod
  datasource:
    url: jdbc:mysql://172.16.100.240:7306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    url: jdbc:mysql://172.16.100.240:7306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    username: jkzl
    password: jkzl@2020
@ -285,7 +285,8 @@ hospital:
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.16.100.241:3000/
  im_list_get: http://172.16.100.65:3000/
#  im_list_get: http://172.16.100.241:3000/
  data_base_name: im
fastDFS:
  fastdfs_file_url: http://172.16.100.240:8888/
@ -294,10 +295,13 @@ wlyy:
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
  ids: xm_xzzx_wx
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code:
  sf_check_word:
jobs:
  schedule: 0 */30 * * * ?
---
spring:

+ 2 - 0
svr/svr-internet-hospital-job/src/main/resources/system.properties

@ -4,6 +4,8 @@ prescriptionStatus_update_job=0 */2 * * * ?
# 门诊记录过期job,每天1 点触发
prescription_overdue_job=0 0 2 * * ?
# 0 */1 * * * ?
prescription_auto_delete_job = 0 30 0 ? * *
#每天13 点触发
data_upload_job=0 0 2 * * ?

+ 36 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/Xzyy/XzyyController.java

@ -63,8 +63,10 @@ public class XzyyController extends EnvelopRestEndpoint {
                                         @ApiParam(name = "startTime", value = "开始时间", required = false)
                                         @RequestParam(value = "startTime",required = false)String startTime,
                                         @ApiParam(name = "endTime", value = "结束时间", required = false)
                                             @RequestParam(value = "endTime",required = false)String endTime)throws Exception{
        return success(xzzxEntranceService.selectOutpatientList(patient,startTime,endTime));
                                             @RequestParam(value = "endTime",required = false)String endTime,
                                          @ApiParam(name = "cardNo", value = "就诊卡", required = false)
                                              @RequestParam(value = "cardNo",required = false)String cardNo)throws Exception{
        return success(xzzxEntranceService.selectOutpatientList(patient,startTime,endTime,cardNo));
    }
    /**
@ -142,5 +144,37 @@ public class XzyyController extends EnvelopRestEndpoint {
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.updatePreStatus(admNo,realOrder,status));
    }
    /**
     * 查询历史就诊病历
     * @param patientId 病人id(必填)
     * @param eventNo 病人住院号
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/findHistoryEmr")
    @ApiOperation(value = "查询历史就诊病历", notes = "查询历史就诊病历")
    public ObjEnvelop findHistoryEmr(@ApiParam(name = "patientId", value = "病人id", required = false)
                                      @RequestParam(value = "patientId",required = false)String patientId,
                                      @ApiParam(name = "eventNo", value = "病人住院号", required = false)
                                      @RequestParam(value = "eventNo",required = false)String eventNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.selectHistoryEmr(patientId,eventNo));
    }
    /**
     * 查询历史就诊病历
     * @param patientId 病人id(必填)
     * @param eventNo 病人住院号
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/findHistoryEmrRecord")
    @ApiOperation(value = "查询历史就诊病历", notes = "查询历史就诊病历")
    public ObjEnvelop findHistoryEmrRecord(@ApiParam(name = "templateId", value = "模板id", required = false)
                                               @RequestParam(value = "templateId",required = false)String templateId,
                                        @ApiParam(name = "patientId", value = "病人id", required = false)
                                     @RequestParam(value = "patientId",required = false)String patientId,
                                     @ApiParam(name = "eventNo", value = "病人住院号", required = false)
                                     @RequestParam(value = "eventNo",required = false)String eventNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.selectHistoryEmrRecord(templateId,patientId,eventNo));
    }
}

+ 3 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java

@ -186,8 +186,9 @@ public class BaseInfoEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "/updateYkyyDoctor")
    @ApiOperation(value = "同步医生信息", notes = "同步医生信息")
    public Envelop updateYkyyDoctor() throws Exception {
        return success(ykyyEntranceService.updateYkyyDoctor());
    public Envelop updateYkyyDoctor(@ApiParam(name = "idcard", value = "医生身份证")
                                        @RequestParam(value = "idcard", required = false)String idcard) throws Exception {
        return success(ykyyEntranceService.updateYkyyDoctor(idcard));
    }
    @GetMapping(value = "/getCFXX")

+ 29 - 9
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -208,6 +208,10 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			}else{
				consult.setType(9);//图文复诊
			}
			WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientCode);
			if (outpatientDO.getStatus().equalsIgnoreCase("-1")){
				return failed("患者已取消!");
			}
			
			
			//咨询类型(1、图文;2、视频,3、图文+视频)
@ -216,16 +220,21 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		
			JSONObject result = new JSONObject();
			synchronized (outpatientCode.intern()){
				
				if(!"xm_ykyy_wx".equals(wxId)){//中山医院-心脏中心需要挂号
					//1.调用挂号接口
					logger.info("调用挂号接口====START");
					String rsCode = "";
					String mes = "";
					if("xm_xzzx_wx".equals(wxId)){ //心脏中心挂号
						JSONObject res = xzyyPrescriptionService.registerOutPatient(outpatientCode,doctorCode);
						rsCode = res.getString("@RESULT");
						mes = res.getString("@MSG");
						if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")){
							JSONObject res = xzyyPrescriptionService.registerOutPatient(outpatientCode,doctorCode);
							rsCode = res.getString("@RESULT");
							mes = res.getString("@MSG");
						}else {
							rsCode="0";
							mes="已挂号";
						}
						if (type==2){
							prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
						}
@ -234,9 +243,15 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
							rsCode="0";
							mes="已挂号";
						}else {
							net.sf.json.JSONObject res = prescriptionService.registerOutPatient(outpatientCode,doctorCode);
							rsCode = (String)res.get("@RESULT");
							mes = (String)res.get("@MSG");
							if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")){
								net.sf.json.JSONObject res = prescriptionService.registerOutPatient(outpatientCode,doctorCode);
								rsCode = (String)res.get("@RESULT");
								mes = (String)res.get("@MSG");
							}else {
								rsCode="0";
								mes="已挂号";
							}
						}
					}
@ -336,6 +351,11 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		consult.setHealthindexType(type);
//			int res = 0;
		WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientCode);
		if (outpatientDO.getStatus().equalsIgnoreCase("-1")){
			return failed("患者已取消!");
		}
		JSONObject result = new JSONObject();
		synchronized (outpatientCode.intern()){
@ -677,9 +697,9 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
					if (consultDo!=null){
						int resutl = imService.finish(consultDo.getId(),doctor,2);
						if (resutl!=-1){
							logger.info("结束咨询成功!");
						}
						logger.info("结束咨询成功!");
					}
				}
					String immsg = imService.sendOutPatientCancle(patientName,patientCode,doctor,cancelRemark,cancelValue,outPatientId);
					System.out.println("发送拒绝接诊消息成功:"+immsg);
				}

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

@ -572,7 +572,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
					logger.info("发送企业号url:"+url);
					enterpriseService.sendMKMesByMobile(qywxId,d.getMobile(),"您的专家咨询有新的消息,请您尽快回复[查看详情]("+url+")");
				}else if("xm_xzzx_wx".equals(qywxId)){
					String roomUrl = "pages/doctor/onlineChat/chatroom?rstitle="+p.getName()+"%20专家咨询&type="+type+"&sessionId="+re.getString("sessiond_id");
					String roomUrl = "pages/doctor/index?opath=/onlineChat/chatroom&rstitle="+p.getName()+"%20专家咨询&type="+type+"&sessionId="+re.getString("sessiond_id");
					logger.info("发送企业号url:"+roomUrl);
					enterpriseService.sendXCXMesByDoctor(qywxId,
							re.getString("doctor"),

+ 2 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/dict/PrivateDictEndpoint.java

@ -26,11 +26,9 @@ public class PrivateDictEndpoint extends EnvelopRestEndpoint {
    @ApiOperation("查询隐私策略")
    @PostMapping(value= BaseHospitalRequestMapping.PatientNoLogin.findPrivateDict)
    public Envelop findPrivateDict(@ApiParam(name = "dictCode", value = "隐私code")
                                    @RequestParam(value = "dictCode", required = false) String dictCode,
                                    @ApiParam(name = "hospitalCode", value = "医院code")
                                    @RequestParam(value = "hospitalCode", required = false) String hospitalCode){
                                    @RequestParam(value = "dictCode", required = false) String dictCode){
        return success(privateDictService.findByHospitalCodeAndDictCode(hospitalCode,dictCode));
        return success(privateDictService.findByHospitalCodeAndDictCode(dictCode));
    }
    @PostMapping(value= BaseHospitalRequestMapping.PatientNoLogin.savePrivateDict)

+ 66 - 14
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java

@ -3,9 +3,12 @@ package com.yihu.jw.hospital.endpoint.hospital;
import com.alibaba.fastjson.JSONObject;
import com.sun.media.jfxmedia.logging.Logger;
import com.yihu.jw.entity.base.doctor.BaseDoctorBackgroundDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
import com.yihu.jw.hospital.family.service.PatientMemberDictService;
import com.yihu.jw.hospital.family.service.WlyyFamilyMemberService;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -38,6 +41,8 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
    @Autowired
    private WlyyFamilyMemberService wlyyFamilyMemberService;
    @Autowired
    private WlyyPatientFamilyMemberDao wlyyPatientFamilyMemberDao;
    @Autowired
    private PatientMemberDictService patientMemberDictService;
    @Autowired
    private EntranceService entranceService;
@ -48,6 +53,8 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
    private final String KEY_SUFFIX = ":code";
    @Autowired
    private ZhongShanSMSService zhongShanSMSService;
    @Autowired
    private YkyyEntranceService ykyyEntranceService;
    @Value("${wechat.id}")
    private String wxId;
@ -67,28 +74,60 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
        String phoneNum = obj.getString("phoneNum");
        String idCard = obj.getString("idCard");
        String familyName = obj.getString("familyName");
        JSONArray jsonArray = entranceService.BS10008(idCard, "", "", "", "", "", false);
        if(jsonArray!=null&&jsonArray.size()>0){
            net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
            String familyId="";
            if (null!=jsonObject.get("Patient_Id")){
                String Pat_name = jsonObject.getString("Pat_Name");
                if (null!=jsonObject.get("Phone_Number_Business")){
                    String Next_Of_Kin_Phone = jsonObject.get("Phone_Number_Business").toString();
                    if(!Next_Of_Kin_Phone.equalsIgnoreCase(phoneNum)){
        String medicareType = obj.getString("medicareType");
        String medicare = obj.getString("medicare");
        String clinicId = obj.getString("clinicId");
        net.sf.json.JSONArray jsonArray = new JSONArray();
        if("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            jsonArray = ykyyEntranceService.findHisPatientBymMedicare(medicare,clinicId,false);
            if(jsonArray!=null&&jsonArray.size()>0){
                net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
                if (null!=jsonObject.get("brid")){
                    String Pat_name = jsonObject.getString("brxm");
                    if(!Pat_name.equalsIgnoreCase(familyName)){
                        mixEnvelop.setStatus(408);
                        mixEnvelop.setMessage("您所添加的家属的电话有误,无法发送验证码");
                        mixEnvelop.setMessage("您所添加的家属的名称有误,无法发送验证码");
                        return mixEnvelop;
                    }
                }
                if(!Pat_name.equalsIgnoreCase(familyName)){
                }else {
                    mixEnvelop.setStatus(408);
                    mixEnvelop.setMessage("您所添加的家属的名称有误,无法发送验证码");
                    mixEnvelop.setMessage("您所添加的家属无就诊记录无法添加");
                    return mixEnvelop;
                }
            }else {
                mixEnvelop.setStatus(408);
                mixEnvelop.setMessage("您所添加的家属无就诊记录无法添加");
                return mixEnvelop;
            }
        }else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            jsonArray = entranceService.BS10008(idCard, "", "", "", "", "", false);
            if(jsonArray!=null&&jsonArray.size()>0){
                net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
                if (null!=jsonObject.get("Patient_Id")){
                    String Pat_name = jsonObject.getString("Pat_Name");
                    if (null!=jsonObject.get("Phone_Number_Business")){
                        String Next_Of_Kin_Phone = jsonObject.get("Phone_Number_Business").toString();
                        if(!Next_Of_Kin_Phone.equalsIgnoreCase(phoneNum)){
                            mixEnvelop.setStatus(408);
                            mixEnvelop.setMessage("您所添加的家属的电话有误,无法发送验证码");
                            return mixEnvelop;
                        }
                    }
                    if(!Pat_name.equalsIgnoreCase(familyName)){
                        mixEnvelop.setStatus(408);
                        mixEnvelop.setMessage("您所添加的家属的名称有误,无法发送验证码");
                        return mixEnvelop;
                    }
                }
            }
        }else if("xm_xzzx_wx".equalsIgnoreCase(wxId)){
            mixEnvelop.setStatus(408);
            mixEnvelop.setMessage("心脏中心暂未开放");
            return mixEnvelop;
        }
        if (StringUtils.isEmpty(client_id)) {
            mixEnvelop.setStatus(468);
            mixEnvelop.setMessage("client_id不能为空");
@ -203,6 +242,9 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
            String client_id = jsonObject.getString("client_id");
            String username = jsonObject.getString("phoneNum");
            String code = jsonObject.getString("code");
            String medicareType = jsonObject.getString("medicareType");
            String medicare = jsonObject.getString("medicare");
            String clinicId = jsonObject.getString("clinicId");
            boolean checkCode = this.verification(client_id, username, code);
            if (checkCode) {
                String patientId = jsonObject.getString("patientId");
@ -210,12 +252,22 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
                String dictId = jsonObject.getString("dictId");
                String cardType = jsonObject.getString("cardType");
                String idCard = jsonObject.getString("idCard");
                //家人关系只允许添加一次自己
                if (null == jsonObject.get("id")&&!StringUtils.isEmpty(dictId)&&"7".equalsIgnoreCase(dictId)){
                    List<WlyyPatientFamilyMemberDO> list = wlyyPatientFamilyMemberDao.findByPatientAndFamilyRelation(patientId,dictId);
                    if (null!=list&&list.size()>0){
                        mixEnvelop.setStatus(408);
                        mixEnvelop.setMessage("您已经添加自己的信息请勿重复添加");
                        return mixEnvelop;
                    }
                }
                String id = "";
                if (null != jsonObject.get("id")) {
                    id = jsonObject.get("id").toString();
                }
                ;
                mixEnvelop = wlyyFamilyMemberService.addFamily(id, patientId, familyName, dictId, cardType, idCard, username, false);
                mixEnvelop = wlyyFamilyMemberService.addFamily(id, patientId, familyName, dictId, cardType, idCard, username, false,medicareType,medicare,clinicId);
            } else {
                mixEnvelop.setStatus(408);
                mixEnvelop.setMessage("验证码不正确");

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/internet/InternetController.java

@ -80,7 +80,7 @@ public class InternetController extends EnvelopRestEndpoint {
        Map map = new HashMap();
        String res = "";
        try {
            res =  internetService.upNsDoctorRecord(startDate,endDate,keyId);
            res =  internetService.upNsDoctorRecord(keyId);
            return ObjEnvelop.getSuccess(res);
        } catch (Exception e) {

+ 66 - 9
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -19,6 +19,7 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.httplog.service.WlyyHttpLogService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.PayInfoNoticeService;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
@ -59,9 +60,9 @@ import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.vavr.control.Try;
import net.sf.json.JSONArray;
import org.apache.axis.utils.StringUtils;
import org.apache.commons.collections.map.AbstractMapDecorator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -157,6 +158,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private WlyyHttpLogService wlyyHttpLogService;
    @Autowired
    private EnterpriseService enterpriseService;
    private String successxml = "SUCCESS";
    private String failedxml = "FALSE";
@ -858,13 +861,23 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                        String title = null;
                                        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
                                        if (wlyyOutpatientDO.getHisStatus()==null){
                                            fee=(prescriptionDO.getDrugFee()+15)+"";
                                            title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!结算费用包含本次在线问诊的复诊诊查费:15元。";
                                            fee=(prescriptionDO.getDrugFee()+wlyyOutpatientDO.getFee())+"";
                                            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                                                title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!结算费用包含本次在线问诊的复诊诊查费:"+wlyyOutpatientDO.getFee()+"元。";
                                            }else if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                                                title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!结算费用包含本次在线问诊的复诊诊查费:"+wlyyOutpatientDO.getFee()+"元。";
                                            }
                                        }else {
                                            fee=prescriptionDO.getDrugFee()+"";
                                            title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!";
                                            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                                                title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!";
                                            }
                                        }
                                        String pushPayLog = null;
                                        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                                            pushPayLog = payInfoNoticeService.pushPrescriptionPay(wlyyOutpatientDO.getConsumer(),prescriptionDO.getDoctorName(),voucherNo,prescriptionDO.getOutpatientId(),prescriptionDO.getId(),fee,title,null);
                                        }
                                        String pushPayLog = payInfoNoticeService.pushPrescriptionPay(wlyyOutpatientDO.getConsumer(),prescriptionDO.getDoctorName(),voucherNo,prescriptionDO.getOutpatientId(),prescriptionDO.getId(),fee,title,null);
                                        WlyyPrescriptionLogDO prescriptionLogDO = new WlyyPrescriptionLogDO();
                                        prescriptionLogDO.setCreateTime(new Date());
                                        prescriptionLogDO.setStatus(30);
@ -894,10 +907,12 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findByRealOrder(waitPayDetailVO.getRecipeNo());
                                        if (wlyyOutpatientDO!=null){
                                            if (wlyyOutpatientDO.getHisStatus()==null){
                                                String fee="15";
                                                String title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!";
                                                String url = "https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId="+wlyyOutpatientDO.getId()+"";
                                                payInfoNoticeService.pushPrescriptionPay(wlyyOutpatientDO.getConsumer(),wlyyOutpatientDO.getDoctorName(),waitPayDetailVO.getVoucherNo(),null,null,fee,title,url);
                                                String fee=wlyyOutpatientDO.getFee()+"";
                                                if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                                                    String title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!";
                                                    String url = "https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId="+wlyyOutpatientDO.getId()+"";
                                                    payInfoNoticeService.pushPrescriptionPay(wlyyOutpatientDO.getConsumer(),wlyyOutpatientDO.getDoctorName(),waitPayDetailVO.getVoucherNo(),null,null,fee,title,url);
                                                }
                                                outpatientDao.updateHisStatusById(wlyyOutpatientDO.getId(),1);
                                                logger.info("更新门诊结算状态");
                                            }
@ -999,5 +1014,47 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
            }
        }
    }
    @PostMapping(value = "/getWXUserInfo")
    @ApiOperation(value = "获取微信用户信息")
    public ObjEnvelop getWXUserInfo(
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient", required = false) String patient) throws Exception {
        return qrcodeService.getWXUserInfo(patient);
    }
    @PostMapping(value = "/getWXGZHQrcode")
    @ApiOperation(value = "生成微信公众号二维码")
    public ObjEnvelop createWXGZHQrcode(@ApiParam(name = "fileName", value = "文件名称")
                                         @RequestParam(value = "fileName", required = false) String fileName) throws Exception {
        ObjEnvelop objEnvelop= new ObjEnvelop();
        objEnvelop.setObj(qrcodeService.createPublicQrcode(fileName));
        return objEnvelop;
    }
    @PostMapping(value = "/findWXGZHQrcode")
    @ApiOperation(value = "查询微信公众号二维码")
    public MixEnvelop findWXGZHQrcode(@ApiParam(name = "orgCode", value = "医院code")
                                     @RequestParam(value = "orgCode", required = false) String orgCode) throws Exception {
        return qrcodeService.getWXGZHQrcode(orgCode);
    }
    @PostMapping(value = "/saveCheckHttpLog")
    @ApiOperation(value = "添加操作日志")
    public Envelop saveCheckHttpLog(@ApiParam(name = "code", value = "code")
                                      @RequestParam(value = "code", required = false) String code,
                                       @ApiParam(name = "name", value = "name")
                                       @RequestParam(value = "name", required = false) String name,
                                       @ApiParam(name = "patient", value = "patient")
                                           @RequestParam(value = "patient", required = false) String patient,
                                       @ApiParam(name = "doctor", value = "doctor")
                                           @RequestParam(value = "doctor", required = false) String doctor,
                                       @ApiParam(name = "request", value = "request")
                                           @RequestParam(value = "request", required = false) String request,
                                       @ApiParam(name = "respone", value = "respone")
                                           @RequestParam(value = "respone", required = false) String respone,
                                       @ApiParam(name = "status", value = "status")
                                           @RequestParam(value = "status", required = false) String status
                                       ) throws Exception {
        wlyyHttpLogService.saveHttpLog(code,name,patient,doctor,request,respone,status);
        return success("添加成功");
    }
}

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

@ -263,8 +263,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.checkOutpatient)
    @ApiOperation(value = "判断是否可用发起门诊", notes = "判断是否可用发起门诊")
    public ObjEnvelop checkOutpatient(@ApiParam(name = "patient", value = "续方明细")
                                      @RequestParam(value = "patient", required = true)String patient)throws Exception{
        return success(prescriptionService.checkOutpatient(patient,wxId));
                                      @RequestParam(value = "patient", required = true)String patient,
                                      @ApiParam(name = "flag", value = "标识是否开启结算")
                                      @RequestParam(value = "flag", required = false)boolean flag)throws Exception{
        return success(prescriptionService.checkOutpatient(patient,wxId,flag));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findAllHospital)
@ -1887,9 +1889,15 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(required = true)String patient) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.outpatient(patient));
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                return ObjEnvelop.getSuccess("ok",xzzxEntranceService.selectHistoryEmrFromEntrance(patient,null));
            }else {
                return ObjEnvelop.getSuccess("ok",prescriptionService.outpatient(patient));
            }
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
@ -1913,7 +1921,11 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "recSn", value = "医疗文书", required = false)
            @RequestParam(required = false)String recSn) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.getPatInfoDataXml(opid,recSn));
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                return ObjEnvelop.getSuccess("ok",xzzxEntranceService.selectBrowseSingleEMR(opid));
            }else {
                return ObjEnvelop.getSuccess("ok",prescriptionService.getPatInfoDataXml(opid,recSn));
            }
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
@ -2219,4 +2231,32 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        objEnvelop.setObj(xzzxEntranceService.saveEmrToEntrance(prescriptionId));
        return objEnvelop;
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.prescriptionManage)
    @ApiOperation(value = "处方管理")
    public MixEnvelop prescriptionManage(
            @ApiParam(name = "keyWord", value = "患者姓名或证件号或就诊卡")
            @RequestParam(value = "keyWord",defaultValue = "",required = false) String keyWord,
            @ApiParam(name = "doctorId", value = "医生id")
            @RequestParam(value = "doctorId",defaultValue = "",required = false) String doctorId,
            @ApiParam(name = "startTime", value = "开始时间")
            @RequestParam(value = "startTime",defaultValue = "",required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间")
            @RequestParam(value = "endTime",defaultValue = "",required = false) String endTime,
            @ApiParam(name = "checkStatus", value = "处方状态")
            @RequestParam(value = "checkStatus",defaultValue = "",required = false) String checkStatus,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page",defaultValue = "",required = false) Integer page,
            @ApiParam(name = "pageSize",value = "页大小")
            @RequestParam(value = "pageSize",defaultValue = "",required = false) Integer pageSize) throws Exception {
        return prescriptionService.prescriptionManage(keyWord,doctorId,startTime,endTime,checkStatus,page,pageSize);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.disablePrescription)
    @ApiOperation(value = "作废处方")
    public Envelop disablePrescription(
            @ApiParam(name = "prescriptionId", value = "prescriptionId")
            @RequestParam(value = "prescriptionId",defaultValue = "",required = true) String prescriptionId) throws Exception {
        return success(prescriptionService.disablePrescription(prescriptionId));
    }
}

+ 261 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/wechat/WechatCoreController.java

@ -0,0 +1,261 @@
package com.yihu.jw.hospital.endpoint.wechat;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.hospital.service.wechat.WeiXinCoreService;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
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.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
/*
 * Created by lyr on 2016/08/11.
*/
@Controller
@RequestMapping(value = "/weixin", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "微信", description = "微信", tags = {"微信"})
public class WechatCoreController extends EnvelopRestEndpoint {
    private Logger logger= LoggerFactory.getLogger(WechatCoreController.class);
    @Autowired
    private WeiXinCoreService weiXinCoreService;
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Value("${wechat.id}")
    private String wechatId;
    private static String wechat_token ="xAeQrX7uOD0OusIZ5JUQzrLPYIQBlqbS" ;
    @Autowired
    private WxPushLogDao wxPushLogDao;
    /**
     * 微信接口验证
     *
     * @param request
     * @param response
     */
    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public void checkSignature(HttpServletRequest request, HttpServletResponse response) {
        try {
            String signature = request.getParameter("signature").toString();
            String timestamp = request.getParameter("timestamp").toString();
            String nonce = request.getParameter("nonce").toString();
            String echostr = request.getParameter("echostr").toString();
            logger.info("echostr"+echostr+"===nonce"+nonce+"====signature"+signature+"====timestamp"+timestamp);
            if (validate(signature, timestamp, nonce)) {
                // 验证成功,返回验证码
                response.getWriter().print(echostr);
            } else {
                // 验证失败
                response.setStatus(401);
            }
        } catch (Exception e) {
            // 服务器错误
            response.setStatus(500);
        }
    }
  /* *//*
     * 接收居民微信回复的消息
     *
     * @return
    *//*
    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public void receiveMessages(HttpServletRequest request, HttpServletResponse response) {
        try {
            String signature = request.getParameter("signature").toString();
            String timestamp = request.getParameter("timestamp").toString();
            String nonce = request.getParameter("nonce").toString();
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (validate(signature, timestamp, nonce)) {
                String xmlStr = weiXinCoreService.messageProcess(request, wxAccessTokenDO.getAccessToken());
                // 判断返回值是xml、json格式(取关是空串)
                Boolean flag = weiXinCoreService.isXML(xmlStr);
                if (xmlStr == "error") {
                    // 服务器错误
                    response.setStatus(500);
                } else if (!flag && StringUtils.isNotEmpty(xmlStr)) {
                    JSONObject json = new JSONObject(xmlStr);
                    if (json.has("openId")) {
                        if (StringUtils.isNotEmpty(json.getString("openId")) && !("undefined".equals(json.getString("openId")))) {
                                try {
                                    logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+json.getString(""));
                                    weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), json.getString("openId"), json);
                                    logger.info("发送成功");
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    logger.info("发送失败,error="+e.getMessage());
                                }
                                //保存发送模板记录,
                                WxPushLogDO wxPushLogDO = new WxPushLogDO();
                                wxPushLogDO.setCreateTime(new Date());
                                wxPushLogDO.setOpenid(json.getString("openId"));
                                wxPushLogDO.setReceiver(null);
                                wxPushLogDO.setWechatId(wechatId);
                                wxPushLogDO.setReceiverName(null);
                                wxPushLogDO.setScene(null);
                                wxPushLogDao.save(wxPushLogDO);
                            }
                        }
                    }
                } else {
                    // 返回消息(图文消息)
                    response.setHeader("Content-type", "text/html;charset=UTF-8");
                    //这句话的意思,是告诉servlet用UTF-8转码,而不是用默认的ISO8859
                    response.setCharacterEncoding("UTF-8");
                    response.getWriter().print(null);
                }
            } else {
                // 验证失败
                response.setStatus(401);
            }
        } catch (Exception e) {
            e.printStackTrace();
            // 服务器错误
            response.setStatus(500);
        }
    }*/
    /**
     * 接收居民微信回复的消息
     *
     * @return
     */
    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public void receiveMessages(HttpServletRequest request, HttpServletResponse response) {
        try {
            String signature = request.getParameter("signature").toString();
            String timestamp = request.getParameter("timestamp").toString();
            String nonce = request.getParameter("nonce").toString();
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (validate(signature, timestamp, nonce)) {
                String xmlStr = weiXinCoreService.messageProcess(request, wxAccessTokenDO.getAccessToken());
                // 判断返回值是xml、json格式(取关是空串)
                Boolean flag = weiXinCoreService.isXML(xmlStr);
                if (xmlStr == "error") {
                    // 服务器错误
                    response.setStatus(500);
                } else if (!flag && StringUtils.isNotEmpty(xmlStr)) {
                    JSONObject json = new JSONObject(xmlStr);
                    if (json.has("openId")) {
                        if (StringUtils.isNotEmpty(json.getString("openId")) && !("undefined".equals(json.getString("openId")))) {
                            logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+json.getString(""));
                            WxTemplateConfigDO wxTemplateConfigDO = new WxTemplateConfigDO();
                            wxTemplateConfigDO.setRemark(json.toString());
                            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), json.getString("openId"), wxTemplateConfigDO);
                            logger.info("发送成功");
                        }
                    }
                } else {
                    // 返回消息(图文消息)
                    response.setHeader("Content-type", "text/html;charset=UTF-8");
                    //这句话的意思,是告诉servlet用UTF-8转码,而不是用默认的ISO8859
                    response.setCharacterEncoding("UTF-8");
                    logger.info(xmlStr);
                    response.getWriter().print(xmlStr);
                }
            } else {
                // 验证失败
                response.setStatus(401);
            }
        } catch (Exception e) {
            e.printStackTrace();
            // 服务器错误
            response.setStatus(500);
        }
    }
     /*
     * 微信推送消息验证
     *
     * @param signature
     * @param timestamp
     * @param nonce
     * @return
     * @throws NoSuchAlgorithmException
     */
    private boolean validate(String signature, String timestamp, String nonce) throws NoSuchAlgorithmException {
        String token = this.wechat_token;
        // 字典序排序
        String[] array = new String[]{token, timestamp, nonce};
        Arrays.sort(array);
        //连接字典序排序后字符串
        String content = "";
        for (String str : array) {
            content += str;
        }
        // 解析
        MessageDigest md = MessageDigest.getInstance("SHA-1");
        String decodeStr = "";
        byte[] bytes = md.digest(content.getBytes());
        decodeStr = byteToStr(bytes);
        if (StringUtils.isNotEmpty(decodeStr) && decodeStr.equals(signature.toUpperCase())) {
            return true;
        } else {
            return false;
        }
    }
    /*
     * 将字节数组转换为字符串
     *
     * @param byteArray
     * @return
    */
    private static String byteToStr(byte[] byteArray) {
        String strDigest = "";
        for (int i = 0; i < byteArray.length; i++) {
            strDigest += byteToHexStr(byteArray[i]);
        }
        return strDigest;
    }
    /*
     * 将字节转换为字符
     *
     * @param mByte
     * @return
     */
    private static String byteToHexStr(byte mByte) {
        char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
        char[] tempArr = new char[2];
        tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
        tempArr[1] = Digit[mByte & 0X0F];
        String s = new String(tempArr);
        return s;
    }
}

+ 79 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/wechat/WechatMenuController.java

@ -0,0 +1,79 @@
package com.yihu.jw.hospital.endpoint.wechat;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONObject;
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.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
/**
 * Created by chenweida on 2017/8/4.
 */
@Controller
@RequestMapping(value = "/wechat/menu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "微信菜单相关管理")
public class WechatMenuController extends EnvelopRestEndpoint {
    private Logger logger= LoggerFactory.getLogger(WechatMenuController.class);
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Value("${wechat.id}")
    private String wechatId;
    /**
     * 微信菜单创建
     *
     * @return
     */
    @ApiOperation(value = "微信菜单创建")
    @RequestMapping(value = "/menu/create", method = RequestMethod.GET)
    public String createMenuTest() {
        try {
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            String filePath = "/usr/local/hospital/weixin_menu.txt";
            logger.info("filePath"+filePath);
            String url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + wxAccessTokenDO.getAccessToken();
            // 读取微信菜单配置文件
            InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), "utf-8");
            BufferedReader bufferedReader = new BufferedReader(reader);
            String params = "";
            String readTxt = "";
            // 读取微信菜单
            while ((readTxt = bufferedReader.readLine()) != null) {
                System.out.println(readTxt);
                params += readTxt;
            }
            bufferedReader.close();
            reader.close();
            // 请求微信接口创建菜单
            String jsonStr = HttpUtil.sendPost(url, params);
            logger.info("日志"+jsonStr);
            JSONObject result = new JSONObject(jsonStr);
            if (result != null && result.get("errcode").toString().equals("0") && result.getString("errmsg").equals("ok")) {
                return  "创建成功!";
            } else {
                return "创建失败!";
            }
        } catch (Exception e) {
            return  "创建失败";
        }
    }
}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 171 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/QrcodeService.java


+ 105 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/wechat/WeiXinCoreService.java

@ -0,0 +1,105 @@
package com.yihu.jw.hospital.service.wechat;
import com.yihu.jw.util.wechat.WeiXinMessageUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by lyr on 2016/08/11.
 */
@Service
public class WeiXinCoreService {
    private Logger logger= LoggerFactory.getLogger(WeiXinCoreService.class);
    @Autowired
    private WeiXinEventProcess weiXinEventProcess;
    /**
     * 微信推送消息处理
     *
     * @param request
     * @param accessToken
     */
    public String messageProcess(HttpServletRequest request, String accessToken) {
        try (InputStream inputStream = request.getInputStream()){
            String returnStr = "";
            // 将解析结果存储在HashMap中
            Map<String, String> message = new HashMap();
            // 从request中取得输入流
            // 读取输入流
            SAXReader reader = new SAXReader();
            Document document = reader.read(inputStream);
            // 得到xml根元素
            Element root = document.getRootElement();
            // 得到根元素的所有子节点
            List elementList = root.elements();
            // 遍历所有子节点
            for (Object e : elementList) {
                Element ele = (Element) e;
                message.put(ele.getName(), ele.getText());
            }
//            logger.info("weixin  event:" + message.toString());
            // 添加access_token参数
            message.put("token", accessToken);
            // 消息处理
            returnStr = messageProcess(message);
            return returnStr;
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }
    }
    /**
     * 对接收到的消息进行处理
     *
     * @param message
     * @return
     */
    private String messageProcess(Map<String, String> message) throws Exception {
        String msgType = message.get("MsgType");
        String result = "";
        switch (msgType) {
            case WeiXinMessageUtils.REQ_MESSAGE_TYPE_EVENT:  // 事件消息
                result = weiXinEventProcess.eventProcess(message);
                break;
            case WeiXinMessageUtils.RESP_MESSAGE_TYPE_TEXT:  // 回复文本消息
                String content = message.get("Content");
                break;
            default:
                break;
        }
        return result;
    }
    /**
     * 判断是否是xml结构
     */
    public boolean isXML(String value) {
        try {
            DocumentHelper.parseText(value);
        } catch (DocumentException e) {
            return false;
        }
        return true;
    }
}

+ 120 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/wechat/WeiXinEventProcess.java

@ -0,0 +1,120 @@
package com.yihu.jw.hospital.service.wechat;
import com.netflix.discovery.converters.Auto;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.util.wechat.WeiXinMessageReplyUtils;
import com.yihu.jw.util.wechat.WeiXinMessageUtils;
import org.apache.commons.lang3.StringUtils;
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.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 微信事件处理
 * <p>
 * Created by lyr on 2016/08/11
 */
@Component
public class WeiXinEventProcess {
    private static Logger logger = LoggerFactory.getLogger(WeiXinEventProcess.class);
    @Value("${wechat.id}")
    private String wechatId;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    /**
     * 微信推送事件处理
     *
     * @param message
     * @return
     */
    public String eventProcess(Map<String, String> message) throws Exception {
        String result = "";
        String event = message.get("Event");
        switch (event) {
            case WeiXinMessageUtils.EVENT_TYPE_SCAN: // 扫描二维码事件
                result = scanEventProcess(message);
                break;
            case WeiXinMessageUtils.EVENT_TYPE_SUBSCRIBE: // 订阅事件
                if (message.containsKey("EventKey") && StringUtils.isNotEmpty(message.get("EventKey")) && message.containsKey("Ticket")
                        && StringUtils.isNotEmpty(message.get("Ticket"))) {
                    result = scanEventProcess(message);
                } /*else {
                    result = subscribeEventProcess(message);
                }*/
                break;
            /*case WeiXinMessageUtils.EVENT_TYPE_UNSUBSCRIBE: // 取消订阅事件
                 result = unsubscribeEventProcess(message);
                break;
            case WeiXinMessageUtils.EVENT_TYPE_CLICK: //菜单点击
                result = this.clickProcess(message);*/
            default:
                break;
        }
        return result;
    }
    /**
     * 微信扫码事件处理(封装图文消息体)
     *
     * @param message
     * @return
     * @throws Exception
     */
    private String scanEventProcess(Map<String, String> message) throws Exception {
        String result = "";
        // 场景值
        String eventKey = message.get("EventKey");
        if (StringUtils.isNotEmpty(eventKey) && (eventKey.startsWith("doctor_"))) {
            // 图文信息
            List<Map<String, String>> articles = new ArrayList<>();
            Map<String, String> article = new HashMap<>();
            // 二维码参数
            String[] keys = eventKey.replace("doctor_", "").split("_");
            // 图片URL
            String picUrl = "";
            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(keys[0]);
            String url = null;
            if (null!=baseDoctorDO){
                picUrl = baseDoctorDO.getPhoto();
            }
            // 医生二维码跳转URL
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                url = "https://intel.yanketong.com/ims-wx/#/doctorInfo?doctorCode="+keys[0];
                picUrl = "https://intel.yanketong.com/"+picUrl;
            }
            // 图文消息URL
            //图片地址
//            picUrl = picUrl.replace("{server}", serverUrl);
            article.put("Url", url);
            article.put("Title", keys[1] + "医生个人诊间");
            article.put("Description", "厦门眼科中心医院互联网医院");
            article.put("PicUrl", picUrl);
            articles.add(article);
            // 消息XML
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }
        return result;
    }
}

+ 1 - 1
svr/svr-internet-hospital/src/main/resources/application.yml

@ -650,7 +650,7 @@ hospital:
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.16.100.241:3000/
  im_list_get: http://172.16.100.65:3000/
  data_base_name: im
# 上传文件临时路径配置

+ 60 - 0
svr/svr-internet-hospital/src/main/resources/wechat/weixin_menu.txt

@ -0,0 +1,60 @@
{
"button":[
   {
	  "name":"掌上医院",
	  "type":"view",
      "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3A%2F%2Fintel.yanketong.com%2Fims-wx%2F%23%2FzsIndex&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
   },
   {
	  "name":"就医问诊",
	  "sub_button":[
		 {
         		"type":"view",
         		"name":"预约挂号",
         		"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3A%2F%2Fintel.yanketong.com%2Fims-wx%2F%23%2Fappointment%2FhospitalList&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		 {
            	"type":"view",
         	    "name":"充值缴费",
         		"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3A%2F%2Fintel.yanketong.com%2Fims-wx%2F%23%2FmedicalCard%2Findex&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		 {
                "type":"view",
               	"name":"专家咨询",
               	"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3A%2F%2Fintel.yanketong.com%2Fims-wx%2F%23%2FnDocList%3Fzjzx%3D2&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
         {
                "type":"view",
                "name":"在线复诊",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3A%2F%2Fintel.yanketong.com%2Fims-wx%2F%23%2FnDocList%3FisFz%3D1&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         }
	  ]
   },
   {
	  "name":"我",
	  "sub_button":[
		 {
                "type":"view",
                "name":"个人中心",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3A%2F%2Fintel.yanketong.com%2Fims-wx%2F%23%2Fpersonal%2Findex&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
         {
        		"type":"view",
        		"name":"APP下载",
        		"url":"http://www.yanketong.com/app/yk.htm"
         },
         {
                "type":"view",
                "name":"报告查询",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3A%2F%2Fintel.yanketong.com%2Fims-wx%2F%23%2FonlineCheck%2Findex&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
         },
         {
               	"type":"view",
                "name":"家庭成员管理",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3A%2F%2Fintel.yanketong.com%2Fims-wx%2F%23%2FfamilyControl%2Findex&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         }
	 ]
  }
]
}