21 Commits 8a0780c9bf ... c0b4705ede

Auteur SHA1 Bericht Datum
  liubing c0b4705ede Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev 2 jaren geleden
  liubing d856d4a0ab 日报新增上级点评 2 jaren geleden
  LAPTOP-KB9HII50\70708 6e845fbd7f 111 2 jaren geleden
  LAPTOP-KB9HII50\70708 ec4391c321 Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev 2 jaren geleden
  LAPTOP-KB9HII50\70708 39fa73b0fc 111 2 jaren geleden
  wangzhinan dd84367f1f Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev 2 jaren geleden
  LAPTOP-KB9HII50\70708 93e66dd12d 111 2 jaren geleden
  wangzhinan e3ead68c77 Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev 2 jaren geleden
  wangzhinan 7ad493cda7 海沧医保接口 2 jaren geleden
  LAPTOP-KB9HII50\70708 b51ba96f45 111 2 jaren geleden
  wangzhinan b9e7b41ead 海沧医保接口 2 jaren geleden
  LAPTOP-KB9HII50\70708 4284ffb9fe 111 2 jaren geleden
  LAPTOP-KB9HII50\70708 ac14585cc2 Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev 2 jaren geleden
  LAPTOP-KB9HII50\70708 d69d7be9bb 111 2 jaren geleden
  LAPTOP-KB9HII50\70708 7503801221 111 2 jaren geleden
  wangzhinan 653e4f937d 海沧医保接口 2 jaren geleden
  wangzhinan 188211c7c9 海沧医保接口 2 jaren geleden
  wangzhinan 659fa49093 海沧医保接口 2 jaren geleden
  wangzhinan 5e4fd8ebfe Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev 2 jaren geleden
  wangzhinan 51a0c60422 添加工具类判断节假日 2 jaren geleden
  liubing 28d9fdb6b2 Merge branch 'dev' of liubing/wlyy2.0 into dev 2 jaren geleden
43 gewijzigde bestanden met toevoegingen van 5540 en 245 verwijderingen
  1. 4 1
      business/base-service/src/main/java/com/yihu/jw/dailyReport/service/DailyReportUploadService.java
  2. 2253 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareNewService.java
  3. 94 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/Pkcs7Encoder.java
  4. 14 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4Context.java
  5. 354 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4New.java
  6. 162 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4Util.java
  7. 292 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/YibaoJiaMi.java
  8. 235 81
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/HcyyPrescriptionService.java
  9. 271 20
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  10. 85 7
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/HcyyEntranceService.java
  11. 14 1
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  12. 930 0
      common/common-entity/sql/mysql关键字大全.sql
  13. 3 0
      common/common-entity/sql/sql记录
  14. 47 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseMqttCallbackRecordDO.java
  15. 4 4
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientHealthIndex.java
  16. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/dailyReport/BaseDailyReportUploadDO.java
  17. 39 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationDO.java
  18. 2 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  19. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/HcyyService.java
  20. 3 8
      svr/svr-base/src/main/java/com/yihu/jw/base/service/menu/BaseMenuManageService.java
  21. 5 0
      svr/svr-cloud-care/pom.xml
  22. 14 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseMqttCallbackRecordDao.java
  23. 29 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wechat/WechatMenuController.java
  24. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  25. 26 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  26. 44 27
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/wechat/WeiXinEventProcess.java
  27. 195 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MQTTKXClientUtil.java
  28. 35 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/PostConstructUtil.java
  29. 2 3
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/common/PostConstructUtil.java
  30. 33 9
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  31. 34 3
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  32. 2 2
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  33. 11 0
      svr/svr-cloud-transfor/pom.xml
  34. 44 12
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/TransforController.java
  35. 22 23
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/service/AqgService.java
  36. 3 3
      svr/svr-cloud-transfor/src/main/resources/application.yml
  37. 1 1
      svr/svr-internet-hospital-entrance/src/main/resources/application.yml
  38. 2 2
      svr/svr-internet-hospital/pom.xml
  39. 3 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/dailyReport/DailyReportUploadPoint.java
  40. 85 27
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthCare/HealthCareEndPoint.java
  41. 89 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  42. 23 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/HcyyPrescriptionCotroller.java
  43. 19 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

+ 4 - 1
business/base-service/src/main/java/com/yihu/jw/dailyReport/service/DailyReportUploadService.java

