Browse Source

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

humingfen 5 years ago
parent
commit
e435b9ad47
48 changed files with 3007 additions and 680 deletions
  1. 1 0
      business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorService.java
  2. 3 1
      business/base-service/src/main/java/com/yihu/jw/evaluate/score/service/BaseEvaluateScoreService.java
  3. 248 22
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  4. 302 23
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  5. 14 5
      business/base-service/src/main/java/com/yihu/jw/internet/entity/InternetUpLogDO.java
  6. 1 1
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetService.java
  7. 578 497
      business/base-service/src/main/java/com/yihu/jw/internet/service/ykyy/YkyyInternetService.java
  8. 7 1
      business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java
  9. 16 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BaseDoctorPatientFollowDao.java
  10. 4 1
      business/base-service/src/main/java/com/yihu/jw/utils/ImgUtils.java
  11. 62 0
      business/base-service/src/main/java/com/yihu/jw/utils/PinYinUtils.java
  12. 18 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/BasePatientWechatDao.java
  13. 48 2
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WxTemplateService.java
  14. 4 1
      business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java
  15. 533 27
      business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java
  16. 30 14
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  17. 19 0
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  18. 61 0
      common/common-entity/src/main/java/com/yihu/jw/entity/auth/OauthRsaKeyDO.java
  19. 38 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseDoctorPatientFollowDO.java
  20. 5 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  21. 76 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/BasePatientWechatDo.java
  22. 32 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java
  23. 16 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  24. 13 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyOutpatientVO.java
  25. 15 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/OauthRsaKeyDao.java
  26. 83 4
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  27. 125 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthSsoService.java
  28. 101 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAEncrypt.java
  29. 2 1
      server/svr-authentication/src/main/resources/application.yml
  30. 1 1
      server/svr-authentication/src/main/resources/bootstrap.yml
  31. 1 1
      server/svr-configuration/src/main/resources/application.yml
  32. 0 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java
  33. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WxTemplateController.java
  34. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  35. 127 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/YkyyDataUploadJob.java
  36. 63 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/UpPrescription.java
  37. 54 2
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  38. 45 2
      svr/svr-internet-hospital-job/src/main/resources/application.yml
  39. 9 2
      svr/svr-internet-hospital-job/src/main/resources/bootstrap.yml
  40. 6 14
      svr/svr-internet-hospital-job/src/main/resources/system.properties
  41. 16 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java
  42. 29 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  43. 24 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  44. 6 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  45. 27 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  46. 12 17
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java
  47. 6 6
      svr/svr-internet-hospital/src/main/resources/application.yml
  48. 124 21
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorService.java

