Forráskód Böngészése

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

humingfen 5 éve
szülő
commit
6fad5b5a67
58 módosított fájl, 4769 hozzáadás és 879 törlés
  1. 7 0
      business/base-service/pom.xml
  2. 25 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseDeptDictDao.java
  3. 25 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseSuperviseDataDictDao.java
  4. 25 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseSuperviseDictDao.java
  5. 9 14
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java
  6. 396 10
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java
  7. 168 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/AES.java
  8. 152 0
      business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java
  9. 5 0
      business/base-service/src/main/java/com/yihu/jw/internet/dao/HospitalImgDao.java
  10. 1824 0
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java
  11. 1 1
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetService.java
  12. 15 0
      business/base-service/src/main/java/com/yihu/jw/oauth/OauthRsaKeyDao.java
  13. 184 0
      business/base-service/src/main/java/com/yihu/jw/oauth/OauthSsoService.java
  14. 0 1
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java
  15. 98 0
      business/base-service/src/main/java/com/yihu/jw/utils/RSAEncrypt.java
  16. 51 2
      business/base-service/src/main/java/com/yihu/jw/wechat/enterprise/EnterpriseService.java
  17. 7 2
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java
  18. 35 4
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WxTemplateService.java
  19. 13 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictDoctorDutyDO.java
  20. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  21. 56 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseDeptDict.java
  22. 251 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseSuperviseDataDict.java
  23. 158 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseSuperviseDict.java
  24. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/jgpt/HospitalImgDO.java
  25. 8 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  26. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/bank/HealthBankMapping.java
  27. 38 0
      common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java
  28. 9 2
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseMethodLogService.java
  29. 2 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  30. 16 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthSsoService.java
  31. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthYlzConfigService.java
  32. 6 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/RegisterService.java
  33. 155 783
      svr/svr-base/sql/init.sql
  34. 96 17
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java
  35. 51 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/methodlog/MethodLogEndpoint.java
  36. 63 0
      svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogDO.java
  37. 10 0
      svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogDao.java
  38. 25 0
      svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogService.java
  39. 28 5
      svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java
  40. 13 1
      svr/svr-base/src/main/resources/application.yml
  41. 7 1
      svr/svr-base/src/main/resources/bootstrap.yml
  42. 106 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java
  43. 2 2
      svr/svr-internet-hospital-job/pom.xml
  44. 126 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/CommonDataUploadJob.java
  45. 83 4
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  46. 71 9
      svr/svr-internet-hospital-job/src/main/resources/application.yml
  47. 8 0
      svr/svr-internet-hospital-job/src/main/resources/bootstrap.yml
  48. 2 0
      svr/svr-internet-hospital-job/src/main/resources/system.properties
  49. 63 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/Xzyy/XzyyController.java
  50. 3 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  51. 32 11
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  52. 25 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  53. 61 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java
  54. 33 1
      svr/svr-internet-hospital/src/main/resources/application.yml
  55. 3 1
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ActivityController.java
  56. 27 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/CreditsDetailController.java
  57. 33 4
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java
  58. 36 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/CreditsDetailService.java

+ 7 - 0
business/base-service/pom.xml

@ -53,6 +53,12 @@
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>
        <!--易惠支付接口-->
        <dependency>
            <groupId>com.ylz</groupId>
            <artifactId>jdk7-onepay-java-sdk</artifactId>
            <version>20190425</version>
        </dependency>
        <!-- xlsx  依赖这个包 -->
        <dependency>
            <groupId>org.apache.poi</groupId>
@ -139,6 +145,7 @@
            <artifactId>ehcsdk</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>

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

@ -0,0 +1,25 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.hospital.dict.BaseDeptDict;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 
 * 监管平台字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年10月19日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDeptDictDao extends PagingAndSortingRepository<BaseDeptDict, Integer>, JpaSpecificationExecutor<BaseDeptDict>  {
    @Query("select s from BaseDeptDict s where s.deptCode=1")
    BaseDeptDict selectByDeptCode(String deptCode);
}

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

@ -0,0 +1,25 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDataDict;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 
 * 监管平台字典
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年10月19日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseSuperviseDataDictDao extends PagingAndSortingRepository<BaseSuperviseDataDict, Integer>, JpaSpecificationExecutor<BaseSuperviseDataDict>  {
    @Query("select s from BaseSuperviseDataDict s where s.status=1")
    BaseSuperviseDataDict selectByDictName();
}

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

@ -0,0 +1,25 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 
 * 监管平台字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年10月19日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseSuperviseDictDao extends PagingAndSortingRepository<BaseSuperviseDict, Integer>, JpaSpecificationExecutor<BaseSuperviseDict>  {
    @Query("select s from BaseSuperviseDict s where s.status=1")
    BaseSuperviseDict selectByDictName();
}

+ 9 - 14
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java

@ -1,34 +1,24 @@
package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.sf.SfConfigDO;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.util.SFUtils;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientKit;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.sfutils.HttpClientUtils;
import com.yihu.jw.utils.sfutils.SHAUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.entity.ContentType;
import org.apache.http.message.BasicNameValuePair;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
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.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
@ -104,10 +94,15 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
     */
    private String SFExpressPost(String xml)throws Exception{
        String verifyCode = SFUtils.verifyCodeSFXmlStr(xml,sf_check_word);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("xml", xml));
        params.add(new BasicNameValuePair("verifyCode", verifyCode));
        String re = HttpClientKit.post(sf_url, params, "UTF-8");
//        List<NameValuePair> params = new ArrayList<>();
//        params.add(new BasicNameValuePair("xml", xml));
//        params.add(new BasicNameValuePair("verifyCode", verifyCode));
    
        JSONObject j =  addOrder();
        j.put("xml",xml);
        j.put("verifyCode",verifyCode);
        
        String re = HttpClientUtils.doPost(sf_url, j.toJSONString(), ContentType.APPLICATION_JSON);
        return re;
    }

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