@ -517,7 +517,7 @@ public class DailyReportUploadService {
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public BaseDailyReportUploadDO verifiedItem(String doctorId,String reportId,List<BaseDailyReportDetailDO> detailDOList) throws Exception {
    public BaseDailyReportUploadDO verifiedItem(String doctorId,String reportId,List<BaseDailyReportDetailDO> detailDOList,String leaderComment) throws Exception {
        String  doubtSql = " select dict_value from  wlyy_hospital_sys_dict where dict_name='healthUpload' and dict_code='healthUpload' ";
        List<String> dictValues = jdbcTemplate.queryForList(doubtSql,String.class);
        JSONObject doubtTypeObj = new JSONObject();
@ -539,6 +539,9 @@ public class DailyReportUploadService {
        if (DateUtil.getDays(nowDate,dailyReportUploadDO.getReportDate())>7){
            throw  new Exception("上传记录已超过7天无法再次操作");
        }
        if (StringUtils.isNotBlank(leaderComment)){
            dailyReportUploadDO.setLeaderComment(leaderComment);
        }
        Set<String> doubtTypeName = new HashSet<>();
        if(detailDOList.size()>0){//无完成事项内容
            boolean doubt  =false;

+ 2253 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareNewService.java

@ -0,0 +1,2253 @@
package com.yihu.jw.healthCare.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.healthCare.*;
import com.yihu.jw.entity.hospital.httplog.YlzHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.healthCare.utils.AES;
import com.yihu.jw.healthCare.utils.SafeUtil;
import com.yihu.jw.healthCare.utils.YibaoJiaMi;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.healthCare.*;
import com.yihu.jw.hospital.httplog.dao.YlzHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import net.sf.json.util.JSONTokener;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import javax.transaction.Transactional;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 医保对接
 * Created by wangzhinan 20211002
 */
@Service
@Transactional
public class HealthCareNewService {
    private Logger logger = LoggerFactory.getLogger(HealthCareNewService.class);
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private YlzHttpLogDao ylzHttpLogDao;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private YlzMedicalPrescriptionUploadDao ylzMedicalPrescriptionUploadDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private YlzMedicailRelationDao ylzMedicailRelationDao;
    @Autowired
    private YlzMedicailBillDao ylzMedicailBillDao;
    @Autowired
    private YlzMedicailIcdDao ylzMedicailIcdDao;
    @Autowired
    private YlzMedicailMxDao ylzMedicailMxDao;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private EntranceService entranceService;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    private String ylzConfigUrl;
    private String ylzConfigAppid;
    private String ylzConfigAppSecret;
    private String ylzConfigEncryptKey;
    private String ylzConfigSignKey;
    private String ylzConfigOrgCode;
    public static String entranceHealthCareUrl = "http://127.0.0.1:10023/healthCare/";
    public void initConfig() throws Exception{
        logger.info("初始话参数!");
        List<WlyyHospitalSysDictDO> hospitalSysDictDOS = hospitalSysDictDao.findByDictName("ylzConfig");
        if (hospitalSysDictDOS==null||hospitalSysDictDOS.size()==0){
            throw new Exception("尚未添加配置参数");
        }else {
            for (WlyyHospitalSysDictDO hospitalSysDictDO:hospitalSysDictDOS){
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigUrl")){
                    ylzConfigUrl = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigAppid")){
                    ylzConfigAppid = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigAppSecret")){
                    ylzConfigAppSecret = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigEncryptKey")){
                    ylzConfigEncryptKey = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigSignKey")){
                    ylzConfigSignKey = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigOrgCode")){
                    ylzConfigOrgCode = hospitalSysDictDO.getDictValue();
                }
            }
        }
    }
    /**
     * 医保统一调用接口
     * @param data
     * @param funid
     * @param name
     * @return
     * @throws Exception
     */
    @org.springframework.transaction.annotation.Transactional(propagation= Propagation.NOT_SUPPORTED)
    public String requestYlz(JSONObject data,String funid,String name) throws Exception {
        String obj="";
        try {
            YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
            initConfig();
            WlyyHospitalSysDictDO systemDict =  hospitalSysDictDao.findOneByDictNameAndDictCode("ylzConfig","testFlag");
            if (null!=systemDict&&"1".equalsIgnoreCase(systemDict.getDictValue())){//测试环境
                //N00.00.00.01接口外其他的接口在服务号前加个T就是测试
                funid ="N00.00.00.01".equalsIgnoreCase(funid)?funid:"T"+funid;
                System.out.println("funid="+funid);
            }
            JSONObject object = new JSONObject();
            object.put("sign_type","md5");
            object.put("appid",ylzConfigAppid);
            String accessToken = getYlzToken();
            if (accessToken==null){
                throw new Exception("token无效");
            }
            object.put("access_token",accessToken);
            object.put("funid",funid);
            data.put("appid",ylzConfigAppid);
            data.put("org_code",ylzConfigOrgCode);
            object.put("data",data);
            String signResult = SafeUtil.sign(object.toJSONString(),ylzConfigSignKey);
            obj = SafeUtil.encrypt(signResult,ylzConfigEncryptKey);
            JSONObject jsonObject = JSONObject.parseObject(obj);
          /*  obj = YibaoJiaMi.encryptData(object,ylzConfigSignKey,ylzConfigEncryptKey);
            JSONObject jsonObject = JSONObject.parseObject(obj);*/
            logger.info("请求前funid=="+funid+"data="+data.toJSONString());
            String response = httpClientUtil.postBody(ylzConfigUrl,jsonObject);
            ylzHttpLogDO.setResponseEncrpty(response);
            if (response!=null&&response!=""){
                JSONObject result = JSONObject.parseObject(response);
                if (result.getString("flag").equalsIgnoreCase("1")){
                    String dataResult = result.getString("encrypt_data");
                    result.remove("encrypt_data");
                    if (dataResult!=null&&dataResult!=""){
                        String decryptResult = AES.aesDecrypt(dataResult,ylzConfigEncryptKey);
                        JSONObject dataObject = JSONObject.parseObject(decryptResult);
                 /*       String decryptResult = YibaoJiaMi.decrypt(dataResult,ylzConfigEncryptKey);
                        JSONObject dataObject = JSONObject.parseObject(decryptResult);*/
                        result.put("encrypt_data",dataObject);
                        response = result.toJSONString();
                    }
                }
            }
            ylzHttpLogDO.setCode(funid);
            ylzHttpLogDO.setName(name);
            ylzHttpLogDO.setRequest(data.toJSONString());
            ylzHttpLogDO.setRequestEncrpty(obj);
            ylzHttpLogDO.setResponse(response);
            ylzHttpLogDO.setCreateTime(new Date());
            ylzHttpLogDao.save(ylzHttpLogDO);
            return response;
        }catch (Exception e){
            e.printStackTrace();
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            String error = sw.toString();
            YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
            ylzHttpLogDO.setCode(funid);
            ylzHttpLogDO.setName(name);
            ylzHttpLogDO.setRequest(data.toJSONString());
            ylzHttpLogDO.setRequestEncrpty(obj);
            ylzHttpLogDO.setResponse(error);
            ylzHttpLogDO.setCreateTime(new Date());
            ylzHttpLogDao.save(ylzHttpLogDO);
            return null;
        }
    }
    /**
     * 获取token
     * @return
     * @throws Exception
     */
    /**
     * 2.3.1	医师身份验证(处方权,多点执业等)
     */
    public String doctorAuthentication(String doctorId){
        try {
            BaseDoctorDO doctorDO = doctorDao.findOne(doctorId);
            if (doctorDO == null){
                throw new Exception("医生不存在");
            }
            List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
            if(doctorHospitalDOS.size()<=0){
                throw new Exception("未找到医生科室编码");
            }
            BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
            JSONObject data = new JSONObject();
            data.put("his_dept_code",doctorHospitalDO.getDeptCode());//his内部科室编码
            data.put("his_dept_name",doctorHospitalDO.getDeptName());//his内部科室名称
//        data.put("dept_code","");//医保科室编码	String	N
//        data.put("dept_name","");//医保科室名称	String	N
            data.put("medical_mode","10");//医疗就诊方式	10	门(急)诊
            data.put("name",doctorDO.getName());//医师姓名
            data.put("idcard",doctorDO.getIdcard());//医师证件号
            data.put("cert_type","01");//医师证件类型
            String result = requestYlz(data,"N20.17.02.01","医师身份验证");
            if(result == null){
                throw new Exception("医保请求失败");
            }
            logger.info("医师身份验证:"+result);
            JSONObject object = JSONObject.parseObject(result);
            if (object.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = object.getJSONObject("encrypt_data");
                return encryptData.getString("is_prescribe");
            }else {
                return "0";
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "0";
    }
    /**
     * 2.3.2	医师人脸签到表单地址
     * @param doctorId
     * @throws Exception
     */
    public String doctorFaceCheckInAddress(String doctorId)throws Exception{
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findOne("ylzConfigFaceReturnUrl");
        if(hospitalSysDictDO == null){
            throw new Exception("未配置回调地址");
        }
        BaseDoctorDO doctorDO = doctorDao.findOne(doctorId);
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
        JSONObject data = new JSONObject();
        data.put("name",doctorDO.getName());//医师姓名
        data.put("idcard",doctorDO.getIdcard());//医师证件号
        data.put("cert_type","01");//医师证件类型
        data.put("redirect_url",hospitalSysDictDO.getDictValue());//回调地址
        String result = requestYlz(data,"N20.17.02.02","医师人脸签到表单地址");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("医师人脸签到表单地址:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.3.3	获取医师人脸签到数据
     */
    public String doctorFaceCheckInData(String doctorId)throws Exception{
        BaseDoctorDO doctorDO = doctorDao.findOne(doctorId);
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
        JSONObject data = new JSONObject();
        data.put("name",doctorDO.getName());//医师姓名
        data.put("idcard",doctorDO.getIdcard());//医师证件号
        data.put("cert_type","01");//医师证件类型
        String result = requestYlz(data,"N20.17.02.05","获取医师人脸签到数据");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("获取医师人脸签到数据:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.3.4	医师人脸签到微信小程序二维码(N20.17.02.06)
     * @param doctorId
     * @throws Exception
     */
    public String doctorFaceCheckInAddressBase64(String doctorId)throws Exception{
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findOne("ylzConfigFaceReturnUrl");
        if(hospitalSysDictDO == null){
            throw new Exception("未配置回调地址");
        }
        BaseDoctorDO doctorDO = doctorDao.findOne(doctorId);
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
        JSONObject data = new JSONObject();
        data.put("name",doctorDO.getName());//医师姓名
        data.put("idcard",doctorDO.getIdcard());//医师证件号
        data.put("cert_type","01");//医师证件类型
        data.put("redirect_url",hospitalSysDictDO.getDictValue());//回调地址
        String result = requestYlz(data,"N20.17.02.06","2.3.3\t获取医师人脸签到数据");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("医师人脸签到表单地址:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.4.1 事前提醒
     */
    public String advanceWarning(String prescriptionId){
        try {
            WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
            if (wlyyPrescriptionDO == null){
                throw new Exception("续方信息不存在");
            }
            WlyyOutpatientDO outpatientDO = outpatientDao.findOne(wlyyPrescriptionDO.getOutpatientId());
            if (outpatientDO == null){
                throw new Exception("门诊信息不存在");
            }
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode");
            if(hospitalSysDictDO == null){
                throw new Exception("未配置网点编号");
            }
            String icCardNo = outpatientDO.getCardNo();
            String his_serial = outpatientDO.getRegisterNo();
            String org_code = hospitalSysDictDO.getDictCode();
            JSONObject data;
            //获取his处方信息
            String infoResponse = xzzxEntranceService.presUpload(icCardNo,his_serial,org_code);
            JSONObject infoObject = JSONObject.parseObject(infoResponse);
            if("0".equals(infoObject.getString("ret_code"))){
                data = infoObject;
            }else {
                throw new Exception("获取his处方信息失败:"+infoObject.getString("ret_mess"));
            }
            data.remove("ret_code");
            data.remove("ret_mess");
            data.remove("log_no");
            data.put("ticket_no",outpatientDO.getXtgzh());//	单据流水号
            String result = requestYlz(data,"N20.17.03.03","事前提醒");
            if(result == null){
                throw new Exception("医保请求失败");
            }
            logger.info("事前提醒:"+result);
            JSONObject object = JSONObject.parseObject(result);
            if (object.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = object.getJSONObject("encrypt_data");
                return encryptData.toJSONString();
            }
            return result;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 2.4.2	医师开方上传
     */
    public String doctorPrescriptionUpload(String prescriptionId,String wxId) throws Exception{
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
        if (wlyyPrescriptionDO == null){
            throw new Exception("续方信息不存在");
        }
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(wlyyPrescriptionDO.getOutpatientId());
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        BaseDoctorDO baseDoctorDO = doctorDao.findById(outpatientDO.getDoctor());
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(outpatientDO.getDoctor());
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode");
        if(hospitalSysDictDO == null){
            throw new Exception("未配置网点编号");
        }
        String icCardNo = outpatientDO.getCardNo();
        String his_serial = outpatientDO.getRegisterNo();
        String org_code = hospitalSysDictDO.getDictCode();
        JSONObject data = new JSONObject();
        if (StringUtils.isNoneBlank(wxId)){
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                //获取his处方信息
                JSONObject infoObject= xzzxEntranceService.presUploadToEntrance(icCardNo,his_serial,org_code);
                JSONObject info = infoObject.getJSONArray("data").getJSONObject(0);
                if("0".equals(info.getString("ret_code"))){
                    data = info;
                }else {
                    throw new Exception("获取his处方信息失败:"+infoObject.getString("ret_mess"));
                }
                data.remove("ret_code");
                data.remove("ret_mess");
                data.remove("log_no");
                data.put("order_id",prescriptionId);
            }else if(wxId.equalsIgnoreCase("xm_zsyy_wx")){
                net.sf.json.JSONArray result = entranceService.BS10108(outpatientDO.getCardNo(),outpatientDO.getIdcard(),null,null,null,null,his_serial,false);
                if (result!=null&&result.size()!=0){
                    net.sf.json.JSONObject object = result.getJSONObject(0);
                    net.sf.json.JSONObject jsonObject = object.getJSONObject("retInfo");
                    net.sf.json.JSONObject msgInfoJson = object.getJSONObject("msgInfo");
                    if (jsonObject.getString("retCode").equalsIgnoreCase("00")){
                        if (msgInfoJson!=null){
                            net.sf.json.JSONObject resultJSON = msgInfoJson.getJSONObject("receipt");
                            if (resultJSON!=null){
                                data.put("name",resultJSON.getString("xming0"));
                                data.put("cert_type","01");
                                data.put("region_code","3502");
                                data.put("order_id",resultJSON.getString("xtgzh0"));
                                data.put("medical_mode","10");
                                data.put("prescription_code",resultJSON.getString("xtgzh0"));
                                data.put("idcard",resultJSON.getString("id0000"));
                                data.put("cert_type","01");
                                data.put("sex",resultJSON.getString("brnl00"));
                                data.put("birth", com.yihu.jw.util.idcard.IdCardUtil.getBirthdayForIdcardStr(resultJSON.getString("id0000")));
                                data.put("phone",outpatientDO.getMobile());
                                data.put("medical_type","11");
                                data.put("medical_type_name","普通门诊");
                                data.put("medical_time",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));
                                data.put("disease_code",outpatientDO.getIcd10());
                                data.put("dept_code",outpatientDO.getDept());
                                data.put("dept_name",outpatientDO.getDeptName());
                                data.put("doctor_idcard",baseDoctorDO.getIdcard());
                                data.put("doctor_code",doctorMappingDO.getMappingCode());
                                data.put("doctor_name",baseDoctorDO.getName());
                                data.put("prescription_date",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()));
                                data.put("prescription_counts",resultJSON.getString("cfxms0"));
                                data.put("prescription_source",0);
                                List<WlyyPrescriptionDiagnosisDO> diagnosisDOList = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionId,1);
                                JSONArray diagnosisArray = new JSONArray();
                                for (WlyyPrescriptionDiagnosisDO diagnosisDO:diagnosisDOList){
                                    JSONObject diagnosisObj = new JSONObject();
                                    diagnosisObj.put("disease_code_icd10",diagnosisDO.getCode());
                                    diagnosisObj.put("disease_name_icd10",diagnosisDO.getName());
                                    diagnosisObj.put("disease_type","01");
                                    diagnosisObj.put("disease_order","01");
                                    diagnosisArray.add(diagnosisObj);
                                }
                                data.put("zdlist",diagnosisArray);
                                JSONArray infoList = new JSONArray();
                                Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                                if(json instanceof JSONObject){
                                    JSONObject mxListJSON = (JSONObject)json;
                                    JSONObject mxlistObj = mxListJSON.getJSONObject("mxlist");
                                    JSONObject infoJson = new JSONObject();
                                    infoJson.put("his_item_name",mxlistObj.getString("xmmc00"));
                                    infoJson.put("his_item_code",mxlistObj.getString("xmbh00"));
                                    infoJson.put("item_name",mxlistObj.getString("xmmc00"));
                                    infoJson.put("item_code",mxlistObj.getString("xmbh00"));
                                    infoJson.put("his_drug_no",mxlistObj.getString("xmbh00"));
                                    infoJson.put("his_detail_sn",mxlistObj.getString("cfhao0"));
                                    infoJson.put("invoice_type","01");
                                    infoJson.put("specification_type",mxlistObj.getString("xmgg00"));
                                    infoJson.put("dosage_form",mxlistObj.getString("jx0000"));
                                    infoJson.put("charge_unit",mxlistObj.getString("xmdw00"));
                                    infoJson.put("price",mxlistObj.getString("xmdj00"));
                                    infoJson.put("amount",mxlistObj.getString("xmsl00"));
                                    infoJson.put("total_money",mxlistObj.getString("xmje00"));
                                    infoJson.put("single_dose",mxlistObj.getString("dcyydw"));
                                    infoJson.put("use_frequency",mxlistObj.getString("yppl00"));
                                    infoJson.put("medical_way",mxlistObj.getString("gytj00"));
                                    infoJson.put("prescription_date",mxlistObj.getString("jzrq"));
                                    infoJson.put("medication_days",mxlistObj.getString("ylts00"));
                                    infoJson.put("his_dept_code",outpatientDO.getDept());
                                    infoJson.put("his_dept_name",outpatientDO.getDeptName());
                                    infoJson.put("limit_type",mxlistObj.getString("sfybxm"));
                                    infoList.add(infoJson);
                                }else if (json instanceof JSONArray){
                                    JSONArray mxListArray = (JSONArray)json;
                                    for (int j=0;j<mxListArray.size();j++){
                                        JSONObject mxlistObj = mxListArray.getJSONObject(j);
                                        JSONObject infoJson = new JSONObject();
                                        infoJson.put("his_item_name",mxlistObj.getString("xmmc00"));
                                        infoJson.put("his_item_code",mxlistObj.getString("xmbh00"));
                                        infoJson.put("item_name",mxlistObj.getString("xmmc00"));
                                        infoJson.put("item_code",mxlistObj.getString("xmbh00"));
                                        infoJson.put("his_drug_no",mxlistObj.getString("xmbh00"));
                                        infoJson.put("his_detail_sn",mxlistObj.getString("cfhao0"));
                                        infoJson.put("invoice_type","01");
                                        infoJson.put("specification_type",mxlistObj.getString("xmgg00"));
                                        infoJson.put("dosage_form",mxlistObj.getString("jx0000"));
                                        infoJson.put("charge_unit",mxlistObj.getString("xmdw00"));
                                        infoJson.put("price",mxlistObj.getString("xmdj00"));
                                        infoJson.put("amount",mxlistObj.getString("xmsl00"));
                                        infoJson.put("total_money",mxlistObj.getString("xmje00"));
                                        infoJson.put("single_dose",mxlistObj.getString("dcyydw"));
                                        infoJson.put("use_frequency",mxlistObj.getString("yppl00"));
                                        infoJson.put("medical_way",mxlistObj.getString("gytj00"));
                                        infoJson.put("prescription_date",mxlistObj.getString("jzrq"));
                                        infoJson.put("medication_days",mxlistObj.getString("ylts00"));
                                        infoJson.put("his_dept_code",outpatientDO.getDept());
                                        infoJson.put("his_dept_name",outpatientDO.getDeptName());
                                        infoJson.put("limit_type",mxlistObj.getString("sfybxm"));
                                        infoList.add(infoJson);
                                    }
                                }
                                data.put("mxlist",infoList);
                            }
                        }
                    }
                }
            }
        }
        YlzMedicalPrescriptionUploadDO uploadDO = new YlzMedicalPrescriptionUploadDO();
        uploadDO.setOrgCode(org_code);
        uploadDO.setIcCardNo(icCardNo);
        uploadDO.setHisSerial(his_serial);
        uploadDO.setOutpatientId(wlyyPrescriptionDO.getOutpatientId());
        uploadDO.setPrescriptionId(prescriptionId);
        uploadDO.setRegionCode(data.getString("region_code"));
        uploadDO.setName(data.getString("name"));
        uploadDO.setIdcard(outpatientDO.getIdcard());
        uploadDO.setCertType(data.getString("cert_type"));
        uploadDO.setDataSource("53");//53移动支付
        uploadDO.setInsuranceSerial(data.getString("insurance_serial"));
        String result = requestYlz(data,"N20.17.03.01","医师开方上传");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("医师开方上传:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            uploadDO.setTransactionNo(encryptData.getString("transaction_no"));
            ylzMedicalPrescriptionUploadDao.save(uploadDO);
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.4.2	医师开方上传
     *
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    public String doctorPrescriptionUploadEntrance(String prescriptionId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"doctorPrescriptionUpload?prescriptionId="+prescriptionId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.4.3	医师开方上传取消(N20.17.03.06)
     */
    public String doctorPrescriptionUploadCancle(String prescriptionId,String cancelReason)throws Exception{
        YlzMedicalPrescriptionUploadDO uploadDO = ylzMedicalPrescriptionUploadDao.findByPrescriptionId(prescriptionId);
        if(uploadDO == null){
            throw new Exception("未找到开发上传记录");
        }
        JSONObject data = new JSONObject();
        data.put("transaction_no",uploadDO.getTransactionNo());//处方上传流水号  	String	Y
        data.put("insurance_serial",uploadDO.getInsuranceSerial());//医保流水号
        data.put("cancel_reason",cancelReason);//作废原因
        data.put("region_code",uploadDO.getRegionCode());//参保地区划代码
        data.put("idcard",uploadDO.getIdcard());//证件号码
        data.put("name",uploadDO.getName());//姓名
        data.put("cert_type",uploadDO.getCertType());//证件类型
        data.put("data_source",uploadDO.getDataSource());//数据来源	String	Y	参见编码附件
        String result = requestYlz(data,"N20.17.03.06","医师开方上传取消");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("医师开方上传取消:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.4.3	医师开方上传取消(N20.17.03.06)
     *
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    public String doctorPrescriptionUploadCancleEntrance(String prescriptionId,String cancelReason) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"doctorPrescriptionUploadCancle?prescriptionId="+prescriptionId+"&cancelReason"+cancelReason;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.6.1	电子处方订单接收(N20.17.05.02)
     */
    public String electronicPrescriptionReceiving(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outpatientId);
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        List<WlyyPrescriptionExpressageDO> expressageDOList = prescriptionExpressageDao.findByOutpatientId(outpatientId);
        if(expressageDOList.size()==0){
            throw new Exception("收获信息不存在");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient());
        if(patientDO==null){
            throw new Exception("居民信息不存在");
        }
        WlyyPrescriptionExpressageDO expressageDO = expressageDOList.get(0);
        logger.info("电子处方订单接收:1");
        List<YlzMedicalRelationDO> ylzMedicalRelationDOList = ylzMedicailRelationDao.findByOutpatientStatus(outpatientId);
        for (YlzMedicalRelationDO ylzMedicalRelationDO:ylzMedicalRelationDOList){
            logger.info("电子处方订单接收:2");
            JSONObject data = new JSONObject();
            data.put("order_time",DateUtil.dateToStrLong(expressageDO.getCreateTime()));//订单时间
            List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByRealOrderList(ylzMedicalRelationDO.getLogNo());
            if(wlyyPrescriptionDOS.size()==0){
                throw new Exception("处方信息不存在");
            }
            data.put("order_code",ylzMedicalRelationDO.getLogNo());//订单号
            WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOS.get(0);
            data.put("prescription_code",wlyyPrescriptionDO.getRealOrder());//医院处方编号
            data.put("channel","1");//1、微信公众号,2、app,3、web
            data.put("insurance_ticket_no",ylzMedicalRelationDO.getBillSerial());//医保收费单据号	String	N	订单结算后的收费单据号
            String order_state = "";
            if (wlyyPrescriptionDO.getStatus()==30){
                order_state = "1";
            }else if (wlyyPrescriptionDO.getStatus()==31){
                order_state = "2";
            }else if (wlyyPrescriptionDO.getStatus()==100){
                order_state = "3";
            }
            logger.info("电子处方订单接收:3"+order_state);
            data.put("order_state",order_state);//订单状态    --1待发货、2配送中、3已签收、4已取消	String	Y
            data.put("order_addr_detail",expressageDO.getProvinceName()+expressageDO.getCityName()+expressageDO.getTownName()+expressageDO.getStreetName()+expressageDO.getAddress());//订单详细地址
            data.put("order_owner",expressageDO.getName());
            data.put("order_owner_idcard",patientDO.getIdcard());
            data.put("order_owner_phone",patientDO.getMobile());
            Map<String,String> map = LatitudeUtils.getGeocoderLatitude(expressageDO.getProvinceName()+expressageDO.getCityName()+expressageDO.getTownName()+expressageDO.getStreetName()+expressageDO.getAddress());
            data.put("addr_lat",map.get("lat"));//收货地址纬度
            data.put("addr_lng",map.get("lng"));//收货地址经度
            if(expressageDO.getOneselfPickupFlg()==1){
                //自取
                data.put("delivery_way","2");//1.网订配送,2.网订自取
                data.put("qrcode_check_time","");//扫码校验时间
                data.put("receiving_time","");//药品签收时间
            }else {
                //非自取
                data.put("delivery_way","1");//配送方式 1.网订配送,2.网订自取
                data.put("delivery_number",expressageDO.getMailno());//配送单号
                data.put("delivery_org","顺丰");//配送单位
                data.put("delivery_take_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//配送接单时间
                data.put("delivery_name","顺丰");//配送人姓名
                data.put("delivery_id_card","顺丰");//配送人身份证
//            data.put("delivery_phone","");//配送人联系电话 N
                data.put("getmedical_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//骑手取药记录
                data.put("delivery_money","");//配送费
            }
//        apothecary_name	药师姓名	String	N
//        apothecary_id_card	药师身份证	String	N
//        apothecary_audit	药师审核时间	String	N
            data.put("money",ylzMedicalRelationDO.getTotalAmount());//商品金额
            data.put("settlement_time",DateUtil.dateToStrLong(ylzMedicalRelationDO.getPayDate()));//结算时间
            data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
            data.put("delivery_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//发单时间
            data.put("elec_prescription_code",wlyyPrescriptionDO.getId());//平台处方编号
            data.put("prescription_code",wlyyPrescriptionDO.getRealOrder());//医院处方编号
//        data.put("insurance_serial",outpatientDO.getInsuranceSerial());//医保门诊流水号
            data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//门诊业务流水号
            JSONArray array = new JSONArray();
            List<YlzMedicalMxDO> ylzMedicalMxDOS = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
            for (YlzMedicalMxDO ylzMedicalMxDO:ylzMedicalMxDOS){
                JSONObject object = new JSONObject();
                object.put("order_id",ylzMedicalRelationDO.getLogNo());
                object.put("settlement_no",ylzMedicalRelationDO.getHisBillSerial());
                object.put("item_name",ylzMedicalMxDO.getItemName());
                object.put("item_code",ylzMedicalMxDO.getItemCode());
                array.add(object);
            }
            data.put("MXLIST",array);
//        mxlist	药品明细	MXLIST	N
//        MXLIST
//        order_id	订单号	String	Y
//        settlement_no	医保结算单据号	String	Y
//        item_name	医保项目名称	String	Y
//        item_code	医保项目编码	String	Y
//        supervision_code	药品电子监管码	String	N	非必填
            String result = requestYlz(data,"N20.17.05.02","电子处方订单接收");
            if(result == null){
                throw new Exception("医保请求失败");
            }
            logger.info("电子处方订单接收:"+result);
            JSONObject object = JSONObject.parseObject(result);
            if (object.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = object.getJSONObject("encrypt_data");
                logger.info("encryptData=="+encryptData);
            }
        }
        return "上传成功";
    }
    /**
     *2.6.2	电子处方订单取消(N20.17.05.03)
     */
    public String electronicPrescriptionCancle(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outpatientId);
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("order_code","");//订单号
        data.put("order_time",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));//订单时间
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        data.put("prescription_code",wlyyPrescriptionDOS.get(0).getRealOrder());//医院处方编号
        data.put("channel","1");//1、微信公众号,2、app,3、web
//        data.put("insurance_ticket_no","");//医保收费单据号	String	N	订单结算后的收费单据号
        data.put("order_state","");//订单状态    --1待发货、2配送中、3已签收、4已取消	String	Y
        data.put("cancel_time","");//订单取消时间  取消时必填
        data.put("cancel_reason","");//取消原因
        String result = requestYlz(data,"N20.17.05.03","电子处方订单取消");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("电子处方订单取消:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.6.3 获取处方流转平台药师审方结果(N20.17.05.04)
     */
    public String pharmacistReviewResults(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outpatientId);
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
//        data.put("order_code","");//订单号
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        data.put("prescription_code",wlyyPrescriptionDOS.get(0).getRealOrder());//医院处方编号
        String result = requestYlz(data,"N20.17.05.04","获取处方流转平台药师审方结果");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("获取处方流转平台药师审方结果:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.2.1	门诊提醒(N21.08.09.01)
     */
    public String outpatientReminder(String outpatientId,String doctorCode)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outpatientId);
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
//        data.put("order_code","");//订单号
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        data.put("card_no",outpatientDO.getCardNo());//社保卡号
        List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(outpatientDO.getDoctor());
        if(doctorHospitalDOS.size()<=0){
            throw new Exception("未找到医生科室编码");
        }
        BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
        data.put("medical_dept_code",doctorHospitalDO.getDeptCode());//科室编码(使用医院科室编号)
        data.put("medical_dept_name",doctorHospitalDO.getDeptName());//科室名称
        data.put("doctor_code",doctorCode);//医师编号(使用医保医生编号)
        data.put("doctor_name",outpatientDO.getDoctorName());//医师姓名
        String result = requestYlz(data,"N21.08.09.01","门诊提醒");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("门诊提醒:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.2.2	门诊事中提醒(N21.08.09.02)
     */
    public String outpatientEventReminder(String outpatientId,String doctorCode)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outpatientId);
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
//        data.put("order_code","");//订单号
        data.put("card_no",outpatientDO.getCardNo());//社保卡号
        data.put("visit_no",outpatientDO.getRegisterNo());//门诊挂号号
        data.put("visit_type","1");//就诊类型	String	Y	(1住院、2门诊)
        data.put("medicine_type","");//医疗类别	String	Y
        List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(outpatientDO.getDoctor());
        if(doctorHospitalDOS.size()<=0){
            throw new Exception("未找到医生科室编码");
        }
        BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
        data.put("medical_dept_code",doctorHospitalDO.getDeptCode());//科室编码(使用医院科室编号)
        data.put("medical_dept_name",doctorHospitalDO.getDeptName());//科室名称
        data.put("doctor_code",doctorCode);//医师编号(使用医保医生编号)
        data.put("doctor_name",outpatientDO.getDoctorName());//医师姓名
        data.put("doctor_advice_no","");// 	处方流水号(医院内部唯一号)	String	Y
        //医嘱
        JSONArray advice_details = new JSONArray();
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        for (WlyyPrescriptionDO wlyyPrescriptionDO:wlyyPrescriptionDOS){
            List<WlyyPrescriptionInfoDO> prescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
            for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:prescriptionInfoDOS){
                JSONObject infoObj = new JSONObject();
                infoObj.put("project_code","");//项目编码	String	Y	(使用医保三目录项目编码),正常情况必填,特殊情况,如生化全套等没有医保编码,可放空。
                infoObj.put("hospital_code","");//院内项目编码
                infoObj.put("project_name","");//项目名称
                infoObj.put("recipe_no",wlyyPrescriptionDO.getRealOrder());//处方号
                infoObj.put("invoice_project","");//发票项目编码	String	Y	(使用医保发票项目编码)
                infoObj.put("medical_specification",wlyyPrescriptionInfoDO.getSpecification());//规格型号
                infoObj.put("dose_form",wlyyPrescriptionInfoDO.getDosage());//剂型
                infoObj.put("charge_unit","");//单位
                infoObj.put("price",wlyyPrescriptionInfoDO.getPackRetprice());//单价
                infoObj.put("dose_unit",wlyyPrescriptionInfoDO.getPackRetprice());//单价
                infoObj.put("medical_number",wlyyPrescriptionInfoDO.getQuantity());//数量
                infoObj.put("amount",wlyyPrescriptionInfoDO.getPackRetprice()*Integer.parseInt(wlyyPrescriptionInfoDO.getQuantity()));//金额
                infoObj.put("single_dose_number","");//每次用量
                infoObj.put("single_dose_unit","");//每次用量
                infoObj.put("use_frequency",wlyyPrescriptionInfoDO.getUsageName());//使用频次
                infoObj.put("deliver_way","");//具体给药途径详见附录三的编码
                infoObj.put("use_day",wlyyPrescriptionInfoDO.getDays());//用药天数
/*                dose_form	剂型, 	String	Y	具体可使用剂型详见附录五的编码
                medical_specification	规格	String	Y
                price	单价	String	Y	必须使用数值型,如”12.5”
                medical_number	数量	String	Y	必须使用数值型,如”10”
                dose_unit	单价 String	Y
                amount	金额	String	Y	必须使用数值型,如”50.5”
                use_day	用药天数	String	Y	(项目为药品时非空),医嘱服用该药品天数,必须使用数值型,如”15”
                single_dose_number	单次用药量	String	Y	(项目为药品时非空),配合下一个字段的单位,如 50 mg,必须使用数值型,如”50”
                single_dose_unit	单次用药量剂量单位	String	Y	(项目为药品时非空),具体可使用剂量单位详见附录四的编码
                take_medical_number	取药总量(	String	Y	项目为药品时非空),配合下一个字段的单位,如 500 mg,必须使用数值型,如”500”
                take_medical_unit	取药总量剂量单位	String	Y	(项目为药品时非空),具体可使用剂量单位附录四的编码
                dose_day	药量天数	String	Y	(项目为药品时非空),依据医嘱服药要求,所配药品患者可以服用的天数,必须使用数值型,如”5”
                deliver_way	给药途径	String	Y	具体给药途径详见附录三的编码
                take_frequence	服用频次	String	Y
                具体可用服用频次详见附录二的编码*/
                advice_details.add(infoObj);
            }
        }
        data.put("advice_details",advice_details);
        //诊断
        JSONArray diagnoses = new JSONArray();
        String icd10 = outpatientDO.getIcd10();
        String icd10Name = outpatientDO.getIcd10Name();
        String icd[] = icd10.split(",");
        String icdName[] = icd10Name.split(",");
        for (int i=0;i<icd.length;i++){
            JSONObject icdObj = new JSONObject();
            icdObj.put("disease_code_icd10",icd[i]);//诊断或症状编码
            icdObj.put("disease_name_icd10",icdName[i]);//诊断或症状名称
            diagnoses.add(icdObj);
        }
        data.put("diagnoses",diagnoses);
        String result = requestYlz(data,"N21.08.09.02","门诊事中提醒");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("门诊事中提醒:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    public String getYlzToken() throws Exception {
        YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
        String token = null;
        initConfig();
        String funid = "N00.00.00.01";
        JSONObject data = new JSONObject();
        data.put("appid",ylzConfigAppid);
        data.put("appsecret",ylzConfigAppSecret);
        data.put("grant_type","client_credentials");
        JSONObject object = new JSONObject();
        object.put("sign_type","md5");
        object.put("appid",ylzConfigAppid);
       /* String stringSignTemp ="appid="+ylzConfigAppid+"&appsecret="+ylzConfigAppSecret+"&data="+data+"&funid="+funid+"&sign_type=md5&key="+ylzConfigSignKey;
        String sign = MD5.md5(stringSignTemp).toUpperCase();*/
        object.put("data",data);
        object.put("funid",funid);
        String signResult = SafeUtil.sign(object.toJSONString(),ylzConfigSignKey);
        String obj = SafeUtil.encrypt(signResult,ylzConfigEncryptKey);
        JSONObject jsonObject = JSONObject.parseObject(obj);
        logger.info("请求前funid=="+funid+"data="+data);
        String response = httpClientUtil.postBody(ylzConfigUrl,jsonObject);
        ylzHttpLogDO.setResponseEncrpty(response);
        logger.info("请求后response=="+response);
        if (response!=null&&response!=""){
            JSONObject result = JSONObject.parseObject(response);
            if (result.getString("flag").equalsIgnoreCase("1")){
                String dataResult = result.getString("encrypt_data");
                result.remove("encrypt_data");
                if (dataResult!=null&&dataResult!=""){
                    String decryptResult = AES.aesDecrypt(dataResult,ylzConfigEncryptKey);
                    JSONObject dataObject = JSONObject.parseObject(decryptResult);
                    result.put("encrypt_data",dataObject);
                    response = result.toString();
                    token = dataObject.getString("access_token");
                }
            }
        }
        ylzHttpLogDO.setCode(funid);
        ylzHttpLogDO.setName("获取AccessToken");
        ylzHttpLogDO.setRequest(data.toJSONString());
        ylzHttpLogDO.setRequestEncrpty(obj);
        ylzHttpLogDO.setResponse(response);
        ylzHttpLogDO.setCreateTime(new Date());
        ylzHttpLogDao.save(ylzHttpLogDO);
        
        return token;
    }
    /**
     * 2.2.1渠道应用是否已授权(N20.17.01.01)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String authorized(String patient) throws Exception{
        String funid = "N20.17.01.01";
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO==null){
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO
        data.put("phone",patientDO.getMobile());
        data.put("user_id",patientMappingDO.getMappingCode());
        String result = requestYlz(data,funid,"渠道应用是否已授权");
        return result;
    }
    /**
     * 2.2.1渠道应用是否已授权(N20.17.01.01)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String authorizedToEntrace(String patient) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"authorized?patient="+patient;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.2.2医保在线服务授权表单(H5表单/小程序)(N20.17.01.02)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String medicareOnline(String patient) throws Exception{
        String funid = "N20.17.01.02";
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl");
        if (hospitalSysDictDO==null){
            throw new Exception("回调地址为空!");
        }
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO==null){
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO
        data.put("phone",patientDO.getMobile());
        data.put("user_id",patientMappingDO.getMappingCode());
        data.put("redirect_url",hospitalSysDictDO.getDictValue());
        String result = requestYlz(data,funid,"医保在线服务授权表单");
        return result;
    }
    /**
     * 2.2.2医保在线服务授权表单(H5表单/小程序)(N20.17.01.02)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String medicareOnlineToEntrance(String patient) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"medicareOnline?patient="+patient;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.2.3医保在线服务授权表单(H5表单/小程序)(N20.17.01.03)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String medicareOnlineBase64(String patient) throws Exception{
        String funid = "N20.17.01.03";
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl");
        if (hospitalSysDictDO==null){
            throw new Exception("回调地址为空!");
        }
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO==null){
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO
        data.put("phone",patientDO.getMobile());
        data.put("user_id",patientMappingDO.getMappingCode());
        data.put("redirect_url",hospitalSysDictDO.getDictValue());
        String result = requestYlz(data,funid,"医保在线服务授权表单");
        return result;
    }
    /**
     * 2.2.3医保在线服务授权表单(H5表单/小程序)(N20.17.01.03)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String medicareOnlineBase64ToEntrance(String patient) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"medicareOnline?patient="+patient;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.1医保挂号(N20.17.04.01)
     *
     * 返回值
     *
     * @param outpatientId 系统id
     * @return
     * @throws Exception
     */
    public String register(String outpatientId) throws Exception{
        String funid = "N20.17.04.01";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("上传医保挂号失败:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("his_dept_code",ylzMedicalRelationDO.getHisDeptCode());//his内部科室编码
        data.put("his_dept_name",ylzMedicalRelationDO.getHisDeptName());//his内部科室名称
        data.put("emergency_sign",ylzMedicalRelationDO.getEmergencySign());//急诊标志0 否,1 是
        data.put("trauma_sign",ylzMedicalRelationDO.getTraumaSign());//外伤标志0 否,1 是
        data.put("date", DateUtil.dateToStrFormatLong(ylzMedicalRelationDO.getDate()));//实际门诊/入院日期 若为空,默认取系统时间
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if (outpatientDO!=null){
            BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor());
            if (doctorDO!=null){
                data.put("atddr_no",doctorDO.getAtddrNo());
                data.put("dr_name",doctorDO.getName());
            }
        }
        String result = requestYlz(data,funid,"医保挂号");
        if (result==null){
            throw new Exception("上传医保挂号失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            String insuranceSerial = encryptData.getString("insurance_serial");
            ylzMedicalRelationDO.setInsuranceSerial(insuranceSerial);
            ylzMedicalRelationDO.setInsuranceType(encryptData.getString("insurance_type"));
            ylzMedicalRelationDO.setInsuranceTypeName(encryptData.getString("insurance_type_name"));
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            logger.info("医保挂号流水号保存成功");
        }
        return result;
    }
    /**
     * 2.5.1医保挂号(N20.17.04.01)
     *
     * 返回值
     *
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public String registerToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"register?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.2医保挂号冲销(N20.17.04.02)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String registerBack(String outpatientId) throws Exception{
        String funid = "N20.17.04.02";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保挂号冲销失败:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        String result = requestYlz(data,funid,"医保挂号冲销");
        if (result==null){
            throw new Exception("上传医保挂号冲销失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            String invalidSerial = encryptData.getString("refund_serial");
            logger.info("医保挂号冲销流水号保存成功");
        }
        return result;
    }
    /**
     * 2.5.2医保挂号冲销(N20.17.04.02)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String registerBackToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"registerBack?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.3医保费用明细上传(N20.17.04.03)
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailUpload(String outpatientId) throws Exception{
        String funid = "N20.17.04.03";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型 TODO
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("item_count",ylzMedicalRelationDO.getItemCount());//明细项目数量
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        List<YlzMedicalIcdDO> ylzMedicalIcdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
        if (ylzMedicalIcdDOList==null){
            throw new Exception("医保费用明细上传:诊断结算信息为空!");
        }
        JSONArray icdArray = new JSONArray();
        for (YlzMedicalIcdDO ylzMI:ylzMedicalIcdDOList){
            JSONObject icdObj = new JSONObject();
            icdObj.put("disease_code_icd10",ylzMI.getDiseaseCodeIcd10());//诊断或症状编码
            icdObj.put("disease_name_icd10",ylzMI.getDiseaseNameIcd10());//诊断或症状名称
            icdObj.put("disease_type",ylzMI.getDiseaseType());//诊断或症状类型
            icdObj.put("disease_order",ylzMI.getDiseaseOrder());//诊断或症状序号
            icdArray.add(icdObj);
        }
        data.put("zdlist",icdArray);
        List<YlzMedicalMxDO> ylzMedicalMxDOS = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
        if (ylzMedicalIcdDOList==null){
            throw new Exception("医保费用明细上传:诊断结算信息为空!");
        }
        JSONArray infoArray = new JSONArray();
        for (YlzMedicalMxDO ylzMedicalMxDO:ylzMedicalMxDOS){
                JSONObject infoObj = new JSONObject();
                infoObj.put("prescription_code",ylzMedicalMxDO.getPrescriptionCode());//医院处方编号
                infoObj.put("his_detail_sn",ylzMedicalMxDO.getHisDetailSn());//his处方明细流水号
                infoObj.put("item_name",ylzMedicalMxDO.getItemName());//医保项目名称
                infoObj.put("item_code",ylzMedicalMxDO.getItemCode());//医保项目编码
                infoObj.put("specification_type",ylzMedicalMxDO.getSpecificationType());//规格型号
                infoObj.put("dosage_form",ylzMedicalMxDO.getDosageForm());//剂型
                infoObj.put("charge_unit",ylzMedicalMxDO.getChargeUnit());//单位
                infoObj.put("price",ylzMedicalMxDO.getPrice());//单价
                infoObj.put("amount",ylzMedicalMxDO.getAmount());//数量
                infoObj.put("total_money",ylzMedicalMxDO.getTotalMoney());//金额
                infoObj.put("prescription_date", DateUtil.dateToStrLong(ylzMedicalMxDO.getPrescriptionDate()));//处方日期
                infoObj.put("his_dept_code",ylzMedicalMxDO.getHisDeptCode());//his内部科室编码
                infoObj.put("his_dept_name",ylzMedicalMxDO.getHisDeptName());//his内部科室名称
                infoObj.put("medical_per_name",ylzMedicalMxDO.getMedicalPerName());//医疗服务人员姓名
                infoObj.put("medical_per_id",ylzMedicalMxDO.getMedicalPerId());//医疗服务人员证件号码
                infoObj.put("limit_type",ylzMedicalMxDO.getLimitType());//限制范围类别
                infoObj.put("actg_date",DateUtil.dateToStr(ylzMedicalMxDO.getActgDate(),DateUtil.YYYYMMDD));//记帐日期
                infoObj.put("his_item_name",ylzMedicalMxDO.getHisItemName());//HIS院内项目名称
                infoObj.put("his_item_code",ylzMedicalMxDO.getHisItemCode());//HIS院内项目编码
                infoObj.put("clerk_days",DateUtil.dateToStrLong(ylzMedicalMxDO.getClerkDays()));//记帐日期
                infoObj.put("people_type",ylzMedicalMxDO.getPeopleType());//医保服务人员类别
                infoArray.add(infoObj);
        }
        data.put("mxlist",infoArray);
        String result = requestYlz(data,funid,"医保费用明细上传");
        if (result==null){
            throw new Exception("医保费用明细上传失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            String detailSerial = encryptData.getString("detail_serial");
            ylzMedicalRelationDO.setDetailSerial(detailSerial);
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            logger.info("医保费用明细上传保存成功");
        }else {
            throw new Exception(object.getString("cause"));
        }
        return result;
    }
    /**
     * 2.5.3医保费用明细上传(N20.17.04.03)
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailUploadToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailUpload?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.4医保费用明细上传冲销(N20.17.04.04)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailRefund(String outpatientId,String remark) throws Exception{
        String funid = "N20.17.04.04";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());//医保明细流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("invalidation_reason",remark);//作废原因
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        String result = requestYlz(data,funid,"医保费用明细上传冲销");
        if (result==null){
            throw new Exception("医保费用明细上传冲销失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            logger.info("医保费用明细上传冲销保存成功");
        }
        return result;
    }
    /**
     * 2.5.4医保费用明细上传冲销(N20.17.04.04)
     *
     * 返回值
     *
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public String feeDetailRefundToEntrance(String outpatientId,String remark) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailRefund?outpatientId="+outpatientId+"&remark="+remark;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.5医保预结算服务(N20.17.04.05)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public YlzMedicalRelationDO preSettlement(String outpatientId) throws Exception{
        String funid = "N20.17.04.05";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("settlement_sign",0);//结算标识
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("trt_fee_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("dept_code",ylzMedicalRelationDO.getDeptCode());//科室编码
        data.put("disease_code",ylzMedicalRelationDO.getDiseaseCode());//病种编码
        data.put("charge_qty",1);//本次收费次数
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        object.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());
        array.add(object);
        data.put("cflist",array);
        String result = requestYlz(data,funid,"医保预结算服务");
        if (result==null){
            throw new Exception("医保预结算服务失败!");
        }else {
            JSONObject resObj = JSONObject.parseObject(result);
            if (resObj.getString("flag").equalsIgnoreCase("1")){
                JSONObject jsonObject = resObj.getJSONObject("encrypt_data");
                ylzMedicalRelationDO.setAccountBalance(jsonObject.getString("account_balance"));
                ylzMedicalRelationDO.setBillSerial(jsonObject.getString("bill_serial"));
                ylzMedicalRelationDO.setPersonalCode(jsonObject.getString("personal_code"));
                ylzMedicalRelationDO.setSex(jsonObject.getString("sex"));
                ylzMedicalRelationDO.setSexMc(jsonObject.getString("sex_mc"));
                ylzMedicalRelationDO.setPersonCash(jsonObject.getString("person_cash"));
                ylzMedicalRelationDO.setPersonAccount(jsonObject.getString("person_account"));
                ylzMedicalRelationDO.setFundPrice(jsonObject.getString("fund_price"));
                ylzMedicalRelationDO.setJkzhPay(jsonObject.getString("own_jkzh_pay"));
                ylzMedicalRelationDO.setOwnPay(jsonObject.getString("own_pay"));
                ylzMedicalRelationDO.setHospitalizationQty(jsonObject.getString("hospitalization_times"));
                ylzMedicalRelationDO.setPayDate(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time")));
                ylzMedicalRelationDO.setInvoiceJj(jsonObject.getString("invoice_jj"));
                ylzMedicalRelationDO.setInvoiceXj(jsonObject.getString("invoice_xj"));
                ylzMedicalRelationDO.setInvoiceZh(jsonObject.getString("invoice_zh"));
                ylzMedicalRelationDO.setDiseaseCode(jsonObject.getString("disease_code"));
                ylzMedicalRelationDO.setTreatmentType(jsonObject.getString("treatment_type"));
                ylzMedicalRelationDO.setTreatmentTypeName(jsonObject.getString("treatment_type_name"));
                ylzMedicalRelationDO.setAllopatryType(jsonObject.getString("allopatry_type"));
                ylzMedicalRelationDO.setAllopatryTypeName(jsonObject.getString("allopatry_type_name"));
                ylzMedicalRelationDO.setAdministrativeArea(jsonObject.getString("administrative_area"));
                ylzMedicalRelationDO.setPayStandard(jsonObject.getString("pay_standard"));
                ylzMedicalRelationDO.setTcjjPay(jsonObject.getString("tcjj_pay"));
                ylzMedicalRelationDO.setSbjjPay(jsonObject.getString("sbjj_pay"));
                ylzMedicalRelationDO.setGwyPay(jsonObject.getString("gwy_pay"));
                ylzMedicalRelationDO.setJzfpPay(jsonObject.getString("jzfp_pay"));
                ylzMedicalRelationDO.setYljzPay(jsonObject.getString("yljz_pay"));
                ylzMedicalRelationDO.setOtherPay(jsonObject.getString("other_pay"));
                ylzMedicalRelationDO.setEnterpriseSupplement(jsonObject.getString("enterprise_supplement"));
                ylzMedicalRelationDO.setJtgjPay(jsonObject.getString("jtgj_pay"));
                ylzMedicalRelationDO.setCollector(jsonObject.getString("collector"));
                ylzMedicalRelationDO.setClrOptins(jsonObject.getString("CLR_OPTINS"));
                ylzMedicalRelationDO.setClrWay(jsonObject.getString("CLR_WAY"));
                ylzMedicalRelationDO.setClrType(jsonObject.getString("CLR_TYPE"));
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getTcjjPay());
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getSbjjPay());
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getGwyPay());
                BigDecimal b4 = new BigDecimal(ylzMedicalRelationDO.getJzfpPay());
                BigDecimal b5 = new BigDecimal(ylzMedicalRelationDO.getYljzPay());
                BigDecimal b6 = new BigDecimal(ylzMedicalRelationDO.getOtherPay());
                BigDecimal b7 = new BigDecimal(ylzMedicalRelationDO.getEnterpriseSupplement());
                Double price = b1.add(b2).add(b3).add(b4).add(b5).add(b6).add(b7).doubleValue();
                /*Double price= Double.parseDouble(ylzMedicalRelationDO.getTcjjPay())+Double.parseDouble(ylzMedicalRelationDO.getSbjjPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getGwyPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getJzfpPay())+Double.parseDouble(ylzMedicalRelationDO.getYljzPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getOtherPay())+Double.parseDouble(ylzMedicalRelationDO.getEnterpriseSupplement());*/
                ylzMedicalRelationDO.setMedicalPrice(price+"");
                logger.info("meidicalPrice====="+price);
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                JSONArray jsonArray = jsonObject.getJSONArray("fplist");
                for (int i=0;i<jsonArray.size();i++){
                    JSONObject jsonObject1 = jsonArray.getJSONObject(i);
                    YlzMedicalBillDO ylzMb = new YlzMedicalBillDO();
                    ylzMb.setMedicalId(ylzMedicalRelationDO.getId());
                    ylzMb.setInvoicePay(jsonObject1.getString("invoice_pay"));
                    ylzMb.setInvoiceType(jsonObject1.getString("invoice_type"));
                    ylzMb.setInvoiceTypeName(jsonObject1.getString("invoice_type_name"));
                    ylzMb.setProjectPay(jsonObject1.getString("project_pay"));
                    ylzMb.setOwnPay(jsonObject1.getString("own_pay"));
                    ylzMb.setSpecialPay(jsonObject1.getString("special_pay"));
                    ylzMb.setUninsurancePay(jsonObject1.getString("uninsurance_pay"));
                    ylzMb.setCreateTime(new Date());
                    ylzMedicailBillDao.save(ylzMb);
                }
            }else {
                throw new Exception(object.getString("cause"));
            }
        }
        List<YlzMedicalIcdDO> icdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
        List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
        ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
        return ylzMedicalRelationDO;
    }
    /**
     * 2.5.5医保预结算服务(N20.17.04.05)
     *
     * 返回值
     *
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public YlzMedicalRelationDO preSettlementToEntrance(String outpatientId) throws Exception{
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
        List<YlzMedicalIcdDO> icdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());;
        if (icdDOList!=null){
            ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
        }
        List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());;
        if (mxDOList!=null){
            ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
        }
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"preSettlement?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
            JSONObject jsonObject1 = JSONObject.parseObject(result);
            if (jsonObject1.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = jsonObject1.getJSONObject("encrypt_data");
                String billSerial = encryptData.getString("bill_serial");
                ylzMedicalRelationDO.setInsuranceSerial(encryptData.getString("insurance_serial"));
                ylzMedicalRelationDO.setBillSerial(encryptData.getString("bill_serial"));
                ylzMedicalRelationDO.setHisBillSerial(encryptData.getString("his_bill_serial"));
                ylzMedicalRelationDO.setSexMc(encryptData.getString("sex_mc"));
                ylzMedicalRelationDO.setPersonCash(encryptData.getString("person_cash"));
                ylzMedicalRelationDO.setPersonAccount(encryptData.getString("person_account"));
                ylzMedicalRelationDO.setFundPrice(encryptData.getString("fund_price"));
                ylzMedicalRelationDO.setJkzhPay(encryptData.getString("jkzh_pay"));
                ylzMedicalRelationDO.setOwnPay(encryptData.getString("own_pay"));
                ylzMedicalRelationDO.setAccountBalance(encryptData.getString("account_balance"));
                ylzMedicalRelationDO.setHospitalizationQty(encryptData.getString("hospitalization_qty"));
                ylzMedicalRelationDO.setPayDate(DateUtil.strToDateLong(encryptData.getString("pay_date")));
                ylzMedicalRelationDO.setInvoiceJj(encryptData.getString("invoice_jj"));
                ylzMedicalRelationDO.setInvoiceXj(encryptData.getString("invoice_xj"));
                ylzMedicalRelationDO.setInvoiceZh(encryptData.getString("invoice_zh"));
                ylzMedicalRelationDO.setCreateTime(new Date());
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                JSONArray jsonArray = encryptData.getJSONArray("fplist");
                for (int i=0;i<jsonArray.size();i++){
                    JSONObject jsonObject = jsonArray.getJSONObject(i);
                    YlzMedicalBillDO ylzMb = new YlzMedicalBillDO();
                    ylzMb.setMedicalId(ylzMedicalRelationDO.getId());
                    ylzMb.setInvoicePay(jsonObject.getString("invoice_pay"));
                    ylzMb.setInvoiceType(jsonObject.getString("invoice_type"));
                    ylzMb.setInvoiceTypeName(jsonObject.getString("invoice_type_name"));
                    ylzMb.setProjectPay(jsonObject.getString("project_pay"));
                    ylzMb.setOwnPay(jsonObject.getString("own_pay"));
                    ylzMb.setSpecialPay(jsonObject.getString("special_pay"));
                    ylzMb.setUninsurancePay(jsonObject.getString("uninsurance_pay"));
                    ylzMb.setCreateTime(new Date());
                    ylzMedicailBillDao.save(ylzMb);
                }
                logger.info("医保预结算服务保存成功");
            }
        }else {
            return null;
        }
        return ylzMedicalRelationDO;
    }
    /**
     * 2.5.6医保结算冲销服务(N20.17.04.06)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String preSettlementRefundToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailRefund?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.6医保结算冲销服务(N20.17.04.06)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String preSettlementRefund(String outpatientId) throws Exception{
        String funid = "N20.17.04.06";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保结算冲销上传:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("bill_serial",ylzMedicalRelationDO.getBillSerial());//医保收费流水号
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisSettleNo());//his收费单据流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("refund_serial",ylzMedicalRelationDO.getHisSerial());//医院退费操作流水号
        String result = requestYlz(data,funid,"医保结算冲销服务");
        if (result==null){
            throw new Exception("医保结算冲销服务失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            logger.info("医保结算冲销服务保存成功");
        }
        return result;
    }
    /**
     * 2.5.7获取医保结算页面地址(N20.17.04.07)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrl(String outpatientId) throws Exception{
        String funid = "N20.17.04.07";
        JSONObject data = new JSONObject();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl");
        if (wlyyHospitalSysDictDO==null){
            throw new Exception("获取医保结算页面地址失败:回调地址为空");
        }
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("person_cash",ylzMedicalRelationDO.getPersonCash());//个人现金支付金额(实付现金)
        data.put("person_account",ylzMedicalRelationDO.getPersonAccount());//个人账户支付金额
        data.put("fund_price",ylzMedicalRelationDO.getMedicalPrice());//基金支付总额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("redirect_url",wlyyHospitalSysDictDO.getDictValue());//回调地址
        data.put("disease_code",ylzMedicalRelationDO.getDiseaseCode());//病种编码
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        object.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());
        array.add(object);
        data.put("cflist",array);
        String result = requestYlz(data,funid,"获取医保结算页面地址");
        if (result==null){
            throw new Exception("获取医保结算页面地址失败!");
        }else {
            JSONObject resObj = JSONObject.parseObject(result);
            if (resObj.getString("flag").equalsIgnoreCase("1")){
                JSONObject jsonObject = resObj.getJSONObject("encrypt_data");
                String link_url = jsonObject.getString("link_url");
                String str1=link_url.substring(0, link_url.indexOf("="));
                String str2=link_url.substring(str1.length()+1, link_url.length());
                ylzMedicalRelationDO.setPageCode(str2);
                ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            }
        }
        return result;
    }
    /**
     * 2.5.7获取医保结算页面地址(N20.17.04.07)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"getSettlementResultUrl?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.8获取医保结算页面地址(N20.17.04.08)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlBase64(String outpatientId) throws Exception{
        String funid = "N20.17.04.08";
        JSONObject data = new JSONObject();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl");
        if (wlyyHospitalSysDictDO==null){
            throw new Exception("获取医保结算页面地址失败:回调地址为空");
        }
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("person_cash",ylzMedicalRelationDO.getPersonCash());//个人现金支付金额(实付现金)
        data.put("person_account",ylzMedicalRelationDO.getPersonAccount());//个人账户支付金额
        data.put("fund_price",ylzMedicalRelationDO.getMedicalPrice());//基金支付总额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("redirect_url",wlyyHospitalSysDictDO.getDictValue());//回调地址
        String result = requestYlz(data,funid,"获取医保结算页面地址");
        if (result==null){
            throw new Exception("获取医保结算页面地址失败!");
        }
        return result;
    }
    /**
     * 2.5.8获取医保结算页面地址(N20.17.04.08)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlBase64ToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"getSettlementResultUrlBase64?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.8获取医保结算结果(N20.17.04.08)
     *
     * 返回值
     *
     * @param code
     * @return
     * @throws Exception
     */
    public String getSettlementResult(String code) throws Exception{
        String funid = "N20.17.04.08";
        JSONObject data = new JSONObject();
        data.put("code",code);//
        String result = requestYlz(data,funid,"获取医保结算结果");
        if (result==null){
            throw new Exception("获取医保结算结果失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject jsonObject = object.getJSONObject("encrypt_data");
            String insuranceSerial = jsonObject.getString("insurance_serial");
            String billSerial = jsonObject.getString("bill_serial");
            String personCash = jsonObject.getString("person_cash");
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByInsuranceSerial(insuranceSerial);
            JSONObject outybsfJson = new JSONObject();
            JSONObject ybdata = new JSONObject();
            ybdata.put("respond_time",jsonObject.getString("date"));
            ybdata.put("inf_refmsgid",jsonObject.getString("personal_code"));
            ybdata.put("appname","hlwyy");
            ybdata.put("infcode",0);
            ybdata.put("refmsg_time",jsonObject.getString("date"));
            JSONObject output = new JSONObject();
            JSONArray setldetailArray = new JSONArray();
            JSONObject setldetailObj =new JSONObject();
            setldetailObj.put("fund_pay_type_name",jsonObject.getString("treatment_type_name"));
            setldetailObj.put("fund_payamt",jsonObject.getString("account_balance"));
            setldetailObj.put("fund_pay_type",jsonObject.getString("treatment_type"));
            setldetailObj.put("inscp_scp_amt",jsonObject.getString("pay_standard"));
            setldetailArray.add(setldetailObj);
            output.put("setldetail",setldetailArray);
            JSONObject setlinfoObj = new JSONObject();
            setlinfoObj.put("hifp_pay",jsonObject.getString("tcjj_pay"));
            setlinfoObj.put("clr_way",jsonObject.getString("clr_way"));
            setlinfoObj.put("mdtrt_id",jsonObject.getString("insurance_serial"));
            setlinfoObj.put("maf_pay",jsonObject.getString("yljz_pay"));
            setlinfoObj.put("fulamt_ownpay_amt",jsonObject.getString("person_cash"));
            setlinfoObj.put("acct_pay",jsonObject.getString("person_account"));
            setlinfoObj.put("clr_type",jsonObject.getString("clr_type"));
            setlinfoObj.put("fund_pay_sumamt",jsonObject.getString("fund_amount"));
            setlinfoObj.put("certno",jsonObject.getString("idcard"));
            setlinfoObj.put("setl_time",DateUtil.dateToStrLong(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time"))));
            setlinfoObj.put("clr_optins",jsonObject.getString("clr_optins"));
            setlinfoObj.put("setl_id",jsonObject.getString("bill_serial"));
            setlinfoObj.put("acct_mulaid_pay",jsonObject.getString("jtgj_pay"));
            setlinfoObj.put("psn_type",jsonObject.getString("treatment_type"));
            setlinfoObj.put("hifdm_pay",0);
            setlinfoObj.put("hifmi_pay",0);
            setlinfoObj.put("psn_cert_type",jsonObject.getString("cert_type"));
            setlinfoObj.put("oth_pay",jsonObject.getString("other_pay"));
            setlinfoObj.put("cvlserv_flag","");
            setlinfoObj.put("age","");
            setlinfoObj.put("psn_part_amt",jsonObject.getString("person_cash"));
            setlinfoObj.put("psn_name",jsonObject.getString("sex_mc"));
            setlinfoObj.put("med_type",ylzMedicalRelationDO.getMedicalType());
            setlinfoObj.put("medins_setl_id",billSerial);
            setlinfoObj.put("act_pay_dedc",jsonObject.getString("pay_standard"));
            setlinfoObj.put("gend",jsonObject.getString("sex_mc"));
            setlinfoObj.put("cvlserv_pay",jsonObject.getString("gwy_pay"));
            setlinfoObj.put("hifes_pay",jsonObject.getString("enterprise_supplement"));
            setlinfoObj.put("balc",jsonObject.getString("account_balance"));
            setlinfoObj.put("mdtrt_cert_type",jsonObject.getString("medical_mode"));
            setlinfoObj.put("preselfpay_amt",0);
            setlinfoObj.put("psn_no",jsonObject.getString("personal_code"));
            setlinfoObj.put("psn_cash_pay",jsonObject.getString("person_cash"));
            setlinfoObj.put("insutype",ylzMedicalRelationDO.getInsuranceType());
            setlinfoObj.put("medfee_sumamt",ylzMedicalRelationDO.getTotalAmount());
            JSONObject expContent = new JSONObject();
            JSONArray fplistArray = jsonObject.getJSONArray("fplist");
            JSONArray fpArray = new JSONArray();
            for (int i=0;i<fplistArray.size();i++){
                JSONObject fplist = fplistArray.getJSONObject(i);
                JSONObject fplistObJ = new JSONObject();
                fplistObJ.put("itemSumamt",Double.parseDouble(fplist.getString("project_pay")));
                fplistObJ.put("itemClaaAmt",Double.parseDouble(fplist.getString("invoice_pay")));
                fplistObJ.put("itemClabAmt",Double.parseDouble(fplist.getString("special_pay")));
                fplistObJ.put("itemOthAmt",Double.parseDouble(fplist.getString("uninsurance_pay")));
                fplistObJ.put("itemOwnpayAmt",Double.parseDouble(fplist.getString("own_pay")));
                fplistObJ.put("medChrgitmName",fplist.getString("type_name"));
                fplistObJ.put("medChrgitmType",fplist.getString("type"));
                fpArray.add(fplistObJ);
            }
            expContent.put("fplist",fpArray);
            setlinfoObj.put("exp_content",expContent.toJSONString());
            output.put("setlinfo",setlinfoObj);
            ybdata.put("output",output);
            outybsfJson.put("data",ybdata);
            ylzMedicalRelationDO.setClrType(jsonObject.getString("clr_type"));
            ylzMedicalRelationDO.setClrWay(jsonObject.getString("clr_way"));
            ylzMedicalRelationDO.setClrOptins(jsonObject.getString("clr_optins"));
            ylzMedicalRelationDO.setOutJson(outybsfJson.toJSONString());
            if (ylzMedicalRelationDO!=null){
                if (!ylzMedicalRelationDO.getPersonCash().equalsIgnoreCase(personCash)){
                    throw new Exception("医保结算金额不一致!");
                }else {
                    ylzMedicalRelationDO.setStatus(1);
                    ylzMedicalRelationDO.setBillSerial(billSerial);
                    ylzMedicalRelationDO.setPayDate(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time")));
                    ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                }
            }
        }
        return result;
    }
    /**
     * 2.5.8获取医保结算结果(N20.17.04.08)
     *
     * 返回值
     *
     * @param code
     * @return
     * @throws Exception
     */
    public String getSettlementResultToEntrance(String code) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"getSettlementResultUrl?code="+code;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.7.1上传用户病史病情及医学报告(N20.17.06.01)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String uploadMedicalHistory(String outpatientId) throws Exception{
        String funid = "N20.17.06.01";
        JSONObject data = new JSONObject();
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
        if (wlyyOutpatientDO==null){
            throw new Exception("医保上传户病史病情及医学报告失败!门诊为空");
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(wlyyOutpatientDO.getRegisterNo());
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        data.put("region_code","350200");//参保地区划代码
        data.put("idcard",wlyyOutpatientDO.getId());//身份证号
        data.put("name",wlyyOutpatientDO.getPatientName());//姓名
        data.put("cert_type","01");//证件类型
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("blood_type",wlyyOutpatientDO.getBloodType());//血型
        data.put("allergy",wlyyOutpatientDO.getAllergy());//过敏史
        data.put("diagnosis",wlyyOutpatientDO.getIcd10Name());//病理诊断
        data.put("describe",wlyyOutpatientDO.getDescription());//病情描述
        data.put("difficult_cases","无");//疑难病例
        data.put("file_list_count",0);//医学报告附件数量
        data.put("data_source","53");//数据来源
        String result = requestYlz(data,funid,"上传用户病史病情及医学报告");
        if (result==null){
            throw new Exception("上传用户病史病情及医学报告失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            wlyyOutpatientDO.setInsuranceMedHistserial(encryptData.getString("insurance_med_hist_serial"));
            logger.info("上传用户病史病情及医学报告保存成功");
        }
        return result;
    }
    /**
     * 2.7.1上传用户病史病情及医学报告(N20.17.06.01)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String uploadMedicalHistoryToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"uploadMedicalHistory?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.7.2作废用户病史病情及医学报告(N20.17.06.06)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String refundMedicalHistory(String outpatientId,String remark) throws Exception{
        String funid = "N20.17.06.06";
        JSONObject data = new JSONObject();
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
        if (wlyyOutpatientDO==null){
            throw new Exception("医保上传户病史病情及医学报告失败!门诊为空");
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(wlyyOutpatientDO.getRegisterNo());
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("insurance_med_hist_serial",wlyyOutpatientDO.getInsuranceMedHistserial());//医保病史上传流水号
        data.put("invalid_reason",remark);//作废原因
        data.put("data_source","53");//数据来源
        String result = requestYlz(data,funid,"作废用户病史病情及医学报告");
        if (result==null){
            throw new Exception("作废用户病史病情及医学报告失败!");
        }
        return result;
    }
    /**
     * 2.7.2作废用户病史病情及医学报告(N20.17.06.06)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String refundMedicalHistoryToEntrance(String outpatientId,String remark) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"refundMedicalHistory?outpatientId="+outpatientId+"&remark="+remark;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.7.3获取问诊过程数据(N20.17.06.02)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String uploadIcdProcess(String outpatientId) throws Exception{
        String funid = "N20.17.06.02";
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
        if (wlyyOutpatientDO==null){
            throw new Exception("获取问诊过程数据失败!门诊为空");
        }
        BaseDoctorDO doctorDO = doctorDao.findById(wlyyOutpatientDO.getDoctor());
        if (doctorDO==null){
            throw new Exception("获取问诊过程数据失败!医生信息为空");
        }
        JSONObject data = new JSONObject();
        data.put("region_code","350200");//参保地区划代码
        data.put("idcard",wlyyOutpatientDO.getIdcard());//身份证号
        data.put("name",wlyyOutpatientDO.getPatientName());//姓名
        data.put("cert_type","01");//证件类型
        data.put("service_serial_id",wlyyOutpatientDO.getRegisterNo());//问诊流水号
        data.put("doctor_id_card",doctorDO.getIdcard());//医师身份证
        data.put("doctor_name",wlyyOutpatientDO.getDoctorName());//医师姓名
        /*data.put("file_list_count","");//附件总数
        data.put("filelist","");//附件列表
        data.put("file_bytes","");//二进制字节流
        data.put("file_name","");//文件名
        data.put("order_num",0);//顺序号*/
        String result = requestYlz(data,funid,"获取问诊过程数据");
        if (result==null){
            throw new Exception("获取问诊过程数据失败!");
        }
        return result;
    }
    /**
     * 2.7.3获取问诊过程数据(N20.17.06.02)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String uploadIcdProcessToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"uploadIcdProcess?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    public Boolean isHospitalFlag(){
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("medicalFlag");
        if (hospitalSysDictDO!=null){
            if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                return true;
            }else {
                return false;
            }
        }else {
            return false;
        }
    }
}

+ 94 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/Pkcs7Encoder.java

@ -0,0 +1,94 @@
package com.yihu.jw.healthCare.utils;//
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.util.Arrays;
import sun.misc.BASE64Encoder;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
public class Pkcs7Encoder {
    static final String KEY_ALGORITHM = "AES";
    static final String algorithmStr = "AES/CBC/PKCS7Padding";
    private static Key key;
    static byte[] iv = new byte[]{48, 49, 48, 50, 48, 51, 48, 52, 48, 53, 48, 54, 48, 55, 48, 56};
    public Pkcs7Encoder() {
    }
    private static Cipher init(byte[] keyBytes) {
        Cipher cipher = null;
        int base = 16;
        if (keyBytes.length % base != 0) {
            int groups = keyBytes.length / base + (keyBytes.length % base != 0 ? 1 : 0);
            byte[] temp = new byte[groups * base];
            Arrays.fill(temp, (byte)0);
            System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
            keyBytes = temp;
        }
        Security.addProvider(new BouncyCastleProvider());
        key = new SecretKeySpec(keyBytes, "AES");
        try {
            cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
        } catch (NoSuchAlgorithmException var5) {
            var5.printStackTrace();
        } catch (NoSuchPaddingException var6) {
            var6.printStackTrace();
        } catch (NoSuchProviderException var7) {
            var7.printStackTrace();
        }
        return cipher;
    }
    public static byte[] encrypt(byte[] content, byte[] keyBytes) {
        byte[] encryptedText = encryptOfDiyIV(content, keyBytes, iv);
        return encryptedText;
    }
    public static byte[] decrypt(byte[] encryptedData, byte[] keyBytes) {
        byte[] encryptedText = decryptOfDiyIV(encryptedData, keyBytes, iv);
        return encryptedText;
    }
    public static byte[] encryptOfDiyIV(byte[] content, byte[] keyBytes, byte[] ivs) {
        byte[] encryptedText = null;
        Cipher cipher = init(keyBytes);
        System.out.println("IV:" + new String(ivs));
        try {
            cipher.init(1, key, new IvParameterSpec(ivs));
            encryptedText = cipher.doFinal(content);
        } catch (Exception var6) {
            var6.printStackTrace();
        }
        return encryptedText;
    }
    public static byte[] decryptOfDiyIV(byte[] encryptedData, byte[] keyBytes, byte[] ivs) {
        byte[] encryptedText = null;
        Cipher cipher = init(keyBytes);
        System.out.println("IV:" + new String(ivs));
        try {
            cipher.init(2, key, new IvParameterSpec(ivs));
            encryptedText = cipher.doFinal(encryptedData);
        } catch (Exception var6) {
            var6.printStackTrace();
        }
        return encryptedText;
    }
    public static String base64Encode(byte[] bytes) {
        return (new BASE64Encoder()).encode(bytes);
    }
}

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4Context.java

@ -0,0 +1,14 @@
package com.yihu.jw.healthCare.utils;//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
public class SM4Context {
    public int mode = 1;
    public long[] sk = new long[32];
    public boolean isPadding = true;
    public SM4Context() {
    }
}

File diff suppressed because it is too large
+ 354 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4New.java


+ 162 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4Util.java

@ -0,0 +1,162 @@
package com.yihu.jw.healthCare.utils;//
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SM4Util {
    public static final String BM = "UTF-8";
    private String secretKey = "";
    private String iv = "1234567890ABCDEF";
    private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
    public SM4Util() {
    }
    public SM4Util(String secretKey) {
        this.secretKey = secretKey;
    }
    public SM4Util(String secretKey, String iv) {
        this.secretKey = secretKey;
        this.iv = iv;
    }
    public String encryptDataECB(String plainText) throws Exception {
        return this.encryptDataECB(plainText.getBytes("UTF-8"));
    }
    public String encryptDataECB(byte[] content) throws Exception {
        SM4Context ctx = new SM4Context();
        ctx.isPadding = true;
        ctx.mode = 1;
        SM4New sm4 = new SM4New();
        byte[] keyBytes = getKey(this.secretKey);
        sm4.sm4_setkey_enc(ctx, keyBytes);
        byte[] encrypted = sm4.sm4_crypt_ecb(ctx, content);
        String cipherText = byteArrToHex(encrypted);
        if (cipherText != null && cipherText.trim().length() > 0) {
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(cipherText);
            cipherText = m.replaceAll("");
        }
        return cipherText.toUpperCase();
    }
    public String decryptDataECB(String encData) throws Exception {
        return new String(this.decryptDataECB(hexToByte(encData)));
    }
    public byte[] decryptDataECB(byte[] content) throws Exception {
        SM4Context ctx = new SM4Context();
        ctx.isPadding = true;
        ctx.mode = 0;
        SM4New sm4 = new SM4New();
        byte[] keyBytes = getKey(this.secretKey);
        sm4.sm4_setkey_dec(ctx, keyBytes);
        byte[] decrypted = sm4.sm4_crypt_ecb(ctx, content);
        return decrypted;
    }
    private static byte[] getKey(String strKey) throws Exception {
        byte[] arrBTmp = strKey.getBytes("UTF-8");
        byte[] arrB = new byte[16];
        for(int i = 0; i < arrBTmp.length && i < arrB.length; ++i) {
            arrB[i] = arrBTmp[i];
        }
        return arrB;
    }
    public String encryptDataCBC(String content) throws Exception {
        String encData = this.encryptDataCBC(content.getBytes("UTF-8"));
        return encData;
    }
    public String encryptDataCBC(byte[] content) throws Exception {
        SM4Context ctx = new SM4Context();
        ctx.isPadding = true;
        ctx.mode = 1;
        byte[] ivBytes = this.iv.getBytes("UTF-8");
        byte[] keyBytes = getKey(this.secretKey);
        SM4New sm4 = new SM4New();
        sm4.sm4_setkey_enc(ctx, keyBytes);
        byte[] encrypted = sm4.sm4_crypt_cbc(ctx, ivBytes, content);
        String cipherText = byteArrToHex(encrypted);
        if (cipherText != null && cipherText.trim().length() > 0) {
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(cipherText);
            cipherText = m.replaceAll("");
        }
        return cipherText.toUpperCase();
    }
    public String decryptDataCBC(String content) throws Exception {
        String data = this.decryptDataCBC(hexToByte(content));
        return data;
    }
    public String decryptDataCBC(byte[] content) throws Exception {
        SM4Context ctx = new SM4Context();
        ctx.isPadding = true;
        ctx.mode = 0;
        byte[] ivBytes = this.iv.getBytes("UTF-8");
        byte[] keyBytes = getKey(this.secretKey);
        SM4New sm4 = new SM4New();
        sm4.sm4_setkey_dec(ctx, keyBytes);
        byte[] decrypted = sm4.sm4_crypt_cbc(ctx, ivBytes, content);
        return new String(decrypted, "UTF-8");
    }
    public static String byteToHex(byte[] b) {
        if (b == null) {
            throw new IllegalArgumentException("Argument b ( byte array ) is null! ");
        } else {
            String hs = "";
            String stmp = "";
            for(int n = 0; n < b.length; ++n) {
                stmp = Integer.toHexString(b[n] & 255);
                if (stmp.length() == 1) {
                    hs = hs + "0" + stmp;
                } else {
                    hs = hs + stmp;
                }
            }
            return hs.toUpperCase();
        }
    }
    public static byte[] hexToByte(String hex) throws IllegalArgumentException {
        if (hex.length() % 2 != 0) {
            throw new IllegalArgumentException();
        } else {
            char[] arr = hex.toCharArray();
            byte[] b = new byte[hex.length() / 2];
            int i = 0;
            int j = 0;
            for(int l = hex.length(); i < l; ++j) {
                String swap = "" + arr[i++] + arr[i];
                int byteint = Integer.parseInt(swap, 16) & 255;
                b[j] = (new Integer(byteint)).byteValue();
                ++i;
            }
            return b;
        }
    }
    public static String byteArrToHex(byte... bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = hexArray[v >>> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }
}

+ 292 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/YibaoJiaMi.java

@ -0,0 +1,292 @@
package com.yihu.jw.healthCare.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
/**
 * Created by Bing on 2022/12/16.
 */
public class YibaoJiaMi {
    public static String signType = "MD5";//MD5,SM3
    public static String encryptType = "PKCS7";//AES,SM4ECB,PKCS7
    public static String encryptDataSign(JSONObject plainJson,String signKey,String encryptKey){
        plainJson.put("chs_fjs_encrypt_type", encryptType);
        plainJson.put("chs_fjs_sign_type", signType);
        //签名
        {
            plainJson.remove("chs_fjs_sign");
            String signTemp = getSortSignTemp(plainJson, signKey);
            String sign = sign(signTemp, signType);
            plainJson.put("chs_fjs_sign", sign);
        }
        //加密
        {
            String context = plainJson.toJSONString();
            if (isNotBlank(context)) {
                String encryptData = encrypt(context, encryptKey, encryptType);
                plainJson.remove("data");
                plainJson.put("chs_fjs_encdata", encryptData);
            }
        }
        System.out.println("最终请求报文:" + plainJson.toJSONString());
        return plainJson.toJSONString();
    }
    public static String encryptData(JSONObject plainJson,String signKey,String encryptKey){
        plainJson.put("encrypt_type", encryptType);
        plainJson.put("sign_type", signType);
        //签名
        {
            plainJson.remove("sign");
            String signTemp = getSortSignTemp(plainJson, signKey);
            String sign = sign(signTemp, signType);
            plainJson.put("sign", sign);
        }
        //加密
        {
            String context = plainJson.getString("data");
            if (isNotBlank(context)) {
                String encryptData = encrypt(context, encryptKey, encryptType);
                plainJson.remove("data");
                plainJson.put("encrypt_data", encryptData);
            }
        }
        System.out.println("最终请求报文:" + plainJson.toJSONString());
        return plainJson.toJSONString();
    }
    public static void main(String[] args) {
        String ylzConfigAppid = "cloudxmjw";
        String ylzConfigAppSecret = "f0ce9e957371bef58735de4abe1fa274";
        String ylzConfigSignKey = "2156B331D45F53B02BFF05C3942E60D8";
        String ylzConfigEncryptKey = "3716B331D45F53B02BFF05C3942E60D8";
        JSONObject object = new JSONObject();
        JSONObject data = new JSONObject();
        String funid = "N00.00.00.01";
        data.put("appid", ylzConfigAppid);
        data.put("appsecret", ylzConfigAppSecret);
        data.put("grant_type","client_credentials");
        object.put("sign_type","md5");
        object.put("chs_fjs_appid", ylzConfigAppid);
        object.put("data",data);
        object.put("chs_fjs_funid",funid);
        String ss = encryptData(object,ylzConfigSignKey,ylzConfigEncryptKey);
        System.out.println(ss);
        System.out.println();
    }
    /**
     * 获取待签名字符串
     *
     * @param json
     * @return
     */
    public static String getSortSignTemp(JSONObject json, String key) {
        System.out.println("需要签名的报文:" + json.toJSONString());
        String signTemp = "";
        String jsonStr = JSONObject.toJSONString(json, SerializerFeature.MapSortField);
        LinkedHashMap m = JSON.parseObject(jsonStr, LinkedHashMap.class);
        Iterator<Map.Entry> iterator = m.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = iterator.next();
            String strVal = "";
            if (entry.getValue() instanceof Map) {
                strVal = JSONObject.toJSONString(entry.getValue(), SerializerFeature.MapSortField);
            } else {
                if (null == entry.getValue()) {
                    strVal = "";
                } else {
                    strVal = String.valueOf(entry.getValue());
                }
            }
            signTemp += entry.getKey() + "=" + strVal + "&";
        }
        signTemp=signTemp.substring(0,signTemp.length()-1);
        signTemp = signTemp + "&key=" + key;
        System.out.println("待签名字符串:" + signTemp);
        return signTemp;
    }
    public static String sign(String signTemp, String signType) {
        switch (signType) {
            case "MD5":
                return signByMd5(signTemp);
            default:
                return null;
        }
    }
    public static String signByMd5(String signTemp) {
        System.out.println("签名类型:MD5");
        String sign = md5(signTemp, "utf-8").toUpperCase();//计算signStr的MD5值,并对结果转为大写
        System.out.println("签名结果:" + sign);
        return sign;
    }
    /**
     * MD5
     *
     * @param str
     * @param charset
     * @return
     */
    public static String md5(String str, String charset) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes(charset));
            byte[] b = md.digest();
            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; ++offset) {
                int i = b[offset];
                if (i < 0) {
                    i += 256;
                }
                if (i < 16) {
                    buf.append("0");
                }
                buf.append(Integer.toHexString(i));
            }
            str = buf.toString();
        } catch (Exception var7) {
            var7.printStackTrace();
        }
        return str;
    }
    public static String encrypt(String context, String key, String encryptType) {
        try {
            switch (encryptType) {
                case "PKCS7":
                    return encryptByPKCS7(context, key);
                case "SM4ECB":
                    return encryptBySM4ECB(context, key);
                case "AES":
                    return AES.aesEncrypt(context, key);
                default:
                    return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public static String encryptByPKCS7(String context, String key) {
        System.out.println("加密模式:PKCS7");
        System.out.println("加密前:" + context);
        String encode = null;
        try {
            BASE64Encoder base64Encoder=new BASE64Encoder();
            encode=base64Encoder.encode(Pkcs7Encoder.encrypt(context.getBytes("UTF-8"), key.getBytes()));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        System.out.println("加密结果:" + encode);
        return encode;
    }
    /**
     * SM4ECB加密
     *
     * @param context
     * @param key
     * @return
     */
    public static String encryptBySM4ECB(String context, String key) {
        SM4Util sm4 = new SM4Util(key, "");
        System.out.println("加密模式:SM4ECB");
        System.out.println("加密前:" + context);
        String cipherText = null;
        try {
            cipherText = sm4.encryptDataECB(context);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("加密结果:" + cipherText);
        return cipherText;
    }
    public static String decrypt(String encryptData, String key) {
        try {
            switch (encryptType) {
                case "PKCS7":
                    return decryptByPKCS7(encryptData, key);
                case "SM4ECB":
                    return decryptBySM4ECB(encryptData, key);
                case "AES":
                    return  AES.aesDecrypt(encryptData, key);
                default:
                    return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public static String decryptBySM4ECB(String encryptData, String key) {
        SM4Util sm4 = new SM4Util(key, "");
        System.out.println("解密模式:SM4ECB");
        System.out.println("解密前:" + encryptData);
        String cipherText = null;
        try {
            cipherText = sm4.decryptDataECB(encryptData);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("解密结果:" + cipherText);
        return cipherText;
    }
    public static String decryptByPKCS7(String context, String key) {
        try {
            BASE64Decoder base64Decoder=new BASE64Decoder();
            String aes7Str = new String(Pkcs7Encoder.decrypt(base64Decoder.decodeBuffer(context), key.getBytes()), "UTF-8");
            return aes7Str;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static boolean isNotBlank(String str) {
        return !isBlank(str);
    }
    public static boolean isBlank(String str) {
        int strLen;
        if (str != null && (strLen = str.length()) != 0) {
            for(int i = 0; i < strLen; ++i) {
                if (!Character.isWhitespace(str.charAt(i))) {
                    return false;
                }
            }
            return true;
        } else {
            return true;
        }
    }
}

+ 235 - 81
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/HcyyPrescriptionService.java

@ -529,6 +529,11 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        if (StringUtils.isNoneBlank(realOrder)){
            params +="&realOrder="+realOrder;
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patNo);
        if (patientMappingDO==null){
            throw new Exception("his用户编码为空!");
        }
        patNo = patientMappingDO.getMappingCode();
        logger.info("处方request:"+registerSn+"=="+patNo+"==="+admNo+"===="+realOrder);
        String obj = hcyyEntranceService.getOriginPrescriptionList(registerSn,patNo,admNo,realOrder,null,null);
        if (StringUtils.isNoneBlank(obj)){
@ -1086,7 +1091,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    /**
     * 挂号接口
     * @param outPatientId
     * @param doctor
     * @param doctor flag 0自费1医保
     * @return
     */
    public JSONObject registerOutPatient(String outPatientId, String doctor){
@ -1151,7 +1156,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        }
        JSONObject res = null;
        try {
            String obj = hcyyEntranceService.registered(doctorFlag,outpatientDO.getDept(),patientMappingDO.getMappingCode(),chargeType,courierflag);
            String obj = hcyyEntranceService.registered(doctorFlag,outpatientDO.getDept(),patientMappingDO.getMappingCode(),chargeType,courierflag,outpatientDO.getMedicalState());
            if (StringUtils.isNoneBlank(obj)){
                res = JSONObject.parseObject(obj);
            }
@ -1611,6 +1616,12 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    public YlzMedicalRelationDO getSettlementInfo(String cardno,String outpatientId) throws Exception {
        YlzMedicalRelationDO ylzMedicalRelationDO =new YlzMedicalRelationDO();
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        //查询余额
        String balance = "";
        JSONObject jsonObject = selectCardInfo(cardno);
        if (jsonObject!=null){
            balance = jsonObject.getString("ZHYE");
        }
        String resNo = outpatientDO.getRegisterNo();
        //请求his获取待结算存储
        Map<String,Object> params = new HashedMap();
@ -1637,6 +1648,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                        if (ylzMedicalRelationDO==null){
                            ylzMedicalRelationDO = new YlzMedicalRelationDO();
                            ylzMedicalRelationDO.setLogNo(logNo);
                            ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                            ylzMedicalRelationDO.setRelationCode(outpatientId);
                            ylzMedicalRelationDO.setName(object.getString("PSN_NAME"));
                            ylzMedicalRelationDO.setTotalAmount(object.getString("COST"));
@ -1649,15 +1661,30 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                            ylzMedicalRelationDO.setHisDeptName(object.getString("DEPT_NAME"));
                            ylzMedicalRelationDO.setStatus(0);
                            ylzMedicalRelationDO.setState(0);
                            ylzMedicalRelationDO.setDel(1);
                            ylzMedicalRelationDO.setDataSource("54");
                            ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                            ylzMedicalRelationDO.setBalance(balance);
                            ylzMedicalRelationDO.setPersonAccount("0");
                            ylzMedicalRelationDO.setMedicalPrice("0");
                            ylzMedicalRelationDO.setCertType("01");
                            ylzMedicalRelationDO.setMedicalMode("10");
                            ylzMedicalRelationDO.setRegionCode("350200");
                            if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                ylzMedicalRelationDO.setMedicalType("13");
                            }else {
                                ylzMedicalRelationDO.setMedicalType("11");
                            }
                            ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO"));
                            ylzMedicalRelationDO.setCardNo(object.getString("CARD_NO"));
                            ylzMedicalRelationDO.setDate(DateUtil.strToDate(object.getString("BEGNTIME")));
                            ylzMedicalRelationDO.setBcwkje(object.getString("MEDFEE_SUMAMT"));
                            ylzMedicalRelationDO.setBcwkje(object.getString("YKFJE0"));
                        }else {
                            ylzMedicalRelationDO.setLogNo(logNo);
                            ylzMedicalRelationDO.setRelationCode(outpatientId);
                            ylzMedicalRelationDO.setDataSource("54");
                            ylzMedicalRelationDO.setDel(1);
                            ylzMedicalRelationDO.setMedicalState(Integer.parseInt(outpatientDO.getMedicalState()));
                            ylzMedicalRelationDO.setName(object.getString("PSN_NAME"));
                            ylzMedicalRelationDO.setTotalAmount(object.getString("COST"));
                            ylzMedicalRelationDO.setPersonCash(object.getString("ORIGIN_CHARGES"));
@ -1669,10 +1696,20 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                            ylzMedicalRelationDO.setHisDeptName(object.getString("DEPT_NAME"));
                            ylzMedicalRelationDO.setPersonAccount("0");
                            ylzMedicalRelationDO.setMedicalPrice("0");
                            ylzMedicalRelationDO.setBalance(balance);
                            ylzMedicalRelationDO.setCertType("01");
                            ylzMedicalRelationDO.setMedicalMode("10");
                            ylzMedicalRelationDO.setRegionCode("350200");
                            if (StringUtils.isNoneBlank(outpatientDO.getDiseaseCode())){
                                ylzMedicalRelationDO.setMedicalType("13");
                            }else {
                                ylzMedicalRelationDO.setMedicalType("11");
                            }
                            ylzMedicalRelationDO.setIdcard(outpatientDO.getIdcard());
                            ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO"));
                            ylzMedicalRelationDO.setCardNo(object.getString("CARD_NO"));
                            ylzMedicalRelationDO.setDate(DateUtil.strToDate(object.getString("BEGNTIME")));
                            ylzMedicalRelationDO.setBcwkje(object.getString("MEDFEE_SUMAMT"));
                            ylzMedicalRelationDO.setBcwkje(object.getString("YKFJE0"));
                        }
                        ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
@ -1680,16 +1717,20 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                        String detailSql =" select * from SST_JSDP_JSMX_GJYB where LOG_NO ='"+logNo+"' ";
                        String detailRes = hcyyEntranceService.getSql(detailSql);
                        List<YlzMedicalMxDO> mxDOList = new ArrayList<>();
                        Integer itemCount = 0;
                        if (StringUtils.isNoneBlank(detailRes)) {
                            JSONObject drs = JSONObject.parseObject(detailRes);
                            Integer dstatus = drs.getInteger("status");
                            if (dstatus != null && dstatus == 200) {
                                JSONArray darray = drs.getJSONArray("detailModelList");
                                itemCount=darray.size();
                                for (int j = 0; j < darray.size(); j++) {
                                    JSONObject dobject = darray.getJSONObject(j);
                                    YlzMedicalMxDO medicalMxDO = new YlzMedicalMxDO();
                                    medicalMxDO.setDel(1);
                                    medicalMxDO.setMedicalId(ylzMedicalRelationDO.getId());
                                    medicalMxDO.setCreateTime(new Date());
                                    medicalMxDO.setInvoiceType("01");
                                    medicalMxDO.setItemName(dobject.getString("XMMC00"));
                                    medicalMxDO.setHisDetailSn(dobject.getString("FEEDETL_SN"));
                                    medicalMxDO.setItemCode(dobject.getString("MED_LIST_CODG"));
@ -1698,6 +1739,13 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                                    medicalMxDO.setSpecificationType(dobject.getString(""));
                                    medicalMxDO.setAmount(dobject.getString("CNT"));
                                    medicalMxDO.setPrice(dobject.getString("PRIC"));
                                    medicalMxDO.setPrescriptionCode(dobject.getString("RXNO"));
                                    medicalMxDO.setSpecificationType(dobject.getString("SPECIFICATION_TYPE"));
                                    medicalMxDO.setDosageForm(dobject.getString("DOSAGE_FORM"));
                                    medicalMxDO.setPrescriptionDate(DateUtil.strToDate(object.getString("BEGNTIME")));
                                    medicalMxDO.setActgDate(DateUtil.strToDate(object.getString("BEGNTIME")));
                                    medicalMxDO.setClerkDays(DateUtil.strToDate(object.getString("BEGNTIME")));
                                    medicalMxDO.setPeopleType(null);
                                    medicalMxDO.setSingleDose(dobject.getString("SIN_DOS_DSCR"));
                                    medicalMxDO.setUseFrequency(dobject.getString("USED_FRQU_DSCR"));
                                    medicalMxDO.setMedicationDays(dobject.getString("PRD_DAYS"));
@ -1708,7 +1756,13 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                                    medicalMxDO.setHisDeptName(dobject.getString("BILG_DEPT_NAME"));
                                    medicalMxDO.setMedicalPerId(dobject.getString("BILG_DR_CODG"));
                                    medicalMxDO.setMedicalPerName(dobject.getString("BILG_DR_NAME"));
                                    medicalMxDO.setLimitType(dobject.getString("HOSP_APPR_FLAG"));
                                    if (StringUtils.isNoneBlank(dobject.getString("HOSP_APPR_FLAG"))){
                                        if (dobject.getString("HOSP_APPR_FLAG").equalsIgnoreCase("0")||dobject.getString("HOSP_APPR_FLAG").equalsIgnoreCase("2")){
                                            medicalMxDO.setLimitType("N");
                                        } else if (dobject.getString("HOSP_APPR_FLAG").equalsIgnoreCase("1")) {
                                            medicalMxDO.setLimitType("Y");
                                        }
                                    }
                                    medicalMxDO.setHisItemCode(dobject.getString("MED_LIST_CODG"));
                                    medicalMxDO.setHisItemName(dobject.getString("XMMC00"));
                                    medicalMxDO.setTotalMoney(dobject.getString("DET_ITEM_FEE_SUMAMT"));
@ -1717,11 +1771,13 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                                }
                            }
                        }
                        ylzMedicalRelationDO.setItemCount(itemCount+"");
                        ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                        List<YlzMedicalIcdDO> icdDOS = new ArrayList<>();
                        ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
                        //获取诊断
                        String icdSql =" select * from SST_JSDP_JSMX_GJYB where LOG_NO ='"+logNo+"' ";
                        String icdSql =" select * from SST_JSDP_DZMX_GJYB where LOG_NO ='"+logNo+"' ";
                        String icdRes = hcyyEntranceService.getSql(icdSql);
                        if (StringUtils.isNoneBlank(icdRes)) {
                            JSONObject drs = JSONObject.parseObject(icdRes);
@ -1760,61 +1816,124 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                throw new Exception("未找到待结算记录");
            }
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
            if (ylzMedicalRelationDO.getState()==1){
            if (ylzMedicalRelationDO.getState()!=null&&ylzMedicalRelationDO.getState()==1){
                return "已结算";
            }
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId());
            ylzMedicalRelationDO.setState(1);
            ylzMedicalRelationDO.setSettleDate(new Date());
            ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            String sql = "update SST_JSDP_JBXX_GJYB\n" +
                    "   set SETL_ID           = '', \n" +
                    "       ACCT_PAY          = '0',\n" +
                    "       PSN_CASH_PAY      = '"+ylzMedicalRelationDO.getTotalAmount()+"',\n" +
                    "       FUND_PAY_SUMAMT   = '0',\n" +
                    "       CVLSERV_PAY       = '0',\n" +
                    "       PSN_PART_AMT      = '0',\n" +
                    "       HIFMI_PAY         = '0',\n" +
                    "       MEDFEE_SUMAMT     = '"+ylzMedicalRelationDO.getBcwkje()+"',\n" +
                    "       SETL_TIME         = '0',\n" +
                    "       BALC              = '0',\n" +
                    "       ACCT_MULAID_PAY   = '0',\n" +
                    "       HIFOB_PAY         = '0',\n" +
                    "       MDTRT_ID          = '',\n" +
                    "       HIFP_PAY          = '0',\n" +
                    "       MAF_PAY           = '',\n" +
                    "       OTH_PAY           = '0',\n" +
                    "       HIFES_PAY         = '0',\n" +
                    "       OUTCHARGENO       = '"+businessOrderDO.getOrderNo()+"',\n" +
                    "       PSN_CERT_TYPE     = '0',\n" +
                    "       NATY              = '0',\n" +
                    "       BRDY              = '0',\n" +
                    "       CVLSERV_FLAG      = '0',\n" +
                    "       ACT_PAY_DEDC      = '0',\n" +
                    "       PSN_TYPE          = '0',\n" +
                    "       HOSP_PART_AMT     = '0',\n" +
                    "       CLR_OPTINS        = '0',\n" +
                    "       CLR_WAY           = '0',\n" +
                    "       CLR_TYPE          = '0',\n" +
                    "       POOL_PROP_SELFPAY = '0',\n" +
                    "       INSUPLC_ADMDVS    = '',\n" +
                    "       INSUTYPE          = '',\n" +
                    "       PSN_NO            = '',\n" +
                    "       CHANNEL_TYPE      = '',\n" +
                    "       ACSIGN_TYPE       = 'null',\n" +
                    "       MDTRT_CERT_TYPE   = '03',\n" +
                    "       CVL_ACCT_PAY      = '0',\n" +
                    "       CVL_ACCT_BALC     = '0',\n" +
                    "       HL_ACCT_PAY       = '0',\n" +
                    "       HL_ACCT_BALC      = '0',\n" +
                    "       FM_ACCT_BALC      = '0',\n" +
                    "       PUR_ACCT_PAY      = '0'\n" +
                    " where 1 = 1\n" +
                    "   and LOG_NO = '"+ylzMedicalRelationDO.getLogNo()+"'";
            //结算更新
            System.out.println("sql=="+sql);
            String res = hcyyEntranceService.updateUrl(sql);
            String depositType = "";
            String depositAmount = "";
            String outChargeNo = "";
            String orderNo="";
            if (businessOrderDO!=null){
                depositType = businessOrderDO.getDepositType();
                depositAmount = businessOrderDO.getPayPrice()+"";
                outChargeNo = businessOrderDO.getTraceNo();
                orderNo = businessOrderDO.getOrderNo();
            }
            if (ylzMedicalRelationDO.getMedicalState()==null||(ylzMedicalRelationDO.getMedicalState()!=null&&ylzMedicalRelationDO.getMedicalState()==0)){
                String sql = "update SST_JSDP_JBXX_GJYB\n" +
                        "   set SETL_ID           = '', \n" +
                        "       ACCT_PAY          = '0',\n" +
                        "       PSN_CASH_PAY      = '"+ylzMedicalRelationDO.getPersonCash()+"',\n" +
                        "       FUND_PAY_SUMAMT   = '0',\n" +
                        "       CVLSERV_PAY       = '0',\n" +
                        "       PSN_PART_AMT      = '0',\n" +
                        "       HIFMI_PAY         = '0',\n" +
                        "       MEDFEE_SUMAMT     = '"+ylzMedicalRelationDO.getBcwkje()+"',\n" +
                        "       SETL_TIME         = '0',\n" +
                        "       BALC              = '0',\n" +
                        "       ACCT_MULAID_PAY   = '0',\n" +
                        "       HIFOB_PAY         = '0',\n" +
                        "       MDTRT_ID          = '',\n" +
                        "       HIFP_PAY          = '0',\n" +
                        "       MAF_PAY           = '',\n" +
                        "       OTH_PAY           = '0',\n" +
                        "       HIFES_PAY         = '0',\n" +
                        "       OUTCHARGENO       = '"+orderNo+"',\n" +
                        "       PSN_CERT_TYPE     = '0',\n" +
                        "       NATY              = '0',\n" +
                        "       BRDY              = '0',\n" +
                        "       CVLSERV_FLAG      = '0',\n" +
                        "       ACT_PAY_DEDC      = '0',\n" +
                        "       PSN_TYPE          = '0',\n" +
                        "       HOSP_PART_AMT     = '0',\n" +
                        "       CLR_OPTINS        = '0',\n" +
                        "       CLR_WAY           = '0',\n" +
                        "       CLR_TYPE          = '0',\n" +
                        "       POOL_PROP_SELFPAY = '0',\n" +
                        "       INSUPLC_ADMDVS    = '',\n" +
                        "       INSUTYPE          = '',\n" +
                        "       PSN_NO            = '',\n" +
                        "       CHANNEL_TYPE      = '',\n" +
                        "       ACSIGN_TYPE       = 'null',\n" +
                        "       MDTRT_CERT_TYPE   = '03',\n" +
                        "       CVL_ACCT_PAY      = '0',\n" +
                        "       CVL_ACCT_BALC     = '0',\n" +
                        "       HL_ACCT_PAY       = '0',\n" +
                        "       HL_ACCT_BALC      = '0',\n" +
                        "       FM_ACCT_BALC      = '0',\n" +
                        "       PUR_ACCT_PAY      = '0'\n" +
                        " where 1 = 1\n" +
                        "   and LOG_NO = '"+ylzMedicalRelationDO.getLogNo()+"'";
                //结算更新
                System.out.println("sql=="+sql);
                String res = hcyyEntranceService.updateUrl(sql);
            }else {
                String sql = "update SST_JSDP_JBXX_GJYB\n" +
                        "   set SETL_ID      = '"+ylzMedicalRelationDO.getBillSerial()+"',\n" +
                        "       PSN_CASH_PAY      = '"+ylzMedicalRelationDO.getPersonCash()+"',\n" +
                        "       MEDFEE_SUMAMT     = '"+ylzMedicalRelationDO.getBcwkje()+"',\n" +
                        "       HIFOB_PAY         = '0',\n" +
                        "       OUTCHARGENO       = '"+orderNo+"',\n" +
                        "       BRDY              = '0',\n" +
                        "       CVLSERV_FLAG      = '0',\n" +
                        "       HOSP_PART_AMT     = '0',\n" +
                        "       POOL_PROP_SELFPAY = '0',\n" +
                        "       INSUPLC_ADMDVS    = '"+ylzMedicalRelationDO.getAdministrativeArea()+"',\n" +
                        "       INSUTYPE          = '',\n" +
                        "       PSN_NO            = '',\n" +
                        "       CHANNEL_TYPE      = '',\n" +
                        "       ACSIGN_TYPE       = 'null',\n" +
                        "       MDTRT_CERT_TYPE   = '03',\n" +
                        "       CVL_ACCT_PAY      = '0',\n" +
                        "       CVL_ACCT_BALC     = '0',\n" +
                        "       HL_ACCT_PAY       = '0',\n" +
                        "       HL_ACCT_BALC      = '0',\n" +
                        "       FM_ACCT_BALC      = '0',\n" +
                        "       PUR_ACCT_PAY      = '0',\n" +
                        "       CHRG_BCHNO      = '"+ylzMedicalRelationDO.getBillSerial()+"',\n" +
                        "       MDTRT_ID      = '"+ylzMedicalRelationDO.getInsuranceSerial()+"',\n" +
                        "       PSN_CERT_TYPE      = '"+ylzMedicalRelationDO.getCertType()+"',\n" +
                        "       NATY      = '"+ylzMedicalRelationDO.getCertType()+"',\n" +
                        "       PSN_TYPE      = '"+ylzMedicalRelationDO.getTreatmentType()+"',\n" +
                        "       RYDYMC      = '"+ylzMedicalRelationDO.getTreatmentTypeName()+"',\n" +
                        "       YBDYZT      = '"+(StringUtils.isNoneBlank(ylzMedicalRelationDO.getTreatmentStatus())?ylzMedicalRelationDO.getTreatmentStatus():0)+"',\n" +
                        "       YBDYMC      = '"+(StringUtils.isNoneBlank(ylzMedicalRelationDO.getTreatmentStatusName())?ylzMedicalRelationDO.getTreatmentStatusName():"")+"',\n" +
                        "       YDJYLX      = '"+ylzMedicalRelationDO.getAllopatryType()+"',\n" +
                        "       YDLXMC      = '"+ylzMedicalRelationDO.getAllopatryTypeName()+"',\n" +
                        "       ACT_PAY_DEDC = '"+ylzMedicalRelationDO.getPayStandard()+"',\n" +
                        "       HIFP_PAY      = '"+ylzMedicalRelationDO.getTcjjPay()+"',\n" +
                        "       CVLSERV_PAY = '"+ylzMedicalRelationDO.getGwyPay()+"',\n" +
                        "       HIFES_PAY      = '"+ylzMedicalRelationDO.getEnterpriseSupplement()+"',\n" +
                        "       HIFMI_PAY      = '"+ylzMedicalRelationDO.getSbjjPay()+"',\n" +
                        "       MAF_PAY      = '"+ylzMedicalRelationDO.getYljzPay()+"',\n" +
                        "       OTH_PAY      = '"+ylzMedicalRelationDO.getOtherPay()+"',\n" +
                        "       PSN_PART_AMT      = '"+ylzMedicalRelationDO.getPersonCash()+"',\n" +
                        "       ACCT_PAY      = '"+ylzMedicalRelationDO.getPersonAccount()+"',\n" +
                        "       BALC      = '"+ylzMedicalRelationDO.getAccountBalance()+"',\n" +
                        "       ACCT_MULAID_PAY = '"+ylzMedicalRelationDO.getJtgjPay()+"',\n" +
                        "       CLR_WAY = '"+(StringUtils.isNoneBlank(ylzMedicalRelationDO.getClrWay())?ylzMedicalRelationDO.getClrWay():0)+"',\n" +
                        "       CLR_OPTINS = '"+(StringUtils.isNoneBlank(ylzMedicalRelationDO.getClrOptins())?ylzMedicalRelationDO.getClrOptins():0)+"',\n" +
                        "       CLR_TYPE = '"+(StringUtils.isNoneBlank(ylzMedicalRelationDO.getClrType())?ylzMedicalRelationDO.getClrType():0)+"',\n" +
                        "       FUND_PAY_SUMAMT = '"+ylzMedicalRelationDO.getFundPrice()+"',\n" +
                        "       SETL_TIME = '"+DateUtil.dateToStrShort(ylzMedicalRelationDO.getPayDate())+"',\n" +
                        "       OUTYBSFJSON = '"+ylzMedicalRelationDO.getOutJson()+"'\n" +
                        " where 1 = 1\n" +
                        "   and LOG_NO = '"+ylzMedicalRelationDO.getLogNo()+"'";
                //结算更新
                System.out.println("sql=="+sql);
                String res = hcyyEntranceService.updateUrl(sql);
            }
            Map<String,Object> params = new HashedMap();
            String url =entranceUrlLocal +"comfirmSettleMent";
            params.put("mct","03");
@ -1822,38 +1941,73 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            params.put("xtgzh0",ylzMedicalRelationDO.getLogNo());
            HttpResponse response = HttpUtils.doGet(url,params);
            System.out.println("response=="+response.getContent());
            List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(ylzMedicalRelationDO.getRelationCode());
            /*String */
            String realOrder = "";
            for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOS){
                if (prescriptionDO.getStatus()==20){
                    WlyyPrescriptionLogDO prescriptionLogDO = new WlyyPrescriptionLogDO();
                    prescriptionLogDO.setCreateTime(new Date());
                    prescriptionLogDO.setStatus(30);
                    prescriptionLogDO.setOutpatientId(prescriptionDO.getOutpatientId());
                    prescriptionLogDO.setPrescriptionCode(prescriptionDO.getId());
                    prescriptionLogDO.setUserCode(prescriptionDO.getPatientCode());
                    prescriptionLogDO.setUserName(prescriptionDO.getPatientName());
                    prescriptionLogDO.setUserType(1);
                    prescriptionLogDO.setDatajson("处方结算");
                    prescriptionLogDao.save(prescriptionLogDO);
                    prescriptionDO.setStatus(30);
                    prescriptionDO.setPayTime(new Date());
                    prescriptionDao.save(prescriptionDO);
                    logger.info("变更处方结算状态成功");
                    realOrder = prescriptionDO.getRealOrder();
            String res = response.getContent();
            boolean flag = true;
            if (StringUtils.isNoneBlank(res)){
                JSONObject jsonObject = JSONObject.parseObject(res);
                String status = jsonObject.getString("status");
                if (status.equalsIgnoreCase("200")){
                    JSONObject obj = jsonObject.getJSONObject("obj");
                    String rs = obj.getString("rs");
                    JSONObject rsObj = JSONObject.parseObject(rs);
                    String retCode = rsObj.getString("retCode");
                    if (retCode.equalsIgnoreCase("99")){
                        flag=false;
                        throw new Exception(rsObj.getString("retMsg"));
                    }
                }else {
                    flag = false;
                }
            }
            if (flag){
                ylzMedicalRelationDO.setState(1);
                ylzMedicalRelationDO.setSettleDate(new Date());
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(ylzMedicalRelationDO.getRelationCode());
                /*String */
                String realOrder = "";
                for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOS){
                    if (prescriptionDO.getStatus()==20){
                        WlyyPrescriptionLogDO prescriptionLogDO = new WlyyPrescriptionLogDO();
                        prescriptionLogDO.setCreateTime(new Date());
                        prescriptionLogDO.setStatus(30);
                        prescriptionLogDO.setOutpatientId(prescriptionDO.getOutpatientId());
                        prescriptionLogDO.setPrescriptionCode(prescriptionDO.getId());
                        prescriptionLogDO.setUserCode(prescriptionDO.getPatientCode());
                        prescriptionLogDO.setUserName(prescriptionDO.getPatientName());
                        prescriptionLogDO.setUserType(1);
                        prescriptionLogDO.setDatajson("处方结算");
                        prescriptionLogDao.save(prescriptionLogDO);
                        prescriptionDO.setStatus(30);
                        prescriptionDO.setVoucherNo(ylzMedicalRelationDO.getHisBillSerial());
                        prescriptionDO.setPayTime(new Date());
                        prescriptionDao.save(prescriptionDO);
                        logger.info("变更处方结算状态成功");
                        realOrder = prescriptionDO.getRealOrder();
                    }
                    try {
                        sfToHis(outpatientId, realOrder);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
                try {
                    sfToHis(outpatientId, realOrder);
                    logger.info("=================电子发票开具开始=================");
                    hcyyEntranceService.OutpatientInvoicing(ylzMedicalRelationDO.getHisBillSerial(),"lb");
                    logger.info("=================电子发票开具结束=================");
                }catch (Exception e){
                    e.printStackTrace();
                }
                return "结算成功!";
            }else {
                throw new Exception("结算失败!");
            }
            return "结算成功!";
        }catch (Exception e){
            e.printStackTrace();
            return "结算失败";
            throw new Exception(e.getMessage());
        }
    }

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

@ -42,7 +42,6 @@ import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorOnlineTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalIcdDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalMxDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
@ -53,6 +52,7 @@ import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.healthCare.service.HealthCareNewService;
import com.yihu.jw.healthCare.service.HealthCareService;
import com.yihu.jw.hospital.consult.dao.BaseAdviceTreatmentDao;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
@ -63,7 +63,6 @@ import com.yihu.jw.hospital.doctor.dao.DoctorWorkTimeDao;
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.doctor.dao.WlyyDoctorOnlineTimeDao;
import com.yihu.jw.hospital.drugstore.dao.BaseDrugStoreDao;
import com.yihu.jw.hospital.family.dao.WlyyNatPatientFamilyMemberDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailMxDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
@ -94,7 +93,6 @@ import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.LatitudeUtils;
@ -115,7 +113,6 @@ import com.yihu.jw.wechat.service.BaseSensitiveFilterWordsService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.jw.yx.dao.YxTokenMappingDao;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import com.ylzinfo.ehc.EhcHandler;
import com.ylzinfo.ehc.common.utils.DateUtils;
@ -143,9 +140,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.print.DocFlavor;
import javax.validation.constraints.Null;
import java.beans.Transient;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.Boolean;
@ -328,6 +322,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private HealthCareService healthCareService;
    @Autowired
    private HealthCareNewService healthCareNewService;
    @Autowired
    private HcyyPrescriptionService hcyyPrescriptionService;
    @Autowired
    private YlzMedicailRelationDao ylzMedicailRelationDao;
@ -1086,6 +1082,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson, WlyyOutpatientDO.class);
        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
        BaseDoctorDO doctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
        if (!StringUtils.isNoneBlank(outpatientDO.getMedicalState())){
            outpatientDO.setMedicalState("0");
        }
        outpatientDO.setIsAgree("1");
        outpatientDO.setMjz("mz");
        outpatientDO.setStatus("0");
@ -4548,13 +4547,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }else {
                        rs.put("is_prescribe",0);
                    }
                }else {
                }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                    String isPrescribe =healthCareService.doctorAuthentication(doctorDO.getId());
                    if (StringUtils.isNoneBlank(isPrescribe)){
                        rs.put("is_prescribe", isPrescribe);//is_prescribe	是否具备处方权	1-有处方权,0无处方权
                    }else {
                        rs.put("is_prescribe",0);
                    }
                }else {
                    String isPrescribe =healthCareNewService.doctorAuthentication(doctorDO.getId());
                    if (StringUtils.isNoneBlank(isPrescribe)){
                        rs.put("is_prescribe", isPrescribe);//is_prescribe	是否具备处方权	1-有处方权,0无处方权
                    }else {
                        rs.put("is_prescribe",0);
                    }
                }
            }else{
@ -4882,8 +4888,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }else {
                        rs.put("is_prescribe",0);
                    }
                }else {
                }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                    rs.put("is_prescribe", healthCareService.doctorAuthentication(doctorDO.getId()));//is_prescribe	是否具备处方权	1-有处方权,0无处方权
                }else{
                    rs.put("is_prescribe", healthCareNewService.doctorAuthentication(doctorDO.getId()));//is_prescribe	是否具备处方权	1-有处方权,0无处方权
                }
            }else{
                rs.put("is_prescribe", 0);//is_prescribe	是否具备处方权	1-有处方权,0无处方权
@ -7258,6 +7266,98 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        System.out.println("old"+(new Date().getTime()-statr));
        return envelop;
    }
    /**
     * 查找有专家问诊排班的医院
     */
    @Transactional(readOnly = true)
    public MixEnvelop findHospitalByZJ(String iswork, String orgName, String outpatientType,
                                       String workingTime, Integer page, Integer pagesize) {
        long statr = new Date().getTime();
        String sql = "SELECT " +
                " distinct o.name AS \"orgName\"," +
                " h.org_code AS \"orgCode\",o.photo AS \"photo\" " ;
        sql+=" FROM " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
                " LEFT JOIN base_org o on o.code = h.org_code ";
        Map<String, Object> params = new HashedMap();
        Date date = new Date();
        if (StringUtils.isNotBlank(workingTime)) {
            sql += " JOIN wlyy_doctor_work_time wk on wk.doctor = d.id ";
        }
        sql += " WHERE h.del = '1' ";
        if (StringUtils.isNotBlank(iswork) && "1".equals(iswork)) {
            logger.info("iswork:" + iswork);
            sql += " AND (" +
                    " EXISTS ( " +
                    " SELECT " +
                    "  1 " +
                    " FROM " +
                    "  wlyy_doctor_work_time t " +
                    " WHERE " +
                    "  t.doctor = d.id " +
                    " AND t.start_time <=:startTime" +
                    " AND t.end_time >=:endTime" +
                    " ) OR " +
                    " d.consult_status = '1') ";
            params.put("startTime", date);
            params.put("endTime", date);
        }
        if (StringUtils.isNotBlank(orgName)) {
            sql += " AND h.org_name like :orgName";
            params.put("orgName", "%" + orgName + "%");
        }
        if (StringUtils.isNotBlank(outpatientType)) {
            if (outpatientType.contains("or")) {
                String[] outpatientTypeArray = outpatientType.split("or");
                sql += " AND ( ";
                for (int i = 0; i < outpatientTypeArray.length; i++) {
                    sql += " d.outpatient_type like'%" + outpatientTypeArray[i] + "%'";
                    if (i != outpatientTypeArray.length - 1) {
                        sql += " or ";
                    }
                }
                sql += " ) ";
            } else {
                sql += " AND d.outpatient_type like'%" + outpatientType + "%'";
            }
        } else {
            sql += " AND d.outpatient_type is not null ";
        }
        if (StringUtils.isNotBlank(workingTime)) {
            sql += " AND wk.work_date = :workingTime ";
            params.put("workingTime", workingTime);
        }
        sql +=" and d.del='1' and o.del='1' order by o.sort ";
        String sqlCount = "select count(1) as \"total\" from ( "+sql+" ) t";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, pagesize);
        List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount, params);
        Long count = 0L;
        if(listCount!=null){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            count = hibenateUtils.objTransformLong(listCount.get(0).get("total"));
        }
        logger.info("findHospitalByZJ end:" + DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss:SSS"));
        logger.info("sql:" + sql);
        MixEnvelop envelop =new MixEnvelop();
        envelop.setDetailModelList(list);
        envelop.setTotalCount(count.intValue());
        envelop.setPageSize(pagesize);
        envelop.setCurrPage(page);
        System.out.println("old"+(new Date().getTime()-statr));
        return envelop;
    }
    /**
     * 获取常见疾病、热门部门、医生拒绝接诊原因 字典
     *
@ -7613,7 +7713,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }else {
                }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                    String result = healthCareService.authorized(basePatientDO.getId());
                    com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                    if (object.getString("flag").equalsIgnoreCase("1")){
@ -7623,6 +7723,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }else {
                    String result = healthCareNewService.authorized(basePatientDO.getId());
                    com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                    if (object.getString("flag").equalsIgnoreCase("1")){
                        com.alibaba.fastjson.JSONObject encryptData = object.getJSONObject("encrypt_data");
                        String state = encryptData.getString("state");
                        String auth_date = encryptData.getString("auth_date");
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
@ -10293,6 +10403,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new Exception(e.getMessage());
                }
            }
            prescriptionLogService.addPrescriptionLog(prescriptionId, 20, 2, operate, operateName, reason, new Date());
@ -14428,17 +14539,71 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            object.put("cardNo",outpatientDO.getCardNo());
            object.put("deptName",outpatientDO.getPatientName());
            return object;
        } else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")){
        } else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            logger.info("获取患者待结算信息开始!");
            YlzMedicalRelationDO ylzMedicalRelationDO = new YlzMedicalRelationDO();
            ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
            if (ylzMedicalRelationDO != null && StringUtils.isNoneBlank(ylzMedicalRelationDO.getPageCode())) {
                String result = confirmSettlementInfo(outpatientId, ylzMedicalRelationDO.getPageCode());
                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(result);
                if (jsonObject.getString("flag").equalsIgnoreCase("1")) {
                    com.alibaba.fastjson.JSONObject object1 = jsonObject.getJSONObject("encrypt_data");
                    BigDecimal b1 = new BigDecimal(object1.getString("tcjj_pay"));
                    BigDecimal b2 = new BigDecimal(object1.getString("sbjj_pay"));
                    BigDecimal b3 = new BigDecimal(object1.getString("gwy_pay"));
                    BigDecimal b4 = new BigDecimal(object1.getString("jzfp_pay"));
                    BigDecimal b5 = new BigDecimal(object1.getString("yljz_pay"));
                    BigDecimal b6 = new BigDecimal(object1.getString("other_pay"));
                    String payDateStr = object1.getString("pay_date");
                    Date payDate = DateUtil.strToDate(payDateStr);
                    Date now = DateUtil.getDateShort(new Date());
                    if (payDate.compareTo(now) == 0) {
                        BigDecimal b7 = new BigDecimal(object1.getString("enterprise_supplement"));
                        Double price = b1.add(b2).add(b3).add(b4).add(b5).add(b6).add(b7).doubleValue();
                        if (Double.parseDouble(ylzMedicalRelationDO.getMedicalPrice()) == price) {
                            ylzMedicalRelationDO.setStatus(1);
                            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                        }
                    } else {
                        ylzMedicalRelationDO.setStatus(0);
                        ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                    }
                }
            }
            if (ylzMedicalRelationDO != null && ylzMedicalRelationDO.getStatus() == 1) {
                com.alibaba.fastjson.JSONObject object2 = hcyyPrescriptionService.selectCardInfo(outpatientDO.getCardNo());
                Double cardFee = object2.getDouble("ZHYE");
                //医保已结算直接返回数据
                List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
                ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                ylzMedicalRelationDO.setBalance(cardFee + "");
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                Double totalPirce = b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:" + totalPirce);
                if (totalPirce != Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())) {
                    object.put("code", "403");
                    object.put("message", "金额不对无法结算!");
                } else {
                    object.put("code", "200");
                    object.put("message", "核对金额无误!");
                }
                object.put("getSettleInfo", ylzMedicalRelationDO);
                return object;
            }
            try {
                ylzMedicalRelationDO = hcyyPrescriptionService.getSettlementInfo(outpatientDO.getCardNo(),outpatientDO.getId());
            }catch (Exception e){
                ylzMedicalRelationDO = hcyyPrescriptionService.getSettlementInfo(outpatientDO.getCardNo(), outpatientDO.getId());
            } catch (Exception e) {
                throw new Exception(e.getMessage());
            }
            BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
            if (ylzMedicalRelationDO==null){
                throw new Exception("无待结算信息");
            }
            /*BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
            BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
            BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
            Double totalPirce=b1.add(b2).add(b3).doubleValue();
@ -14449,9 +14614,62 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }else {
                object.put("code","200");
                object.put("message","核对金额无误!");
            }*/
            if(outpatientDO!=null&&outpatientDO.getMedicalState().equalsIgnoreCase("1")){
                logger.info("医保挂号开始!");
                String register = healthCareNewService.register(outpatientId);
                logger.info("医保挂号结束!");
                logger.info("医保费用明细上传开始!");
                String feeDetailUpload= healthCareNewService.feeDetailUpload(outpatientId);
                logger.info("医保费用明细上传结束!");
                logger.info("医保预结算信息开始!");
                ylzMedicalRelationDO =  healthCareNewService.preSettlement(outpatientId);
                logger.info("医保预结算信息结束!");
                if (flag==1){
                    logger.info("获取医保结算页面地址开始!");
                    String getSettlementResultUrl = healthCareNewService.getSettlementResultUrl(outpatientId);
                    logger.info("获取医保结算页面地址结束!");
                    object.put("getSettlementResultUrl",getSettlementResultUrl);
                }else if (flag==2){
                    logger.info("获取医保结算页面地址开始!");
                    String getSettlementResultUrlBase64 = healthCareService.getSettlementResultUrlBase64(outpatientId);
                    logger.info("获取医保结算页面地址结束!");
                    object.put("getSettlementResultUrlBase64",getSettlementResultUrlBase64);
                }
                if (ylzMedicalRelationDO.getPersonCash()!=null){
                    BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                    BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                    BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                    Double totalPirce=b1.add(b2).add(b3).doubleValue();
                    logger.info("总费用:"+totalPirce);
                    if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
                        object.put("code","403");
                        object.put("message","金额不对无法结算!");
                    }else {
                        object.put("code","200");
                        object.put("message","核对金额无误!");
                    }
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                return object;
            }else {
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                Double totalPirce=b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:"+totalPirce);
                if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
                    object.put("code","403");
                    object.put("message","金额不对无法结算!");
                }else {
                    object.put("code","200");
                    object.put("message","核对金额无误!");
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                return object;
            }
            object.put("getSettleInfo",ylzMedicalRelationDO);
            return object;
        } else {
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            logger.info("获取患者待结算信息开始!");
@ -14486,12 +14704,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }
            }
            if (ylzMedicalRelationDO!=null&&ylzMedicalRelationDO.getStatus()==1){
                net.sf.json.JSONObject object2 = entranceService.qutpatientBalance(outpatientDO.getCardNo(), false);
                Double cardFee = object2.getDouble("ZHYE");
                //医保已结算直接返回数据
                List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
                ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                ylzMedicalRelationDO.setBalance(cardFee+"");
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                Double totalPirce=b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:"+totalPirce);
                if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
@ -14605,10 +14827,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            throw new Exception("门诊信息为空");
        }
        if (StringUtils.isNoneBlank(code)){
            logger.info("医保结算结果获取start!");
            result = healthCareService.getSettlementResult(code);
            logger.info("医保结算结果获取end!");
            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
            if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                logger.info("医保结算结果获取start!");
                result = healthCareService.getSettlementResult(code);
                logger.info("医保结算结果获取end!");
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
            }else {
                logger.info("医保结算结果获取start!");
                result = healthCareNewService.getSettlementResult(code);
                logger.info("医保结算结果获取end!");
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
            }
        }/*else{
            logger.info("医保结算页面start!");
            String registerNo = outpatientDO.getRegisterNo();
@ -15559,4 +15789,25 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }*/
    /**
     * 更新门诊记录
     * @param outpatientId
     * @param diseaseCode
     * @param diseaseName
     * @param medicalState
     * @return
     */
    public WlyyOutpatientDO updateOutpatient(String outpatientId,String diseaseCode,String diseaseName,String medicalState){
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
            if (StringUtils.isNoneBlank(diseaseCode)){
                outpatientDO.setDiseaseCode(diseaseCode);
                outpatientDO.setDiseaseName(diseaseName);
            }
            if (StringUtils.isNoneBlank(medicalState)){
                outpatientDO.setMedicalState(medicalState);
            }
            return outpatientDao.save(outpatientDO);
    }
}

+ 85 - 7
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/HcyyEntranceService.java

@ -136,9 +136,9 @@ public class HcyyEntranceService {
    private JdbcTemplate jdbcTemplate;
    private static String key="bvvsf3JA0mUXMU+mVnMaOQ==";
    private static String key="ydxtMEQmPymRtfz15lW76Tne88pHcuAU8WygMu/TrTKPRY5G7jttcg==";
    private static String caKey = "bvvsf3JA0mUXMU+mVnMaOQ==";
    private static String caKey = "ydxtMEQmPymRtfz15lW76Tne88pHcuAU8WygMu/TrTKPRY5G7jttcg==";
    private static String checkKey = "ydxtMEQmPymRtfz15lW76Tne88pHcuAU8WygMu/TrTKPRY5G7jttcg==";
@ -403,6 +403,7 @@ public class HcyyEntranceService {
                            doctor.setTownName("海沧区");
                            doctor.setCityCode("350200");
                            doctor.setCityName("厦门市");
                            doctor.setAtddrNo(doctorJson.getString("COUNTRY_CODE"));
                            if (!"[]".equalsIgnoreCase(doctorJson.getString("expertise"))&&StringUtils.isNoneBlank(doctorJson.getString("expertise"))){
                                doctor.setExpertise(doctorJson.getString("expertise"));
                            }
@ -437,12 +438,12 @@ public class HcyyEntranceService {
                                    doctorHospitalDao.save(hospitalDO);
                                }
                            }
                            List<DoctorMappingDO> doctorMappingDOS = doctorMappingDao.findByOrgCodeAndMappingCode("350211A5010",doctorJson.getString("code"));
                            List<DoctorMappingDO> doctorMappingDOS = doctorMappingDao.findByOrgCodeAndMappingCode("350211A1002",doctorJson.getString("code"));
                            if (doctorMappingDOS!=null&&doctorMappingDOS.size()!=0){
                                DoctorMappingDO doctorMappingDO = doctorMappingDOS.get(0);
                                doctorMappingDO.setIdcard(idcard);
                                doctorMappingDO.setDoctor(doctor.getId());
                                doctorMappingDO.setOrgCode("350211A5022");
                                doctorMappingDO.setOrgCode("350211A1002");
                                doctorMappingDO.setOrgName("海沧医院");
                                doctorMappingDO.setMappingCode(doctorJson.getString("code"));
                                doctorMappingDO.setMappingName(doctorJson.getString("name"));
@ -457,7 +458,7 @@ public class HcyyEntranceService {
                                DoctorMappingDO doctorMappingDO = new DoctorMappingDO();
                                doctorMappingDO.setIdcard(idcard);
                                doctorMappingDO.setDoctor(doctor.getId());
                                doctorMappingDO.setOrgCode("350211A5022");
                                doctorMappingDO.setOrgCode("350211A1002");
                                doctorMappingDO.setOrgName("海沧医院");
                                doctorMappingDO.setMappingCode(doctorJson.getString("code"));
                                doctorMappingDO.setMappingName(doctorJson.getString("name"));
@ -482,6 +483,7 @@ public class HcyyEntranceService {
                            doctor.setProvinceName("福建省");
                            doctor.setTownCode("350205");
                            doctor.setTownName("海沧区");
                            doctor.setAtddrNo(doctorJson.getString("COUNTRY_CODE"));
                            doctor.setCityCode("350200");
                            doctor.setCityName("厦门市");
                            if (!"[]".equalsIgnoreCase(doctorJson.getString("expertise"))&&StringUtils.isNoneBlank(doctorJson.getString("expertise"))){
@ -1087,7 +1089,7 @@ public class HcyyEntranceService {
     * @throws Exception
     */
    //挂号(调his后台包)
    public String registered(String doctor,String dept,String sickId,String clinicclass,String courierflag)throws Exception{
    public String registered(String doctor,String dept,String sickId,String clinicclass,String courierflag,String flag)throws Exception{
        String api = "Registered";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
@ -1115,6 +1117,10 @@ public class HcyyEntranceService {
        if (!StringUtils.isEmpty(courierflag)&&!courierflag.equalsIgnoreCase("null")){
            condition +="<courierflag>"+courierflag+"</courierflag>";
        }
        if (!StringUtils.isEmpty(flag)&&!flag.equalsIgnoreCase("null")){
            condition +="<flag>"+flag+"</flag>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
@ -1804,6 +1810,7 @@ public class HcyyEntranceService {
        wlyyHttpLogDO.setRequest(msgBody);
        wlyyHttpLogDO.setName("保存电子病历");
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO = wlyyHttpLogDao.save(wlyyHttpLogDO);
        logger.info("returnEmrHtmlByHLW params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        logger.info("returnEmrHtmlByHLW json:"+xml);
@ -1957,7 +1964,7 @@ public class HcyyEntranceService {
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(bstrEmrID)){
            condition += "<bstrEmrID>"+bstrEmrID+"</bstrEmrID>";
            condition += "<emrId>"+bstrEmrID+"</emrId>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
@ -3172,4 +3179,75 @@ public class HcyyEntranceService {
    //===========================结算==================================
    //===========================电票接口===============================
    /**
     * 电票下载接口
     * @return
     */
    public String downloadinvoice(String settleNo)throws Exception{
        String api = "downloadinvoice";
        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(settleNo)){
            condition = "<SETTLE_NO>"+settleNo+"</SETTLE_NO>";
        }
        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("downloadinvoice params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("downloadinvoice json:"+json);
        return json;
    }
    /**
     * 电票开具接口
     * @return
     */
    public String OutpatientInvoicing(String settleNo,String operator)throws Exception{
        String api = "OutpatientInvoicing";
        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(settleNo)){
            condition += "<SETTLE_NO>"+settleNo+"</SETTLE_NO>";
        }
        if (StringUtils.isNoneBlank(operator)){
            condition += "<OPERATOR>"+operator+"</OPERATOR>";
        }
        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("OutpatientInvoicing params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("OutpatientInvoicing json:"+json);
        return json;
    }
    //===========================电票接口===============================
}

+ 14 - 1
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.healthCare.service.HealthCareNewService;
import com.yihu.jw.healthCare.service.HealthCareService;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
@ -108,6 +109,8 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    private HospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private HealthCareService healthCareService;
    @Autowired
    private HealthCareNewService healthCareNewService;
    /**
     * 居民id
     * @param patientId
@ -419,7 +422,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }else {
                }else if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                    String result = healthCareService.authorized(basePatientDO.getId());
                    JSONObject object = JSONObject.parseObject(result);
                    if (object.getString("flag").equalsIgnoreCase("1")){
@ -429,6 +432,16 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }else {
                    String result = healthCareNewService.authorized(basePatientDO.getId());
                    JSONObject object = JSONObject.parseObject(result);
                    if (object.getString("flag").equalsIgnoreCase("1")){
                        JSONObject encryptData = object.getJSONObject("encrypt_data");
                        String state = encryptData.getString("state");
                        String auth_date = encryptData.getString("auth_date");
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }
            }
        }catch (Exception e){

+ 930 - 0
common/common-entity/sql/mysql关键字大全.sql

@ -0,0 +1,930 @@
关键字
A
ACCESSIBLE
ACCOUNT
ACTION
ACTIVE
ADD
ADMIN
AFTER
AGAINST
AGGREGATE
ALGORITHM
ALL
ALTER
ALWAYS
ANALYSE
ANALYZE
AND
ANY
ARRAY
AS
ASC
ASCII
ASENSITIVE
AT
ATTRIBUTE
AUTHENTICATION
AUTOEXTEND_SIZE
AUTO_INCREMENT
AVG
AVG_ROW_LENGTH
B
BACKUP
BEFORE
BEGIN
BETWEEN
BIGINT
BINARY
BINLOG
BIT
BLOB
BLOCK
BOOL
BOOLEAN
BOTH
BTREE
BUCKETS
BY
BYTE
C
CACHE
CALL
CASCADE
CASCADED
CASE
CATALOG_NAME
CHAIN
CHALLENGE_RESPONSE
CHANGE
CHANGED
CHANNEL
CHAR
CHARACTER
CHARSET
CHECK
CHECKSUM
CIPHER
CLASS_ORIGIN
CLIENT
CLONE
CLOSE
COALESCE
CODE
COLLATE
COLLATION
COLUMN
COLUMNS
COLUMN_FORMAT
COLUMN_NAME
COMMENT
COMMIT
COMMITTED
COMPACT
COMPLETION
COMPONENT
COMPRESSED
COMPRESSION
CONCURRENT
CONDITION
CONNECTION
CONSISTENT
CONSTRAINT
CONSTRAINT_CATALOG
CONSTRAINT_NAME
CONSTRAINT_SCHEMA
CONTAINS
CONTEXT
CONTINUE
CONVERT
CPU
CREATE
CROSS
CUBE
CUME_DIST
CURRENT
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURRENT_USER
CURSOR
CURSOR_NAME
D
DATA
DATABASE
DATABASES
DATAFILE
DATE
DATETIME
DAY
DAY_HOUR
DAY_MICROSECOND
DAY_MINUTE
DAY_SECOND
DEALLOCATE
DEC
DECIMAL
DECLARE
DEFAULT
DEFAULT_AUTH
DEFINER
DEFINITION
DELAYED
DELAY_KEY_WRITE
DELETE
DENSE_RANK
DESC
DESCRIBE
DESCRIPTION
DES_KEY_FILE
DETERMINISTIC
DIAGNOSTICS
DIRECTORY
DISABLE
DISCARD
DISK
DISTINCT
DISTINCTROW
DIV
DO
DOUBLE
DROP
DUAL
DUMPFILE
DUPLICATE
DYNAMIC
E
EACH
ELSE
ELSEIF
EMPTY
ENABLE
ENCLOSED
ENCRYPTION
END
ENDS
ENFORCED
ENGINE
ENGINES
ENGINE_ATTRIBUTE
ENUM
ERROR
ERRORS
ESCAPE
ESCAPED
EVENT
EVENTS
EVERY
EXCEPT
EXCHANGE
EXCLUDE
EXECUTE
EXISTS
EXIT
EXPANSION
EXPIRE
EXPLAIN
EXPORT
EXTENDED
EXTENT_SIZE
F
FACTOR
FAILED_LOGIN_ATTEMPTS
FALSE
FAST
FAULTS
FETCH
FIELDS
FILE
FILE_BLOCK_SIZE
FILTER
FINISH
FIRST
FIRST_VALUE
FIXED
FLOAT
FLOAT4
FLOAT8
FLUSH
FOLLOWING
FOLLOWS
FOR
FORCE
FOREIGN
FORMAT
FOUND
FROM
FULL
FULLTEXT
FUNCTION
G
GENERAL
GENERATED
GEOMCOLLECTION
GEOMETRY
GEOMETRYCOLLECTION
GET
GET_FORMAT
GET_MASTER_PUBLIC_KEY
GET_SOURCE_PUBLIC_KEY
GLOBAL
GRANT
GRANTS
GROUP
GROUPING
GROUPS
GROUP_REPLICATION
H
HANDLER
HASH
HAVING
HELP
HIGH_PRIORITY
HISTOGRAM
HISTORY
HOST
HOSTS
HOUR
HOUR_MICROSECOND
HOUR_MINUTE
HOUR_SECOND
I
IDENTIFIED
IF
IGNORE
IGNORE_SERVER_IDS
IMPORT
IN
INACTIVE
INDEX
INDEXES
INFILE
INITIAL
INITIAL_SIZE
INITIATE
INNER
INOUT
INSENSITIVE
INSERT
INSERT_METHOD
INSTALL
INSTANCE
INT
INT1
INT2
INT3
INT4
INT8
INTEGER
INTERVAL
INTO
INVISIBLE
INVOKER
IO
IO_AFTER_GTIDS
IO_BEFORE_GTIDS
IO_THREAD
IPC
IS
ISOLATION
ISSUER
ITERATE
J
JOIN
JSON
JSON_TABLE
JSON_VALUE
K
KEY
KEYRING
KEYS
KEY_BLOCK_SIZE
KILL
L
LAG
LANGUAGE
LAST
LAST_VALUE
LATERAL
LEAD
LEADING
LEAVE
LEAVES
LEFT
LESS
LEVEL
LIKE
LIMIT
LINEAR
LINES
LINESTRING
LIST
LOAD
LOCAL
LOCALTIME
LOCALTIMESTAMP
LOCK
LOCKED
LOCKS
LOGFILE
LOGS
LONG
LONGBLOB
LONGTEXT
LOOP
LOW_PRIORITY
M
MASTER
MASTER_AUTO_POSITION
MASTER_BIND
MASTER_COMPRESSION_ALGORITHMS
MASTER_CONNECT_RETRY
MASTER_DELAY
MASTER_HEARTBEAT_PERIOD
MASTER_HOST
MASTER_LOG_FILE
MASTER_LOG_POS
MASTER_PASSWORD
MASTER_PORT
MASTER_PUBLIC_KEY_PATH
MASTER_RETRY_COUNT
MASTER_SERVER_ID
MASTER_SSL
MASTER_SSL_CA
MASTER_SSL_CAPATH
MASTER_SSL_CERT
MASTER_SSL_CIPHER
MASTER_SSL_CRL
MASTER_SSL_CRLPATH
MASTER_SSL_KEY
MASTER_SSL_VERIFY_SERVER_CERT
MASTER_TLS_CIPHERSUITES
MASTER_TLS_VERSION
MASTER_USER
MASTER_ZSTD_COMPRESSION_LEVEL
MATCH
MAXVALUE
MAX_CONNECTIONS_PER_HOUR
MAX_QUERIES_PER_HOUR
MAX_ROWS
MAX_SIZE
MAX_UPDATES_PER_HOUR
MAX_USER_CONNECTIONS
MEDIUM
MEDIUMBLOB
MEDIUMINT
MEDIUMTEXT
MEMBER
MEMORY
MERGE
MESSAGE_TEXT
MICROSECOND
MIDDLEINT
MIGRATE
MINUTE
MINUTE_MICROSECOND
MINUTE_SECOND
MIN_ROWS
MOD
MODE
MODIFIES
MODIFY
MONTH
MULTILINESTRING
MULTIPOINT
MULTIPOLYGON
MUTEX
MYSQL_ERRNO
N
NAME
NAMES
NATIONAL
NATURAL
NCHAR
NDB
NDBCLUSTER
NESTED
NETWORK_NAMESPACE
NEVER
NEW
NEXT
NO
NODEGROUP
NONE
NOT
NOWAIT
NO_WAIT
NO_WRITE_TO_BINLOG
NTH_VALUE
NTILE
NULL
NULLS
NUMBER
NUMERIC
NVARCHAR
O
OF
OFF
OFFSET
OJ
OLD
ON
ONE
ONLY
OPEN
OPTIMIZE
OPTIMIZER_COSTS
OPTION
OPTIONAL
OPTIONALLY
OPTIONS
OR
ORDER
ORDINALITY
ORGANIZATION
OTHERS
OUT
OUTER
OUTFILE
OVER
OWNER
P
PACK_KEYS
PAGE
PARSER
PARTIAL
PARTITION
PARTITIONING
PARTITIONS
PASSWORD
PASSWORD_LOCK_TIME
PATH
PERCENT_RANK
PERSIST
PERSIST_ONLY
PHASE
PLUGIN
PLUGINS
PLUGIN_DIR
POINT
POLYGON
PORT
PRECEDES
PRECEDING
PRECISION
PREPARE
PRESERVE
PREV
PRIMARY
PRIVILEGES
PRIVILEGE_CHECKS_USER
PROCEDURE
PROCESS
PROCESSLIST
PROFILE
PROFILES
PROXY
PURGE
Q
QUARTER
QUERY
QUICK
R
RANDOM
RANGE
RANK
READ
READS
READ_ONLY
READ_WRITE
REAL
REBUILD
RECOVER
RECURSIVE
REDOFILE
REDO_BUFFER_SIZE
REDUNDANT
REFERENCE
REFERENCES
REGEXP
REGISTRATION
RELAY
RELAYLOG
RELAY_LOG_FILE
RELAY_LOG_POS
RELAY_THREAD
RELEASE
RELOAD
REMOTE
REMOVE
RENAME
REORGANIZE
REPAIR
REPEAT
REPEATABLE
REPLACE
REPLICA
REPLICAS
REPLICATE_DO_DB
REPLICATE_DO_TABLE
REPLICATE_IGNORE_DB
REPLICATE_IGNORE_TABLE
REPLICATE_REWRITE_DB
REPLICATE_WILD_DO_TABLE
REPLICATE_WILD_IGNORE_TABLE
REPLICATION
REQUIRE
REQUIRE_ROW_FORMAT
RESET
RESIGNAL
RESOURCE
RESPECT
RESTART
RESTORE
RESTRICT
RESUME
RETAIN
RETURN
RETURNED_SQLSTATE
RETURNING
RETURNS
REUSE
REVERSE
REVOKE
RIGHT
RLIKE
ROLE
ROLLBACK
ROLLUP
ROTATE
ROUTINE
ROW
ROWS
ROW_COUNT
ROW_FORMAT
ROW_NUMBER
RTREE
S
SAVEPOINT
SCHEDULE
SCHEMA
SCHEMAS
SCHEMA_NAME
SECOND
SECONDARY
SECONDARY_ENGINE
SECONDARY_ENGINE_ATTRIBUTE
SECONDARY_LOAD
SECONDARY_UNLOAD
SECOND_MICROSECOND
SECURITY
SELECT
    SENSITIVE
        SEPARATOR
    SERIAL
    SERIALIZABLE
    SERVER
    SESSION
SET
    SHARE
    SHOW
    SHUTDOWN
    SIGNAL
    SIGNED
    SIMPLE
    SKIP
    SLAVE
    SLOW
    SMALLINT
    SNAPSHOT
    SOCKET
    SOME
    SONAME
    SOUNDS
    SOURCE
    SOURCE_AUTO_POSITION
    SOURCE_BIND
    SOURCE_COMPRESSION_ALGORITHMS
    SOURCE_CONNECT_RETRY
    SOURCE_DELAY
    SOURCE_HEARTBEAT_PERIOD
    SOURCE_HOST
    SOURCE_LOG_FILE
    SOURCE_LOG_POS
    SOURCE_PASSWORD
    SOURCE_PORT
    SOURCE_PUBLIC_KEY_PATH
    SOURCE_RETRY_COUNT
    SOURCE_SSL
    SOURCE_SSL_CA
    SOURCE_SSL_CAPATH
    SOURCE_SSL_CERT
    SOURCE_SSL_CIPHER
    SOURCE_SSL_CRL
    SOURCE_SSL_CRLPATH
    SOURCE_SSL_KEY
    SOURCE_SSL_VERIFY_SERVER_CERT
    SOURCE_TLS_CIPHERSUITES
    SOURCE_TLS_VERSION
    SOURCE_USER
    SOURCE_ZSTD_COMPRESSION_LEVEL
    SPATIAL
    SPECIFIC
    SQL
    SQLEXCEPTION
    SQLSTATE
    SQLWARNING
    SQL_AFTER_GTIDS
    SQL_AFTER_MTS_GAPS
    SQL_BEFORE_GTIDS
    SQL_BIG_RESULT
    SQL_BUFFER_RESULT
    SQL_CACHE
    SQL_CALC_FOUND_ROWS
    SQL_NO_CACHE
    SQL_SMALL_RESULT
    SQL_THREAD
    SQL_TSI_DAY
    SQL_TSI_HOUR
    SQL_TSI_MINUTE
    SQL_TSI_MONTH
    SQL_TSI_QUARTER
    SQL_TSI_SECOND
    SQL_TSI_WEEK
    SQL_TSI_YEAR
    SRID
    SSL
    STACKED
START
    STARTING
    STARTS
    STATS_AUTO_RECALC
    STATS_PERSISTENT
    STATS_SAMPLE_PAGES
    STATUS
    STOP
    STORAGE
    STORED
    STRAIGHT_JOIN
    STREAM
    STRING
    SUBCLASS_ORIGIN
    SUBJECT
    SUBPARTITION
    SUBPARTITIONS
    SUPER
    SUSPEND
    SWAPS
    SWITCHES
    SYSTEM
    T
    TABLE
    TABLES
    TABLESPACE
    TABLE_CHECKSUM
    TABLE_NAME
    TEMPORARY
    TEMPTABLE
    TERMINATED
    TEXT
    THAN
    THEN
    THREAD_PRIORITY
    TIES
    TIME
    TIMESTAMP
    TIMESTAMPADD
    TIMESTAMPDIFF
    TINYBLOB
    TINYINT
    TINYTEXT
    TLS
    TO
    TRAILING
    TRANSACTION
    TRIGGER
    TRIGGERS
    TRUE
    TRUNCATE
    TYPE
    TYPES
    U
    UNBOUNDED
    UNCOMMITTED
    UNDEFINED
    UNDO
    UNDOFILE
    UNDO_BUFFER_SIZE
    UNICODE
    UNINSTALL
UNION
UNIQUE
UNKNOWN
UNLOCK
UNREGISTER
UNSIGNED
UNTIL
UPDATE
    UPGRADE
    USAGE
    USE
    USER
    USER_RESOURCES
    USE_FRM
    USING
    UTC_DATE
    UTC_TIME
    UTC_TIMESTAMP
    V
    VALIDATION
    VALUE
VALUES
    VARBINARY
    VARCHAR
    VARCHARACTER
    VARIABLES
    VARYING
    VCPU
    VIEW
    VIRTUAL
    VISIBLE
    W
    WAIT
    WARNINGS
    WEEK
    WEIGHT_STRING
    WHEN
WHERE
    WHILE
    WINDOW
WITH
    WITHOUT
    WORK
    WRAPPER
    WRITE
    X
    X509
    XA
    XID
    XML
    XOR
    Y
    YEAR
    YEAR_MONTH
    Z
    ZEROFILL
    ZONE
    A
    ACTIVE
    ADMIN
    ARRAY
    ATTRIBUTE
    AUTHENTICATION
    B
    BUCKETS
    C
    CHALLENGE_RESPONSE
    CLONE
    COMPONENT
    CUME_DIST
    D
    DEFINITION
    DENSE_RANK
    DESCRIPTION
    E
    EMPTY
    ENFORCED
    ENGINE_ATTRIBUTE
    EXCEPT
    EXCLUDE
    F
    FACTOR
    FAILED_LOGIN_ATTEMPTS
    FINISH
    FIRST_VALUE
    FOLLOWING
    G
    GEOMCOLLECTION
    GET_MASTER_PUBLIC_KEY
    GET_SOURCE_PUBLIC_KEY
    GROUPING
    GROUPS
    H
    HISTOGRAM
    HISTORY
    I
    INACTIVE
    INITIAL
    INITIATE
    INVISIBLE
    J
    JSON_TABLE
    JSON_VALUE
    K
    KEYRING
    L
    LAG
    LAST_VALUE
    LATERAL
    LEAD
    LOCKED
    M
    MASTER_COMPRESSION_ALGORITHMS
    MASTER_PUBLIC_KEY_PATH
    MASTER_TLS_CIPHERSUITES
    MASTER_ZSTD_COMPRESSION_LEVEL
    MEMBER
    N
    NESTED
    NETWORK_NAMESPACE
    NOWAIT
    NTH_VALUE
    NTILE
    NULLS
    O
    OF
    OFF
    OJ
    OLD
    OPTIONAL
    ORDINALITY
    ORGANIZATION
    OTHERS
    OVER
    P
    PASSWORD_LOCK_TIME
    PATH
    PERCENT_RANK
    PERSIST
    PERSIST_ONLY
    PRECEDING
    PRIVILEGE_CHECKS_USER
    PROCESS
    R
    RANDOM
    RANK
    RECURSIVE
    REFERENCE
    REGISTRATION
    REPLICA
    REPLICAS
    REQUIRE_ROW_FORMAT
    RESOURCE
    RESPECT
    RESTART
    RETAIN
    RETURNING
    REUSE
    ROLE
    ROW_NUMBER
    S
    SECONDARY
    SECONDARY_ENGINE
    SECONDARY_ENGINE_ATTRIBUTE
    SECONDARY_LOAD
    SECONDARY_UNLOAD
    SKIP
    SOURCE_AUTO_POSITION
    SOURCE_BIND
    SOURCE_COMPRESSION_ALGORITHMS
    SOURCE_CONNECT_RETRY
    SOURCE_DELAY
    SOURCE_HEARTBEAT_PERIOD
    SOURCE_HOST
    SOURCE_LOG_FILE
    SOURCE_LOG_POS
    SOURCE_PASSWORD
    SOURCE_PORT
    SOURCE_PUBLIC_KEY_PATH
    SOURCE_RETRY_COUNT
    SOURCE_SSL
    SOURCE_SSL_CA
    SOURCE_SSL_CAPATH
    SOURCE_SSL_CERT
    SOURCE_SSL_CIPHER
    SOURCE_SSL_CRL
    SOURCE_SSL_CRLPATH
    SOURCE_SSL_KEY
    SOURCE_SSL_VERIFY_SERVER_CERT
    SOURCE_TLS_CIPHERSUITES
    SOURCE_TLS_VERSION
    SOURCE_USER
    SOURCE_ZSTD_COMPRESSION_LEVEL
    SRID
    STREAM
    SYSTEM
    T
    THREAD_PRIORITY
    TIES
    TLS
    U
    UNBOUNDED
    UNREGISTER
    V
    VCPU
    VISIBLE
    W
    WINDOW
    Z
    ZONE

+ 3 - 0
common/common-entity/sql/sql记录

@ -2430,3 +2430,6 @@ alter table wlyy_outpatient add column is_positive tinyint(1) DEFAULT NULL comme
-- 2022-12-27 ysj wlyy_specialist
alter table wlyy_patient_rehabilitation_plan add column patient_info_code varchar(50) DEFAULT NULL COMMENT '自动下转关联code';
alter table wlyy_patient_rehabilitation_plan add column third_org_code varchar(50) DEFAULT NULL COMMENT '自动下转的医院code';
-- 2023-02-13
ALTER TABLE base_doctor_daily_report_upload add column leader_comment VARCHAR(1000) COMMENT '上级点评'

+ 47 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseMqttCallbackRecordDO.java

@ -0,0 +1,47 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * mqtt回调记录
 * Created by yeshijie on 2023/1/13.
 */
@Entity
@Table(name = "base_mqtt_callback_record")
public class BaseMqttCallbackRecordDO extends UuidIdentityEntityWithCreateTime {
    private String deviceId;//设备id
    private String topic;//回调的topic
    private String payload;//回调内容
    @Column(name = "device_id")
    public String getDeviceId() {
        return deviceId;
    }
    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }
    @Column(name = "topic")
    public String getTopic() {
        return topic;
    }
    public void setTopic(String topic) {
        this.topic = topic;
    }
    @Column(name = "payload")
    public String getPayload() {
        return payload;
    }
    public void setPayload(String payload) {
        this.payload = payload;
    }
}

+ 4 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientHealthIndex.java

@ -21,11 +21,11 @@ public class DevicePatientHealthIndex extends IdEntity {
	private String user;
	// 干预标志
	private String intervene;
	// 血糖/收缩压/体重/腰围/早餐前空腹
	// 血糖/收缩压/体重/腰围/早餐前空腹/血氧百分比
	private String value1;
	// 舒张压/早餐后空腹/身高
	// 舒张压/早餐后空腹/身高/血氧报警上限
	private String value2;
	// 午餐空腹/BMI
	// 午餐空腹/BMI/血氧报警下限
	private String value3;
	// 午餐后/偏胖-1/正常0/偏瘦1
	private String value4;
@ -36,7 +36,7 @@ public class DevicePatientHealthIndex extends IdEntity {
	// 睡前
	private String value7;
	// 健康指标类型(1血糖,2血压,3体重/身高/BMI,4腰围,5心率,6体温,7呼吸)
	// 健康指标类型(1血糖,2血压,3体重/身高/BMI,4腰围,5心率,6体温,7呼吸,8血氧)
	private Integer type;
	// 记录时间
	private Date recordDate;

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/dailyReport/BaseDailyReportUploadDO.java

@ -24,6 +24,7 @@ public class BaseDailyReportUploadDO extends UuidIdentityEntityWithOperator {
    private String reportDate; //上报日期
    private String totalHour;//上报时长
    private Integer niceWorkType;//点赞类型
    private String leaderComment;//上级点评
    /**
     * 非数据库字段
@ -139,4 +140,12 @@ public class BaseDailyReportUploadDO extends UuidIdentityEntityWithOperator {
    public void setNiceWorkType(Integer niceWorkType) {
        this.niceWorkType = niceWorkType;
    }
    public String getLeaderComment() {
        return leaderComment;
    }
    public void setLeaderComment(String leaderComment) {
        this.leaderComment = leaderComment;
    }
}

+ 39 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationDO.java

@ -94,6 +94,45 @@ public class YlzMedicalRelationDO extends UuidIdentityEntity {
    private Date settleDate;//his结算时间
    private String bcwkje;//本次未扣费用
    private String clrOptins;//清算经办机构
    private String clrWay;//清算方式
    private String clrType;//清算类别
    private String outJson;//海沧his需要
    public String getOutJson() {
        return outJson;
    }
    public void setOutJson(String outJson) {
        this.outJson = outJson;
    }
    public String getClrOptins() {
        return clrOptins;
    }
    public void setClrOptins(String clrOptins) {
        this.clrOptins = clrOptins;
    }
    public String getClrWay() {
        return clrWay;
    }
    public void setClrWay(String clrWay) {
        this.clrWay = clrWay;
    }
    public String getClrType() {
        return clrType;
    }
    public void setClrType(String clrType) {
        this.clrType = clrType;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name="settle_date")
    public Date getSettleDate() {

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

@ -2583,7 +2583,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            isNeedGeet=wlyyHospitalSysDictDO.getDictValue();
        }
        String wechatId = parameters.get("wechatId");
        if (!wechatId.equalsIgnoreCase("xm_ihealth_wx")){
        if (!StringUtils.isEmpty(wechatId)&&!wechatId.equalsIgnoreCase("xm_ihealth_wx")){
            if (parameters.get("mobile")==null){
                if ("1".equalsIgnoreCase(isNeedGeet)){
                    String geetestChallenge = parameters.get("geetestChallenge");
@ -2613,7 +2613,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (wechatId.equalsIgnoreCase("xm_ihealth_wx")){
        if (!StringUtils.isEmpty(wechatId)&&wechatId.equalsIgnoreCase("xm_ihealth_wx")){
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("clientId", userDetailsService.getClientId()));
            ClientDetails clientDetails = clientDetailsService.loadClientByClientId(userDetailsService.getClientId());

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

@ -54,7 +54,7 @@ public class HcyyService {
    @Autowired
    private OauthRsaKeyDao rsaKeyDao;
    private static String caKey ="bvvsf3JA0mUXMU+mVnMaOQ==";
    private static String caKey ="ydxtMEQmPymRtfz15lW76Tne88pHcuAU8WygMu/TrTKPRY5G7jttcg==";
    static {
        System.setProperty("kasite.appId", APP_ID);
        System.setProperty("kasite.appSecret", APP_SECRET);

+ 3 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/service/menu/BaseMenuManageService.java

@ -10,19 +10,12 @@ import com.yihu.jw.base.dao.menu.BaseMenuShowDao;
import com.yihu.jw.entity.base.menu.BaseLinkDictDO;
import com.yihu.jw.entity.base.menu.BaseMenuDictDO;
import com.yihu.jw.entity.base.menu.BaseMenuShowDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
@ -183,7 +176,9 @@ public class BaseMenuManageService {
                    baseMenuDictDO.setParentName(parentDo.getName());
                }
                WlyyHospitalSysDictDO menuFunction = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("menuFunction",baseMenuDictDO.getFunctionType());
                baseMenuDictDO.setFunctionName(menuFunction.getDictValue());
                if(menuFunction!=null){
                    baseMenuDictDO.setFunctionName(menuFunction.getDictValue());
                }
            }else {
                WlyyHospitalSysDictDO menuLocation = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("menuLocation",baseMenuDictDO.getMenuLocation());
                if (menuLocation==null||menuLocation.getDictValue() == null){

+ 5 - 0
svr/svr-cloud-care/pom.xml

@ -286,6 +286,11 @@
            <artifactId>tencentcloud-speech-sdk-java</artifactId>
            <version>1.0.12</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.paho</groupId>
            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
            <version>1.2.5</version>
        </dependency>
    </dependencies>
    <build>

+ 14 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseMqttCallbackRecordDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseMqttCallbackRecordDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2023/1/13.
 */
public interface BaseMqttCallbackRecordDao extends JpaRepository<BaseMqttCallbackRecordDO,String>,
        JpaSpecificationExecutor<BaseMqttCallbackRecordDO> {
}

+ 29 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wechat/WechatMenuController.java

@ -12,9 +12,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.File;
@ -24,7 +26,7 @@ import java.io.InputStreamReader;
/**
 * Created by chenweida on 2017/8/4.
 */
@Controller
@RestController
@RequestMapping(value = "/wechat/menu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "微信菜单相关管理")
public class WechatMenuController extends EnvelopRestEndpoint {
@ -34,6 +36,31 @@ public class WechatMenuController extends EnvelopRestEndpoint {
    private WxAccessTokenService wxAccessTokenService;
    @Value("${wechat.id}")
    private String wechatId;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @ApiOperation(value = "微信菜单创建-读数据库")
    @PostMapping(value = "/menu/createByMysql")
    public String createByMysql() {
        try {
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            String sql = "SELECT content from wx_menu_json WHERE id = 'weixin_menu'";
            String params = jdbcTemplate.queryForObject(sql,String.class);
            String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + wxAccessTokenDO.getAccessToken();
            // 请求微信接口创建菜单
            String jsonStr = HttpUtil.sendPost(url, params);
            JSONObject result = new JSONObject(jsonStr);
            if (result != null && result.get("errcode").toString().equals("0") && result.getString("errmsg").equals("ok")) {
                return "创建成功!";
            } else {
                return "创建失败!";
            }
        } catch (Exception e) {
            e.printStackTrace();
            return "创建失败";
        }
    }
    /**
     * 微信菜单创建

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -1863,7 +1863,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        if ("4".equals(devices.get(0).getCategoryCode())){//手表
            Device device = deviceDao.findOne(devices.get(0).getDeviceId());
            if (device!=null){
                if ("X1".equals(device.getModel())){
                if ("X1".equals(device.getModel())||"X3".equals(device.getModel())){
                    url = MessageFormat.format(AqgConfig.X1sos_numbers, deviceSn,seqid);
                }
            }
@ -1973,7 +1973,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            if ("4".equals(devices.get(0).getCategoryCode())){//手表
                Device device = deviceDao.findOne(devices.get(0).getDeviceId());
                if (device!=null){
                    if ("X1".equals(device.getModel())){
                    if ("X1".equals(device.getModel())||"X3".equals(device.getModel())){
                        url = MessageFormat.format(AqgConfig.X1fence_area, deviceSnTmp,fenceNO);
                    }
                }
@ -2208,7 +2208,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            if ("4".equals(devices.get(0).getCategoryCode())){//手表
                Device device = deviceDao.findOne(devices.get(0).getDeviceId());
                if (device!=null){
                    if ("X1".equals(device.getModel())){
                    if ("X1".equals(device.getModel())||"X3".equals(device.getModel())){
                        url = MessageFormat.format(AqgConfig.X1fence_area, deviceSnTmp,1);
                    }
                }

+ 26 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.service.third;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.BaseSleepPlanDao;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.PatientSafeAreaDao;
import com.yihu.jw.care.dao.label.BaseCapacityLabelDao;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
@ -22,6 +23,7 @@ import com.yihu.jw.care.util.Point;
import com.yihu.jw.entity.base.dict.BaseYujingDict;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.PatientSafeAreaDO;
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
@ -40,6 +42,7 @@ import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -94,6 +97,10 @@ public class PatientInfoPlatFormService {
    private GpsUtil gpsUtil;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    @Autowired
    private DeviceDao deviceDao;
    @Value("${spring.profiles.active}")
    private String profiles;
    /**
@ -714,6 +721,7 @@ public class PatientInfoPlatFormService {
     *获取设备详情
     */
    public List<Map<String,Object>> getPatientDeviceInfoWithDetail(String patient,String deviceSn,String warnTime,Integer isShow){
        //已绑定设备
        List<Map<String,Object>>  list = new ArrayList<>();
        String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime,dd.device_type as deviceType " +
                "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
@ -727,7 +735,9 @@ public class PatientInfoPlatFormService {
        sql+=" order by dd.device_type desc,pd.czrq asc ";
        list =  jdbcTemplate.queryForList(sql);
        Map<String,String> map = new HashMap<>();
        for (Map<String,Object> tmp :list){
            map.put(tmp.get("device_name")+"","");
            String category_code = tmp.get("category_code").toString();
            String deviceSN = tmp.get("device_sn").toString();
            Map<String,Object> detailInfo =  getDeviceIndexAndOrder(category_code,deviceSN,patient,warnTime);
@ -739,6 +749,22 @@ public class PatientInfoPlatFormService {
            list.add(resultMap);
        }
        //查找所有设备
        if("hzkxtest".equals(profiles)){
            List<Device> deviceList = deviceDao.findAll();
            Map<String,List<Device>>  deviceMap = deviceList.stream().collect(Collectors.groupingBy(Device::getName));
            for (String deviceName:deviceMap.keySet()){
                if(map.get(deviceName)==null){
                    Map<String,Object> devicetmp=new HashMap<>();
                    devicetmp.put("photo",deviceMap.get(deviceName).get(0).getPhoto());
                    devicetmp.put("category_code",deviceMap.get(deviceName).get(0).getCategoryCode());
                    devicetmp.put("deviceType",deviceMap.get(deviceName).get(0).getDeviceType());
                    devicetmp.put("device_name",deviceName);
                    devicetmp.put("detailInfo",new JSONObject());
                    list.add(devicetmp);
                }
            }
        }
        return list;
    }

+ 44 - 27
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/wechat/WeiXinEventProcess.java

@ -31,6 +31,10 @@ public class WeiXinEventProcess {
    private String wechatId;
    @Value("${wechat.appId}")
    private String appId;
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Value("${spring.profiles.active}")
    private String profiles;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
@ -142,44 +146,57 @@ public class WeiXinEventProcess {
     * @param articles
     */
    public void setUrlItems(List<Map<String, String>> articles) {
        String baseUrl = "zhyzh.gongshu.gov.cn";
        String street = "朝晖";
        String Description = "这里是智慧养老和健康管理服务社区+幼儿成长教育服务平台";
        String PicUrl = "https://zhyzh.gongshu.gov.cn/image/index.png";
        if("hzkxtest".equals(profiles)){
            baseUrl = "hzyy.cityihealth.com";
            street= "凯旋";
            Description = "这里是智慧养老和健康管理服务社区";
            PicUrl = "https://zhyzh.gongshu.gov.cn/image/kxindex.jpg";
        }
        Map<String, String> articleBooking = new HashMap<>();
        // 图文URL
        String urlBooking = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2Fhome%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        String urlBooking = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2F"+baseUrl+"%2Fmedical-care-patient%2Fhome%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlBooking = urlBooking.replace("{appId}", appId);
        articleBooking.put("Url", urlBooking);
        articleBooking.put("Title", "您好,欢迎来到朝晖云照护!");
        articleBooking.put("Description", "这里是智慧养老和健康管理服务社区+幼儿成长教育服务平台\n" +
        articleBooking.put("Title", "您好,欢迎来到"+street+"云照护!");
        articleBooking.put("Description", Description+"\n" +
                "我们陪你一起,关爱老人,呵护孩子!\n" +
                "感谢关注,点击下方菜单直接进入朝晖云照护平台");
        articleBooking.put("PicUrl", "https://zhyzh.gongshu.gov.cn/image/index.png");
                "感谢关注,点击下方菜单直接进入"+street+"云照护平台");
        articleBooking.put("PicUrl", PicUrl);
        articles.add(articleBooking);
        Map<String, String> articleDevice = new HashMap<>();
        // 图文URL
        String urlDevice = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FonlineRegistration%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlDevice = urlDevice.replace("{appId}", appId);
        articleDevice.put("Url", urlDevice);
        articleDevice.put("Title", "幼儿在线入园");
        articleDevice.put("Description", "申请专业托育机构入园资格");
        articleDevice.put("PicUrl", "https://zhyzh.gongshu.gov.cn/image/doorCoach.png");
        articles.add(articleDevice);
        Map<String, String> articleFamily = new HashMap<>();
        // 图文URL
        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex%3Ftype%3D2&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
//        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex%3Ftype%3D2&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlFamily = urlFamily.replace("{appId}", appId);
        articleFamily.put("Url", urlFamily);
        articleFamily.put("Title", "幼儿上门辅导预约");
        articleFamily.put("Description", "预约幼儿教育专家上门育儿指导");
        articleFamily.put("PicUrl", "https://zhyzh.gongshu.gov.cn/image/online.png");
        articles.add(articleFamily);
        if("hzprod".equals(profiles)){
            Map<String, String> articleDevice = new HashMap<>();
            // 图文URL
            String urlDevice = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2F"+baseUrl+"%2Fmedical-care-patient%2FonlineRegistration%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
            urlDevice = urlDevice.replace("{appId}", appId);
            articleDevice.put("Url", urlDevice);
            articleDevice.put("Title", "幼儿在线入园");
            articleDevice.put("Description", "申请专业托育机构入园资格");
            articleDevice.put("PicUrl", "https://zhyzh.gongshu.gov.cn/image/doorCoach.png");
            articles.add(articleDevice);
            Map<String, String> articleFamily = new HashMap<>();
            // 图文URL
            String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2F"+baseUrl+"%2Fmedical-care-patient%2FlifeCare%2Findex%3Ftype%3D2&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
            urlFamily = urlFamily.replace("{appId}", appId);
            articleFamily.put("Url", urlFamily);
            articleFamily.put("Title", "幼儿上门辅导预约");
            articleFamily.put("Description", "预约幼儿教育专家上门育儿指导");
            articleFamily.put("PicUrl", "https://zhyzh.gongshu.gov.cn/image/online.png");
            articles.add(articleFamily);
        }
        Map<String, String> oldzhaohuService = new HashMap<>();
        // 图文URL
        String urlOld = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FtoGround%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        String urlOld = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2F"+baseUrl+"%2Fmedical-care-patient%2FtoGround%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlOld = urlOld.replace("{appId}", appId);
        oldzhaohuService.put("Url", urlOld);
        oldzhaohuService.put("Title", "老人照护服务介绍");

+ 195 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MQTTKXClientUtil.java

@ -0,0 +1,195 @@
package com.yihu.jw.care.util;
import com.yihu.jw.care.dao.device.BaseMqttCallbackRecordDao;
import com.yihu.jw.entity.care.device.BaseMqttCallbackRecordDO;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.concurrent.ScheduledExecutorService;
/**
 * 凯旋街道视频
 * Created by yeshijie on 2023/1/12.
 */
@Component
public class MQTTKXClientUtil {
    private static Logger logger = LoggerFactory.getLogger(MQTTKXClientUtil.class);
    public static final String HOST = "tcp://121.40.135.79";
    public static final String deviceId = "18202a08724e5573";
    public static final Integer qos = 1;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseMqttCallbackRecordDao mqttCallbackRecordDao;
/*    	1、心跳保活,设置为30s:
    mosquitto_pub -h 121.40.135.79 -t "device/18202a08724e5573/cmd/ipcam_keep_alive" -u admin -P admin -m "30"
            2、订阅:
    mosquitto_sub -h 121.40.135.79 -t "device/18202a08724e5573/response/+"
            3、开启视频推流:
    mosquitto_pub -h 121.40.135.79 -t "device/18202a08724e5573/cmd/ipcam_video_start" -u admin -P admin -m "1"
            6、解析步骤2的payload,获取直播SourceURL:
    如:http://121.40.135.79/live/18202a08724e5573_1673488105807/hls.m3u8
            5、关闭视频推流:
    mosquitto_pub -h 121.40.135.79 -t "device/18202a08724e5573/cmd/ipcam_video_start" -u admin -P admin -m "0"*/
    public static final String ipcam_keep_alive = "device/{deviceId}/cmd/ipcam_keep_alive";
    public static final String TOPIC = "device/{deviceId}/response/+";
    public static final String ipcam_video_start = "device/{deviceId}/cmd/ipcam_video_start";
    private static final String clientid = String.valueOf(System.currentTimeMillis());;
    private MqttClient client;
    private MqttConnectOptions options;
    private String userName = "admin";
    private String passWord = "admin";
    private ScheduledExecutorService scheduler;
    public void start() {
        logger.info("启动监听mqtt-start");
        try {
            // host为主机名,clientid即连接MQTT的客户端ID,一般以唯一标识符表示,MemoryPersistence设置clientid的保存形式,默认为以内存保存
            client = new MqttClient(HOST, clientid, new MemoryPersistence());
            // MQTT的连接设置
            options = new MqttConnectOptions();
            // 设置是否清空session,这里如果设置为false表示服务器会保留客户端的连接记录,这里设置为true表示每次连接到服务器都以新的身份连接
            options.setCleanSession(true);
            // 设置连接的用户名
            options.setUserName(userName);
            // 设置连接的密码
            options.setPassword(passWord.toCharArray());
            // 设置超时时间 单位为秒
            options.setConnectionTimeout(10);
            options.setAutomaticReconnect(true);//设置自动重连
            // 设置会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端发送个消息判断客户端是否在线,但这个方法并没有重连的机制
            options.setKeepAliveInterval(20);
            // 设置回调
            client.setCallback(new MqttCallback(){
                @Override
                public void connectionLost(Throwable throwable) {
                    // 连接丢失后,一般在这里面进行重连
                    throwable.printStackTrace();
                    logger.info("连接断开,可以做重连");
                }
                @Override
                public void messageArrived(String topic, MqttMessage message) throws Exception {
                    // subscribe后得到的消息会执行到这里面
                    BaseMqttCallbackRecordDO mqttCallbackRecordDO = new BaseMqttCallbackRecordDO();
                    if(StringUtils.isNotBlank(topic)){
                        String[] deviceId = topic.split("//");
                        if(deviceId.length>1){
                            mqttCallbackRecordDO.setDeviceId(deviceId[1]);
                        }
                    }
                    mqttCallbackRecordDO.setTopic(topic);
                    mqttCallbackRecordDO.setPayload(new String(message.getPayload()));
                    mqttCallbackRecordDao.save(mqttCallbackRecordDO);
                    logger.info("接收消息主题 : " + topic+","+"接收消息内容 : " + new String(message.getPayload()));
                }
                @Override
                public void deliveryComplete(IMqttDeliveryToken token) {
                    logger.info("deliveryComplete---------" + token.isComplete());
                }
            });
            client.connect(options);
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info("启动监听mqtt-end");
    }
    public MqttClient getClient(){
        return client;
    }
    /**
     * 开启关闭直播
     */
    public void ipcam_video_start(String open,String deviceId) throws Exception{
        String payload = open;//
        MqttMessage message = new MqttMessage(payload.getBytes("UTF-8"));
        // 设置消息的服务质量
        message.setQos(qos);
        message.setRetained(true);
        // 发布消息
        String topic = ipcam_video_start.replace("{deviceId}",deviceId);
        logger.info(topic);
        getClient().publish(topic, message);
    }
    /**
     * 心跳
     */
    public void heart(String deviceId) throws Exception{
        String payload = "30";//
        MqttMessage message = new MqttMessage(payload.getBytes("UTF-8"));
        // 设置消息的服务质量
        message.setQos(qos);
        message.setRetained(true);
        // 发布消息
        String topic = ipcam_keep_alive.replace("{deviceId}",deviceId);
        logger.info(topic);
        getClient().publish(topic, message);
    }
    /**
     * 订阅消息
     */
    public void subscribe(String deviceId) throws Exception{
        int[] Qos  = {qos};
        String topic = TOPIC.replace("{deviceId}",deviceId);
        logger.info(topic);
        String[] topic1 = {topic};
        getClient().subscribe(topic1, Qos);
    }
//    public static void main(String[] args) throws Exception {
//        try {
//            MQTTKXClientUtil mqttkxClientUtil = new MQTTKXClientUtil();
//            mqttkxClientUtil.start();
//            logger.info("启动监听mqtt");
//            // 心跳
//            heart(client,deviceId);
//
//            //订阅消息
//            subscribe(client,deviceId);
//
//            Scanner scanner = new Scanner(System.in);
//            System.out.println("请输入1-3数字");
//            String username = scanner.nextLine();
//            if("1".equals(username)){
//                //开启直播
//                logger.info("开启直播");
//                ipcam_video_start(client,"1",deviceId);
//            }
//            System.out.println("请输入密码");
//            String password = scanner.nextLine();
//            if("2".equals(password)){
//                //关闭直播
//                logger.info("关闭直播");
//                ipcam_video_start(client,"0",deviceId);
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
}

+ 35 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/PostConstructUtil.java

@ -0,0 +1,35 @@
package com.yihu.jw.care.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
 * 项目启动就执行的类
 * Created by yeshijie on 2022/5/7.
 */
@Component
public class PostConstructUtil {
    private static final Logger logger = LoggerFactory.getLogger(PostConstructUtil.class);
    @Value("${spring.profiles.active}")
    private String profiles;
    @Autowired
    private MQTTKXClientUtil mqttkxClientUtil;
    @PostConstruct
    public void init(){
        logger.info("启动凯旋的设备的mqtt订阅====");
        mqttkxClientUtil.start();
    }
}

+ 2 - 3
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/common/PostConstructUtil.java

@ -1,6 +1,5 @@
package com.yihu.jw.care.common;
import com.yihu.jw.care.netdevsdk.NetDevSdkService;
import com.yihu.jw.care.util.MQTTClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -25,8 +24,8 @@ public class PostConstructUtil {
    @Autowired
    private MQTTClientUtil mqttClientUtil;
    @Autowired
    private NetDevSdkService netDevSdkService;
//    @Autowired
//    private NetDevSdkService netDevSdkService;
    @PostConstruct
    public void init(){

+ 33 - 9
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java

@ -1,29 +1,22 @@
package com.yihu.jw.care.endpoint;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.service.DeviceService;
import com.yihu.jw.care.service.YsDeviceService;
import com.yihu.jw.care.util.DeviceDataPushLogUtil;
import com.yihu.jw.entity.care.device.DeviceDetail;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
@ -277,6 +270,37 @@ public class DeviceController {
        }
    }
    @ApiOperation("设备血氧接收")
    @RequestMapping(value = "byBloodoxygen",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byBloodoxygen(
            @ApiParam(name="device_type",required = false,value="设备型号",defaultValue = "")
            @RequestParam(value = "device_type",required = true) String device_type,
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin_str",required = false,value="时间YYYYmmDDHHMMSS显示(将time_begin按YYYYmmDDHHMMSS格式化,字符串,长度固定14 )",defaultValue = "")
            @RequestParam(value = "time_begin_str",required = true) String time_begin_str,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS",defaultValue = "")
            @RequestParam(value = "time_begin",required = true) String time_begin,
            @ApiParam(name="bloodoxygen",required = false,value="血氧百分比",defaultValue = "")
            @RequestParam(value = "bloodoxygen",required = true) Integer bloodoxygen,
            @ApiParam(name="bloodoxygen_h",required = false,value="血氧报警上限")
            @RequestParam(value = "bloodoxygen_h",required = false) Integer bloodoxygen_h,
            @ApiParam(name="bloodoxygen_l",required = false,value="血氧报警下限")
            @RequestParam(value = "bloodoxygen_l",required = false) Integer bloodoxygen_l,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂血氧接收,请求参数:\n"+paraString);
            dataPushLogUtil.savePushLog(imei,paraString,"爱牵挂设备血氧数据接收");
            deviceService.byBloodoxygen(device_type, imei, time_begin_str, time_begin, bloodoxygen, bloodoxygen_h, bloodoxygen_l);
            dataPushLogUtil.updContactStatus(imei,1,false);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /*******************************************睡眠带begin****************************************************************/
    @ApiOperation("爱牵挂-睡眠带睡眠接收")
    @RequestMapping(value = "bySleep",  method = {RequestMethod.POST,RequestMethod.GET})

+ 34 - 3
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -10,7 +10,6 @@ import com.yihu.jw.care.util.*;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
@ -29,7 +28,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -37,7 +35,6 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.servlet.http.HttpServletRequest;
import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -766,6 +763,40 @@ public class DeviceService {
        }
    }
    //设备血氧接收
    @Async
    public void byBloodoxygen(String device_type,String imei,String time_begin_str,String time_begin
            ,Integer bloodoxygen,Integer bloodoxygen_h,Integer bloodoxygen_l) {
        try {
            if(StringUtils.isNotBlank(imei)) {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size() > 0) {
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setName(patientDO.getName());
                    patientHealthIndex.setDeviceSn(imei);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
                    patientHealthIndex.setValue1(bloodoxygen + "");
                    patientHealthIndex.setValue2(bloodoxygen_h + "");
                    patientHealthIndex.setValue3(bloodoxygen_l + "");
                    patientHealthIndex.setType(8);
                    Date recordDate = DateUtil.strToDate(time_begin);
                    patientHealthIndex.setRecordDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setCzrq(new Date());
                    patientHealthIndex.setStatus(0);
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     *
     * @param device

+ 2 - 2
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -130,7 +130,7 @@ public class PatientDeviceService {
        if ("4".equals(devices.get(0).getCategoryCode())){//手表
            Device device = deviceDao.findOne(devices.get(0).getDeviceId());
            if (device!=null){
                if ("X1".equals(device.getModel())){
                if ("X1".equals(device.getModel())||"X3".equals(device.getModel())){
                    url = MessageFormat.format(AqgConfig.X1sos_numbers, deviceSn,seqid);
                }
            }
@ -203,7 +203,7 @@ public class PatientDeviceService {
        if ("4".equals(devices.get(0).getCategoryCode())){//手表
            Device device = deviceDao.findOne(devices.get(0).getDeviceId());
            if (device!=null){
                if ("X1".equals(device.getModel())){
                if ("X1".equals(device.getModel())||"X3".equals(device.getModel())){
                    url = MessageFormat.format(AqgConfig.X1fence_area, deviceSn,fenceNO);
                }
            }

+ 11 - 0
svr/svr-cloud-transfor/pom.xml

@ -50,6 +50,17 @@
            <artifactId>swagger-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>mysql-starter</artifactId>
            <version>2.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>tomcat-jdbc</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- SPRINGSIDE -->
        <dependency>
            <groupId>org.springside</groupId>

+ 44 - 12
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/TransforController.java

@ -45,7 +45,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备sos数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -71,7 +71,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备开关机数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -95,7 +95,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,deviceid);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备消息通知数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -131,7 +131,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂位置接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -160,7 +160,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂心率数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -190,7 +190,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url =RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂血压数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -222,7 +222,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂跌倒数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -246,7 +246,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("设备步数接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -256,6 +256,38 @@ public class TransforController {
        }
    }
    @ApiOperation("设备血氧接收")
    @RequestMapping(value = "byBloodoxygen",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byBloodoxygen(
            @ApiParam(name="device_type",required = false,value="设备型号",defaultValue = "")
            @RequestParam(value = "device_type",required = true) String device_type,
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin_str",required = false,value="时间YYYYmmDDHHMMSS显示(将time_begin按YYYYmmDDHHMMSS格式化,字符串,长度固定14 )",defaultValue = "")
            @RequestParam(value = "time_begin_str",required = true) String time_begin_str,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS",defaultValue = "")
            @RequestParam(value = "time_begin",required = true) String time_begin,
            @ApiParam(name="bloodoxygen",required = false,value="血氧百分比",defaultValue = "")
            @RequestParam(value = "bloodoxygen",required = true) Integer bloodoxygen,
            @ApiParam(name="bloodoxygen_h",required = false,value="血氧报警上限")
            @RequestParam(value = "bloodoxygen_h",required = false) Integer bloodoxygen_h,
            @ApiParam(name="bloodoxygen_l",required = false,value="血氧报警下限")
            @RequestParam(value = "bloodoxygen_l",required = false) Integer bloodoxygen_l,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("设备血氧接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /*******************************************睡眠带begin****************************************************************/
    @ApiOperation("爱牵挂-睡眠带睡眠接收")
    @RequestMapping(value = "bySleep",  method = {RequestMethod.POST,RequestMethod.GET})
@ -279,7 +311,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,device);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带睡眠接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -336,7 +368,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,device);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带睡眠报告接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -360,7 +392,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,device);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带wifi在线状态接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -394,7 +426,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-手表睡眠接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();

+ 22 - 23
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/service/AqgService.java

@ -4,11 +4,14 @@ package com.yihu.jw.care.service;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
@ -20,36 +23,32 @@ import java.net.URLDecoder;
@Service
public class AqgService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public String getBaseUrl(String imei){
        if(StringUtils.isBlank(imei)){
            return "https://zhyzh.gongshu.gov.cn/device/";
        }
        String sql = "SELECT push_address from device_push_address where device_sn = '"+imei+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list==null||list.size()==0){
            return "https://zhyzh.gongshu.gov.cn/device/";
        }else {
            return list.get(0).get("push_address")+"";
        }
    }
    private Logger logger = LoggerFactory.getLogger(AqgService.class);
    private static final RestTemplate restTemplate = new RestTemplate();
    private static final String baseUrl = "https://zhyzh.gongshu.gov.cn/device/";
//    private static final String baseUrl = "http://ehr.yihu.com/wlyy/aqg";
    public String aqgForward(String method,String body,String uri){
        String res = "";
        try {
            String url;
            if(StringUtils.isBlank(body)){
                uri = URLDecoder.decode(uri,"UTF-8");
                url = baseUrl+uri;
            }else{
                url = baseUrl+method+"?"+body;
            }
            ResponseEntity<String> responseEntity = null;
            logger.info("推送爱牵挂数据给医养项目url="+ url);
            responseEntity = restTemplate.getForEntity(url, String.class);
            res = responseEntity.getBody();
            logger.info("推送爱牵挂数据给医养项目res="+ res);
        }catch (Exception e){
            e.printStackTrace();
        }
        return res;
    }
    public String aqgForward(String url){
    public String aqgForward(String url,String imei){
        String res = "";
        try {
            String baseUrl = getBaseUrl(imei);
            ResponseEntity<String> responseEntity = null;
            logger.info("推送爱牵挂数据给医养项目url="+ baseUrl+url);
            responseEntity = restTemplate.getForEntity(baseUrl+url, String.class);

+ 3 - 3
svr/svr-cloud-transfor/src/main/resources/application.yml

@ -77,9 +77,9 @@ spring:
  profiles: prod
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://172.26.0.104/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: ssgg
    password: ssgg@jkzl2019
    url: jdbc:mysql://192.168.1.221:3306/device?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: wlyy_sr
    password: 4zjQjEax
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode

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

@ -627,7 +627,7 @@ spring:
  profiles: hcyyProd
  datasource:
    driver-class-name: oracle.jdbc.driver.OracleDriver
    url: jdbc:oracle:thin:@10.95.100.10:1521/hcyy
    url: jdbc:oracle:thin:@192.168.120.102:1521/hcyy
    username: NET
    password: zy02v4NT
  jpa:

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

@ -11,7 +11,7 @@
    </parent>
    <groupId>com.yihu.jw</groupId>
    <artifactId>svr-internet-hospital</artifactId>
    <artifactId>svr-internet-hospital-test</artifactId>
    <packaging>jar</packaging>
    <version>${parent.version}</version>
@ -267,7 +267,7 @@
    </dependencies>
    <build>
        <finalName>svr-internet-hospital</finalName>
        <finalName>svr-internet-hospital-test</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>

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

@ -142,6 +142,8 @@ public class DailyReportUploadPoint extends EnvelopRestEndpoint {
                                   @RequestParam(value = "doctorId", required = true) String doctorId,
                                   @ApiParam(name = "reportID", value = "reportID")
                                   @RequestParam(value = "reportID", required = true) String reportID,
                                   @ApiParam(name = "leaderComment", value = "leaderComment")
                                   @RequestParam(value = "leaderComment", required = false) String leaderComment,
                                   @ApiParam(name = "jsonData", value = "事项信息实体")
                                   @RequestParam(value = "jsonData", required = false) String jsonData) {
        try {
@ -149,7 +151,7 @@ public class DailyReportUploadPoint extends EnvelopRestEndpoint {
            if (StringUtils.isNoneBlank(jsonData)){
                healthUploadDOs = JSONArray.parseArray(jsonData,BaseDailyReportDetailDO.class);
            }
            BaseDailyReportUploadDO dailyReport = dailyReportUploadService.verifiedItem(doctorId,reportID,healthUploadDOs);
            BaseDailyReportUploadDO dailyReport = dailyReportUploadService.verifiedItem(doctorId,reportID,healthUploadDOs,leaderComment);
            return success(dailyReport);
        } catch (Exception e) {
            return failedObjEnvelopException(e);

+ 85 - 27
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthCare/HealthCareEndPoint.java

@ -1,6 +1,7 @@
package com.yihu.jw.hospital.endpoint.healthCare;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.healthCare.service.HealthCareNewService;
import com.yihu.jw.healthCare.service.HealthCareService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -30,6 +31,8 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private HealthCareService healthCareService;
    @Autowired
    private HealthCareNewService healthCareNewService;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${wechat.id}")
    private String wechatId;
@ -49,8 +52,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorAuthentication(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorAuthentication(doctorId));
            }
        }catch (Exception e){
@ -73,8 +78,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorFaceCheckInAddress(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorFaceCheckInAddress(doctorId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -96,8 +103,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorFaceCheckInAddressBase64(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorFaceCheckInAddressBase64(doctorId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -119,8 +128,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorFaceCheckInData(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorFaceCheckInData(doctorId));
            }
        }catch (Exception e){
@ -143,8 +154,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.advanceWarning(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.advanceWarning(outpatientId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -166,8 +179,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorPrescriptionUpload(prescriptionId,wechatId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorPrescriptionUpload(prescriptionId,wechatId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -191,8 +206,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorPrescriptionUploadCancle(prescriptionId,cancelReason));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorPrescriptionUploadCancle(prescriptionId,cancelReason));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -213,8 +230,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
            }else {
                return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
            }
        }else {
        }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            return ObjEnvelop.getSuccess("ok",healthCareService.electronicPrescriptionReceiving(outpatientId));
        }else {
            return ObjEnvelop.getSuccess("ok",healthCareNewService.electronicPrescriptionReceiving(outpatientId));
        }
    }
@ -232,8 +251,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.electronicPrescriptionCancle(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.electronicPrescriptionCancle(outpatientId));
            }
        }catch (Exception e){
@ -256,8 +277,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.pharmacistReviewResults(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.pharmacistReviewResults(outpatientId));
            }
        }catch (Exception e){
@ -282,8 +305,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.outpatientReminder(outpatientId,doctorCode));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.outpatientReminder(outpatientId,doctorCode));
            }
        }catch (Exception e){
@ -309,8 +334,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.outpatientEventReminder(outpatientId,doctorCode));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.outpatientEventReminder(outpatientId,doctorCode));
            }
        }catch (Exception e){
@ -332,8 +359,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.getYlzToken());
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.getYlzToken());
            }
        }catch (Exception e){
@ -357,10 +386,13 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.authorized(patient));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.authorized(patient));
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
@ -381,8 +413,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.medicareOnline(patient));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.medicareOnline(patient));
            }
        }catch (Exception e){
@ -405,8 +439,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.medicareOnlineBase64(patient));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.medicareOnlineBase64(patient));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -428,8 +464,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.register(outpatientId));
            }else{
                return ObjEnvelop.getSuccess("ok",healthCareNewService.register(outpatientId));
            }
        }catch (Exception e){
@ -452,8 +490,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.registerBack(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.registerBack(outpatientId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -475,8 +515,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailUpload(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.feeDetailUpload(outpatientId));
            }
        }catch (Exception e){
@ -501,8 +543,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailRefund(outpatientId,remark));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.feeDetailRefund(outpatientId,remark));
            }
        }catch (Exception e){
@ -525,8 +569,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.preSettlement(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.preSettlement(outpatientId));
            }
        }catch (Exception e){
@ -549,8 +595,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareService.preSettlementRefund(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.preSettlementRefund(outpatientId));
            }
        }catch (Exception e){
@ -573,8 +621,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResultUrl(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.getSettlementResultUrl(outpatientId));
            }
        }catch (Exception e){
@ -597,8 +647,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResult(code));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.getSettlementResult(code));
            }
        }catch (Exception e){
@ -621,8 +673,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.uploadMedicalHistory(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.uploadMedicalHistory(outpatientId));
            }
        }catch (Exception e){
@ -647,8 +701,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareService.refundMedicalHistory(outpatientId,remark));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.refundMedicalHistory(outpatientId,remark));
            }
        }catch (Exception e){
@ -671,8 +727,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.uploadIcdProcess(outpatientId));
            }else{
                return ObjEnvelop.getSuccess("ok",healthCareNewService.uploadIcdProcess(outpatientId));
            }
        }catch (Exception e){

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

@ -29,6 +29,8 @@ import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.es.service.StatisticsEsService;
import com.yihu.jw.es.service.yqfk.YqfkService;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.healthCare.service.HealthCareNewService;
import com.yihu.jw.healthCare.service.HealthCareService;
import com.yihu.jw.healthUpload.service.BaseDoctorHealthUploadService;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
@ -70,6 +72,7 @@ import com.yihu.jw.sms.service.YkyyINSMSService;
import com.yihu.jw.util.common.FileUtil;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.enterprise.EnterpriseService;
@ -249,7 +252,39 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private EnterpriseService enterpriseService;
    @Autowired
    private WxEnterpriseDao wxEnterpriseDao;
    @Value("${wechat.id}")
    private String wechatId;
    public static String entranceHealthCareUrl = "http://127.0.0.1:10023/healthCare/";
    @Autowired
    private HealthCareService healthCareService;
    @Autowired
    private HealthCareNewService healthCareNewService;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @GetMapping(value = "findHospitalByZJ")
    @ApiOperation(value = "查找有专家问诊排班的医院", notes = "查找有专家问诊排班的医院")
    public MixEnvelop findHospitalByZJ(@ApiParam(name = "iswork", value = "是否过滤排班,1是")
                                                            @RequestParam(value = "iswork", required = true)String iswork,
                                                            @ApiParam(name = "orgName", value = "机构code", required = false)
                                                            @RequestParam(value = "orgName", required = false)String orgName,
                                                            @ApiParam(name = "outpatientType", value = "咨询类型zj 专家咨询")
                                                            @RequestParam(value = "outpatientType", required = false)String outpatientType,
                                                            @ApiParam(name = "workingTime", value = "排班时间YYYY-MM-DD")
                                                            @RequestParam(value = "workingTime", required = false)String workingTime,
                                                            @ApiParam(name = "page", value = "第几页")
                                                            @RequestParam(value = "page",required = false) Integer page,
                                                            @ApiParam(name = "pagesize", value = "分页大小")
                                                            @RequestParam(value = "pagesize",required = false) Integer pagesize
    ){
        try {
            logger.info("findHospitalByZJ start:"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
            return prescriptionService.findHospitalByZJ(iswork,orgName,
                    outpatientType,workingTime,page,pagesize);
        } catch (Exception e){
            return  failedMixEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientNoLogin.findDoctorByHospitalAndDiseaseAndDept)
@ -2911,4 +2946,58 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                       @RequestParam(value = "flag",required = false)Integer flag,HttpServletRequest request)throws Exception{
        return ObjEnvelop.getSuccess("ok",hcyyEntranceService.initiateDataSign(prescriptionId, flag,getIpAddress(request)));
    }
    @GetMapping(value = "doctorAuthentication")
    @ApiOperation(value = "医师身份验证", notes = "医师身份验证")
    public ObjEnvelop doctorAuthentication(@ApiParam(name = "doctorId", value = "医生id", required = true)
                                           @RequestParam(value = "doctorId",required = true) String doctorId){
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                String url = entranceHealthCareUrl + "doctorAuthentication?doctorId="+doctorId;
                String infoResponse = httpClientUtil.get(url,"GBK");
                JSONObject jsonObject = JSONObject.parseObject(infoResponse);
                if(jsonObject.getInteger("status")==200){
                    return ObjEnvelop.getSuccess("ok",jsonObject.get("obj"));
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorAuthentication(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorAuthentication(doctorId));
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    @PostMapping(value = "/authorized")
    @ApiOperation(value = "渠道应用是否已授权", notes = "渠道应用是否已授权")
    public ObjEnvelop authorized(@ApiParam(name = "patient", value = "患者id", required = true)
                                 @RequestParam(value = "patient", required = true)String patient)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "authorized?patient="+patient;
                String infoResponse = httpClientUtil.get(url,"GBK");
                JSONObject jsonObject = JSONObject.parseObject(infoResponse);
                if(jsonObject.getInteger("status")==200){
                    return ObjEnvelop.getSuccess("ok",jsonObject.get("obj"));
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.authorized(patient));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.authorized(patient));
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
}

+ 23 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/HcyyPrescriptionCotroller.java

@ -271,8 +271,10 @@ public class HcyyPrescriptionCotroller extends EnvelopRestEndpoint {
                                 @ApiParam(name = "clinicclass", value = "挂号类别", required = false)
                                     @RequestParam(value = "clinicclass",required = false)String clinicclass,
                                 @ApiParam(name = "courierflag", value = "快递发药标识(Y快递N为自取)", required = false)
                                     @RequestParam(value = "courierflag",required = false)String courierflag)throws Exception{
        return ObjEnvelop.getSuccess("ok",hcyyEntranceService.registered(doctor,dept,sickId,clinicclass,courierflag));
                                     @RequestParam(value = "courierflag",required = false)String courierflag,
                                 @ApiParam(name = "flag", value = "flag 0自费1医保", required = false)
                                     @RequestParam(value = "flag",required = false)String flag)throws Exception{
        return ObjEnvelop.getSuccess("ok",hcyyEntranceService.registered(doctor,dept,sickId,clinicclass,courierflag,flag));
    }
    /**
@ -860,4 +862,23 @@ public class HcyyPrescriptionCotroller extends EnvelopRestEndpoint {
                                           @RequestParam(value = "realorder",required = false)String realorder)throws Exception{
        return ObjEnvelop.getSuccess("ok",hcyyPrescriptionService.sfToHis(outpatientId,realorder));
    }
    @GetMapping(value = "/downloadinvoice")
    @ApiOperation(value = "电票下载", notes = "电票下载")
    public ObjEnvelop downloadinvoice(@ApiParam(name = "settleNo", value = "结算号", required = false)
                                           @RequestParam(value = "settleNo",required = false)String settleNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",hcyyEntranceService.downloadinvoice(settleNo));
    }
    @GetMapping(value = "/OutpatientInvoicing")
    @ApiOperation(value = "电票开具", notes = "电票开具")
    public ObjEnvelop OutpatientInvoicing(@ApiParam(name = "settleNo", value = "结算号", required = false)
                                      @RequestParam(value = "settleNo",required = false)String settleNo,
                                          @ApiParam(name = "operator", value = "操作人", required = false)
                                          @RequestParam(value = "operator",required = false)String operator)throws Exception{
        return ObjEnvelop.getSuccess("ok",hcyyEntranceService.OutpatientInvoicing(settleNo,operator));
    }
}

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

@ -3770,5 +3770,24 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping("/updateOutpatient")
    @ApiOperation(value = "更新门诊记录", notes = "更新门诊记录")
    public Envelop updateOupatient(
            @ApiParam(name = "outpatientId", value = "门诊id")
            @RequestParam(value = "outpatientId", required = false) String outpatientId,
            @ApiParam(name = "diseaseCode", value = "特殊病种code")
            @RequestParam(value = "diseaseCode", required = false) String diseaseCode,
            @ApiParam(name = "diseaseName", value = "特殊病种名称")
            @RequestParam(value = "diseaseName", required = false) String diseaseName,
            @ApiParam(name = "medicalState", value = "是否医保01")
            @RequestParam(value = "medicalState", required = false) String medicalState) {
        try {
            return success("操作成功", prescriptionService.updateOutpatient(outpatientId,diseaseCode,diseaseName,medicalState));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
}