@ -253,6 +253,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        if(StringUtils.isNotBlank(newSpecialDisease) && StringUtils.isNotBlank(newSpecialDiseaseCode)){
        if(StringUtils.isNotBlank(newSpecialDisease) && StringUtils.isNotBlank(newSpecialDiseaseCode)){
            String[] split = newSpecialDisease.split(",");
            String[] split = newSpecialDisease.split(",");
            String[] splitCode = newSpecialDiseaseCode.split(",");
            String[] splitCode = newSpecialDiseaseCode.split(",");
            specialDiseaseDao.deleteByDoctorCode(doctorId);
            for (int i=0;i<split.length;i++ ){
            for (int i=0;i<split.length;i++ ){
                DoctorSpecialDiseaseDo specialDiseaseDo = new DoctorSpecialDiseaseDo();
                DoctorSpecialDiseaseDo specialDiseaseDo = new DoctorSpecialDiseaseDo();
                specialDiseaseDo.setDoctorCode(doctorId);
                specialDiseaseDo.setDoctorCode(doctorId);

+ 3 - 1
business/base-service/src/main/java/com/yihu/jw/evaluate/score/service/BaseEvaluateScoreService.java

@ -70,10 +70,12 @@ public class BaseEvaluateScoreService extends BaseJpaService<BaseEvaluateScoreDO
     * @return
     * @return
     */
     */
    private Double getAvgScore(String startTime,String endTime,String area,int level){
    private Double getAvgScore(String startTime,String endTime,String area,int level){
        String sql = "select count(*) as total, sum(score) as score from base.base_evaluate_score o where";
        String sql = "select count(*) as total, sum(score) as score from base.base_evaluate_score o where ";
        if (level == 4){
        if (level == 4){
            sql += " o.doctor IN (SELECT doctor_code FROM `base_doctor_hospital` dh where dh.org_code ='"+area+"' and dh.del=1)";
            sql += " o.doctor IN (SELECT doctor_code FROM `base_doctor_hospital` dh where dh.org_code ='"+area+"' and dh.del=1)";
        }if (level==2){
            sql += " 1=1 ";
        }else if (level == 5){
        }else if (level == 5){
            sql += " o.doctor IN (SELECT doctor_code FROM `base_doctor_hospital` dh where dh.dept_code ='"+area+"' and dh.del=1)";
            sql += " o.doctor IN (SELECT doctor_code FROM `base_doctor_hospital` dh where dh.dept_code ='"+area+"' and dh.del=1)";
        }else if (level == 6){
        }else if (level == 6){

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

@ -8,6 +8,7 @@ import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
@ -20,6 +21,7 @@ import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
@ -37,6 +39,7 @@ import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BaseDoctorPatientFollowDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.restmodel.base.dict.DictHospitalDeptVO;
import com.yihu.jw.restmodel.base.dict.DictHospitalDeptVO;
@ -50,7 +53,9 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.PinYinUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
@ -155,6 +160,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private SystemMessageService systemMessageService;
    private SystemMessageService systemMessageService;
    @Autowired
    @Autowired
    private HibenateUtils hibenateUtils;
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDoctorPatientFollowDao baseOrgPatientDao;
    @Value("${demo.flag}")
    @Value("${demo.flag}")
@ -811,16 +818,33 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * 获取所有医院列表
     * 获取所有医院列表
     * @return
     * @return
     */
     */
    public List<BaseOrgVO> findAllHospital(Integer level){
        if(level!=null){
            List<BaseOrgDO> list = baseOrgDao.findByLevelAndDel(level,"1");
            List<BaseOrgVO> rs = new ArrayList<>();
            return convertToModels(list,rs,BaseOrgVO.class);
        }else {
            List<BaseOrgDO> list = baseOrgDao.findByDel("1");
            List<BaseOrgVO> rs = new ArrayList<>();
            return convertToModels(list,rs,BaseOrgVO.class);
    public List<BaseOrgVO> findAllHospital(Integer level,String keyWord){
    
        if (StringUtils.isNoneEmpty(keyWord)) {
            keyWord = "%" + keyWord + "%";
    
            if(level!=null){
                List<BaseOrgDO> list = baseOrgDao.findByLevelAndName(level,"1",keyWord);
                List<BaseOrgVO> rs = new ArrayList<>();
                return convertToModels(list,rs,BaseOrgVO.class);
            }else {
                List<BaseOrgDO> list = baseOrgDao.findByDelAndName("1",keyWord);
                List<BaseOrgVO> rs = new ArrayList<>();
                return convertToModels(list,rs,BaseOrgVO.class);
            }
        }else{
    
            if(level!=null){
                List<BaseOrgDO> list = baseOrgDao.findByLevelAndDel(level,"1");
                List<BaseOrgVO> rs = new ArrayList<>();
                return convertToModels(list,rs,BaseOrgVO.class);
            }else {
                List<BaseOrgDO> list = baseOrgDao.findByDel("1");
                List<BaseOrgVO> rs = new ArrayList<>();
                return convertToModels(list,rs,BaseOrgVO.class);
            }
        }
        }
    }
    }
    /**
    /**
@ -1195,11 +1219,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public net.sf.json.JSONObject registerOutPatient(String outPatientId,String doctor)throws Exception{
    public net.sf.json.JSONObject registerOutPatient(String outPatientId,String doctor)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
        
        
        DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(doctor,outpatientDO.getHospital());
        DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(doctor,outpatientDO.getHospital());
        if(doctorMappingDO==null){
        if(doctorMappingDO==null){
            throw new RuntimeException("未找到医生映射信息");
            throw new RuntimeException("未找到医生映射信息");
        }
        }
        
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
    
        Integer manageType = 1;//处理类型(1-新增 2-修改 3-删除) 必填
        //查找居民当天挂号记录
        //查找居民当天挂号记录
        String date = DateUtil.dateToStr(new Date(),"yyyy-MM-dd");
        String date = DateUtil.dateToStr(new Date(),"yyyy-MM-dd");
@ -1218,7 +1248,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                outpatientDO.setRegisterNo(registerDO.getRegisterNo());
                outpatientDO.setRegisterNo(registerDO.getRegisterNo());
                outpatientDO.setAdmDate(registerDO.getCreateTime());
                outpatientDO.setAdmDate(registerDO.getCreateTime());
                outpatientDao.save(outpatientDO);
                outpatientDao.save(outpatientDO);
                //调用电子病历注册
                manageType =2;
                registDianziBingli(outPatientId,basePatientDO,manageType);
                return res;
                return res;
            }
            }
        }
        }
@ -1228,6 +1260,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        net.sf.json.JSONObject res = rs.getJSONObject("resquest");
        net.sf.json.JSONObject res = rs.getJSONObject("resquest");
        logger.info("挂号结果 res: " +res.toString());
        logger.info("挂号结果 res: " +res.toString());
        String rsCode = res.getString("@RESULT");
        String rsCode = res.getString("@RESULT");
        
        if("0".equals(rsCode)){
        if("0".equals(rsCode)){
            //存储挂号号
            //存储挂号号
            // {"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47770476","@times":"28"}}
            // {"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47770476","@times":"28"}}
@ -1255,6 +1288,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            registerDO.setCreateTime(new Date());
            registerDO.setCreateTime(new Date());
            registerDO.setDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd"));
            registerDO.setDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd"));
            patientRegisterDao.save(registerDO);
            patientRegisterDao.save(registerDO);
            
            
        }else if("-2".equals(rsCode)){
        }else if("-2".equals(rsCode)){
            String serialNo = (String)res.get("@serial_no");
            String serialNo = (String)res.get("@serial_no");
@ -1282,6 +1317,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            patientRegisterDao.save(registerDO);
            patientRegisterDao.save(registerDO);
        }
        }
    
        manageType = 1;//处理类型(1-新增 2-修改 3-删除) 必填
    
        registDianziBingli(outPatientId,basePatientDO,manageType);
        
            //保存日志
            //保存日志
        WlyyHttpLogDO log = new WlyyHttpLogDO();
        WlyyHttpLogDO log = new WlyyHttpLogDO();
        log.setCode("registerOutPatient");
        log.setCode("registerOutPatient");
@ -1295,6 +1336,104 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        wlyyHttpLogDao.save(log);
        wlyyHttpLogDao.save(log);
        return res;
        return res;
    }
    }
    
    public String registDianziBingli(String outPatientId,BasePatientDO basePatientDO,Integer manageType) throws Exception {
    
        //调用电子病历接口注册居民信息
            String patientMappingCode =  patientMappingService.findHisPatNoByIdCard(basePatientDO.getIdcard());
            Map<String,String> params = new HashedMap();
            params.put("type","PatientInfo");
            String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                    "<HtRequest >" +
                    "<PatientInfo>" +
                    "<RecordFlow>"+outPatientId+"</RecordFlow >" +
                    "<PID>"+patientMappingCode+"</PID>" +
                    "<InsuranceNo>"+basePatientDO.getIdcard()+"</InsuranceNo>" +
                    "<PatientName>"+basePatientDO.getName()+"</PatientName>" +
                    "<TmpFlag>正式</TmpFlag>" +
                    "<LastName>"+basePatientDO.getName().substring(1,basePatientDO.getName().length())+"</LastName>" +
                    "<FirstName>"+basePatientDO.getName().substring(0,1)+"</FirstName>" +
                    "<PY>"+ PinYinUtils.getUpEname(basePatientDO.getName())+"</PY>" +
                    "<WB></WB>" +
                    "<SexCode>"+basePatientDO.getSex()+"</SexCode>";
            if(1 == basePatientDO.getSex()){
                xmlStr = xmlStr + "<Sex>男</Sex>";
            }else{
                xmlStr = xmlStr +  "<Sex>女</Sex>";
            }
        
            xmlStr = xmlStr +    "<DateOfBirth>"+DateUtil.dateToStrShort(IdCardUtil.getBirthdayForIdcard(basePatientDO.getIdcard()))+"</DateOfBirth>" +
                    "<TimeOfBirth></TimeOfBirth>" +
                    "<MarriageStatusCode></MarriageStatusCode>" +
                    "<MarriageStatus></MarriageStatus>" +
                    "<OccupationCode></OccupationCode>" +
                    "<Occupation></Occupation>" +
                    "<NationalityCode></NationalityCode>" +
                    "<Nationality></Nationality>" +
                    "<CountryCode>CN</CountryCode>" +
                    "<Country>中国</Country>" +
                    "<FormalSchoolingCode></FormalSchoolingCode>" +
                    "<FormalSchooling></FormalSchooling>" +
                    "<Religion></Religion>" +
                    "<BirthPlaceCode></BirthPlaceCode>" +
                    "<BirthPlace></BirthPlace>" +
                    "<NativePlaceCode></NativePlaceCode>" +
                    "<NativePlace></NativePlace>" +
                    "<BloodType></BloodType>" +
                    "<CertTypeCode>111</CertTypeCode>" +
                    "<CertType>身份证</CertType>" +
                    "<CertNo>"+basePatientDO.getIdcard()+"</CertNo>" +
                    "<PatientClassCode></PatientClassCode>" +
                    "<PatientClass></PatientClass>" +
                    "<FeeTypeCode></FeeTypeCode>" +
                    "<FeeType></FeeType>" +
                    "<Company></Company>" +
                    "<PublicExpenseNo></PublicExpenseNo>" +
                    "<ContractUnitCode></ContractUnitCode> " +
                    "<ContractUnit></ContractUnit>" +
                    "<BusinessAddressCode></BusinessAddressCode>" +
                    "<BusinessAddress></BusinessAddress>" +
                    "<BusinessPostCode></BusinessPostCode>" +
                    "<BusinessPhone></BusinessPhone>" +
                    "<HomeAddressCode></HomeAddressCode>" +
                    "<HomeAddress></HomeAddress>" +
                    "<HomePostCode></HomePostCode>" +
                    "<MobilePhone></MobilePhone>" +
                    "<Contact></Contact>" +
                    "<RelationCode></RelationCode>" +
                    "<Relation></Relation>" +
                    "<ContactEmail></ContactEmail>" +
                    "<ContactMethod></ContactMethod>" +
                    "<VIPType></VIPType>" +
                    "<OperatorID></OperatorID>" +
                    "<Operator></Operator>" +
                    "<OperatorTime>0</OperatorTime>" +
                    "<Available></Available>" +
                    "<ManageType>"+manageType+"</ManageType>" +
                    "<InsuranceTypeCode></InsuranceTypeCode>" +
                    "<InsuranceType></InsuranceType>" +
                    "<RegisteredAddressCode></RegisteredAddressCode>" +
                    "<RegisteredAddress></RegisteredAddress>" +
                    "<ContactAddressCode></ContactAddressCode>" +
                    "<ContactAddress></ContactAddress>" +
                    "<RegisteredPostCode></RegisteredPostCode>" +
                    "<ContactPostcode></ContactPostcode>" +
                    "<BloodType></BloodType>" +
                    "<RhBloodType></RhBloodType>" +
                    "</PatientInfo>" +
                    "</HtRequest>";
            String returnValue = "";
            params.put("xmlStr",xmlStr);
        
            returnValue = WebserviceUtil.post("http://192.10.33.34:9080/HtMzWebService/services/Manage",
                    "http://business.htemr.haitaiinc.com",
                    "manageAdt",
                    params);
        
            logger.info("调用电子病历注册接口请求成功,返回值xmlstr:"+returnValue);
            
            return returnValue;
    }
    /**
    /**
     * 获取诊断
     * 获取诊断
@ -2927,7 +3066,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param consutlSort
     * @param consutlSort
     * @return
     * @return
     */
     */
    public List<Map<String,Object>> findDoctorByHospitalAndDiseaseAndDept(String iswork,String orgCode, String dept,
    public List<Map<String,Object>> findDoctorByHospitalAndDiseaseAndDept(String iswork,String patientid,String orgCode, String dept,
                                                                          String diseaseKey, String doctorNameKey,
                                                                          String diseaseKey, String doctorNameKey,
                                                                          String jobTitleNameKey, String outpatientType,
                                                                          String jobTitleNameKey, String outpatientType,
                                                                          String keyName, String workingTime, String consultStatus,String chargType,String consutlSort,Integer page,Integer pagesize) {
                                                                          String keyName, String workingTime, String consultStatus,String chargType,String consutlSort,Integer page,Integer pagesize) {
@ -2954,10 +3093,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " d.outpatient_type AS outpatientType," +
                " d.outpatient_type AS outpatientType," +
                " a.total as consultTotal," +
                " a.total as consultTotal," +
                " h.org_name as orgName," +
                " h.org_name as orgName," +
                " follow.patient as followid," +
                " h.org_code as orgCode" +
                " h.org_code as orgCode" +
                " FROM " +
                " FROM " +
                " base_doctor d " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id "+
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id "+
                " Left join base_doctor_patient_follow follow on follow.doctor = d.id and follow.patient='"+patientid+"'"+
                " Left join ( select count(id) as total,doctor from wlyy_outpatient where status = 2 GROUP BY doctor ) a on a.doctor = d.id ";
                " Left join ( select count(id) as total,doctor from wlyy_outpatient where status = 2 GROUP BY doctor ) a on a.doctor = d.id ";
                
                
        if(StringUtils.isNotBlank(workingTime)){
        if(StringUtils.isNotBlank(workingTime)){
@ -3111,9 +3252,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    " d.id, " +
                    " d.id, " +
                    " d.`name`, " +
                    " d.`name`, " +
                    " h.org_code, " +
                    " h.org_code, " +
                    " h.org_name, " +
                    " h.dept_code, " +
                    " h.dept_name " +
                    " h.org_name " +
                    " FROM " +
                    " FROM " +
                    " base_doctor d " +
                    " base_doctor d " +
                    " JOIN base_doctor_hospital h ON d.id= h.doctor_code " +
                    " JOIN base_doctor_hospital h ON d.id= h.doctor_code " +
@ -3130,9 +3269,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    " d.id, " +
                    " d.id, " +
                    " d.`name`, " +
                    " d.`name`, " +
                    " h.org_code, " +
                    " h.org_code, " +
                    " h.org_name, " +
                    " h.dept_code, " +
                    " h.dept_name " +
                    " h.org_name " +
                    " FROM " +
                    " FROM " +
                    " base_doctor d " +
                    " base_doctor d " +
                    " JOIN base_doctor_hospital h ON d.id= h.doctor_code " +
                    " JOIN base_doctor_hospital h ON d.id= h.doctor_code " +
@ -3148,9 +3285,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    " d.id, " +
                    " d.id, " +
                    " d.`name`, " +
                    " d.`name`, " +
                    " h.org_code, " +
                    " h.org_code, " +
                    " h.org_name, " +
                    " h.dept_code, " +
                    " h.dept_name " +
                    " h.org_name " +
                    " FROM " +
                    " FROM " +
                    " base_doctor d " +
                    " base_doctor d " +
                    " JOIN base_doctor_hospital h ON d.id= h.doctor_code " +
                    " JOIN base_doctor_hospital h ON d.id= h.doctor_code " +
@ -3183,8 +3318,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    WlyyDoctorWorkTimeDO t = new WlyyDoctorWorkTimeDO();
                    WlyyDoctorWorkTimeDO t = new WlyyDoctorWorkTimeDO();
                    t.setDoctor((String)doctor.get("id"));
                    t.setDoctor((String)doctor.get("id"));
                    t.setDoctorName((String)doctor.get("name"));
                    t.setDoctorName((String)doctor.get("name"));
                    t.setDept((String)doctor.get("dept_code"));
                    t.setDeptName((String)doctor.get("dept_name"));
//                    t.setDept((String)doctor.get("dept_code"));
//                    t.setDeptName((String)doctor.get("dept_name"));
                    t.setHospital((String)doctor.get("org_code"));
                    t.setHospital((String)doctor.get("org_code"));
                    t.setHospitalName((String)doctor.get("org_name"));
                    t.setHospitalName((String)doctor.get("org_name"));
                    t.setCreateTime(new Date());
                    t.setCreateTime(new Date());
@ -4394,4 +4529,95 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        }
        return list;
        return list;
    }
    }
    
    public void followOrgByPatient(String patientid, String doctorid, String type) {
        List<BaseDoctorPatientFollowDO> list =baseOrgPatientDao.findByDoctorAndPatient(patientid,doctorid);
        if("1".equals(type)){//关注
            if(list.isEmpty()){
                BaseDoctorPatientFollowDO baseOrgPatientFollowDO = new BaseDoctorPatientFollowDO();
                baseOrgPatientFollowDO.setDoctor(doctorid);
                baseOrgPatientFollowDO.setPatient(patientid);
                baseOrgPatientDao.save(baseOrgPatientFollowDO);
            }
        }else if("0".equals(type)){//取消关注
            if(!list.isEmpty()){
                for (BaseDoctorPatientFollowDO baseOrgPatientFollowDO:list){
                    baseOrgPatientDao.delete(baseOrgPatientFollowDO.getId());
                }
            }
        }else{}
    }
    
    public List<Map<String,Object>> findDeptByKeyWord(String keyWord,Integer page,Integer pagesize) {
    
        if(page >=1){
            page --;
        }
    
        if (pagesize <= 0) {
            pagesize = 10;
        }
    
        String sql ="SELECT " +
                "dept.`code` AS deptCode," +
                "dept.`name` AS deptName," +
                "org.CODE AS orgCode, " +
                "org.NAME AS orgName " +
                "FROM " +
                "dict_hospital_dept dept," +
                "base_org org " +
                "WHERE org.CODE=dept.org_code " +
                "AND org.del=1 ";
        
        if(StringUtils.isNoneBlank(keyWord)){
            sql = sql + "AND dept.NAME LIKE '%"+keyWord+"%' ";
        }
        sql = sql + " limit "+page * pagesize +","+pagesize ;
    
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        logger.info("sql:"+sql);
        return list;
    }
    public List<Map<String,Object>> findDeptWithDoctorWorkTime(String hospital,String keyWord,Integer page,Integer pagesize ){
        String now = DateUtil.dateToStr(new Date(),"yyyy-MM-dd");
        Date startDate = DateUtil.stringToDate(now+" 00:00:00","yyyy-MM-dd HH:mm:ss");
        Date endDate = DateUtil.stringToDate(now+" 23:59:59","yyyy-MM-dd HH:mm:ss");
        String sql ="SELECT  " +
                " DISTINCT " +
                " h.dept_code AS \"deptCode\", " +
                " h.dept_name AS \"deptName\"," +
                " h.org_code AS \"orgCode\"," +
                " h.org_name AS \"orgName\"" +
                " FROM " +
                " base_doctor_hospital h " +
                " WHERE " +
                " EXISTS ( " +
                " SELECT " +
                "  w.doctor " +
                " FROM " +
                "  wlyy_doctor_work_time w " +
                " WHERE " +
                "  w.doctor = h.doctor_code " +
                " AND start_time >=:startTime " +
                " AND start_time <=:endDate " +
                " ) " +
                " AND h.dept_code IS NOT NULL " +
                " AND h.dept_code !=''";
        Map<String,Object> params = new HashedMap();
        params.put("startTime",startDate);
        params.put("endDate",endDate);
        if(StringUtils.isNotBlank(hospital)){
            sql +=" AND h.org_code =:hospital";
            params.put("hospital",hospital);
        }
        if(StringUtils.isNotBlank(keyWord)){
            sql +=" AND h.dept_name like:keyWord";
            params.put("keyWord","%"+keyWord+"%");
        }
        return hibenateUtils.createSQLQuery(sql,params,page,pagesize);
    }
}
}

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

@ -11,14 +11,28 @@ import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.score.BaseEvaluateDO;
import com.yihu.jw.entity.base.score.BaseEvaluateScoreDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateDao;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateScoreDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.security.MD5;
import com.yihu.utils.security.MD5;
import javafx.scene.DepthTest;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
@ -63,9 +77,30 @@ public class YkyyEntranceService {
    @Autowired
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    @Autowired
    private HibenateUtils hibenateUtils;
    private HibenateUtils hibenateUtils;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private BaseEvaluateScoreDao baseEvaluateScoreDao;
    @Autowired
    private BaseEvaluateDao baseEvaluateDao;
    public List<Map<String, Object>> createSQLQuery(String sql, Map<String, Object> params, Integer page, Integer size){
    public List<Map<String, Object>> createSQLQuery(String sql, Map<String, Object> params, Integer page, Integer size){
        return hibenateUtils.createSQLQuery(sql,params,page,size);
        return hibenateUtils.createSQLQuery(sql,params,page,size);
    }
    }
@ -97,7 +132,7 @@ public class YkyyEntranceService {
                    if(list!=null&&list.size()>0){
                    if(list!=null&&list.size()>0){
                        DictHospitalDeptDO deptDO = list.get(0);
                        DictHospitalDeptDO deptDO = list.get(0);
                        deptDO.setName(deptjson.getString("name"));
                        deptDO.setName(deptjson.getString("name"));
                        deptDO.setConsultDeptFlag(deptjson.getString("consultdeptflag"));
                        deptDO.setConsultDeptFlag(deptjson.getString("consultDeptFlag"));
                        hospitalDeptDao.save(deptDO);
                        hospitalDeptDao.save(deptDO);
                    }else {
                    }else {
                        //新增
                        //新增
@ -105,7 +140,7 @@ public class YkyyEntranceService {
                        deptDO.setOrgCode(orgCode);
                        deptDO.setOrgCode(orgCode);
                        deptDO.setCode(code);
                        deptDO.setCode(code);
                        deptDO.setName(deptjson.getString("name"));
                        deptDO.setName(deptjson.getString("name"));
                        deptDO.setConsultDeptFlag(deptjson.getString("consultdeptflag"));
                        deptDO.setConsultDeptFlag(deptjson.getString("consultDeptFlag"));
                        deptDO.setCreateTime(new Date());
                        deptDO.setCreateTime(new Date());
                        hospitalDeptDao.save(deptDO);
                        hospitalDeptDao.save(deptDO);
                    }
                    }
@ -251,26 +286,270 @@ public class YkyyEntranceService {
        return buffer.toString();
        return buffer.toString();
    }
    }
//    public String test(){
    public String getCFXX(String brids,String ysdm,String startDate)throws Exception{
        BaseDoctorDO doctor = findByMapingCode(ysdm);
        if(doctor==null){
            return "doctor mapping not exist !";
        }
        BaseDoctorHospitalDO hospitalDO = getDept(doctor.getId());
        if(hospitalDO==null){
            return "hospital not exist!";
        }
        String sql ="SELECT " +
                " c.BRID," +
                " c.CFHM," +
                " c.TSCF," +
                " c.BRXM," +
                " c.YSDM," +
                " c.KSDM," +
                " c.YPMC," +
                " c.YPDJ," +
                " c.YPSL," +
                " c.HJJE," +
                " c.JZXH," +
                " c.FPHM," +
                " c.FYBZ," +
                " c.YPCD," +
                " c.YPXH," +
                " c.YPYF," +
                " d.ICD," +
                " d.JBMC," +
                " x.YPDM," +
                " x.YFGG," +
                " x.YFDW," +
                " x.YFBZ," +
                " x.YPSX," +
                " x.YPJL," +
                " x.JLDW," +
                " x.PYDM," +
                " x.FYFS," +
                " x.GYFF," +
                " x.GYFFMC," +
                " x.YFZF," +
                " x.LSJG," +
                " x.KCSL," +
                " x.ZFPB," +
                " x.JBYWBZ," +
                " x.YDYP," +
                " x.YPMC2," +
                " p.JZKH " +
                "FROM " +
                " V_ZKSG_CFCX c, " +
                " v_hlw_mzbrzd d, " +
                " V_ZKSG_MZ_YPXX x," +
                " V_ZKSG_BRCX p " +
                "WHERE " +
                " c.BRID = d.BRID " +
                " AND c.jzxh = d.jzxh " +
                " AND c.ysdm = '"+ysdm+"' " +
                " AND x.ypxh = c.ypxh  " +
                " AND x.ypcd = c.ypcd " +
                " AND p.BRID = c.BRID " +
                " AND c.BRID in  ("+brids+") order by c.BRID DESC";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
//        HttpResponse response = HttpUtils.doGet(url,params);
//        String content = response.getContent();
//        logger.info("response:"+content);
//        JSONObject rs = JSON.parseObject(content);
//        Integer status = rs.getInteger("status");
//        Map<String,String> map = new HashedMap();
//        if(status!=null&&status == 200){
//            JSONArray array = rs.getJSONArray("detailModelList");
//            logger.info("detailModelList size:"+array.size());
//            if(array!=null&&array.size()>0) {
//                for(int i= 0;i<array.size();i++){
//                    JSONObject cfxx = array.getJSONObject(i);
//                    String brid = cfxx.getString("BRID");
//                    BasePatientDO patientDO = findPatientByMapingCode(brid);
//                    if(patientDO!=null){
//                        if(map.get(brid)==null){
//                            map.put(brid,brid);
//                            logger.info("1.创建门诊记录");
//                            //1.创建门诊记录
//                            WlyyOutpatientDO outpatientDO = saveOutPatient(cfxx,hospitalDO,patientDO,doctor,startDate);
//
//                            logger.info("2.生成处方记录");
//                            //2.生成处方记录
//                            savePrescription(outpatientDO,cfxx,startDate);
//
//
//        DictHospitalDeptDO deptDO = new DictHospitalDeptDO();
////        deptDO.setId(5);
//        deptDO.setOrgCode("test");
//        deptDO.setCode("test");
//        deptDO.setName("test");
//        deptDO.setConsultDeptFlag("test");
//        deptDO.setCreateTime(new Date());
//        hospitalDeptDao.save(deptDO);
//                            logger.info("3.医生评价");
//                            //3.医生评价
//                            saveDoctorScore(outpatientDO);
//
//
////        BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
////        hospitalDO.setDeptName("test");
////        hospitalDO.setDeptCode("test");
////        hospitalDO.setOrgCode("test");
////        hospitalDO.setOrgName("test");
////        hospitalDO.setDeptCode("test");
////        hospitalDO.setDeptName("test");
////        hospitalDO.setDel("1");
////        baseDoctorHospitalDao.save(hospitalDO);
//        return "ok";
//    }
//                        }
//                    }else{
//                        logger.info("brid:"+brid+" mapping not exist");
//                    }
//                }
//            }
//        }
        return "ok";
    }
    //生成门诊信息
    public WlyyOutpatientDO saveOutPatient(JSONObject cfxx,BaseDoctorHospitalDO hospitalDO,BasePatientDO patientDO,BaseDoctorDO doctor,String startDate){
        WlyyOutpatientDO outpatientDO = new WlyyOutpatientDO();
        outpatientDO.setRegisterNo(cfxx.getString("JZXH"));
        outpatientDO.setOutpatientType("1");
        outpatientDO.setType("1");
        outpatientDO.setHospital(orgCode);
        outpatientDO.setHospitalName(orgName);
        outpatientDO.setDept(hospitalDO.getDeptCode());
        outpatientDO.setDeptName(hospitalDO.getDeptName());
        outpatientDO.setPatient(patientDO.getId());
        outpatientDO.setPatientName(patientDO.getName());
        outpatientDO.setDoctor(doctor.getId());
        outpatientDO.setDoctorName(doctor.getName());
        outpatientDO.setIdcard(patientDO.getIdcard());
        outpatientDO.setMjz("mz");
        outpatientDO.setIcd10(cfxx.getString("ICD"));
        outpatientDO.setIcd10Name(cfxx.getString("JBMC"));
        outpatientDO.setAdvice("注意休息,防止过度疲劳");
        outpatientDO.setStatus("2");
        outpatientDO.setDescription("身体不舒服,焦虑");
        outpatientDO.setCreateTime(DateUtil.strToDate(startDate+" 08:30:00","yyyy-MM-dd HH:mm:ss"));
        outpatientDO.setDiseaseImg("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1583567535353&di=6529f7ff05e79c26f37e0176adcb3241&imgtype=0&src=http%3A%2F%2Fimages.669pic.com%2Felement_pic%2F74%2F70%2F44%2F48%2F8997cd56af062ce6e1ca3da37506f3c9.jpg");
        outpatientDO.setConNo(cfxx.getString("JZXH"));
        outpatientDO.setRegisterDate(DateUtil.strToDate(startDate+" 08:30:00","yyyy-MM-dd HH:mm:ss"));
        outpatientDO.setEvaluateStatus("1");
        outpatientDO.setEndTime(DateUtil.strToDate(startDate+" 09:30:00","yyyy-MM-dd HH:mm:ss"));
        outpatientDO.setAdmNo("001");
        return outpatientDao.save(outpatientDO);
    }
    public void savePrescription(WlyyOutpatientDO outpatientDO,JSONObject cfxx,String startDate){
        WlyyPrescriptionDO prescriptionDO = new WlyyPrescriptionDO();
        prescriptionDO.setOutpatientId(outpatientDO.getId());
        prescriptionDO.setRealOrder(cfxx.getString("CFHM"));
        prescriptionDO.setSerialNo(cfxx.getString("JZXH"));
        prescriptionDO.setType(1);
        prescriptionDO.setPatientCode(outpatientDO.getPatient());
        prescriptionDO.setPatientName(outpatientDO.getPatientName());
        prescriptionDO.setIdcard(outpatientDO.getIdcard());
        prescriptionDO.setSsc(outpatientDO.getCardNo());
        prescriptionDO.setDoctor(outpatientDO.getDoctor());
        prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
        prescriptionDO.setStatus(100);
        prescriptionDO.setCreateTime(DateUtil.strToDate(startDate+" 09:00:00","yyyy-MM-dd HH:mm:ss"));
        prescriptionDO.setDept(outpatientDO.getDept());
        prescriptionDO.setDeptName(outpatientDO.getDeptName());
        prescriptionDO.setHospital(outpatientDO.getHospital());
        prescriptionDO.setHospitalName(outpatientDO.getHospitalName());
        prescriptionDO.setRemark("001");
        prescriptionDO.setDiseaseImg("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1583567535353&di=6529f7ff05e79c26f37e0176adcb3241&imgtype=0&src=http%3A%2F%2Fimages.669pic.com%2Felement_pic%2F74%2F70%2F44%2F48%2F8997cd56af062ce6e1ca3da37506f3c9.jpg");
        prescriptionDO.setDrugFee(cfxx.getDouble("HJJE"));
        prescriptionDO.setInspectFee(0D);
        prescriptionDO.setRegFee(0D);
        WlyyPrescriptionDO temp = prescriptionDao.save(prescriptionDO);
        WlyyPrescriptionInfoDO info = new WlyyPrescriptionInfoDO();
        info.setPrescriptionId(temp.getId());
        info.setDrugNo(cfxx.getString("PYDM"));
        info.setDrugName(cfxx.getString("YPMC"));
        info.setDosage(cfxx.getString("YPJL"));
        info.setQuantity(cfxx.getString("YPSL"));
        //计量单位
        info.setUnitName(cfxx.getString("JLDW"));
        //包装单位
        info.setPackUnitName(cfxx.getString("YFDW"));
        //用法
        info.setSupplyCode(cfxx.getString("GYFF"));
        info.setSupplyName(cfxx.getString("GYFFMC"));
        //规格
        info.setSpecification(cfxx.getString("YFGG"));
        info.setDel(1);
        info.setUsageCode(cfxx.getString("YPYF"));
        info.setUsageName(cfxx.getString("YPYF"));
        //药品单价
        info.setPackRetprice(cfxx.getDouble("YPDJ"));
        info.setComm("001");
        prescriptionInfoDao.save(info);
    }
    public void saveDoctorScore(WlyyOutpatientDO outpatientDO){
        BaseEvaluateScoreDO scoreDO = new BaseEvaluateScoreDO();
        scoreDO.setHospital(orgCode);
        scoreDO.setHospital(orgName);
        scoreDO.setDoctor(outpatientDO.getDoctor());
        scoreDO.setDoctorName(outpatientDO.getDoctorName());
        scoreDO.setPatient(outpatientDO.getPatient());
        scoreDO.setPatientName(outpatientDO.getPatientName());
        scoreDO.setEvaluateType(1);
        scoreDO.setScore(100D);
        scoreDO.setType(1);
        scoreDO.setRelationCode("001");
        BaseEvaluateScoreDO temp = baseEvaluateScoreDao.save(scoreDO);
        BaseEvaluateDO evaluateDO = new BaseEvaluateDO();
        evaluateDO.setRelationCode(temp.getId());
        evaluateDO.setScore(1D);
        evaluateDO.setScoreType("4");
        evaluateDO.setContent("五星好评!");
        baseEvaluateDao.save(evaluateDO);
    }
    /**
     * 获取医生信息
     * @param mappingCode
     * @return
     */
    public BaseDoctorDO findByMapingCode(String mappingCode){
        String sql = "SELECT " +
                " map.doctor AS \"doctor\" " +
                " FROM " +
                " base_doctor_mapping map " +
                " WHERE " +
                " map.org_code ='350211A5004' " +
                " AND map.mapping_code ='"+mappingCode+"' ";
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        if(list!=null&&list.size()>0){
            BaseDoctorDO doctorDO = baseDoctorDao.findById(list.get(0).get("doctor").toString());
            return doctorDO;
        }
        return null;
    }
    //获取部门
    public BaseDoctorHospitalDO getDept(String doctor){
        List<BaseDoctorHospitalDO> list =  baseDoctorHospitalDao.findByDoctorCode(doctor);
        if(list!=null&&list.size()>0){
            return list.get(0);
        }
        return null;
    }
    //获取居民信息
    public BasePatientDO findPatientByMapingCode(String mappingCode){
        PatientMappingDO patientMappingDO = patientMappingDao.findByMappingCodeAndSource(mappingCode,"1");
        if(patientMappingDO==null){
            return null;
        }
        BasePatientDO patientDO = basePatientDao.findById(patientMappingDO.getPatient());
        return patientDO;
    }
}
}

+ 14 - 5
business/base-service/src/main/java/com/yihu/jw/internet/entity/InternetUpLogDO.java

@ -2,6 +2,7 @@ package com.yihu.jw.internet.entity;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Table;
@ -16,7 +17,7 @@ public class InternetUpLogDO {
    private String id; //上传批次
    private String id; //上传批次
    private String code;//监管平台任务编码',
    private String code;//监管平台任务编码',
    private Date date;//执行日期',
    private Date createDate;//执行日期',
    private Date startDate;//开始时间',
    private Date startDate;//开始时间',
    private Date endDate;//结束时间',
    private Date endDate;//结束时间',
    private Integer suc;//成功条数',
    private Integer suc;//成功条数',
@ -33,6 +34,7 @@ public class InternetUpLogDO {
        this.id = id;
        this.id = id;
    }
    }
    @Column(name = "code")
    public String getCode() {
    public String getCode() {
        return code;
        return code;
    }
    }
@ -41,14 +43,16 @@ public class InternetUpLogDO {
        this.code = code;
        this.code = code;
    }
    }
    public Date getDate() {
        return date;
    @Column(name = "create_date")
    public Date getCreateDate() {
        return createDate;
    }
    }
    public void setDate(Date date) {
        this.date = date;
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
    }
    @Column(name = "start_date")
    public Date getStartDate() {
    public Date getStartDate() {
        return startDate;
        return startDate;
    }
    }
@ -57,6 +61,7 @@ public class InternetUpLogDO {
        this.startDate = startDate;
        this.startDate = startDate;
    }
    }
    @Column(name = "end_date")
    public Date getEndDate() {
    public Date getEndDate() {
        return endDate;
        return endDate;
    }
    }
@ -65,6 +70,7 @@ public class InternetUpLogDO {
        this.endDate = endDate;
        this.endDate = endDate;
    }
    }
    @Column(name = "suc")
    public Integer getSuc() {
    public Integer getSuc() {
        return suc;
        return suc;
    }
    }
@ -73,6 +79,7 @@ public class InternetUpLogDO {
        this.suc = suc;
        this.suc = suc;
    }
    }
    @Column(name = "err")
    public Integer getErr() {
    public Integer getErr() {
        return err;
        return err;
    }
    }
@ -81,6 +88,7 @@ public class InternetUpLogDO {
        this.err = err;
        this.err = err;
    }
    }
    @Column(name = "data_err")
    public Integer getDataErr() {
    public Integer getDataErr() {
        return dataErr;
        return dataErr;
    }
    }
@ -89,6 +97,7 @@ public class InternetUpLogDO {
        this.dataErr = dataErr;
        this.dataErr = dataErr;
    }
    }
    @Column(name = "remark")
    public String getRemark() {
    public String getRemark() {
        return remark;
        return remark;
    }
    }

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

@ -1634,7 +1634,7 @@ public class InternetService extends BaseJpaService<InternetUpErrorLogDO, IntUpE
        internetUpLogDO.setCode(code);
        internetUpLogDO.setCode(code);
        internetUpLogDO.setStartDate(startDate);
        internetUpLogDO.setStartDate(startDate);
        internetUpLogDO.setEndDate(endDate);
        internetUpLogDO.setEndDate(endDate);
        internetUpLogDO.setDate(new Date());
        internetUpLogDO.setCreateDate(new Date());
        internetUpLogDO.setSuc(suc);
        internetUpLogDO.setSuc(suc);
        internetUpLogDO.setErr(err);
        internetUpLogDO.setErr(err);
        internetUpLogDO.setDataErr(dataErr);
        internetUpLogDO.setDataErr(dataErr);

File diff suppressed because it is too large
+ 578 - 497
business/base-service/src/main/java/com/yihu/jw/internet/service/ykyy/YkyyInternetService.java


+ 7 - 1
business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java

@ -49,6 +49,12 @@ public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String
    List<BaseOrgDO> findByCityCodeAndLevel(String cityCode,Integer level);
    List<BaseOrgDO> findByCityCodeAndLevel(String cityCode,Integer level);
    List<BaseOrgDO> findByDel(String del);
    List<BaseOrgDO> findByDel(String del);
    @Query(value="select b.* from base_org b where b.del=?1  and b.name like ?2 ORDER BY sort DESC",nativeQuery = true)
    List<BaseOrgDO> findByDelAndName(String del,String name);
    
    @Query(value="select b.* from base_org b where b.level= ?1 and b.del=?2  and b.name like ?3 ORDER BY sort DESC",nativeQuery = true)
    List<BaseOrgDO> findByLevelAndName(Integer level,String del,String name);
    
    @Query(value="select b.* from base_org b where b.level= ?1 and b.del=?2 ORDER BY sort DESC",nativeQuery = true)
    List<BaseOrgDO> findByLevelAndDel(Integer level,String del);
    List<BaseOrgDO> findByLevelAndDel(Integer level,String del);
}
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author huangwenjie
 * @date 2020/3/9 09:57
 */