@ -14,6 +14,7 @@ import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
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.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
@ -21,9 +22,12 @@ import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
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.prescription.service.entrance.util.AES;
import com.yihu.jw.patient.dao.BasePatientDao;
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.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
@ -71,17 +75,38 @@ public class XzzxEntranceService {
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private static String key="bvvsf3JA0mUXMU+mVnMaOQ==";
    //发送微信模板消息
    public static String sendMessageUrl ="http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
    public String getXzzxWebServiceInfo(String api, Map<String,String> params)throws Exception{
    public static String entranceUrl = "http://172.16.100.240:10023/xzzx/";
    public String getSelectUrl(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("xzzxWebSelectService");
        String url = list.get(0).getDictCode();
        return url;
    }
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("xzzxWebService");
    public String getOperateUrl(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("xzzxWebOperateService");
        String url = list.get(0).getDictCode();
        return url;
    }
    public String getXzzxWebServiceInfo(String api, Map<String,String> params,String url)throws Exception{
        logger.info("url"+url);
@ -100,7 +125,6 @@ public class XzzxEntranceService {
     */
    public String getDeptInfo(String code)throws Exception{
        String api = "GetDeptInfo";
        String key ="bvvsf3JA0mUXMU+mVnMaOQ==";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
@ -120,7 +144,7 @@ public class XzzxEntranceService {
        params.put("msgBody",msgBody);
        logger.info("getDeptInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params);
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
@ -172,7 +196,6 @@ public class XzzxEntranceService {
     */
    public String getDoctorInfo(String idcard)throws Exception{
        String api = "GetDoctorInfo";
        String key ="bvvsf3JA0mUXMU+mVnMaOQ==";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
@ -192,7 +215,7 @@ public class XzzxEntranceService {
        params.put("msgBody",msgBody);
        logger.info("getDoctorInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params);
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
@ -368,7 +391,6 @@ public class XzzxEntranceService {
     */
    public String getJobTitle()throws Exception{
        String api = "GetTitleInfo";
        String key ="bvvsf3JA0mUXMU+mVnMaOQ==";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
@ -384,7 +406,7 @@ public class XzzxEntranceService {
        params.put("msgBody",msgBody);
        logger.info("getJobTitleInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params);
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
@ -419,7 +441,6 @@ public class XzzxEntranceService {
     */
    public String getChargeDict()throws Exception{
        String api = "GetScheduleType";
        String key ="bvvsf3JA0mUXMU+mVnMaOQ==";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
@ -435,7 +456,7 @@ public class XzzxEntranceService {
        params.put("msgBody",msgBody);
        logger.info("getChargeDictInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params);
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
@ -471,6 +492,257 @@ public class XzzxEntranceService {
        }
        return json;
    }
    /**
     * 查询患者就诊卡
     * @param idCard 身份证
     * @return
     * @throws Exception
     */
    //查询患者就诊卡
    public String findPatientCard(String idCard)throws Exception{
        String api = "FindPatientCard";
        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("findPatientCard params:"+params.toString());
        String xml = getXzzxWebServiceInfo("FindPatientCard",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("findPatientCard json:"+json);
        return json;
    }
    /**
     *
     *  获取卡信息
     *
     * @param cardNo 卡号(必填)
     * @return
     * @throws Exception
     */
    //获取卡信息
    public String getCardInfo(String cardNo)throws Exception{
        String api = "GetCardInfo";
        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(cardNo)){
            condition = "<cardNo>"+cardNo+"</cardNo>";
        }
        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("getCardInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("GetCardInfo",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getCardInfo json:"+json);
        return json;
    }
    /**
     * 获取单条门诊就诊记录
     * @param patient 居民id
     * @param conNo 就诊次数
     * @return
     * @throws Exception
     */
    //获取单条门诊就诊记录
    public String findOutpatientInfo(String patient,String conNo)throws Exception{
        String api = "FindOutpatientInfo";
        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(patient)){
            condition += "<patient>"+patient+"</patient>";
        }
        if (StringUtils.isNoneBlank(conNo)){
            condition += "<conNo>"+conNo+"</conNo>";
        }
        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("FindOutpatientInfo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("FindOutpatientInfo",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getCardInfo json:"+json);
        return json;
    }
    /**
     * 获取门诊下所有处方信息
     * @param registerSn 流水号(必传)
     * @param patNo 病人id(必传)
     * @param admNo 住院唯一号(必传)
     * @param realOrder 处方号(非必传,传相当于查单条处方)
     * @return
     * @throws Exception
     */
    //获取门诊下所有处方信息
    public String getOriginPrescriptionList(String registerSn,String patNo,String admNo,String realOrder)throws Exception{
        String api = "GetOriginPrescriptionList";
        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(registerSn)){
            condition += "<registerSn>"+registerSn+"</registerSn>";
        }
        if (StringUtils.isNoneBlank(patNo)){
            condition += "<patNo>"+patNo+"</patNo>";
        }
        if (StringUtils.isNoneBlank(admNo)){
            condition += "<admNo>"+admNo+"</admNo>";
        }
        if (StringUtils.isNoneBlank(realOrder)){
            condition += "<realOrder>"+realOrder+"</realOrder>";
        }
        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("getOriginPrescriptionList params:"+params.toString());
        String xml = getXzzxWebServiceInfo("GetOriginPrescriptionList",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getOriginPrescriptionList json:"+json);
        return json;
    }
    /**
     * 挂号(调his后台包)
     * @param doctor 医生ID(必填)
     * @param dept 科室编码(必填)
     * @param sickId 病人id
     * @param clinicclass 挂号类别(必填)
     * @return
     * @throws Exception
     */
    //挂号(调his后台包)
    public String registered(String doctor,String dept,String sickId,String clinicclass)throws Exception{
        String api = "Registered";
        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(doctor)){
            condition += "<doctor>"+doctor+"</doctor>";
        }
        if (StringUtils.isNoneBlank(dept)){
            condition +="<dept>"+dept+"</dept>";
        }
        if (StringUtils.isNoneBlank(sickId)){
            condition += "<sickId>"+sickId+"</sickId>";
        }
        if (StringUtils.isNoneBlank(clinicclass)){
            condition +="<clinicclass>"+clinicclass+"</clinicclass>";
        }
        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("registered params:"+params.toString());
        String xml = getXzzxWebServiceInfo("Registered",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("registered json:"+json);
        return json;
    }
    /**
     * 处方状态变更
     * @param admNo 就诊唯一号(必填)
     * @param realOrder 处方号(必填)
     * @param status 处方状态:3结算完成(必填)
     * @return
     * @throws Exception
     */
    //处方状态变更
    public String updatePreStatus(String admNo,String realOrder,String status)throws Exception{
        String api = "UpdatePreStatus";
        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(admNo)){
            condition += "<admNo>"+admNo+"</admNo>";
        }
        if (StringUtils.isNoneBlank(realOrder)){
            condition +="<realOrder>"+realOrder+"</realOrder>";
        }
        if (StringUtils.isNoneBlank(status)){
            condition += "<status>"+status+"</status>";
        }
        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("updatePreStatus params:"+params.toString());
        String xml = getXzzxWebServiceInfo("UpdatePreStatus",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("updatePreStatus json:"+json);
        return json;
    }
//=====================微信模板消息推送===================================
    public String sendMes(String wxId,String patient,String cardNo,String first,String noticeContent,String remark,String redirectUrl){
@ -555,6 +827,120 @@ public class XzzxEntranceService {
        }
    }
    /**
     * 获取心脏医院token
     * @return
     * @throws Exception
     */
    public String getXzToken() throws Exception{
        JSONObject params = new JSONObject();
        params.put("appId","1BQ08T2R60006501A8C00000BE73319D");
        params.put("encryptType","DES");
        params.put("sign","58E40DCEA527333B9E7C3CCD1A08979F");
        params.put("signType","MD5");
        params.put("timestamp",new Date().getTime());
        params.put("version","v.1.0.0");
        params.put("serviceId","ext.user.getTokenByMerchId");
        JSONObject p = new JSONObject();
        p.put("medicalId","3501000014");
        params.put("param",p);
        String rs = HttpUtil.sendPost("http://xzbh.xmheart.com:8090/hospitalPortal-ext-app/ext/app/unifyapi",params.toJSONString());
        logger.info("rs :"+rs);
        JSONObject rsJson = JSON.parseObject(rs);
        String tokenAES = rsJson.getJSONObject("param").getString("token");
        String token = AES.decrypt("xm_xxg_zxzx", tokenAES);
        return token;
    }
    public String ehospitalNotice(String userName, String idCard, String phone, String title, String url, String content, String contentString) {
        logger.info("ehospitalNotice:");
        BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(idCard,"1");
        if(patientDO!=null&&StringUtils.isNotBlank(patientDO.getIdcard())){
            sendMes("xm_xzzx_wx",patientDO.getId(),null,content,contentString,"",url);
        }
        return "-2";
    }
//=====================微信模板消息推送接口================================
//=====================hospital应用调用entrance应用============start=================
    /**
     * 查询患者就诊卡
     * @param idCard 身份证号
     * @return
     */
    public String selectPateintCard(String idCard){
        String response="";
        String url = entranceUrl+"findPatientCard?idCard="+idCard;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
    /**
     * 获取卡信息
     * @param cardNo 就诊卡
     * @return
     */
    public String selectCardInfo(String cardNo){
        String response="";
        String url = entranceUrl+"getCardInfo?cardNo="+cardNo;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
    /**
     * 获取单条门诊就诊记录
     * @param patient 居民id
     * @param conNo 就诊次数
     * @return
     */
    public String selectOutpatientInfo(String patient,String conNo){
        String response="";
        String url = entranceUrl+"findOutpatientInfo?patient="+patient+"&conNo="+conNo;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
    /**
     * 获取门诊下所有处方信息
     * @param registerSn 流水号
     * @param patNo 病人id
     * @param admNo 住院唯一号
     * @param realOrder 处方号
     * @return
     */
    public String selectOriginPrescriptionList(String registerSn,String patNo,String admNo,String realOrder){
        String response="";
        String url = entranceUrl+"getOriginPrescriptionList?registerSn="+registerSn+"&patNo="+patNo+"&admNo="+admNo+"&realOrder"+realOrder;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
    /**
     *
     * 挂号(调his后台包)
     * @param doctor 医生ID(必填)
     * @param dept 科室编码(必填)
     * @param sickId 病人id
     * @param clinicclass 挂号类别(必填)
     * @return
     */
    public String registeredOperate(String doctor,String dept,String sickId,String clinicclass){
        String response="";
        String url = entranceUrl+"registered?doctor="+doctor+"&dept="+dept+"&sickId="+sickId+"&clinicclass"+clinicclass;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
//=====================hospital应用调用entrance应用============end=================
}

+ 168 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/AES.java

@ -0,0 +1,168 @@
package com.yihu.jw.hospital.prescription.service.entrance.util;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import com.yihu.jw.utils.encode.Base64;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class AES {
	public static String encrypt(String strKey, String strIn) {
		try {
			SecretKeySpec skeySpec = getKey(strKey);
			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			IvParameterSpec iv = new IvParameterSpec(
					"0102030405060708".getBytes());
			cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
			byte[] encrypted = cipher.doFinal(strIn.getBytes("UTF-8"));
			return Base64.encode(encrypted);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	public static String decrypt(String strKey, String strIn) throws Exception {
		try {
			SecretKeySpec skeySpec = getKey(strKey);
			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			IvParameterSpec iv = new IvParameterSpec(
					"0102030405060708".getBytes());
			cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
			byte[] encrypted1 = Base64.decode(strIn);
			byte[] original = cipher.doFinal(encrypted1);
			String originalString = new String(original, "UTF-8");
			return originalString;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	private static SecretKeySpec getKey(String strKey) throws Exception {
		byte[] arrBTmp = strKey.getBytes();
		byte[] arrB = new byte[16]; // 创建一个空的16位字节数组(默认值为0)
		for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) {
			arrB[i] = arrBTmp[i];
		}
		SecretKeySpec skeySpec = new SecretKeySpec(arrB, "AES");
		return skeySpec;
	}
	
	/** 
	 * 随机生成秘钥 
	 */  
	public static void generateKey(){    
	    try {    
	        KeyGenerator kg = KeyGenerator.getInstance("AES");    
	        kg.init(128);//要生成多少位,只需要修改这里即可128, 192或256    
	        SecretKey sk = kg.generateKey();    
	        byte[] b = sk.getEncoded();    
	        String s = byteToHexString(b);    
	        System.out.println(s);    
	        System.out.println("十六进制密钥长度为"+s.length());    
	        System.out.println("二进制密钥的长度为"+s.length()*4);    
	    } catch (NoSuchAlgorithmException e) {    
	        e.printStackTrace();    
	        System.out.println("没有此算法。");    
	    }    
	} 
	
	/** 
	 * byte数组转化为16进制字符串 
	 * @param bytes 
	 * @return 
	 */  
	public static String byteToHexString(byte[] bytes){       
	    StringBuffer sb = new StringBuffer();       
	    for (int i = 0; i < bytes.length; i++) {       
	         String strHex=Integer.toHexString(bytes[i]);   
	         if(strHex.length() > 3){       
	                sb.append(strHex.substring(6));       
	         } else {    
	              if(strHex.length() < 2){    
	                 sb.append("0" + strHex);    
	              } else {    
	                 sb.append(strHex);       
	              }       
	         }    
	    }    
	   return  sb.toString();       
	}
	public static String signConvertToPara(String region) {
		String target = "";
		if (region != null) {
			target = region.replaceAll("\\+", "%2B").replaceAll("\\ ", "%20")
					.replaceAll("\\/", "%2F").replaceAll("\\?", "%3F")
					.replaceAll("\\#", "%23").replaceAll("\\&", "%26")
					.replaceAll("\\=", "%3D");
		}
		return target;
	}
	public static String paraConvertsign(String region) {
		String target = "";
		if (region != null) {
			target = region.replaceAll("%2B", "+").replaceAll("%20", " ")
					.replaceAll("%2F", "/").replaceAll("%3F", "?")
					.replaceAll("%25", "%").replaceAll("%23", "#")
					.replaceAll("%26", "&").replaceAll("%3D", "=");
		}
		return target;
	}
	//用于和c#互通的加解密
	//https://www.jianshu.com/p/9483c9ea3a04
	 /**
     * AES的加密函数
     * @param str 传入需要加密的字符
     * @param key 传入一个16位长度的密钥。否则报错
     * @return 执行成功返回加密结果,否则报错
     * @throws Exception 抛出一个加密异常
     */
    public static String aesEncrypt(String str, String key) throws Exception {
        if (str == null || key == null) return null;
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key.getBytes("utf-8"), "AES"));
        byte[] bytes = cipher.doFinal(str.getBytes("utf-8"));
        return new BASE64Encoder().encode(bytes);
    }
    /**
     * AES的解密函数
     * @param str 传入需要解密的字符
     * @param key 传入一个16位长度的密钥。否则报错
     * @return 执行成功返回加密结果,否则报错
     * @throws Exception 抛出一个解密异常
     */
    public static String aesDecrypt(String str, String key) throws Exception {
        if (str == null || key == null) return null;
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key.getBytes("utf-8"), "AES"));
        byte[] bytes = new BASE64Decoder().decodeBuffer(str);
        bytes = cipher.doFinal(bytes);
        return new String(bytes, "utf-8");
    }
    
	public static void main(String[] args) throws Exception {
		generateKey();
		String testKey = "xmxzzxtj";
		String testEn = AES.encrypt(testKey, "{'function':'healthExam','yyid00':'220006','userId':'','name':'','phone':'','identityCard':'','icCard':''}");
		System.out.println(testEn);
		String testDe = AES.decrypt(testKey, testEn);
		System.out.println(testDe);
		
	}
}

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

@ -0,0 +1,152 @@
package com.yihu.jw.hospital.ykyy.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
 *
 * 眼科通接口
 *
 * Created by wangzhinan on 2020/4/11.
 */
@Service
public class YkyyService {
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private BasePatientDao patientDao;
    private static String yktUrl = "http://www.yanketong.com:133/api/";
    public String selectCards(String patient) throws Exception {
        String response = null;
        BasePatientDO basePatientDO  = patientDao.findById(patient);
        if (basePatientDO!=null){
            String userId = basePatientDO.getUserId();
            if (StringUtils.isNoneBlank(userId)){
               response = selectCardList(userId);
            }else {
               String response1 = getShortMessage("1",basePatientDO.getMobile());
                JSONObject jsonObject = JSONObject.parseObject(response1);
                if (jsonObject.getString("code").equalsIgnoreCase("10000")){
                    String code = jsonObject.getString("value");
                    String r =getRegisterUser(basePatientDO.getMobile(),"123456",code,"a01522","xmijk","xmijk");
                    JSONObject object = JSONObject.parseObject(r);
                    if (object.getString("code").equalsIgnoreCase("200")){
                        JSONObject object1 = object.getJSONObject("data");
                        if (object1!=null){
                            userId = object1.getString("ID");
                            basePatientDO.setUserId(userId);
                            patientDao.save(basePatientDO);
                            response = selectCardList(userId);
                        }
                    }else {
                        throw new Exception("用户注册失败");
                    }
                }else {
                    throw new Exception("获取验证码失败");
                }
            }
        }
        return response;
    }
    /**
     * 互联网-添加就诊卡
     * @param patient
     * @param card
     * @param userId
     * @param type
     * @return
     */
    public String addYkCard(String patient,String card,String userId,String type){
        String response = null;
        BasePatientDO patientDO = patientDao.findById(patient);
        String user_id=null;
        if (StringUtils.isNoneBlank(userId)){
            user_id=userId;
        }else {
            user_id=patientDO.getUserId();
        }
        response = addCard(user_id,patientDO.getName(),card,"7A585AB3-ED33-B40D-C3E3-A8BB0A1195D8","厦门大学附属厦门眼科中心思北院区",type,"1");
        return response;
    }
    /**
     * 眼科通验证码
     * @param type
     * @param phone
     * @return
     */
    public String getShortMessage(String type,String phone){
        String response="";
        String url = yktUrl+"verification_code/short_message?type="+type+"&telephone="+phone;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
    /**
     * telephone=15578008051&patient_pwd=123456&code=513970&invite_code=a01522&equipment_type=ios&equipment_guid=12312321
     * 眼科通用户注册
     *
     * @param telephone
     * @param patientPwd
     * @param code
     * @return
     */
    public String getRegisterUser(String telephone,String patientPwd,String code,String inviteCode,String equipmentType,String equipmentGuid){
        String response="";
        String url = yktUrl+"user_center/patient_register01?telephone="+telephone+"&patient_pwd="+patientPwd+"&code="+code+"&invite_code="+inviteCode+"&equipment_type="+equipmentType+
                "&equipment_guid="+equipmentGuid;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
    /**
     * 获取就诊卡数据接口
     * @param userId
     * @return
     */
    public String selectCardList(String userId){
        String response="";
        Map<String,Object> param = new HashedMap();
        param.put("user_id",userId);
        String url = yktUrl+"patient/get_patient_card_list?user_id="+userId;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
    /**
     * user_id=1a6a0016-a788-3c84-82e0-f1283e891ccc&patient_name=wangzhinan&card=12345678901&hospital_id=7A585AB3-ED33-B40D-C3E3-A8BB0A1195D8&hospital_name=厦门大学附属厦门眼科中心思北院区&type=0&hos_num=1
     *
     * 添加就诊卡接口
     *
     *
     */
    public String addCard(String userId,String patientName,String card,String hospitalId,String hospitalName,String type,String hosNum){
        String response="";
        String url = yktUrl+"patient/add_card?user_id="+userId+"&patient_name="+patientName+"&card="+card+"&hospital_id="+hospitalId+
                "&hospital_name="+hospitalName+"&type="+type+"&hos_num="+hosNum;
        response = httpClientUtil.get(url,"GBK");
        return response;
    }
}

+ 5 - 0
business/base-service/src/main/java/com/yihu/jw/internet/dao/HospitalImgDao.java

@ -1,11 +1,16 @@
package com.yihu.jw.internet.dao;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import com.yihu.jw.entity.hospital.jgpt.HospitalImgDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2019/11/28.
 */
public interface HospitalImgDao extends PagingAndSortingRepository<HospitalImgDO, String>, JpaSpecificationExecutor<HospitalImgDO> {
    @Query("select s from HospitalImgDO s where s.id=?1 and s.status=1")
    HospitalImgDO selectById(String id);
}

+ 1824 - 0
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java

@ -0,0 +1,1824 @@
package com.yihu.jw.internet.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.BaseDeptDictDao;
import com.yihu.jw.dict.dao.BaseSuperviseDataDictDao;
import com.yihu.jw.dict.dao.BaseSuperviseDictDao;
import com.yihu.jw.dict.dao.DictDoctorDutyDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.dict.BaseDeptDict;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDataDict;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import com.yihu.jw.entity.hospital.jgpt.HospitalImgDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.internet.dao.HospitalImgDao;
import com.yihu.jw.internet.dao.IntUpErrorLogDao;
import com.yihu.jw.internet.dao.InternetUpLogDao;
import com.yihu.jw.internet.entity.InternetUpErrorLogDO;
import com.yihu.jw.internet.entity.InternetUpLogDO;
import com.yihu.jw.internet.wsapi.Wsapi;
import com.yihu.jw.internet.wsapi.WsapiProxy;
import com.yihu.jw.patient.dao.BasePatientDao;
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.ImgUtils;
import com.yihu.jw.utils.JSONUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.encode.AESUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import nu.xom.jaxen.function.IdFunction;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedCaseInsensitiveMap;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.math.BigDecimal;
import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO, IntUpErrorLogDao> {
    private org.slf4j.Logger logger = LoggerFactory.getLogger(InternetCommonService.class);
    @Autowired
    private InternetUpErrorLogService internetUpErrorLogService;
    @Autowired
    private InternetUpLogDao internetUpLogDao;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private HospitalImgDao hospitalImgDao;
    @Autowired
    private WlyyHospitalSysDictDao dictDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseSuperviseDictDao superviseDictDao;
    @Autowired
    private BaseSuperviseDataDictDao superviseDataDictDao;
    @Autowired
    private BaseDeptDictDao deptDictDao;
    @Autowired
    private DictDoctorDutyDao dictDoctorDutyDao;
    public String userName ;
    public String psw ;
    public String appId ;
    public String AesEncodeKey ;
    public String urlString;  // 正式线路径
 //   static String urlString = "http://fjhlw.bsoft.com.cn:18081/micc/wsapi/1.0?wsdl";   // 测试线路径
    public String method;
    public String token;
    public String orgCode;
    public String orgName;
    public String orgArea;
    public String orgSub ;
    public String imgUrl;
    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;
    public void getBaseSurperviseDict(){
        BaseSuperviseDict superviseDict = superviseDictDao.selectByDictName();
        userName=superviseDict.getUserName();
        psw=superviseDict.getPsw();
        appId=superviseDict.getAppId();
        AesEncodeKey = superviseDict.getAesEncodeKey();
        method = superviseDict.getMethod();
        token = superviseDict.getToken();
        orgArea=superviseDict.getOrgArea();
        orgCode = superviseDict.getOrgCode();
        orgName=superviseDict.getOrgName();
        orgSub=superviseDict.getOrgSub();
        imgUrl=superviseDict.getImgUrl();
    }
    /**
     * 监管平台上传地址
     * @return
     */
    public String getUrl(){
        return dictDao.findByDictName("dataUpload").get(0).getDictCode();
    }
    public String getImUrl(){
        return dictDao.findByDictName("imData").get(0).getDictCode();
    }
    public String getSystemUrl(){
        return dictDao.findByDictName("SYSTEM_URL").get(0).getDictCode();
    }
    // 0 调用省监管平台接口
    public String postToInter(String token, String api, JSONArray params,String url) throws Exception {
        getBaseSurperviseDict();
        WsapiProxy proxy = new WsapiProxy();
        proxy.setEndpoint(url);
        Wsapi wsapi = proxy.getWsapi();
//        logger.info("postToInter:"+JSONUtils.toString(new String[] {token, params.toString()}));
        String encryptParams = AESUtils.encrypt(JSONUtils.toString(new String[] {token, params.toString()}), AesEncodeKey);
        String result = wsapi.invoke(appId, "", api, method, encryptParams);
        String deResult = AESUtils.decrypt(result, AesEncodeKey);
        logger.info("postToInter:"+JSONUtils.toString(deResult));
        return deResult;
    }
    // 1  接口用户信息,获取TOKEN值	 micc.upNsUserToken   --- 完成
    public String upNsUserToken(String url) throws Exception {
        getBaseSurperviseDict();
        WsapiProxy proxy = new WsapiProxy();
        proxy.setEndpoint(url);
        Wsapi wsapi = proxy.getWsapi();
        String api = "micc.upNsUserToken";
        JSONObject jb = new JSONObject();
        jb.put("cd_user", userName);
        jb.put("pwd_user", psw);
        logger.info("url :"+url);
        logger.info("jb :"+jb.toString());
        String encryptParams = AESUtils.encrypt(JSONUtils.toString(new String[] { jb.toString() }), AesEncodeKey);
        String res = wsapi.invoke(appId, "", api, method, encryptParams);
        logger.info("appId :"+appId);
        logger.info("method :"+method);
        logger.info("encryptParams :"+encryptParams);
        String deResult = AESUtils.decrypt(res, AesEncodeKey);
        logger.info("AesEncodeKey :"+AesEncodeKey);
        JSONObject resJson = (JSONObject) JSONObject.parse(deResult);
        if("200".equals(resJson.get("msg").toString())) {
            token = resJson.get("token").toString();
        }
        logger.info("upNsUserToken : "+token);
        return token;
    }
    // 2  医院基本信息	micc.upNsOrganBas     --- 完成
    public String upNsOrganBas() throws Exception {
        getBaseSurperviseDict();
        BaseSuperviseDataDict superviseDataDict = superviseDataDictDao.selectByDictName();
        String url = getUrl();
        String api = "micc.upNsOrganBase";
        JSONObject jb = new JSONObject();
        jb.put("organ_code", orgCode);
        jb.put("organ_name",orgName);
        jb.put("corporation", superviseDataDict.getCorporation());
        jb.put("no_pra_lic", superviseDataDict.getNoPraLic());
        jb.put("second_organ_name", StringUtils.isNoneBlank(superviseDataDict.getSecondOrganName())?superviseDataDict.getSecondOrganName():"");
        jb.put("charge_person",StringUtils.isNoneBlank(superviseDataDict.getChargePerson())?superviseDataDict.getChargePerson():"");
        jb.put("level", superviseDataDict.getLevel());
        jb.put("economic_type", superviseDataDict.getEconomicType());
        jb.put("organ_type",superviseDataDict.getOrganType());
        jb.put("organ_sub", orgSub);
        jb.put("hospital_district",orgArea);
        jb.put("hospital_address", superviseDataDict.getHospitalAddress());
        jb.put("hospital_phone", superviseDataDict.getHospitalPhone());
     /*   jb.put("hospital_img","");*/
//        jb.put("bus_lic", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"yyzz.jpg"));
//        jb.put("corp_idcord_head", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"a.jpg"));
//        jb.put("corp_idcord_tail", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"b.jpg"));
//        jb.put("pra_lic", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"zyxkz.jpg"));
/*        jb.put("bus_lic", null);
        jb.put("corp_idcord_head", null);
        jb.put("corp_idcord_tail", null);
        jb.put("pra_lic", null);*/
        String hospitalImg="";
        String busLic="";
        String corpIdcardHead ="";
        String corpIdcardTail="";
        String praLic="";
        //医院图片
        jb.put("hospital_img",ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"hsimg.jpg"));
        //营业执照
        jb.put("bus_lic",ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"zyxkz.jpg"));
        //身份证正面
        jb.put("corp_idcord_head",ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"idcardA.jpg"));
        jb.put("corp_idcord_tail", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"idcardB.jpg"));
        jb.put("pra_lic", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"zyxkz.jpg"));
        jb.put("secu_level",StringUtils.isNoneBlank(superviseDataDict.getSecuLevel())?superviseDataDict.getSecuLevel():"");
        jb.put("secu_level_cert",ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"dbtp.jpg"));
        jb.put("net_service", superviseDataDict.getNetService());
        jb.put("net_service_ot", "");
        jb.put("service_dept", superviseDataDict.getServiceDept());
        jb.put("txt_introduction", "");
        //用户协议
        jb.put("protocol_type", superviseDataDict.getProtocolType());
        jb.put("protocol_content", superviseDataDict.getProtocolContent());
        jb.put("publish_date",superviseDataDict.getPublishDate());
        jb.put("protocol_name", superviseDataDict.getProtocolName());
        //其他建设信息
        jb.put("quai_mang_dept", "");
        jb.put("info_mang_dept", "");
        jb.put("medi_service_dept", "");
        jb.put("server_type", "");
        jb.put("server_total", "");
        jb.put("server_ip", "");
        jb.put("mp_system_type", "");
        jb.put("mp_system_total", "");
        jb.put("tran_link", "");
        jb.put("tran_link_band", "");
        jb.put("server_system_name", "");
        jb.put("server_system_ip", "");
        jb.put("tech_manual", "");
        jb.put("server_manual", "");
        jb.put("emr_level", "");
        jb.put("emr_level_cert", "");
        jb.put("zone_record_share", "");
        jb.put("prov_monitor", "");
        jb.put("prov_service", "");
        jb.put("server_func", "");
        jb.put("third_compeny_name", "");
        jb.put("third_compeny_code", "");
        jb.put("third_compeny_cert", "");
        jb.put("third_compeny_corp", "");
        jb.put("third_compeny_corp_id", "");
        jb.put("third_compeny_prot", "");
        JSONArray jsonArray = new JSONArray();
        jsonArray.add(jb);
        String token = upNsUserToken(url);
        String res = postToInter(token, api, jsonArray,url);
        return res;
    }
    // 3 医师基本信息	micc.upNsDoctorRecord   --- 完成
    public String upNsDoctorRecord(String keyId) throws Exception {
        getBaseSurperviseDict();
        BaseSuperviseDataDict superviseDataDict = superviseDataDictDao.selectByDictName();
        String url = getUrl();
        String api = "micc.upNsDoctorRecord";
        String upid = getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String token = upNsUserToken(url);
        //  因为要上传的是医师信息,所以针对到注册用户且无部门信息的用户数据不上传
        String sql = "select " +
                "   a.id AS \"id\"," +
                "   a.name AS \"name\"," +
                "   a.idcard AS \"idcard\"," +
                "   a.sex AS \"sex\"," +
                "   a.birthday AS \"birthday\", " +
                "   a.cert_no AS \"cert_no\", " +
                "   a.prac_no AS \"prac_no\"," +
                "   a.mobile AS \"mobile\"," +
                "   b.dept_code AS \"dept_code\"," +
                "   b.dept_name AS \"dept_name\"," +
                "   a.job_title_code AS \"job_title_code\"," +
                "   a.fzrq AS \"fzrq\"" +
                "  from base_doctor a " +
                "      ,base_doctor_hospital b" +
                " where a.id = b.doctor_code" +
                "   AND b.dept_code is NOT NULL " +
                "   AND a.job_title_code is NOT NULL " +
                "   AND a.fzrq IS NOT NULL " +
                "   AND a.cert_no IS NOT NULL " +
                "   AND a.prac_no IS NOT NULL ";
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and a.id = '" + keyId + "' ";
        }
        List list = jdbcTemplate.queryForList(sql);
        total = list.size();
        for(int i=0; i<list.size(); i++){
            LinkedCaseInsensitiveMap info = (LinkedCaseInsensitiveMap)list.get(i);
            Boolean errorFlag = false;
            JSONObject jb = new JSONObject();
            try {
                String[] dept = depToSubject(info.get("dept_code").toString());
                // 中山医院 监管平台  职务字典强转
                String[] dutyInfo = classToduty(info.get("job_title_code").toString());
                jb.put("organ_code", orgCode);
                jb.put("organ_name", orgName);
                jb.put("doc_name", info.get("name")== null ? "0":info.get("name"));
                jb.put("docimg", "");
                jb.put("id_card", info.get("idcard")== null ? "0":info.get("idcard"));
                jb.put("sex", info.get("sex")== null ? "0":info.get("sex"));
                jb.put("birthday", info.get("birthday")  == null?"1900-01-01": DateUtil.dateToStrLong((Date)info.get("birthday")));
                jb.put("subject", dept[0]);
                jb.put("subject_name", dept[1]);
                jb.put("belong_dept",jb.getString("dept_code"));
                jb.put("belong_dept_name", jb.getString("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 医师
                jb.put("title_code", dutyInfo[0]);  // 需要与监管平台的字典进行映射
                jb.put("first_compeny_code", orgCode);
                jb.put("first_compeny_name", orgName);
                jb.put("secd_compeny_code", "");
                jb.put("secd_compeny_name", "");
                jb.put("net_service", superviseDataDict.getDoctorNetService());
                jb.put("cert_no",  info.get("cert_no")== null ? "0":info.get("cert_no"));
                jb.put("prac_no",  info.get("prac_no")== null ? "0":info.get("prac_no"));
                //资格证书
                jb.put("doc_cert",ImgUtils.getImageStr(imgPath+"doctor"+ File.separator+info.get("name")+File.separator+"zg.jpg"));
                //执业证书
                jb.put("cert_doc_prac", ImgUtils.getImageStr(imgPath+"doctor"+ File.separator+info.get("name")+File.separator+"zy.jpg"));
                jb.put("txt_introduction",StringUtils.isNoneBlank(superviseDataDict.getTxtIntroduction())?superviseDataDict.getTxtIntroduction():"");
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"3",info.get("id").toString(),"数据格式错误",1);
                error++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                //上传监管平台
                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,"3",info.get("id").toString(),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"3",new Date(),new Date(),success,error,dataError,resInfo);
        return resInfo;
    }
    // 4 获取监管平台医师唯一标识	micc.achNsDoctorRecord  --- 完成
    public String achNsDoctorRecord(String idCardNo) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.achNsDoctorRecord";
        JSONObject jb = new JSONObject();
        jb.put("organ_code", orgCode);
        jb.put("organ_name", orgName);
        jb.put("id_card", idCardNo);
        JSONArray jsonArray = new JSONArray();
        jsonArray.add(jb);
        String token = upNsUserToken(url);
        String res = postToInter(token, api, jsonArray,url);
        JSONObject rs = (JSONObject) JSONObject.parse(res);
        String msg = rs.getString("msg");
        if("200".equals(msg)){
            JSONArray reqContent = rs.getJSONArray("reqContent");
            JSONObject req = (JSONObject)reqContent.get(0);
            return req.getString("miccId");
        }
        return "";
    }
    // 5 网上预约挂号	micc.upAppointmentOnline  ----完成
    public String upAppointmentOnline(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upAppointmentOnline";
        String upid = getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int dataError = 0;
        int error = 0;
        String token = upNsUserToken(url);
        String sql = "SELECT " +
                "   p.id AS \"id\"," +
                "   p.register_no AS \"register_no\", " +
                "   p.status AS \"status\", " +
                "   p.dept AS \"dept\", " +
                "   p.dept_name AS \"dept_name\"," +
                "   p.patient_name AS \"paName\"," +
                "   p.doctor_name AS \"docName\"," +
                "   p.idcard AS \"idcard\"," +
                "   p.register_date AS \"date\"" +
                "   FROM wlyy_outpatient p " +
                " WHERE 1=1" ;
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and p.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and p.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  p.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i< total; i++){
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try{
                String[] dept = depToSubject(info.get("dept").toString());
                jb.put("id", orgCode +"_"+ (String)info.get("id"));
                jb.put("cd_org", orgCode);
                jb.put("cd_area", orgArea);
                jb.put("cd_orgSub", orgSub);
                jb.put("reg_time", info.get("date") == null?"1900-01-01": DateUtil.dateToStrLong((Date)info.get("date")));
                jb.put("fg_visit",  fgConvent(info.get("status") == null?"-1":info.get("status").toString()));
                jb.put("reg_dep_code",  info.get("dept") == null?"0":info.get("dept"));
                jb.put("reg_dep_name",  info.get("dept_name") == null?"0":info.get("dept_name"));
                jb.put("reg_subject_code",  dept[0]);
                jb.put("reg_subject_name", dept[1]);
                jb.put("reg_price",  "0");
                jb.put("pt_name", info.get("name") == null?"0":info.get("name"));
                jb.put("ge_code",   IdCardUtil.getSexForIdcard_new(info.get("idcard").toString()));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("idcard").toString()));
                jb.put("card_type", "1");
                jb.put("id_no",  info.get("idcard") == null?"0":info.get("idcard"));
                jb.put("pt_tel",  "00000000000");
                jb.put("crt_date",DateUtil.dateToStrLong(DateUtil.getNow()));
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"5",(String)info.get("id"),"网上预约挂号数据格式错误",1);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                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,"5",(String)info.get("id"),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"5",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 6 在线医技预约 	micc.upMedicalOnline --- 完成
    public String upMedicalOnline(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upMedicalOnline";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String sql ="SELECT " +
                " i.id AS \"id\", " +
                " i.code AS \"code\", " +
                " o.dept AS \"dept\", " +
                " o.doctor AS \"doctor\", " +
                " o.register_date AS \"register_date\", " +
                " i.create_time AS \"create_time\", " +
                " p.name AS \"name\", " +
                " p.idcard AS \"idcard\", " +
                " d.idcard AS \"doctorIdCard\"" +
                "FROM " +
                " wlyy_inspection i " +
                " JOIN wlyy_outpatient o ON o.id = i.outpatient_id  " +
                " JOIN base_patient p ON p.id = o.patient " +
                " JOIN base_doctor d ON d.id = o.doctor " +
                "WHERE " +
                " i.dept is not null" +
                " and o.register_date is not null";
        if(StringUtils.isNotBlank(keyId)){
            sql +=" and i.id = '"+keyId+"'";
        }
        if(StringUtils.isNotBlank(startDate)){
            sql +=" and i.create_time >='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            sql +=" and i.create_time <='"+endDate+"' ";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list != null && list.size() > 0){
            total = list.size();
            for(Map<String,Object> ins :list ){
                JSONObject jb = new JSONObject();
                Boolean errorFlag = false;
                try {
                    String[] dept = depToSubject(ins.get("dept").toString());
                    String docInterId = achNsDoctorRecord((String)ins.get("doctorIdCard"));
                    jb.put("id",orgCode +"_"+ (String)ins.get("id"));
                    jb.put("cd_org", orgCode);
                    jb.put("cd_area", orgArea);
                    jb.put("cd_orgSub", orgSub);
                    jb.put("app_time",DateUtil.dateToStr((Date)ins.get("register_date"),"yyyy-MM-dd HH:mm:ss"));
                    jb.put("app_dep_code", dept[0]);
                    jb.put("app_class_code", ins.get("code"));
                    jb.put("id_doctor", docInterId);
                    jb.put("fg_handle", "1");
                    jb.put("handle_time", DateUtil.dateToStr((Date)ins.get("create_time"),"yyyy-MM-dd HH:mm:ss"));
                    jb.put("pt_name",ins.get("name").toString());
                    String sex = IdCardUtil.getSexForIdcard_new(ins.get("idcard").toString());
                    jb.put("ge_code", sex=="3"?"9":sex);
                    jb.put("card_type", "1");
                    jb.put("id_no", ins.get("idcard").toString());
                    jb.put("pt_tel", "00000000000");
                    jb.put("crt_date",DateUtil.dateToStrLong(DateUtil.getNow()));
                }catch (Exception e){
                    errorFlag = true;
                    saveErrorLog(upid,"6",(String)ins.get("id"),"在线医技预约格式错误",1);
                    dataError++;
                    logger.error(e.toString());
                }
                if(!errorFlag){
                    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,"6",(String)ins.get("id "),res,2);
                        error++;
                    }
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"6",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 7 医生评价信息	micc.upNsDoctorScore  --- 完成
    public String upNsDoctorScore(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsDoctorScore";
        String upid = getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String token = upNsUserToken(url);
        String sql ="SELECT " +
                " a.id AS \"id\", " +
                " a.doctor_name AS \"name\", " +
                " a.score AS \"score\", " +
                " a.patient_name AS \"patient_name\", " +
                " a.create_time AS \"create_time\", " +
                " e.content AS \"content\", " +
                " d.idcard AS \"docIdCard\" " +
                "FROM " +
                " base_evaluate_score a " +
                "JOIN base_evaluate e ON a.id = e.relation_code " +
                "JOIN base_doctor d ON d.id = a.doctor " +
                "WHERE " +
                " e.score_type = '4'";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and a.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and a.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<list.size(); i++) {
            Map<String,Object> info =list.get(i);
            Boolean errorFlag = false;
            JSONObject jb = new JSONObject();
            try{
                String interId = "";
                String idCard = info.get("docIdCard") == null ? "0":info.get("docIdCard").toString();
                if( info.get("docIdCard") == null){
                    interId = "0";
                }else {
                    interId = achNsDoctorRecord(idCard);
                }
//                String[] dept = depToSubject(info.get("dept_code").toString());
                jb.put("id",orgCode +"_"+ (String)info.get("id"));
                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){
                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);
        return resInfo;
    }
    // 8 网络咨询服务信息	micc.upNsOnlineAsk  --- 完成
    public String upNsOnlineAsk(String startDate, String endDate,String keyId) throws Exception {
        String base = getImUrl();
        getBaseSurperviseDict();
        String systemUrl = getSystemUrl();
        String url = getUrl();
        String api = "micc.upNsOnlineAsk";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
       String sql = "SELECT\n" +
               "\ta.id as \"id\",\n" +
               "\ta.type as \"type\",\n" +
               "\tc. NAME AS \"docName\",\n" +
               "\tc.idcard AS \"docIdCard\",\n" +
               "\tc.id AS \"docId\",\n" +
               "\tb.patient AS \"patient\",\n" +
               "\tb. NAME AS \"patientName\",\n" +
               "\tb.birthday as \"birthday\",\n" +
               "\tb.doctor as \"doctor\",\n" +
               "\ta.czrq as \"czrq\",\n" +
               "\ta.end_time as \"end_time\",\n" +
               "\ta.symptoms as \"symptoms\",\n" +
               "\td.sex AS \"sex\",\n" +
               "\td.mobile AS \"mobile\",\n" +
               "\td.idcard AS \"patIdCard\",\n" +
               "\td.city_code AS \"city_code\",\n" +
               "\te.dept_code AS \"dept_code\",\n" +
               "\te.dept_name AS \"dept_name\",\n" +
               "\tt.id AS \"consult\" \n" +
               "FROM\n" +
               "\twlyy_consult a ,\n" +
               "\twlyy_consult_team b \n" +
               "JOIN base_doctor c ON c.id = b.doctor \n" +
               "JOIN base_patient d ON d.id = b.patient \n" +
               "JOIN base_doctor_hospital e ON e.doctor_code = b.doctor \n" +
               "JOIN "+base+".topics t ON t.id = b.consult\n" +
               "WHERE\n" +
               "\ta.id = b.consult\n" +
               " AND a.symptoms IS NOT NULL AND b.status=1 ";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and a.czrq >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and a.czrq <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            String sqlMessage="SELECT\n" +
                    "\tM.sender_name AS \"sender_name\",\n" +
                    "\tM.sender_id AS \"sender_id\",\n" +
                    "\tM.timestamp AS \"timestamp\",\n" +
                    "\tM.content AS \"content\",\n" +
                    "\tM.content_type AS \"content_type\",\n" +
                    "\tT.id AS \"id\",\n" +
                    "\tM.sender_id AS \"session_id\"\n" +
                    "FROM\n" +
                    "\t"+base+".topics T\n" +
                    "JOIN "+base+".muc_messages M ON M.sender_id = T.session_id\n" +
                    "AND M.timestamp >= T.create_time\n" +
                    "AND M.timestamp <= T.end_time\n" +
                    "AND T.id='"+info.get("consult").toString()+"' "+
                    " ORDER BY\n" +
                    "\tM.timestamp ASC";
        /*    String sqlMessage = "SELECT m.sender_name AS \"sender_name\", m.`timestamp` AS \"timestamp\", m.content AS  \"content\", t.id AS \"id\"  FROM topics t " +
                    "JOIN muc_messages m ON m.session_id = t.session_id AND m.`timestamp` >= t.create_time AND m.`timestamp` <= t.end_time " +
                    "AND t.id = '"+info.get("consult").toString()+"' ORDER BY m.`timestamp` ASC";*/
            List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sqlMessage);
            String content="";
            JSONArray array = new JSONArray();
            for (Map<String,Object> map:list1){
                String sql1= "SELECT\n" +
                        "\ts.participant_id as \"participant_id\" \n" +
                        "FROM\n" +
                        "\t"+base+".PARTICIPANTS s \n" +
                        "WHERE\n" +
                        "\t s.SESSION_ID = '"+map.get("session_id").toString()+"' AND S.participant_id<> '"+map.get("sender_id").toString()+"'";
                List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql1);
                JSONObject object =new JSONObject();
                if (list2!=null&&list2.size()!=0){
                    Map<String,Object> map1 = list2.get(0);
                    BaseDoctorDO doctorDO = doctorDao.findById(map1.get("participant_id").toString());
                    if (doctorDO!=null){
                        object.put("receiver",doctorDO.getName());
                    }else {
                        BasePatientDO patientDO = patientDao.findById(map1.get("participant_id").toString());
                        object.put("receiver",patientDO.getName());
                    }
                }
                object.put("sender",map.get("sender_name"));
                object.put("msg",map.get("content"));
                object.put("msg_type",map.get("content_type"));
                object.put("send_time",DateUtil.dateToStr(DateUtil.strToDate(map.get("timestamp").toString(),"yyyy-MM-dd HH:mm:ss"),"yyyy-MM-dd HH:mm:ss"));
                array.add(object);
            }
            info.put("content",array.toJSONString());
        }
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try {
                //基于科室转换成国家诊疗科目代码
                String[] dept = depToSubject(info.get("dept_code").toString());
                // 获取监管平台唯一标识
                String visitDocCode = achNsDoctorRecord((String)info.get("docIdCard"));
                jb.put("id_online_ask", orgCode+"_"+(String)info.get("id"));
                jb.put("net_service_code", "1");
                jb.put("med_class_code", info.get("type"));
                jb.put("med_pop_code", "1");
                jb.put("org_name",orgName);
                jb.put("org_code", orgCode);
                jb.put("cd_orgSub", orgSub);
                jb.put("cd_area", orgArea);
                jb.put("visit_doc_name",  info.get("docName")== null? "0":info.get("docName"));
                jb.put("visit_doc_id_no",  info.get("docIdCard")== null? "0":info.get("docIdCard"));
                jb.put("visit_doc_code",  visitDocCode);
                jb.put("visit_dept_code", info.get("dept_code") == null?"0":info.get("dept_code"));
                jb.put("visit_dept_name", info.get("dept_name") == null?"0":info.get("dept_name"));
                jb.put("pt_no", info.get("patientName")== null? "0":info.get("patientName"));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("patIdCard").toString()));
                jb.put("cost_type", "");
                jb.put("pt_birthdate", info.get("birthday") == null? "":DateUtil.dateToStrShort((Date)info.get("birthday")));
                jb.put("ge_code", info.get("sex")== null? "0":info.get("sex"));
                jb.put("pt_tel",info.get("mobile") == null ? "0":info.get("mobile"));
                jb.put("card_type", "1");
                jb.put("id_no", info.get("patIdCard")== null? "0":info.get("patIdCard"));
                jb.put("pt_district",info.get("city_code") == null?"":info.get("city_code"));
                jb.put("apply_time", info.get("czrq")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("czrq")));
                jb.put("visit_time", info.get("czrq")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("czrq")));
                jb.put("visit_finish_time", info.get("end_time")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("end_time")));
                jb.put("complaint_content", info.get("content"));
               /* String procFile="";
                if (info.get("content")!=null){
                    JSONArray array = JSONArray.parseArray(info.get("content").toString());
                    for (int j=0;j<array.size();j++){
                        String type = array.getJSONObject(j).getString("content_type");
                        if (type.equalsIgnoreCase("3")||type.equalsIgnoreCase("12")){
                            procFile=imgUrl+array.getJSONObject(j).getString("content");
                            break;
                        }
                    }
                }*/
                jb.put("proc_file", systemUrl+"ims-web/#/login?type=9&doctorCode="+info.get("doctor")+"&qCode="+info.get("id"));
                jb.put("price", 0);
                jb.put("fg_reply", "1");
                jb.put("crt_time", DateUtil.dateToStrLong(DateUtil.getNow()));
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"8",(String)info.get("id"),"网络咨询服务信息格式错误",2);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                String str = jb.toJSONString();
                res = postToInter(token,api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"8",info.get("id").toString(),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"8",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return null;
    }
    // 9 网络诊疗服务信息 	micc.upNsOnlineMed
    public String upNsOnlineMed(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsOnlineMed";
        String upid = getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String token = upNsUserToken(url);
        String sql = "select " +
                "       a.id AS \"id\"," +
                "       a.register_no AS \"register_no\", " +
                "       a.type AS \"type\", " +
                "       b.id AS \"docId\", " +
                "       a.doctor_name AS \"doctor_name\", " +
                "       b.idcard AS \"docIdCard\"," +
                "       a.dept AS \"dept\", " +
                "       a.dept_name AS \"dept_name\", " +
                "       c.name AS \"paName\", " +
                "       c.idcard AS \"paId\", " +
                "       c.sex AS \"sex\"," +
                "       c.mobile AS \"mobile\"," +
                "       a.create_time AS \"create_time\"," +
                "       b.charge_type AS \"charge_type\"," +
                "       a.register_date AS \"register_date\", " +
                "       a.end_time AS \"end_time\"," +
                "       a.icd10 AS \"icd10\"," +
                "       a.icd10_name AS \"icd10_name\"," +
                "       a.origin_adm_no AS \"origin_adm_no\"," +
                "       a.card_no AS \"card_no\", " +
                "       a.description AS \"description\"" +
                "  from wlyy_outpatient a " +
                "      join base_doctor b on b.id = a.doctor" +
                "      join base_patient c on c.id = a.patient" +
                " where a.register_no is NOT NULL and a.dept is not null " +
                " and a.register_date is not null " ;
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and a.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and a.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<list.size(); i++) {
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try {
                //基于科室转换成国家诊疗科目代码
                String[] dept = depToSubject(info.get("dept").toString());
                // 获取监管平台唯一标识
                String visitDocCode = achNsDoctorRecord((String)info.get("docIdCard"));
//                String visitDocCode = achNsDoctorRecord("350102198005012428");
                jb.put("id_online_med", orgCode +"_"+ (String)info.get("id"));
                jb.put("net_service_code", "4");
                jb.put("med_class_code", info.get("type")== ""?"1":info.get("type"));
                jb.put("org_name", orgName);
                jb.put("org_code", orgCode);
                jb.put("cd_orgSub",orgSub);
                jb.put("cd_area",orgArea);
                jb.put("visit_doc_name",  info.get("doctor_name"));
                jb.put("visit_doc_id_no", info.get("docIdCard"));
                jb.put("visit_doc_code", visitDocCode);
                jb.put("visit_subject_code", dept[0]);
                jb.put("visit_ subject _name",dept[1]);
                jb.put("visit_dept_code", info.get("dept"));
                jb.put("visit_dept_name", info.get("dept_name"));
                jb.put("pt_no", info.get("paName"));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("paId").toString()));
//                jb.put("cost_type", info.get("charge_type").toString());
                jb.put("cost_type", "");
                jb.put("pt_birthdate", null);
                String sex = IdCardUtil.getSexForIdcard_new(info.get("paId").toString());
                jb.put("ge_code", sex=="3"?"9":sex);
                jb.put("pt_tel", info.get("moble")==null?"00000000000":info.get("moble").toString());
                jb.put("card_type", "1");
                jb.put("id_no", info.get("paId"));
                jb.put("pt_district", "");
                jb.put("pt_card_type", "");
                jb.put("pt_card_no",info.get("card_no"));
                Date createTime = (Date) info.get("create_time");
                jb.put("apply_time", DateUtil.dateToStr(createTime,"yyyy-MM-dd HH:mm:ss"));
                Date date = (Date) info.get("register_date");
                jb.put("visit_time", DateUtil.dateToStr(date,"yyyy-MM-dd HH:mm:ss"));
                String dateStr = DateUtil.dateToStr(DateUtil.getPreDays(date,1),"yyyy-MM-dd");
                jb.put("visit_finish_time", dateStr+" 00:00:00");
                jb.put("old_diag_code", "");
                jb.put("old_diag_name", "");
                jb.put("diag_code",info.get("icd10"));
                jb.put("diag_name", info.get("icd10_name"));
                jb.put("diseases_type", info.get("origin_adm_no") == null ? "1":"2");
                jb.put("complaint_content", info.get("paName").toString()+DateUtil.dateToStr(date,"yyyy-MM-dd HH:mm:ss")+info.get("description").toString()+"\n");
                jb.put("proc_file", "");
                jb.put("price","0");
                jb.put("fg_reply", "");
                jb.put("crt_time", DateUtil.dateToStrLong(DateUtil.getNow()));
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"9",(String)info.get("id"),"网络诊疗服务信息格式错误",1);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                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,"9",(String)info.get("id"),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"9",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 10 电子处方表 micc.upPrescription    --- 完成
    public String upPrescription(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upPrescription";
        String upid =getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String token = upNsUserToken(url);
        String sql = "select " +
                "  a.id AS \"id\"," +
                "  a.real_order AS \"real_order\"," +
                "  a.patient_code AS \"patient_code\"," +
                "  a.outpatient_id AS \"outpatient_id\"," +
                "  a.patient_name AS \"patient_name\"," +
                "  b.idcard AS \"idcard\"," +
                "  b.city_code AS \"city_code\"," +
                "  a.hospital AS \"hospital\"," +
                "  a.hospital_name AS \"hospital_name\"," +
                "  p.icd10 AS \"icd10\"," +
                "  p.icd10_name AS \"icd10_name\"," +
                "  p.dept AS \"dept\"," +
                "  p.dept_name AS \"dept_name\"," +
                "  a.doctor AS \"doctor\"," +
                "  a.doctor_name AS \"doctor_name\"," +
                "  a.his_register_fee AS \"his_register_fee\"," +
                "  c.idcard AS \"docIdcard\"" +
                "  from  wlyy_prescription a" +
                "     JOIN base_patient b on a.patient_code = b.id " +
                "     JOIN base_doctor c on a.doctor = c.id " +
                "     JOIN wlyy_outpatient p on p.id = a.outpatient_id  " +
                "  where  c.idcard is not null  and a.real_order is not null and p.icd10 is not null ";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and a.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and a.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try {
                //基于科室转换成国家诊疗科目代码
                String[] dept = depToSubject(info.get("dept").toString());
                // 获取监管平台唯一标识
                String visitDocCode = achNsDoctorRecord(info.get("docIdcard").toString());
                jb.put("id_prescription", orgCode +"_"+ (String)info.get("id"));
                jb.put("pres_no",info.get("real_order")== null?"0":info.get("real_order"));
                jb.put("pres_class_code", "1");
                jb.put("pres_class_name", "西药");
                jb.put("pt_id", info.get("patient_code"));
                jb.put("med_rd_no", info.get("outpatient_id"));
                jb.put("med_class_code", "4");
                jb.put("med_class_name", "在线复诊");
                jb.put("pt_no", info.get("patient_name"));
                jb.put("ge_code", info.get("sex")== null?"0": info.get("sex"));
                jb.put("pt_age",IdCardUtil.getAgeForIdcard(info.get("idcard").toString()));
                jb.put("birthday", info.get("birthday")  == null?"": DateUtil.dateToStrLong((Date)info.get("birthday")));
                jb.put("card_type", "1");
                jb.put("id_no", info.get("idcard"));
                jb.put("guarder_name", "");
                jb.put("guarder_no", "");
                jb.put("pt_tel",info.get("mobile") == null?"": info.get("mobile"));
                jb.put("pt_district", info.get("city_code")== null?"": info.get("city_code"));
                jb.put("allergic_history", "");
                jb.put("cost_type", "");
                jb.put("ins_class_code", "");
                jb.put("ins_class_name", "");
                jb.put("org_code", orgCode);
                jb.put("org_name",orgName);
                jb.put("pres_subject_code", dept[0]);
                jb.put("pres_subject_name", dept[1]);
                jb.put("pres_dept_code", info.get("dept")== null?"0":info.get("dept"));
                jb.put("pres_dept_name",info.get("dept_name")== null?"0":info.get("dept_name"));
                jb.put("pres_time", info.get("create_time")== null?"1900-01-01 00:00:00":DateUtil.dateToStrLong((Date)info.get("create_time")));
                jb.put("pres_doc_code", visitDocCode);
                jb.put("pres_doc_name", info.get("doctor_name")== null?"0":info.get("doctor_name"));
                jb.put("pres_doc_id_no", info.get("docIdcard")== null?"0":info.get("docIdcard"));
                jb.put("trial_doc_code", visitDocCode);
                jb.put("trial_doc_name", info.get("doctor_name")== null?"0":info.get("doctor_name"));
                jb.put("trial_doc_id_no",info.get("docIdcard")== null?"0":info.get("docIdcard"));
                jb.put("diag_code", info.get("icd10"));
                jb.put("diag_name", info.get("icd10_name"));
                jb.put("diseases_type", "0");
                jb.put("mobility_flag", "3");
                jb.put("long_medical_flag", "3");
                jb.put("pres_effec_days", 0);
                jb.put("total_price",info.get("his_register_fee")== null?  0 : info.get("his_register_fee"));
                jb.put("upload_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
                jb.put("pres_photo", "");
                jb.put("pres_photos_list", "");
                jb.put("pres_photos", "");
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"10",(String)info.get("id"),"电子处方表格式错误",1);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                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,"10",(String)info.get("id"),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条";
        saveUpLog(upid,"10",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 11 电子处方_药品明细表	micc.upPrescriptionDrug     --- 完成
    public String upPrescriptionDrug(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upPrescriptionDrug";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String sql = "select " +
                "    b.real_order AS \"real_order\"," +
                "    a.id AS \"id\", " +
                "    a.prescription_id AS \"prescription_id\", " +
                "    a.drug_no AS \"drug_no\"," +
                "    a.drug_name AS \"drug_name\", " +
                "    a.dosage AS \"dosage\"," +
                "    a.unit AS \"unit\"," +
                "    a.quantity AS \"quantity\"," +
                "    a.pack_unit AS \"pack_unit\"," +
                "    a.usage_code AS \"usage_code\"," +
                "    a.supply_code AS \"supply_code\"," +
                "    a.specification AS \"specification\"," +
                "    a.pack_retprice AS \"pack_retprice\"," +
                "    a.pack_retprice AS \"drug_total_price\"" +
                "  from wlyy_prescription_info a " +
                "     JOIN wlyy_prescription b " +
                "     on b.id = a.prescription_id" +
                "  where  a.dosage is not null and b.real_order is not null";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and b.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and b.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try {
                jb.put("id_prescription_drug",orgCode +"_"+ (String)info.get("id"));
                jb.put("pres_no", info.get("real_order") == null? "0": info.get("real_order"));
                jb.put("org_code",orgCode);
                jb.put("appr_drug_code", info.get("drug_no") == null? "0": info.get("drug_no"));
                jb.put("appr_drug_name", info.get("drug_name") == null? "0": info.get("drug_name"));
                jb.put("drug_code", "");
                jb.put("drug_name", "");
                jb.put("drug_form", "");
                jb.put("dosage",info.get("dosage") == null? 0: info.get("dosage"));
                jb.put("dosage_unit", info.get("unit") == null? "0": info.get("unit"));
                jb.put("total_dosage", info.get("quantity") == null? 0: info.get("quantity"));
                jb.put("total_dosage_unit", info.get("pack_unit") == null? "0": info.get("pack_unit"));
                jb.put("medicine_freq", info.get("usage_code") == null? "0": info.get("usage_code"));
                jb.put("drug_use", info.get("supply_code") == null? "0": info.get("supply_code"));
                jb.put("standard_desc", info.get("specification") == null? "0": info.get("specification"));
                jb.put("single_price",info.get("pack_retprice") == null? 0: info.get("pack_retprice"));
                BigDecimal pack_retprice = (BigDecimal)info.get("pack_retprice");
                Long quantity = Long.parseLong((String)info.get("quantity"));
                Double price = pack_retprice.doubleValue()*quantity;
                jb.put("drug_total_price",price);
                jb.put("comments", "");
                jb.put("anti_comments", "");
                jb.put("dec_meth_name", "");
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"11",(String)info.get("id"),res,1);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                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,"11",(String)info.get("id"),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"11",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 12.在线诊疗服务信息-过程图片上传     --- 完成
    public String upNsOnlineImg(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsOnlineImg";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String sql = "SELECT " +
                "   p.id AS \"id\"," +
                "   p.disease_img AS \"disease_img\" " +
                " FROM wlyy_outpatient p " +
                " WHERE p.disease_img is not null ";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and p.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and p.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  p.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            String pathimg[] = ((String)info.get("disease_img")).split(",");
            if(pathimg!=null&&pathimg.length>0){
                for(String img:pathimg){
                    JSONObject jb = new JSONObject();
                    Boolean errorFlag = false;
                    try {
                        jb.put("id_online_img",getCode());
                        jb.put("id_onlne_base", orgCode+"_"+info.get("id"));
                        jb.put("online_type","2");
                        String base64 =getImg(img);
                        jb.put("img_path",base64);
                        jb.put("img_sort", i);
                        jb.put("upload_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd hh:mm:ss"));
                    }catch (Exception e){
                        errorFlag = true;
                        saveErrorLog(upid,"12",(String)info.get("id"),res,1);
                        dataError++;
                        logger.error(e.toString());
                    }
                    if(!errorFlag){
                        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,"12",(String)info.get("id"),res,2);
                            error++;
                        }
                    }
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"12",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    //13.用户协议信息
    public String upNsOrganProtocol(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        BaseSuperviseDataDict superviseDataDict = superviseDataDictDao.selectByDictName();
        String url = getUrl();
        String api = "micc.upNsOrganProtocol";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        JSONObject jb = new JSONObject();
        Boolean errorFlag = false;
        try {
            jb.put("id_organ_protocol",orgCode+"_"+upid);
            jb.put("organ_code", orgCode);
            jb.put("organ_name",orgName);
            jb.put("protocol_type", superviseDataDict.getUserProtocolType());
            jb.put("protocol_content", superviseDataDict.getUserProtocolContent());
            jb.put("publish_date", superviseDataDict.getUserPublishDate());
            jb.put("protocol_name", superviseDataDict.getUserProtocolName());
            jb.put("upload_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }catch (Exception e){
            errorFlag = true;
            saveErrorLog(upid,"13",upid,res,1);
            dataError++;
            logger.error(e.toString());
        }
        if(!errorFlag){
            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,"13",upid,res,2);
                error++;
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"13",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    //14.数据上传汇总信息
    public String upNsInvokeTotal(String startDate, String endDate) throws Exception {
        String base = getImUrl();
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsInvokeTotal";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        //时间参数
        Map<String,Object> params = new HashedMap();
        //5.统计预约量
        String yyghSql = "SELECT " +
                "   count(1) AS \"yyghtotal\"" +
                " FROM wlyy_outpatient p " +
                " WHERE 1=1" ;
        if(StringUtils.isNotBlank(startDate)){
            yyghSql =  yyghSql + "  and p.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            yyghSql =  yyghSql +  "  and p.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        List<Map<String,Object>> yygh = hibenateUtils.createSQLQuery(yyghSql,params);
        Long yyghtotal = 0L;
        if(yygh!=null&&yygh.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            yyghtotal = hibenateUtils.objTransformLong(yygh.get(0).get("yyghtotal"));
        }
        //7.医生评价
        String yypjSql ="SELECT " +
                "   count(1) AS \"yypjtotal\"" +
                " FROM " +
                " base_evaluate_score a " +
                " JOIN base_evaluate e ON a.id = e.relation_code " +
                " JOIN base_doctor d ON d.id = a.doctor " +
                " WHERE " +
                " e.score_type = '4'";
        if(StringUtils.isNotBlank(startDate)){
            yypjSql =  yypjSql + "  and a.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            yypjSql =  yypjSql +  "  and a.create_time <=:endDate";
        }
        List<Map<String,Object>> yypj = hibenateUtils.createSQLQuery(yypjSql,params);
        Long yypjtotal = 0L;
        if(yypj!=null&&yypj.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            yypjtotal = hibenateUtils.objTransformLong(yypj.get(0).get("yypjtotal"));
        }
        //8.统计网络咨询
        String wlzxSql = "SELECT\n" +
                "   count(1) AS \"wlzxtotal\"" +
                "FROM\n" +
                "\twlyy_consult a ,\n" +
                "\twlyy_consult_team b \n" +
                "JOIN base_doctor c ON c.id = b.doctor \n" +
                "JOIN base_patient d ON d.id = b.patient \n" +
                "JOIN base_doctor_hospital e ON e.doctor_code = b.doctor \n" +
                "JOIN "+base+".topics t ON t.id = b.consult\n" +
                "WHERE\n" +
                "\ta.id = b.consult\n" +
                "AND a.symptoms IS NOT NULL AND b.status=1";
        if(StringUtils.isNotBlank(startDate)){
            wlzxSql =  wlzxSql + "  and a.czrq >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            wlzxSql =  wlzxSql +  "  and a.czrq <=:endDate";
        }
        List<Map<String,Object>> wlzx = hibenateUtils.createSQLQuery(wlzxSql,params);
        Long wlzxtotal = 0L;
        if(wlzx!=null&&wlzx.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            wlzxtotal = hibenateUtils.objTransformLong(wlzx.get(0).get("wlzxtotal"));
        }
        //9.网络诊疗服务
        String wlzlSql = "select " +
                "   count(1) AS \"wlzltotal\"" +
                "  from wlyy_outpatient a " +
                "      join base_doctor b on b.id = a.doctor" +
                "      join base_patient c on c.id = a.patient" +
                " where a.register_no is NOT NULL and a.dept is not null " +
                " and a.register_date is not null " ;
        if(StringUtils.isNotBlank(startDate)){
            wlzlSql =  wlzlSql + "  and a.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            wlzlSql =  wlzlSql +  "  and a.create_time <=:endDate";
        }
        List<Map<String,Object>> wlzl = hibenateUtils.createSQLQuery(wlzlSql,params);
        Long wlzltotal = 0L;
        if(wlzl!=null&&wlzl.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            wlzltotal = hibenateUtils.objTransformLong(wlzl.get(0).get("wlzltotal"));
        }
        //10.电子处方
        String dzcfsql = "select " +
                "   count(1) AS \"dzcftotal\"" +
                "  from  wlyy_prescription a" +
                "     JOIN base_patient b on a.patient_code = b.id " +
                "     JOIN base_doctor c on a.doctor = c.id " +
                "     JOIN wlyy_outpatient p on p.id = a.outpatient_id  " +
                "  where  c.idcard is not null  and a.real_order is not null and p.icd10 is not null ";
        if(StringUtils.isNotBlank(startDate)){
            dzcfsql =  dzcfsql + "  and a.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            dzcfsql =  dzcfsql +  "  and a.create_time <=:endDate";
        }
        List<Map<String,Object>> dzcf = hibenateUtils.createSQLQuery(dzcfsql,params);
        Long dzcftotal = 0L;
        if(dzcf!=null&&dzcf.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            dzcftotal = hibenateUtils.objTransformLong(dzcf.get(0).get("dzcftotal"));
        }
        //11.电子处方药品明细
        String infosql = "select " +
                "   count(1) AS \"infototal\"" +
                "  from wlyy_prescription_info a " +
                "     JOIN wlyy_prescription b " +
                "     on b.id = a.prescription_id" +
                "  where  a.dosage is not null and b.real_order is not null";
        if(StringUtils.isNotBlank(startDate)){
            infosql =  infosql + "  and b.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            infosql =  infosql +  "  and b.create_time <=:endDate";
        }
        List<Map<String,Object>> info = hibenateUtils.createSQLQuery(infosql,params);
        Long infototal = 0L;
        if(info!=null&&info.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            infototal = hibenateUtils.objTransformLong(info.get(0).get("infototal"));
        }
        //12.过程图片
        String gctpsql = "SELECT " +
                "   count(1) AS \"gctptotal\"" +
                " FROM wlyy_outpatient p " +
                " WHERE p.disease_img is not null ";
        if(StringUtils.isNotBlank(startDate)){
            gctpsql =  gctpsql + "  and p.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            gctpsql =  gctpsql +  "  and p.create_time <=:endDate";
        }
        List<Map<String,Object>> gctp = hibenateUtils.createSQLQuery(gctpsql,params);
        Long gctptotal = 0L;
        if(gctp!=null&&gctp.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            gctptotal = hibenateUtils.objTransformLong(gctp.get(0).get("gctptotal"));
        }
        JSONObject jb = new JSONObject();
        Boolean errorFlag = false;
        try {
            jb.put("id_ws_invoke_total",upid);
            jb.put("org_code", orgCode);
            jb.put("org_name",orgName);
            jb.put("wsyy_upload_count", yyghtotal);
            jb.put("zxyj_upload_count", 0);
            jb.put("yspj_upload_count", yypjtotal);
            jb.put("wlzx_upload_count", wlzxtotal);
            jb.put("wlzl_upload_count", wlzltotal);
            jb.put("dzcf_upload_count", dzcftotal);
            jb.put("ypmx_upload_count", infototal);
            jb.put("gctp_upload_count", gctptotal);
            jb.put("ywsj", DateUtil.dateToStr(new Date(),"yyyy-MM-dd"));
            jb.put("crt_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }catch (Exception e){
            errorFlag = true;
            saveErrorLog(upid,"14",upid,res,1);
            dataError++;
            logger.error(e.toString());
        }
        logger.info(jb.toString());
        if(!errorFlag){
            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,"14",upid,res,2);
                error++;
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"14",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 基于医生所在科室,转换成国家诊疗科目代码(中山医院专用)
    // 当科室信息在列表中不存在的情况,全部配置为预防保健科
    public String[] depToSubject(String dep){
        String[] res = new String[2];
        BaseDeptDict baseDeptDict = deptDictDao.selectByDeptCode(dep);
        if (baseDeptDict!=null){
            res[0]=baseDeptDict.getSubject();
            res[1]=baseDeptDict.getSubjectName();
        }else {
            res[0]="";
            res[1]="";
        }
        return res;
    }
    //2.5 预约,是否到诊字典转换
    public static String fgConvent(String status){
        String res ="";
        switch (status) {
            case "-1":
                res = "0";
                break;
            case "0":
                res = "1";
                break;
            case "1":
                res = "1";
                break;
            case "2":
                res = "1";
                break;
            default:
                res = "";
        }
        return res;
    }
    // 将上传失败的数据存储到LOG 中,便于后续补传
    public void saveErrorLog(String upId,String type, String id, String errorInfo,Integer errorType){
        InternetUpErrorLogDO internetUpErrorLogDO = new InternetUpErrorLogDO();
        internetUpErrorLogDO.setUpId(upId);
        internetUpErrorLogDO.setType(type);
        internetUpErrorLogDO.setKeyId(id);
        internetUpErrorLogDO.setErrorInfo(errorInfo);
        internetUpErrorLogDO.setErrorType(errorType);
        internetUpErrorLogService.save(internetUpErrorLogDO);
    }
    public void saveUpLog(String upid,String code,Date startDate,Date endDate,Integer suc,Integer err,Integer dataErr,String remark){
        InternetUpLogDO internetUpLogDO = new InternetUpLogDO();
        internetUpLogDO.setId(upid);
        internetUpLogDO.setCode(code);
        internetUpLogDO.setStartDate(startDate);
        internetUpLogDO.setEndDate(endDate);
        internetUpLogDO.setCreateDate(new Date());
        internetUpLogDO.setSuc(suc);
        internetUpLogDO.setErr(err);
        internetUpLogDO.setDataErr(dataErr);
        internetUpLogDO.setRemark(remark);
        internetUpLogDao.save(internetUpLogDO);
    }
    // 基于中山医院的职务字典,强转为监管平台的字典(该部分过滤掉字典与监管理无法匹配的部分)
    public  String[]  classToduty(String duty){
        String[] res = new String[2];
        DictDoctorDutyDO doctorDutyDO = dictDoctorDutyDao.findByCode(duty);
        if (doctorDutyDO!=null){
            res[0]=doctorDutyDO.getTitleCode();
            res[1]=doctorDutyDO.getName();
        }else {
            res[0]="";
            res[1]="";
        }
        return  res;
    }
    /**
     * 网络图片地址
     * @param path
     * @return
     * @throws Exception
     */
    public String getImg(String path)throws Exception{
        try{
            if(path.contains("http")){
                URL url = new URL(path);
                DataInputStream dataInputStream = new DataInputStream(url.openStream());
                return getBase64FromInputStream(dataInputStream);
            }
            URL url = new URL(fastdfs_file_url+path);
            DataInputStream dataInputStream = new DataInputStream(url.openStream());
            return getBase64FromInputStream(dataInputStream);
        }catch (Exception e){
            logger.error("getImg:"+e.toString());
        }
        return "";
    }
    public String getDateString(String date){
        String dates[] = date.split("-");
        if(dates!=null&&dates.length>0){
            if(dates[1].length()<2){
                dates[1] = "0"+dates[1];
            }
            if(dates[2].length()<2){
                dates[2] = "0"+dates[2];
            }
            return dates[0]+"-"+dates[1]+"-"+dates[2];
        }
        return date;
    }
    private String getBase64FromInputStream(InputStream is) throws Exception {
        // 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
        byte[] data = null;
        // 读取图片字节数组
        try {
            ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
            byte[] buff = new byte[100];
            int rc = 0;
            while ((rc = is.read(buff, 0, 100)) > 0) {
                swapStream.write(buff, 0, rc);
            }
            data = swapStream.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    throw new Exception("输入流关闭异常");
                }
            }
        }
        //转化方法1
        BASE64Encoder encoder = new BASE64Encoder();
        return encoder.encodeBuffer(data).trim();
        //转化方法2
//        return new String(Base64.encodeBase64(data));
    }
    public String testImg(String path){
        return ImgUtils.getImageStr(path);
    }
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetService.java

@ -219,7 +219,7 @@ public class InternetService extends BaseJpaService<InternetUpErrorLogDO, IntUpE
                "(八)其他\n" +
                "1、本协议构成双方对本协议之约定事项及其他有关事宜的完整协议,除本协议规定的之外,未赋予本协议各方其他权利。 \n" +
                "2、如本协议中的任何条款无论因何种原因完全或部分无效或不具有执行力,本协议的其余条款仍应有效并且有约束力。 \n" +
                "3、本协议中的标题仅为方便而设,在解释本协议时应被忽略\"");
                "3、本协议中的标题仅为方便而设,在解释本协议时应被忽略");
        jb.put("publish_date", "2019-08-24");
        jb.put("protocol_name", "用户使用协议");

+ 15 - 0
business/base-service/src/main/java/com/yihu/jw/oauth/OauthRsaKeyDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.oauth;
import com.yihu.jw.entity.auth.OauthRsaKeyDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2020/3/10.
 */
public interface OauthRsaKeyDao extends PagingAndSortingRepository<OauthRsaKeyDO, String>, JpaSpecificationExecutor<OauthRsaKeyDO> {
    List<OauthRsaKeyDO> findByCodeAndAppId(String Code, String appId);
}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 184 - 0
business/base-service/src/main/java/com/yihu/jw/oauth/OauthSsoService.java


+ 0 - 1
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java

@ -3,7 +3,6 @@ package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 98 - 0
business/base-service/src/main/java/com/yihu/jw/utils/RSAEncrypt.java

@ -0,0 +1,98 @@
package com.yihu.jw.utils;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
public class RSAEncrypt {
    /**
     * 随机生成密钥对
     * @throws NoSuchAlgorithmException
     */
    public static Map<Integer, String> genKeyPair() throws NoSuchAlgorithmException {
        Map<Integer, String> keyMap = new HashMap<Integer, String>();
        // KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
        KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
        // 初始化密钥对生成器,密钥大小为96-1024位
        keyPairGen.initialize(1024,new SecureRandom());
        // 生成一个密钥对,保存在keyPair中
        KeyPair keyPair = keyPairGen.generateKeyPair();
        RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();   // 得到私钥
        RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();  // 得到公钥
        String publicKeyString = new String(Base64.encodeBase64(publicKey.getEncoded()));
        // 得到私钥字符串
        String privateKeyString = new String(Base64.encodeBase64((privateKey.getEncoded())));
        // 将公钥和私钥保存到Map
        keyMap.put(0,publicKeyString);  //0表示公钥
        keyMap.put(1,privateKeyString);  //1表示私钥
        return keyMap;
    }
    /**
     * RSA公钥加密
     *
     * @param str
     *            加密字符串
     * @param publicKey
     *            公钥
     * @return 密文
     * @throws Exception
     *             加密过程中的异常信息
     */
    public static String encrypt( String str, String publicKey) throws Exception{
        //base64编码的公钥
        byte[] decoded = Base64.decodeBase64(publicKey);
        RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
        //RSA加密
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.ENCRYPT_MODE, pubKey);
        String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8")));
        return outStr;
    }
    /**
     * RSA私钥解密
     *
     * @param str
     *            加密字符串
     * @param privateKey
     *            私钥
     * @return 铭文
     * @throws Exception
     *             解密过程中的异常信息
     */
    public static String decrypt(String str, String privateKey) throws Exception{
        //64位解码加密后的字符串
        byte[] inputByte = Base64.decodeBase64(str.getBytes("UTF-8"));
        //base64编码的私钥
        byte[] decoded = Base64.decodeBase64(privateKey);
        RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded));
        //RSA解密
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.DECRYPT_MODE, priKey);
        String outStr = new String(cipher.doFinal(inputByte));
        return outStr;
    }
//    public static void main(String[] args) throws Exception {
//        //生成公钥和私钥
//        Map<Integer, String> keyMap = genKeyPair();
//        //加密字符串
//        String message = "test";
//        System.out.println("随机生成的公钥为:" + keyMap.get(0));
//        System.out.println("随机生成的私钥为:" + keyMap.get(1));
//        String messageEn = encrypt(message,keyMap.get(0));
//        System.out.println(message + "\t加密后的字符串为:" + messageEn);
//        String messageDe = decrypt(messageEn,keyMap.get(1));
//        System.out.println("还原后的字符串为:" + messageDe);
//    }
}

+ 51 - 2
business/base-service/src/main/java/com/yihu/jw/wechat/enterprise/EnterpriseService.java

@ -85,6 +85,42 @@ public class EnterpriseService {
        return token.getAccessToken();
    }
    public String getXCXToken(String enterpriseId)throws Exception{
        logger.info("getXCXToken");
        WxEnterpriseDO wxEnterpriseDO = wxEnterpriseDao.findOne(enterpriseId+"_xcx");
        List<WxEnterpriseTokenDO> wxEnterpriseTokenDOs = wxEnterpriseTokenDao.findByCodeOrderByCreateTimeDesc(enterpriseId+"_xcx");
        if(wxEnterpriseTokenDOs!=null&&wxEnterpriseTokenDOs.size()>0) {
            logger.info("token size:"+wxEnterpriseTokenDOs.size());
            WxEnterpriseTokenDO tokenDO = wxEnterpriseTokenDOs.get(0);
            if (tokenDO.getExpiresTime().after(new Date())) {
                return tokenDO.getAccessToken();
            }else{
                wxEnterpriseTokenDao.delete(wxEnterpriseTokenDOs);
            }
        }
        String result = HttpUtil.sendGet("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid="+wxEnterpriseDO.getCorpid()+"&corpsecret="+wxEnterpriseDO.getCorpsecret());
        logger.info("getToken result:"+result);
        JSONObject json = JSONObject.parseObject(result);
        //保存当前token
        WxEnterpriseTokenDO token = new WxEnterpriseTokenDO();
        Date date = new Date();
        token.setAccessToken(json.getString("access_token"));
        token.setCreateTime(date);
        token.setExpiresTime(DateUtil.setDateHours(date,2));
        token.setCode(enterpriseId+"_xcx");
        wxEnterpriseTokenDao.save(token);
        return token.getAccessToken();
    }
    public String sendTextMes(String enterpriseId,String userId,String content)throws Exception{
        String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="+getToken(enterpriseId);
@ -154,7 +190,20 @@ public class EnterpriseService {
        }
        return "";
    }
    
    /**
     *
     * @param enterpriseId
     * @param doctor
     * @param appid
     * @param page
     * @param title
     * @param description (不能超过12个字符)
     * @param emphasis_first_item
     * @param content_item
     * @return
     * @throws Exception
     */
    public String sendXCXMesByDoctor(String enterpriseId, String doctor, String appid,String page, String title, String description, Boolean emphasis_first_item, String content_item)throws Exception {
        BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
@ -294,7 +343,7 @@ public class EnterpriseService {
     */
    public String sendXCXMes(String enterpriseId, String userId, String appid,String page, String title, String description, Boolean emphasis_first_item, String content_item)throws Exception{
        String mesurl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="+getToken(enterpriseId);
        String mesurl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="+getXCXToken(enterpriseId);
        JSONObject param = new JSONObject();
        param.put("touser",userId);

+ 7 - 2
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java

@ -3,6 +3,7 @@ package com.yihu.jw.wechat.service;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.dao.WechatDao;
import org.json.JSONObject;
@ -19,6 +20,8 @@ public class WechatInfoService {
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private EntranceService entranceService;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    /**
     * 通过code获取判断openid
@ -63,7 +66,7 @@ public class WechatInfoService {
            WxWechatDO wxWechat = null;
            
            //中山医院互联网医院
            if("xm_zsyy_wx".equals(wxId)){
            if("xm_zsyy_wx".equals(wxId) || "xm_xzzx_wx".equals(wxId)){
                jsapiTickets = wxAccessTokenService.findJsapiTicket(wxId);
            }else{
                wxWechat = wxAccessTokenService.getWxInfo(wxId);
@ -83,8 +86,10 @@ public class WechatInfoService {
            String token = "";
            
            //中山医院互联网医院
            if("xm_zsyy_wx".equals(wxId)){
            if("xm_zsyy_wx".equals(wxId)) {
                token = entranceService.getAccessToken("100033");
            }else if("xm_xzzx_wx".equals(wxId)){
                token = xzzxEntranceService.getXzToken();
            }else{
                token = wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
            }

+ 35 - 4
business/base-service/src/main/java/com/yihu/jw/wechat/service/WxTemplateService.java

@ -7,11 +7,14 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateDO;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.oauth.OauthSsoService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.RSAEncrypt;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.dao.WxTemplateDao;
@ -21,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -53,6 +57,12 @@ public class WxTemplateService {
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    
    @Autowired
    private OauthSsoService oauthSsoService;
    
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    
    
    /**
     * 发送微信模版消息-小程序视频
@ -70,10 +80,31 @@ public class WxTemplateService {
                logger.info("该用户"+reciver_name+"没有openid,无法推送模版消息,用户ID:"+reciver_id+"wechatId:"+wechatId);
            }else{
                for (BasePatientWechatDo basePatientWechatDo:ps){
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_consult_notice","spthtx",1);
                    config.setFirst(config.getFirst().replace("key1",sender_name));
                    config.setPagepath(config.getPagepath()+""+reciver_id+"&doctorName="+sender_name+"&role=patient&roomID="+session_id+"&template=1v1&debugMode=false&cloudenv=PRO");
                    weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                    if("xm_xzzx_wx".equals(wechatId)){
                        String getAuthCode = oauthSsoService.getSsoPublic(wechatId,basePatientDO.getId());
    
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("name",basePatientDO.getName());
                        jsonObject.put("idcard",basePatientDO.getIdcard());
                        jsonObject.put("mobile",basePatientDO.getMobile());
                        jsonObject.put("openid",basePatientWechatDo.getOpenid());
                        String authCode = jsonObject.toJSONString();
                        String jm = URLEncoder.encode(RSAEncrypt.encrypt(authCode,getAuthCode),"utf-8");
                        String miniprogramUrl = "pages/room/room?patientCode="+reciver_id+"&doctorName="+sender_name+"&role=patient&roomID="+session_id+"&template=1v1&debugMode=false&cloudenv=PRO&authCode="+jm+"&code="+wechatId+"&appId="+basePatientDO.getId();
                        //心脏中心模版消息推送接口
                        logger.info("心脏中心小程序跳转URL:"+miniprogramUrl);
                        xzzxEntranceService.sendXCXMes(wechatId,
                                basePatientDO.getId(),
                                basePatientDO.getIdcard(),
                                sender_name+"主任医生已向您发起视频通话邀请,请点击详情进入视频诊室。",
                                "点击消息进入视频诊室接听视频通话,开始视频咨询",
                                "",miniprogramUrl,"wx53f6bb4ac081d840");
                    }else{
                        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_consult_notice","spthtx",1);
                        config.setFirst(config.getFirst().replace("key1",sender_name));
                        config.setPagepath(config.getPagepath()+""+reciver_id+"&doctorName="+sender_name+"&role=patient&roomID="+session_id+"&template=1v1&debugMode=false&cloudenv=PRO");
                        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                    }
                }
            }

+ 13 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictDoctorDutyDO.java

@ -32,6 +32,10 @@ public class DictDoctorDutyDO extends IntegerIdentityEntity {
    @Column(name = "name")
	private String name;
    @Column(name = "title_code")
    private String titleCode;
    /**
	 * 创建时间
	 */
@ -63,4 +67,13 @@ public class DictDoctorDutyDO extends IntegerIdentityEntity {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "title_code")
    public String getTitleCode() {
        return titleCode;
    }
    public void setTitleCode(String titleCode) {
        this.titleCode = titleCode;
    }
}

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

@ -235,6 +235,8 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
     */
    private Date loginDate;
    private String userId;
    @Column(name = "saas_id")
    public String getSaasId() {
@ -604,4 +606,12 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
        this.loginDate = loginDate;
    }
    @Column(name = "user_id")
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
}

+ 56 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseDeptDict.java

@ -0,0 +1,56 @@
package com.yihu.jw.entity.hospital.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by zdm on 2019/5/28.
 */
@Entity
@Table(name = "base_dept_dict")
public class BaseDeptDict extends IntegerIdentityEntity {
    private String subject;
    private String subjectName;
    private String deptCode;
    private String deptName;
    @Column(name = "subject")
    public String getSubject() {
        return subject;
    }
    public void setSubject(String subject) {
        this.subject = subject;
    }
    @Column(name = "subject_name")
    public String getSubjectName() {
        return subjectName;
    }
    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }
    @Column(name = "dept_code")
    public String getDeptCode() {
        return deptCode;
    }
    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
}

+ 251 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseSuperviseDataDict.java

@ -0,0 +1,251 @@
package com.yihu.jw.entity.hospital.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by zdm on 2019/5/28.
 */
@Entity
@Table(name = "base_supervise_data_dict")
public class BaseSuperviseDataDict extends IntegerIdentityEntity {
    private String dictName;//环境名字
    private String corporation;//单位法人姓名
    private String noPraLic;//执业许可登记号
    private String secondOrganName;//机构第二名称
    private String chargePerson;//主要负责人
    private String level;//机构等位分级
    private String economicType;//经济类型
    private String organType;//组织类别
    private String hospitalAddress;//医院具体地址
    private String hospitalPhone;//医院联系电话
    private String secuLevel;//信息系统安全等级保护级别
    private String netService;//开展互联网医疗服务
    private String serviceDept;//开展的临床科室
    private String protocolType;//协议类型
    private String protocolContent;//协议内容
    private String publishDate;//发布时间
    private String protocolName;//协议名称
    private String txtIntroduction;//医生介绍
    private String doctorNetService;//医生开展互联网医疗服务
    private String userProtocolType;//用户使用协议类型
    private String userProtocolContent;//用户使用协议内容
    private String userPublishDate;//用户使用发布时间
    private String userProtocolName;//用户协议名称
    private Integer status;//1生效0失效
    @Column(name = "dict_name")
    public String getDictName() {
        return dictName;
    }
    public void setDictName(String dictName) {
        this.dictName = dictName;
    }
    @Column(name = "corporation")
    public String getCorporation() {
        return corporation;
    }
    public void setCorporation(String corporation) {
        this.corporation = corporation;
    }
    @Column(name = "no_pra_lic")
    public String getNoPraLic() {
        return noPraLic;
    }
    public void setNoPraLic(String noPraLic) {
        this.noPraLic = noPraLic;
    }
    @Column(name = "second_organ_name")
    public String getSecondOrganName() {
        return secondOrganName;
    }
    public void setSecondOrganName(String secondOrganName) {
        this.secondOrganName = secondOrganName;
    }
    @Column(name = "charge_person")
    public String getChargePerson() {
        return chargePerson;
    }
    public void setChargePerson(String chargePerson) {
        this.chargePerson = chargePerson;
    }
    @Column(name = "level")
    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }
    @Column(name = "economic_type")
    public String getEconomicType() {
        return economicType;
    }
    public void setEconomicType(String economicType) {
        this.economicType = economicType;
    }
    @Column(name = "organ_type")
    public String getOrganType() {
        return organType;
    }
    public void setOrganType(String organType) {
        this.organType = organType;
    }
    @Column(name = "hospital_address")
    public String getHospitalAddress() {
        return hospitalAddress;
    }
    public void setHospitalAddress(String hospitalAddress) {
        this.hospitalAddress = hospitalAddress;
    }
    @Column(name = "hospital_phone")
    public String getHospitalPhone() {
        return hospitalPhone;
    }
    public void setHospitalPhone(String hospitalPhone) {
        this.hospitalPhone = hospitalPhone;
    }
    @Column(name = "secu_level")
    public String getSecuLevel() {
        return secuLevel;
    }
    public void setSecuLevel(String secuLevel) {
        this.secuLevel = secuLevel;
    }
    @Column(name = "net_service")
    public String getNetService() {
        return netService;
    }
    public void setNetService(String netService) {
        this.netService = netService;
    }
    @Column(name = "service_dept")
    public String getServiceDept() {
        return serviceDept;
    }
    public void setServiceDept(String serviceDept) {
        this.serviceDept = serviceDept;
    }
    @Column(name = "protocol_type")
    public String getProtocolType() {
        return protocolType;
    }
    public void setProtocolType(String protocolType) {
        this.protocolType = protocolType;
    }
    @Column(name = "protocol_content")
    public String getProtocolContent() {
        return protocolContent;
    }
    public void setProtocolContent(String protocolContent) {
        this.protocolContent = protocolContent;
    }
    @Column(name = "publish_date")
    public String getPublishDate() {
        return publishDate;
    }
    public void setPublishDate(String publishDate) {
        this.publishDate = publishDate;
    }
    @Column(name = "protocol_name")
    public String getProtocolName() {
        return protocolName;
    }
    public void setProtocolName(String protocolName) {
        this.protocolName = protocolName;
    }
    @Column(name = "txt_introduction")
    public String getTxtIntroduction() {
        return txtIntroduction;
    }
    public void setTxtIntroduction(String txtIntroduction) {
        this.txtIntroduction = txtIntroduction;
    }
    @Column(name = "user_protocol_type")
    public String getUserProtocolType() {
        return userProtocolType;
    }
    public void setUserProtocolType(String userProtocolType) {
        this.userProtocolType = userProtocolType;
    }
    @Column(name = "user_protocol_content")
    public String getUserProtocolContent() {
        return userProtocolContent;
    }
    public void setUserProtocolContent(String userProtocolContent) {
        this.userProtocolContent = userProtocolContent;
    }
    @Column(name = "user_publish_date")
    public String getUserPublishDate() {
        return userPublishDate;
    }
    public void setUserPublishDate(String userPublishDate) {
        this.userPublishDate = userPublishDate;
    }
    @Column(name = "user_protocol_name")
    public String getUserProtocolName() {
        return userProtocolName;
    }
    public void setUserProtocolName(String userProtocolName) {
        this.userProtocolName = userProtocolName;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "doctor_net_service")
    public String getDoctorNetService() {
        return doctorNetService;
    }
    public void setDoctorNetService(String doctorNetService) {
        this.doctorNetService = doctorNetService;
    }
}

+ 158 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseSuperviseDict.java

@ -0,0 +1,158 @@
package com.yihu.jw.entity.hospital.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by zdm on 2019/5/28.
 */
@Entity
@Table(name = "base_supervise_dict")
public class BaseSuperviseDict extends IntegerIdentityEntity {
    private String userName ;
    private String psw ;
    private String appId ;
    private String aesEncodeKey ;
    private String urlString;
    private String method;
    private String token;
    private String orgCode;
    private String orgName;
    private String orgArea;
    private String orgSub ;
    private Integer status;
    private String dictName;
    private String imgUrl;//服务器地址
    @Column(name = "url_string")
    public String getUrlString() {
        return urlString;
    }
    public void setUrlString(String urlString) {
        this.urlString = urlString;
    }
    @Column(name = "method")
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    @Column(name = "token")
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    @Column(name = "org_name")
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    @Column(name = "org_area")
    public String getOrgArea() {
        return orgArea;
    }
    public void setOrgArea(String orgArea) {
        this.orgArea = orgArea;
    }
    @Column(name = "org_sub")
    public String getOrgSub() {
        return orgSub;
    }
    public void setOrgSub(String orgSub) {
        this.orgSub = orgSub;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "dict_name")
    public String getDictName() {
        return dictName;
    }
    public void setDictName(String dictName) {
        this.dictName = dictName;
    }
    @Column(name = "user_name")
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    @Column(name = "psw")
    public String getPsw() {
        return psw;
    }
    public void setPsw(String psw) {
        this.psw = psw;
    }
    @Column(name = "app_id")
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    @Column(name = "aes_encode_key")
    public String getAesEncodeKey() {
        return aesEncodeKey;
    }
    public void setAesEncodeKey(String aesEncodeKey) {
        this.aesEncodeKey = aesEncodeKey;
    }
    @Column(name = "img_url")
    public String getImgUrl() {
        return imgUrl;
    }
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/jgpt/HospitalImgDO.java

@ -2,6 +2,7 @@ package com.yihu.jw.entity.hospital.jgpt;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -14,6 +15,7 @@ public class HospitalImgDO extends UuidIdentityEntity {
    private String name;
    private String img;
    private Integer status;
    public String getName() {
        return name;
@ -30,4 +32,13 @@ public class HospitalImgDO extends UuidIdentityEntity {
    public void setImg(String img) {
        this.img = img;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 8 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -706,5 +706,13 @@ public class BaseRequestMapping {
    public static class BaseRoleMenu extends Basic {
        public static final String PREFIX  = "/baseRoleMenu";
    }
    
    /**
     * 系统日志
     */
    public static class BaseMethodLog extends Basic{
        public static final String PREFIX  = "/baseMethodLog";
        public static final String getLog  = "/getLog";
    }
}

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/bank/HealthBankMapping.java

@ -85,5 +85,6 @@ public class HealthBankMapping {
        public static final String selectWeekReward="/selectWeekReward";
        public static final String reduceIntegrate ="/reduceIntegrate";
        public static final String createPlanActivity = "/createPlanActivity";
        public static final String completePlan="/completePlan";
    }
}

+ 38 - 0
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -298,4 +298,42 @@ public class HttpClientUtil {
        return null;
    }
    public  String get(String url, String chatSet,Map<String,Object> headerMap) {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            // 创建httpget.
            url= url.replaceAll(" ", "%20");
            HttpGet httpget = new HttpGet(url);
            for(String str:headerMap.keySet()){
                httpget.addHeader(str,headerMap.get(str).toString());
            }
            // 执行get请求.
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                // 获取响应实体
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}

+ 9 - 2
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseMethodLogService.java

@ -1,6 +1,7 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.gateway.useragent.UserAgent;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -34,8 +35,14 @@ public class BaseMethodLogService {
        try{
            logger.info("saveMethodLog");
            BaseMethodLogDO log = new BaseMethodLogDO();
            log.setUuid(userAgent.getUID());
            log.setName(userAgent.getUNAME());
            if(StringUtils.isBlank(userAgent.getUID())){
                log.setUuid("system");
                log.setName("system");
            }else{
                log.setUuid(userAgent.getUID());
                log.setName(userAgent.getUNAME());
            }
            
            log.setIp(getIpAddress(request));
            log.setCreateTime(new Date());
            log.setMethod(request.getRequestURI());

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

@ -1120,7 +1120,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        properties.put("kaptcha.textproducer.font.size", "45");
        properties.put("kaptcha.textproducer.char.length", "4");
        properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
        properties.put("kaptcha.textproducer.char.string","0123456789QWERTYUIOPLKJHGFDSAZXCVBNM");
        properties.put("kaptcha.textproducer.char.string","0123456789");
        Config config = new Config(properties);
        captchaProducer.setConfig(config);
        String captchaText = captchaProducer.createText();
@ -1330,7 +1330,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        } else {
            return ObjEnvelop.getError("验证码错误!");
        }
        String rs = registerService.updateDoctorPw(pw,mobile);
        String rs = registerService.updateDoctorPw(mobile,pw);
        if("ok".equals(rs)){
            return ObjEnvelop.getSuccess("修改成功!");
        }

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

@ -124,6 +124,22 @@ public class OauthSsoService {
                    rs.put("code",1);
                    rs.put("mes","获取居民信息成功");
                    rs.put("patient",basePatientDO);
                    List<BasePatientWechatDo> wechatDos = basePatientWechatDao.findByWechatIdAndPatientId(appId,basePatientDO.getId());
                    if(wechatDos!=null&&wechatDos.size()>0){
                        for(BasePatientWechatDo wechatDo:wechatDos){
                            wechatDo.setOpenid(openid);
                        }
                        basePatientWechatDao.save(wechatDos);
                    }else {
                        //保存openid
                        BasePatientWechatDo wechatDo = new BasePatientWechatDo();
                        wechatDo.setOpenid(openid);
                        wechatDo.setPatientId(basePatientDO.getId());
                        wechatDo.setWechatId(appId);
                        basePatientWechatDao.save(wechatDo);
                    }
                    return rs;
                }

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

@ -133,7 +133,7 @@ public class OauthYlzConfigService {
    public Map<String,Object> getOauthQRCodeImg(){
        try {
            logger.info("getOauthQRCodeImg dao1:"+DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findOne("ylz_config1");
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findOne("ylz_config");
            logger.info("getOauthQRCodeImg dao2:"+DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
            TransRequest e = new TransRequest();
            e.setMethod("ehc.ehealthcard.authurl");

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

@ -171,4 +171,10 @@ public class RegisterService {
        return buffer.toString();
    }
//    public static void main(String ag[]){
//        String dd ="jkzl@2020";
//        String pw =MD5.md5Hex(dd + "{jkzl}");
//        System.out.println(pw);
//    }
}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 155 - 783
svr/svr-base/sql/init.sql


+ 96 - 17
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java

@ -1,5 +1,8 @@
package com.yihu.jw.base.endpoint.common;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.base.util.ErrorCodeUtil;
@ -13,6 +16,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.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.web.bind.annotation.*;
@ -22,6 +27,7 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URLDecoder;
import java.util.Base64;
import java.util.Map;
/**
 * 文件上传不在微服务中处理
@ -32,19 +38,48 @@ import java.util.Base64;
@Api(tags = "文件上传相关操作", description = "文件上传相关操作")
public class FileUploadController extends EnvelopRestEndpoint {
    private static final Logger logger = LoggerFactory.getLogger(EnvelopRestEndpoint.class);
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    FileUploadService fileUploadService;
    @Value("${testPattern.sign}")
    private String isClose;
    @Value("${testPattern.remote_inner_url}")
    private String remote_inner_url;
    @Autowired
    private ObjectMapper objectMapper;
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
    public ObjEnvelop<UploadVO> uploadImg(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadImg(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
//        String originalFilename = file.getOriginalFilename();
//        InputStream inputStream = file.getInputStream();
//        UploadVO uploadVO = fileUploadService.uploadImg(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
//        return success("上传成功", uploadVO);
        UploadVO uploadVO = new UploadVO();
        if (isClose.equalsIgnoreCase("1")){
            Map<String, Object> map = fileUploadService.uploadImg(file);
            uploadVO.setFullUri(map.get("accessory").toString());
        }else if(isClose.equals("2")){
            //内网上传
            String rs = fileUploadService.request(remote_inner_url,file,null);
            logger.info(rs);
            JSONObject json = JSON.parseObject(rs);
            uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
        }else {
            // 得到文件的完整名称  xxx.txt
            String originalFilename = file.getOriginalFilename();
            InputStream inputStream = file.getInputStream();
            uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        }
        return success("上传成功", uploadVO);
    }
@ -53,24 +88,44 @@ public class FileUploadController extends EnvelopRestEndpoint {
    @ApiOperation(value = "文件流上传附件", notes = "文件流上传附件")
    public ObjEnvelop<UploadVO> uploadAttachment(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadAttachment(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
//        String originalFilename = file.getOriginalFilename();
//        InputStream inputStream = file.getInputStream();
//
//    UploadVO uploadVO = fileUploadService.uploadAttachment(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
//        return success("上传成功", uploadVO);
        UploadVO uploadVO = new UploadVO();
        if (isClose.equalsIgnoreCase("1")){
            Map<String, Object> map = fileUploadService.uploadImg(file);
            uploadVO.setFullUri(map.get("accessory").toString());
        }else if(isClose.equals("2")){
            //内网上传
            String rs = fileUploadService.request(remote_inner_url,file,null);
            logger.info(rs);
            JSONObject json = JSON.parseObject(rs);
            uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                                 @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        }else {
            // 得到文件的完整名称  xxx.txt
            String originalFilename = file.getOriginalFilename();
            InputStream inputStream = file.getInputStream();
            uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        }
        return success("上传成功", uploadVO);
//        return uploadStream(file);
    }
//    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
//    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
//    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
//                                                 @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
//
//        // 得到文件的完整名称  xxx.txt
//        String originalFilename = file.getOriginalFilename();
//        InputStream inputStream = file.getInputStream();
//        UploadVO uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
//        return success("上传成功", uploadVO);
//    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STRING)
    @ApiOperation(value = "base64上传图片",notes = "base64上传图片")
    public ObjEnvelop<UploadVO> uploadImages(@ApiParam(name = "jsonData", value = "头像转化后的输入流")
@ -79,4 +134,28 @@ public class FileUploadController extends EnvelopRestEndpoint {
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        UploadVO uploadVO = new UploadVO();
        if (isClose.equalsIgnoreCase("1")){
            Map<String, Object> map = fileUploadService.uploadImg(file);
            uploadVO.setFullUri(map.get("accessory").toString());
        }else if(isClose.equals("2")){
            //内网上传
            String rs = fileUploadService.request(remote_inner_url,file,null);
            logger.info(rs);
            JSONObject json = JSON.parseObject(rs);
            uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
        }else {
            // 得到文件的完整名称  xxx.txt
            String originalFilename = file.getOriginalFilename();
            InputStream inputStream = file.getInputStream();
            uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        }
        return success("上传成功", uploadVO);
    }
}

+ 51 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/methodlog/MethodLogEndpoint.java

@ -0,0 +1,51 @@
package com.yihu.jw.base.endpoint.methodlog;
import com.yihu.jw.base.methlog.BaseMethodLogDO;
import com.yihu.jw.base.methlog.BaseMethodLogService;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.restmodel.base.doctor.BaseDoctorVO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * 系统日志
 * @author huangwenjie
 * @date 2020/4/11 10:16
 */
@RestController
@RequestMapping(value = BaseRequestMapping.BaseMethodLog.PREFIX)
@Api(value = "系统日志管理", description = "系统日志管理接口", tags = {"基础服务 - 系统日志管理管理服务接口"})
public class MethodLogEndpoint extends EnvelopRestEndpoint {
	
	@Autowired
	private BaseMethodLogService baseMethodLogService;
	
	@GetMapping(value = BaseRequestMapping.BaseMethodLog.getLog)
	@ApiOperation(value = "获取分页")
	public PageEnvelop<BaseMethodLogDO> page(
			@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
			@RequestParam(value = "fields", required = false) String fields,
			@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
			@RequestParam(value = "filters", required = false) String filters,
			@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
			@RequestParam(value = "sorts", required = false) String sorts,
			@ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
			@RequestParam(value = "page") int page,
			@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
			@RequestParam(value = "size") int size) throws Exception {
		List<BaseMethodLogDO> baseDoctors = baseMethodLogService.search(fields, filters, sorts, page, size);
		int count = (int) baseMethodLogService.getCount(filters);
		return success(baseDoctors, count, page, size);
	}
}

+ 63 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogDO.java

@ -0,0 +1,63 @@
package com.yihu.jw.base.methlog;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2020/2/19.
 */
@Entity
@Table(name = "base_method_log")
public class BaseMethodLogDO extends UuidIdentityEntity {
    private String uuid;
    private String name;
    private String ip;
    private String method;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date createTime;
    public String getUuid() {
        return uuid;
    }
    public void setUuid(String uuid) {
        this.uuid = uuid;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getIp() {
        return ip;
    }
    public void setIp(String ip) {
        this.ip = ip;
    }
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 10 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogDao.java

@ -0,0 +1,10 @@
package com.yihu.jw.base.methlog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2020/2/19.
 */
public interface BaseMethodLogDao extends PagingAndSortingRepository<BaseMethodLogDO, String>, JpaSpecificationExecutor<BaseMethodLogDO> {
}

+ 25 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/methlog/BaseMethodLogService.java

@ -0,0 +1,25 @@
package com.yihu.jw.base.methlog;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.mysql.query.BaseJpaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * Created by Trick on 2020/2/19.
 */
@Service
@Transactional
public class BaseMethodLogService  extends BaseJpaService<BaseMethodLogDO, BaseMethodLogDao> {
    private static final Logger logger = LoggerFactory.getLogger(BaseMethodLogService.class);
    @Autowired
    private BaseMethodLogDao baseMethodLogDao;
    
}

+ 28 - 5
svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java

@ -73,7 +73,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
        userDO.setLoginFailureCount(0);
        String password = userDO.getPassword();
        if (StringUtils.isEmpty(password)) {
            password = userDO.getIdcard().substring(0, 5);
            password = userDO.getIdcard().substring(userDO.getIdcard().length()-6,userDO.getIdcard().length());
        }
        userDO.setPassword(MD5.md5Hex(password + "{" + userDO.getSalt() + "}"));
        return userDao.save(userDO);
@ -92,7 +92,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
        userDO.setLoginFailureCount(0);
        String password = userDO.getPassword();
        if (StringUtils.isEmpty(password)) {
            password = userDO.getMobile().substring(0, 5);
            password = userDO.getMobile().substring(userDO.getMobile().length()-6, userDO.getMobile().length());
        }
        userDO.setPassword(MD5.md5Hex(password + "{" + userDO.getSalt() + "}"));
        return userDao.save(userDO);
@ -272,7 +272,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
        }
        JSONObject returnMsg = new JSONObject();
        returnMsg.put("username",userDO.getUsername());
        returnMsg.put("password",userDO.getSalt());
        returnMsg.put("password",userDO.getIdcard().substring(userDO.getIdcard().length()-6,userDO.getIdcard().length()));
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg", returnMsg);
        return result;
@ -440,9 +440,32 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
            result.put("msg","user not exist for id : " + userId);
            return result;
        }
        registerWithIdcard(user);
//        registerWithIdcard(user);
        String idcard = user.getIdcard();
        String mobile = user.getMobile();
        String password = null;
        if(!StringUtils.isEmpty(password)&&idcard.length()>10){
            password = idcard.substring(idcard.length()-6,idcard.length());
        }else if(!StringUtils.isEmpty(mobile)&&mobile.length()>=11){
            password = mobile.substring(mobile.length()-6,mobile.length());
        }
        if(StringUtils.isEmpty(password)){
            result.put("response", ConstantUtils.FAIL);
            result.put("msg","idcard or moblie not exist : " + userId);
            return result;
        }
        user.setSalt(randomString(5));
        user.setEnabled(true);
        user.setLocked(false);
        user.setLoginFailureCount(0);
        user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
        userDao.save(user);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg", user.getSalt());
        result.put("msg", password);
        return result;
    }

+ 13 - 1
svr/svr-base/src/main/resources/application.yml

@ -115,6 +115,10 @@ wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
---
spring:
  profiles: jwtest
@ -154,6 +158,10 @@ wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
---
spring:
  profiles: jwprod
@ -190,4 +198,8 @@ hospital:
wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream

+ 7 - 1
svr/svr-base/src/main/resources/bootstrap.yml

@ -30,7 +30,13 @@ spring:
    config:
      uri: ${wlyy.spring.config.uri:http://192.0.33.26:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: xzprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.16.100.63:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: local

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

@ -6,9 +6,11 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@ -46,4 +48,108 @@ public class XzzxCotroller extends EnvelopRestEndpoint {
    public ObjEnvelop getChargeDict()throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.getChargeDict());
    }
    /**
     * 查询患者就诊卡
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/findPatientCard")
    @ApiOperation(value = "查询患者就诊卡", notes = "查询患者就诊卡")
    public ObjEnvelop findPatientCard(@ApiParam(name = "idCard", value = "身份证号", required = false)
                                          @RequestParam(value = "idCard",required = false)String idCard)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.findPatientCard(idCard));
    }
    /**
     * 获取卡信息
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getCardInfo")
    @ApiOperation(value = "获取卡信息", notes = "获取卡信息")
    public ObjEnvelop getCardInfo(@ApiParam(name = "cardNo", value = "就诊卡", required = false)
                                      @RequestParam(value = "cardNo",required = false)String cardNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.getCardInfo(cardNo));
    }
    /**
     * 获取单条门诊就诊记录
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/findOutpatientInfo")
    @ApiOperation(value = "获取单条门诊就诊记录", notes = "获取单条门诊就诊记录")
    public ObjEnvelop findOutpatientInfo(@ApiParam(name = "patient", value = "居民id", required = false)
                                  @RequestParam(value = "patient",required = false)String patient,
                                         @ApiParam(name = "conNo", value = "就诊次数", required = false)
                                         @RequestParam(value = "conNo",required = false)String conNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.findOutpatientInfo(patient,conNo));
    }
    /**
     * 获取门诊下所有处方信息
     * @param registerSn 流水号(必传)
     * @param patNo 病人id(必传)
     * @param admNo 住院唯一号(必传)
     * @param realOrder 处方号(非必传,传相当于查单条处方)
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getOriginPrescriptionList")
    @ApiOperation(value = "获取门诊下所有处方信息", notes = "获取门诊下所有处方信息")
    public ObjEnvelop getOriginPrescriptionList(@ApiParam(name = "registerSn", value = "流水号", required = false)
                                         @RequestParam(value = "registerSn",required = false)String registerSn,
                                         @ApiParam(name = "patNo", value = "病人id", required = false)
                                         @RequestParam(value = "patNo",required = false)String patNo,
                                         @ApiParam(name = "admNo", value = "住院唯一号", required = false)
                                             @RequestParam(value = "admNo",required = false)String admNo,
                                         @ApiParam(name = "realOrder", value = "处方号", required = false)
                                             @RequestParam(value = "realOrder",required = false)String realOrder)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.getOriginPrescriptionList(registerSn,patNo,admNo,realOrder));
    }
    /**
     * 挂号(调his后台包)
     * @param doctor 医生ID(必填)
     * @param dept 科室编码(必填)
     * @param sickId 病人id
     * @param clinicclass 挂号类别(必填)
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/registered")
    @ApiOperation(value = "挂号(调his后台包)", notes = "挂号(调his后台包)")
    public ObjEnvelop registered(@ApiParam(name = "doctor", value = "医生ID", required = false)
                                         @RequestParam(value = "doctor",required = false)String doctor,
                                         @ApiParam(name = "dept", value = "科室编码", required = false)
                                         @RequestParam(value = "dept",required = false)String dept,
                                 @ApiParam(name = "sickId", value = "病人id", required = false)
                                     @RequestParam(value = "sickId",required = false)String sickId,
                                 @ApiParam(name = "clinicclass", value = "挂号类别", required = false)
                                     @RequestParam(value = "clinicclass",required = false)String clinicclass)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.registered(doctor,dept,sickId,clinicclass));
    }
    /**
     * 处方状态变更
     * @param admNo 就诊唯一号(必填)
     * @param realOrder 处方号(必填)
     * @param status 处方状态:3结算完成(必填)
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/updatePreStatus")
    @ApiOperation(value = "获取单条门诊就诊记录", notes = "获取单条门诊就诊记录")
    public ObjEnvelop updatePreStatus(@ApiParam(name = "admNo", value = "就诊唯一号", required = false)
                                 @RequestParam(value = "admNo",required = false)String admNo,
                                 @ApiParam(name = "realOrder", value = "处方号", required = false)
                                 @RequestParam(value = "realOrder",required = false)String realOrder,
                                 @ApiParam(name = "status", value = "处方状态:3结算完成", required = false)
                                 @RequestParam(value = "status",required = false)String status)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.updatePreStatus(admNo,realOrder,status));
    }
}

+ 2 - 2
svr/svr-internet-hospital-job/pom.xml

@ -46,10 +46,10 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
       <!-- <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        </dependency>-->
        <!--注释掉就不会读取git的配置,只会读取yml中的配置-->
        <!--<dependency>-->
            <!--<groupId>org.springframework.cloud</groupId>-->

+ 126 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/CommonDataUploadJob.java

@ -0,0 +1,126 @@
package com.yihu.jw.job;
import com.yihu.jw.internet.service.InternetCommonService;
import com.yihu.jw.internet.service.ykyy.YkyyInternetService;
import com.yihu.jw.util.date.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * Created by Trick on 2020/3/11
 */
public class CommonDataUploadJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(DataUploadJob.class);
    @Autowired
    private InternetCommonService internetService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========DataUploadJob========");
        try {
            //1、获取 JOB 执行区间  执行时间点的前一天  时间点定在每天的 02:00:00 执行,同步前一天的数据
            String endDate = DateUtil.dateToStr(DateUtil.getNow(),"yyyy-MM-dd")+" 00:00:00";
            String startDate = DateUtil.dateToStr(DateUtil.getPreDays(DateUtil.getNow(),-1),"yyyy-MM-dd")+" 00:00:00";
            String res = "";
            //2、分步执行需要JOB执行的服务
            logger.info("START========2.5 网上预约挂号上传开始========");
            try {
                res = internetService.upAppointmentOnline(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.5 网上预约挂号上传结束========" + res);
//            logger.info("START========2.6 网上医技预约上传开始========");
//            try {
//                res = internetService.upMedicalOnline(startDate,endDate,null);
//            }catch (Exception e){
//                e.printStackTrace();
//                logger.error(e.toString());
//            }
//            logger.info("END==========2.6 网上医技预约上传结束========" + res);
            logger.info("START========2.7 医生评价信息开始========");
            try {
                res = internetService.upNsDoctorScore(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.7 医生评价信息结束========" + res);
            logger.info("START========2.8 网络咨询服务信息开始========");
            try {
                res = internetService.upNsOnlineAsk(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.8 网络咨询服务信息结束========" + res);
            logger.info("START========2.9 网络诊疗服务信息========");
            try {
                res = internetService.upNsOnlineMed(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.9 网络诊疗服务信息========" + res);
            logger.info("START========2.10 电子处方表开始========");
            try {
                res = internetService.upPrescription(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.10 电子处方表结束========" + res);
            logger.info("START========2.11 电子处方_药品明细表开始 ========");
            try {
                res = internetService.upPrescriptionDrug(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.11 电子处方_药品明细表结束 ========" + res);
            logger.info("START========2.12 在线诊疗服务信息-过程图片上传 开始========");
            try {
                res = internetService.upNsOnlineImg(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.12 在线诊疗服务信息-过程图片上传 结束========" + res);
            logger.info("END========DataUploadJob 执行结束========");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("END===ERROE===DataUploadJob,message:"+e.getMessage());
        }
    }
}

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

@ -3,12 +3,10 @@ package com.yihu.jw.web.quota;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.internet.service.DataGeneratorService;
import com.yihu.jw.internet.service.InternetCommonService;
import com.yihu.jw.internet.service.InternetService;
import com.yihu.jw.internet.service.ykyy.YkyyInternetService;
import com.yihu.jw.job.DataUploadJob;
import com.yihu.jw.job.PrescriptionOverdueJob;
import com.yihu.jw.job.PrescriptionStatusUpdateJob;
import com.yihu.jw.job.QuartzHelper;
import com.yihu.jw.job.*;
import com.yihu.jw.job.ykyy.YkyyDataUploadJob;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.quota.JobService;
@ -53,6 +51,9 @@ public class JobController extends BaseController {
    @Autowired
    private YkyyInternetService ykyyInternetService;
    @Autowired
    private InternetCommonService internetCommonService;
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
        this.jobService = jobService;
@ -133,6 +134,17 @@ public class JobController extends BaseController {
                        logger.info("data_ykupload_job  job exist");
                    }
                    break;
                case "data_common_upload_job" :
                    //互联网医院 监管平台上报
                    if (!quartzHelper.isExistJob("data_common_upload_job")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("data_common_upload_job");
                        quartzHelper.addJob(CommonDataUploadJob.class, trigger, "data_common_upload_job", new HashMap<String, Object>());
                        logger.info("data_common_upload_job  job success");
                    } else {
                        logger.info("data_common_upload_job  job exist");
                    }
                    break;
                default :
            }
@ -466,6 +478,73 @@ public class JobController extends BaseController {
            return error(-1, "执行失败");
        }
    }
    @RequestMapping(value = "/inernetCommonUpload", method = RequestMethod.GET)
    @ApiOperation("监管平台通用业务数据上传")
    public String inernetCommonUpload(String id,String startDate,String endDate,String keyId) {
        try {
            switch(id){
                case "2.2" :
                    internetCommonService.upNsOrganBas();
                    break; //可选
                case "2.3" :
                    //语句
                    internetCommonService.upNsDoctorRecord(keyId);
                    break; //可选
                case "2.5" :
                    //语句
                    internetCommonService.upAppointmentOnline(startDate,endDate,keyId);
                    break; //可选
                case "2.6" :
                    //语句
                    internetCommonService.upMedicalOnline(startDate,endDate,keyId);
                    break; //可选
                case "2.7" :
                    //语句
                    internetCommonService.upNsDoctorScore(startDate,endDate,keyId);
                    break; //可选upNsDoctorScore
                case "2.8" :
                    //语句
                    internetCommonService.upNsOnlineAsk(startDate,endDate,keyId);
                    break; //可选
                case "2.9" :
                    //语句
                    internetCommonService.upNsOnlineMed(startDate,endDate,keyId);
                    break; //可选
                case "2.10" :
                    //语句
                    internetCommonService.upPrescription(startDate,endDate,keyId);
                    break; //可选
                case "2.11" :
                    //语句
                    internetCommonService.upPrescriptionDrug(startDate,endDate,keyId);
                    break; //可选
                case "2.12" :
                    //语句
                    internetCommonService.upNsOnlineImg(startDate,endDate,keyId);
                    break; //可选
                case "2.13" :
                    //语句
                    internetCommonService.upNsOrganProtocol(startDate,endDate,keyId);
                    break; //可选
                case "2.14" :
                    //语句
                    internetCommonService.upNsInvokeTotal(startDate,endDate);
                    break; //可选
                default : //可选
                    //语句
            }
            return write(200, "执行成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "执行失败");
        }
    }
    @RequestMapping(value = "/testImg", method = RequestMethod.GET)
    @ApiOperation("测试图片")
    public String testImg(String path) {

+ 71 - 9
svr/svr-internet-hospital-job/src/main/resources/application.yml

@ -53,14 +53,14 @@ FileTempPath:
  chat_file_path : /var/local/upload/chat
#发现服务
eureka:
  client:
    healthcheck:
      enabled: false #监控检查
    serviceUrl:
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/
  instance:
    prefer-ip-address: false
#eureka:
#  client:
#    healthcheck:
#      enabled: true #监控检查
#    serviceUrl:
#      defaultZone: http://172.16.100.63:8761/eureka/
#  instance:
#    prefer-ip-address: false
#    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
---
@ -222,4 +222,66 @@ fastDFS:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
---
spring:
  profiles: xzprod
  datasource:
    url: jdbc:mysql://172.16.100.240:7306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: jkzl
    password: jkzl@2020
hlwyyEntrance:
  url: http://172.16.100.63:10023
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.16.100.241:3000/
  data_base_name: im
fastDFS:
  fastdfs_file_url: http://172.16.100.240:8888/
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
---
spring:
  profiles: xzprod_in
  datasource:
    url: jdbc:mysql://192.168.103.155:7306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: jkzl
    password: jkzl@2020
hlwyyEntrance:
  url: http://172.16.100.63:10023
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://192.168.103.150:3000/
  data_base_name: im
fastDFS:
  fastdfs_file_url: http://192.168.103.159:8888/
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段

+ 8 - 0
svr/svr-internet-hospital-job/src/main/resources/bootstrap.yml

@ -51,3 +51,11 @@ spring:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.131.174:1221}
      label: ${wlyy.spring.config.label:local}
----
spring:
  profiles: xzprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.16.100.63:1221}
      label: ${wlyy.spring.config.label:master}

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

@ -13,3 +13,5 @@ data_upload_job=0 0 2 * * ?
data_ykupload_job=0 0 0 * * ?
#-------------------------眼科医院end-----------------------------#
#-------------------------监管平台通用医院-----------------------------#
data_common_upload_job=0 0 0 * * ?

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

@ -0,0 +1,63 @@
package com.yihu.jw.hospital.endpoint.Xzyy;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2020/1/19.
 */
@RestController
@RequestMapping(value ="/Xzyy")
@Api(value = "心脏医院", description = "心脏医院", tags = {"心脏医院"})
public class XzyyController extends EnvelopRestEndpoint {
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    /**
     * 查询患者就诊卡
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/findPatientCard")
    @ApiOperation(value = "查询患者就诊卡", notes = "查询患者就诊卡")
    public ObjEnvelop findPatientCard(@ApiParam(name = "idCard", value = "身份证号", required = false)
                                      @RequestParam(value = "idCard",required = false)String idCard)throws Exception{
        try {
            return ObjEnvelop.getSuccess("ok",xzzxEntranceService.selectPateintCard(idCard));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    /**
     * 获取卡信息
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getCardInfo")
    @ApiOperation(value = "获取卡信息", notes = "获取卡信息")
    public ObjEnvelop getCardInfo(@ApiParam(name = "cardNo", value = "就诊卡", required = false)
                                  @RequestParam(value = "cardNo",required = false)String cardNo)throws Exception{
        try {
            return ObjEnvelop.getSuccess("ok",xzzxEntranceService.getCardInfo(cardNo));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

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

@ -763,7 +763,9 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
                                      @ApiParam(name = "reciver_type", value = "接收人类型1居民 2医生")
                                      @RequestParam(value = "reciver_name",required = true) String reciver_type,
                                      @ApiParam(name = "session_id", value = "会话ID")
                                      @RequestParam(value = "session_id",required = true) String session_id
                                      @RequestParam(value = "session_id",required = true) String session_id,
                                      @ApiParam(name = "wechat_id", value = "来源")
                                      @RequestParam(value = "wechat_id",required = false) String wechat_id
	                                      )throws Exception  {
		wxTemplateService.sendWeTempMesMiniProgram(sender_id,sender_name,reciver_id,reciver_name,session_id);
		return success("操作成功");

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

@ -95,6 +95,12 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@Value("${wlyy.url}")
	private String wlyyUrl;
	
	@Value("${qywx.url}")
	private String qywxUrl;
	
	@Value("${qywx.id}")
	private String qywxId;
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
	@ApiOperation(value = "患者咨询记录查询")
	public Envelop records(
@ -411,21 +417,36 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			BasePatientDO p = basePatientDao.findById(re.getString("patient"));
			//发送企业号推送
			try{
				String url = "https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/chatroom?rstitle="+p.getName()+"%20专家咨询&type=1&sessionId="+re.getString("sessiond_id");
				logger.info("发送企业号url:"+url);
				enterpriseService.sendMKMesByMobile("zsyy",d.getMobile(),"您的专家咨询有新的消息,请您尽快回复[查看详情]("+url+")");
				
				
				if("zsyy".equals(qywxId)){
					String url = qywxUrl+"/ims-app-web/#/onlineChat/chatroom?rstitle="+p.getName()+"%20专家咨询&type="+type+"&sessionId="+re.getString("sessiond_id");
					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");
					logger.info("发送企业号url:"+roomUrl);
					enterpriseService.sendXCXMesByDoctor(qywxId,
							re.getString("doctor"),
							"wx53f6bb4ac081d840",
							roomUrl,
							p.getName()+"%20专家咨询","您有新的咨询消息",false,"");
				}else{}
				
				
			}catch (Exception e){
				logger.info("发送企业号失败"+e.toString());
			}
			//发送厦门i健康智能推送
			try{
				String wxurl = wlyyUrl+"/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId="+p.getId()+"_"+d.getId()+"_1&sessionType=1&from="+p.getId()+"&content="+URLEncoder.encode(symptoms)+"&businessType=1&doctor_idcard="+d.getIdcard()+"&patientName="+URLEncoder.encode(p.getName())+"&url=1";
				logger.info("发送厦门i健康智能推送url:"+wxurl);
				wlyyBusinessService.sendDoctorTemplateByDoctorIdcard(wxurl);
			}catch (Exception e){
				logger.info("发送厦门i健康智能失败"+e.toString());
			if(!"zsyy".equals(qywxId) && !"xm_xzzx_wx".equals(qywxId)){
				//发送厦门i健康智能推送
				try{
					String wxurl = wlyyUrl+"/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId="+p.getId()+"_"+d.getId()+"_1&sessionType=1&from="+p.getId()+"&content="+URLEncoder.encode(symptoms)+"&businessType=1&doctor_idcard="+d.getIdcard()+"&patientName="+URLEncoder.encode(p.getName())+"&url=1";
					logger.info("发送厦门i健康智能推送url:"+wxurl);
					wlyyBusinessService.sendDoctorTemplateByDoctorIdcard(wxurl);
				}catch (Exception e){
					logger.info("发送厦门i健康智能失败"+e.toString());
				}
			}
		}
		return success("操作成功", consult);
	}

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

@ -641,6 +641,31 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success(xzzxEntranceService.sendXCXMes( wxId, patient, cardNo, first, noticeContent, remark, miniProgramPagepath, miniProgramAppId));
    }
    @PostMapping(value = "/sendXZMes")
    @ApiOperation(value = "心脏模板消息推送小程序跳转", notes = "心脏模板消息推送小程序跳转")
    public Envelop ehospitalNotice(
            @ApiParam(name = "userName", value = "推送人姓名")
            @RequestParam(value = "userName", required = true) String userName,
            @ApiParam(name = "idCard", value = "推送人身份证")
            @RequestParam(value = "idCard", required = false) String idCard,
            @ApiParam(name = "phone", value = "推送人手机号")
            @RequestParam(value = "phone", required = true) String phone,
            @ApiParam(name = "title", value = "推送标题")
            @RequestParam(value = "title", required = true) String title,
            @ApiParam(name = "url", value = "跳转链接")
            @RequestParam(value = "url", required = false) String url,
            @ApiParam(name = "content", value = "内容简介")
            @RequestParam(value = "content", required = true) String content,
            @ApiParam(name = "contentString", value = "内容明细串")
            @RequestParam(value = "contentString", required = false) String contentString) throws Exception {
        String rs = xzzxEntranceService.ehospitalNotice(userName, idCard, phone, title, url, content, contentString);
        if("1".equals(rs)){
            return success("推送成功");
        }
        return failed("推送失败");
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientInfo)
    @ApiOperation(value = "获取居民信息接口", notes = "获取居民信息接口")
    public ObjEnvelop findPatientInfo(@ApiParam(name = "patient", value = "居民ID")

+ 61 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java

@ -0,0 +1,61 @@
package com.yihu.jw.hospital.endpoint.ykyy;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
 * Created by Trick on 2020/1/19.
 */
@RestController
@RequestMapping(value ="/ykyy")
@Api(value = "眼科医院", description = "眼科医院", tags = {"眼科医院"})
public class YkyyController extends EnvelopRestEndpoint {
    @Autowired
    private YkyyService ykyyService;
    @GetMapping(value = "/selectCardList")
    @ApiOperation(value = "查询就诊卡")
    public ObjEnvelop selectCardList(@ApiParam(name = "patient", value = "sql语句", required = true)
                                      @RequestParam(value = "patient",required = true)String patient){
        try {
            return ObjEnvelop.getSuccess("ok",ykyyService.selectCards(patient));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = "/addYkCard")
    @ApiOperation(value = "添加就诊卡")
    public ObjEnvelop addYkCard(@ApiParam(name = "patient", value = "sql语句", required = true)
                                     @RequestParam(value = "patient",required = true)String patient,
                                     @ApiParam(name = "card", value = "卡号", required = true)
                                     @RequestParam(value = "card",required = true)String card,
                                     @ApiParam(name = "type", value = "卡类型(0社保卡,1就诊卡)", required = true)
                                         @RequestParam(value = "type",required = true)String type,
                                    @ApiParam(name = "userId", value = "", required = false)
                                    @RequestParam(value = "userId",required = false)String userId){
        try {
            return ObjEnvelop.getSuccess("ok",ykyyService.addYkCard(patient,card,userId,type));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

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

@ -150,6 +150,10 @@ FileTempPath:
  image_path : /var/local/upload/images
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat
qywx:
  url: 2
  id: 2
---
spring:
  profiles: jwtest
@ -220,6 +224,10 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wlyy:
  url: http://ehr.yihu.com/wlyy/
qywx:
  url: 2
  id: 1
---
spring:
  profiles: jwprod
@ -292,6 +300,10 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
qywx:
  url: https://hlwyy.xmzsh.com/hlwyy
  id: zsyy
---
spring:
  profiles: jwOracleTest
@ -370,6 +382,10 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wlyy:
  url: http://ehr.yihu.com/wlyy/
qywx:
  url: 2
  id: 1
---
spring:
  profiles: jwOracleProd
@ -448,6 +464,10 @@ testPattern:
wlyy:
  url: http://ehr.yihu.com/wlyy/
qywx:
  url: 2
  id: 1
---
##==心脏中心 ===============================================================================
spring:
@ -519,6 +539,10 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wlyy:
  url: http://ehr.yihu.com/wlyy/
qywx:
  url: https://ih.xmheart.com/hlwyy/
  id: xm_xzzx_wx
---
##==心脏中心外 ===============================================================================
spring:
@ -592,6 +616,10 @@ testPattern:
wlyy:
  url: http://ehr.yihu.com/wlyy/
qywx:
  url: https://ih.xmheart.com/hlwyy/
  id: xm_xzzx_wx
---
##==厦门卫计委 ===============================================================================
spring:
@ -663,4 +691,8 @@ es:
  host:  http://172.16.100.240:9200
  tHost: 172.16.100.240:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  securityUser: lion:jkzlehr
qywx:
  url: 1
  id: 2

+ 3 - 1
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ActivityController.java

@ -174,13 +174,15 @@ public class ActivityController extends EnvelopRestEndpoint {
    @ApiOperation(value = "参与的活动")
    public MixEnvelop<ActivityDO, ActivityDO> selectByPatient(@ApiParam(name = "activity",value = "健康活动JSON")
                                           @RequestParam(value = "activity",required = false)String activity,
                                            @ApiParam(name = "flag",value = "1活动和计划")
                                                @RequestParam(value = "flag",required = false)String flag,
                                                  @ApiParam(name = "page", value = "第几页,从1开始")
                                           @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                                  @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                           @RequestParam(value = "size", required = false)Integer size){
        try{
            ActivityDO activityDO = toEntity(activity,ActivityDO.class);
            return service.selectByPatient(activityDO,page,size);
            return service.selectByPatient(activityDO,flag,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());

+ 27 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/CreditsDetailController.java

@ -497,4 +497,31 @@ public class CreditsDetailController extends EnvelopRestEndpoint {
    }
    @PostMapping(value = HealthBankMapping.healthBank.completePlan)
    @ApiOperation(value ="完成计划获取积分")
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> completePlan(@ApiParam(name = "hospital",value = "社区code" )
                                                                        @RequestParam(value = "hospital",required = false)String hospital,
                                                                        @ApiParam(name = "hospitalName",value = "社区名称")
                                                                        @RequestParam(value = "hospitalName",required = false)String hospitalName,
                                                                        @ApiParam(name = "patient",value = "居民code")
                                                                        @RequestParam(value = "patient",required = true)String patient,
                                                                        @ApiParam(name = "planCode",value = "计划code")
                                                                        @RequestParam(value = "planCode",required = true)String planCode,
                                                                        @ApiParam(name = "idcard",value = "身份证")
                                                                            @RequestParam(value = "idcard",required = false)String idcard,
                                                                        @ApiParam(name = "integrate",value = "积分")
                                                                            @RequestParam(value = "integrate",required = true)Integer integrate){
        try {
            CreditsDetailDO creditsDetailDO =service.completePlan(planCode,patient,idcard,integrate,hospital,hospitalName);
            MixEnvelop<CreditsDetailDO,CreditsDetailDO> envelop = new MixEnvelop<>();
            envelop.setObj(creditsDetailDO);
            return envelop;
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 33 - 4
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java

@ -185,6 +185,8 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
           activityDO.setDescription(templateName);
           activityDO.setGlobelTemplate(planCode);
           activityDO.setIntroduction(templateName);
           activityDO.setIsFlag(-1);
           activityDO.setDelFlag(1);
           activityDO =  activityDao.save(activityDO);
           TaskDO taskDO = new TaskDO();
           taskDO.setSaasId("dev");
@ -211,9 +213,32 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
               taskPatientDetailDO.setUpdateTime(new Date());
               taskPatientDetailDO.setTotal(0L);
               taskPatientDetailDO.setCouponTotal(0L);
               taskPatientDetailDO.setStatus(0);
               taskPatientDetailDO.setStatus(1);
               taskPatientDetailDao.save(taskPatientDetailDO);
           }
       }else {
           List<TaskDO> taskDOS = taskDao.selectByActivityId(activityDO.getId());
           if (taskDOS!=null&&taskDOS.size()!=0){
               TaskDO taskDO = taskDOS.get(0);
               TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
               if (taskPatientDetailDO==null){
                   taskPatientDetailDO = new TaskPatientDetailDO();
                   taskPatientDetailDO.setSaasId("dev");
                   taskPatientDetailDO.setTaskId(taskDO.getId());
                   taskPatientDetailDO.setActivityId(activityDO.getId());
                   taskPatientDetailDO.setPatientIdcard(idcard);
                   taskPatientDetailDO.setPatientId(patient);
                   taskPatientDetailDO.setHospital(hospital);
                   taskPatientDetailDO.setHospitalName(hospitalName);
                   taskPatientDetailDO.setCreateTime(new Date());
                   taskPatientDetailDO.setUpdateTime(new Date());
                   taskPatientDetailDO.setTotal(0L);
                   taskPatientDetailDO.setCouponTotal(0L);
                   taskPatientDetailDO.setStatus(1);
                   taskPatientDetailDao.save(taskPatientDetailDO);
               }
           }
       }
       envelop.setObj(activityDO);
       return envelop;
@ -363,11 +388,15 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
     * @param size 分页大小
     * @return
     */
    public MixEnvelop<ActivityDO, ActivityDO> selectByPatient(ActivityDO activityDO, Integer page, Integer size){
    public MixEnvelop<ActivityDO, ActivityDO> selectByPatient(ActivityDO activityDO,String flag, Integer page, Integer size){
        String condition = "";
        if (activityDO.getUnionId()!=null&&activityDO.getUnionId() !=""){
            condition="AND union_id = '"+ activityDO.getUnionId()+"'";
        }
        String condition1="";
        if (!StringUtils.isNoneBlank(flag)){
            condition1 =" and type <> '健康计划' ";
        }
        String sql ="SELECT * " +
                " FROM wlyy_health_bank_activity " +
                "WHERE " +
@ -379,7 +408,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
                "wlyy_health_bank_task_patient_detail" +
                " WHERE " +
                " patient_idcard = '"+activityDO.getPatientIdcard()+"' "+ condition+")" +
                " ) AND del_flag =1 " +
                " ) AND del_flag =1 " +condition1+
                " LIMIT "+(page-1)*size +","+size;
        List<ActivityDO> activityDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ActivityDO.class));
        for (ActivityDO activityDO1:activityDOS){
@ -450,7 +479,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
                "wlyy_health_bank_task_patient_detail" +
                " WHERE " +
                " patient_openid = '"+activityDO.getOpenId()+ "' AND patient_idcard = '"+activityDO.getPatientIdcard()+"'"+condition+ ")" +
                " )";
                " ) "+condition1;
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){

+ 36 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/CreditsDetailService.java

@ -1685,4 +1685,40 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        }
    }
    public CreditsDetailDO completePlan(String planCode,String patient,String idcard,Integer integrate,String hospital,String hospitalName) throws Exception {
        ActivityDO activityDO = activityDao.selectByTemplateIdAndType(planCode,"健康计划");
        CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
        if (activityDO!=null){
            List<TaskDO> taskDOS = taskDao.selectByActivityId(activityDO.getId());
            AccountDO accountDO = accountDao.selectByPatientId(patient);
            if (taskDOS!=null&&taskDOS.size()!=0){
                creditsDetailDO.setSaasId("dev");
                creditsDetailDO.setPatientId(patient);
                creditsDetailDO.setIdCard(idcard);
                creditsDetailDO.setIntegrate(integrate);
                creditsDetailDO.setStatus(1);
                creditsDetailDO.setTradeDirection(1);
                creditsDetailDO.setTradeType("ACTIVITY_TASK");
                creditsDetailDO.setAccountId(accountDO.getId());
                creditsDetailDO.setHospital(hospital);
                creditsDetailDO.setHospitalName(hospitalName);
                creditsDetailDO.setTransactionId(taskDOS.get(0).getId());
                creditsDetailDO.setUpdateTime(new Date());
                creditsDetailDO.setCreateTime(new Date());
                credittsLogDetailDao.save(creditsDetailDO);
                TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDOS.get(0).getId(),patient);
                if (taskPatientDetailDO!=null){
                    taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+integrate);
                }
                taskPatientDetailDao.save(taskPatientDetailDO);
                accountDO.setTotal(accountDO.getTotal()+integrate);
                accountDao.save(accountDO);
            }
        }else {
            throw new Exception("暂不能获取积分!");
        }
        return creditsDetailDO;
    }
}