public interface BaseDoctorPatientFollowDao extends PagingAndSortingRepository<BaseDoctorPatientFollowDO, String>, JpaSpecificationExecutor<BaseDoctorPatientFollowDO> {
	
	List<BaseDoctorPatientFollowDO> findByDoctorAndPatient(String doctor, String patient);
}

+ 4 - 1
business/base-service/src/main/java/com/yihu/jw/utils/ImgUtils.java

@ -78,6 +78,9 @@ public class ImgUtils {
        }
        }
        //对字节数组Base64编码
        //对字节数组Base64编码
        BASE64Encoder encoder = new BASE64Encoder();
        BASE64Encoder encoder = new BASE64Encoder();
        return encoder.encode(data);//返回Base64编码过的字节数组字符串
        if(data!=null){
            return encoder.encode(data);//返回Base64编码过的字节数组字符串
        }
        return "0";
    }
    }
}
}

+ 62 - 0
business/base-service/src/main/java/com/yihu/jw/utils/PinYinUtils.java

@ -0,0 +1,62 @@
package com.yihu.jw.utils;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
/**
 * @author huangwenjie
 * @date 2020/3/13 09:32
 */
public class PinYinUtils {
	 //将中文转换为英文
	public static String getEname(String name) throws  Exception
    {
		HanyuPinyinOutputFormat pyFormat = new HanyuPinyinOutputFormat();
		pyFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
		pyFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
		pyFormat.setVCharType(HanyuPinyinVCharType.WITH_V);
		
		return PinyinHelper.toHanyuPinyinString(name, pyFormat, "");
	}
	
	//姓、名的第一个字母需要为大写
	public static String getUpEname(String name) throws  Exception {
		char[] strs = name.toCharArray();
		String newname = null;
		
		//名字的长度
		if (strs.length == 2) {
			newname = toUpCase(getEname("" + strs[0])) + " "
					+ toUpCase(getEname("" + strs[1]));
		} else if (strs.length == 3)
		{
			newname = toUpCase(getEname("" + strs[0])) + " "
					+ toUpCase(getEname("" + strs[1] + strs[2]));
		}
		else if (strs.length == 4)
		{
			newname = toUpCase(getEname("" + strs[0] + strs[1])) + " "
					+ toUpCase(getEname("" + strs[2] + strs[3]));
		} else
		{
			newname = toUpCase(getEname(name));
		}
		return newname;
	}
	
	//首字母大写
	private static String toUpCase(String str) {
		StringBuffer newstr = new StringBuffer();
		newstr.append((str.substring(0, 1)).toUpperCase()).append(
				str.substring(1, str.length()));
		
		return newstr.toString();
	}
	public static void main(String[] args)  throws  Exception{
		System.out.println(getUpEname("李宇春"));
		
	}
}

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/BasePatientWechatDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.wechat.dao;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author huangwenjie
 * @date 2020/3/10 14:43
 */
public interface BasePatientWechatDao extends
		PagingAndSortingRepository<BasePatientWechatDo, String>,
		JpaSpecificationExecutor<BasePatientWechatDo> {
	
	List<BasePatientWechatDo> findByWechatIdAndPatientId (String wechatid,String patientId);
}

+ 48 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WxTemplateService.java

@ -1,20 +1,24 @@
package com.yihu.jw.base.service.wx;
package com.yihu.jw.wechat.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateDO;
import com.yihu.jw.entity.base.wx.WxTemplateDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.dao.WxTemplateDao;
import com.yihu.jw.wechat.dao.WxTemplateDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.ArrayList;
@ -40,6 +44,47 @@ public class WxTemplateService {
    @Autowired
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    private WeixinMessagePushUtils weixinMessagePushUtils;
    @Value("${wechat.id}")
    private String wechatId;
    
    @Autowired
    private BasePatientDao basePatientDao;
    
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    
    
    /**
     * 发送微信模版消息-小程序视频
     * @param sender_id 发送者ID
     * @param sender_name 发送者姓名
     * @param reciver_id 接收者ID
     * @param reciver_name 接收者姓名
     * @param session_id 会话ID
     */
    public String sendWeTempMesMiniProgram(String sender_id, String sender_name, String reciver_id, String reciver_name,String session_id)throws Exception {
        BasePatientDO basePatientDO = basePatientDao.findById(reciver_id);
        if(basePatientDO!=null){
            List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,reciver_id);
            if(ps.isEmpty()){
                logger.info("该用户"+reciver_name+"没有openid,无法推送模版消息,用户ID:"+reciver_id+"wechatId:"+wechatId);
            }else{
                for (BasePatientWechatDo basePatientWechatDo:ps){
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_consult_notice","spthtx",1);
                    config.setFirst(config.getFirst().replace("key1",sender_name));
                    config.setPagepath(config.getPagepath()+""+reciver_id+"&doctorName="+sender_name+"&role=patient&roomID="+session_id+"&template=1v1&debugMode=false&cloudenv=PRO");
                    weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                }
            }
        }else{
            throw new Exception("接收者ID错误,无法找到该账号");
        }
        return "success";
    }
    
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_survey","test",1);
        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_survey","test",1);
        config.setFirst(config.getFirst().replace("key1","小明"));
        config.setFirst(config.getFirst().replace("key1","小明"));
@ -93,4 +138,5 @@ public class WxTemplateService {
        }
        }
        return rs;
        return rs;
    }
    }
}
}

+ 4 - 1
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -479,7 +479,10 @@ public class WlyyBusinessService {
                                doctor.setCityName(doctorJson.getString("cityName"));
                                doctor.setCityName(doctorJson.getString("cityName"));
                                doctor.setExpertise(doctorJson.getString("expertise"));
                                doctor.setExpertise(doctorJson.getString("expertise"));
                                doctor.setIntroduce(doctorJson.getString("introduce"));
                                doctor.setIntroduce(doctorJson.getString("introduce"));
//                                String salt = randomString(5);
//                                String pw = idcard.substring(idcard.length() - 6);
//                                doctor.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
//                                doctor.setSalt(salt);
                                String jobName = doctorJson.getString("jobName");
                                String jobName = doctorJson.getString("jobName");
                                doctor.setJobTitleCode(getDutysCode(dutys, jobName));
                                doctor.setJobTitleCode(getDutysCode(dutys, jobName));

+ 533 - 27
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -24,10 +24,13 @@ import org.apache.commons.lang3.StringUtils;
import org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParametersFactory;
import org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParametersFactory;
import org.omg.CORBA.OBJ_ADAPTER;
import org.omg.CORBA.OBJ_ADAPTER;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import javax.xml.soap.SAAJMetaFactory;
import javax.xml.soap.SAAJMetaFactory;
import java.security.acl.LastOwnerException;
import java.security.acl.LastOwnerException;
import java.text.DecimalFormat;
import java.text.DecimalFormat;
@ -39,8 +42,11 @@ import java.util.*;
 * Created by wangzhinan on 2019/12/3.
 * Created by wangzhinan on 2019/12/3.
 */
 */
@Service
@Service
@Transactional
public class StatisticsEsService {
public class StatisticsEsService {
    Logger logger = LoggerFactory.getLogger(StatisticsEsService.class);
    @Autowired
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    @Autowired
@ -113,9 +119,11 @@ public class StatisticsEsService {
        object.put("prescriptionRate",prescriptionRate);//开方率
        object.put("prescriptionRate",prescriptionRate);//开方率
        String startTime = DateUtil.getStringDateShort()+" 00:00:00";
        String startTime = DateUtil.getStringDateShort()+" 00:00:00";
        String endTime = DateUtil.getStringDateShort() +" 23:59:59";
        String endTime = DateUtil.getStringDateShort() +" 23:59:59";
        String sql = "select count(*) as total from base.wlyy_outpatient o where o.status=2 and o.create_time >='"+startTime+"' and o.create_time <='"+endTime+"'";
        String sql = "select count(*) as total from base.wlyy_consult_oupatient_info o where  o.create_time >='"+startTime+"' and o.create_time <='"+endTime+"'";
        if (level==4){
        if (level==4){
            sql += " and o.doctor IN (SELECT doctor_code FROM `base_doctor_hospital` dh where dh.org_code ='"+area+"' and dh.del=1)";
            sql += " and o.doctor IN (SELECT doctor_code FROM `base_doctor_hospital` dh where dh.org_code ='"+area+"' and dh.del=1)";
        }if (level==2){
            sql += " 1=1 ";
        }else if (level==5){
        }else if (level==5){
            sql += " and o.doctor IN (SELECT doctor_code FROM `base_doctor_hospital` dh where dh.dept_code ='"+area+"' and dh.del=1)";
            sql += " and o.doctor IN (SELECT doctor_code FROM `base_doctor_hospital` dh where dh.dept_code ='"+area+"' and dh.del=1)";
        }else if (level==6){
        }else if (level==6){
@ -150,6 +158,7 @@ public class StatisticsEsService {
     * @throws Exception
     * @throws Exception
     */
     */
    public JSONObject getOutPatientLine(String startDate, String endDate, String area, int level, String index,int interval, String level2_type) throws Exception {
    public JSONObject getOutPatientLine(String startDate, String endDate, String area, int level, String index,int interval, String level2_type) throws Exception {
        logger.info("service index:"+index+" and level2_type:"+level2_type+" and level:"+level);
        //问诊量
        //问诊量
        JSONObject object = new JSONObject();
        JSONObject object = new JSONObject();
        if (interval==1){
        if (interval==1){
@ -175,15 +184,15 @@ public class StatisticsEsService {
            JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,"5","16",SaveModel.timeLevel_ZL);
            JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,"5","16",SaveModel.timeLevel_ZL);
            object.put("vedioData",array4);
            object.put("vedioData",array4);
        }else if (interval==3){
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            object.put("data",array);
            JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,"5","1",SaveModel.timeLevel_ZL);
            JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,"5","1",SaveModel.timeLevel_ZL,null);
            object.put("specialistData",array1);
            object.put("specialistData",array1);
            JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,"5","9",SaveModel.timeLevel_ZL);
            JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,"5","9",SaveModel.timeLevel_ZL,null);
            object.put("topicData",array2);
            object.put("topicData",array2);
            JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,"5","12",SaveModel.timeLevel_ZL);
            JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,"5","12",SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            object.put("synergyData",array3);
            JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,"5","16",SaveModel.timeLevel_ZL);
            JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,"5","16",SaveModel.timeLevel_ZL,null);
            object.put("vedioData",array4);
            object.put("vedioData",array4);
        }
        }
        if (StringUtils.isNoneBlank(level2_type)){
        if (StringUtils.isNoneBlank(level2_type)){
@ -200,6 +209,283 @@ public class StatisticsEsService {
            JSONArray array = new JSONArray();
            JSONArray array = new JSONArray();
            List<String> list = new ArrayList<>();
            List<String> list = new ArrayList<>();
            for (SaveModel saveModel:syngySaveModels){
                if (level2_type.equals(SaveModel.OrgLevel)){
                    if (StringUtils.isNoneBlank(saveModel.getHospital())){
                        list.add(saveModel.getHospital());
                    }
                }else if (level2_type.equals(SaveModel.deptLevel)){
                    if (StringUtils.isNoneBlank(saveModel.getDept())){
                        list.add(saveModel.getDept());
                    }
                }else if (level2_type.equals(SaveModel.doctorLevel)){
                    if (StringUtils.isNoneBlank(saveModel.getDoctor())){
                        list.add(saveModel.getDoctor());
                    }
                }
            }
            for (int i=0;i<list.size();i++){
                String code = list.get(i);
                JSONObject jsonObject = new JSONObject();
                Double specialist = 0.0;
                Double topic = 0.0;
                Double vedio =0.0;
                Double synegy =0.0;
                if (index.equalsIgnoreCase("3")){
                    specialist = 0.0;
                }else if (index.equalsIgnoreCase("5")){
                    for (SaveModel saveModel:specialistSaveModels){
                        if (level2_type.equals(SaveModel.OrgLevel)){
                            if (StringUtils.isNoneBlank(saveModel.getHospital())&&code.equalsIgnoreCase(saveModel.getHospital())){
                                jsonObject.put("code",code);
                                jsonObject.put("name",saveModel.getHospitalName());
                                jsonObject.put("specialist",saveModel.getResult1());
                                specialist = saveModel.getResult1();
                                break;
                            }
                        }else if (level2_type.equals(SaveModel.deptLevel)){
                            if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                                jsonObject.put("code",code);
                                jsonObject.put("name",saveModel.getDeptName());
                                jsonObject.put("specialist",saveModel.getResult1());
                                specialist = saveModel.getResult1();
                                break;
                            }
                        }else if (level2_type.equals(SaveModel.doctorLevel)){
                            if (StringUtils.isNoneBlank(saveModel.getDoctor())&&code.equalsIgnoreCase(saveModel.getDoctor())){
                                if (level==6){
                                    List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(area);
                                    if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
                                        BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
                                        jsonObject.put("code",doctorHospitalDO.getDeptCode());
                                        jsonObject.put("name",doctorHospitalDO.getDeptName());
                                    }
                                }else {
                                    DictHospitalDeptDO dictHospitalDeptDO =  hospitalDeptDao.findByCode(area);
                                    jsonObject.put("code",area);
                                    jsonObject.put("name",dictHospitalDeptDO.getName());
                                }
                                jsonObject.put("doctorCode",code);
                                BaseDoctorDO doctorDO = doctorDao.findById(code);
                                if (doctorDO!=null){
                                    jsonObject.put("doctorJob",doctorDO.getJobTitleName());
                                }else {
                                    jsonObject.put("doctorJob",null);
                                }
                                jsonObject.put("doctorName",saveModel.getDoctorName());
                                jsonObject.put("specialist",saveModel.getResult1());
                                specialist = saveModel.getResult1();
                                break;
                            }
                        }
                    }
                }
                for (SaveModel saveModel:syngySaveModels){
                    if (level2_type.equals(SaveModel.OrgLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getHospital())&&code.equalsIgnoreCase(saveModel.getHospital())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getHospitalName());
                            jsonObject.put("synegy",saveModel.getResult1());
                            synegy = saveModel.getResult1();
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.deptLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("synegy",saveModel.getResult1());
                            synegy = saveModel.getResult1();
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.doctorLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDoctor())&&code.equalsIgnoreCase(saveModel.getDoctor())){
                            if (level==6){
                                List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(area);
                                if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
                                    BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
                                    jsonObject.put("code",doctorHospitalDO.getDeptCode());
                                    jsonObject.put("name",doctorHospitalDO.getDeptName());
                                }
                            }else {
                                DictHospitalDeptDO dictHospitalDeptDO =  hospitalDeptDao.findByCode(area);
                                jsonObject.put("code",area);
                                jsonObject.put("name",dictHospitalDeptDO.getName());
                            }
                            BaseDoctorDO doctorDO = doctorDao.findById(code);
                            if (doctorDO!=null){
                                jsonObject.put("doctorJob",doctorDO.getJobTitleName());
                            }else {
                                jsonObject.put("doctorJob",null);
                            }
                            jsonObject.put("doctorCode",code);
                            jsonObject.put("doctorName",saveModel.getDoctorName());
                            jsonObject.put("synegy",saveModel.getResult1());
                            synegy = saveModel.getResult1();
                            break;
                        }
                    }
                }
                for (SaveModel saveModel:topicSaveModels){
                    if (level2_type.equals(SaveModel.OrgLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getHospital())&&code.equalsIgnoreCase(saveModel.getHospital())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getHospitalName());
                            jsonObject.put("topic",saveModel.getResult1());
                            topic = saveModel.getResult1();
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.deptLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("topic",saveModel.getResult1());
                            topic = saveModel.getResult1();
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.doctorLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDoctor())&&code.equalsIgnoreCase(saveModel.getDoctor())){
                            if (level==6){
                                List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(area);
                                if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
                                    BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
                                    jsonObject.put("code",doctorHospitalDO.getDeptCode());
                                    jsonObject.put("name",doctorHospitalDO.getDeptName());
                                }
                            }else {
                                DictHospitalDeptDO dictHospitalDeptDO =  hospitalDeptDao.findByCode(area);
                                jsonObject.put("code",area);
                                jsonObject.put("name",dictHospitalDeptDO.getName());
                            }
                            BaseDoctorDO doctorDO = doctorDao.findById(code);
                            if (doctorDO!=null){
                                jsonObject.put("doctorJob",doctorDO.getJobTitleName());
                            }else {
                                jsonObject.put("doctorJob",null);
                            }
                            jsonObject.put("doctorCode",code);
                            jsonObject.put("doctorName",saveModel.getDoctorName());
                            jsonObject.put("topic",saveModel.getResult1());
                            topic = saveModel.getResult1();
                            break;
                        }
                    }
                }
                for (SaveModel saveModel:vedioSaveModels){
                    if (level2_type.equals(SaveModel.OrgLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getHospital())&&code.equalsIgnoreCase(saveModel.getHospital())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getHospitalName());
                            jsonObject.put("vedio",saveModel.getResult1());
                            vedio = saveModel.getResult1();
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.deptLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("vedio",saveModel.getResult1());
                            vedio = saveModel.getResult1();
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.doctorLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDoctor())&&code.equalsIgnoreCase(saveModel.getDoctor())){
                            if (level==6){
                                List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(area);
                                if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
                                    BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
                                    jsonObject.put("code",doctorHospitalDO.getDeptCode());
                                    jsonObject.put("name",doctorHospitalDO.getDeptName());
                                }
                            }else {
                                DictHospitalDeptDO dictHospitalDeptDO =  hospitalDeptDao.findByCode(area);
                                jsonObject.put("code",area);
                                jsonObject.put("name",dictHospitalDeptDO.getName());
                            }
                            jsonObject.put("doctorCode",code);
                            BaseDoctorDO doctorDO = doctorDao.findById(code);
                            if (doctorDO!=null){
                                jsonObject.put("doctorJob",doctorDO.getJobTitleName());
                            }else {
                                jsonObject.put("doctorJob",null);
                            }
                            jsonObject.put("doctorName",saveModel.getDoctorName());
                            jsonObject.put("vedio",saveModel.getResult1());
                            vedio = saveModel.getResult1();
                            break;
                        }
                    }
                }
                Double total1 = topic+vedio ;//图文和视频总和
                Double total = topic+vedio+synegy+specialist;//总和
                jsonObject.put("total1",total1);//图文和视频总和
                jsonObject.put("total",total);//总和
                array.add(jsonObject);
            }
            object.put("excelData",array);
        }
        return object;
    }
    public JSONObject getOutPatientPriceLine(String startDate, String endDate, String area, int level, String index,int interval, String level2_type) throws Exception {
        logger.info("service index:"+index+" and level2_type:"+level2_type+" and level:"+level);
        //问诊量
        JSONObject object = new JSONObject();
        if (interval==1){
            JSONArray array = dateTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            JSONArray array1 = dateTotalStatistics2(startDate,endDate,area,level,"3","3",SaveModel.timeLevel_ZL,null);
            object.put("specialistData",array1);
            JSONArray array2 = dateTotalStatistics2(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"1");
            object.put("topicData",array2);
            JSONArray array3 = dateTotalStatistics2(startDate,endDate,area,level,"3","2",SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = dateTotalStatistics2(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"2");
            object.put("vedioData",array4);
        }else if (interval==2){
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
            JSONArray array1 = weekTotalStatistics2(startDate,endDate,area,level,"3","3",SaveModel.timeLevel_ZL,"1");
            object.put("specialistData",array1);
            JSONArray array2 = weekTotalStatistics2(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"1");
            object.put("topicData",array2);
            JSONArray array3 = weekTotalStatistics2(startDate,endDate,area,level,"3","2",SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = weekTotalStatistics2(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"2");
            object.put("vedioData",array4);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,"3","3",SaveModel.timeLevel_ZL,"1");
            object.put("specialistData",array1);
            JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"1");
            object.put("topicData",array2);
            JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,"3","2",SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"2");
            object.put("vedioData",array4);
        }
        if (StringUtils.isNoneBlank(level2_type)){
            //问诊量表格
            //专家咨询数量
            List<SaveModel> specialistSaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"3",null,level2_type);
            //协同门诊
            List<SaveModel> syngySaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"2",null,level2_type);
            //图文复诊
            List<SaveModel> topicSaveModels = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1","1",null,level2_type);
            ///视频复诊
            List<SaveModel> vedioSaveModels = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1","2",null,level2_type);
            JSONArray array = new JSONArray();
            List<String> list = new ArrayList<>();
            for (SaveModel saveModel:syngySaveModels){
            for (SaveModel saveModel:syngySaveModels){
                if (level2_type.equals(SaveModel.deptLevel)){
                if (level2_type.equals(SaveModel.deptLevel)){
                    if (StringUtils.isNoneBlank(saveModel.getDept())){
                    if (StringUtils.isNoneBlank(saveModel.getDept())){
@ -211,6 +497,11 @@ public class StatisticsEsService {
                        list.add(saveModel.getDoctor());
                        list.add(saveModel.getDoctor());
                    }
                    }
                }else if (level2_type.equals(SaveModel.OrgLevel)){
                    if (StringUtils.isNoneBlank(saveModel.getHospital())){
                        list.add(saveModel.getHospital());
                    }
                }
                }
            }
            }
            for (int i=0;i<list.size();i++){
            for (int i=0;i<list.size();i++){
@ -224,7 +515,15 @@ public class StatisticsEsService {
                    specialist = 0.0;
                    specialist = 0.0;
                }else if (index.equalsIgnoreCase("5")){
                }else if (index.equalsIgnoreCase("5")){
                    for (SaveModel saveModel:specialistSaveModels){
                    for (SaveModel saveModel:specialistSaveModels){
                        if (level2_type.equals(SaveModel.deptLevel)){
                        if (level2_type.equals(SaveModel.OrgLevel)){
                            if (StringUtils.isNoneBlank(saveModel.getHospital())&&code.equalsIgnoreCase(saveModel.getHospital())){
                                jsonObject.put("code",code);
                                jsonObject.put("name",saveModel.getHospitalName());
                                jsonObject.put("specialist",saveModel.getResult1());
                                specialist = saveModel.getResult1();
                                break;
                            }
                        }else if (level2_type.equals(SaveModel.deptLevel)){
                            if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                            if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                                jsonObject.put("code",code);
                                jsonObject.put("code",code);
                                jsonObject.put("name",saveModel.getDeptName());
                                jsonObject.put("name",saveModel.getDeptName());
@ -265,7 +564,15 @@ public class StatisticsEsService {
                }
                }
                for (SaveModel saveModel:syngySaveModels){
                for (SaveModel saveModel:syngySaveModels){
                    if (level2_type.equals(SaveModel.deptLevel)){
                    if (level2_type.equals(SaveModel.OrgLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getHospital())&&code.equalsIgnoreCase(saveModel.getHospital())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getHospitalName());
                            jsonObject.put("synegy",saveModel.getResult1());
                            synegy = saveModel.getResult1();
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.deptLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("code",code);
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("name",saveModel.getDeptName());
@ -303,7 +610,15 @@ public class StatisticsEsService {
                    }
                    }
                }
                }
                for (SaveModel saveModel:topicSaveModels){
                for (SaveModel saveModel:topicSaveModels){
                    if (level2_type.equals(SaveModel.deptLevel)){
                    if (level2_type.equals(SaveModel.OrgLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getHospital())&&code.equalsIgnoreCase(saveModel.getHospital())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getHospitalName());
                            jsonObject.put("topic",saveModel.getResult1());
                            synegy = saveModel.getResult1();
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.deptLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("code",code);
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("name",saveModel.getDeptName());
@ -340,7 +655,15 @@ public class StatisticsEsService {
                    }
                    }
                }
                }
                for (SaveModel saveModel:vedioSaveModels){
                for (SaveModel saveModel:vedioSaveModels){
                    if (level2_type.equals(SaveModel.deptLevel)){
                    if (level2_type.equals(SaveModel.OrgLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getHospital())&&code.equalsIgnoreCase(saveModel.getHospital())){
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getHospitalName());
                            jsonObject.put("vedio",saveModel.getResult1());
                            vedio = saveModel.getResult1();
                            break;
                        }
                    }else  if (level2_type.equals(SaveModel.deptLevel)){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                        if (StringUtils.isNoneBlank(saveModel.getDept())&&code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("code",code);
                            jsonObject.put("code",code);
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("name",saveModel.getDeptName());
@ -1311,6 +1634,172 @@ public class StatisticsEsService {
    }
    }
    private JSONArray weekTotalStatistics2(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel,String lowCode2) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        // 起始日期
        Calendar start = Calendar.getInstance();
        start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
        // 第一个统计周期结束日期
        String firstEnd = "";
        // 结束日期
        Calendar end = Calendar.getInstance();
        //因为统计时间是统计到当前时间的前一天,所以这里的时间是提前一天
        Calendar temp = Calendar.getInstance();
        temp.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
//        temp.add(Calendar.DAY_OF_MONTH, -1);
        end.setTime(temp.getTime());
        // 起始日期为周几
        int week = start.get(Calendar.DAY_OF_WEEK);
        int incre = 7 - week + 1;
        // 日期集合
        List<Calendar> days = new ArrayList<>();
        days.add(start);
        boolean flag = true;
        int i = 0;
        if (startDate.compareTo(endDate) == 0) {
            flag = false;
            days.add(end);
            firstEnd = df.format(end.getTime());
        }
        // 计算统计日期
        while (flag) {
            Calendar next = Calendar.getInstance();
            next.setTime(days.get(days.size() - 1).getTime());
            if (i == 0) {
                if (incre != 7) {
                    next.add(Calendar.DATE, incre);
                }
            } else {
                next.add(Calendar.DATE, 7);
            }
            if (next.getTime().before(DateUtil.strToDate(endDate, "yyyy-MM-dd"))) {
                days.add(next);
                if (i == 0) {
                    firstEnd = df.format(next.getTime());
                }
            } else {
                days.add(end);
                flag = false;
                if (i == 0) {
                    firstEnd = df.format(end.getTime());
                }
            }
            i++;
        }
        // 结果集
        Map<String, JSONObject> countResult = new HashMap<>();
//        Date dd = df.parse();
        // 算出每个查询周期
        for (int j = 0; j < days.size() - 1; j++) {
            String startStr = "";
            String endStr = df.format(days.get(j + 1).getTime());
            // 起始、截止日期
            if (j == 0) {
                startStr = df.format(days.get(j).getTime());
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(days.get(j).getTime());
                cal.add(Calendar.DATE, 1);
                startStr = df.format(cal.getTime());
            }
            JSONObject range = new JSONObject();
            range.put("range", endStr);
            range.put("amount", 0);
            range.put("num",0.0);
            countResult.put(endStr, range);
//            if(!DateUtil.getSundayOfThisDate(new Date()).equals(df.format(new Date()))){
//                JSONObject range2 = new JSONObject();
//                range2.put("range", endDate);
//                range2.put("amount", 0);
//                countResult.put(df.format(new Date()), range2);
//            };
        }
        if (startDate.equals(df.format(new Date()))) {
            Calendar preDate = Calendar.getInstance();
            preDate.setTime(df.parse(endDate));
            preDate.add(Calendar.DATE, -1);
            startDate = df.format(preDate.getTime());
        }
        List<SaveModel> saveModels = new ArrayList<>();
        if (StringUtils.isNotBlank(lowCode)) {
            if (StringUtils.isNoneBlank(lowCode2)){
                saveModels = elasticsearchUtil.findLineChartDateQuotaLevel2(startDate, endDate, area, level, index, timelevel, SaveModel.interval_week, lowCode,lowCode2);
            }else {
                saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_week, lowCode);
            }
        } else {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_week);
        }
        if (saveModels != null) {
            // 计算结果
            for (SaveModel saveModel : saveModels) {
                String range = "";
                if (saveModel.getQuotaDate() != null) {
                    Calendar quotaDate = Calendar.getInstance();
                    quotaDate.setTime(saveModel.getQuotaDate());
                    quotaDate.add(Calendar.DATE, 6);
                    range = df.format(quotaDate.getTime());
                }
                JSONObject json = countResult.get(range);
//                //因为上述时间集提前一天  但是前端是显示当前时间,所以这里给调整回去
//                if (range.equals(df.format(temp.getTime()))) {
//                    json.put("range", endDate);
//                }
                if (json != null) {
                    long amount = saveModel.getResult2().longValue();
                    double num = saveModel.getResult1();
                    json.put("amount", amount);
                    json.put("num",num);
                }
            }
            List<JSONObject> result = new ArrayList<>(countResult.values());
            // 排序
            result.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if (o1.getString("range").compareTo(o2.getString("range")) > 0) {
                        return 1;
                    } else if (o1.getString("range").compareTo(o2.getString("range")) < 0) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
            });
            JSONArray jsonArray = new JSONArray();
            for (JSONObject object:result){
                jsonArray.add(object);
            }
            return jsonArray;
        } else {
            return new JSONArray();
        }
    }
    /**
    /**
     * 按月统计 折线图
     * 按月统计 折线图
     *
     *
@ -1323,7 +1812,7 @@ public class StatisticsEsService {
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    private JSONArray monthTotalStatistics2(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel) throws Exception {
    private JSONArray monthTotalStatistics2(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel,String lowCode2) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
@ -1394,7 +1883,11 @@ public class StatisticsEsService {
        }
        }
        List<SaveModel> saveModels = new ArrayList<>();
        List<SaveModel> saveModels = new ArrayList<>();
        if (StringUtils.isNotBlank(lowCode)) {
        if (StringUtils.isNotBlank(lowCode)) {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_month, lowCode);
            if (StringUtils.isNoneBlank(lowCode2)){
                saveModels = elasticsearchUtil.findLineChartDateQuotaLevel2(startDate, endDate, area, level, index, timelevel, SaveModel.interval_month, lowCode,lowCode2);
            }else {
                saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_month, lowCode);
            }
        } else {
        } else {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_month);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_month);
        }
        }
@ -1644,7 +2137,7 @@ public class StatisticsEsService {
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
            object.put("data",array);
        }else if (interval==3){
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            object.put("data",array);
        }
        }
        return object;
        return object;
@ -1932,7 +2425,7 @@ public class StatisticsEsService {
        }else if (interval==2){
        }else if (interval==2){
            array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
        }else if (interval==3){
        }else if (interval==3){
            array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
        }
        }
        for (int i=0;i<array.size();i++){
        for (int i=0;i<array.size();i++){
            JSONObject jsonObject = array.getJSONObject(i);
            JSONObject jsonObject = array.getJSONObject(i);
@ -2168,11 +2661,24 @@ public class StatisticsEsService {
            resultMaps.add(rs);
            resultMaps.add(rs);
        }
        }
        //根据为回复数排序
        //根据为回复数排序
        Collections.sort(resultMaps, new Comparator<Map<String, Object>>() {
       /* Collections.sort(resultMaps, new Comparator<Map<String, Object>>() {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                return (Double) o1.get("total") < (Double) o2.get("total") ? 1 : ((Double) o1.get("total") == (Double) o2.get("total") ? 0 : -1);
                return (Double) o1.get("total") < (Double) o2.get("total") ? 1 : ((Double) o1.get("total") == (Double) o2.get("total") ? 0 : -1);
            }
            }
        });*/
        Collections.sort(resultMaps, new Comparator<Map<String,Object>>() {
            @Override
            public int compare(Map<String,Object> o1, Map<String,Object> o2) {
                Double total1 = (Double) o1.get("total");
                Double total2 = (Double) o2.get("total");
                if (total1 - total2 > 0) {
                    return -1;
                } else if (total1 - total2 < 0) {
                    return 1;
                }
                return 0;
            }
        });
        });
        result1.put("resultList", resultMaps);
        result1.put("resultList", resultMaps);
        return result1;
        return result1;
@ -2278,7 +2784,7 @@ public class StatisticsEsService {
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
            object.put("data",array);
        }else if (interval==3){
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            object.put("data",array);
        }
        }
        return object;
        return object;
@ -2413,7 +2919,7 @@ public class StatisticsEsService {
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
            object.put("data",array);
        }else if (interval==3){
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            object.put("data",array);
        }
        }
        return object;
        return object;
@ -2555,26 +3061,26 @@ public class StatisticsEsService {
        }else if (interval==3){
        }else if (interval==3){
            if (index.equalsIgnoreCase("6")){
            if (index.equalsIgnoreCase("6")){
                JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
                JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL,null);
                object.put("totalData",array);
                object.put("totalData",array);
                JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,index,"0",SaveModel.timeLevel_ZL);
                JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,index,"0",SaveModel.timeLevel_ZL,null);
                object.put("noReplyData",array1);
                object.put("noReplyData",array1);
                JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL);
                JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,null);
                object.put("replyData",array2);
                object.put("replyData",array2);
                JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL);
                JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL,null);
                object.put("commingData",array3);
                object.put("commingData",array3);
                JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,index1,"1",SaveModel.timeLevel_ZL);
                JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,index1,"1",SaveModel.timeLevel_ZL,null);
                object.put("endData",array4);
                object.put("endData",array4);
            }else {
            }else {
                JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
                JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL,null);
                object.put("totalData",array);
                object.put("totalData",array);
                JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL);
                JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL,null);
                object.put("noReceiveData",array1);
                object.put("noReceiveData",array1);
                JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,index1,"1",SaveModel.timeLevel_ZL);
                JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,index1,"1",SaveModel.timeLevel_ZL,null);
                object.put("haveReceiveData",array2);
                object.put("haveReceiveData",array2);
                JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL);
                JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL,null);
                object.put("concleData",array3);
                object.put("concleData",array3);
                JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,index,"2",SaveModel.timeLevel_ZL);
                JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,index,"2",SaveModel.timeLevel_ZL,null);
                object.put("endData",array4);
                object.put("endData",array4);
            }
            }

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

@ -170,7 +170,7 @@ public class ImService {
	 * @param status 状态
	 * @param status 状态
	 * @return
	 * @return
	 */
	 */
	public List<ConsultVO>  findConsultRecordByPatient(String patient, String id,Integer type, int page,int pagesize, String title,Integer status) {
	public List<ConsultVO>  findConsultRecordByPatient(String patient, String id,String type, int page,int pagesize, String title,Integer status) {
		if(page >=1){
		if(page >=1){
			page --;
			page --;
@ -197,7 +197,7 @@ public class ImService {
				"base_doctor d, " +
				"base_doctor d, " +
				"base_doctor_hospital h " +
				"base_doctor_hospital h " +
				"WHERE a.id=b.consult and d.id = h.doctor_code " +
				"WHERE a.id=b.consult and d.id = h.doctor_code " +
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type="+type;
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type in ("+type+")";
		List<ConsultVO> result = new ArrayList<>();
		List<ConsultVO> result = new ArrayList<>();
		
		
		if(!StringUtils.isEmpty(title)){
		if(!StringUtils.isEmpty(title)){
@ -234,7 +234,7 @@ public class ImService {
	 * @param title 标题关键字
	 * @param title 标题关键字
	 * @return
	 * @return
	 */
	 */
	public Long countConsultRecordByPatient(String patient, String id,Integer type, String title) {
	public Long countConsultRecordByPatient(String patient, String id,String type, String title) {
		
		
		String  sql = "SELECT " +
		String  sql = "SELECT " +
				" COUNT(1) AS total " +
				" COUNT(1) AS total " +
@ -242,7 +242,7 @@ public class ImService {
				"wlyy_consult_team b," +
				"wlyy_consult_team b," +
				"base_doctor d " +
				"base_doctor d " +
				"WHERE a.id=b.consult " +
				"WHERE a.id=b.consult " +
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type="+type;
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type in ("+type+") ";
		List<ConsultVO> result = new ArrayList<>();
		List<ConsultVO> result = new ArrayList<>();
		
		
		if(!StringUtils.isEmpty(title)){
		if(!StringUtils.isEmpty(title)){
@ -897,7 +897,11 @@ public class ImService {
		//推送给IM去创建议题,取得成员消息
		//推送给IM去创建议题,取得成员消息
		JSONObject messages = imUtil.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), jsonObject.toJSONString(), consult.getImages(), doctor);
		JSONObject messages = imUtil.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), jsonObject.toJSONString(), consult.getImages(), doctor);
		users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
		users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
		JSONObject obj = imUtil.createTopics(patient + "_" + doctor + "_" + ct.getType(), consult.getId(), tempPatient.getName(), users, messages, imUtil.SESSION_TYPE_MUC);
		String session_type = imUtil.SESSION_TYPE_MUC;
		if(17 == ct.getType()){
			session_type = imUtil.SESSION_TYPE_MUC_VIDEO;//专家咨询-视频
		}
		JSONObject obj = imUtil.createTopics(patient + "_" + doctor + "_" + ct.getType(), consult.getId(), tempPatient.getName(), users, messages, session_type);
		if (obj == null) {
		if (obj == null) {
			throw new RuntimeException("IM消息发送异常!");
			throw new RuntimeException("IM消息发送异常!");
		}
		}
@ -1450,6 +1454,7 @@ public class ImService {
		patientinfoObj.put("sex",basePatientDO.getSex());
		patientinfoObj.put("sex",basePatientDO.getSex());
		patientinfoObj.put("mobile",basePatientDO.getMobile());
		patientinfoObj.put("mobile",basePatientDO.getMobile());
		patientinfoObj.put("address",basePatientDO.getAddress());
		patientinfoObj.put("address",basePatientDO.getAddress());
		patientinfoObj.put("photo",basePatientDO.getPhoto());
		Integer age = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
		Integer age = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
		patientinfoObj.put("age",age);
		patientinfoObj.put("age",age);
		result.put("patientInfo",patientinfoObj);
		result.put("patientInfo",patientinfoObj);
@ -1609,6 +1614,16 @@ public class ImService {
		return imUtil.sessionCountByType(userid,type,status);
		return imUtil.sessionCountByType(userid,type,status);
	}
	}
	
	
	/**
	 *获取所有会话未读消息数
	 * @param userid
	 * @param type
	 * @return
	 */
	public Integer SessionsUnreadMessageCount(String userid,Integer type){
		return imUtil.SessionsUnreadMessageCount(userid,type);
	}
	
	/**
	/**
	 * 发送复诊诊断和药品消息
	 * 发送复诊诊断和药品消息
	 * @param wlyyPrescriptionVO
	 * @param wlyyPrescriptionVO
@ -1647,7 +1662,7 @@ public class ImService {
	 * @return
	 * @return
	 */
	 */
	public List<ConsultVO>  findConsultRecordByDoctor(String doctor, String id,
	public List<ConsultVO>  findConsultRecordByDoctor(String doctor, String id,
	                                                  Integer type, Integer status,
	                                                  String type, Integer status,
	                                                  int page,int pagesize,
	                                                  int page,int pagesize,
	                                                  String title,String start_time,String end_time) {
	                                                  String title,String start_time,String end_time) {
		
		
@ -1660,7 +1675,8 @@ public class ImService {
		}
		}
		
		
		String  sql = "";
		String  sql = "";
		if(1 == type || 15 ==type){
		//专家咨询
		if("1".equals(type) || "15".equals(type) || type.contains(",")){
			sql = "SELECT " +
			sql = "SELECT " +
					"a.id AS id," +
					"a.id AS id," +
					"a.type AS type," +
					"a.type AS type," +
@ -1736,9 +1752,9 @@ public class ImService {
			
			
		}
		}
		
		
		//咨询状态
		if(type != 0){
				sql +=" AND a.type="+type;
		//咨询类型
		if(!StringUtils.isEmpty(type)){
				sql +=" AND a.type in ("+type+")" ;
		}
		}
		
		
		if (!StringUtils.isEmpty(id)) {
		if (!StringUtils.isEmpty(id)) {
@ -1761,7 +1777,7 @@ public class ImService {
	 * @param end_time 结束时间
	 * @param end_time 结束时间
	 * @return
	 * @return
	 */
	 */
	public Long countConsultRecordByDoctor(String doctor, String id,Integer type, Integer status,String title,String start_time,String end_time) {
	public Long countConsultRecordByDoctor(String doctor, String id,String type, Integer status,String title,String start_time,String end_time) {
		
		
		String  sql = "SELECT " +
		String  sql = "SELECT " +
				" COUNT(1) AS total " +
				" COUNT(1) AS total " +
@ -1798,9 +1814,9 @@ public class ImService {
		}
		}
		
		
		
		
		//咨询状态
		if(type != 0){
			sql +=" AND a.type="+type;
		//咨询类型
		if(!StringUtils.isEmpty(type)){
			sql +=" AND a.type in ("+type+")";
		}
		}
		
		
		if (!StringUtils.isEmpty(id)) {
		if (!StringUtils.isEmpty(id)) {

+ 19 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -681,6 +681,7 @@ public class ImUtil {
	public static final String SESSION_TYPE_GUIDANCE_HOSPITAL = "14";//互联网医院居民导诊聊天
	public static final String SESSION_TYPE_GUIDANCE_HOSPITAL = "14";//互联网医院居民导诊聊天
	public static final String SESSION_TYPE_GENERAL_EXPERT = "15";//全科医生发起求助专科医生的专家咨询
	public static final String SESSION_TYPE_GENERAL_EXPERT = "15";//全科医生发起求助专科医生的专家咨询
	public static final String SESSION_TYPE_EXAMINATION_VIDEO = "16";//在线复诊-视频
	public static final String SESSION_TYPE_EXAMINATION_VIDEO = "16";//在线复诊-视频
	public static final String SESSION_TYPE_MUC_VIDEO = "17";//专家-视频
	public static final String SESSION_STATUS_PROCEEDINGS = "0";
	public static final String SESSION_STATUS_PROCEEDINGS = "0";
	public static final String SESSION_STATUS_END = "1";
	public static final String SESSION_STATUS_END = "1";
	
	
@ -704,5 +705,23 @@ public class ImUtil {
			return 0;
			return 0;
		}
		}
	}
	}
	
	/**
	 *获取所有会话未读消息数。
	 * @param userid
	 * @param type
	 * @param status
	 * @return
	 */
	public Integer SessionsUnreadMessageCount(String userid,Integer type){
		String url = im_host + "api/v2/sessions/unread_message_count?user_id="+userid;
		String ret = HttpClientUtil.get(url,"utf-8");
		JSONObject obj = JSON.parseObject(ret);
//		if(obj.getInteger("count") ==200){
		return obj.getInteger("count");
//		}else{
//			return 0;
//		}
	}
}
}

+ 61 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/auth/OauthRsaKeyDO.java

@ -0,0 +1,61 @@
package com.yihu.jw.entity.auth;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2020/3/10.
 */
@Entity
@Table(name = "oauth_rsa_key")
public class OauthRsaKeyDO extends UuidIdentityEntity{
    private String code;//第三方用户唯一标识',
    private String appId;//客户端唯一标识',
    private String publicKey;//公钥',
    private String privateKey;//私钥',
    private Date createTime;//创建时间',
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getPublicKey() {
        return publicKey;
    }
    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }
    public String getPrivateKey() {
        return privateKey;
    }
    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 38 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseDoctorPatientFollowDO.java

@ -0,0 +1,38 @@
package com.yihu.jw.entity.base.org;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 居民医院关注列表
 * @author huangwenjie
 * @date 2020/3/9 09:39
 */
@Entity
@Table(name = "base_doctor_patient_follow")
public class BaseDoctorPatientFollowDO extends UuidIdentityEntity {
	
	private String patient;
	
	private String doctor;
	
	
	public String getPatient() {
		return patient;
	}
	
	public void setPatient(String patient) {
		this.patient = patient;
	}
	
	public String getDoctor() {
		return doctor;
	}
	
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
}

+ 5 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java

@ -160,6 +160,11 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
     * 机构分部号,每个机构都不一样,例如中山医院:6总部7金榜8夏禾 默认1
     * 机构分部号,每个机构都不一样,例如中山医院:6总部7金榜8夏禾 默认1
     */
     */
    private String winNo;
    private String winNo;
	
	/**
	 * 排序
	 */
	private Integer sort;
    public BaseOrgDO() {
    public BaseOrgDO() {
    }
    }

+ 76 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/BasePatientWechatDo.java

@ -0,0 +1,76 @@
package com.yihu.jw.entity.base.wx;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * @author huangwenjie
 * @date 2020/3/10 14:39
 */
@Entity
@Table(name = "base_patient_wechat")
public class BasePatientWechatDo extends UuidIdentityEntity {
	
	private String saasId;
	private String wechatId;
	private String patientId;
	private String openid;
	private String unionid;
	private String createTime;
	
	@Column(name = "saas_id")
	public String getSaasId() {
		return saasId;
	}
	
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	
	@Column(name = "wechat_id")
	public String getWechatId() {
		return wechatId;
	}
	
	public void setWechatId(String wechatId) {
		this.wechatId = wechatId;
	}
	
	@Column(name = "patient_id")
	public String getPatientId() {
		return patientId;
	}
	
	public void setPatientId(String patientId) {
		this.patientId = patientId;
	}
	
	public String getOpenid() {
		return openid;
	}
	
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	
	public String getUnionid() {
		return unionid;
	}
	
	public void setUnionid(String unionid) {
		this.unionid = unionid;
	}
	
	@Column(name = "create_time")
	public String getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
}

+ 32 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java

@ -1,5 +1,6 @@
package com.yihu.jw.entity.specialist;
package com.yihu.jw.entity.specialist;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Column;
@ -79,6 +80,13 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntityWithOperator
    private String healthStatusCode;//健康状况编码
    private String healthStatusCode;//健康状况编码
    @Column(name = "disease_code")
    @Column(name = "disease_code")
    private String diseaseCode;//签约疾病编码,多个使用逗号隔开
    private String diseaseCode;//签约疾病编码,多个使用逗号隔开
    @Column(name = "is_manage")
    private Integer isManage;//是否管理(1管理0未管理)
    @Column(name = "manage_user")
    private String manageUser;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "manage_time")
    private Date manageTime;
    public String getSaasId() {
    public String getSaasId() {
@ -266,4 +274,28 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntityWithOperator
    public void setDiseaseCode(String diseaseCode) {
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
        this.diseaseCode = diseaseCode;
    }
    }
    public Integer getIsManage() {
        return isManage;
    }
    public void setIsManage(Integer isManage) {
        this.isManage = isManage;
    }
    public String getManageUser() {
        return manageUser;
    }
    public void setManageUser(String manageUser) {
        this.manageUser = manageUser;
    }
    public Date getManageTime() {
        return manageTime;
    }
    public void setManageTime(Date manageTime) {
        this.manageTime = manageTime;
    }
}
}

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

@ -81,6 +81,11 @@ public class BaseHospitalRequestMapping {
         * 查询机构底下部门
         * 查询机构底下部门
         */
         */
        public static final String findDeptByHospital ="/findDeptByHospital";
        public static final String findDeptByHospital ="/findDeptByHospital";
    
        /**
         * 查询有所有已开放的科室
         */
        public static final String findDeptByKeyWord ="/findDeptByKeyWord";
        /**
        /**
         * 查询部门下医生
         * 查询部门下医生
@ -92,6 +97,11 @@ public class BaseHospitalRequestMapping {
         */
         */
        public static final String findDoctorByHospitalAndDiseaseAndDept = "/findDoctorByHospitalAndDiseaseAndDept";
        public static final String findDoctorByHospitalAndDiseaseAndDept = "/findDoctorByHospitalAndDiseaseAndDept";
    
    
        /**
         * 居民关注医院
         */
        public static final String followOrgByPatient = "/followOrgByPatient";
    
        /**
        /**
         * 获取常见疾病、热门部门、医生拒绝接诊原因 字典
         * 获取常见疾病、热门部门、医生拒绝接诊原因 字典
         */
         */
@ -346,6 +356,9 @@ public class BaseHospitalRequestMapping {
        public static final String findPatientRecord = "/findPatientRecord";
        public static final String findPatientRecord = "/findPatientRecord";
        public static final String findDoctorByName = "/findDoctorByName";
        public static final String findDoctorByName = "/findDoctorByName";
        public static final String findDeptWithDoctorWorkTime = "/findDeptWithDoctorWorkTime";
    }
    }
@ -519,6 +532,9 @@ public class BaseHospitalRequestMapping {
    
    
        //医生端:查询会话视频邀请状态
        //医生端:查询会话视频邀请状态
        public static final String getVideoInviteStatus="getVideoInviteStatus";
        public static final String getVideoInviteStatus="getVideoInviteStatus";
    
        //医生端:发起/断开 会话小程序视频邀请
        public static final String videoInviteMiniProgram="videoInviteMiniProgram";
    }
    }

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

@ -207,6 +207,11 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
    @ApiModelProperty(value = "1.在线复诊2.协同门诊", example = "模块1")
    @ApiModelProperty(value = "1.在线复诊2.协同门诊", example = "模块1")
    private String outpatientType;
    private String outpatientType;
    @ApiModelProperty(value = "医嘱", example = "模块1")
    private String advice;
    public String getAdmNo() {
    public String getAdmNo() {
        return admNo;
        return admNo;
    }
    }
@ -453,4 +458,12 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
    public void setMobile(String mobile) {
    public void setMobile(String mobile) {
        this.mobile = mobile;
        this.mobile = mobile;
    }
    }
    public String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
}
}

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

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

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

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import com.google.code.kaptcha.util.Config;
import com.yihu.jw.entity.auth.OauthRsaKeyDO;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
@ -18,10 +19,7 @@ import com.yihu.jw.security.model.*;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.service.OauthCaConfigSerivce;
import com.yihu.jw.security.service.OauthWjwConfigService;
import com.yihu.jw.security.service.OauthWlyyConfigService;
import com.yihu.jw.security.service.OauthYlzConfigService;
import com.yihu.jw.security.service.*;
import com.yihu.jw.security.utils.AES;
import com.yihu.jw.security.utils.AES;
import com.yihu.jw.security.utils.DateUtil;
import com.yihu.jw.security.utils.DateUtil;
import com.yihu.jw.security.utils.SerializeUtil;
import com.yihu.jw.security.utils.SerializeUtil;
@ -126,6 +124,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private OauthCaConfigSerivce oauthCaConfigSerivce;
    private OauthCaConfigSerivce oauthCaConfigSerivce;
    @Autowired
    @Autowired
    private OauthWjwConfigService oauthWjwConfigService;
    private OauthWjwConfigService oauthWjwConfigService;
    @Autowired
    private OauthSsoService oauthSsoService;
    @PostConstruct
    @PostConstruct
@ -1085,4 +1085,83 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        }
        return pass;
        return pass;
    }
    }
    @RequestMapping(value = "/oauth/getSsoPublicKey", method = RequestMethod.GET)
    @ApiOperation("获取通用公钥")
    public ObjEnvelop getSsoPublicKey(String code,String appId)throws Exception{
        return ObjEnvelop.getSuccess("success",oauthSsoService.getSsoPublic(code,appId));
    }
    @RequestMapping(value = "/oauth/test", method = RequestMethod.GET)
    @ApiOperation("test dd")
    public ObjEnvelop test()throws Exception{
        return ObjEnvelop.getSuccess("success",oauthSsoService.getAuthCode());
    }
    @RequestMapping(value = "/oauth/ssoPatientLogin", method = RequestMethod.POST)
    public ObjEnvelop ssoPatientLogin(String authCode,String client_id,String code,String appId,String login_type){
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
        }
        if (StringUtils.isEmpty(authCode)) {
            throw new InvalidRequestException("authCode is null");
        }
        if (StringUtils.isEmpty(code)) {
            throw new InvalidRequestException("code is null");
        }
        if (StringUtils.isEmpty(appId)) {
            throw new InvalidRequestException("appId is null");
        }
        try {
            logger.info("authCode :"+authCode);
            BasePatientDO patientDO = oauthSsoService.savePatient(code,appId,authCode);
            if(patientDO == null){
                return ObjEnvelop.getError("授权登录失败!");
            }
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            Map<String, String> parameters = new HashedMap();
            parameters.put("username",patientDO.getIdcard());
            parameters.put("grant_type", "ihealthCode");
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            if (authenticatedClient != null) {
                oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
            }
            OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
            WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
            wlyyUserSimple.setAccessToken(token.getValue());
            wlyyUserSimple.setTokenType(token.getTokenType());
            wlyyUserSimple.setExpiresIn(token.getExpiresIn());
            wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
            wlyyUserSimple.setUser(parameters.get("username"));
            String loginType = parameters.get("login_type");
            BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
            userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
            baseLoginLogDO.setUserId(wlyyUserSimple.getId());
            baseLoginLogDO.setCreateTime(new Date());
            String userAgent = JSONObject.toJSONString(wlyyUserSimple);
            baseLoginLogDO.setUserAgent(userAgent);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogService.save(baseLoginLogDO);
            return ObjEnvelop.getSuccess("success",wlyyUserSimple);
        }catch (Exception e){
            logger.error(e);
        }
        return ObjEnvelop.getError("登录失败!");
    }
}
}

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

@ -0,0 +1,125 @@
package com.yihu.jw.security.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.auth.OauthRsaKeyDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.security.dao.OauthRsaKeyDao;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.jw.security.utils.RSAEncrypt;
import com.yihu.utils.security.MD5;
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.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by Trick on 2020/3/10.
 */
@Service
@Transactional
public class OauthSsoService {
    Logger logger = LoggerFactory.getLogger(OauthSsoService.class);
    @Autowired
    private OauthRsaKeyDao rsaKeyDao;
    @Autowired
    private BasePatientDao basePatientDao;
    public String getAuthCode()throws Exception{
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name","测试用户");
        jsonObject.put("idcard","350600456789456123");
        jsonObject.put("mobile","15426852352");
        String authCode = jsonObject.toJSONString();
        logger.info("authCode:"+authCode);
        String publicKey = getSsoPublic("1", "appid");
        String jm = RSAEncrypt.encrypt(authCode,publicKey);
        return jm;
    }
    public String getSsoPublic(String code,String appId)throws Exception{
        /**
         * 删除之前秘钥
         */
        List<OauthRsaKeyDO> oauthRsaKeyDOs = rsaKeyDao.findByCodeAndAppId(code,appId);
        if(oauthRsaKeyDOs!=null&&oauthRsaKeyDOs.size()>0){
            rsaKeyDao.delete(oauthRsaKeyDOs);
        }
        /**
         * 生成新的秘钥
         */
        OauthRsaKeyDO oauthRsaKeyDO = new OauthRsaKeyDO();
        Map<Integer, String> key  = RSAEncrypt.genKeyPair();
        oauthRsaKeyDO.setCode(code);
        oauthRsaKeyDO.setAppId(appId);
        oauthRsaKeyDO.setPublicKey(key.get(0));
        oauthRsaKeyDO.setPrivateKey(key.get(1));
        oauthRsaKeyDO.setCreateTime(new Date());
        rsaKeyDao.save(oauthRsaKeyDO);
        return oauthRsaKeyDO.getPublicKey();
    }
    public BasePatientDO savePatient(String code,String appId,String authCode)throws Exception{
        String jsonStr = decrypt(code,appId,authCode);
        JSONObject info = JSON.parseObject(jsonStr);
        String name = info.getString("name");
        String idcard = info.getString("idcard");
        String mobile = info.getString("mobile");
        if(StringUtils.isNotBlank(idcard)){
            BasePatientDO basePatientDO = basePatientDao.findByIdcardAndDel(idcard,"1");
            if(basePatientDO!=null){
                return basePatientDO;
            }
            BasePatientDO patient = new BasePatientDO();
            String salt = UUID.randomUUID().toString().substring(0,5);
            String pw = idcard.substring(idcard.length()-6);
            patient.setIdcard(idcard);
            patient.setName(name);
            patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            patient.setSalt(salt);
            patient.setMobile(mobile);
            patient.setDel("1");
            patient.setEnabled(1);
            patient.setLocked(0);
            patient.setCreateTime(new Date());
            patient.setUpdateTime(new Date());
            patient.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard));
            patient.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard)));
            basePatientDao.save(patient);
            return basePatientDO;
        }
        return null;
    }
    public String decrypt(String code,String appId,String authCode)throws Exception{
        List<OauthRsaKeyDO> oauthRsaKeyDOs = rsaKeyDao.findByCodeAndAppId(code,appId);
        OauthRsaKeyDO oauthRsaKeyDO = oauthRsaKeyDOs.get(0);
        String str = RSAEncrypt.decrypt(authCode,oauthRsaKeyDO.getPrivateKey());
        logger.info("decrypt : "+str);
        return  str;
    }
}

+ 101 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAEncrypt.java

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

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

@ -103,6 +103,7 @@ zhongshanHospital:
fastDFS:
fastDFS:
  fastdfs_file_url: http://192.0.33.26:22122
  fastdfs_file_url: http://192.0.33.26:22122
---
---
## 心脏中心外网
spring:
spring:
  profiles: xzprod
  profiles: xzprod
  datasource:
  datasource:
@ -141,4 +142,4 @@ iHealth:
zhongshanHospital:
zhongshanHospital:
  user-info-uri: http://laptop-u738dn2p:10023/mqsdk/getUserInfoByOpenid
  user-info-uri: http://laptop-u738dn2p:10023/mqsdk/getUserInfoByOpenid
fastDFS:
fastDFS:
  fastdfs_file_url: http://192.168.103.159:22122
  fastdfs_file_url: http://192.168.103.159:22122

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

@ -54,7 +54,7 @@ spring:
  profiles: xzprod
  profiles: xzprod
  cloud:
  cloud:
    config:
    config:
      uri: ${wlyy.spring.config.uri:http://172.16.100.63:1221}
      uri: ${wlyy.spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}
      label: ${wlyy.spring.config.label:master}
---
---
spring:
spring:

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

@ -15,7 +15,7 @@ eureka:
    healthcheck:
    healthcheck:
      enabled: false #启动监控检查,
      enabled: false #启动监控检查,
    serviceUrl: # 默认正式线地址
    serviceUrl: # 默认正式线地址
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka  # 测试环境
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka  # 默认本机环境
#      defaultZone: http://jw:jkzl@172.16.1.42:8761/eureka # 中山医院
#      defaultZone: http://jw:jkzl@172.16.1.42:8761/eureka # 中山医院
#      defaultZone: http://jw:jkzl@192.0.33.26:8762/eureka
#      defaultZone: http://jw:jkzl@192.0.33.26:8762/eureka
#      defaultZone: http://jw:jkzl@192.168.33.199:8761/eureka
#      defaultZone: http://jw:jkzl@192.168.33.199:8761/eureka

+ 0 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java

@ -3,7 +3,6 @@ package com.yihu.jw.base.endpoint.wx;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.wx.WechatService;
import com.yihu.jw.base.service.wx.WechatService;
import com.yihu.jw.base.service.wx.WxTemplateService;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.restmodel.base.wx.*;
import com.yihu.jw.restmodel.base.wx.*;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WxTemplateController.java

@ -1,9 +1,9 @@
package com.yihu.jw.base.endpoint.wx;
package com.yihu.jw.base.endpoint.wx;
import com.yihu.jw.base.service.wx.WxTemplateService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -3,7 +3,6 @@ package com.yihu.jw.base.service.doctor;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.dict.DictDoctorDutyDao;
import com.yihu.jw.base.dao.dict.DictJobTitleDao;
import com.yihu.jw.base.dao.dict.DictJobTitleDao;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleDao;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleDao;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleInfoDao;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleInfoDao;
@ -14,6 +13,7 @@ import com.yihu.jw.base.service.org.OrgTree;
import com.yihu.jw.base.service.org.OrgTreeService;
import com.yihu.jw.base.service.org.OrgTreeService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.dict.dao.DictDoctorDutyDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;

+ 127 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/YkyyDataUploadJob.java

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

File diff suppressed because it is too large
+ 63 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/UpPrescription.java


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

@ -9,6 +9,7 @@ import com.yihu.jw.job.DataUploadJob;
import com.yihu.jw.job.PrescriptionOverdueJob;
import com.yihu.jw.job.PrescriptionOverdueJob;
import com.yihu.jw.job.PrescriptionStatusUpdateJob;
import com.yihu.jw.job.PrescriptionStatusUpdateJob;
import com.yihu.jw.job.QuartzHelper;
import com.yihu.jw.job.QuartzHelper;
import com.yihu.jw.job.ykyy.YkyyDataUploadJob;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.util.SystemConf;
@ -121,6 +122,17 @@ public class JobController extends BaseController {
                        logger.info("data_upload_job  job exist");
                        logger.info("data_upload_job  job exist");
                    }
                    }
                    break;
                case "data_ykupload_job" :
                    //互联网医院 监管平台上报
                    if (!quartzHelper.isExistJob("data_ykupload_job")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("data_ykupload_job");
                        quartzHelper.addJob(YkyyDataUploadJob.class, trigger, "data_ykupload_job", new HashMap<String, Object>());
                        logger.info("data_ykupload_job  job success");
                    } else {
                        logger.info("data_ykupload_job  job exist");
                    }
                    break;
                    break;
                default :
                default :
            }
            }
@ -395,7 +407,7 @@ public class JobController extends BaseController {
    @RequestMapping(value = "/ykyyUpload", method = RequestMethod.GET)
    @RequestMapping(value = "/ykyyUpload", method = RequestMethod.GET)
    @ApiOperation("上传")
    @ApiOperation("上传")
    public String ykyyUpload(String id) {
    public String ykyyUpload(String id,String startDate,String endDate,String keyId) {
        try {
        try {
            switch(id){
            switch(id){
                case "2.2" :
                case "2.2" :
@ -403,7 +415,47 @@ public class JobController extends BaseController {
                    break; //可选
                    break; //可选
                case "2.3" :
                case "2.3" :
                    //语句
                    //语句
                    ykyyInternetService.upNsDoctorRecord(null,null,null);
                    ykyyInternetService.upNsDoctorRecord(keyId);
                    break; //可选
                case "2.5" :
                    //语句
                    ykyyInternetService.upAppointmentOnline(startDate,endDate,keyId);
                    break; //可选
                case "2.6" :
                    //语句
                    ykyyInternetService.upMedicalOnline(startDate,endDate,keyId);
                    break; //可选
                case "2.7" :
                    //语句
                    ykyyInternetService.upNsDoctorScore(startDate,endDate,keyId);
                    break; //可选upNsDoctorScore
                case "2.8" :
                    //语句
                    ykyyInternetService.upNsOnlineAsk(startDate,endDate,keyId);
                    break; //可选
                case "2.9" :
                    //语句
                    ykyyInternetService.upNsOnlineMed(startDate,endDate,keyId);
                    break; //可选
                case "2.10" :
                    //语句
                    ykyyInternetService.upPrescription(startDate,endDate,keyId);
                    break; //可选
                case "2.11" :
                    //语句
                    ykyyInternetService.upPrescriptionDrug(startDate,endDate,keyId);
                    break; //可选
                case "2.12" :
                    //语句
                    ykyyInternetService.upNsOnlineImg(startDate,endDate,keyId);
                    break; //可选
                case "2.13" :
                    //语句
                    ykyyInternetService.upNsOrganProtocol(startDate,endDate,keyId);
                    break; //可选
                case "2.14" :
                    //语句
                    ykyyInternetService.upNsInvokeTotal(startDate,endDate);
                    break; //可选
                    break; //可选
                default : //可选
                default : //可选
                    //语句
                    //语句

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

@ -76,6 +76,8 @@ im:
  data_base_name: im_internet_hospital
  data_base_name: im_internet_hospital
fastDFS:
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
  fastdfs_file_url: http://172.26.0.110:8888/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
---
---
spring:
spring:
  profiles: jwtest
  profiles: jwtest
@ -102,9 +104,11 @@ fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
  fastdfs_file_url: http://172.26.0.110:8888/
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
---
---
spring:
spring:
  profiles: jwOracleProd
  profiles: jwOracleTest
  datasource:
  datasource:
    driver-class-name: oracle.jdbc.driver.OracleDriver
    driver-class-name: oracle.jdbc.driver.OracleDriver
    url: jdbc:oracle:thin:@172.26.0.141:1521:helowin
    url: jdbc:oracle:thin:@172.26.0.141:1521:helowin
@ -135,6 +139,43 @@ fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
  fastdfs_file_url: http://172.26.0.110:8888/
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
---
spring:
  profiles: jwOracleProd
  datasource:
    driver-class-name: oracle.jdbc.driver.OracleDriver
    url: jdbc:oracle:thin:@192.168.20.55:1521:orcl
    username: system
    password: hxyk9573
  jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.Oracle10gDialect
        show_sql: true
    database: oracle
hlwyyEntrance:
  url: http://172.16.1.42:10023
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.26.0.105:3000/
  data_base_name: im_internet_hospital
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
---
---
spring:
spring:
  profiles: jwprod
  profiles: jwprod
@ -160,4 +201,6 @@ im:
fastDFS:
fastDFS:
  fastdfs_file_url: http://192.0.33.26:8888/
  fastdfs_file_url: http://192.0.33.26:8888/
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段

+ 9 - 2
svr/svr-internet-hospital-job/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
spring:
  application:
  application:
    name: svr-internet-hospital-job-yx
    name: svr-internet-hospital-job
  cloud:
  cloud:
    config:
    config:
      failFast: true
      failFast: true
@ -24,12 +24,19 @@ spring:
      label: ${wlyy.spring.config.label:jwdev}
      label: ${wlyy.spring.config.label:jwdev}
---
---
spring:
spring:
  profiles: jwOracleProd
  profiles: jwOracleTest
  cloud:
  cloud:
    config:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.107:1221}
      uri: ${wlyy.spring.config.uri:http://172.26.0.107:1221}
      label: ${wlyy.spring.config.label:jwdev}
      label: ${wlyy.spring.config.label:jwdev}
---
---
spring:
  profiles: jwOracleProd
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
spring:
  profiles: jwprod
  profiles: jwprod
  cloud:
  cloud:

+ 6 - 14
svr/svr-internet-hospital-job/src/main/resources/system.properties

@ -1,4 +1,4 @@
#-------------------------共同配置-----------------------------#
#-------------------------中山医院-----------------------------#
# 健康频道状态
# 健康频道状态
prescriptionStatus_update_job=0 */2 * * * ?
prescriptionStatus_update_job=0 */2 * * * ?
@ -8,16 +8,8 @@ prescription_overdue_job=0 0 1 * * ?
#每天13 点触发
#每天13 点触发
data_upload_job=0 0 2 * * ?
data_upload_job=0 0 2 * * ?
#data_upload_25_job=0 0 1 * * ?
#
#data_upload_26_job=0 0 1 * * ?
#
#data_upload_27_job=0 0 1 * * ?
#
#data_upload_28_job=0 0 1 * * ?
#
#data_upload_29_job=0 0 1 * * ?
#
#data_upload_210_job=0 0 1 * * ?
#
#data_upload_211_job=0 0 1 * * ?
#-------------------------中山医院end-----------------------------#
#-------------------------眼科医院-----------------------------#
data_ykupload_job=0 0 0 * * ?
#-------------------------眼科医院end-----------------------------#

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

@ -190,6 +190,22 @@ public class BaseInfoEndpoint extends EnvelopRestEndpoint {
        return success(ykyyEntranceService.updateYkyyDoctor());
        return success(ykyyEntranceService.updateYkyyDoctor());
    }
    }
    @GetMapping(value = "/getCFXX")
    @ApiOperation(value = "同步处方信息生成数据", notes = "同步处方信息生成数据")
    public Envelop getCFXX(@ApiParam(name = "brids", value = "病人id")
                           @RequestParam(value = "brids", required = true)String brids,
                           @ApiParam(name = "ysdm", value = "医生id")
                           @RequestParam(value = "ysdm", required = true)String ysdm,
                           @ApiParam(name = "startDate", value = "生成时间")
                           @RequestParam(value = "startDate", required = true)String startDate) throws Exception {
        return success(ykyyEntranceService.getCFXX(brids,ysdm,startDate));
    }
    @GetMapping(value = "/findPatientByMapingCode")
    @ApiOperation(value = "findPatientByMapingCode", notes = "findPatientByMapingCode")
    public Envelop findPatientByMapingCode(String code) throws Exception {
        return success(ykyyEntranceService.findPatientByMapingCode(code));
    }
//    @GetMapping(value = "/test")
//    @GetMapping(value = "/test")
//    @ApiOperation(value = "test", notes = "test")
//    @ApiOperation(value = "test", notes = "test")
//    public Envelop test() throws Exception {
//    public Envelop test() throws Exception {

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

@ -7,7 +7,6 @@ import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
@ -26,6 +25,7 @@ import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.wechat.service.WxTemplateService;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
@ -81,6 +81,8 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	private HospitalSystemMessageService hospitalSystemMessageService;
	private HospitalSystemMessageService hospitalSystemMessageService;
	@Autowired
	@Autowired
	public BasePatientDao basePatientDao;
	public BasePatientDao basePatientDao;
	@Autowired
	private WxTemplateService wxTemplateService;
	
	
	
	
@ -157,7 +159,12 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "reason", value = "复诊说明", defaultValue = "复诊说明")
			@ApiParam(name = "reason", value = "复诊说明", defaultValue = "复诊说明")
			@RequestParam(value = "reason", required = false) String reason)throws Exception{
			@RequestParam(value = "reason", required = false) String reason)throws Exception{
			ConsultTeamDo consult = new ConsultTeamDo();
			ConsultTeamDo consult = new ConsultTeamDo();
			consult.setType(9);//续方咨询
			if(2 == type){
				consult.setType(16);//视频复诊
			}else{
				consult.setType(9);//图文复诊
			}
			
			
			
			//咨询类型(1、图文;2、视频,3、图文+视频)
			//咨询类型(1、图文;2、视频,3、图文+视频)
			consult.setHealthindexType(type);
			consult.setHealthindexType(type);
@ -345,7 +352,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "id", value = "咨询ID")
			@ApiParam(name = "id", value = "咨询ID")
			@RequestParam(value = "id",required = false) String id,
			@RequestParam(value = "id",required = false) String id,
			@ApiParam(name = "type", value = "咨询类型")
			@ApiParam(name = "type", value = "咨询类型")
			@RequestParam(value = "type",required = true) Integer type,
			@RequestParam(value = "type",required = true) String type,
			@ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
			@ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
			@RequestParam(value = "status",required = true) Integer status,
			@RequestParam(value = "status",required = true) Integer status,
			@ApiParam(name = "start_time", value = "开始时间 YYYY-MM-DD HH:MM:SS")
			@ApiParam(name = "start_time", value = "开始时间 YYYY-MM-DD HH:MM:SS")
@ -743,4 +750,23 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		
		
	}
	}
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.videoInviteMiniProgram)
	@ApiOperation(value = "医生端:发起/断开 会话小程序视频邀请", notes = "医生端:发起/断开 会话小程序视频邀请")
	public Envelop videoInviteMiniProgram(@ApiParam(name = "sender_id", value = "发起人")
	                                 @RequestParam(value = "sender_id",required = true) String sender_id,
	                                 @ApiParam(name = "sender_name", value = "发起人名字")
	                                 @RequestParam(value = "sender_name",required = true) String sender_name,
                                      @ApiParam(name = "reciver_id", value = "接收人")
                                      @RequestParam(value = "reciver_id",required = true) String reciver_id,
                                      @ApiParam(name = "reciver_name", value = "接收人")
                                      @RequestParam(value = "reciver_name",required = true) String reciver_name,
                                      @ApiParam(name = "reciver_type", value = "接收人类型1居民 2医生")
                                      @RequestParam(value = "reciver_name",required = true) String reciver_type,
                                      @ApiParam(name = "session_id", value = "会话ID")
                                      @RequestParam(value = "session_id",required = true) String session_id
	                                      )throws Exception  {
		wxTemplateService.sendWeTempMesMiniProgram(sender_id,sender_name,reciver_id,reciver_name,session_id);
		return success("操作成功");
	}
}
}

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

@ -92,6 +92,9 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@Value("${fastDFS.fastdfs_file_url}")
	@Value("${fastDFS.fastdfs_file_url}")
	private String fastdfs_file_url;
	private String fastdfs_file_url;
	
	
	@Value("${wlyy.url}")
	private String wlyyUrl;
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
	@ApiOperation(value = "患者咨询记录查询")
	@ApiOperation(value = "患者咨询记录查询")
	public Envelop records(
	public Envelop records(
@ -102,7 +105,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
								@ApiParam(name = "id", value = "咨询ID")
								@ApiParam(name = "id", value = "咨询ID")
								@RequestParam(value = "id",required = false) String id,
								@RequestParam(value = "id",required = false) String id,
								@ApiParam(name = "type", value = "咨询类型")
								@ApiParam(name = "type", value = "咨询类型")
								@RequestParam(value = "type",required = true) Integer type,
								@RequestParam(value = "type",required = true) String type,
								@ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
								@ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
								@RequestParam(value = "status",required = false) Integer status,
								@RequestParam(value = "status",required = false) Integer status,
								@ApiParam(name = "page", value = "第几页")
								@ApiParam(name = "page", value = "第几页")
@ -283,6 +286,8 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@ApiOperation(value = "根据疾病名称,热门部门查询医生", notes = "根据疾病名称,热门部门查询医生")
	@ApiOperation(value = "根据疾病名称,热门部门查询医生", notes = "根据疾病名称,热门部门查询医生")
	public ListEnvelop findDoctorByHospitalAndDiseaseAndDept(@ApiParam(name = "iswork", value = "机构code")
	public ListEnvelop findDoctorByHospitalAndDiseaseAndDept(@ApiParam(name = "iswork", value = "机构code")
																 @RequestParam(value = "iswork", required = false)String iswork,
																 @RequestParam(value = "iswork", required = false)String iswork,
	                                                         @ApiParam(name = "patientid", value = "居民ID")
	                                                         @RequestParam(value = "patientid", required = false)String patientid,
			                                       @ApiParam(name = "orgCode", value = "机构code")
			                                       @ApiParam(name = "orgCode", value = "机构code")
	                                               @RequestParam(value = "orgCode", required = false)String orgCode,
	                                               @RequestParam(value = "orgCode", required = false)String orgCode,
	                                               @ApiParam(name = "dept", value = "部门code")
	                                               @ApiParam(name = "dept", value = "部门code")
@ -312,7 +317,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	) throws Exception{
	) throws Exception{
		logger.info("findDoctorByHospitalAndDiseaseAndDept start:"+DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
		logger.info("findDoctorByHospitalAndDiseaseAndDept start:"+DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
		return success(prescriptionService.findDoctorByHospitalAndDiseaseAndDept(iswork,
		return success(prescriptionService.findDoctorByHospitalAndDiseaseAndDept(iswork,patientid,
				orgCode,dept,
				orgCode,dept,
				diseaseKey,doctorNameKey,
				diseaseKey,doctorNameKey,
				jobTitleNameKey,outpatientType,
				jobTitleNameKey,outpatientType,
@ -340,7 +345,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "images",required = false) String images,
			@RequestParam(value = "images",required = false) String images,
			@ApiParam(name = "voice", value = "语音")
			@ApiParam(name = "voice", value = "语音")
			@RequestParam(value = "voice",required = false) String voice,
			@RequestParam(value = "voice",required = false) String voice,
			@ApiParam(name = "type", value = "咨询类型:1专家咨询 14导诊助手")
			@ApiParam(name = "type", value = "咨询类型:1专家咨询 14导诊助手 17专家视频咨询")
			@RequestParam(value = "type",required = false) Integer type)throws Exception{
			@RequestParam(value = "type",required = false) Integer type)throws Exception{
		
		
//		//发送厦门i健康智能推送
//		//发送厦门i健康智能推送
@ -414,7 +419,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			}
			}
			//发送厦门i健康智能推送
			//发送厦门i健康智能推送
			try{
			try{
				String wxurl = "http://www.xmtyw.cn/wlyy/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId="+p.getId()+"_"+d.getId()+"_1&sessionType=1&from="+p.getId()+"&content="+URLEncoder.encode(symptoms)+"&businessType=1&doctor_idcard="+d.getIdcard()+"&patientName="+URLEncoder.encode(p.getName())+"&url=1";
				String wxurl = wlyyUrl+"/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId="+p.getId()+"_"+d.getId()+"_1&sessionType=1&from="+p.getId()+"&content="+URLEncoder.encode(symptoms)+"&businessType=1&doctor_idcard="+d.getIdcard()+"&patientName="+URLEncoder.encode(p.getName())+"&url=1";
				logger.info("发送厦门i健康智能推送url:"+wxurl);
				logger.info("发送厦门i健康智能推送url:"+wxurl);
				wlyyBusinessService.sendDoctorTemplateByDoctorIdcard(wxurl);
				wlyyBusinessService.sendDoctorTemplateByDoctorIdcard(wxurl);
			}catch (Exception e){
			}catch (Exception e){
@ -611,4 +616,19 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
		return success("查询成功",imService.getDoctorConsultCount(doctorids));
		return success("查询成功",imService.getDoctorConsultCount(doctorids));
		
		
	}
	}
	
	
	@PostMapping(value = BaseHospitalRequestMapping.Prescription.followOrgByPatient)
	@ApiOperation(value = "居民关注医院", notes = "居民关注医院")
	public Envelop followOrgByPatient(
			@ApiParam(name = "patientid", value = "发送者id", defaultValue = "")
			@RequestParam(value = "patientid", required = true) String patientid,
			@ApiParam(name = "orgid", value = "发送者姓名", defaultValue = "")
			@RequestParam(value = "orgid", required = true) String orgid,
			@ApiParam(name = "type", value = "1关注 0取消关注", defaultValue = "")
			@RequestParam(value = "type", required = true) String type
	)throws Exception{
		prescriptionService.followOrgByPatient(patientid,orgid,type);
		return success("操作成功!");
	}
}
}

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

@ -87,7 +87,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    ) throws Exception{
    ) throws Exception{
        logger.info("findDoctorByHospitalAndDiseaseAndDept start:"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
        logger.info("findDoctorByHospitalAndDiseaseAndDept start:"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
        return success(prescriptionService.findDoctorByHospitalAndDiseaseAndDept(null,
        return success(prescriptionService.findDoctorByHospitalAndDiseaseAndDept(null,null,
                orgCode,dept,
                orgCode,dept,
                diseaseKey,doctorNameKey,
                diseaseKey,doctorNameKey,
                jobTitleNameKey,outpatientType,
                jobTitleNameKey,outpatientType,
@ -200,9 +200,14 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
            Integer zjCount = imService.sessionCountByType(doctor.getId(),1,0);
            Integer zjCount = imService.sessionCountByType(doctor.getId(),1,0);
            //全科医生求助专科
            //全科医生求助专科
            Integer zjqzCount = imService.sessionCountByType(doctor.getId(),15,0);
            Integer zjqzCount = imService.sessionCountByType(doctor.getId(),15,0);
    
            //专家咨询
            Integer unreadMessageCount = imService.SessionsUnreadMessageCount(doctor.getId(),1);
            result.put("zjCount",zjCount+zjqzCount);//专家咨询数量
            result.put("zjCount",zjCount+zjqzCount);//专家咨询数量
            result.put("zjUnreadMessageCount",unreadMessageCount);//专家咨询未读数
        }else{
        }else{
            result.put("zjCount",0);//专家咨询数量
            result.put("zjCount",0);//专家咨询数量
            result.put("zjUnreadMessageCount",0);//专家咨询未读数
        }
        }
        return success("请求成功",result);
        return success("请求成功",result);
    }
    }

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

@ -208,8 +208,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findAllHospital)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findAllHospital)
    @ApiOperation(value = "查询所有机构", notes = "查询所有机构")
    @ApiOperation(value = "查询所有机构", notes = "查询所有机构")
    public ListEnvelop findAllHospital(@ApiParam(name = "level", value = "医院等级")
    public ListEnvelop findAllHospital(@ApiParam(name = "level", value = "医院等级")
                                       @RequestParam(value = "level", required = false)Integer level) {
        return success(prescriptionService.findAllHospital(level));
                                       @RequestParam(value = "level", required = false)Integer level,
                                       @ApiParam(name = "keyWord", value = "名字关键字")
                                       @RequestParam(value = "keyWord", required = false)String keyWord) {
        return success(prescriptionService.findAllHospital(level,keyWord));
    }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByHospital)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByHospital)
@ -222,6 +224,17 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                          @RequestParam(value = "consultDeptFlag", required = false)String consultDeptFlag) {
                                          @RequestParam(value = "consultDeptFlag", required = false)String consultDeptFlag) {
        return success(prescriptionService.findDeptByHospital(orgCode,dept,consultDeptFlag));
        return success(prescriptionService.findDeptByHospital(orgCode,dept,consultDeptFlag));
    }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByKeyWord)
    @ApiOperation(value = "查询有所有已开放的科室", notes = "查询有所有已开放的科室")
    public ListEnvelop findDeptByKeyWord(@ApiParam(name = "keyWord", value = "关键字")
                                          @RequestParam(value = "keyWord", required = false)String keyWord,
                                         @ApiParam(name = "page", value = "第几页")
                                         @RequestParam(value = "page",required = true) Integer page,
                                         @ApiParam(name = "pagesize", value = "分页大小")
                                             @RequestParam(value = "pagesize",required = true) Integer pagesize) {
        return success(prescriptionService.findDeptByKeyWord(keyWord,page,pagesize));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorByHospitalAndDept)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorByHospitalAndDept)
    @ApiOperation(value = "查询部门下医生", notes = "查询部门下医生")
    @ApiOperation(value = "查询部门下医生", notes = "查询部门下医生")
@ -943,5 +956,16 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success(prescriptionService.findDoctorByName(hospital,name,chargeType));
        return success(prescriptionService.findDoctorByName(hospital,name,chargeType));
    }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptWithDoctorWorkTime)
    @ApiOperation(value = "获取带排班部门")
    public ListEnvelop findDeptWithDoctorWorkTime(@ApiParam(name = "hospital", value = "医院code")
                                                  @RequestParam(value = "hospital",required = false)String hospital,
                                                  @ApiParam(name = "keyWord", value = "科室关键字")
                                                  @RequestParam(value = "keyWord",required = false)String keyWord,
                                                  @ApiParam(name = "page", value = "第几页")
                                                  @RequestParam(value = "page",required = false)Integer page,
                                                  @ApiParam(name = "pagesize", value = "每页大小")
                                                  @RequestParam(value = "pagesize",required = false)Integer pagesize) {
        return success(prescriptionService.findDeptWithDoctorWorkTime(hospital,keyWord,page,pagesize));
    }
}
}

+ 12 - 17
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -11,6 +11,8 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -27,6 +29,9 @@ import java.util.List;
@Api(value = "统计分析", description = "统计分析", tags = {"统计分析"})
@Api(value = "统计分析", description = "统计分析", tags = {"统计分析"})
public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    Logger logger = LoggerFactory.getLogger(EsStatisticsEndpoint.class);
    @Autowired
    @Autowired
    private StatisticsEsService statisticsEsService;
    private StatisticsEsService statisticsEsService;
@ -54,11 +59,15 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = false)int interval,
            @RequestParam(required = false)int interval,
            @RequestParam(required = false) String level2_type) {
            @RequestParam(required = false) String level2_type) {
            //新版与旧版统计适配
            //新版与旧版统计适配
        level = elasticsearchUtil.changeLevel(level);
        String[] indexes = index.split(",");
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        logger.info("index:"+index+" and level2_type:"+level2_type+" and level:"+level);
        try {
        try {
            result= statisticsEsService.getOutPatientLine(startDate, endDate, area, level, index, interval,level2_type);
            if (index.contains("3")){
                result= statisticsEsService.getOutPatientPriceLine(startDate, endDate, area, level, index, interval,level2_type);
            }else {
                result= statisticsEsService.getOutPatientLine(startDate, endDate, area, level, index, interval,level2_type);
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
@ -87,8 +96,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = true) String index,
            @RequestParam(required = true) String index,
            @RequestParam(required = false)int interval,
            @RequestParam(required = false)int interval,
            @RequestParam(required = false) String level2_type) {
            @RequestParam(required = false) String level2_type) {
        //新版与旧版统计适配
        level = elasticsearchUtil.changeLevel(level);
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
            result= statisticsEsService.getPrescriptionLine(startDate, endDate, area, level, index, interval,level2_type);
            result= statisticsEsService.getPrescriptionLine(startDate, endDate, area, level, index, interval,level2_type);
@ -109,8 +116,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @RequestParam(required = true) String index,
            @RequestParam(required = false) String level2_type) {
            @RequestParam(required = false) String level2_type) {
        //新版与旧版统计适配
        level = elasticsearchUtil.changeLevel(level);
        String[] indexes = index.split(",");
        String[] indexes = index.split(",");
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
@ -132,8 +137,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @RequestParam(required = true) String index,
            @RequestParam(required = false) String level2_type) {
            @RequestParam(required = false) String level2_type) {
        //新版与旧版统计适配
        level = elasticsearchUtil.changeLevel(level);
        String[] indexes = index.split(",");
        String[] indexes = index.split(",");
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
@ -164,8 +167,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @RequestParam(required = true) String index,
            @RequestParam(required = false) String level2_type) {
            @RequestParam(required = false) String level2_type) {
        //新版与旧版统计适配
        level = elasticsearchUtil.changeLevel(level);
        String[] indexes = index.split(",");
        String[] indexes = index.split(",");
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
@ -197,8 +198,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @RequestParam(required = true) String index,
            @RequestParam(required = false) String level2_type) {
            @RequestParam(required = false) String level2_type) {
        //新版与旧版统计适配
        level = elasticsearchUtil.changeLevel(level);
        String[] indexes = index.split(",");
        String[] indexes = index.split(",");
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
@ -219,7 +218,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
                                          @RequestParam(required = true) String index,
                                          @RequestParam(required = true) String index,
                                          @RequestParam(required = false) String level2_type,
                                          @RequestParam(required = false) String level2_type,
                                          @RequestParam(required = true) Integer flag) {
                                          @RequestParam(required = true) Integer flag) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
            result= statisticsEsService.getDoctorStatistics(startDate,endDate,area,level,index,level2_type,flag);
            result= statisticsEsService.getDoctorStatistics(startDate,endDate,area,level,index,level2_type,flag);
@ -239,7 +237,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
                                     @RequestParam(required = true) String index,
                                     @RequestParam(required = true) String index,
                                     @RequestParam(required = false) String level2_type,
                                     @RequestParam(required = false) String level2_type,
                                     @RequestParam(required = true) Integer flag) {
                                     @RequestParam(required = true) Integer flag) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
            result= statisticsEsService.getDoctorTotal(startDate,endDate,area,level,index,level2_type,flag);
            result= statisticsEsService.getDoctorTotal(startDate,endDate,area,level,index,level2_type,flag);
@ -258,7 +255,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
                                     @RequestParam(required = true) String index,
                                     @RequestParam(required = true) String index,
                                     @RequestParam(required = false) String level2_type,
                                     @RequestParam(required = false) String level2_type,
                                     @RequestParam(required = true) Integer flag) {
                                     @RequestParam(required = true) Integer flag) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
            result= statisticsEsService.getDoctorStatisticsExcel(startDate,endDate,area,level,index,level2_type,flag);
            result= statisticsEsService.getDoctorStatisticsExcel(startDate,endDate,area,level,index,level2_type,flag);
@ -285,7 +281,6 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = true) String area,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index) {
            @RequestParam(required = true) String index) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        try {
        try {
            result = statisticsEsService.getSpecialConsultHead(startDate, endDate, area, level, index);
            result = statisticsEsService.getSpecialConsultHead(startDate, endDate, area, level, index);

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

@ -177,7 +177,7 @@ fastDFS:
fast-dfs:
fast-dfs:
  tracker-server: 172.26.0.110:22122 #服务器地址
  tracker-server: 172.26.0.110:22122 #服务器地址
wechat:
wechat:
  id: 97ed8a0a-4f07-4b85-ab02-b716c611a464  # base库中,wx_wechat 的id字段
  id: xm_test_ihealth_wx  # base库中,wx_wechat 的id字段
# 短信验证码发送的客户端标识,居民端
# 短信验证码发送的客户端标识,居民端
sms:
sms:
  clientId: EwC0iRSrcP
  clientId: EwC0iRSrcP
@ -217,7 +217,7 @@ FileTempPath:
testPattern:
testPattern:
  sign: 0
  sign: 0
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
  url: http://ehr.yihu.com/wlyy/
---
---
spring:
spring:
  profiles: jwprod
  profiles: jwprod
@ -365,7 +365,7 @@ es:
testPattern:
testPattern:
  sign: 0
  sign: 0
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
  url: http://ehr.yihu.com/wlyy/
---
---
spring:
spring:
  profiles: jwOracleProd
  profiles: jwOracleProd
@ -441,7 +441,7 @@ es:
testPattern:
testPattern:
  sign: 0
  sign: 0
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
  url: http://ehr.yihu.com/wlyy/
---
---
##==心脏中心 ===============================================================================
##==心脏中心 ===============================================================================
@ -512,7 +512,7 @@ es:
testPattern:
testPattern:
  sign: 0
  sign: 0
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
  url: http://ehr.yihu.com/wlyy/
---
---
##==心脏中心外 ===============================================================================
##==心脏中心外 ===============================================================================
spring:
spring:
@ -583,7 +583,7 @@ es:
testPattern:
testPattern:
  sign: 0
  sign: 0
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
  url: http://ehr.yihu.com/wlyy/
---
---
##==厦门卫计委 ===============================================================================
##==厦门卫计委 ===============================================================================
spring:
spring:

+ 124 - 21
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -458,18 +458,17 @@ public class RehabilitationManageService {
     */
     */
    public ObjEnvelop calendarPlanDetailList(String planId,Integer searchTask,Integer status,String doctorCode,String executeStartTime,String executeEndTime){
    public ObjEnvelop calendarPlanDetailList(String planId,Integer searchTask,Integer status,String doctorCode,String executeStartTime,String executeEndTime){
        String sql = " select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.content,i.title from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_service_item i on i.id = h.service_item_id " +
        String sql = " select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.code,i.name from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  " +
                " where d.execute_time>='"+executeStartTime+"' and d.execute_time<='"+executeEndTime+"' and d.plan_id='"+planId+"' " ;
                " where d.execute_time>='"+executeStartTime+"' and d.execute_time<='"+executeEndTime+"' and d.plan_id='"+planId+"' " ;
        if(searchTask!=null){
        if(searchTask!=null){
            if(searchTask==1){
            if(searchTask==1){
                sql+="and d.doctor='"+doctorCode+"' ";
                sql+="and d.doctor='"+doctorCode+"' ";
            }else if(searchTask==2||searchTask==4||searchTask==3){
            }/*else if(searchTask==2||searchTask==4||searchTask==3){
                sql+=" and i.type="+searchTask+" " ;
                sql+=" and i.type="+searchTask+" " ;
            }else if(searchTask==5){
            }else if(searchTask==5){
                sql+=" and i.reserve=1 " ;
                sql+=" and i.reserve=1 " ;
            }
            }*/
        }
        }
        if(status!=null){
        if(status!=null){
            sql+= "and d.status="+status;
            sql+= "and d.status="+status;
@ -485,7 +484,7 @@ public class RehabilitationManageService {
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public ObjEnvelop serviceItemList(String planDetailIds,String doctorCode) throws Exception{
  /*  public ObjEnvelop serviceItemList(String planDetailIds,String doctorCode) throws Exception{
        String[] s = planDetailIds.split(",");
        String[] s = planDetailIds.split(",");
        String planDetailList = "";
        String planDetailList = "";
        for(String one:s){
        for(String one:s){
@ -579,6 +578,106 @@ public class RehabilitationManageService {
         }
         }
            return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList);
            return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList);
//        }
//        }
//        return MixEnvelop.getError("没有该服务项详情信息!");
    }*/
    /**
     * 多个康复计划服务项目内容列表
     * @param planDetailIds
     * @return
     * @throws Exception
     */
    public ObjEnvelop serviceItemList(String planDetailIds,String doctorCode) throws Exception{
        String[] s = planDetailIds.split(",");
        String planDetailList = "";
        for(String one:s){
            planDetailList +=",'"+one+"'";
        }
        String planDetailResult = StringUtils.isNotEmpty(planDetailList)?planDetailList.substring(1):"";
        String sql = "select i.name,i.code,d.execute_time,d.hospital_name,d.id,d.status,d.type as detailType,d.expense,d.doctor as executeDoctor," +
                " d.doctor_name as executeDoctorName,p.patient ,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus  " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
                " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
                " where d.id in ("+planDetailResult+") order BY d.execute_time ASC ";
        List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
//        if(serviceItemList.size()>0){
//            Map<String,Object> serviceItem = serviceItemList.get(0);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> one:serviceItemList){
            Map<String,Object> resultMap = new HashMap<>();
            Integer isMyTask = 0;
            if(StringUtils.isNotEmpty(doctorCode)&&doctorCode.equals(one.get("executeDoctor")+"")){
                isMyTask=1;
            }
            resultMap.put("isMyTask",isMyTask);//0不是自己的任务,1是自己的任务
//            if(!(one.get("specialistDoctor")+"").equals((one.get("create_user")+""))){
//                executeDoctorList.add(one.get("create_user_name")+"");
//            }
            List<String> executeDoctorList = new ArrayList<>();
            executeDoctorList.add(one.get("executeDoctorName")+"");
            resultMap.put("executeDoctorList",executeDoctorList);//执行医生名称列表
            resultMap.put("executeDoctorCode",one.get("executeDoctor")+"");//执行医生code
            resultMap.put("executeDoctorName",one.get("executeDoctorName")+"");//执行医生code
            resultMap.put("specialistDoctorCode",one.get("createDoctor")+"");//创建人(专科)医生code
            resultMap.put("specialistDoctorName",one.get("createDoctorName")+"");//创建人(专科)医生名字
            resultMap.put("title",one.get("name"));//项目标题
            resultMap.put("planDetaiId",one.get("id"));//计划服务项目id
            resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
            resultMap.put("content",one.get("name"));//项目内容
            resultMap.put("hospitalName",one.get("hospital_name"));//地点
            resultMap.put("executeTime",one.get("execute_time"));//执行时间
            DecimalFormat df = new DecimalFormat("0.00");
            resultMap.put("expense", one.get("expense")!=null?df.format(((Integer)one.get("expense")*1.00)/100.00):0);//收费
            resultMap.put("reserve",null);//是否需要预约(1预约、0不预约)
            resultMap.put("planStatus",one.get("planStatus"));//计划的状态
            Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
            String statusName = "";
            switch (status){
                case 0:{statusName="未完成";break;}
                case 1:{statusName="已完成";break;}
                case 2:{statusName="已预约";break;}
            }
            resultMap.put("statusName",statusName);//状态
            //指导与汇报
            List<GuidanceMessageLogDO> messageList = guidanceMessageLogDao.findByPlanDetailId(one.get("id").toString());
            List<Map<String,Object>> messageMapList = new ArrayList<>();
            for(GuidanceMessageLogDO one2:messageList){
                Map<String,Object> map = new HashMap<>();
                map.put("doctorName",one2.getDoctorName());
                map.put("adminTeamName",one2.getAdminTeamName());
                map.put("content",one2.getContent());
                map.put("contentType",one2.getContentType());
                map.put("createTime",DateUtil.dateToStr(one2.getCreateTime(),"MM-dd HH:mm"));
                messageMapList.add(map);
            }
           /* Integer itemType = (Integer) one.get("itemType");*/
            resultMap.put("messageList",messageMapList);//指导与汇报记录
            resultMap.put("patient",one.get("patient"));
            resultMap.put("itemType",null);
            resultMap.put("detaiType",one.get("detaiType"));
            resultMap.put("status",status);//状态
            //是否完成任务
            List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
            Integer operate = 0;
            if(operateList.size()>0){
                operate =1;
                RehabilitationOperateRecordsDO temp = operateList.get(0);
                operate =1;
                Date completeTime = temp.getCompleteTime();
                String completeTimeStr = DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD_HH_MM);
                resultMap.put("completeTime",completeTimeStr);//完成时间
                resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
                resultMap.put("node",temp.getNode());
                resultMap.put("relationRecordImg",(temp.getRelationRecordImg()!=null&&StringUtils.isNotEmpty(temp.getRelationRecordImg()))?(new JSONArray(temp.getRelationRecordImg())):null);//json格式
                resultMap.put("relationRecordCode",temp.getRelationRecordCode());
                resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
            }
            resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成)
            resultList.add(resultMap);
        }
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList);
//        }
//        return MixEnvelop.getError("没有该服务项详情信息!");
//        return MixEnvelop.getError("没有该服务项详情信息!");
    }
    }
@ -590,12 +689,11 @@ public class RehabilitationManageService {
     *
     *
     */
     */
    public ObjEnvelop serviceItem(String planDetailId,String doctorCode) throws Exception{
    public ObjEnvelop serviceItem(String planDetailId,String doctorCode) throws Exception{
        String sql = "select i.title,i.content,i.type as itemType,i.reserve,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as executeDoctor, " +
        String sql = "select h.name as title,h.name as content,h.code as itemType,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as executeDoctor, " +
                " d.doctor_name as executeDoctorName,p.patient ,p.name as patientName,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus," +
                " d.doctor_name as executeDoctorName,p.patient ,p.name as patientName,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus," +
                " p.disease,p.disease_name as diseaseName,p.title as planTitle"+
                " p.disease,p.disease_name as diseaseName,p.title as planTitle"+
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_specialist.wlyy_service_item i on i.id = h.service_item_id " +
                " LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item h on d.hospital_service_item_id = h.code "+
                " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
                " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
                " where d.id = '"+planDetailId+"'";
                " where d.id = '"+planDetailId+"'";
        List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
@ -623,7 +721,7 @@ public class RehabilitationManageService {
        resultMap.put("hospitalName",one.get("hospital_name"));//地点
        resultMap.put("hospitalName",one.get("hospital_name"));//地点
        resultMap.put("executeTime",one.get("execute_time"));//执行时间
        resultMap.put("executeTime",one.get("execute_time"));//执行时间
        DecimalFormat df = new DecimalFormat("0.00");
        DecimalFormat df = new DecimalFormat("0.00");
        resultMap.put("expense",df.format(((Integer)one.get("expense")*1.00)/100.00));//收费
        resultMap.put("expense",one.get("expense")!=null?df.format(((Integer)one.get("expense")*1.00)/100.00):0);//收费
        resultMap.put("reserve",one.get("reserve"));//是否需要预约(1预约、0不预约)
        resultMap.put("reserve",one.get("reserve"));//是否需要预约(1预约、0不预约)
        resultMap.put("planStatus",one.get("planStatus"));//计划的状态
        resultMap.put("planStatus",one.get("planStatus"));//计划的状态
        Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
        Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
@ -650,11 +748,10 @@ public class RehabilitationManageService {
            map.put("createTime",DateUtil.dateToStr(one2.getCreateTime(),"MM-dd HH:mm"));
            map.put("createTime",DateUtil.dateToStr(one2.getCreateTime(),"MM-dd HH:mm"));
            messageMapList.add(map);
            messageMapList.add(map);
        }
        }
        Integer itemType = (Integer) one.get("itemType");
        resultMap.put("messageList",messageMapList);//指导与汇报记录
        resultMap.put("messageList",messageMapList);//指导与汇报记录
        resultMap.put("patient",one.get("patient"));
        resultMap.put("patient",one.get("patient"));
        resultMap.put("patientName",one.get("patientName"));
        resultMap.put("patientName",one.get("patientName"));
        resultMap.put("type",itemType);//1扫码、0上传附件、2、健康教育,3、健康指导,4、随访
        resultMap.put("type",one.get("itemType"));//1扫码、0上传附件、2、健康教育,3、健康指导,4、随访
        //是否完成任务
        //是否完成任务
        List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
        List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
@ -668,10 +765,10 @@ public class RehabilitationManageService {
            resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
            resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
            resultMap.put("node",temp.getNode());
            resultMap.put("node",temp.getNode());
            resultMap.put("relationRecordImg",(temp.getRelationRecordImg()!=null&&StringUtils.isNotEmpty(temp.getRelationRecordImg()))?(new JSONArray(temp.getRelationRecordImg())):null);//json格式
            resultMap.put("relationRecordImg",(temp.getRelationRecordImg()!=null&&StringUtils.isNotEmpty(temp.getRelationRecordImg()))?(new JSONArray(temp.getRelationRecordImg())):null);//json格式
            if(itemType!=1&&itemType!=0){
         /*   if(itemType!=1&&itemType!=0){*/
                resultMap.put("relationRecordCode",temp.getRelationRecordCode());
                resultMap.put("relationRecordCode",temp.getRelationRecordCode());
                resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
                resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
            }
  /*          }*/
        }
        }
        resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成)
        resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成)
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
@ -690,6 +787,7 @@ public class RehabilitationManageService {
        Map<String,Object> resultMap = new HashMap<>();
        Map<String,Object> resultMap = new HashMap<>();
        //个人基础信息(康复机构)
        //个人基础信息(康复机构)
        String patientInfoSql = " SELECT DISTINCT hospital_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
        String patientInfoSql = " SELECT DISTINCT hospital_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
                " where p.patient='"+patientCode+"' and p.status=1 ";
                " where p.patient='"+patientCode+"' and p.status=1 ";
@ -788,6 +886,8 @@ public class RehabilitationManageService {
            }
            }
            map.put("planTypeName",planTypeName);//安排类型名称
            map.put("planTypeName",planTypeName);//安排类型名称
            map.put("statusName",statusName);//状态名称
            map.put("statusName",statusName);//状态名称
            map.put("medicalRecordsCode",one.getMedicalRecordsCode());//住院code
            map.put("adviceContent",one.getAdviceContent());//康复建议
            //已完成
            //已完成
            Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.getId());
            Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.getId());
            map.put("allFinishCount",allFinishCount);//已完成
            map.put("allFinishCount",allFinishCount);//已完成
@ -874,8 +974,8 @@ public class RehabilitationManageService {
        Map<String,Object> resultMap = new HashMap<>();
        Map<String,Object> resultMap = new HashMap<>();
        //近期康复相关记录
        //近期康复相关记录
//        String currentTime = DateUtil.getStringDate();
//        String currentTime = DateUtil.getStringDate();
        String planDetailSql = " select d.*,i.content,i.title,s.complete_time from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_hospital_service_item h on d.hospital_service_item_id=h.id" +
                " LEFT JOIN wlyy_service_item i on i.id=h.service_item_id LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id" +
        String planDetailSql = " select d.*,h.name,h.code,s.complete_time from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id=h.code" +
                " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id" +
                " left join wlyy_rehabilitation_operate_records s on s.rehabilitation_detail_id=d.id " +
                " left join wlyy_rehabilitation_operate_records s on s.rehabilitation_detail_id=d.id " +
                " where d.status=1 and p.patient='"+patientCode+"' ";
                " where d.status=1 and p.patient='"+patientCode+"' ";
        if(StringUtils.isNotEmpty(startTime)){
        if(StringUtils.isNotEmpty(startTime)){
@ -895,8 +995,8 @@ public class RehabilitationManageService {
        for(Map<String,Object> one:planDetails){
        for(Map<String,Object> one:planDetails){
            Date executeTimeDate = (Date)one.get("complete_time");
            Date executeTimeDate = (Date)one.get("complete_time");
            String executeTime = DateUtil.dateToStr(executeTimeDate,"yyyy/MM/dd HH:mm");
            String executeTime = DateUtil.dateToStr(executeTimeDate,"yyyy/MM/dd HH:mm");
            String content = one.get("content")+"";
            String title = one.get("title")+"";
            String content = one.get("code")+"";
            String title = one.get("name")+"";
            Integer status = (Integer)one.get("status");
            Integer status = (Integer)one.get("status");
            String statusName = "";
            String statusName = "";
            switch (status){
            switch (status){
@ -917,8 +1017,8 @@ public class RehabilitationManageService {
            planDetailList.add(map);
            planDetailList.add(map);
        }
        }
        resultMap.put("planDetailList",planDetailList);//康复相关记录列表
        resultMap.put("planDetailList",planDetailList);//康复相关记录列表
        String planDetailCountSql = " select d.status as num from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_hospital_service_item h on d.hospital_service_item_id=h.id" +
                " LEFT JOIN wlyy_service_item i on i.id=h.service_item_id LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"'";
        String planDetailCountSql = " select d.status as num from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id=h.code" +
                "  LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"'";
        List<Map<String,Object>> planDetailList2 = jdbcTemplate.queryForList(planDetailCountSql);
        List<Map<String,Object>> planDetailList2 = jdbcTemplate.queryForList(planDetailCountSql);
        Integer planDetailFinish = 0;
        Integer planDetailFinish = 0;
        Integer planDetailUnfinish = 0;
        Integer planDetailUnfinish = 0;
@ -1035,7 +1135,7 @@ public class RehabilitationManageService {
        }
        }
//        String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='"+patientCode+"' and sign_status='1' and status='1'";
//        String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='"+patientCode+"' and sign_status='1' and status='1'";
        String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 and  p.patient='"+patientCode+"'";
        String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 AND d.doctor IS  NOT  NULL and  d.doctor <> ''  and  p.patient='"+patientCode+"'";
        List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
        List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
        for(Map<String,Object> one:specialistRelationList){
        for(Map<String,Object> one:specialistRelationList){
            String doctor = one.get("doctor")+"";
            String doctor = one.get("doctor")+"";
@ -1255,6 +1355,9 @@ public class RehabilitationManageService {
            resultMap.put("planTitle",p.getTitle());
            resultMap.put("planTitle",p.getTitle());
            resultMap.put("status", p.getStatus());
            resultMap.put("status", p.getStatus());
            resultMap.put("patientImg", p.getPatientImg());
            resultMap.put("patientImg", p.getPatientImg());
            resultMap.put("adviceContent",p.getAdviceContent());
            resultMap.put("medicalRecordsCode",p.getMedicalRecordsCode());
        }
        }
//        resultMap.put("healthyCondition",healthyCondition);
//        resultMap.put("healthyCondition",healthyCondition);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);