Browse Source

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

wangjun 3 years ago
parent
commit
fab7ac8f83
100 changed files with 5082 additions and 329 deletions
  1. 4 9
      business/base-service/src/main/java/com/yihu/jw/complaint/BaseComplaintService.java
  2. 18 4
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  3. 6 6
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseBannerDoctorService.java
  4. 70 4
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseUserMsgService.java
  5. 5 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNatAppointmentDao.java
  6. 246 13
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  7. 1139 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TasyNatService.java
  8. 4 4
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java
  9. 37 1
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  10. 4 3
      business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java
  11. 75 0
      common/common-entity/sql记录
  12. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  13. 31 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java
  14. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageRecordDO.java
  15. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java
  16. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java
  17. 46 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/booking/BaseBookingServiceDo.java
  18. 103 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/PatientSosContactsDO.java
  19. 85 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/BaseEmergencyWarnLogDO.java
  20. 10 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  21. 2 4
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/BusinessMapping.java
  22. 2 0
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupSign.java
  23. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNatAppointmentDO.java
  24. 13 4
      common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java
  25. 2 0
      common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/RehabilitationguidanceDO.java
  26. 2 4
      common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/RehabilitationguidancePatientDO.java
  27. 4 4
      common/common-entity/src/main/java/com/yihu/jw/entity/util/SystemConf.java
  28. 156 0
      common/common-entity/src/main/java/com/yihu/jw/entity/voluntary/VoluntaryRecruitmentArrangeDO.java
  29. 111 0
      common/common-entity/src/main/java/com/yihu/jw/entity/voluntary/VoluntaryRecruitmentCompanyDO.java
  30. 111 0
      common/common-entity/src/main/java/com/yihu/jw/entity/voluntary/VoluntaryRecruitmentPeopleDO.java
  31. 39 3
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/emergency/EmergencyOrderVO.java
  32. 49 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  33. 31 23
      common/common-util/src/main/java/com/yihu/jw/util/healthIndex/HealthIndexUtil.java
  34. 3 2
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/DidiFilterProcessor.java
  35. 16 0
      gateway/ag-basic/src/main/resources/application.yml
  36. 9 1
      gateway/ag-basic/src/main/resources/bootstrap.yml
  37. 16 16
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  38. 5 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  39. 25 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWjwConfigService.java
  40. 35 35
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWlyyConfigService.java
  41. 31 1
      server/svr-authentication/src/main/resources/application.yml
  42. 9 1
      server/svr-authentication/src/main/resources/bootstrap.yml
  43. 15 0
      server/svr-configuration/src/main/resources/bootstrap.yml
  44. 15 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentArrangeDao.java
  45. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentCompanyDao.java
  46. 24 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentPeopleDao.java
  47. 2 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/TemplateManageEndpoint.java
  48. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java
  49. 160 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentArrangeEndpoint.java
  50. 157 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentCompanyEndpoint.java
  51. 246 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentEndpoint.java
  52. 107 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentPeopleEndpoint.java
  53. 47 22
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/TemplateManageService.java
  54. 1 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  55. 3 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java
  56. 12 12
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java
  57. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageService.java
  58. 18 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentArrangeService.java
  59. 18 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentCompanyService.java
  60. 18 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentPeopleService.java
  61. 154 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentService.java
  62. 4 0
      svr/svr-cloud-care/sql/init.sql
  63. 34 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/NetworkCardConfig.java
  64. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/assistance/EmergencyAssistanceDao.java
  65. 21 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/booking/BaseBookingServiceDao.java
  66. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/contacts/PatientSosContactsDao.java
  67. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  68. 16 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/BaseEmergencyWarnLogDao.java
  69. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/SecurityMonitoringOrderDao.java
  70. 17 15
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java
  71. 49 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/booking/BaseBookingServiceEndpoint.java
  72. 35 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java
  73. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java
  74. 81 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/NetworkCardController.java
  75. 19 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  76. 59 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  77. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientHealthController.java
  78. 6 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java
  79. 10 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  80. 4 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java
  81. 32 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java
  82. 39 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/OnlineContactEndpoint.java
  83. 40 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientBirthdayWishesEndpoint.java
  84. 15 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java
  85. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  86. 36 9
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  87. 56 21
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  88. 89 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  89. 42 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  90. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/securrity/SecuMonOrderEndpoint.java
  91. 110 42
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  92. 29 12
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java
  93. 37 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/booking/BaseBookingServiceService.java
  94. 4 13
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java
  95. 171 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  96. 121 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java
  97. 155 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  98. 92 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  99. 6 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  100. 0 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java

+ 4 - 9
business/base-service/src/main/java/com/yihu/jw/complaint/BaseComplaintService.java

@ -19,21 +19,16 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.enterprise.EnterpriseService;
import jdk.management.resource.internal.TotalResourceContext;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.CriteriaBuilder;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
@ -431,9 +426,9 @@ public class BaseComplaintService {
                " t.mobile as \"mobile\"," +
                " t.passto as \"passto\"," +
                " t.acceptor_name as \"acceptorName\"" +
                "from base_complaint t  " +
                " from base_complaint t  " +
                " left join base_patient b on t.patient=b.id " ;
        sql+=" left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del=1 ";
        sql+=" left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1 '";
        if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
            sql+=" and  g.status='3' ";
        }/*else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
@ -615,7 +610,7 @@ public class BaseComplaintService {
                " t.acceptor_name as \"acceptorName\"" +
                " from base_complaint t " +
                " left join base_patient b on t.patient=b.id" +
                " where t.is_del=1";
                " where t.is_del='1'";
        if (StringUtils.isNoneBlank(status)){
            sql+=" and t.status ='"+status+"'";
        }
@ -736,7 +731,7 @@ public class BaseComplaintService {
                "  from base_complaint t  " +
                " left join base_patient b on t.patient=b.id " ;
        sql+=" left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del=1 ";
        sql+=" left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
        if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
            sql+="  and g.status='3' ";
        } /*else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){

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

@ -73,7 +73,16 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
        MixEnvelop mixEnvelop = new MixEnvelop();
        try{
        BasePatientMemberDictDO basePatientMemberDictDO = basePatientMemberDictDao.findOne(dictId);
        BasePatientDO basePatientDO = basePatientDao.findByIdcard(idCard);
        BasePatientDO basePatientDO = null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            List<BasePatientDO> listpatients=basePatientDao.findByMobileAndDel(phoneNum,"1");
            if (listpatients!=null&&listpatients.size()>0){
                basePatientDO=listpatients.get(0);
            }
        }else {
            basePatientDO= basePatientDao.findByIdcard(idCard);
        }
        List<BasePatientDO> list = basePatientDao.findByMobile(phoneNum);
        if ("xm_xzzx_wx".equalsIgnoreCase(wxId)){
            if (list!=null&&list.size()>0&&basePatientDO!=null){
@ -380,9 +389,14 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                            System.out.println("==="+jsonArray.get(i).toString());
                            if (StringUtils.isNotEmpty(jsonObject1.getString("IDCARD"))){
                                System.out.println("同步的身份证号:"+jsonObject1.getString("IDCARD"));
                                BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(jsonObject1.getString("IDCARD"),"1");
                                if (patientDO==null){
                                    patientDO = new BasePatientDO();
                                BasePatientDO patientDO = null;
                                if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                                    List<BasePatientDO> listpatients=basePatientDao.findByMobileAndDel(jsonObject1.getString("TEL"),"1");
                                    if (listpatients!=null&&listpatients.size()>0){
                                        patientDO=listpatients.get(0);
                                    }
                                }else {
                                    patientDO= basePatientDao.findByIdcard(jsonObject1.getString("IDCARD"));
                                }
                                patientDO.setMobile(jsonObject1.getString("TEL"));
                                if(StringUtils.isNotBlank(jsonObject1.getString("BIRTHDAY"))){

File diff suppressed because it is too large
+ 6 - 6
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseBannerDoctorService.java


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

@ -1,13 +1,17 @@
package com.yihu.jw.hospital.message.service;
import com.alibaba.fastjson.JSONObject;
import com.google.j2objc.annotations.AutoreleasePool;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.score.BaseEvaluateDO;
import com.yihu.jw.entity.base.score.BaseEvaluateScoreDO;
import com.yihu.jw.entity.base.words.BaseSensitiveDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.httplog.BaseOperateLogDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
import com.yihu.jw.entity.hospital.message.BaseUserMessageDO;
@ -15,6 +19,7 @@ import com.yihu.jw.entity.hospital.message.BaseUserMsgContentDO;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateDao;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateScoreDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.BaseOperateLogDao;
import com.yihu.jw.hospital.message.dao.BaseBannerDao;
import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
import com.yihu.jw.hospital.message.dao.BaseUserMessageDao;
@ -80,6 +85,10 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
    private StringRedisTemplate redisTemplate;
    @Autowired
    private BaseBannerDoctorService baseBannerDoctorService;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private BaseOperateLogDao baseOperateLogDao;
    @Value("${wechat.id}")
    private String wxId;
@ -192,7 +201,7 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
    }
    //评论留言展示
    public Envelop getMessage(String doctor, String showAll, String showAllType, String beginTime, String endTime, Integer page, Integer pageSize) {
    public Envelop getMessage(String doctor, String showAll, String showAllType, String beginTime, String endTime,String patient, Integer page, Integer pageSize) {
        StringBuffer sql = new StringBuffer();
        Map<String,Object> params = new HashedMap();
        sql.append("select t.id as \"id\" ,t.content as \"content\",t.type as \"type\"," +
@ -214,6 +223,9 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        if (StringUtils.isNotEmpty(doctor)) {
            sql.append(" and t.receiver = '" + doctor + "'");
        }
        if (StringUtils.isNotEmpty(patient)) {
            sql.append(" and t.sender = '" + patient + "'");
        }
        if (StringUtils.isNotEmpty(showAll)) {
            sql.append(" and t.status = " + showAll);
        }
@ -266,6 +278,18 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
            if (map.get("type")!=null){
                baseUserMsgDO.setType(Integer.valueOf(map.get("type").toString()));
            }
            String reciveDoctor=null==map.get("receiver")?"":map.get("receiver").toString();
            List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(reciveDoctor);
            if (baseDoctorHospitalDOS!=null&&baseDoctorHospitalDOS.size()>0){
                returnMap.put("deptName",baseDoctorHospitalDOS.get(0).getDeptName());
            }
            BaseDoctorDO baseDoctorDO=baseDoctorDao.findById(reciveDoctor);
            if (baseDoctorDO!=null){
                returnMap.put("doctorName",baseDoctorDO.getName());
                returnMap.put("doctorPhoto",baseDoctorDO.getPhoto());
                returnMap.put("jobtitleName",baseDoctorDO.getJobTitleName());
            }
            baseUserMsgDO.setReceiver(null==map.get("receiver")?"":map.get("receiver").toString());
            baseUserMsgDO.setReceiverName(null==map.get("receiver_name")?"":map.get("receiver_name").toString());
            baseUserMsgDO.setSender(null==map.get("sender")?"":map.get("sender").toString());
@ -279,6 +303,7 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
                }
            }
            baseUserMsgDO.setContent(content);
            baseUserMsgDO.setRelationCode(null==map.get("relation_code")?"":map.get("relation_code").toString());
            baseUserMsgDO.setRelationType(null==map.get("relation_type")?0:Integer.valueOf(map.get("relation_type").toString()));
@ -527,9 +552,50 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        }
        return true;
    }
    public void deleteMessageOrMessageContent(String msgId,String isDelParent){
        if ("1".equalsIgnoreCase(isDelParent)){
            BaseUserMessageDO baseUserMessageDO = baseUserMessageDao.findOne(msgId);
            if (baseUserMessageDO!=null){
                BaseOperateLogDO baseOperateLogDO = new BaseOperateLogDO();
                JSONObject jsonObject = new JSONObject();
                baseUserMessageDO.setDel(0);
                baseUserMessageDao.save(baseUserMessageDO);
                baseOperateLogDO.setOperator(baseUserMessageDO.getSender());
                baseOperateLogDO.setIsDel("0");
                List<BaseBannerDoctorDO> ba =  baseBannerDoctorDao.getBanners(baseUserMessageDO.getReceiver(),baseUserMessageDO.getSender(),baseUserMessageDO.getRelationCode());
                if(ba!=null&&ba.size()>0){
                    jsonObject.put("banners",ba);
                    baseBannerDoctorDao.delete(ba);
                }
    public static void main(String[] args) throws Exception {
        String sex = IdCardUtil.getSexForIdcard_new("411526199410084833");
        System.out.println(sex);
                List<BaseEvaluateScoreDO> scoreList= baseEvaluateScoreDao.findByRelationCode(baseUserMessageDO.getRelationCode());
                if (scoreList!=null&&scoreList.size()>0){
                    for (BaseEvaluateScoreDO baseEvaluateScoreDO:scoreList){
                        List<BaseEvaluateDO> baseEvaluateDO=baseEvaluateDao.findByRelationCode(baseEvaluateScoreDO.getId());
                        jsonObject.put(baseEvaluateScoreDO.getId(),baseEvaluateDO);
                        if (baseEvaluateDO!=null&&baseEvaluateDO.size()>0){
                            baseEvaluateDao.delete(baseEvaluateDO);
                        }
                    }
                    jsonObject.put("scoreList",scoreList);
                    baseEvaluateScoreDao.delete(scoreList);
                }
                baseOperateLogDO.setRelationCode(baseUserMessageDO.getId());
                baseOperateLogDO.setName("删除留言评价");
                baseOperateLogDO.setRelationType(jsonObject.toString());
                try {
                    baseOperateLogDao.save(baseOperateLogDO);
                }catch (Exception e){
                    e.printStackTrace();
                }
                List<BaseUserMsgContentDO> contentlist=baseUserMsgContentDao.getContentListByID(msgId);
                for (BaseUserMsgContentDO baseUserMsgContentDO:contentlist){
                    baseUserMsgContentDO.setDel(0);
                    baseUserMsgContentDao.save(baseUserMsgContentDO);
                }
            }
        }
    }
}

+ 5 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNatAppointmentDao.java

@ -13,10 +13,14 @@ public interface BaseNatAppointmentDao extends PagingAndSortingRepository<BaseNa
    @Query("from BaseNatAppointmentDO t where t.payStatus = 0 ")
    List<BaseNatAppointmentDO> findByPayStatus();
    @Query("from BaseNatAppointmentDO t where t.payStatus = 0 and t.isSuccess=1 and t.patientId=?1")
    @Query("from BaseNatAppointmentDO t where  t.payStatus = 0 and t.isSuccess=1 and t.patientId=?1")
    List<BaseNatAppointmentDO> findPayStatusByPatientId(String patientId);
    @Query("from BaseNatAppointmentDO t where t.patientId=?1 and t.payStatus in (0,1) and t.isSuccess=1 ")
    List<BaseNatAppointmentDO> findByTasy(String patientId);
    @Query("select a from BaseNatAppointmentDO a where  a.realOrder =?1 ")
    List<BaseNatAppointmentDO> findByRealOrderList(String realOrder);
}

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

@ -322,6 +322,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private BaseAdviceTreatmentDao baseAdviceTreatmentDao;
    @Autowired
    private EnterpriseService enterpriseService;
    @Autowired
    private TasyNatService tasyNatService;
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -7533,31 +7535,39 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "AND outpatient.doctor='" + doctor + "' " +
                "AND outpatient.pay_status = 1 " +
                "AND outpatient.outpatient_type= '" + outpatient_type + "'  ";
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        Calendar now = Calendar.getInstance();
        now.setTime(date);
        System.out.println(sdf.format(now.getTime()));
        now.add(Calendar.DAY_OF_MONTH, -1);
        System.out.println(sdf.format(now.getTime()));
        if (!"xm_ihealth_wx".contains(wxId)){
            if ("1".equals(outpatient_type)||"3".equals(outpatient_type)) {//复诊
                sql = sql + " AND outpatient.type= '" + type + "' ";
                if ("2".equals(type)) {//视频复诊才需要判断时间,
                    if ("xm_ykyy_wx".equals(wxId)) {
                        if (flag){
                            sql += " AND outpatient.register_date is not null and outpatient.register_date >= str_to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                            sql += " AND outpatient.register_date is not null and outpatient.register_date >= str_to_date('" + sdf.format(now.getTime()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                        }else {
                            sql += " AND outpatient.register_date is not null and outpatient.register_date >= to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                            sql += " AND outpatient.register_date is not null and outpatient.register_date >= to_date('" + sdf.format(now.getTime()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                        }
                    } else {
                        sql = sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '" + DateUtil.dateToStrShort(new Date()) + " 00:00:00' ";
                        sql = sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '" + sdf.format(now.getTime()) + " 00:00:00' ";
                    }
                }
            } else if ("2".equals(outpatient_type)) {
                //协同门诊也需要判断时间
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        sql += " AND outpatient.register_date is not null and outpatient.register_date >= str_to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                        sql += " AND outpatient.register_date is not null and outpatient.register_date >= str_to_date('" + sdf.format(now.getTime()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        sql += " AND outpatient.register_date is not null and outpatient.register_date >= to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                        sql += " AND outpatient.register_date is not null and outpatient.register_date >= to_date('" + sdf.format(now.getTime()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    sql = sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '" + DateUtil.dateToStrShort(new Date()) + " 00:00:00' ";
                    sql = sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '" + sdf.format(now.getTime()) + " 00:00:00' ";
                }
            }
        }
@ -11338,11 +11348,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
       return doorServiceCount;
    }
    public MixEnvelop findJobCategory(){
        String sqlPid = "select id as \"id\",name as \"name\",pid as \"pid\" from base_job_category  where pid = 0 and del = 1";
        String sqlPid = "select id as \"id\",name as \"name\",code as \"code\",pid as \"pid\" from base_job_category  where pid = 0 and del = 1";
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sqlPid);
        if (list.size()>0){
            for (Map<String,Object> map:list){
                String child = "select id as \"id\",name as \"name\",pid as \"pid\" from base_job_category  where del = 1";
                String child = "select id as \"id\",name as \"name\",code as \"code\",pid as \"pid\" from base_job_category  where del = 1";
                String pid = map.get("id").toString();
                child+=" and pid = "+pid;
                List<Map<String,Object>> childList = hibenateUtils.createSQLQuery(child);
@ -11374,7 +11384,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return null;
    }
    public Map saveNatAppointment(String chargeAmount,String inspectionName,String mediaCard,String patientId,String name,String cardNo,String cardType,String mobile,
                                   String firstJobCode,String firstJobName,String secondJobCode,String secondJobName,String natTime,String address,String provinceName,String cityName,String townName,String streetName,String pm,String pushChannel,String pushFlag,String cardNoType,String consumer) throws Exception {
                                   String firstJobCode,String firstJobName,String secondJobCode,String secondJobName,String natTime,String address,String provinceName,String cityName,String townName,String streetName,String pm,String pushChannel,String pushFlag,String cardNoType,String consumer,String preNo) throws Exception {
        Map returnMap = new HashMap();
        List<WlyyHospitalSysDictDO> natConfigList = wlyyHospitalSysDictDao.findByDictName("natConfigList");
        String checkPart = "鼻/咽拭子";
@ -11679,6 +11689,194 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            returnMap.put("id",baseNatAppointmentDO.getId());
            returnMap.put("realOrder",baseNatAppointmentDO.getRealOrder());
            return returnMap;
        }else if (wechatId.equalsIgnoreCase("xm_tasy_wx")){
            BasePatientDO  basePatientDO = basePatientDao.findById(patientId);
            List<WlyyHospitalSysDictDO> tasyList = wlyyHospitalSysDictDao.findByDictName("natConfigList");
            String deptCode = "0001";
            String staffNo = "0001";
            String staffName = "0001";
            String regDept="";
            String deptName="";
            String itemPrice="";
            for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:tasyList){
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"deptCode".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    deptCode = wlyyHospitalSysDictDO.getDictValue();
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"staffNo".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    staffNo = wlyyHospitalSysDictDO.getDictValue();
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"regDept".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    regDept = wlyyHospitalSysDictDO.getDictValue();
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"deptName".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    deptName = wlyyHospitalSysDictDO.getDictValue();
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"staffName".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    staffName = wlyyHospitalSysDictDO.getDictValue();
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"itemPrice".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    itemPrice = wlyyHospitalSysDictDO.getDictValue();
                }
            }
            Double natFee = 8000.0;
            if(StringUtils.isNoneBlank(itemPrice)){
                natFee= Double.parseDouble(itemPrice)*100;
            }
            //先预约号源
            Date format2 = null;
            format2 = new SimpleDateFormat("yyyy-MM-dd").parse(natTime);
            String shortDate = new SimpleDateFormat("yyyyMMdd").format(format2);
            System.out.println("yyyy-MM-dd转yyyyMMdd:"+shortDate);
           /* String regRes=tasyNatService.saveRegOrder(regDept,shortDate,pm,preNo,cardNo,mobile,name,"3");
            com.alibaba.fastjson.JSONObject regObj = com.alibaba.fastjson.JSONObject.parseObject(regRes);
            String HisSeqNo="";
            String orderNum="";
            if (regObj!=null){
                if ("true".equalsIgnoreCase(regObj.getString("success"))){
                    com.alibaba.fastjson.JSONObject dataObj = com.alibaba.fastjson.JSONObject.parseObject(regObj.getString("data"));
                    HisSeqNo=dataObj.getString("HisSeqNo").trim();
                    orderNum=dataObj.getString("OrderNumber").trim();
                }else {
                    returnMap.put("msg",regObj.getString("data"));
                    returnMap.put("status","-1");
                    return  returnMap;
                }
            }*/
            //先进行核算检测预约
            String realOrder="";
            String addressNow=provinceName+cityName+townName+streetName+address;
            String result = tasyNatService.initNatParams("",name.trim(),mediaCard.trim(),addressNow,firstJobCode,secondJobCode);
            Boolean flag = false;
            if (StringUtils.isNoneBlank(result)){
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                logger.info("核酸检测预约结束"+result);
                if (object!=null){
                    String returnCode = object.getString("ReturnCode");
                    System.out.println("returnCode"+returnCode);
                    if ("0".equalsIgnoreCase(returnCode)){
                        returnMap.put("msg",object.getString("data"));
                        returnMap.put("status","-1");
                        //tasyNatService.cancleOrder(cardNo,HisSeqNo,orderNum);
                        return  returnMap;
                    }else {
                        flag = true;
                        System.out.println(flag);
                        realOrder=object.getString("hisTradeNo");
                        System.out.println(realOrder);
                    }
                }
            }
            if (flag){
                logger.info("BaseNatAppointmentDO保存开始");
                BaseNatAppointmentDO baseNatAppointmentDO= new BaseNatAppointmentDO();
                baseNatAppointmentDO.setChargeAmount(itemPrice);
                baseNatAppointmentDO.setMedicare(mediaCard.trim());
                //baseNatAppointmentDO.setRegisterNo(HisSeqNo);
                baseNatAppointmentDO.setName(name);
                baseNatAppointmentDO.setCardNo(cardNo.trim());
                baseNatAppointmentDO.setCardType(cardType);
                baseNatAppointmentDO.setAddress(address);
                //baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDateLong(natTime));
                //baseNatAppointmentDO.setOderNum(orderNum);
                baseNatAppointmentDO.setCityName(cityName);
                baseNatAppointmentDO.setFirstJobCode(firstJobCode);
                baseNatAppointmentDO.setFirstJobName(firstJobName);
                baseNatAppointmentDO.setSecondJobCode(secondJobCode);
                baseNatAppointmentDO.setSecondJobName(secondJobName);
                baseNatAppointmentDO.setProvinceName(provinceName);
                baseNatAppointmentDO.setTownName(townName);
                baseNatAppointmentDO.setStreetName(streetName);
                baseNatAppointmentDO.setPatientId(patientId);
                baseNatAppointmentDO.setIsSuccess("0");
                baseNatAppointmentDO.setCardNoType(cardNoType);
                baseNatAppointmentDO.setPayStatus("0");
                baseNatAppointmentDO.setCreateTime(new Date());
                baseNatAppointmentDO.setMobile(mobile);
                baseNatAppointmentDO.setInspectionCode(chargeCode);
                baseNatAppointmentDO.setInspectionName(inspectionName);
                baseNatAppointmentDO.setIcdCode(icdCode);
                baseNatAppointmentDO.setChargeCode(chargeCode);
                baseNatAppointmentDO.setWinNo(String.valueOf(winNo));
                baseNatAppointmentDO.setDept(deptCode);
                baseNatAppointmentDO.setDeptName(deptName);
                baseNatAppointmentDO.setRealOrder(realOrder);
                baseNatAppointmentDO.setAmpm(pm);
                baseNatAppointmentDO.setDoctorId(staffNo);
                baseNatAppointmentDO.setConsumer(consumer);
                baseNatAppointmentDO.setDoctorName(staffName);
                baseNatAppointmentDO.setAppointmentTime(new Date());
                baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
                logger.info("BaseNatAppointmentDO保存结束"+baseNatAppointmentDO.getId());
                //添加订单
                BusinessOrderDO businessDO = new BusinessOrderDO();
                businessDO.setPatient(consumer);
                businessDO.setPatientName(basePatientDO.getName());
                businessDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
                businessDO.setCreateTime(new Date());
                businessDO.setStatus(0);
                businessDO.setRelationCode(baseNatAppointmentDO.getId()+"");
                businessDO.setRelationName("核酸检测订单");
                businessDO.setOrderCategory("6");
                businessDO.setOrderType(12);
                businessDO.setPayPrice(natFee);
                businessDO.setRematk("核酸检测订单");
                businessDO.setDescription("核酸检测订单");
                businessDO.setPayType(1);
                businessDO.setUpdateTime(new Date());
                businessDO=businessOrderDao.save(businessDO);
                String openId="";
                List<BasePatientWechatDo> basePatientWechatDo = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,consumer);
                if (basePatientWechatDo!=null&&basePatientWechatDo.size()>0){
                    openId=basePatientWechatDo.get(0).getOpenid();
                }
                //亿同支付创建订单
                com.alibaba.fastjson.JSONObject orderObj= new com.alibaba.fastjson.JSONObject();
                orderObj.put("payType",1);
                orderObj.put("tradeNo",businessDO.getOrderNo());
                orderObj.put("openId",openId);
                orderObj.put("name",name);
                orderObj.put("idNo",cardNo.trim());
                Map mapHis=tasyNatService.getPatientHisId(cardNo.trim(),mediaCard.trim());
                orderObj.put("patientId",mapHis.get("Patientid").toString());
                orderObj.put("mobile",mapHis.get("MobilePhone").toString());
                //orderObj.put("socialCard","");
                orderObj.put("icCard",mediaCard);
                BigDecimal b = new BigDecimal(itemPrice);
                b=b.setScale(2, BigDecimal.ROUND_DOWN);
                System.out.println("amount"+b);
                orderObj.put("amount",b);
                String orderRes=tasyNatService.placeOrder(orderObj);
                if (StringUtils.isNoneBlank(orderRes)){
                    com.alibaba.fastjson.JSONObject jsonObject= JSON.parseObject(orderRes);
                    if (jsonObject!=null){
                        if("0".equalsIgnoreCase(jsonObject.getString("code"))){
                            com.alibaba.fastjson.JSONObject dataObj= com.alibaba.fastjson.JSONObject.parseObject(jsonObject.getString("data"));
                            businessDO.setTraceNo(dataObj.getString("orderNo"));
                            businessDO.setRematk(dataObj.toJSONString());
                            businessDO=businessOrderDao.save(businessDO);
                        }
                    }
                }
                try {
                    tasyNatService.sendWxtemplateMessaeg(baseNatAppointmentDO.getConsumer(),baseNatAppointmentDO.getName(),"hszftx",baseNatAppointmentDO.getId().toString());
                    tasyNatService.sendWxtemplateMessaeg(baseNatAppointmentDO.getConsumer(),baseNatAppointmentDO.getName(),"hsyycg",baseNatAppointmentDO.getId().toString());
                }catch (Exception e){
                    e.printStackTrace();
                }
                logger.info("开单结束");
                returnMap.put("msg","预约成功");
                returnMap.put("status","200");
                returnMap.put("id",baseNatAppointmentDO.getId());
                returnMap.put("realOrder",baseNatAppointmentDO.getRealOrder());
                baseNatAppointmentDO.setIsSuccess("1");
                baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
            }else {
                returnMap.put("msg","核酸开方失败");
                returnMap.put("status","-1");
                return returnMap;
            }
            return returnMap;
        }
        return returnMap;
    }
@ -11868,13 +12066,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "t.id as \"id\"," +
                "t.card_no_type as \"cardNoType\"," +
                "t.HOSPITAL_FLAG as \"hospitalFlag\"," +
                "t.charge_amount as \"chargeAmount\"," +
                "t.appointment_time as \"appointmentTime\" " +
                " from base_nat_appointment t where 1=1 ";
                "t.charge_amount as \"chargeAmount\"," ;
        if ("xm_tasy_wx".equalsIgnoreCase(wechatId)){
            sql+=" date_format(t.appointment_time ,'%Y-%m-%d' ) as \"appointmentTime\" ";
        }else {
            sql+=" t.appointment_time as \"appointmentTime\"";
        }
        sql+=  " from base_nat_appointment t where 1=1 ";
        if (StringUtils.isNoneBlank(patientId)){
            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
                sql+=" and t.consumer ='"+patientId+"'";
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_tasy_wx")){
                sql+=" and t.consumer ='"+patientId+"'";
            } else {
                sql+=" and t.patient_id ='"+patientId+"'";
            }
@ -12066,6 +12271,34 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                            ykyyEntranceService.updateHisStatus(update01sq);
                        }
                    }else if("xm_tasy_wx".equalsIgnoreCase(wechatId)){
                        if (StringUtils.isNoneBlank(baseNatAppointmentDO.getRealOrder())){
                            logger.info("同步his订单状态"+baseNatAppointmentDO.getRealOrder());
                            //取消号源
                            //String registerCancel =tasyNatService.cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                            /*com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(registerCancel);
                            String isSuccess=jsonObject.getString("success");*/
                            String natCancel=tasyNatService.cancelNat(baseNatAppointmentDO.getRealOrder(),baseNatAppointmentDO.getMedicare().trim(),baseNatAppointmentDO.getName());
                            com.alibaba.fastjson.JSONObject jsonObject1 = JSON.parseObject(natCancel);
                            String returnCode=jsonObject1.getString("ReturnCode");
                            if ("1".equalsIgnoreCase(returnCode)){
                                System.out.println("11111");
                                baseNatAppointmentDO.setIsSuccess("-1");
                                baseNatAppointmentDO.setCancelReson("患者本人取消");
                                baseNatAppointmentDO.setCancelTime(new Date());
                                baseNatAppointmentDO.setCancelBy(patientId);
                                baseNatAppointmentDao.save(baseNatAppointmentDO);
                                res="success";
                            }
                            /*String backMsg="";
                            if ("0".equalsIgnoreCase(returnCode)){
                                backMsg+=jsonObject1.getString("ReturnMsg");
                            }
                            if (!"true".equalsIgnoreCase(isSuccess)){
                                String data=jsonObject1.getString("data");
                                backMsg+=jsonObject1.getString("ReturnMsg");
                            }*/
                        }
                    }

+ 1139 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TasyNatService.java

@ -0,0 +1,1139 @@
package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.prescription.BaseNatAppointmentDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.prescription.dao.BaseNatAppointmentDao;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.utils.date.DateUtil;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
@Transactional
public class TasyNatService {
    private static Logger logger = LoggerFactory.getLogger(TasyNatService.class);
    private static String operator="健康之路";
    private static String key="1";
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private BaseNatAppointmentDao baseNatAppointmentDao;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    public String getOperateUrl(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("TasyWebOperateService");
        String url = list.get(0).getDictCode();
        return url;
    }
    public String gethsQueryDataWS(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("hdrQueryDataWSUrl");
        String url = list.get(0).getDictCode();
        return url;
    }
    public String getTaszWebServiceInfo(String api, Map<String,String> params, String url)throws Exception{
        logger.info("url"+url);
        List<WlyyHospitalSysDictDO> xzzxNamespaces =  wlyyHospitalSysDictDao.findByDictName("TasyNamespace");
        String xzzxNamespace = xzzxNamespaces.get(0).getDictCode();
        logger.info("TasyNamespace",xzzxNamespace);
        return WebserviceUtil.post(url,xzzxNamespace,api,params);
    }
    /**
     * 线上注册
     * @return
     */
    public String registerPatient(JSONObject jsonObject)throws Exception{
        String api = "SickNocardRegister";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(jsonObject.getString("IdType"))){
            condition += "<IdType>"+jsonObject.getString("IdType")+"</IdType>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("IdNo"))){
            condition += "<IdNo>"+jsonObject.getString("IdNo")+"</IdNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("UserName"))){
            condition += "<UserName>"+jsonObject.getString("UserName")+"</UserName>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("UserSex"))){
            condition += "<UserSex>"+jsonObject.getString("UserSex")+"</UserSex>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("MobilePhone"))){
            condition += "<MobilePhone>"+jsonObject.getString("MobilePhone")+"</MobilePhone>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("Birthday"))){
            condition += "<Birthday>"+jsonObject.getString("Birthday")+"</Birthday>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("Address "))){
            condition += "<Address >"+jsonObject.getString("Address ")+"</Address >";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("WorkUnit"))){
            condition += "<WorkUnit>"+jsonObject.getString("WorkUnit")+"</WorkUnit>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("CardType"))){
            condition += "<CardType>"+jsonObject.getString("CardType")+"</CardType>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("CardNo"))){
            condition += "<CardNo>"+jsonObject.getString("CardNo")+"</CardNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("Citizen"))){
            condition += "<Citizen>"+jsonObject.getString("Citizen")+"</Citizen>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("BirthPlace"))){
            condition += "<BirthPlace>"+jsonObject.getString("BirthPlace")+"</BirthPlace>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("MaritalStatus"))){
            condition += "<MaritalStatus>"+jsonObject.getString("MaritalStatus")+"</MaritalStatus>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("UnitPhone"))){
            condition += "<UnitPhone>"+jsonObject.getString("UnitPhone")+"</UnitPhone>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("Email"))){
            condition += "<Email>"+jsonObject.getString("Email")+"</Email>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("Community"))){
            condition += "<Community>"+jsonObject.getString("Community")+"</Community>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("ContactName"))){
            condition += "<ContactName>"+jsonObject.getString("ContactName")+"</ContactName>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("ContactRelation"))){
            condition += "<ContactRelation>"+jsonObject.getString("ContactRelation")+"</ContactRelation>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("ContactPhone"))){
            condition += "<ContactPhone>"+jsonObject.getString("ContactPhone")+"</ContactPhone>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("ContactAddress"))){
            condition += "<ContactAddress>"+jsonObject.getString("ContactAddress")+"</ContactAddress>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("Id000"))){
            condition += "<Id000>"+jsonObject.getString("Id000")+"</Id000>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("registerPatient params:"+params.toString());
        String xml = getTaszWebServiceInfo("CallInterface",params,getOperateUrl());
        /*xml= xml.replace("<![CDATA[<?xml version=\"1.0\" encoding=\"utf-8\"?>","");
        xml= xml.replace("]]>","");*/
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        System.out.println(xml);
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("registerPatient json:"+json);
        return json;
    }
    /**
     * 挂号+项目开单
     * @return
     */
    public String insertNucleicBill(JSONObject jsonObject)throws Exception{
        String api = "insertNucleicBill";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(jsonObject.getString("deptCode"))){
            condition += "<deptCode>"+jsonObject.getString("deptCode")+"</deptCode>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("staffNo"))){
            condition += "<staffNo>"+jsonObject.getString("staffNo")+"</staffNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("preNo"))){
            condition += "<preNo>"+jsonObject.getString("preNo")+"</preNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("icCardNo"))){
            condition += "<icCardNo>"+jsonObject.getString("icCardNo")+"</icCardNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("patientName"))){
            condition += "<patientName>"+jsonObject.getString("patientName")+"</patientName>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("registerFee"))){
            condition += "<registerFee>"+jsonObject.getString("registerFee")+"</registerFee>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("clinicFee"))){
            condition += "<clinicFee>"+jsonObject.getString("clinicFee")+"</clinicFee>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("address_now"))){
            condition += "<address_now>"+jsonObject.getString("address_now")+"</address_now>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("ncp_standing_type"))){
            condition += "<ncp_standing_type>"+jsonObject.getString("ncp_standing_type")+"</ncp_standing_type>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("ncp_profession"))){
            condition += "<ncp_profession>"+jsonObject.getString("ncp_profession")+"</ncp_profession>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("ncp_profession_sub"))){
            condition += "<ncp_profession_sub>"+jsonObject.getString("ncp_profession_sub")+"</ncp_profession_sub>";
        }
        String itemCoditon="";
        if (StringUtils.isNoneBlank(jsonObject.getString("item"))){
            JSONObject itemObject=jsonObject.getJSONObject("item");
            if (StringUtils.isNoneBlank(itemObject.getString("itemCode"))){
                itemCoditon += "<itemCode>"+itemObject.getString("itemCode")+"</itemCode>";
            }
            if (StringUtils.isNoneBlank(itemObject.getString("itemName"))){
                itemCoditon += "<itemName>"+itemObject.getString("itemName")+"</itemName>";
            }
            if (StringUtils.isNoneBlank(itemObject.getString("itemPrice"))){
                itemCoditon += "<itemPrice>"+itemCoditon+"</itemPrice>";
            }
            condition += "<itemList><item>"+itemCoditon+"</item></itemList>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("insertNucleicBill params:"+params.toString());
        String xml = getTaszWebServiceInfo("CallInterface",params,getOperateUrl());
        /*xml= xml.replace("<![CDATA[<?xml version=\"1.0\" encoding=\"utf-8\"?>","");
        xml= xml.replace("]]>","");*/
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        System.out.println(xml);
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("insertNucleicBill json:"+json);
        return json;
    }
    /**
     * 取消核酸预约
     * @return
     */
    public String cancelNucleicBill(JSONObject jsonObject)throws Exception{
        String api = "cancelNucleicBill";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(jsonObject.getString("hisTradeNo"))){
            condition += "<hisTradeNo>"+jsonObject.getString("hisTradeNo")+"</hisTradeNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("icCardNo"))){
            condition += "<icCardNo>"+jsonObject.getString("icCardNo")+"</icCardNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("patientName"))){
            condition += "<patientName>"+jsonObject.getString("patientName")+"</patientName>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("cancelNucleicBill params:"+params.toString());
        String xml = getTaszWebServiceInfo("CallInterface",params,getOperateUrl());
        /*xml= xml.replace("<![CDATA[<?xml version=\"1.0\" encoding=\"utf-8\"?>","");
        xml= xml.replace("]]>","");*/
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        System.out.println(xml);
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("cancelNucleicBill json:"+json);
        return json;
    }
    /**
     * 核酸检测项目扣费
     * @return
     */
    public String ChargenucleicBill(JSONObject jsonObject)throws Exception{
        String api = "ChargenucleicBill";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(jsonObject.getString("hisTradeNo"))){
            condition += "<hisTradeNo>"+jsonObject.getString("hisTradeNo")+"</hisTradeNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("icCardNo"))){
            condition += "<icCardNo>"+jsonObject.getString("icCardNo")+"</icCardNo>";
        }
        if (StringUtils.isNoneBlank(jsonObject.getString("patientName"))){
            condition += "<patientName>"+jsonObject.getString("patientName")+"</patientName>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("ChargenucleicBill params:"+params.toString());
        String xml = getTaszWebServiceInfo("CallInterface",params,getOperateUrl());
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        saveHttpLog("ChargenucleicBill",jsonObject.toString(),json,"ChargenucleicBill");
        logger.info("ChargenucleicBill json:"+json);
        return json;
    }
    //组装核算下单参数
    public String initNatParams(String preNo,String patientName,String icCardNo,String address,String job,String jobChild){
        List<WlyyHospitalSysDictDO> natConfigList = wlyyHospitalSysDictDao.findByDictName("natConfigList");
        String deptCode = "0001";
        String staffNo = "0001";
        String registerFee = "0.01";
        String clinicFee = "0.01";
        String itemCode = "xmCode";
        String itemName = "核酸检测";
        String itemPrice = "0.01";
        String ncpStandingType="";
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:natConfigList){
            if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"deptCode".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                deptCode = wlyyHospitalSysDictDO.getDictValue();
            }
            if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"staffNo".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                staffNo = wlyyHospitalSysDictDO.getDictValue();
            }
            if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"registerFee".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                registerFee = wlyyHospitalSysDictDO.getDictValue();
            }
            if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"clinicFee".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                clinicFee = wlyyHospitalSysDictDO.getDictValue();
            }
            if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"itemCode".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                itemCode = wlyyHospitalSysDictDO.getDictValue();
            }
            if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"itemName".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                itemName = wlyyHospitalSysDictDO.getDictValue();
            }
            if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"itemPrice".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                itemPrice = wlyyHospitalSysDictDO.getDictValue();
            }
            if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"ncp_standing_type".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                ncpStandingType = wlyyHospitalSysDictDO.getDictValue();
            }
        }
        JSONObject jsonObject = new JSONObject();
        //jsonObject.put("preNo",preNo);
        jsonObject.put("icCardNo",icCardNo);
        jsonObject.put("patientName",patientName);
        jsonObject.put("deptCode",deptCode);
        jsonObject.put("staffNo",staffNo);
        jsonObject.put("registerFee",registerFee);
        jsonObject.put("clinicFee",clinicFee);
        jsonObject.put("ncp_profession_sub",jobChild);
        jsonObject.put("address_now",address);
        jsonObject.put("ncp_profession",job);
        jsonObject.put("ncp_standing_type",ncpStandingType);
        JSONObject item = new JSONObject();
        item.put("itemCode",itemCode);
        item.put("itemName",itemName);
        item.put("itemPrice",itemPrice);
        jsonObject.put("item",item);
        String res="";
        try {
            res = insertNucleicBill(jsonObject);
            saveHttpLog("insertNucleicBill",jsonObject.toString(),res,"insertNucleicBill");
            if (StringUtils.isNoneBlank(res)){
                return res;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }
    //调用取消核酸接口
    public String cancelNat(String hisTraceNo,String idCardNo,String patientName){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("hisTradeNo",hisTraceNo);
        jsonObject.put("icCardNo",idCardNo);
        jsonObject.put("patientName",patientName);
        String res="";
        try {
            res = cancelNucleicBill(jsonObject);
            saveHttpLog("cancelNat",jsonObject.toString(),res,"cancelNat");
            if (StringUtils.isNoneBlank(res)){
                return res;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }
    //调用扣费接口
    public String chargeBill(String hisTraceNo,String idCardNo,String patientName){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("hisTraceNo",hisTraceNo);
        jsonObject.put("idCardNo",idCardNo);
        jsonObject.put("patientName",patientName);
        String res="";
        try {
            res = ChargenucleicBill(jsonObject);
            saveHttpLog("chargeBill",jsonObject.toString(),res,"chargeBill");
            if (StringUtils.isNoneBlank(res)){
                return res;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }
//Integer payType,String tradeNo,String openId,String idNo,String name ,String amountJSONObject jsonObject = new JSONObject();
//        jsonObject.put("payType",payType);
//        jsonObject.put("tradeNo",tradeNo);
//        jsonObject.put("openId",openId);
//        jsonObject.put("idNo",idNo);
//        jsonObject.put("name",name);
//        jsonObject.put("amount",amount);
    public String placeOrder(JSONObject jsonObject){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("placeOrderUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        System.out.println(url);
        /*List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("payType", jsonObject.getString("payType")));
        params.add(new BasicNameValuePair("tradeNo", jsonObject.getString("tradeNo")));
        params.add(new BasicNameValuePair("openId", jsonObject.getString("openId")));
        params.add(new BasicNameValuePair("name", jsonObject.getString("name")));
        params.add(new BasicNameValuePair("idNo", jsonObject.getString("idNo")));
        params.add(new BasicNameValuePair("amount", jsonObject.getString("amount")));*/
        System.out.println(jsonObject.toString());
        String response = httpClientUtil.postBody(url,jsonObject);
        System.out.println("res"+response);
        saveHttpLog("placeOrder",jsonObject.toString(),response,url);
        return response;
    }
    public String orderStatus(JSONObject jsonObject){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("orderStatusUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        System.out.println(url);
        String response = httpClientUtil.postBody(url,jsonObject);
        System.out.println("res"+response);
        saveHttpLog("orderStatus",jsonObject.toString(),response,url);
        return response;
    }
    public String tmpPush(JSONObject jsonObject){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("tmpPushUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        System.out.println(url);
        String response = httpClientUtil.postBody(url,jsonObject);
        System.out.println("res"+response);
        saveHttpLog("tmpPush",jsonObject.toString(),response,url);
        return response;
    }
    public void  saveHttpLog(String name,String req,String res,String code){
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setRequest(req);
        wlyyHttpLogDO.setName(name);
        //wlyyHttpLogDO.setCode(code);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDao.save(wlyyHttpLogDO);
    }
    public String sendWxtemplateMessaeg(String patient,String name,String scene,String relationCode){
        String url="";
        String openId="";
        JSONObject key=new JSONObject();
        JSONObject first=new JSONObject();
        JSONObject key1=new JSONObject();
        JSONObject key2=new JSONObject();
        JSONObject key3=new JSONObject();
        JSONObject key4=new JSONObject();
        JSONObject key5=new JSONObject();
        JSONObject remark=new JSONObject();
        BaseNatAppointmentDO baseNatAppointmentD0 = baseNatAppointmentDao.findOne(Integer.valueOf(relationCode));
        List<BasePatientWechatDo> basePatientWechatDo = basePatientWechatDao.findByWechatIdAndPatientId("xm_tasy_wx",patient);
        if (basePatientWechatDo!=null&&basePatientWechatDo.size()>0){
            openId=basePatientWechatDo.get(0).getOpenid();
        }
        if ("hszfcgtx".equalsIgnoreCase(scene)){
            //开始发送模板消息
            logger.info("开始发送模板消息");
            List<WxTemplateConfigDO> wxTemplateConfigDO = wxTemplateConfigDao.findByWechatIdAndScene("xm_tasy_wx",scene);
            WxTemplateConfigDO wxTemplateConfigDO1 = new WxTemplateConfigDO();
            if (wxTemplateConfigDO!=null&&wxTemplateConfigDO.size()>0){
                wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
            }
            url=wxTemplateConfigDO1.getUrl()+relationCode;
            first.put("value",wxTemplateConfigDO1.getFirst());
            first.put("color",wxTemplateConfigDO1.getKeyword6());
            key1.put("value",baseNatAppointmentD0.getDoctorName());
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("value",baseNatAppointmentD0.getChargeAmount()+".00元");
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key3.put("value",wxTemplateConfigDO1.getKeyword3());
            key3.put("color",wxTemplateConfigDO1.getKeyword6());
            key4.put("value",baseNatAppointmentD0.getChargeAmount()+".00元");
            key4.put("color",wxTemplateConfigDO1.getKeyword6());
            key5.put("value",baseNatAppointmentD0.getVoucherNo());
            key5.put("color",wxTemplateConfigDO1.getKeyword6());
            remark.put("value",wxTemplateConfigDO1.getRemark());
            remark.put("color",wxTemplateConfigDO1.getKeyword6());
            key.put("first",first);
            key.put("keyword1",key1);
            key.put("keyword2",key2);
            key.put("keyword3",key3);
            key.put("keyword4",key4);
            key.put("keyword5",key5);
            key.put("remark",remark);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("template_id",wxTemplateConfigDO1.getTemplateId());//
            jsonObject.put("data",key);
            jsonObject.put("touser",openId);
            jsonObject.put("url",url);
            logger.info("核酸检测支付成功模板消息推送param"+jsonObject.toString());
            String tmResilt= tmpPush(jsonObject);
            return tmResilt;
        } else if ("hszftx".equalsIgnoreCase(scene)) {
            //开始发送模板消息
            logger.info("开始发送模板消息");
            List<WxTemplateConfigDO> wxTemplateConfigDO = wxTemplateConfigDao.findByWechatIdAndScene("xm_tasy_wx",scene);
            WxTemplateConfigDO wxTemplateConfigDO1 = new WxTemplateConfigDO();
            if (wxTemplateConfigDO!=null&&wxTemplateConfigDO.size()>0){
                wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
            }
            url=wxTemplateConfigDO1.getUrl()+relationCode;
            first.put("value",wxTemplateConfigDO1.getFirst());
            first.put("color",wxTemplateConfigDO1.getKeyword6());
            key1.put("value",name);
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("value",baseNatAppointmentD0.getDeptName());
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key3.put("value",wxTemplateConfigDO1.getKeyword3());
            key3.put("color",wxTemplateConfigDO1.getKeyword6());
            key4.put("value",baseNatAppointmentD0.getDoctorName());
            key4.put("color",wxTemplateConfigDO1.getKeyword6());
            key5.put("value", DateUtil.formatDate(baseNatAppointmentD0.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
            key5.put("color",wxTemplateConfigDO1.getKeyword6());
            remark.put("value",wxTemplateConfigDO1.getRemark());
            remark.put("color",wxTemplateConfigDO1.getKeyword6());
            key.put("first",first);
            key.put("keyword1",key1);
            key.put("keyword2",key2);
            key.put("keyword3",key3);
            key.put("keyword4",key4);
            key.put("keyword5",key5);
            key.put("remark",remark);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("template_id",wxTemplateConfigDO1.getTemplateId());//
            jsonObject.put("data",key);
            jsonObject.put("touser",openId);
            jsonObject.put("url",url);
            logger.info("核酸检测支付提醒模板消息推送param"+jsonObject.toString());
            String tmResilt= tmpPush(jsonObject);
            return tmResilt;
        } else if ("hsyycg".equalsIgnoreCase(scene)) {
            //开始发送模板消息
            logger.info("开始发送模板消息");
            List<WxTemplateConfigDO> wxTemplateConfigDO = wxTemplateConfigDao.findByWechatIdAndScene("xm_tasy_wx",scene);
            WxTemplateConfigDO wxTemplateConfigDO1 = new WxTemplateConfigDO();
            if (wxTemplateConfigDO!=null&&wxTemplateConfigDO.size()>0){
                wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
            }
            url=wxTemplateConfigDO1.getUrl()+relationCode;
            first.put("value",wxTemplateConfigDO1.getFirst().replace("key1",name));
            first.put("color",wxTemplateConfigDO1.getKeyword6());
            key1.put("value",name);
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("value",baseNatAppointmentD0.getInspectionName());
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key3.put("value",wxTemplateConfigDO1.getKeyword3());//DateUtil.formatDate(baseNatAppointmentD0.getAppointmentTime(),"yyyy-MM-dd")
            key3.put("color",wxTemplateConfigDO1.getKeyword6());
            key4.put("value",wxTemplateConfigDO1.getKeyword4());
            key4.put("color",wxTemplateConfigDO1.getKeyword6());
            remark.put("value",wxTemplateConfigDO1.getRemark());
            remark.put("color",wxTemplateConfigDO1.getKeyword6());
            key.put("first",first);
            key.put("keyword1",key1);
            key.put("keyword2",key2);
            key.put("keyword3",key3);
            key.put("keyword4",key4);
            key.put("remark",remark);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("template_id",wxTemplateConfigDO1.getTemplateId());//
            jsonObject.put("data",key);
            jsonObject.put("touser",openId);
            jsonObject.put("url",url);
            logger.info("核酸检测预约成功模板消息推送param"+jsonObject.toString());
            String tmResilt= tmpPush(jsonObject);
            return tmResilt;
        }
        return "";
    }
    //查询排班部门
    public String departMent(String ApplyType){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("DepartMentUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?ApplyType="+ApplyType;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("departMent",ApplyType,response,url);
        return response;
    }
    //保存预约
    public String saveRegOrder(String DepartId,String OrderDate,String OrderTime,String OrderID,String HisID,String Tel,
                               String HisName,String ApplyType){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("saveNatOrderUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?DepartId="+DepartId+"&OrderDate="+OrderDate+"&OrderTime="+OrderTime+"&OrderID="+OrderID
                +"&HisID="+HisID+"&Tel="+Tel+"&HisName="+HisName+"&ApplyType="+ApplyType;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("saveRegOrder",url,response,url);
        return response;
    }
    //取消预约
    public String cancleOrder(String HisID,String HisSeqNo,String OrderNumber) throws Exception{
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("CancleOrderUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?HisID="+HisID+"&HisSeqNo="+HisSeqNo+"&OrderNumber="+OrderNumber;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("cancleOrder",url,response,url);
        return response;
    }
    //查询排班医生
    public String GetDoctorWorkDate(String ApplyType,String DepartId){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("GetDoctorWorkDateUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?ApplyType="+ApplyType+"&DepartId="+DepartId;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("departMent",url,response,url);
        return response;
    }
    //预约查询
    public String GetOrderInfo(String HisID,String ApplyType){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("GetOrderInfoUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?ApplyType="+ApplyType+"&HisID="+HisID;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("departMent",url,response,url);
        return response;
    }
    //获取号源
    public String GetOrderSource(String DepartId,String DoctorId,String QueryDate,String ApplyType,String IsAll,String QueryTime){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("GetOrderSourceUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?DepartId="+DepartId+"&DoctorId="+DoctorId+"&QueryDate="+QueryDate+"&ApplyType="+ApplyType+"&IsAll="+IsAll+"&QueryTime="+QueryTime;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("GetOrderInfo",url,response,url);
        return response;
    }
    //查询患者就诊卡
    public String findHisPatientCard(String idcard) throws Exception{
        String api = "QuerySickInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(idcard)){
            condition += "<IdNo>"+idcard+"</IdNo>";
            condition += "<IdType>100</IdType>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("QuerySickInfo params:"+params.toString());
        String xml = getTaszWebServiceInfo("CallInterface",params,getOperateUrl());
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("QuerySickInfo json:"+json);
        return json;
    }
    public JSONArray findPatientCard(String patient) throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findById(patient);
        String idcard="";
        if (basePatientDO!=null){
            idcard=basePatientDO.getIdcard();
        }
        String res = findHisPatientCard(idcard);
        JSONArray jsonArray = new JSONArray();
        if (StringUtils.isNoneBlank(res)){
            JSONObject jsonObject = JSON.parseObject(res);
            jsonArray.add(jsonObject);
            return jsonArray;
        }
        return null;
    }
    //病人单据状态查询
    public String QueryApplyInfo(String nullahNumber) throws Exception{
        String api = "QueryApplyInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(nullahNumber)){
            condition += "<NullahNumber>"+nullahNumber+"</NullahNumber>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("QueryApplyInfo params:"+params.toString());
        String xml = getTaszWebServiceInfo("CallInterface",params,getOperateUrl());
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("QueryApplyInfo json:"+json);
        return json;
    }
    public void savePayStatusByHis(String patientId) throws Exception {
        List<BaseNatAppointmentDO> baseNatAppointmentDOList = baseNatAppointmentDao.findByTasy(patientId);
        for (BaseNatAppointmentDO baseNatAppointmentDO:baseNatAppointmentDOList){
            System.out.println("baseNatAppointmentDO==="+baseNatAppointmentDO.getName());
                String res = QueryApplyInfo(baseNatAppointmentDO.getRealOrder());
                JSONObject jsonObject = JSON.parseObject(res);
                if (jsonObject!=null){
                    if (jsonObject.getString("ReturnCode").equalsIgnoreCase("1")){
                        String applyinfo = jsonObject.getString("applyinfo");
                        if (StringUtils.isNoneBlank(applyinfo)){
                            if (applyinfo.contains("[")){
                                JSONArray jsonArray = JSON.parseArray(applyinfo);
                                if (jsonArray!=null&&jsonArray.size()>0) {
                                    if (StringUtils.isNoneBlank(baseNatAppointmentDO.getVoucherNo())) {
                                        for (int i = 0; i < jsonArray.size(); i++) {
                                            JSONObject child = jsonArray.getJSONObject(i);
                                            System.out.println("数组" + child.getString("ApplyNo"));
                                            if (child.getString("ApplyNo").equalsIgnoreCase(baseNatAppointmentDO.getVoucherNo())) {
                                                if ("已扣费".equalsIgnoreCase(child.getString("Status"))) {
                                                    baseNatAppointmentDO.setPayStatus("1");
                                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                                    if (businessOrderDO != null) {
                                                        businessOrderDO.setStatus(1);
                                                        businessOrderDao.save(businessOrderDO);
                                                    }
                                                } else if ("已退费".equalsIgnoreCase(child.getString("Status"))) {
                                                    logger.info("进入退费订单同步");
                                                    baseNatAppointmentDO.setPayStatus("-1");
                                                    baseNatAppointmentDO.setIsSuccess("-1");
                                                    baseNatAppointmentDO.setCancelReson("患者本人线下取消");
                                                    baseNatAppointmentDO.setCancelTime(new Date());
                                                    baseNatAppointmentDO.setCancelBy(patientId);
                                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                                    if (businessOrderDO != null) {
                                                        businessOrderDO.setStatus(-1);
                                                        businessOrderDao.save(businessOrderDO);
                                                    }
                                                    //取消号源
                                                    //cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                                                }
                                                baseNatAppointmentDao.save(baseNatAppointmentDO);
                                            }
                                        }
                                    }else {
                                        JSONObject child = jsonArray.getJSONObject(jsonArray.size()-1);
                                        System.out.println("数组" + child.getString("ApplyNo"));
                                        if (child.getString("ApplyNo").equalsIgnoreCase(baseNatAppointmentDO.getVoucherNo())) {
                                            if ("已扣费".equalsIgnoreCase(child.getString("Status"))) {
                                                baseNatAppointmentDO.setPayStatus("1");
                                                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                                if (businessOrderDO != null) {
                                                    businessOrderDO.setStatus(1);
                                                    businessOrderDao.save(businessOrderDO);
                                                }
                                            } else if ("已退费".equalsIgnoreCase(child.getString("Status"))) {
                                                logger.info("进入退费订单同步");
                                                baseNatAppointmentDO.setPayStatus("-1");
                                                baseNatAppointmentDO.setIsSuccess("-1");
                                                baseNatAppointmentDO.setCancelReson("患者本人线下取消");
                                                baseNatAppointmentDO.setCancelTime(new Date());
                                                baseNatAppointmentDO.setCancelBy(patientId);
                                                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                                if (businessOrderDO != null) {
                                                    businessOrderDO.setStatus(-1);
                                                    businessOrderDao.save(businessOrderDO);
                                                }
                                                //取消号源
                                                //cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                                            }
                                            baseNatAppointmentDO.setVoucherNo(child.getString("ApplyNo"));
                                            baseNatAppointmentDao.save(baseNatAppointmentDO);
                                        }
                                    }
                                }
                            }else {
                                JSONObject jsonObject1 = JSONObject.parseObject(applyinfo);
                                System.out.println("单条"+jsonObject1.getString("ApplyNo"));
                                if ("已扣费".equalsIgnoreCase(jsonObject1.getString("Status"))){
                                    baseNatAppointmentDO.setPayStatus("1");
                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                    if (businessOrderDO!=null){
                                        businessOrderDO.setStatus(1);
                                        businessOrderDao.save(businessOrderDO);
                                    }
                                }else if ("已退费".equalsIgnoreCase(jsonObject1.getString("Status"))){
                                    logger.info("进入退费订单同步");
                                    baseNatAppointmentDO.setPayStatus("-1");
                                    baseNatAppointmentDO.setIsSuccess("-1");
                                    baseNatAppointmentDO.setCancelReson("患者本人线下取消");
                                    baseNatAppointmentDO.setCancelTime(new Date());
                                    baseNatAppointmentDO.setCancelBy(patientId);
                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                    if (businessOrderDO!=null){
                                        businessOrderDO.setStatus(-1);
                                        businessOrderDao.save(businessOrderDO);
                                    }
                                    //取消号源
                                    //cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                                }
                                baseNatAppointmentDO.setVoucherNo(jsonObject1.getString("ApplyNo"));
                                baseNatAppointmentDao.save(baseNatAppointmentDO);
                            }
                        }
                    }
                }
            }
    }
    public String selectByRelationCode(String relationCode) throws  Exception{
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
        if (NumberUtils.isDigits(relationCode) ){
            BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(Integer.valueOf(relationCode));
            if (baseNatAppointmentDO!=null&&"-1".equalsIgnoreCase(baseNatAppointmentDO.getIsSuccess())){
                throw new Exception("订单已取消");
            }
            if (businessOrderDO!=null&&businessOrderDO.getStatus()==1){
                throw new Exception("订单已支付");
            }
            String openId="";
            List<BasePatientWechatDo> wechatList=basePatientWechatDao.findByWechatIdAndPatientId("xm_tasy_wx",baseNatAppointmentDO.getConsumer());
            if (wechatList!=null&&wechatList.size()>0){
                openId=wechatList.get(0).getOpenid();
            }
            if (StringUtils.isNoneBlank(businessOrderDO.getOrderNo())){
                String orderNo= businessOrderDO.getOrderNo();
                String newOrder="HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100;
                businessOrderDO.setOrderNo(newOrder);
                businessOrderDO.setHistoryOrder(orderNo+","+newOrder);
            }
            com.alibaba.fastjson.JSONObject orderObj= new com.alibaba.fastjson.JSONObject();
            orderObj.put("payType",1);
            orderObj.put("tradeNo",businessOrderDO.getOrderNo());
            orderObj.put("openId",openId);
            orderObj.put("name",baseNatAppointmentDO.getName());
            orderObj.put("idNo",baseNatAppointmentDO.getCardNo());
            Map mapHis=getPatientHisId(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getMedicare());
            orderObj.put("patientId",mapHis.get("Patientid").toString());
            orderObj.put("mobile",mapHis.get("MobilePhone").toString());
            //orderObj.put("socialCard","");
            orderObj.put("icCard",baseNatAppointmentDO.getMedicare());
            BigDecimal b = new BigDecimal(baseNatAppointmentDO.getChargeAmount());
            b=b.setScale(2, BigDecimal.ROUND_DOWN);
            System.out.println("amount"+b);
            orderObj.put("amount",b);
            //重新下单
            String orderRes=placeOrder(orderObj);
            if (StringUtils.isNoneBlank(orderRes)){
                com.alibaba.fastjson.JSONObject jsonObject= JSON.parseObject(orderRes);
                if (jsonObject!=null){
                    if("0".equalsIgnoreCase(jsonObject.getString("code"))){
                        com.alibaba.fastjson.JSONObject dataObj= com.alibaba.fastjson.JSONObject.parseObject(jsonObject.getString("data"));
                        businessOrderDO.setTraceNo(dataObj.getString("orderNo"));
                        businessOrderDO.setRematk(dataObj.toJSONString());
                        businessOrderDO=businessOrderDao.save(businessOrderDO);
                    }
                }
            }
        }
        return businessOrderDO.getRematk();
    }
    public String getNatResult(String patientId) throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findById(patientId);
        Calendar c = Calendar.getInstance();
        c.add(Calendar.MONTH, -6);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = sdf.format(c.getTime());
        String idcard="";
        String hospitalOid="";
        String wsCode="";
        if (basePatientDO!=null){
            idcard=basePatientDO.getIdcard();
        }
        List<WlyyHospitalSysDictDO> list = wlyyHospitalSysDictDao.findByDictName("hdrQueryDataParam");
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:list){
            if ("hospitalOid".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                hospitalOid=wlyyHospitalSysDictDO.getDictValue();
            }
            if ("wsCode".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                wsCode=wlyyHospitalSysDictDO.getDictValue();
            }
        }
        String res=hdrQueryDataWS(idcard,wsCode,hospitalOid,dateStr);
        return res;
    }
    //病人单据状态查询
    public String hdrQueryDataWS(String idcard,String wsCode,String oid,String time) throws Exception{
        /*String api = "hdrQueryDataWS";*/
        /*String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";*/
        String msg="<HOSPITAL_OID>"+oid+"</HOSPITAL_OID>";
        if (StringUtils.isNoneBlank()){
            msg+="<ID_CARD>"+idcard+"</ID_CARD>";
        }
        if (StringUtils.isNoneBlank(wsCode)){
            msg+="<WS_CODE>"+wsCode+"</WS_CODE>";
        }
        String condition ="";
        if (StringUtils.isNoneBlank(time)){
            condition+="<CONDITION><ELEM NAME=\"LAB_ITEM_NAME\" VALUE=\"核酸\" OPERATOR=\"like\"></ELEM>" +
                    "<ELEM NAME=\"REPORT_TIME\" VALUE=\""+time+"\" OPERATOR=\"&gt;=\"></ELEM></CONDITION>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                "<MSG>"+msg+condition+"</MSG>";
        Map<String,String> params = new HashedMap();
        params.put("msg",msgBody);
        logger.info("hdrQueryDataWS params:"+params.toString());
        String xml = getTaszWebServiceInfo("hdrQueryDataWS",params,gethsQueryDataWS());
        if (xml.contains("<ArrayList>")){
            xml=xml.substring(xml.indexOf("<ArrayList>"),xml.lastIndexOf("]]"));
        }else {
            xml=xml.substring(xml.indexOf("<?xml"),xml.lastIndexOf("]]"));
        }
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("hdrQueryDataWS json:"+json);
        return json;
    }
    public  Map checkBalance(String relationCode) throws  Exception{
        BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(Integer.parseInt(relationCode));
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("MzBalance");
        String tmpBalance="";
        if (wlyyHospitalSysDictDO!=null){
            tmpBalance=wlyyHospitalSysDictDO.getDictValue();
        }
        String res = findHisPatientCard(baseNatAppointmentDO.getCardNo());
        String mediacard=baseNatAppointmentDO.getMedicare();
        Map result=new HashMap();
        if (StringUtils.isNoneBlank(res)){
            JSONObject jsonObject = JSON.parseObject(res);
            if ("1".equalsIgnoreCase(jsonObject.getString("ReturnCode"))) {
                String patients=jsonObject.getString("patients");
                if (patients.contains("[")){
                    JSONArray jsonArray = JSON.parseArray(patients);
                    if (jsonArray != null && jsonArray.size() > 0) {
                        for (int i = 0; i < jsonArray.size(); i++) {
                            JSONObject child = jsonArray.getJSONObject(i);
                            if (mediacard.equalsIgnoreCase(child.getString("CardNo"))) {
                                String MzBalance = child.getString("MzBalance");
                                if (StringUtils.isNoneBlank(tmpBalance)){
                                    MzBalance=tmpBalance;
                                }
                                BigDecimal b = new BigDecimal(MzBalance);
                                b=b.setScale(2, BigDecimal.ROUND_DOWN);
                                System.out.println("MzBalance====="+MzBalance);
                                if (StringUtils.isNoneBlank(MzBalance) && b.compareTo(new BigDecimal("0")) < 0) {
                                    result.put("msgCode", "-1");
                                    result.put("msg", "余额不足");
                                    return result;
                                }
                            }
                        }
                    }
                }else {
                    try {
                        JSONObject jsonObject1= JSONObject.parseObject(patients);
                        if (mediacard.equalsIgnoreCase(jsonObject1.getString("CardNo"))) {
                            String MzBalance = jsonObject1.getString("MzBalance");
                            if (StringUtils.isNoneBlank(tmpBalance)){
                                MzBalance=tmpBalance;
                            }
                            System.out.println("MzBalance====="+MzBalance);
                            BigDecimal b = new BigDecimal(MzBalance);
                            b=b.setScale(2, BigDecimal.ROUND_DOWN);
                            System.out.println("MzBalance====="+b);
                            if (StringUtils.isNoneBlank(MzBalance) && b.compareTo(new BigDecimal("0")) < 0) {
                                result.put("msgCode", "-1");
                                result.put("msg", "余额不足");
                                return result;
                            }
                            return result;
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                        result.put("msgCode","-1000");
                        result.put("msg","json格式验证失败");
                    }
                }
            }
        }
        result.put("msgCode","200");
        result.put("msg","验证通过");
        return  result;
    }
    public Map getPatientHisId(String idcard,String mediacard) throws Exception{
        Map map = new HashMap();
        String res = findHisPatientCard(idcard);
        JSONObject jsonObject = JSON.parseObject(res);
        if ("1".equalsIgnoreCase(jsonObject.getString("ReturnCode"))) {
            String patients=jsonObject.getString("patients");
            if (patients.contains("[")) {
                JSONArray jsonArray = JSON.parseArray(patients);
                if (jsonArray != null && jsonArray.size() > 0) {
                    for (int i = 0; i < jsonArray.size(); i++) {
                        JSONObject child = jsonArray.getJSONObject(i);
                        if (mediacard.equalsIgnoreCase(child.getString("CardNo"))) {
                            String Patientid = child.getString("Patientid");
                            String MobilePhone = child.getString("MobilePhone");
                            map.put("Patientid",Patientid);
                            map.put("MobilePhone",MobilePhone);
                            return map;
                        }
                    }
                }
            } else {
                try {
                    JSONObject jsonObject1 = JSONObject.parseObject(patients);
                    if (mediacard.equalsIgnoreCase(jsonObject1.getString("CardNo"))) {
                        String Patientid = jsonObject1.getString("Patientid");
                        String MobilePhone = jsonObject1.getString("MobilePhone");
                        map.put("Patientid",Patientid);
                        map.put("MobilePhone",MobilePhone);
                        return map;
                    }
                } catch (Exception e) {
                   e.printStackTrace();
                }
            }
        }
        return map;
    }
}

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

@ -371,7 +371,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("belong_dept_name", info.get("dept_name"));
                jb.put("doo_tel", info.get("mobile")== null ? "":info.get("mobile"));
                jb.put("title_rec_date", getDateString(info.get("fzrq").toString()));
                if (info.get("idcard").toString().equalsIgnoreCase("350524198906247742")){
                if (info.get("idcard").toString().equalsIgnoreCase("350104197904305425")){
                    jb.put("prac_type", "2");   // 因为上传的是医师的信息,所以该字段全部默认设置为 1 医师
                }else {
                    jb.put("prac_type", "1");   // 因为上传的是医师的信息,所以该字段全部默认设置为 1 医师
@ -1188,7 +1188,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                // 获取监管平台唯一标识
                String visitDocCode = achNsDoctorRecord(info.get("docIdcard").toString());
                String trialDocCode =  achNsDoctorRecord("350524198906247742");
                String trialDocCode =  achNsDoctorRecord("350104197904305425");
                jb.put("id_prescription", orgCode +"_"+ (String)info.get("id"));
                jb.put("pres_no",info.get("real_order")== null?"0":info.get("real_order"));
@ -1224,8 +1224,8 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("pres_doc_name", info.get("doctor_name")== null?"0":info.get("doctor_name"));
                jb.put("pres_doc_id_no", info.get("docIdcard")== null?"0":info.get("docIdcard"));
                jb.put("trial_doc_code", trialDocCode);
                jb.put("trial_doc_name", "陈丽玲");
                jb.put("trial_doc_id_no","350524198906247742");
                jb.put("trial_doc_name", "陈燕莺");
                jb.put("trial_doc_id_no","350104197904305425");
                jb.put("diag_code", info.get("icd10"));
                jb.put("diag_name", info.get("icd10_name"));
                jb.put("diseases_type", "0");

+ 37 - 1
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -40,6 +40,7 @@ import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeiXinPayUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.ByteToInputStream;
@ -55,6 +56,8 @@ import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -140,6 +143,8 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    private WlyyInspectionDao inspectionDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
@ -1923,7 +1928,25 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        mixEnvelop.setTotalCount(listCount==null?0:listCount.size());
        return mixEnvelop;
    }
    public  JSONObject validateGeet( String geetestChallenge,String geetestValidate,String geetestSeccode,String isPatient){
        String validateUrl = "http://localhost:8088/validate";
        List<WlyyHospitalSysDictDO> list = hospitalSysDictDao.findByDictName("geetConfig");
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:list){
            if ("validateUrl".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                validateUrl=wlyyHospitalSysDictDO.getDictValue();
            }
        }
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("geetest_challenge",geetestChallenge));
        params.add(new BasicNameValuePair("geetest_validate",geetestValidate));
        params.add(new BasicNameValuePair("geetest_seccode",geetestSeccode));
        params.add(new BasicNameValuePair("isPatient",isPatient));
        String res = httpClientUtil.post(validateUrl, params, "UTF-8");
        JSONObject statusObject = JSONObject.parseObject(res);
        System.out.println(statusObject.toJSONString());
        return statusObject;
    }
    /**
     * 眼科就诊卡充值
     * @param mzhm
@ -1936,7 +1959,20 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
     * @return
     * @throws Exception
     */
    public Map yktMedicalCardTopUp(String mzhm,Double jkje,Integer type,Integer paymentType,String patientId,String wechatId,String hospitalId,String wxPayType,String appletCode) throws Exception {
    public Map yktMedicalCardTopUp(String mzhm,Double jkje,Integer type,Integer paymentType,String patientId,String wechatId,String hospitalId,String wxPayType,String appletCode,String geetestChallenge
    ,String geetestValidate,String geetestSeccode) throws Exception {
        String isNeedGeet= "0";//1需要 0不需要
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO1= hospitalSysDictDao.findById("isCardNeedGeet");
        if (wlyyHospitalSysDictDO1!=null){
            isNeedGeet=wlyyHospitalSysDictDO1.getDictValue();
        }
        if("1".equalsIgnoreCase(isNeedGeet)){
            JSONObject resResult =validateGeet(geetestChallenge,geetestValidate,geetestSeccode,"2");
            if (resResult==null||!resResult.getString("result").equalsIgnoreCase("success")){
                throw new  Exception("验证失败");
            }
        }
        BasePatientDO patientDO = patientDao.findById(patientId);
        BusinessOrderDO businessOrderDO = new BusinessOrderDO();
        businessOrderDO.setPatient(patientId);

+ 4 - 3
business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java

@ -13,7 +13,8 @@ import java.util.List;
public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrderDO, Integer>, JpaSpecificationExecutor<BusinessOrderDO>  {
    @Query("from BusinessOrderDO w where w.traceNo = ?1 and w.orderNo=?2")
    BusinessOrderDO selectByTraceNoAndorderNo(String traceNo,String orderNo);
    @Query("from BusinessOrderDO w where w.orderNo = ?1 ")
    BusinessOrderDO selectByOrderNo(String orderNo);
@ -35,6 +36,6 @@ public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrd
    @Query("from BusinessOrderDO w where w.patient = ?1 and w.status=?2  and w.orderCategory =?3")
    List<BusinessOrderDO> selectByPatientAndStatusAndOrderCategory(String patient,Integer status,String orderCategory);
   /* @Query("from BusinessOrderDO  w where w.status=0 and w.lastPayTime<=?1")
    List<BusinessOrderDO> selectByLastPayTime(Long lastPayTime);*/
    @Query("from BusinessOrderDO  w where w.status=0 and w.lastPayTime<=?1")
    List<BusinessOrderDO> selectByLastPayTime(Long lastPayTime);
}

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

@ -1167,5 +1167,80 @@ ALTER table base.base_login_log add column client_type varchar(10) DEFAULT NULL
-- 2021-7-22 lb
alter table base_life_care_item_dict add column pad_icon_img varchar(255) DEFAULT NULL COMMENT 'pad图标'
-- 2021-08-02 ysj
CREATE TABLE `voluntary_recruitment_arrange` (
  `id` varchar(50) NOT NULL,
  `company_id` varchar(50) DEFAULT NULL,
  `day` varchar(10) DEFAULT NULL COMMENT '服务日期',
  `time` varchar(10) DEFAULT NULL COMMENT '服务时间段',
  `people_id` varchar(50) DEFAULT NULL COMMENT '服务人员id',
  `station` varchar(50) DEFAULT NULL COMMENT '服务站',
  `people_name` varchar(50) DEFAULT NULL COMMENT '服务人员姓名',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `voluntary_recruitment_company` (
  `id` varchar(50) NOT NULL,
  `name` varchar(100) DEFAULT NULL COMMENT '单位名称',
  `contacts` varchar(50) DEFAULT NULL COMMENT '联系人',
  `phone` varchar(50) DEFAULT NULL COMMENT '联系人手机',
  `times` varchar(30) DEFAULT NULL COMMENT '服务时间段',
  `service_station` varchar(5000) DEFAULT NULL COMMENT '服务站',
  `num` int(10) DEFAULT NULL COMMENT '报名人数',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='新冠志愿招募-企业';
CREATE TABLE `voluntary_recruitment_people` (
  `id` varchar(50) NOT NULL,
  `company_id` varchar(50) DEFAULT NULL,
  `company_name` varchar(100) DEFAULT NULL,
  `name` varchar(50) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `idcard` varchar(50) DEFAULT NULL,
  `vaccination` tinyint(1) DEFAULT NULL COMMENT '是否接种疫苗 0未接种 1接种1针 2已接种',
  `experience` tinyint(1) DEFAULT NULL COMMENT '是否有核酸设备运维经验',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='企业人员表';
alter table base_job_category  add code varchar(50);
alter table base_nat_appointment  add oder_num varchar(50);
alter table base_business_order_pay  add history_order varchar(1000);
-- 2021-08-09
create TABLE base.base_emergency_warn_log(
	id int(11) NOT NULL AUTO_INCREMENT ,
	order_id varchar(50) default null COMMENT '工单id',
	user_code varchar(50) default null comment '操作用户',
	user_name varchar(50) default null comment '操作用户',
	user_type int(4) default null COMMENT '用户类型 1居民 2助老员',
	content VARCHAR(255) default null comment '操作详情',
	create_time timestamp NULL DEFAULT NULL COMMENT '创建时间',
	PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='紧急预警工单动态消息';
-- 2021-08-10
CREATE TABLE `base_patient_sos_contacts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民id',
  `sos_name` varchar(50) DEFAULT NULL COMMENT '紧急联系人姓名',
  `sos_phone` varchar(50) DEFAULT NULL COMMENT '紧急联系人电话',
  `relation` int(2) DEFAULT NULL COMMENT '家庭关系 同base_patient_family_member',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `success_flag` tinyint(4) DEFAULT NULL COMMENT '联系人是否同步成功-1失败 0待同步 1成功',
  `del` int(1) DEFAULT NULL COMMENT '是否有效 1有效 0无效',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='居民紧急联系人';
-- 2021-08-11
ALTER table base.base_patient_sos_contacts add column phone_seqid int(2) default null COMMENT '联系人序号';
ALTER table base_emergency_assistance_order add column device_sn varchar(50) DEFAULT NULL COMMENT '设备触发工单时有该字段';
ALTER table base_security_monitoring_order add column device_sn varchar(50) DEFAULT NULL COMMENT '设备触发工单时有该字段';
ALTER table base_service_package_record add column team_code varchar(50) DEFAULT NULL COMMENT '团队id';

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

@ -283,6 +283,8 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String padImei;//绑定平板标志
    private String residentialArea;//居住小区
    private Integer deviceFlag;//绑定设备标识 大于0为绑定了设备
    public String getCardType() {
        return cardType;
    }
@ -869,4 +871,13 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public void setResidentialArea(String residentialArea) {
        this.residentialArea = residentialArea;
    }
    @Transient
    public Integer getDeviceFlag() {
        return deviceFlag;
    }
    public void setDeviceFlag(Integer deviceFlag) {
        this.deviceFlag = deviceFlag;
    }
}

+ 31 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java

@ -33,6 +33,10 @@ public class ServicePackageDO extends UuidIdentityEntityWithCreateTime implement
    private List<BaseTeamDO> teamDOList;//服务团队
    private String teamNames;//服务团队
    private String orgNames;//服务机构
    private String orgCodes;
    private String orgCode;
    private String orgName;
    @Transient
    public String getTypeName() {
        return typeName;
@ -140,6 +144,15 @@ public class ServicePackageDO extends UuidIdentityEntityWithCreateTime implement
        this.teamNames = teamNames;
    }
    @Transient
    public String getOrgCodes() {
        return orgCodes;
    }
    public void setOrgCodes(String orgCodes) {
        this.orgCodes = orgCodes;
    }
    @Transient
    public String getOrgNames() {
        return orgNames;
@ -148,4 +161,22 @@ public class ServicePackageDO extends UuidIdentityEntityWithCreateTime implement
    public void setOrgNames(String orgNames) {
        this.orgNames = orgNames;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    @Column(name = "org_name")
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageRecordDO.java

@ -2,6 +2,7 @@ package com.yihu.jw.entity.base.servicePackage;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@ -26,6 +27,7 @@ public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime imp
     * 居民id
     */
    private String patient;
    private String teamCode;//服务团队id
    public String getSignId() {
        return signId;
@ -50,4 +52,13 @@ public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime imp
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "team_code")
    public String getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }
}

+ 1 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java

@ -137,4 +137,5 @@ public class ServicePackageSignRecordDO extends UuidIdentityEntityWithCreateTime
    public void setPackageList(List<Map<String,Object>> packageList) {
        this.packageList = packageList;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java

@ -69,6 +69,7 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private Integer type; //发起类型(1本人发起 2家人待预约 3医生代预约)
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String deviceSn;//设备sn  设备触发是才有该字段值
    private String sendMessage;//
@ -352,4 +353,12 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    public void setEmergencyCancel(Integer emergencyCancel) {
        this.emergencyCancel = emergencyCancel;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}

+ 46 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/booking/BaseBookingServiceDo.java

@ -0,0 +1,46 @@
package com.yihu.jw.entity.care.booking;
import javax.persistence.*;
/***
 * @ClassName: BaseBookingServiceDo
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/12 10:19
 */
@Entity
@Table(name="base_booking_service")
public class BaseBookingServiceDo {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    private String patient;
    private Integer status;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 103 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/PatientSosContactsDO.java

@ -0,0 +1,103 @@
package com.yihu.jw.entity.care.contacts;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by Bing on 2021/8/10.
 * 居民紧急联系人表
 */
@Entity
@Table(name="base_patient_sos_contacts")
public class PatientSosContactsDO extends IdEntity {
    private String patient;
    private String sosName; //紧急联系人
    private String sosPhone; //联系电话
    private Integer relation; //与联系人关系 同base_patient_family_member
    private Date updateTime; //修改日期
    private Integer successFlag;//联系人是否同步成功 -2删除失败 -1添加失败 0待同步 1添加成功 2删除成功
    private Integer del;
    private Integer phoneSeqid;// 联系人序号 1 或2
    private String relationName;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getSosName() {
        return sosName;
    }
    public void setSosName(String sosName) {
        this.sosName = sosName;
    }
    public String getSosPhone() {
        return sosPhone;
    }
    public void setSosPhone(String sosPhone) {
        this.sosPhone = sosPhone;
    }
    public Integer getRelation() {
        return relation;
    }
    public void setRelation(Integer relation) {
        this.relation = relation;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getSuccessFlag() {
        return successFlag;
    }
    public void setSuccessFlag(Integer successFlag) {
        this.successFlag = successFlag;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Transient
    public String getRelationName() {
        return relationName;
    }
    public void setRelationName(String relationName) {
        this.relationName = relationName;
    }
    public Integer getPhoneSeqid() {
        return phoneSeqid;
    }
    public void setPhoneSeqid(Integer phoneSeqid) {
        this.phoneSeqid = phoneSeqid;
    }
}

+ 85 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/BaseEmergencyWarnLogDO.java

@ -0,0 +1,85 @@
package com.yihu.jw.entity.care.securitymonitoring;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.crypto.Data;
import java.util.Date;
/**
 * Created by Bing on 2021/8/9.
 */
@Entity
@Table(name="base_emergency_warn_log")
public class BaseEmergencyWarnLogDO extends IdEntity {
    public String orderId;
    public String userCode;
    public String userName;
    public Integer userType; //用户类型 1居民 2助老员
    public String content;
    public Date createTime;
    public String timeInfo;
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public String getUserCode() {
        return userCode;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Transient
    public String getTimeInfo() {
        return timeInfo;
    }
    public void setTimeInfo(String timeInfo) {
        this.timeInfo = timeInfo;
    }
}

+ 10 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -146,7 +146,7 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private String patientPhone;
    /**
     * 居民自己服务描述
     * 服务描述 关联security_server_dict
     */
    private String serveDesc;
@ -322,6 +322,7 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String topicItem;//安防工单所属专题 base_system_dict_entry表service_item
    private String sceneImg;//现场照片
    private String deviceSn;//设备sn  设备触发是才有该字段值
    /**
     * 医生确认医生结束服务时间
@ -727,4 +728,12 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    public void setSceneImg(String sceneImg) {
        this.sceneImg = sceneImg;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}

+ 2 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/followup/BusinessMapping.java

@ -3,10 +3,7 @@ package com.yihu.jw.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.*;
import java.util.Date;
@ -17,6 +14,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "wlyy_business_mapping")
@SequenceGenerator(name="id_generated", sequenceName="seq_wlyy_business_mapping")
public class BusinessMapping extends IntegerIdentityEntity {
	private String code;
	private Integer businessId;

+ 2 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupSign.java

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
@ -12,6 +13,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "wlyy_followup_sign")
@SequenceGenerator(name="id_generated", sequenceName="seq_wlyy_followup_sign")
public class FollowupSign extends IntegerIdentityEntity {
    private String code;//

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNatAppointmentDO.java

@ -59,6 +59,15 @@ public class BaseNatAppointmentDO extends IntegerIdentityEntity {
    private String hospitalFlag;
    private String consumer;
    private String consumerName;
    private String oderNum;
    public String getOderNum() {
        return oderNum;
    }
    public void setOderNum(String oderNum) {
        this.oderNum = oderNum;
    }
    public String getConsumer() {
        return consumer;

+ 13 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java

@ -34,7 +34,7 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    private String relationCode;//业务关联code
    private String relationName;//业务关联名称
    private String description;//支付备注
    private String rematk;//病人描述
    private String remark;//病人描述
    private Integer payType;//支付类型1微信2支付宝3易联众支付
    private Double payPrice;//支付金额
    private Date payTime;//支付时间
@ -54,6 +54,15 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    private String ykOrderId;
    private String traceNo;//支付平台的订单号
    private Long lastPayTime;//订单截至支付日期 13位时间戳
    private String historyOrder;
    @Column(name = "history_order")
    public String getHistoryOrder() {
        return historyOrder;
    }
    public void setHistoryOrder(String historyOrder) {
        this.historyOrder = historyOrder;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time", nullable = false, length = 0,updatable = false)
@ -261,11 +270,11 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    @Column(name = "remark")
    public String getRematk() {
        return rematk;
        return remark;
    }
    public void setRematk(String rematk) {
        this.rematk = rematk;
    public void setRematk(String remark) {
        this.remark = remark;
    }
    @Column(name = "yk_order_no")

+ 2 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/RehabilitationguidanceDO.java

@ -6,6 +6,7 @@ import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
@ -14,6 +15,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "wlyy_rehabilitation_guidance")
@SequenceGenerator(name="id_generated", sequenceName="seq_wlyy_rehabilitation_guidance")
public class RehabilitationguidanceDO extends IntegerIdentityEntity {
    private String code;

+ 2 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/RehabilitationguidancePatientDO.java

@ -3,10 +3,7 @@ package com.yihu.jw.entity.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.*;
import java.util.Date;
/**
@ -14,6 +11,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "wlyy_rehabilitation_guidance_patient")
@SequenceGenerator(name="id_generated", sequenceName="seq_wlyy_rehabilitation_guidance_patient")
public class RehabilitationguidancePatientDO extends IntegerIdentityEntity {
    private String patient;

+ 4 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/util/SystemConf.java

@ -7,7 +7,7 @@ import java.io.InputStream;
import java.util.Properties;
@Component
public class SystemConf {
public class SystemConfEntity {
    // 别处登录
    public static final int LOGIN_OTHER = 999;
@ -45,16 +45,16 @@ public class SystemConf {
    private static Object lock = new Object();
    // 全局系统配置信息
    private static SystemConf systemConf;
    private static SystemConfEntity systemConf;
    // 系统配置文件
    private Properties systemProperties;
    //im列表
    private String imListGet;
    public static SystemConf getInstance() {
    public static SystemConfEntity getInstance() {
        if (systemConf == null) {
            synchronized (lock) {
                systemConf = new SystemConf();
                systemConf = new SystemConfEntity();
            }
        }
        return systemConf;

+ 156 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/voluntary/VoluntaryRecruitmentArrangeDO.java

@ -0,0 +1,156 @@
package com.yihu.jw.entity.voluntary;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * Created with IntelliJ IDEA.
 * 志愿招募人员安排表
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@Entity
@Table(name="voluntary_recruitment_arrange")
public class VoluntaryRecruitmentArrangeDO extends UuidIdentityEntityWithCreateTime{
    /**
     * 单位id
     */
    private String companyId;
    /**
     * '服务日期'
     */
    private String day;
    /**
     * '服务时间段'
     */
    private String time;
    /**
     * '服务人员id'
     */
    private String peopleId;
    /**
     * '服务人员姓名'
     */
    private String peopleName;
    /**
     * '服务站'
     */
    private String station;
    /**
     *非数据库字段
     */
    private String companyName;//企业名称
    private String phone;//服务人员手机
    private String idcard;//服务人员身份证
    private String vaccination;//是否接种疫苗 0未接种 1接种1针 2已接种
    private String experience;//是否有核酸设备运维经验
    @Column(name = "company_id")
    public String getCompanyId() {
        return companyId;
    }
    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }
    @Column(name = "day")
    public String getDay() {
        return day;
    }
    public void setDay(String day) {
        this.day = day;
    }
    @Column(name = "time")
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    @Column(name = "people_id")
    public String getPeopleId() {
        return peopleId;
    }
    public void setPeopleId(String peopleId) {
        this.peopleId = peopleId;
    }
    @Column(name = "people_name")
    public String getPeopleName() {
        return peopleName;
    }
    public void setPeopleName(String peopleName) {
        this.peopleName = peopleName;
    }
    @Column(name = "station")
    public String getStation() {
        return station;
    }
    public void setStation(String station) {
        this.station = station;
    }
    @Transient
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    @Transient
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    @Transient
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Transient
    public String getVaccination() {
        return vaccination;
    }
    public void setVaccination(String vaccination) {
        this.vaccination = vaccination;
    }
    @Transient
    public String getExperience() {
        return experience;
    }
    public void setExperience(String experience) {
        this.experience = experience;
    }
}

+ 111 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/voluntary/VoluntaryRecruitmentCompanyDO.java

@ -0,0 +1,111 @@
package com.yihu.jw.entity.voluntary;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 * 只有招募单位表
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@Entity
@Table(name="voluntary_recruitment_company")
public class VoluntaryRecruitmentCompanyDO extends UuidIdentityEntityWithCreateTime{
    /**
     * 单位名称
     */
    private String name;
    /**
     * 联系人
     */
    private String contacts;
    /**
     * 联系人手机
     */
    private String phone;
    /**
     * 服务时间段
     */
    private String times;
    /**
     * 服务站
     */
    private String serviceStation;
    /**
     * 报名人数
     */
    private Integer num;
    List<VoluntaryRecruitmentPeopleDO> peopleDOList;
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "contacts")
    public String getContacts() {
        return contacts;
    }
    public void setContacts(String contacts) {
        this.contacts = contacts;
    }
    @Column(name = "phone")
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    @Column(name = "times")
    public String getTimes() {
        return times;
    }
    public void setTimes(String times) {
        this.times = times;
    }
    @Column(name = "service_station")
    public String getServiceStation() {
        return serviceStation;
    }
    public void setServiceStation(String serviceStation) {
        this.serviceStation = serviceStation;
    }
    @Column(name = "num")
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    @Transient
    public List<VoluntaryRecruitmentPeopleDO> getPeopleDOList() {
        return peopleDOList;
    }
    public void setPeopleDOList(List<VoluntaryRecruitmentPeopleDO> peopleDOList) {
        this.peopleDOList = peopleDOList;
    }
}

+ 111 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/voluntary/VoluntaryRecruitmentPeopleDO.java

@ -0,0 +1,111 @@
package com.yihu.jw.entity.voluntary;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 * 志愿招募企业表
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@Entity
@Table(name="voluntary_recruitment_people")
public class VoluntaryRecruitmentPeopleDO extends UuidIdentityEntityWithCreateTime{
    /**
     * 单位id
     */
    private String companyId;
    /**
     * 单位名称
     */
    private String companyName;
    /**
     * 姓名
     */
    private String name;
    /**
     * 手机
     */
    private String phone;
    /**
     * 身份证
     */
    private String idcard;
    /**
     * 是否接种疫苗 0未接种 1接种1针 2已接种
     */
    private String vaccination;
    /**
     * 是否有核酸设备运维经验
     */
    private String experience;
    @Column(name = "company_id")
    public String getCompanyId() {
        return companyId;
    }
    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }
    @Column(name = "company_name")
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "phone")
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    @Column(name = "idcard")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Column(name = "vaccination")
    public String getVaccination() {
        return vaccination;
    }
    public void setVaccination(String vaccination) {
        this.vaccination = vaccination;
    }
    @Column(name = "experience")
    public String getExperience() {
        return experience;
    }
    public void setExperience(String experience) {
        this.experience = experience;
    }
}

+ 39 - 3
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/emergency/EmergencyOrderVO.java

@ -1,6 +1,8 @@
package com.yihu.jw.restmodel.emergency;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import java.util.Date;
@ -36,10 +38,8 @@ public class EmergencyOrderVO {
    private String sceneImg;//工单发起是现场照片
    //附加信息
    private Map<String,Object> information;//附加信息
    private Map<String,Object> information;//附加信息(安防工单不同专题返回值不一样)
    private String phone;
    //围栏状态 fences
@ -49,6 +49,10 @@ public class EmergencyOrderVO {
    private List<Map<String,Object>> noticePersons;//通知对象
    private String otherDoctorDistance;//其他医生定位信息
    private String topicItem;//安防工单专题code关联security_topic_dict字典
    private List<BaseEmergencyWarnLogDO> orderLogInfo;
    private List<PatientSosContactsDO> sosContacts;//紧急联系人
    private List<Map<String,Object>> securityDevices;//安防设备列表
    public String getId() {
        return id;
@ -249,4 +253,36 @@ public class EmergencyOrderVO {
    public void setSceneImg(String sceneImg) {
        this.sceneImg = sceneImg;
    }
    public String getTopicItem() {
        return topicItem;
    }
    public void setTopicItem(String topicItem) {
        this.topicItem = topicItem;
    }
    public List<BaseEmergencyWarnLogDO> getOrderLogInfo() {
        return orderLogInfo;
    }
    public void setOrderLogInfo(List<BaseEmergencyWarnLogDO> orderLogInfo) {
        this.orderLogInfo = orderLogInfo;
    }
    public List<PatientSosContactsDO> getSosContacts() {
        return sosContacts;
    }
    public void setSosContacts(List<PatientSosContactsDO> sosContacts) {
        this.sosContacts = sosContacts;
    }
    public List<Map<String, Object>> getSecurityDevices() {
        return securityDevices;
    }
    public void setSecurityDevices(List<Map<String, Object>> securityDevices) {
        this.securityDevices = securityDevices;
    }
}

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

@ -11,6 +11,7 @@ import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/5/19.
@ -1354,6 +1355,54 @@ public class DateUtil {
        return dateTime.substring(0, 10);
    }
    /**
     *  返回 xx天XX小时XX分钟XX秒前
     * @param date1 当前时间
     * @param date2 过去时间
     * @param fliter 0不携带秒 1携带秒
     * @return
     */
    public static String getDifferentTimeInfo(Date date1, Date date2,Integer fliter){
        if (date1 == null || date2 == null){
            return null;
        }
        StringBuilder result = new StringBuilder("");
        long millisecondsDiff = date1.getTime() - date2.getTime();
        long secondsDiff = millisecondsDiff / TimeUnit.SECONDS.toMillis(1L);
        long minutesDiff = millisecondsDiff / TimeUnit.MINUTES.toMillis(1L);
        long hoursDiff = millisecondsDiff / TimeUnit.HOURS.toMillis(1L);
        long daysDiff = millisecondsDiff / TimeUnit.DAYS.toMillis(1L);
        long hourFieldDiff = hoursDiff - TimeUnit.DAYS.toHours(daysDiff);
        long minuteFieldDiff = minutesDiff - TimeUnit.HOURS.toMinutes(hoursDiff);
        long secondFieldDiff = secondsDiff - TimeUnit.MINUTES.toSeconds(minutesDiff);
        if (daysDiff > 0L) {
            result.append(String.format("%d天", daysDiff));
            result.append("前");
            return result.toString();
        }
        if (hourFieldDiff > 0L) {
            result.append(String.format("%d小时", hourFieldDiff));
        }
        if (minuteFieldDiff > 0L) {
            result.append(String.format("%d分钟", minuteFieldDiff));
            if (result.indexOf("小时")>0){
                result.append("前");
                return result.toString();
            }
        }
        if (1==fliter){
            if (secondFieldDiff > 0L) {
                result.append(String.format("%d秒", secondFieldDiff));
            }
        }else {
            if (result.indexOf("分钟")==-1){
                result.append("1分钟前");
                return result.toString();
            }
        }
        result.append("前");
        return result.toString();
    }
}

+ 31 - 23
common/common-util/src/main/java/com/yihu/jw/util/healthIndex/HealthIndexUtil.java

@ -54,17 +54,19 @@ public class HealthIndexUtil {
            int index = Integer.valueOf(values[1]);
            String value1 = values[0];
            // 餐后
            if (index % 2 == 0) {
                tmp.put("value1",value1);
                tmp.put("indexName","血糖");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter));
            if (StringUtils.isNotBlank(value1)){
                if (index % 2 == 0) {
                    tmp.put("value1",value1);
                    tmp.put("indexName","血糖");
                    tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter));
            } else { //餐前
                tmp.put("value1",value1);
                tmp.put("indexName","血糖");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore));
                } else { //餐前
                    tmp.put("value1",value1);
                    tmp.put("indexName","血糖");
                    tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore));
                }
                result.add(tmp);
            }
            result.add(tmp);
        }
        //血压校验
        else if (type == 2) {
@ -78,17 +80,21 @@ public class HealthIndexUtil {
            Double maxValueSZY = HEALTH_STANDARD_SZY_MAX;
            Double minValueSZY = HEALTH_STANDARD_SZY_MIN;
            // 收缩压/舒张压校验
            tmp.put("value1",value1);
            tmp.put("indexName","收缩压");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY));
            result.add(tmp);
            if (StringUtils.isNotBlank(value1)){
                tmp.put("value1",value1);
                tmp.put("indexName","收缩压");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY));
                result.add(tmp);
            }
            //舒张压校验
            tmp = new JSONObject();
            tmp.put("value1",value2);
            tmp.put("indexName","舒张压");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY));
            result.add(tmp);
            tmp = new JSONObject();
            if (StringUtils.isNotBlank(value2)){
                tmp = new JSONObject();
                tmp.put("value1",value2);
                tmp.put("indexName","舒张压");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY));
                result.add(tmp);
                tmp = new JSONObject();
            }
            //脉搏检验
            if (StringUtils.isNotBlank(value3)){
                tmp.put("value1",value3);
@ -99,10 +105,12 @@ public class HealthIndexUtil {
        }
        else if (type == 5) {//心率
            String value1 = values[0];//心率
            tmp.put("value1",value1);
            tmp.put("indexName","心率");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN));
            result.add(tmp);
            if (StringUtils.isNotBlank(value1)){
                tmp.put("value1",value1);
                tmp.put("indexName","心率");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN));
                result.add(tmp);
            }
        }
        return result;
    }

+ 3 - 2
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/DidiFilterProcessor.java

@ -32,7 +32,8 @@ public class DidiFilterProcessor extends FilterProcessor {
        try {
            return super.processZuulFilter(filter);
        } catch (ZuulException e) {
            if (e.nStatusCode==500){
            throw e;
            /*if (e.nStatusCode==500){
                String message="";
                String cause="";
                String serviceId="";
@ -79,7 +80,7 @@ public class DidiFilterProcessor extends FilterProcessor {
                throw e1 ;
            }else {
                throw e;
            }
            }*/
        }
    }
}

+ 16 - 0
gateway/ag-basic/src/main/resources/application.yml

@ -62,6 +62,10 @@ zuul:
    svr-base:
      path: /cityihealth/base/**
      serviceId: svr-base
#新冠患者招募
    svr-base-vol:
      path: /cityihealth/baseVol/**
      serviceId: svr-base-vol
    svr-authentication:
      path: /cityihealth/auth/**
      serviceId: svr-authentication
@ -255,3 +259,15 @@ spring:
     host: 127.0.0.1 # Redis server host.
     port: 6380  # Redis server port.
     password: Kb6wKDQP1W4
---
spring:
  profiles: dsyy
  datasource:
     url: jdbc:mysql://127.0.0.1:3306/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
     username: wlyy
     password: 2oEq3Kf7@zjxl
  redis:
    host: 127.0.0.1 # Redis server host.
    port: 6380 # Redis server port.

+ 9 - 1
gateway/ag-basic/src/main/resources/bootstrap.yml

@ -13,7 +13,7 @@ eureka:
    healthcheck:
      enabled: false #监控检查
    serviceUrl:
      defaultZone: http://jw:jkzl@192.168.120.210:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/
  instance:
    prefer-ip-address: false
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
@ -136,4 +136,12 @@ spring:
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://192.168.120.71:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: dsyy
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}

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

@ -589,7 +589,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        } else if ("2".equals(loginType)) {//2.为医生账号
            result = this.getJdbcTemplate().queryForMap("select d.login_failure_count,d.last_login_failure_time from base_doctor d where d.mobile = ? or d.idcard = ?", username, username);
        } else if ("3".equals(loginType)) { //3.患者账号
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ?", username, username);
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ? limit 1", username, username);
        } else if ("4".equals(loginType)) { //4.第三方患者账号
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ?", username, getIdcard());
        }
@ -697,22 +697,22 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
     * @return
     */
    private String getClientName(String clientType){
        String result = "";
        switch (clientType){
            case "app":
                result = "APP";
                break;
            case "wx":
                result = "微信公众号";
                break;
            case "pad":
                result = "多媒体平板";
                break;
            case "pc":
                result = "脑端";
                break;
        if(StringUtils.isBlank(clientType)){
            return "";
        }
        return result;
        if("app".equals(clientType)){
            return "APP";
        }
        if("wx".equals(clientType)){
            return "微信公众号";
        }
        if("pad".equals(clientType)){
            return "多媒体平板";
        }
        if("pc".equals(clientType)){
            return "电脑脑端";
        }
        return "";
    }
    /**

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

@ -1292,17 +1292,21 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            String data = new String(Base64Utils.decode((str.getBytes())));
            //固定秘钥解密
            String key = "FEA5049E4CCD16A9";
            String result = AES.decrypt(key,data);
            String result = AesEncryptUtils.decrypt(data,key);
          /*  String result = AES.decrypt(key,data);*/
            logger.info("wjwLogin :"+result);
            BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
            logger.info("授权进来1");
            if(patientDO == null){
                return ObjEnvelop.getError("授权登录失败!");
            }
            logger.info("授权进来2");
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            logger.info("授权进来3");
            Map<String, String> parameters = new HashedMap();
            parameters.put("username",patientDO.getIdcard());

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

@ -3,9 +3,12 @@ package com.yihu.jw.security.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.dao.patient.BasePatientWechatDao;
import com.yihu.jw.security.dao.patient.WlyyPatientFamilyMemberDao;
import com.yihu.jw.security.model.PatientWechat;
import com.yihu.jw.security.utils.AES;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.utils.security.MD5;
@ -20,9 +23,12 @@ import org.springframework.transaction.annotation.Transactional;
import java.net.URLDecoder;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.springframework.util.Base64Utils;
import javax.sound.midi.MidiDevice;
/**
 * Created by Trick on 2020/2/24.
 */
@ -36,6 +42,8 @@ public class OauthWjwConfigService {
    private BasePatientDao basePatientDao;
    @Autowired
    private WlyyPatientFamilyMemberDao familyMemberDao;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    public BasePatientDO savePatient(String data)throws Exception{
        logger.info("savePatient :"+data);
@ -52,6 +60,7 @@ public class OauthWjwConfigService {
            String userSex = info.getString("userSex");
            String userIdNo = info.getString("userIdNo");
            String dType = info.getString("dType");
            String openId = info.getString("openid");
            if(StringUtils.isNotBlank(userIdNo)){
@ -84,6 +93,7 @@ public class OauthWjwConfigService {
                String pw = userIdNo.substring(userIdNo.length()-6);
                patient.setIdcard(userIdNo);
                patient.setCardType("01");
                patient.setName(name);
                patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patient.setSalt(salt);
@ -112,8 +122,22 @@ public class OauthWjwConfigService {
                    basePatientFamilyMemberDO.setFamilyMember(patient.getId());
                    familyMemberDao.save(basePatientFamilyMemberDO);
                }
                List<BasePatientWechatDo> patientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId("xm_tasy_wx",patient.getId());
                if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                    BasePatientWechatDo basePatientWechatDo = patientWechatDos.get(0);
                    basePatientWechatDo.setOpenid(openId);
                }else {
                    BasePatientWechatDo patientWechatDo = new BasePatientWechatDo();
                    patientWechatDo.setOpenid(openId);
                    patientWechatDo.setCreateTime(new Date());
                    patientWechatDo.setPatientId(patient.getId());
                    patientWechatDo.setWechatId("xm_tasy_wx");
                    patientWechatDo.setSaasId("prod");
                    basePatientWechatDao.save(patientWechatDo);
                }
                return basePatientDO;
                return patient;
            }
            return null;

+ 35 - 35
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWlyyConfigService.java

@ -97,48 +97,48 @@ public class OauthWlyyConfigService {
                    BaseDoctorDO doctorDO = baseDoctorDao.findByIdcard(idcard);
                    if(doctorDO!=null){
                        Integer level =  doctorJson.getInteger("level");
                        if(level==null||level!=1){
                            //判断区信息 补充数据
                            if(StringUtils.isBlank(doctorDO.getTownCode())){
                                doctorDO.setTownCode(doctorJson.getString("town"));
                                doctorDO.setTownName(doctorJson.getString("townName"));
                                baseDoctorDao.save(doctorDO);
                            }
                        //判断区信息 补充数据
                        if(StringUtils.isBlank(doctorDO.getTownCode())){
                            doctorDO.setTownCode(doctorJson.getString("town"));
                            doctorDO.setTownName(doctorJson.getString("townName"));
                            baseDoctorDao.save(doctorDO);
                        }
                        //判断不充机构信息
                        List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
                        if(hospitalDOs!=null&&hospitalDOs.size()>0){
                            //不新增
                        }else{
                            //补充机构信息
                            BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
                            hospitalDO.setDoctorCode(doctorDO.getId());
                            hospitalDO.setOrgCode(doctorJson.getString("hospital"));
                            hospitalDO.setOrgName(doctorJson.getString("hospitalName"));
                            hospitalDO.setDel("1");
                            baseDoctorHospitalDao.save(hospitalDO);
                        }
                            //判断不充机构信息
                            List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
                            if(hospitalDOs!=null&&hospitalDOs.size()>0){
                                //不新增
                            }else{
                                //补充机构信息
                                BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
                                hospitalDO.setDoctorCode(doctorDO.getId());
                                hospitalDO.setOrgCode(doctorJson.getString("hospital"));
                                hospitalDO.setOrgName(doctorJson.getString("hospitalName"));
                                hospitalDO.setDel("1");
                                baseDoctorHospitalDao.save(hospitalDO);
                            }
                        List<BaseDoctorRoleDO> roleDOs = baseDoctorRoleDao.findByDoctorCode(doctorDO.getId());
                            List<BaseDoctorRoleDO> roleDOs = baseDoctorRoleDao.findByDoctorCode(doctorDO.getId());
                        //判断不充角色信息
                        if(roleDOs!=null&&roleDOs.size()>0){
                            //不新增
                        }else{
                            Integer level =  doctorJson.getInteger("level");
                            //判断不充角色信息
                            if(roleDOs!=null&&roleDOs.size()>0){
                                //不新增
                            }else{
                            BaseDoctorRoleDO role = new BaseDoctorRoleDO();
                            role.setDoctorCode(doctorDO.getId());
                            if(level!=null&&level==1){
                                role.setRoleCode("specialist");
                            }else {
                                role.setRoleCode("generalDoctor");
                            }
                                BaseDoctorRoleDO role = new BaseDoctorRoleDO();
                                role.setDoctorCode(doctorDO.getId());
                                if(level!=null&&level==1){
                                    role.setRoleCode("specialist");
                                }else {
                                    role.setRoleCode("generalDoctor");
                                }
                            baseDoctorRoleDao.save(role);
                                baseDoctorRoleDao.save(role);
                            }
                        }
                        return data;
                    }else{
                        //存储医生全科医生信息

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

@ -492,4 +492,34 @@ im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
    eachOther: 1
---
spring:
  profiles: dsyy
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    username: wlyy
    password: 2oEq3Kf7@zjxl
  redis:
    host: 127.0.0.1 # Redis server host.
    port: 6379 # Redis server port.
iHealth:
  user-info-uri: http://ehr.yihu.com/wlyy/iHealth/userInfo
zhongshanHospital:
  user-info-uri: http://laptop-u738dn2p:10023/mqsdk/getUserInfoByOpenid
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
wlyy:
  url: http://www.xmtyw.cn/wlyy/
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
kick:
    eachOther: 1
im:
  im_list_get: http://172.26.0.105:3000/
wechat:
  id: xm_dsyy_wx

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

@ -138,4 +138,12 @@ spring:
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:jwdev}
      label: ${wlyy-spring.config.label:jwdev}
---
spring:
  profiles: dsyy
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:master}

+ 15 - 0
server/svr-configuration/src/main/resources/bootstrap.yml

@ -207,4 +207,19 @@ spring:
        git:
          uri: ${wlyy.spring.config.git.uri:http://127.0.0.1:3000/jkzl/ehr.config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:master}
---
spring:
  profiles: dsyy
##git配置
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: ${wlyy.spring.config.git.uri:http://27.150.172.197:3001/jkzl/wlyy2.0.config.git}
          basedir: /usr/local/wlyy2.0.config
          username: jkzl
          password: jkzl
        default-label: ${wlyy.spring.config.git.label:master}

+ 15 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentArrangeDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.base.dao.voluntary;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentArrangeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
public interface VoluntaryRecruitmentArrangeDao extends PagingAndSortingRepository<VoluntaryRecruitmentArrangeDO, String>, JpaSpecificationExecutor<VoluntaryRecruitmentArrangeDO> {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentCompanyDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao.voluntary;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
public interface VoluntaryRecruitmentCompanyDao extends PagingAndSortingRepository<VoluntaryRecruitmentCompanyDO, String>, JpaSpecificationExecutor<VoluntaryRecruitmentCompanyDO> {
    VoluntaryRecruitmentCompanyDO findByName(String name);
    boolean existsByName(String name);
    List<VoluntaryRecruitmentCompanyDO> findByContactsAndPhone(String contacts,String phone);
}

+ 24 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentPeopleDao.java

@ -0,0 +1,24 @@
package com.yihu.jw.base.dao.voluntary;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentPeopleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
public interface VoluntaryRecruitmentPeopleDao extends PagingAndSortingRepository<VoluntaryRecruitmentPeopleDO, String>, JpaSpecificationExecutor<VoluntaryRecruitmentPeopleDO> {
    boolean existsByPhone(String phone);
    List<VoluntaryRecruitmentPeopleDO> queryByIdIn(String[] id);
    @Query("select count(1) from VoluntaryRecruitmentPeopleDO where companyId = ?1 ")
    Integer findByCompanyId(String CompanyId);
}

+ 2 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/TemplateManageEndpoint.java

@ -459,7 +459,8 @@ public class TemplateManageEndpoint  extends EnvelopRestEndpoint {
            @ApiParam(name = "diseaseId", value = "id")
            @RequestParam(value = "diseaseId", required = false) String diseaseId) throws Exception {
        try {
            return success(templateManageService.findTemplateByDisease(diseaseId));
            String doctorId=getUID();
            return success(templateManageService.findTemplateByDisease(doctorId,diseaseId));
        }catch (Exception e){
            e.printStackTrace();
            return failedMixEnvelopException(e);

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java

@ -81,8 +81,12 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByServicePackageId(servicePackageDO.getId());
            List<String> orgNames = itemDOList.stream().map(p -> p.getOrgName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            List<String> teamNames = itemDOList.stream().map(p -> p.getTeamName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            List<String> orgCodes = itemDOList.stream().map(p -> p.getOrgCode()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
 //           List<String> teamCodes = itemDOList.stream().map(p -> p.getTeamCode()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            servicePackageDO.setOrgNames(StringUtils.join(orgNames,","));
            servicePackageDO.setTeamNames(StringUtils.join(teamNames,","));
            servicePackageDO.setOrgCodes(StringUtils.join(orgCodes,","));
            for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:wlyyHospitalSysDictDOS){
                if (servicePackageDO.getType().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){

+ 160 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentArrangeEndpoint.java

@ -0,0 +1,160 @@
package com.yihu.jw.base.endpoint.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentPeopleDao;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentArrangeService;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentArrangeDO;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentPeopleDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
/**
 * Created by Bing on 2021/8/4.
 */
@RestController
@RequestMapping(value = "voluntaryRecruitmentArrange")
@Api(value = "新冠-志愿招募安排管理", description = "新冠-志愿招募安排管理", tags = {"新冠-志愿招募安排管理"})
public class VoluntaryRecruitmentArrangeEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private VoluntaryRecruitmentArrangeService arrangeService;
    @Autowired
    private VoluntaryRecruitmentPeopleDao peopleDao;
    @GetMapping(value = "page")
    @ApiOperation(value = "获取分页")
    public PageEnvelop<VoluntaryRecruitmentArrangeDO> page(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<VoluntaryRecruitmentArrangeDO> appVersions = arrangeService.search(fields, filters, sorts, page, size);
        int count = (int) arrangeService.getCount(filters);
        return success(appVersions, count, page, size, VoluntaryRecruitmentArrangeDO.class);
    }
    @GetMapping(value = "list")
    @ApiOperation(value = "获取列表")
    public ListEnvelop<VoluntaryRecruitmentArrangeDO> list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<VoluntaryRecruitmentArrangeDO> appVersions = arrangeService.search(fields, filters, sorts);
        return success(appVersions, VoluntaryRecruitmentArrangeDO.class);
    }
    @GetMapping(value = "/excelControl/exportExcel")
    @ApiOperation("导出列表")
    @ResponseBody
    public void searchList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            HttpServletResponse response) {
        try {
            List<VoluntaryRecruitmentArrangeDO> appVersions = arrangeService.search(fields, filters, sorts);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("volunteerArrange.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os, appVersions);
        } catch (Exception ex) {
            Envelop.getError("导出失败");
        }
    }
    private void write(OutputStream os, List<VoluntaryRecruitmentArrangeDO> list) throws Exception {
        WritableWorkbook wwb = Workbook.createWorkbook(os);
        try {
            WritableSheet sheet = wwb.createSheet("sheet", 1);
            String header[] = {"序号", "日期","服务时间","所在单位", " 姓名", "手机号", "身份证号", "是否有核酸检测信息采集设备运维经验","是否接种疫苗"};
            int i = 0;
            for (String h : header) {
                addCell(sheet, 0, i, h);
                i++;
            }
            int j = 1;
            int ii=1;
            for (VoluntaryRecruitmentArrangeDO tmp : list) {
                VoluntaryRecruitmentPeopleDO peopleDO= peopleDao.findOne(tmp.getPeopleId());
                if (null == peopleDO){
                    continue;
                }
                String vaccinationName = "未接种";
                String experienceName = "否";
                if (StringUtils.isNotBlank(peopleDO.getVaccination())){
                    String  vaccination = peopleDO.getVaccination();
                    switch (vaccination){
                        case "1":
                            vaccinationName = "已接种一针";
                            break;
                        case "2":
                            vaccinationName = "已接种";
                            break;
                    }
                }
                if (StringUtils.isNotBlank(peopleDO.getExperience())){
                    String  experience = peopleDO.getExperience();
                    switch (experience){
                        case "0":
                            experienceName = "否";
                            break;
                        case "1 ":
                            experienceName = "是";
                            break;
                    }
                }
                addCell(sheet, j, 0, ii + "");
                addCell(sheet, j, 1, tmp.getDay());
                addCell(sheet, j, 2, tmp.getTime());
                addCell(sheet, j, 3, peopleDO.getCompanyName());
                addCell(sheet, j, 4, tmp.getPeopleName() + "");
                addCell(sheet, j, 5, peopleDO.getPhone()+"");
                addCell(sheet, j, 6, peopleDO.getIdcard() + "");
                addCell(sheet, j, 7, experienceName);
                addCell(sheet, j, 8, vaccinationName);
                j++;
                ii++;
            }
            wwb.write();
            wwb.close();
        } catch (Exception e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
        }
    }
    private void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        ws.addCell(label);
    }
}

+ 157 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentCompanyEndpoint.java

@ -0,0 +1,157 @@
package com.yihu.jw.base.endpoint.voluntary;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentCompanyService;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@RestController
@RequestMapping(value = "voluntaryRecruitmentCompany")
@Api(value = "新冠-志愿招募单位管理", description = "新冠-志愿招募单位管理", tags = {"新冠-志愿招募单位管理"})
public class VoluntaryRecruitmentCompanyEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private VoluntaryRecruitmentCompanyService companyService;
    @PostMapping(value = "delete")
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        companyService.delete(ids.split(","));
        return success("删除成功");
    }
    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    public ObjEnvelop<VoluntaryRecruitmentCompanyDO> update(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        VoluntaryRecruitmentCompanyDO appVersion = toEntity(jsonData, VoluntaryRecruitmentCompanyDO.class);
        if (null == appVersion.getId()) {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        appVersion = companyService.save(appVersion);
        return success(appVersion, VoluntaryRecruitmentCompanyDO.class);
    }
    @GetMapping(value = "page")
    @ApiOperation(value = "获取分页")
    public PageEnvelop<VoluntaryRecruitmentCompanyDO> page(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<VoluntaryRecruitmentCompanyDO> appVersions = companyService.search(fields, filters, sorts, page, size);
        int count = (int) companyService.getCount(filters);
        return success(appVersions, count, page, size, VoluntaryRecruitmentCompanyDO.class);
    }
    @GetMapping(value = "list")
    @ApiOperation(value = "获取列表")
    public ListEnvelop<VoluntaryRecruitmentCompanyDO> list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<VoluntaryRecruitmentCompanyDO> appVersions = companyService.search(fields, filters, sorts);
        return success(appVersions, VoluntaryRecruitmentCompanyDO.class);
    }
    @GetMapping(value = "/excelControl/exportExcel")
    @ApiOperation("导出列表")
    @ResponseBody
    public void searchList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            HttpServletResponse response) {
        try {
            List<VoluntaryRecruitmentCompanyDO> appVersions = companyService.search(fields, filters, sorts);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("volunteerInfo.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os, appVersions);
        } catch (Exception ex) {
            Envelop.getError("导出失败");
        }
    }
    private void write(OutputStream os, List<VoluntaryRecruitmentCompanyDO> list) throws Exception {
        WritableWorkbook wwb = Workbook.createWorkbook(os);
        try {
            WritableSheet sheet = wwb.createSheet("sheet", 1);
            String header[] = {"序号", "所在单位", "单位联系人", " 联系人手机号", "报名志愿者人数", "意向服务时间段", "意向服务的核酸采集点"};
            int i = 0;
            for (String h : header) {
                addCell(sheet, 0, i, h);
                i++;
            }
            int j = 1;
            int ii=1;
            for (VoluntaryRecruitmentCompanyDO tmp : list) {
                addCell(sheet, j, 0, ii + "");
                addCell(sheet, j, 1, tmp.getName());
                addCell(sheet, j, 2, tmp.getContacts());
                addCell(sheet, j, 3, tmp.getPhone() + "");
                addCell(sheet, j, 4, tmp.getNum()+"");
                addCell(sheet, j, 5, tmp.getTimes() + "");
                addCell(sheet, j, 6, tmp.getServiceStation() + "");
                j++;
                ii++;
            }
            wwb.write();
            wwb.close();
        } catch (Exception e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
        }
    }
    private void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        ws.addCell(label);
    }
}

+ 246 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentEndpoint.java

@ -0,0 +1,246 @@
package com.yihu.jw.base.endpoint.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentCompanyDao;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentPeopleDao;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentArrangeService;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentCompanyService;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentPeopleService;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentService;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentPeopleDO;
import com.yihu.jw.hospital.dict.service.WlyyHospitalSysDictService;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@RestController
@RequestMapping(value = "open/voluntary")
@Api(value = "新冠-志愿招募管理", description = "新冠-志愿招募管理", tags = {"新冠-志愿招募管理"})
public class VoluntaryRecruitmentEndpoint extends EnvelopRestEndpoint {
 
    @Autowired
    private VoluntaryRecruitmentService voluntaryRecruitmentService;
    @Autowired
    private VoluntaryRecruitmentCompanyService companyService;
    @Autowired
    private VoluntaryRecruitmentPeopleDao peopleDao;
    @Autowired
    private WlyyHospitalSysDictService wlyyHospitalSysDictService;
    @Autowired
    private VoluntaryRecruitmentArrangeService arrangeService;
    @Autowired
    private VoluntaryRecruitmentPeopleService peopleService;
    @Autowired
    private VoluntaryRecruitmentCompanyDao companyDao;
    @PostMapping(value = "add")
    @ApiOperation(value = "企业报名")
    public Envelop add (
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
         @RequestParam String jsonData){
        try {
            VoluntaryRecruitmentCompanyDO companyDO = toEntity(jsonData, VoluntaryRecruitmentCompanyDO.class);
            String result = voluntaryRecruitmentService.add(companyDO);
            if(StringUtil.isBlank(result)){
                return success("报名成功");
            }
           return Envelop.getError(result,-1);
        }catch (Exception e){
            e.printStackTrace();
            return failedException2(e);
        }
    }
    @GetMapping(value = "page")
    @ApiOperation(value = "获取分页")
    public PageEnvelop<VoluntaryRecruitmentCompanyDO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size){
            try {
                List<VoluntaryRecruitmentCompanyDO> appVersions = companyService.search(fields, filters, sorts, page, size);
                int count = (int)companyService.getCount(filters);
                return success(appVersions, count, page, size, VoluntaryRecruitmentCompanyDO.class);
            }catch (Exception e){
                e.printStackTrace();
                return  PageEnvelop.getError("查询失败");
            }
    }
    @GetMapping(value = "existsByPhone")
    @ApiOperation(value = "人员是否已报名")
    public ObjEnvelop existsByPhone (
            @ApiParam(name = "phone", value = "联系人手机")
            @RequestParam(value = "phone", required = true) String phone){
        try {
            return ObjEnvelop.getSuccess("查找成功",peopleDao.existsByPhone(phone));
        }catch (Exception e){
            e.printStackTrace();
            return  ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "findByContactsAndPhone")
    @ApiOperation(value = "查找单个企业")
    public ObjEnvelop<VoluntaryRecruitmentCompanyDO> findByContactsAndPhone (
            @ApiParam(name = "contacts", value = "联系人姓名")
            @RequestParam(value = "contacts", required = true) String contacts,
            @ApiParam(name = "phone", value = "联系人手机")
            @RequestParam(value = "phone", required = true) String phone){
        try {
            VoluntaryRecruitmentCompanyDO companyDO = voluntaryRecruitmentService.findByContactsAndPhone(contacts,phone);
            if(companyDO==null){
               return ObjEnvelop.getError("未找到关联企业");
            }
            return ObjEnvelop.getSuccess("查找成功",companyDO);
        }catch (Exception e){
            e.printStackTrace();
            return  ObjEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = "arrange")
    @ApiOperation(value = "人员安排")
    public Envelop arrange (
            @ApiParam(name = "companyId", value = "联系人姓名")
            @RequestParam(value = "companyId", required = true) String companyId,
            @ApiParam(name = "day", value = "服务日期")
            @RequestParam(value = "day", required = true) String day,
            @ApiParam(name = "time", value = "服务时间段")
            @RequestParam(value = "time", required = true) String time,
            @ApiParam(name = "peoples", value = "服务人员 id+姓名逗号间隔。例:1:测试1,2:测试2")
            @RequestParam(value = "peoples", required = true) String peoples,
            @ApiParam(name = "station", value = "服务站")
            @RequestParam(value = "station", required = true) String station){
        try {
            voluntaryRecruitmentService.arrange(companyId, day, time, peoples, station);
            return success("安排成功");
        }catch (Exception e){
            e.printStackTrace();
            return failedException2(e);
        }
    }
    @GetMapping(value = "arrangeInfoList")
    @ApiOperation(value = "获取企业人员安排数量列表")
    public ListEnvelop arrangeInfoList (
            @ApiParam(name = "companyId", value = "企业id")
            @RequestParam(value = "companyId", required = true) String companyId){
        try {
            return ListEnvelop.getSuccess("安排成功",voluntaryRecruitmentService.arrangeInfoList(companyId));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "arrangeInfoDetail")
    @ApiOperation(value = "获取企业安排信息详情详情")
    public ListEnvelop arrangeInfoDetail (
            @ApiParam(name = "companyId", value = "企业id")
            @RequestParam(value = "companyId", required = true) String companyId,
            @ApiParam(name = "day", value = "日期 yyyy-MM-dd格式")
            @RequestParam(value = "day", required = false) String day){
        try {
            return ListEnvelop.getSuccess("安排成功",voluntaryRecruitmentService.arrangeInfoDetail(companyId,day));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "companyPeopleUnArrange")
    @ApiOperation(value = "获取企业志愿者列表(未被安排)")
    public ListEnvelop companyPeopleUnArrange (
            @ApiParam(name = "companyId", value = "企业id")
            @RequestParam(value = "companyId", required = true) String companyId,
            @ApiParam(name = "day", value = "日期 yyyy-MM-dd格式")
            @RequestParam(value = "day", required = true) String day,
            @ApiParam(name = "time", value = "时间")
            @RequestParam(value = "time", required = true) String time){
        try {
            return ListEnvelop.getSuccess("安排成功",voluntaryRecruitmentService.companyPeopleUnArrange(companyId,day,time));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @PostMapping(value = "arrangeDelete")
    @ApiOperation(value = "企业志愿者安排删除")
    public Envelop arrangeDelete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        arrangeService.delete(ids.split(","));
        return success("删除成功");
    }
    @GetMapping(value = "companyPeopleList")
    @ApiOperation(value = "企业志愿者名单列表")
    public ListEnvelop<VoluntaryRecruitmentPeopleDO> companyPeopleList (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<VoluntaryRecruitmentPeopleDO> appVersions = peopleService.search(fields, filters, sorts);
        return success(appVersions, VoluntaryRecruitmentPeopleDO.class);
    }
    @PostMapping(value = "companyPeopleDelete")
    @ApiOperation(value = "企业志愿者名单删除")
    public Envelop companyPeopleDelete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        String[] idsTmp = ids.split(",");
        List<VoluntaryRecruitmentPeopleDO> List = peopleService.getRepository().queryByIdIn(idsTmp);
        peopleService.delete(ids.split(","));
        for (VoluntaryRecruitmentPeopleDO tmp:List){
            VoluntaryRecruitmentCompanyDO companyDO = companyDao.findOne(tmp.getCompanyId());
            if (null !=companyDO ){
                Integer count = peopleService.getRepository().findByCompanyId(tmp.getCompanyId());
                companyDO.setNum(count);
                companyDao.save(companyDO);
            }
        }
        return success("删除成功");
    }
    @ApiOperation("查询字典")
    @GetMapping(value= "findDict")
    public MixEnvelop findDict(@ApiParam(name = "name", value = "name", required = false)
                               @RequestParam(value = "name", required = false)String name,
                               @ApiParam(name = "modelName", value = "modelName", required = false)
                               @RequestParam(value = "modelName", required = false)String modelName,
                               @ApiParam(name = "code", value = "code", required = false)
                               @RequestParam(value = "code", required = false)String code,
                               @ApiParam(name = "value", value = "value", required = false)
                               @RequestParam(value = "value", required = false)String value,
                               @ApiParam(name = "page", value = "page", required = false)
                               @RequestParam(value = "page", required = false) Integer page,
                               @ApiParam(name = "pageSize", value = "pageSize", required = false)
                               @RequestParam(value = "pageSize", required = false)Integer pageSize){
        return wlyyHospitalSysDictService.findDictsByNameCode(modelName,name,code,value,page,pageSize);
    }
}

+ 107 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentPeopleEndpoint.java

@ -0,0 +1,107 @@
package com.yihu.jw.base.endpoint.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentCompanyDao;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentPeopleService;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentPeopleDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@RestController
@RequestMapping(value = "voluntaryRecruitmentPeople")
@Api(value = "新冠-志愿招募单位人员管理", description = "新冠-志愿招募单位人员管理", tags = {"新冠-志愿招募单位人员管理"})
public class VoluntaryRecruitmentPeopleEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private VoluntaryRecruitmentPeopleService peopleService;
    @Autowired
    private VoluntaryRecruitmentCompanyDao companyDao;
    @PostMapping(value = "delete")
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        String[] idsTmp = ids.split(",");
        List<VoluntaryRecruitmentPeopleDO> List = peopleService.getRepository().queryByIdIn(idsTmp);
        peopleService.delete(ids.split(","));
        for (VoluntaryRecruitmentPeopleDO tmp:List){
            VoluntaryRecruitmentCompanyDO companyDO = companyDao.findOne(tmp.getCompanyId());
            if (null !=companyDO ){
                Integer count = peopleService.getRepository().findByCompanyId(tmp.getCompanyId());
                companyDO.setNum(count);
                companyDao.save(companyDO);
            }
        }
        return success("删除成功");
    }
    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    public ObjEnvelop<VoluntaryRecruitmentPeopleDO> update (
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        VoluntaryRecruitmentPeopleDO appVersion = toEntity(jsonData, VoluntaryRecruitmentPeopleDO.class);
        if (null == appVersion.getId()) {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        appVersion = peopleService.save(appVersion);
        VoluntaryRecruitmentCompanyDO companyDO = companyDao.findOne(appVersion.getCompanyId());
        if (null !=companyDO ){
            Integer count = peopleService.getRepository().findByCompanyId(appVersion.getCompanyId());
            companyDO.setNum(count);
            companyDao.save(companyDO);
        }
        return success(appVersion, VoluntaryRecruitmentPeopleDO.class);
    }
    @GetMapping(value = "page")
    @ApiOperation(value = "获取分页")
    public PageEnvelop<VoluntaryRecruitmentPeopleDO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<VoluntaryRecruitmentPeopleDO> appVersions = peopleService.search(fields, filters, sorts, page, size);
        int count = (int)peopleService.getCount(filters);
        return success(appVersions, count, page, size, VoluntaryRecruitmentPeopleDO.class);
    }
    @GetMapping(value = "list")
    @ApiOperation(value = "获取列表")
    public ListEnvelop<VoluntaryRecruitmentPeopleDO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<VoluntaryRecruitmentPeopleDO> appVersions = peopleService.search(fields, filters, sorts);
        return success(appVersions, VoluntaryRecruitmentPeopleDO.class);
    }
}

+ 47 - 22
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/TemplateManageService.java

@ -2,12 +2,16 @@ package com.yihu.jw.base.service.dict;
import com.yihu.jw.base.dao.saas.SaasDao;
import com.yihu.jw.dict.dao.*;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.dict.*;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.xerces.dom.PSVIAttrNSImpl;
@ -41,6 +45,8 @@ public class TemplateManageService {
    private BaseOrgDao baseOrgDao;
    @Autowired
    private BaseFollowUpDictDao baseFollowUpDictDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    public MixEnvelop findTempalte(String templateType,String code,String name,String diseaseName,String diseaseId, Integer page ,Integer pageSize){
@ -906,38 +912,57 @@ public class TemplateManageService {
            return null;
        }
    }
    public List<Map<String,Object>> findTemplateByDisease(String diseaseId){
        String sql =" select t.id as \"id\" ," +
    public List<Map<String,Object>> findTemplateByDisease(String doctor,String diseaseId){
        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctor);
        String orgCode="";
        if (baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
            orgCode=baseDoctorHospitalDO.get(0).getOrgCode();
        }
        String sql =" select DISTINCT t.id as \"id\" ," +
                " t.name as \"name\"," +
                " t.code as \"code\"," +
                " t.children_count as \"childrenCount\"," +
                " t.update_user as \"updateUser\"," +
                " t.update_user_name as \"updateUserName\"," +
                " t.update_time as \"updateTime\"," +
                " t.disease_name as \"diseaseName\"," +
                " t.disease_id as \"diseaseId\"," +
                " t.template_type as \"templateType\"," +
                " t.is_del as \"isDel\" " +
                " from base_template t " +
                " where t.is_del='1' and t.template_type='followUpDict' ";
                " t.children_count as \"children_count\"," +
                " t.template_type as \"template_type\"," +
                " t.disease_id as \"disease_id\"," +
                " t.disease_name as \"disease_name\"," +
                " t.is_del as \"is_del\"," +
                " t.update_time as \"updateTime\" " +
                " from base_template_org m left join base_template t " +
                " on m.template_id=t.id " +
                " left join base_template_dict d on t.id = d.template_id " +
                " left join base_follow_up_dict f on f.id=d.dict_id " +
                " where t.is_del='1' and m.is_del='1' and d.is_del='1' and f.is_del='1'  and t.template_type='followUpDict' ";
        if (StringUtils.isNoneBlank(orgCode)){
            sql+=" and m.org_code='"+orgCode+"'";
        }
        if (StringUtils.isNoneBlank(diseaseId)){
            sql+=" and t.disease_id='"+diseaseId+"'";
        }
        System.out.println(sql);
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for (Map<String,Object> map:list){
            if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                map.put("statusName","生效中");
            }else {
                map.put("statusName","已失效");
            }
            if (map.get("disease_id")!=null){
            String sqlChild=" select  f.id as \"id\" ," +
                    " f.name as \"name\"," +
                    " f.code as \"code\"," +
                    " f.project_content as \"project_content\"," +
                    " f.status as \"status\"," +
                    " f.is_del as \"is_del\" " +
                    " from base_template t " +
                    " left join base_template_dict d on t.id = d.template_id " +
                    " left join base_follow_up_dict f on f.id=d.dict_id " +
                    " where t.is_del='1'  and d.is_del='1' and f.is_del='1'  and t.template_type='followUpDict' ";
            sqlChild+=" and t.id='"+map.get("id").toString()+"'";
            System.out.println("=="+sqlChild);
            map.put("childList",hibenateUtils.createSQLQuery(sqlChild));
            /*if (map.get("disease_id")!=null){
                String[] diseaseIds=map.get("disease_id").toString().split(",");
                for (int i=0;i<diseaseIds.length;i++){
                    if (diseaseIds[i].equalsIgnoreCase(diseaseId)){
                        resultList.add(map);
                    }
                }
            }
            }*/
        }
        return resultList;
        return list;
    }
}

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

@ -1016,6 +1016,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            baseDoctorDO.setEnabled(1);
            baseDoctorDO.setLocked(0);
            String salt = UUID.randomUUID().toString().substring(0,5);
            baseDoctorDO.setSalt(salt);
            String pw = one.getIdcard().substring(one.getIdcard().length()-6,one.getIdcard().length());
            baseDoctorDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            if(!StringUtils.isEmpty(one.getJobTitleName())){

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java

@ -238,6 +238,9 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
            if(StringUtils.isEmpty(mobile)){
                return "联系电话不能为空!";
            }
            if(mobile.length()!=11){
                return "联系电话格式错误!";
            }
            baseOrgDO.setOrgAdmin(adminName);
            baseOrgDO.setAdminMobile(mobile);
            baseOrgDao.save(baseOrgDO);

+ 12 - 12
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java

@ -37,20 +37,20 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
    public JSONObject create(ServicePackageItemDO itemDO){
        JSONObject result = new JSONObject();
         if(StringUtils.isEmpty(itemDO.getTeamCode())){
            result.put("msg","请选择服务团队");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
//         if(StringUtils.isEmpty(itemDO.getTeamCode())){
//            result.put("msg","请选择服务团队");
//            result.put("response", ConstantUtils.FAIL);
//            return result;
//        }
        BaseOrgDO baseOrgDO = baseOrgDao.findByCode(itemDO.getOrgCode());
        if (baseOrgDO!=null){
            itemDO.setOrgName(baseOrgDO.getName());
        }
        BaseTeamDO baseTeamDO  = baseTeamDao.findOne(itemDO.getTeamCode());
        if (baseTeamDO!=null){
            itemDO.setTeamName(baseTeamDO.getName());
        }
//        BaseTeamDO baseTeamDO  = baseTeamDao.findOne(itemDO.getTeamCode());
//        if (baseTeamDO!=null){
//            itemDO.setTeamName(baseTeamDO.getName());
//        }
        if(StringUtil.isEmpty(itemDO.getId())){
            SystemDictEntryDO systemDictEntryDO = systemDictEntryDao.findByDictCodeAndCode("service_item",itemDO.getCode());
            if (systemDictEntryDO!=null){
@ -83,9 +83,9 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
            oldItemDO.setCode(itemDO.getCode());
            oldItemDO.setFeeType(itemDO.getFeeType());
            oldItemDO.setIntroduce(itemDO.getIntroduce());
            oldItemDO.setOrgCode(itemDO.getOrgCode());
            oldItemDO.setOrgName(itemDO.getOrgName());
//            oldItemDO.setOrgCode(itemDO.getOrgCode());
//
//            oldItemDO.setOrgName(itemDO.getOrgName());
            oldItemDO.setTeamCode(itemDO.getTeamCode());
            oldItemDO.setTeamName(itemDO.getTeamName());
            servicePackageItemDao.save(oldItemDO);

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageService.java

@ -74,6 +74,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
            oldDO.setDel(servicePackageDO.getDel());
            oldDO.setType(servicePackageDO.getType());
            oldDO.setIntroduce(servicePackageDO.getIntroduce());
            oldDO.setOrgCode(servicePackageDO.getOrgCode());
            oldDO.setOrgName(servicePackageDO.getOrgName());
            servicePackageDO= servicePackageDao.save(oldDO);
            servicePackageItemDao.deleteByServicePackageId(oldDO.getId());
        }

+ 18 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentArrangeService.java

@ -0,0 +1,18 @@
package com.yihu.jw.base.service.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentArrangeDao;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentArrangeDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@Service
public class VoluntaryRecruitmentArrangeService extends BaseJpaService<VoluntaryRecruitmentArrangeDO, VoluntaryRecruitmentArrangeDao> {
    
}

+ 18 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentCompanyService.java

@ -0,0 +1,18 @@
package com.yihu.jw.base.service.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentCompanyDao;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@Service
public class VoluntaryRecruitmentCompanyService extends BaseJpaService<VoluntaryRecruitmentCompanyDO, VoluntaryRecruitmentCompanyDao> {
}

+ 18 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentPeopleService.java

@ -0,0 +1,18 @@
package com.yihu.jw.base.service.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentPeopleDao;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentPeopleDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@Service
public class VoluntaryRecruitmentPeopleService extends BaseJpaService<VoluntaryRecruitmentPeopleDO, VoluntaryRecruitmentPeopleDao> {
    
}

+ 154 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentService.java

@ -0,0 +1,154 @@
package com.yihu.jw.base.service.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentArrangeDao;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentCompanyDao;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentPeopleDao;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentArrangeDO;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentPeopleDO;
import com.yihu.jw.utils.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/1
 * @Description:
 */
@Service
public class VoluntaryRecruitmentService {
    @Autowired
    private VoluntaryRecruitmentCompanyDao companyDao;
    @Autowired
    private VoluntaryRecruitmentArrangeDao arrangeDao;
    @Autowired
    private VoluntaryRecruitmentPeopleDao peopleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 人员安排
     */
    public void arrange(String companyId,String day,String time,String peoples,String station){
        List<VoluntaryRecruitmentArrangeDO> arrangeDOs = new ArrayList<>();
        String people[] = peoples.split(",");
        for (String peo:people){
            String p[] = peo.split(":");
            VoluntaryRecruitmentArrangeDO arrangeDO = new VoluntaryRecruitmentArrangeDO();
            arrangeDO.setCompanyId(companyId);
            arrangeDO.setDay(day);
            arrangeDO.setPeopleId(p[0]);
            arrangeDO.setPeopleName(p[1]);
            arrangeDO.setStation(station);
            arrangeDO.setTime(time);
            arrangeDOs.add(arrangeDO);
        }
        arrangeDao.save(arrangeDOs);
    }
    /**
     * 企业人员安排信息
     */
    public List<Map<String,Object>> arrangeInfoList(String companyId){
        String sql = " select day,time,count(people_id) from voluntary_recruitment_arrange where company_id = '"+companyId+"' " +
                " group by day,time order by day,time asc ";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public List<VoluntaryRecruitmentArrangeDO> arrangeInfoDetail(String companyId,String day){
        String sql = "select ar.*,po.company_name,po.phone,po.idcard,po.vaccination,po.experience from " +
                " voluntary_recruitment_arrange ar  INNER JOIN voluntary_recruitment_people po on ar.people_id = po.id " +
                " where ar.company_id = '"+companyId+"' " ;
        if (StringUtils.isNoneBlank(day)){
            sql += " and ar.day = '"+day+"' ";
        }
        sql += " order by ar.day,ar.time asc ";
        List<VoluntaryRecruitmentArrangeDO> result = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(VoluntaryRecruitmentArrangeDO.class));
        return result;
    }
    public List<VoluntaryRecruitmentPeopleDO> companyPeopleUnArrange(String companyId,String day,String time){
        String sql =" select po.* from voluntary_recruitment_people po  LEFT JOIN voluntary_recruitment_arrange ar " +
                " on ar.people_id = po.id where ar.company_id = '"+companyId+"'  and ar.`day`='"+day+"' " +
                "  and ar.time<> '"+time+"' group by ar.day,ar.time order by ar.day,ar.time asc ";
        List<VoluntaryRecruitmentPeopleDO> result = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(VoluntaryRecruitmentPeopleDO.class));
      return result;
    }
    public VoluntaryRecruitmentCompanyDO findByContactsAndPhone(String contacts,String phone){
        List<VoluntaryRecruitmentCompanyDO> companyDOs = companyDao.findByContactsAndPhone(contacts,phone);
        if(companyDOs!=null&&companyDOs.size()>0){
            return companyDOs.get(0);
        }
        return null;
    }
    /**
     * 企业报名
     */
    public String add(VoluntaryRecruitmentCompanyDO companyDO){
        List<VoluntaryRecruitmentPeopleDO> peopleDOs = new ArrayList<>();
        if(StringUtil.isBlank(companyDO.getId())){
            if(companyDao.existsByName(companyDO.getName())){
                return "该企业已报名,请勿重复报名";
            }
            List<VoluntaryRecruitmentCompanyDO> companyDOs = companyDao.findByContactsAndPhone(companyDO.getContacts(),companyDO.getPhone());
            if(companyDOs!=null&&companyDOs.size()>0){
                return "该联系人已被其他企业添加";
            }
            List<VoluntaryRecruitmentPeopleDO> peopleDOList = companyDO.getPeopleDOList();
            if(peopleDOList!=null){
                addPeople(peopleDOList,peopleDOs,companyDO);
                return null;
            }
            return null;
        }
        List<VoluntaryRecruitmentPeopleDO> peopleDOList = companyDO.getPeopleDOList();
        if(peopleDOList==null){
            return "请添加人员";
        }
        addPeople(peopleDOList,peopleDOs,companyDO);
        return null;
    }
    public void addPeople(List<VoluntaryRecruitmentPeopleDO> peopleDOList,List<VoluntaryRecruitmentPeopleDO> peopleDOs,VoluntaryRecruitmentCompanyDO companyDO){
        if(!StringUtil.isBlank(companyDO.getId())){
            VoluntaryRecruitmentCompanyDO old = companyDao.findOne(companyDO.getId());
            companyDO = old;
        }else {
            companyDO.setNum(0);
            companyDao.save(companyDO);
        }
        for (VoluntaryRecruitmentPeopleDO peopleDO:peopleDOList){
            if(peopleDao.existsByPhone(peopleDO.getPhone())){
                continue;
            }
            peopleDO.setCompanyId(companyDO.getId());
            peopleDO.setCompanyName(companyDO.getName());
            peopleDOs.add(peopleDO);
        }
        if(peopleDOs.size()>0){
            peopleDao.save(peopleDOs);
        }
        companyDO.setNum(companyDO.getNum()+peopleDOs.size());
        companyDao.save(companyDO);
    }
}

+ 4 - 0
svr/svr-cloud-care/sql/init.sql

@ -13,3 +13,7 @@ INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb791c71820179644c4e7a0043', NULL, 'orderPayStatus', '5', '已退款', '', '5', NULL, '2021-05-13 13:56:33.018', '123', NULL, '2021-05-13 16:02:53.057', '123', NULL, '', '订单支付状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb797db4ce01797e3f387a0003', NULL, 'orderPayStatus', '6', '退款中', '', '6', NULL, '2021-05-18 14:52:23.034', '123', NULL, '2021-05-18 14:52:23.034', '123', NULL, '', '订单支付状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb797db4ce01797e4111060004', NULL, 'orderPayStatus', '7', '已取消', '', '7', NULL, '2021-05-18 14:54:24.006', '123', NULL, '2021-05-18 14:54:24.006', '123', NULL, '', '订单支付状态');
-- 2021-08-09
ALTER TABLE base.base_service_package add COLUMN `org_code` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '机构编码';
ALTER TABLE base.base_service_package add COLUMN `org_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '机构名称';

+ 34 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/NetworkCardConfig.java

@ -0,0 +1,34 @@
package com.yihu.jw.care.config;
import com.yihu.jw.util.date.DateUtil;
/**
 * Created by Bing on 2021/8/6.
 * 电信物联网卡
 */
public class NetworkCardConfig {
    //平台地址 https://ct.cmonelink.com/zh/#/infoPanel/index
    //user:BE5714630405 password:Zjxl2008@
    //文档地址https://ec.iot.10086.cn/ecology/supportService/documents
    public static final String appid="571AIOT2021072910102922281";
    public static final String password="OnXE@QFlwt9R";
    public static final String redisKey="dianXinAssesToken";
    public static final String groupId="9911000019160041";//所有卡号均在同一分组下方便维护
    //APPID+YYYYMMDDHHMISS+8位数字序列
    public static String getTransid() {
        return appid+ DateUtil.getNo(8);
    }
    public static final String getToken="https://api.iot.10086.cn/v5/ec/get/token";
    //获取语音白名单
    public static final String getPatientContacts="https://api.iot.10086.cn/v5/ec/query/member-voice-whitelist";
    //设置语音白名单 //同一卡号一分钟只能调用该接口一次 一个月仅能删除一次(一次最多删除2个号码)
    public static final String setPatientContacts="https://api.iot.10086.cn/v5/ec/config/member-voice-whitelist";
}

+ 1 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/assistance/EmergencyAssistanceDao.java

@ -18,4 +18,5 @@ public interface EmergencyAssistanceDao extends PagingAndSortingRepository<Emerg
    List<EmergencyAssistanceDO> findByPatientAndStatus(String patient,Integer status);
    List<EmergencyAssistanceDO> findByProxyPatientAndStatus(String proxyPatient,Integer status);
    List<EmergencyAssistanceDO> findBySessionId(String sessionId);
}

+ 21 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/booking/BaseBookingServiceDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.care.dao.booking;
import com.yihu.jw.entity.care.booking.BaseBookingServiceDo;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/***
 * @ClassName: BaseBookingServiceDao
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/12 10:23
 */
public interface BaseBookingServiceDao extends PagingAndSortingRepository<BaseBookingServiceDo,String>,
        JpaSpecificationExecutor<BaseBookingServiceDo> {
    @Query("select a from BaseBookingServiceDo a where a.patient = ?1 and a.status = '1'")
    BaseBookingServiceDo findByPatient(String patient);
}

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/contacts/PatientSosContactsDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.care.dao.contacts;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/8/10.
 */
public interface PatientSosContactsDao extends PagingAndSortingRepository<PatientSosContactsDO,Long>,
        JpaSpecificationExecutor<PatientSosContactsDO> {
    List<PatientSosContactsDO> findByPatientAndDel(String patient,Integer del);
    List<PatientSosContactsDO> findByPatientOrderByUpdateTimeDesc(String patient);
    PatientSosContactsDO findByPatientAndSosPhone(String patient,String sosPhone);
}

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

@ -14,6 +14,9 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    Iterable<DevicePatientDevice> findByUser(String user);
    @Query("select a from DevicePatientDevice a where a.del = 0 ")
    List<DevicePatientDevice> findByAll();
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    List<DevicePatientDevice> findByPatient(String user);

+ 16 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/BaseEmergencyWarnLogDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.security;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/8/9.
 */
public interface BaseEmergencyWarnLogDao extends PagingAndSortingRepository<BaseEmergencyWarnLogDO, Long>,
        JpaSpecificationExecutor<BaseEmergencyWarnLogDO> {
    List<BaseEmergencyWarnLogDO> findByOrderIdOrderByCreateTimeDesc(String oderId);
}

+ 1 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/SecurityMonitoringOrderDao.java

@ -28,4 +28,5 @@ public interface SecurityMonitoringOrderDao extends PagingAndSortingRepository<S
    void updateConclusionStatus2(String orderId);
    List<SecurityMonitoringOrderDO> findByPatientAndStatus(String patient,Integer status);
}

+ 17 - 15
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java

@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -279,21 +281,6 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "test")
    @ApiOperation(value = "患者发送快捷消息")
    @ObserverRequired
    public ObjEnvelop test(@ApiParam(name="doctor",value = "doctor",required =true )
                           @RequestParam(value = "doctor") String doctor,
                           @ApiParam(name="orderID",value = "orderID",required =true )
                           @RequestParam(value = "orderID") String orderID){
        try {
            return ObjEnvelop.getSuccess("发送成功",assistanceService.test(doctor, orderID));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping("responseOrder")
    @ApiOperation(value = "医生响应紧急预警(点击立即前往)")
    @ObserverRequired
@ -340,4 +327,19 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping("doctorSendMessageLog")
    @ApiOperation(value = "助老员紧急预警im发送消息日志")
    public ObjEnvelop doctorSendMessageLog(
            @ApiParam(name="doctor")@RequestParam(value = "doctor")String doctor,
            @ApiParam(name="type",value = "im会话对应type")@RequestParam(value = "type")String type,
            @ApiParam(name="message",value = "发送内容")@RequestParam(value = "message")String message,
            @ApiParam(name="session_id",value = "im会话对应id")@RequestParam(value = "session_id")String session_id){
        try {
            return ObjEnvelop.getSuccess("success",assistanceService.doctorSendMessageLog(doctor,type,session_id,message));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
}

+ 49 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/booking/BaseBookingServiceEndpoint.java

@ -0,0 +1,49 @@
package com.yihu.jw.care.endpoint.booking;
import com.yihu.jw.care.service.booking.BaseBookingServiceService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/***
 * @ClassName: BaseBookingServiceEndpoint
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/12 10:31
 */
@RestController
@RequestMapping("bookingService" )
@Api(tags = "预订服务弹框", description = "预订服务弹框")
public class BaseBookingServiceEndpoint  extends EnvelopRestEndpoint {
    @Autowired
    private BaseBookingServiceService serviceService;
    @ApiOperation("是否需要弹框")
    @GetMapping(value= "findByPatient")
    public Envelop findByPatient(@ApiParam(name = "patient", value = "patient", required = true) @RequestParam(value = "patient", required = true)String patient){
        return success("获取成功!",serviceService.findByPatient(patient));
    }
    @ApiOperation("保存,不在弹框")
    @GetMapping(value= "saveByPatient")
    public Envelop saveByPatient(@ApiParam(name = "patient", value = "patient", required = true) @RequestParam(value = "patient", required = true)String patient){
        try {
            serviceService.saveByPatient(patient);
            return success("保存成功!");
        }catch (Exception e){
            e.printStackTrace();
            return success("保存失败!");
        }
    }
}

+ 35 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java

@ -1,14 +1,17 @@
package com.yihu.jw.care.endpoint.device;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.util.CommonUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
@ -52,6 +55,8 @@ public class DoctorDeviceController extends BaseController {
	@Autowired
	private JmsTemplate jmsTemplate;
	@Autowired
	private ContactsService contactsService;
	private ObjectMapper  objectMapper=new ObjectMapper();
@ -116,4 +121,34 @@ public class DoctorDeviceController extends BaseController {
			return write(200, "获取设备成功!", "data",objects);
	}
	@RequestMapping(value ="updatePatientSosContacts",method = RequestMethod.POST)
	@ApiOperation(value = "设置居民紧急联系人")
	public String updatePatientSosContacts(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
										   @RequestParam(value = "patient", required = true) String patient,
										   @ApiParam(name="num",value = "成员配置的语音白名单号码 新增时只能传一个,删除时最多两个,用下划线隔开")
										   @RequestParam(value = "num")String num,
										   @ApiParam(name="operType",value = "1新增 4删除")
										   @RequestParam(value ="operType",required = true)Integer operType,
										   @ApiParam(name = "name", value = "联系人姓名")
										   @RequestParam(value = "name", required = false) String name,
										   @ApiParam(name = "relation", value = "与联系人关系,同base_patient_family_member")
										   @RequestParam(value = "relation", required = false) String relation){
		try {
			if (1!=operType&&4!=operType){
				return error(-1,"参数错误");
			}
			JSONObject result = contactsService.updatePatientSosContacts(patient,num,operType,name,relation);
			if (ResponseContant.success == result.getInteger(ResponseContant.resultFlag)){
				return success("修改成功");
			}
			else {
				return error(-1,result.getString(ResponseContant.resultMsg));
			}
		}catch (Exception e){
			return errorResult(e);
		}
	}
}

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java

@ -100,6 +100,9 @@ public class DoctorHealthController extends BaseController {
											  @RequestParam(value="pagesize",required = true) int pagesize) {
		try {
			JSONObject jsonObject = new JSONObject();
			if(StringUtils.isBlank(begin)){
				begin="2016-07-23 00:00:00";
			}
			if (type == 1) {
				List<Object> list = healthIndexService.findIndexByPatient2(patient, type, begin, end, page, pagesize);
				jsonObject.put("data",list);

+ 81 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/NetworkCardController.java

@ -0,0 +1,81 @@
package com.yihu.jw.care.endpoint.device;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.device.NetworkCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
 * Created by Bing on 2021/8/6.
 * 电信物联网卡
 */
@RestController
@RequestMapping("dianxin/card")
@Api(value = "电信物联网卡相关服务", description = "电信物联网卡相关服务")
public class NetworkCardController extends BaseController {
    @Autowired
    private NetworkCardService networkCardService;
    @ApiOperation("获取getAccessToken")
    @RequestMapping(value = "getAccessToken", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String getAccessToken(
            HttpServletRequest request) {
        try {
           networkCardService.getAccessToken();
            return write(200,"查询成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("获取物联网卡语音白名单手机号")
    @RequestMapping(value = "getPatientContacts", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String getPatientContacts(@ApiParam(name="msisdn",value = "",defaultValue = "14809011400")@RequestParam(value ="msisdn",required = false)String msisdn,
                                     @ApiParam(name="iccid",value = "")@RequestParam(value ="iccid",required = false)String iccid,
                                     @ApiParam(name="imsi",value = "")@RequestParam(value ="imsi",required = false)String imsi,
                                     @ApiParam(name="groupId",value = "默认所有卡号均在9911000019160041一个群组",defaultValue = "9911000019160041")@RequestParam(value ="groupId",required = true,defaultValue = "9911000019160041")String groupId) {
        try {
            //三个参数必须有且仅有一个
            if (StringUtils.isBlank(msisdn)&&StringUtils.isBlank(iccid)&&StringUtils.isBlank(imsi)){
                return error(-1,"参数错误");
            }
            return write(200,"查询成功","data",networkCardService.getPatientContacts(msisdn,iccid,imsi,groupId));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("设置物联网卡语音白名单手机号")
    @RequestMapping(value = "setPatientContacts", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String getPatientContacts(@ApiParam(name="msisdn",value = "",defaultValue = "14809011400")@RequestParam(value ="msisdn",required = false)String msisdn,
                                     @ApiParam(name="iccid",value = "")@RequestParam(value ="iccid",required = false)String iccid,
                                     @ApiParam(name="imsi",value = "")@RequestParam(value ="imsi",required = false)String imsi,
                                     @ApiParam(name="operType",value = "1新增 4删除")@RequestParam(value ="operType",required = true)String operType,
                                     @ApiParam(name="whiteNumber",value = "成员配置的语音白名单号码 新增时只能传一个,删除时最多两个 用下划线隔开 ")@RequestParam(value ="whiteNumber",required = true)String whiteNumber,
                                     @ApiParam(name="groupId",value = "默认所有卡号均在9911000019160041一个群组",defaultValue = "9911000019160041")@RequestParam(value ="groupId",required = true,defaultValue = "9911000019160041")String groupId) {
        try {
            //三个参数必须有且仅有一个
            if (StringUtils.isBlank(msisdn)&&StringUtils.isBlank(iccid)&&StringUtils.isBlank(imsi)){
                return error(-1,"参数错误");
            }
            return write(200,"查询成功","data",networkCardService.setPatientContacts(msisdn,iccid,imsi,operType,whiteNumber,groupId));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"error");
        }
    }
}

+ 19 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java

@ -1,8 +1,11 @@
package com.yihu.jw.care.endpoint.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
@ -12,6 +15,8 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -47,6 +52,8 @@ public class PadDeviceController extends BaseController {
    private ObjectMapper objectMapper = new ObjectMapper();
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private ContactsService contactsService;
    /**
     * 设备列表获取
     *
@ -149,4 +156,16 @@ public class PadDeviceController extends BaseController {
        }
    }
    @RequestMapping(value ="getPatientSosContacts",method = RequestMethod.GET)
    @ApiOperation(value = "获取居民紧急联系人")
    public String getPatientSosContacts(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                             @RequestParam(value = "patient", required = true) String patient){
        try {
            return write(200,"获取成功","detailModelList",contactsService.getPatientSosContacts(patient));
        }catch (Exception e){
            return errorResult(e);
        }
    }
}

+ 59 - 7
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -9,6 +9,7 @@ import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -170,7 +171,7 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "patientDeviceListByTopic", method = RequestMethod.GET)
    public String patientDeviceListByTopic(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                                @RequestParam(value = "patient", required = true) String patient,
                                                @ApiParam(name = "topic", value = "专题CODE;preventLost防走失,preventFall防跌倒", defaultValue = "preventLost")
                                                @ApiParam(name = "topic", value = "专题code,关联security_topic_dict字典", defaultValue = "preventLost")
                                                @RequestParam(value = "topic", required = false) String topic) {
        try {
            return write(200,"查询成功","detailModelList",  patientDeviceService.patientDeviceListByTopic(patient,topic));
@ -179,6 +180,17 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("紧急预警获取患者设备信息")
    @RequestMapping(value = "patientEmeDeviceList", method = RequestMethod.GET)
    public String patientEmeDeviceList(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                           @RequestParam(value = "patient", required = true) String patient) {
        try {
            return write(200,"查询成功","detailModelList",  patientDeviceService.patientEmeDeviceList(patient));
        } catch (Exception ex) {
            return errorResult(ex);
        }
    }
    /**
     * 设备删除
     */
@ -226,7 +238,7 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("修改删除 爱牵挂亲情号码")
    @ApiOperation("修改删除 爱牵挂亲情号码--未使用")
    @RequestMapping(value = "updAqgDeviceSosInfo",method = RequestMethod.POST)
    public String updAqgDeviceSosInfo(@ApiParam(name = "deviceSn",value = "设备id")
                                   @RequestParam(value = "deviceSn",required = true)String deviceSn,
@ -241,11 +253,12 @@ public class PatientDeviceController extends BaseController {
                                   @ApiParam(name = "clear",value = "删除标志,删除传1",required = false)
                                   @RequestParam(value = "clear",required = false)String clear){
        try {
            com.alibaba.fastjson.JSONObject json = patientDeviceService.updAqgDeviceSosInfo(deviceSn, seqid, name, num, dial_flag, clear);
            if(json.getBoolean("success")){
                return success("操作成功");
            }
            return error(-1,json.getString("error_desc"));
//            com.alibaba.fastjson.JSONObject json = patientDeviceService.updAqgDeviceSosInfo(deviceSn, seqid, name, num, dial_flag, clear);
//            if(json.getBoolean("success")){
//                return success("操作成功");
//            }
//            return error(-1,json.getString("error_desc"));
            return error(-1,"接口无效");
        }catch (Exception e){
            return errorResult(e);
        }
@ -291,4 +304,43 @@ public class PatientDeviceController extends BaseController {
            return errorResult(e);
        }
    }
    @ApiOperation("获取设备详情信息")
    @RequestMapping(value = "getPatientDeviceDetail",method = RequestMethod.GET)
    public String getPatientDeviceDetail(@ApiParam(name="patient")
                                         @RequestParam(value = "patient")String patient,
                                         @ApiParam(name="deviceSN")
                                         @RequestParam(value = "deviceSN")String deviceSn){
        try {
            JSONObject result = patientDeviceService.getPatientDeviceDetail(patient,deviceSn);
            if (result.getInt(ResponseContant.resultFlag)==ResponseContant.success){
                return write(200,"获取成功","data",result.getJSONObject(ResponseContant.resultMsg));
            }else {
                return error(-1,result.getString(ResponseContant.resultMsg));
            }
        }catch (Exception e){
            return errorResult(e);
        }
    }
    @ApiOperation("获取设备详情信息")
    @RequestMapping(value = "getPatientDeviceData",method = RequestMethod.GET)
    public String getPatientDeviceData(@ApiParam(name="patient")
                                       @RequestParam(value = "patient")String patient,
                                       @ApiParam(name="deviceSN")
                                       @RequestParam(value = "deviceSN")String deviceSn,
                                       @ApiParam(name="page")
                                       @RequestParam(value = "page")Integer page,
                                       @ApiParam(name="pageSize")
                                       @RequestParam(value = "pageSize")Integer pageSize){
        try {
            return write(200,"获取成功","data",patientDeviceService.getPatientDeviceData(patient,deviceSn,page,pageSize));
        }catch (Exception e){
            return errorResult(e);
        }
    }
}

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientHealthController.java

@ -410,6 +410,9 @@ public class PatientHealthController extends BaseController {
        try {
            JSONObject jsonObject = new JSONObject();
            if (StringUtils.isBlank(start)){
                start="2016-07-23 00:00:00";
            }
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
                jsonObject.put("data",list);

+ 6 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java

@ -238,12 +238,12 @@ public class DoctorBirthdayWishesEndpoint extends BaseController {
                    com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
                    String first = "助老员key1为您发送生日祝福,请点击查看。";
                    first = first.replace("key1",one.getDoctorName());
                    json.put("doctorName", one.getDoctorName());
                    json.put("toUser", patient);
                    json.put("name", tmp.get("name").toString());
                    json.put("content", one.getContent());
                    json.put("openid",tmp.get("openid").toString());
                    json.put("represented","");//被代理人
                    json.put("id", one.getId());
//                    json.put("toUser", patient);
//                    json.put("name", tmp.get("name").toString());
//                    json.put("content", one.getContent());
//                    json.put("openid",tmp.get("openid").toString());
//                    json.put("represented","");//被代理人
                    boolean success =  messageUtil.putTemplateWxMessage(wxId,"template_success_notice","srzf",tmp.get("openid").toString(),first,
                            null,one.getContent(),26,json,"已发送", DateUtil.dateToChineseTime(new Date()));
                    if (success){

+ 10 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -232,6 +232,16 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "/baseInfoCount")
    @ApiOperation(value = "医生首页服务数量获取")
    public ObjEnvelop baseInfoCount(@ApiParam(name="doctor")@RequestParam(value = "doctor")String doctor){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorService.baseInfoCount(doctor)) ;
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "/initEntranceData")
    @ApiOperation(value = "初始化新生儿未入学埋点数据")
    public Envelop initEntranceData(){

+ 4 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java

@ -179,14 +179,15 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "家庭成员查询")
    public ObjEnvelop getPatientFamilyMembers(@RequestParam(required = false) String patient,
                                              @RequestParam(required = false) String isContain,
                                              @RequestParam(required = false) Integer isContacts) {
                                              @RequestParam(required = false) Integer isContacts,
                                              @RequestParam(required = false) String archiveType) {
        try {
            JSONObject data = new JSONObject();
            JSONArray result = new JSONArray();
            if (StringUtils.isNotEmpty(patient)) {
                result = familyMemberService.getPatientMembers(patient, "", isContain,isContacts);
                result = familyMemberService.getPatientMembers(patient, "", isContain,isContacts,archiveType);
            } else  {
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",isContacts);
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",isContacts,archiveType);
            }
            data.put("normalmembers",result);//家人关系

+ 32 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java

@ -94,6 +94,38 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "infoCount")
    @ApiOperation(value = "查询工单数量")
    public ObjEnvelop infoCount(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient) {
        try {
            JSONObject allResult = lifeCareOrderService.queryInfoList(patient, null, 1, 5);
            if (allResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(allResult.getString(ResponseContant.resultMsg), -1);
            }
            int allCount = allResult.getIntValue(ResponseContant.count);
            JSONObject object = new JSONObject();
            object.put("allCount",allCount);
            JSONObject qxResult = lifeCareOrderService.queryInfoList(patient, -1, 1, 5);
            if (qxResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(qxResult.getString(ResponseContant.resultMsg), -1);
            }
            int qxCount = qxResult.getIntValue(ResponseContant.count);
            object.put("qxCount",qxCount);
            JSONObject wcResult = lifeCareOrderService.queryInfoList(patient, 2, 1, 5);
            if (wcResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(wcResult.getString(ResponseContant.resultMsg), -1);
            }
            int wcCount = wcResult.getIntValue(ResponseContant.count);
            object.put("wcCount",wcCount);
            return ObjEnvelop.getSuccess("查询成功",object);
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "findItemDict")
    @ApiOperation(value = "查找服务项字典")
    public ListEnvelop findItemDict() {

+ 39 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/OnlineContactEndpoint.java

@ -0,0 +1,39 @@
package com.yihu.jw.care.endpoint.patient;
import com.yihu.jw.care.service.patient.OnlineContactService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/***
 * @ClassName: OnlineContactEndpoint
 * @Description: 在线联系
 * @Auther: shi kejing
 * @Date: 2021/8/11 16:43
 */
@RestController
@RequestMapping("online" )
@Api(tags = "在线联系", description = "在线联系")
public class OnlineContactEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private OnlineContactService service;
    @GetMapping(value = "getOnLineObj")
    @ApiOperation(value = "获取在线联系")
    public Envelop getOnLineObj(
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient) {
        try{
            return success("获取成功",service.getOnLineObj(patient));
        }catch (Exception e){
            return failedException2(e);
        }
    }
}

+ 40 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientBirthdayWishesEndpoint.java

@ -0,0 +1,40 @@
package com.yihu.jw.care.endpoint.patient;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.birthday.BirthdayWishesService;
import com.yihu.jw.entity.care.birthday.BirthDayWishesToPatient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Bing on 2021/8/4.
 */
@RestController
@RequestMapping(value = "patient/birthday")
@Api(tags = "居民生日祝福", description = "居民生日祝福")
public class PatientBirthdayWishesEndpoint extends BaseController {
    @Autowired
    private BirthdayWishesService birthdayWishesService;
    @RequestMapping(value = "/getWishesById", method = RequestMethod.GET)
    @ApiOperation(value = "根据模板id获取祝福信息")
    public String getWishesById(@ApiParam(name = "id", value = "发送记录id")
                                  @RequestParam(required = true) Long id) {
        try {
            BirthDayWishesToPatient result = birthdayWishesService.getWishesById(id);
            if (null == result){
                return write(-1, "无对应祝福信息");
            }
            return write(200,"获取成功","data",result);
        } catch (Exception e) {
            return errorResult(e);
        }
    }
}

+ 15 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java

@ -57,12 +57,13 @@ public class PatientContactsEndpoint extends EnvelopRestEndpoint {
     * @return
     */
    @RequestMapping(value = "setPatientContacts", method = RequestMethod.POST)
    @ApiOperation(value = "设置一键联系人")
    @ApiOperation(value = "设置一键联系人--未使用")
    public Envelop setPatientContacts(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) String fid) {
        try {
            contactsService.setContacts(fid,patient);
            return ObjEnvelop.getSuccess("设置成功");
//            contactsService.setContacts(fid,patient);
//            return ObjEnvelop.getSuccess("设置成功");
            return Envelop.getError("接口无效");
        } catch (Exception e) {
            return failedException2(e);
        }
@ -129,4 +130,15 @@ public class PatientContactsEndpoint extends EnvelopRestEndpoint {
            return failedListEnvelopException2(e);
        }
    }
    @RequestMapping(value ="getPatientSosContacts",method = RequestMethod.GET)
    @ApiOperation(value = "获取居民紧急联系人")
    public ListEnvelop getPatientSosContacts(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                                 @RequestParam(value = "patient", required = true) String patient){
        try {
            return ListEnvelop.getSuccess("获取成功",contactsService.getPatientSosContacts(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -41,7 +41,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "testException")
    @ApiOperation(value = "测试异常")
    public String testException2(String type) throws Exception {
//        patientService.intiPatient();
        if("1".equals(type)){
            throw new NullPointerException();
        }else if("2".equals(type)){
@ -51,7 +51,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
        return "获取成功";
    }
    @RequestMapping(value = "testRedisLock")
    @GetMapping(value = "testRedisLock")
    @RedisLock(key = "#patientDO.id")
    public Envelop testRedisLock(BasePatientDO patientDO) {
        try {

+ 36 - 9
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java

@ -38,7 +38,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
                               @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource,
                               @ApiParam(name="warnStr",value = "紧急预警弹框字段")
                               @RequestParam(value = "warnStr",defaultValue = "疑似离开安全区域",required = false) String warnStr){
        try {
        try {//服务描述关联security_server_dict字典
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource,warnStr);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
@ -59,9 +59,11 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
                                            @RequestParam(value = "patientName",required = false)String patientName,
                                            @ApiParam(name="patient",value = "patient")
                                            @RequestParam(value = "patient",required = false)String patient,
                                            @ApiParam(name="status",value = "工单状态-1已取消1待处置2前往居民定位3已签到4已登记小结5待补录6待评价7已完成")
                                            @ApiParam(name="status",value = "工单状态-2误报警-1已取消0已完成1申请中")
                                            @RequestParam(value = "status",required = false)String status,
                                            @ApiParam(name = "topicItem", value = "专题code,security安防相关专题", required = false)
                                            @ApiParam(name="svrDesc",value = "服务类型 关联security_server_dict字典")
                                            @RequestParam(value = "svrDesc",required = false)String svrDesc,
                                            @ApiParam(name = "topicItem", value = "专题CODE;关联security_topic_dict字典", required = false)
                                            @RequestParam(value = "topicItem",required = false) String topicItem,
                                            @ApiParam(name="page",value = "page",required = true)
                                            @RequestParam(value = "page")Integer page,
@ -70,12 +72,37 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        try {
            page = page>1?page-1:0;
            return securityMonitoringOrderService.getSecurityOrderList(doctor,serverDoctor,patientName, patient, status, topicItem,page, pageSize);
            return securityMonitoringOrderService.getSecurityOrderList(doctor,serverDoctor,patientName, patient, status, svrDesc,topicItem,page, pageSize);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getSecurityTab")
    @ApiOperation(value = "获取安防tab数量")
    public ObjEnvelop getSecurityTab(@ApiParam(name="patient",value = "患者")
                                     @RequestParam(value = "patient",required = false) String patient,
                                     @ApiParam(name="doctor",value = "医生")
                                     @RequestParam(value = "doctor",required = false) String doctor,
                                     @ApiParam(name="status",value = "工单状态-2误报警-1已取消0已完成1申请中")
                                     @RequestParam(value = "status",required = false)String status,
                                     @ApiParam(name="svrDesc",value = "服务类型 关联security_server_dict字典")
                                     @RequestParam(value = "svrDesc",required = false)String svrDesc,
                                     @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)
                                     @RequestParam(value = "topicItem",required = false) String topicItem){
        try {
            if (org.apache.commons.lang3.StringUtils.isBlank(patient)&& org.apache.commons.lang3.StringUtils.isBlank(doctor)){
                return ObjEnvelop.getError("请求参数错误");
            }
            if (org.apache.commons.lang3.StringUtils.isNotBlank(patient)&& org.apache.commons.lang3.StringUtils.isNotBlank(doctor)){
                return ObjEnvelop.getError("请求参数错误");
            }
            return ObjEnvelop.getSuccess("查询成功",securityMonitoringOrderService.getSecurityTab(patient,doctor,status,svrDesc,topicItem));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getSecurityOrderUnCompleteList")
    @ApiOperation(value = "获取服务医生下未结束的安防工单")
    public ListEnvelop getSecurityOrderUnCompleteList(@ApiParam(name="doctor",value = "医生ID,当前查看列表医生",required = true)
@ -90,7 +117,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getSecurityOrderDetail")
    @ApiOperation(value = "获取安防工单详情")//
    @ApiOperation(value = "获取安防工单详情")
    public ObjEnvelop getSecurityOrderDetail(@ApiParam(name="orderId",value = "orderId",required = true)
                                            @RequestParam(value = "orderId")String orderId,
                                             @ApiParam(name="doctor",value = "doctor",required = false)
@ -278,10 +305,10 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "getSecurityServerDoctor")
    @ApiOperation(value = "获取安防监护服务人员")//
    @ApiOperation(value = "获取安防监护服务人员")
    public ListEnvelop getSecurityServerDoctor(@ApiParam(name="patient",value = "patient",required = true)
                                             @RequestParam(value = "patient")String patient,
                                             @ApiParam(name = "topicItem", value = "专题code,security安防相关专题", required = false)
                                             @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)
                                             @RequestParam(value = "topicItem",required = false,defaultValue = "preventLost") String topicItem){
        try {
@ -296,8 +323,8 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @ResponseBody
    public ObjEnvelop patientMonitoringInfo(@ApiParam(name = "patient", value = "patient")
                                @RequestParam(value = "patient") String patient,
                                @ApiParam(name = "topicItem", value = "专题code,security安防相关专题", required = false)
                                @RequestParam(value = "topicItem",required = false,defaultValue = "preventLost") String topicItem) {
                                @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)
                                @RequestParam(value = "topicItem",required = false) String topicItem) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.patientMonitoringInfo(patient,topicItem));
        } catch (Exception e) {

+ 56 - 21
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -67,7 +67,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findSignDoctor")
    @ApiOperation(value = "查找签约医生")
    public ListEnvelop findSignDoctor (
            @ApiParam(name = "patient", value = "医生code", required = true)
            @ApiParam(name = "patient", value = "居民code", required = true)
            @RequestParam(value = "patient",required = true) String patient,
            @ApiParam(name = "orgCode", value = "医院code", required = false)
            @RequestParam(value = "orgCode",required = false) String orgCode) throws Exception {
@ -192,6 +192,30 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findPatientSignList")
    @ApiOperation(value = "获取签约服务包记录")
    public ListEnvelop findPatientSignList (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient) throws Exception {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findPatientSignList(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "signPackageDetail")
    @ApiOperation(value = "获取签约服务包记录详情")
    public ObjEnvelop signPackageDetail (
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.signPackageDetail(id));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "servicePackageSign")
    @ApiOperation(value = "分配服务包-签约")
    @ObserverRequired
@ -200,32 +224,47 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @RequestParam String jsonData,
            @ApiParam(name = "patientId", value = "居民id", required = true)
            @RequestParam String patientId,
            @ApiParam(name = "signYear", value = "签约时长 0长期 1 1年 2 2年", required = true)
            @RequestParam String signYear,
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
        try{
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId);
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId,signYear);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg));
            }
            servicePackageService.setPatientServiceItems(result.getJSONObject("resultMsg").getString("patient"));
            return Envelop.getSuccess("分配成功");
            return Envelop.getSuccess("签约成功");
        }catch (Exception e){
            if (e.getMessage().contains("重复签约服务项目")){
                return failed("分配失败,"+e.getMessage(),-1);
                return failed("签约失败,"+e.getMessage(),-1);
            }
            return failedException2(e);
        }
    }
    @GetMapping(value = "findServicePackageByOrgCode")
    @ApiOperation(value = "获取服务包")
    public ListEnvelop<List<Map<String,Object>>> findServicePackageByOrgCode (
            @ApiParam(name = "orgCode", value = "机构code", required = false)
            @RequestParam(value = "orgCode",required = false)  String orgCode) {
        try{
            return ListEnvelop.getSuccess("获取成功",servicePackageService.findServicePackageByOrgCode(orgCode));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "servicePackagePage")
    @ApiOperation(value = "获取服务包分页")
    public PageEnvelop<List<Map<String,Object>>> servicePackagePage (
            @ApiParam(name = "orgCode", value = "机构code", required = false)
            @RequestParam(value = "orgCode",required = false)  String orgCode,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        try{
            return servicePackageService.servicePackagePage(page, size);
            return servicePackageService.servicePackagePage(page, size,orgCode);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -269,8 +308,6 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "status",required = false) Integer status,
            @ApiParam(name = "levelConclusion", value = "评估结果/等级结论", required = false)
            @RequestParam(value = "levelConclusion",required = false) Integer levelConclusion,
            @ApiParam(name = "servicePackageStatus", value = "服务包分配(0未分配,1已分配)", required = false)
            @RequestParam(value = "servicePackageStatus",required = false) Integer servicePackageStatus,
            @ApiParam(name = "type", value = "type 0当年 1全部", required = false)
            @RequestParam(value = "type",required = false,defaultValue = "0") Integer type,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
@ -278,7 +315,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        try{
            return capacityAssessmentRecordService.assessmentPage(doctorId,patientId, name, type,page, size, status, levelConclusion, servicePackageStatus);
            return capacityAssessmentRecordService.assessmentPage(doctorId,patientId, name, type,page, size, status, levelConclusion);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -503,18 +540,6 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value="getServerDoctorByPackage")
    @ApiOperation(value = "根据服务包,服务项目获取对应的服务医生")
    public ListEnvelop getServerDoctorByPackage(@ApiParam(name="packageId",value = "服务包id",required = true)
                       @RequestParam(value = "packageId")String packageId,
                       @ApiParam(name="serverItem",value = "服务项目code",required = true)
                       @RequestParam(value = "serverItem")String serverItem){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.getServerDoctorByPackage(packageId,serverItem));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value="getServerDoctorAll")
    @ApiOperation(value = "获取所有服务医生")
@ -562,4 +587,14 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value="signPackageDoctorList")
    @ApiOperation(value = "签约服务包医生列表")
    public ListEnvelop signPackageDoctorList(@ApiParam(name="pateint",value = "姓名或身份证",required = true)
                                      @RequestParam(value = "pateint",required = true)String pateint){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.signPackageDoctorList(pateint));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

+ 89 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -1,11 +1,15 @@
package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.doctor.CareDoctorService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.care.service.statistics.StatisticsService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -16,6 +20,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
@ -32,6 +39,12 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    private StatisticsService statisticsService;
    @Autowired
    private CarePatientService patientService;
    @Autowired
    private CareDoctorService doctorService;
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @Autowired
    private EmergencyAssistanceService emergencyAssistanceService;
    @GetMapping(value = "statisticsTotalAmount")
    @ApiOperation(value = "统计总数")
@ -45,6 +58,28 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "serviceResources")
    @ApiOperation(value = "服务资源v0.7.0")
    public ObjEnvelop ServiceResources() {
        try {
            JSONObject result = statisticsService.serviceResources();
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "realTimeDataNew")
    @ApiOperation(value = "实时数据v0.7.0")
    public ObjEnvelop realTimeDataNew() {
        try {
            JSONObject result = statisticsService.realTimeDataNew();
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "serviceRankingAnalysis")
    @ApiOperation(value = "服务排名分析")
    public ListEnvelop serviceRankingAnalysis(
@ -56,6 +91,17 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "fingLoginLog")
    @ApiOperation(value = "获取登录记录")
    public PageEnvelop fingLoginLog(
            @RequestParam(required = true) Integer page,@RequestParam(required = true) Integer size) {
        try {
            return statisticsService.fingLoginLog(page,size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "realTimeData")
    @ApiOperation(value = "大屏实时数据")
    public ObjEnvelop realTimeData() {
@ -96,4 +142,47 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
            return failedException2(e);
        }
    }
    @GetMapping(value = "doctorInfo")
    @ApiOperation(value = "获取医生详情")
    public ObjEnvelop doctorInfo (
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam(value = "doctorId",required = true) String doctorId) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",doctorService.doctorSimpleInfo(doctorId));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getDoctorOrderList")
    @ApiOperation("获取医生生活照料列表")
    public ObjEnvelop getDoctorOrderList(@ApiParam(name="doctor",value = "医生id",required = true)
                                      @RequestParam(value = "doctor")String doctor,
                                      @ApiParam(name="page",value="page")
                                      @RequestParam(name = "page")Integer page,
                                      @ApiParam(name="size",value="size")
                                      @RequestParam(name = "size")Integer size){
        try {
            return ObjEnvelop.getSuccess("查询成功",lifeCareOrderService.getDoctorOrderList(doctor,page,size));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getEmergencyAssistanceList")
    @ApiOperation(value = "紧急救助列表")
    public PageEnvelop getEmergencyAssistanceList(@ApiParam(name="doctor",value = "医生id",required = true)
                                                     @RequestParam(value = "doctor")String doctor,
                                                 @ApiParam(name="page",value = "page")
                                                 @RequestParam(value = "page") Integer page,
                                                 @ApiParam(name="size",value = "size")
                                                 @RequestParam(value = "size") Integer size){
        try {
            return emergencyAssistanceService.getEmergencyAssistanceList(page,size,doctor);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
}

+ 42 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -268,6 +268,48 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getEmergencyWarnOrderListNew")
    @ApiOperation(value = "安防监测列表 v0.7.0")//        疑似离开安全区域+疑似跌倒
    public PageEnvelop getEmergencyWarnOrderListNew(@ApiParam(name="page",value = "page")
                                                 @RequestParam(value = "page") Integer page,
                                                 @ApiParam(name="pageSize",value = "pageSize")
                                                 @RequestParam(value = "pageSize") Integer pageSize
    ){
        try {
            return patientInfoPlatFormService.getEmergencyWarnOrderListNew(page,pageSize);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getEmergencyWarningListNew")
    @ApiOperation(value = "紧急预警列表 v0.7.0")//        发起紧急救助
    public PageEnvelop getEmergencyWarningListNew(@ApiParam(name="page",value = "page")
                                                    @RequestParam(value = "page") Integer page,
                                                    @ApiParam(name="pageSize",value = "pageSize")
                                                    @RequestParam(value = "pageSize") Integer pageSize
    ){
        try {
            return patientInfoPlatFormService.getEmergencyWarningListNew(page,pageSize);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getHealthMonitoringListNew")
    @ApiOperation(value = "健康监测列表 v0.7.0")//        血糖+血压
    public PageEnvelop getHealthMonitoringListNew(@ApiParam(name="page",value = "page")
                                                  @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="pageSize",value = "pageSize")
                                                  @RequestParam(value = "pageSize") Integer pageSize
    ){
        try {
            return patientInfoPlatFormService.getHealthMonitoringListNew(page,pageSize);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @ApiOperation("查询字典")
    @GetMapping(value= "findDict")
    public MixEnvelop findDict(@ApiParam(name = "name", value = "name", required = false)

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/securrity/SecuMonOrderEndpoint.java

@ -34,7 +34,7 @@ public class SecuMonOrderEndpoint extends EnvelopRestEndpoint {
                                  @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource,
                                  @ApiParam(name="warnStr",value = "紧急预警弹框字段")
                                  @RequestParam(value = "warnStr",defaultValue = "疑似离开安全区域",required = false) String warnStr){
        try {
        try {//服务描述关联security_server_dict字典
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource,warnStr);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));

+ 110 - 42
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -6,12 +6,15 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.assistance.EmergencyAssistanceDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
import com.yihu.jw.care.dao.security.EmergencyWarnConclusionDao;
import com.yihu.jw.care.dao.security.EmergencyWarnDoctorResponseDao;
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.util.ConstantUtil;
@ -22,9 +25,12 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnDoctorResponseDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
@ -33,7 +39,9 @@ import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.emergency.EmergencyOrderVO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
@ -95,7 +103,10 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    private ConsultDao consultDao;
    @Autowired
    private DictService dictService;
    @Autowired
    private BaseEmergencyWarnLogDao logDao;
    @Autowired
    private ContactsService contactsService;
    /**
     * 新建居民紧急救助
@ -113,6 +124,12 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        if (emergencyAssistanceDao.findByPatientAndStatus(patient,EmergencyAssistanceDO.Status.apply.getType()).size()>0){
            String failMsg = "当前居民存在发起中工单,请完成后再申请";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        assistanceDO.setOrderSource(orderSource);
        assistanceDO.setStatus(1);
        assistanceDO.setPatient(patient);
@ -172,22 +189,6 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        //获取距离患者最近的一个医生(默认直线距离最近的医生)
//        double distance = 0.0;
//        for (BaseDoctorDO doctorDO:doctorDOS){
//            if (StringUtils.isBlank(doctorDO.getDoctorLat())||StringUtils.isBlank(doctorDO.getDoctorLon())){
//                continue;
//            }
//            double distanceTmp = countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(doctorDO.getDoctorLat()),Double.parseDouble(doctorDO.getDoctorLon()));
//            if (distanceTmp>distance){
//                distance = distanceTmp;
//                assistanceDO.setDoctor(doctorDO.getId());
//                assistanceDO.setDoctorName(doctorDO.getName());
//                assistanceDO.setDoctorAddress(doctorDO.getDoctorLocateAddress());
//                assistanceDO.setDoctorLon(doctorDO.getDoctorLon());
//                assistanceDO.setDoctorLat(doctorDO.getDoctorLat());
//            }
//        }
        assistanceDO = emergencyAssistanceDao.save(assistanceDO);
        //创建im会话  紧急救助咨询的sessionid  为居民code+(wlyy_consult_team表consult)+20
        JSONObject IMObj = consultTeamService.addServiceConsult(assistanceDO.getId(),patient,proxyPatient,null);
@ -272,7 +273,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            case -2:statusName="误警报";break;
            case -1:statusName="已取消";break;
            case 0:statusName="已完成";break;
            case 1:statusName="申请中";break;
            case 1:statusName="预警中";break;
        }
        emergencyOrderVO.setStatusName(statusName);
        emergencyOrderVO.setOrderId(orderID);
@ -286,6 +287,16 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        emergencyOrderVO.setSex(patientDO.getSex());
        emergencyOrderVO.setPhone(assistanceDO.getPatientPhone());
        List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(assistanceDO.getId());
        for (BaseEmergencyWarnLogDO tmp:logDOS){
            tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime(),0));
        }
        emergencyOrderVO.setOrderLogInfo(logDOS);
        List<PatientSosContactsDO> contactsDOS = contactsService.getPatientSosContacts(assistanceDO.getPatient());
        emergencyOrderVO.setSosContacts(contactsDOS);
        List<Map<String,Object>> securityDevices = patientDeviceService.patientEmeDeviceList(assistanceDO.getPatient());
        emergencyOrderVO.setSecurityDevices(securityDevices);
        if(StringUtils.isNotBlank(patientDO.getIdcard())){
            emergencyOrderVO.setAge((IdCardUtil.getAgeForIdcard(patientDO.getIdcard()))+"");
        }
@ -313,7 +324,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        //附加信息 紧急救助无
        //通知对象
        List<Map<String,Object>> noticePersons = new ArrayList<>();
        JSONArray familyArr =  familyMemberService.getPatientMembers(assistanceDO.getPatient(),null,null,null);
        JSONArray familyArr =  familyMemberService.getPatientMembers(assistanceDO.getPatient(),null,null,null,null);
        String emeCallPhone = "";
        if (assistanceDO.getOrderSource()!=1){//设备发起工单
            String category = assistanceDO.getOrderSource()==2?"4":"7";
@ -534,7 +545,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        tmpObj.put("status_-2",0);//误报警
        tmpObj.put("status_-1",0);//已取消
        tmpObj.put("status_0",0);//已完成
        tmpObj.put("status_1",0);//申请中
        tmpObj.put("status_1",0);//预警中
        StringBuilder sql = new StringBuilder(" select ord.status,count(ord.id) count from base_emergency_assistance_order ord where 1=1") ;
        if (StringUtils.isNotBlank(patient)){
            sql.append( " and (ord.patient='"+patient+"' or ord.proxy_patient='"+patient+"' ) group by ord.status  ");
@ -543,7 +554,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            sql.append(" AND EXISTS (" +
                    "SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = i.team_code " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                    " and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') group by ord.status");
        }
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
@ -593,7 +604,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            sql.append(" AND EXISTS (" +
                    "SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = i.team_code " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                    " and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ");
        }
        if (StringUtils.isNotBlank(patient)){
@ -621,7 +632,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            sql.append(" AND EXISTS (" +
                    "SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = i.team_code " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                    " and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ");
        }
        if (StringUtils.isNotBlank(patient)){
@ -839,6 +850,18 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            responseDO.setDoctor(doctor);
            responseDO.setResponseTime(new Date());
            emergencyWarnDoctorResponseDao.save(responseDO);
            BaseDoctorDO doctorDO = doctorDao.findById(doctor);
            if (null!=doctorDO){
                BaseEmergencyWarnLogDO logDO = new BaseEmergencyWarnLogDO();
                logDO.setUserCode(doctor);
                logDO.setUserName(doctorDO.getName());
                logDO.setOrderId(orderId);
                logDO.setUserType(2);
                logDO.setCreateTime(new Date());
                logDO.setContent("前往定位");
                logDao.save(logDO);
            }
        }
        result.put("resultFlag", 1);
@ -915,27 +938,72 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        return null;
    }
    public String test(String doctor,String orderID){
//        JSONObject message = new JSONObject();
//        message.put("session_id","808080eb78b5d8e90178b5fcfa330001_4028030c78f1df510178f217a6c50001_20");
//        message.put("sender_name","一一");
//        message.put("sender_code","808080eb78b5d8e90178b5fcfa330001");
//        message.put("order_id","4028030c78f1df510178f217a6a70000");
//        message.put("content_type",40);
//        imUtill.sendMDTSocketMessageToDoctor(doctor,message.toString());
    public JSONObject getDoctorOrderList(String doctor, int page, int size) {
        page = page>0?page-1:0;
        String sqlCount = "select count(ord.id) from  base_life_care_order ord where ord.doctor = '"+doctor+"' ";
        String sql = "select ord.id,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') createTime,DATE_FORMAT(ord.patient_expected_serve_time,'%Y-%m-%d %H:%i:%S') serveTime,ord.status,ord.hospital,ord.hospital_name hospitalName" +
                ",ord.doctor,ord.doctor_name doctorName,ord.expected_doctor_name expectedDoctorName,group_concat(Distinct fee.name SEPARATOR '、') serveItems" +
                " from base_emergency_assistance_order ord LEFT JOIN base_life_care_fee_detail fee on ord.id = fee.order_id " +
                "and fee.`status`<>3 where ord.doctor = '"+doctor+"' and ord.status<>0  ";
        String fliter = " and ord.status =2 ";
        Long count = jdbcTemplate.queryForObject(sqlCount+fliter,Long.class);
        fliter += " group by ord.id order by ord.create_time desc limit "+page*size+","+size;
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql+fliter);
        JSONObject object = new JSONObject();
        object.put("total",count);
        object.put("detailModelList",result);
        object.put("currPage",page);
        object.put("pageSize",size);
        return object;
    }
        //结束救助咨询
        String sql = "select id from base_emergency_assistance_order where status!=1";
        List<String> ids = jdbcTemplate.queryForList(sql,String.class);
        for (String id:ids){
            EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderID);
            if (!consultTeamService.finishConsult(assistanceDO.getId(),assistanceDO.getPatient(),doctor,2)){
                String failMsg = "咨询结束失败 无法完成工单";
                return failMsg;
    /**
     * 紧急救助列表
     * @param page
     * @param size
     * @return
     */
    public PageEnvelop getEmergencyAssistanceList(Integer page, Integer size,String doctor){
        page = page>0?page-1:0;
        String sql = " select '20' as OrderType,ord.id,ord.doctor,ord.status,p.name,'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time" +
                " from base_emergency_assistance_order ord INNER JOIN base_doctor p on ord.doctor = p.id where ord.doctor='"+doctor+"'" ;
        sql +="UNION " +
                "select  '22' as 'OrderType',ord.id,ord.doctor,ord.status,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_security_monitoring_order ord INNER JOIN base_doctor p on ord.doctor = p.id  where ord.doctor='"+doctor+"'" ;
        String countSql = "select count(id) from ("+sql+")A ";
        long count = jdbcTemplate.queryForObject(countSql,long.class);
        sql +=" order by create_time desc limit "+page*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    public BaseEmergencyWarnLogDO doctorSendMessageLog(String doctor,String type,String session_id,String message){
        BaseEmergencyWarnLogDO logDO = new BaseEmergencyWarnLogDO();
        BaseDoctorDO doctorDO = doctorDao.findById(doctor);
        if (null!=doctorDO){
            if ("20".equals(type)){//紧急
                List<EmergencyAssistanceDO> orderDOS = emergencyAssistanceDao.findBySessionId(session_id);
                if (orderDOS.size()>0){
                    logDO.setOrderId(orderDOS.get(0).getId());
                }
            }else if ("22".equals(type)){//安防
                String[]str  = session_id.split("_");
                ConsultTeamDo consultTeam = consultTeamDao.findByConsult(str[1]);
                if (null!=consultTeam){
                    logDO.setOrderId(consultTeam.getRelationCode());
                }
            }
            if (StringUtils.isNotBlank(logDO.getOrderId())){
                logDO.setUserCode(doctor);
                logDO.setUserName(doctorDO.getName());
                logDO.setUserType(2);
                logDO.setContent("发送消息\""+message+"\"");
                logDO.setCreateTime(new Date());
                logDao.save(logDO);
            }
        }
        return null;
        return logDO;
    }
}

+ 29 - 12
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java

@ -172,7 +172,7 @@ public class BirthdayWishesService {
        //获取当天0点
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        String now = f.format(new Date());
        String sql = "SELECT p.id patient, p.`name`, " +
        String sql = "SELECT DISTINCT p.id patient, p.`name`, " +
                "CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END sex," +
                "p.idcard, p.photo," +
                " CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END date " +
@ -180,18 +180,23 @@ public class BirthdayWishesService {
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = '"+doctor+"' ) "+
                "and i.del = 1 and m.team_code = r.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "' " ;
        List<Map<String, Object>> patientInfos =  jdbcTemplate.queryForList(sql);
        //整理未发送居民信息
        for(Map<String, Object> map : patientInfos){
            if (sendPatients == null || !sendPatients.contains(map.get("patient"))) {
        Iterator<Map<String, Object>> iterator = patientInfos.iterator();
        while (iterator.hasNext()){
            Map<String, Object> map = iterator.next();
            if (sendPatients == null || !sendPatients.contains(map.get("patient").toString())) {
                int age = IdCardUtil.getAgeForIdcard(map.get("idcard") + "");
                Date birthday = IdCardUtil.getBirthdayForIdcard(map.get("idcard") + "");
                map.put("age", age);
                map.put("birthday", DateUtil.dateToStr(birthday, "yyyy-MM-dd"));
            }
            else {
                iterator.remove();
            }
        }
        return patientInfos;
    }
@ -216,17 +221,21 @@ public class BirthdayWishesService {
        //获取当天0点
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        String now = f.format(new Date());
        String sql = "SELECT COUNT(DISTINCT p.id) " +
        String sql = "SELECT DISTINCT p.id " +
                "from wlyy_archive a,base_patient p WHERE  a.patient = p.id and a.sign_status = 1 and EXISTS( " +
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = '"+doctor+"' ) "+
                "and i.del = 1 and m.team_code = r.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "'  " ;
        List<String> patientInfos =  jdbcTemplate.queryForList(sql,String.class);
        Integer count=0;
        for (String tmp:patientInfos){
            if (null == sendPatients){
                count = patientInfos.size();
                break;
            }
            if (!sendPatients.contains(tmp)){
                count++;
            }
@ -252,7 +261,7 @@ public class BirthdayWishesService {
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code ";
                "and i.del = 1 and m.team_code = r.team_code ";
        //根据权限获取生日居民列表
        if (roleType == 1) {
@ -329,8 +338,12 @@ public class BirthdayWishesService {
                            map.put("birthday", esMap.get("birthday") + "");
                            map.put("doctorName", esMap.get("doctorName") + "");
                            map.put("content", esMap.get("content") + "");
                            map.put("createTime", (esMap.get("createTime") + "").replace("T", " ").replace("+0800", ""));
                            map.put("createTimeStr", (esMap.get("createTime") + "").replace("T", " ").replace("+0800", ""));
                            Date dateTmp = DateUtil.strToDate(esMap.get("createTime") + "");
                            map.put("createTime", (DateUtil.dateToChineseDate(dateTmp)));
                            map.put("status", "已发送");
                            BasePatientDO patientDO = patientDao.findById(map.get("patient") + "");
                            map.put("patientBirthday", IdCardUtil.getBirthdayForIdcardStr(patientDO.getIdcard()));
                            patientSet.add(patientCode);
                            resultList.add(map);
                        }
@ -345,11 +358,10 @@ public class BirthdayWishesService {
                        String birthday = map.get("birthday")+"日";
                        StringBuilder bir = new StringBuilder(birthday);
                        bir.insert(2, "月");
//                            int age = IdCardUtil.getAgeForIdcard(map.get("idcard") + "");
                        map.put("birthday", bir.toString());
//                        int age = IdCardUtil.getAgeForIdcard(map.get("idcard") + "");
//                        map.put("age", age);
                        map.put("status", "未发送");
                        BasePatientDO patientDO = patientDao.findById(map.get("patient") + "");
                        map.put("patientBirthday", IdCardUtil.getBirthdayForIdcardStr(patientDO.getIdcard()));
                        resultList.add(map);
                    }
                }
@ -474,7 +486,7 @@ public class BirthdayWishesService {
//            System.out.println("ES保存成功!");
            //将发送生日祝福的居民code存起来
            Calendar today = Calendar.getInstance();
            today.set(Calendar.HOUR, 23);
            today.set(Calendar.HOUR_OF_DAY, 23);
            today.set(Calendar.MINUTE, 59);
            today.set(Calendar.SECOND, 59);
            today.set(Calendar.MILLISECOND, 999);
@ -500,4 +512,9 @@ public class BirthdayWishesService {
        List<BirthDayWishesToPatient> patientList = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper<>(BirthDayWishesToPatient.class));
        return patientList;
    }
    public BirthDayWishesToPatient getWishesById(Long id){
        BirthDayWishesToPatient tmp = bwToPatientDao.findOne(id);
        return tmp;
    }
}

+ 37 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/booking/BaseBookingServiceService.java

@ -0,0 +1,37 @@
package com.yihu.jw.care.service.booking;
import com.yihu.jw.care.dao.booking.BaseBookingServiceDao;
import com.yihu.jw.entity.care.booking.BaseBookingServiceDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/***
 * @ClassName: BaseBookingServiceService
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/12 10:24
 */
@Service
public class BaseBookingServiceService {
    @Autowired
    private BaseBookingServiceDao serviceDao;
    public void saveByPatient(String patient) throws Exception {
            BaseBookingServiceDo serviceDo = new BaseBookingServiceDo();
            serviceDo.setPatient(patient);
            serviceDo.setStatus(1);
            serviceDao.save(serviceDo);
    }
    public int findByPatient(String patient){
        BaseBookingServiceDo serviceDo = serviceDao.findByPatient(patient);
        if (serviceDo != null){
            return serviceDo.getStatus();
        }else {
            return 0;
        }
    }
}

+ 4 - 13
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java

@ -14,9 +14,7 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
@ -24,23 +22,16 @@ import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.utils.EntityUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.rm.hospital.BaseHospitalRequestMapping.PatientIM.patientInfo;
/**
 * Created by yeshijie on 2020/12/23.
 */
@ -205,7 +196,7 @@ public class ConsultTeamService {
        //4、 紧急救助咨询-参与者
        JSONObject participants = new JSONObject();
        participants.put(patient, 0);
        JSONArray familyArr =  familyMemberService.getPatientMembers(patient,null,null,null);
        JSONArray familyArr =  familyMemberService.getPatientMembers(patient,null,null,null,null);
        for (int i=0;i<familyArr.size();i++){
            JSONObject tmp = familyArr.getJSONObject(i);
            String patientId = tmp.getString("id");
@ -233,7 +224,7 @@ public class ConsultTeamService {
        }
        //加入团队医生
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient,"emergencyAssistance");
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient);
        for(Map<String,Object> map:doctorList){
            participants.put(String.valueOf(map.get("id")), 0);
        }
@ -411,7 +402,7 @@ public class ConsultTeamService {
        JSONObject participants = new JSONObject();
        participants.put(patient, 0);
        //家属
        JSONArray familyArr =  familyMemberService.getPatientMembers(patient,null,null,null);
        JSONArray familyArr =  familyMemberService.getPatientMembers(patient,null,null,null,null);
        for (int i=0;i<familyArr.size();i++){
            JSONObject tmp = familyArr.getJSONObject(i);
            String patientId = tmp.getString("id");
@ -440,7 +431,7 @@ public class ConsultTeamService {
        //加入团队医生
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient,"preventLost");
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient);
        for(Map<String,Object> map:doctorList){
            participants.put(String.valueOf(map.get("id")), 0);
        }

+ 171 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java

@ -1,10 +1,13 @@
package com.yihu.jw.care.service.contacts;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.contacts.BasePatientContactsOrgDao;
import com.yihu.jw.care.dao.contacts.PatientSosContactsDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.family.PatientFamilyMemberDao;
import com.yihu.jw.care.service.device.NetworkCardService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
@ -12,20 +15,24 @@ import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.entity.care.contacts.BasePatientContactsOrgDO;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.LatitudeUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.xml.crypto.Data;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created with IntelliJ IDEA.
@ -55,6 +62,10 @@ public class ContactsService {
    private BaseOrgDao baseOrgDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private PatientSosContactsDao sosContactsDao;
    @Autowired
    private NetworkCardService networkCardService;
    /**
     * 查找居民联系服务站
@ -126,7 +137,7 @@ public class ContactsService {
    }
    /**
     * 设置一键联系人
     * 设置一键联系人  未使用
     * @param fid
     * @param patient
     */
@ -202,4 +213,160 @@ public class ContactsService {
        return result;
    }
    /**
     * 获取居民紧急联系人
     */
    public List<PatientSosContactsDO> getPatientSosContacts(String patient){
        List<PatientSosContactsDO> sosContactsDOS = sosContactsDao.findByPatientAndDel(patient,1);
        for (PatientSosContactsDO tmp:sosContactsDOS){
            tmp.setRelationName(PatientFamilyMemberService.relations.get(tmp.getRelation()));
        }
        return sosContactsDOS;
    }
    /**
     *设置居民紧急联系人
     */
    public JSONObject updatePatientSosContacts(String patient,String num,Integer operType,String name,String relation) throws Exception {
        JSONObject result = new JSONObject();
        List<PatientSosContactsDO> list = sosContactsDao.findByPatientOrderByUpdateTimeDesc(patient);
        if (4==operType){//一个月只能删除一次
            if (list.size()>0){
                Date updateTime = list.get(0).getUpdateTime();
                if (null==updateTime){
                }else {
                    Long timeDiffer = DateUtil.timeDifference(new Date(),updateTime);
                    if (timeDiffer<=(1000L*3600*24*30)){
                        Long day = (1000L*3600*24*30-timeDiffer)/(1000L*3600*24)+1;
                        result.put(ResponseContant.resultFlag,ResponseContant.fail);
                        result.put(ResponseContant.resultMsg,"您本月删除紧急联系人次数已使用,请"+day+"天后再试");
                        return result;
                    }
                }
                String[] numTmp = num.split("_");
                String sql = " select pd.device_sn,wd.sim from  wlyy_patient_device pd inner join wlyy_devices wd  " +
                        "on pd.device_sn = wd.device_code and pd.del=0 and wd.sim is not null and pd.category_code in('7','4')  " +
                        "where pd.user='"+patient+"' ";
                List<Map<String,Object>> sims = jdbcTemplate.queryForList(sql);
                //修改
                delSosNumber(sims,patient,numTmp);
            }else {
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"该用户已无紧急联系人");
                return result;
            }
        }
        if (1==operType){//新增联系人
            list = sosContactsDao.findByPatientAndDel(patient,1);
            Integer seqid=1;
            if (list.size()>=2){
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"该用户紧急联系人已上线");
                return result;
            }
            else {
                if (list.size()>0){
                    seqid = list.get(0).getPhoneSeqid();
                }
                PatientSosContactsDO contactsDO = new PatientSosContactsDO();
                list = sosContactsDao.findByPatientAndDel(patient,0);
                if (list.size()>0) {
                    contactsDO =list.get(0);
                }
                else {
                    contactsDO.setPhoneSeqid(1==seqid?2:1);
                }
                contactsDO.setDel(1);
                contactsDO.setPatient(patient);
                contactsDO.setSosName(name);
                contactsDO.setSosPhone(num);
                contactsDO.setRelation(Integer.parseInt(relation));
                contactsDO.setSuccessFlag(0);
                sosContactsDao.save(contactsDO);
            }
        }
        result.put(ResponseContant.resultFlag,ResponseContant.success);
        result.put(ResponseContant.resultMsg,"修改成功");
        return result;
    }
    public void delSosNumber(List<Map<String,Object>> sims,String patient,String[] numTmp) {
        String delSuccess = "";//白名单删除号码
        for (Map<String,Object> simTmp : sims) {
            String sim = simTmp.get("sim").toString();
            try {
                JSONArray respons = networkCardService.getPatientContacts(sim, null, null, null);
                List<Map<String, Object>> memberArr = null;
                if (respons.size() > 0) {
                    respons.getJSONObject(0).getJSONArray("memVoiceWhiteList");
                    memberArr = (List<Map<String, Object>>) JSONArray.parse(respons.getJSONObject(0).getJSONArray("memVoiceWhiteList").toJSONString());
                    List<String> WhiteList = memberArr.stream().map(e -> e.get("whiteNumber").toString()).collect(Collectors.toList());
                    String del_num = "";
                    if (WhiteList.contains(numTmp[0])) {
                        del_num = numTmp[0];
                    }
                    if (numTmp.length == 2) {
                        if (WhiteList.contains(numTmp[1])) {
                            if (StringUtils.isNotBlank(del_num)) {
                                del_num += "_" + numTmp[1];
                            } else {
                                del_num = numTmp[1];
                            }
                        }
                    }
                    if (StringUtils.isNotBlank(del_num)) {
//                        String response = networkCardService.setPatientContacts(sim, null, null, "4", del_num, null);
//                        if (StringUtils.isNotBlank(response)) {
                        if (StringUtils.isNotBlank("111")) {//todo 对接时不做
                            String[] DelNums = del_num.split("_");
                            for (String tmp:DelNums){
                                if (!delSuccess.contains(tmp)){//本次已删除过 不再作删除操作
                                    String deviceCode = simTmp.get("device_sn").toString();
                                    JSONObject aqgDeviceInfo = patientDeviceService.getAqgDeviceInfo(deviceCode);
                                    JSONArray aqgDeviceSosNum = aqgDeviceInfo.getJSONArray("sos_numbers");
                                    Integer numIndex=0;
                                    for (int i=0;i<aqgDeviceSosNum.size();i++){
                                        JSONObject aqgTmp = aqgDeviceSosNum.getJSONObject(i);
                                        String aqgNum = aqgTmp.getString("num");
                                        if (aqgNum.equals(tmp)){
                                            numIndex = aqgTmp.getInteger("seqid");
                                            break;
                                        }
                                    }
                                    if (numIndex!=0){
                                      JSONObject response2 =  patientDeviceService.updAqgDeviceSosInfo(deviceCode,numIndex+"",null,null,null,"1");
                                      if (response2.getBoolean("success")){
                                          delSuccess += "_"+tmp;
                                      }
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        //保存修改记录
        List<PatientSosContactsDO> modify = new ArrayList<>();
        for (String num:numTmp){
            if (StringUtils.isNotBlank(num)){
                PatientSosContactsDO patientSosContactsDO = sosContactsDao.findByPatientAndSosPhone(patient,num);
                patientSosContactsDO.setUpdateTime(new Date());
                patientSosContactsDO.setDel(0);
                if (delSuccess.contains(num)){
                    patientSosContactsDO.setSuccessFlag(2);
                }
                else {
                    patientSosContactsDO.setSuccessFlag(-2);
                }
                modify.add(patientSosContactsDO);
            }
        }
        sosContactsDao.save(modify);
    }
}

+ 121 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java

@ -0,0 +1,121 @@
package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.NetworkCardConfig;
import com.yihu.jw.care.config.YsConfig;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
 * Created by Bing on 2021/8/6.
 */
@Service
public class NetworkCardService {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 获取电信物联网卡assesToken
     */
    public String getAccessToken() throws Exception {
        if(redisTemplate.hasKey(NetworkCardConfig.redisKey)){
            return redisTemplate.opsForValue().get(NetworkCardConfig.redisKey);
        }
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("appid", NetworkCardConfig.appid));
        params.add(new BasicNameValuePair("password",NetworkCardConfig.password));
        params.add(new BasicNameValuePair("transid", NetworkCardConfig.getTransid()));
        String response = httpClientUtil.get(NetworkCardConfig.getToken,params,"UTF-8");
        JSONObject responseBody = JSONObject.parseObject(response);
        String assToken = null;
        if (responseBody.getInteger("status")==0){
            JSONObject tmp = responseBody.getJSONArray("result").getJSONObject(0);
            assToken = tmp.getString("token");
            Long expireTime =Long.parseLong(tmp.getString("ttl"));//token有效期
            redisTemplate.opsForValue().set(NetworkCardConfig.redisKey,assToken,expireTime, TimeUnit.SECONDS);
        }else {
            throw new Exception(response);
        }
        return assToken;
    }
    public JSONArray getPatientContacts(String msisdn, String iccid, String imsi, String groupId) throws Exception {
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("transid", NetworkCardConfig.getTransid()));
        boolean flag = false;
        if (!flag&&StringUtils.isNotBlank(msisdn)){
            params.add(new BasicNameValuePair("msisdn", msisdn));
            flag=true;
        }
        if (!flag&&StringUtils.isNotBlank(iccid)){
            params.add(new BasicNameValuePair("iccid", iccid));
        }
        if (!flag&&StringUtils.isNotBlank(imsi)){
            params.add(new BasicNameValuePair("imsi", imsi));
        }
        params.add(new BasicNameValuePair("groupId", NetworkCardConfig.groupId));
        params.add(new BasicNameValuePair("token", getAccessToken()));
        String response = httpClientUtil.get(NetworkCardConfig.getPatientContacts,params,"UTF-8");
        JSONObject responseBody = JSONObject.parseObject(response);
        if (responseBody.getInteger("status")==0){
            JSONArray tmp = responseBody.getJSONArray("result");
            return tmp;
        }else if (responseBody.getInteger("status")==14008){//未查询到数据白名单列表为空
            return new JSONArray();
        }else{
            throw new Exception(response);
        }
    }
    public String setPatientContacts(String msisdn, String iccid, String imsi,String operType,String  whiteNumber,String groupId) throws Exception {
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("transid", NetworkCardConfig.getTransid()));
        boolean flag = false;
        if (!flag&&StringUtils.isNotBlank(msisdn)){
            params.add(new BasicNameValuePair("msisdn", msisdn));
            flag=true;
        }
        if (!flag&&StringUtils.isNotBlank(iccid)){
            params.add(new BasicNameValuePair("iccid", iccid));
        }
        if (!flag&&StringUtils.isNotBlank(imsi)){
            params.add(new BasicNameValuePair("imsi", imsi));
        }
        params.add(new BasicNameValuePair("groupId", NetworkCardConfig.groupId));
        params.add(new BasicNameValuePair("token", getAccessToken()));
        params.add(new BasicNameValuePair("operType", operType));
        params.add(new BasicNameValuePair("whiteNumber", whiteNumber));
        String response = httpClientUtil.get(NetworkCardConfig.setPatientContacts,params,"UTF-8");
        JSONObject responseBody = JSONObject.parseObject(response);
        if (responseBody.getInteger("status")==0){
            JSONObject tmp = responseBody.getJSONArray("result").getJSONObject(0);
            return tmp.getString("orderNum");
        }else {
            throw new Exception("物联网卡操作失败:"+response);
        }
    }
}

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

@ -1,10 +1,13 @@
package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
import com.yihu.jw.care.util.ConcealUtil;
import com.yihu.jw.care.util.MyJdbcTemplate;
@ -15,9 +18,12 @@ import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
@ -79,6 +85,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private YsDeviceService ysDeviceService;
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
@ -91,6 +99,10 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private String esIndex;
    @Autowired
    private GpsUtil gpsUtil;
    @Autowired
    private ContactsService contactsService;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    @PostConstruct
    public void init() {
@ -455,12 +467,23 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        sql += " and  pd.`user`='" + patient + "' ";
        }
        if (StringUtils.isNotBlank(serviceTopic)) {
            sql+= " and dd.service_topic='"+serviceTopic+"' ";
            sql+= " and dd.service_topic like '%"+serviceTopic+"%' ";
        }
        sql+=" order by pd.czrq asc ";
        return jdbcTemplate.queryForList(sql);
    }
    public List<Map<String,Object>> patientEmeDeviceList(String patient){
        String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime " +
                "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
                "where 1=1 and  pd.del=0 ";
        if (StringUtils.isNotBlank(patient)) {
            sql += " and  pd.`user`='" + patient + "' ";
        }
        sql+=" and dd.service_topic is not null order by pd.czrq asc ";
        return jdbcTemplate.queryForList(sql);
    }
    public JSONArray getDeviceByDeviceSn(String deviceSn, String type) {
        List<DevicePatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        JSONArray objects = new JSONArray();
@ -750,13 +773,141 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return resultMap;
    }
    /**
     * 根据设备sn及居民code获取居民有效的设备绑定信息
     * @param deviceSn 设备sn码
     * @return
     */
    public JSONObject getPatientDeviceDetail(String patient,String deviceSn){
        JSONObject result = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patient);
        if (null==patientDO){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"当前居民不存在");
        }
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
        if (devices.size()==0){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"未查询到该设备");
        }else {
            DevicePatientDevice device = devices.get(0);
            if (!patient.equals(device.getUser())){
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"居民未绑定该设备");
            }else {
                String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime " +
                        "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
                        "where 1=1 and  pd.del=0 and pd.device_sn ='"+deviceSn+"' ";
                Map<String,Object> devInfo = jdbcTemplate.queryForMap(sql);
                devInfo.put("patient",patient);
                devInfo.put("patientName",patientDO.getName());
                devInfo.put("sosContactsDOS",new ArrayList<>());
                if ("4".equals(device.getCategoryCode())||"7".equals(device.getCategoryCode())){
                    devInfo.put("sosContactsDOS",contactsService.getPatientSosContacts(patient));
                }
                result.put(ResponseContant.resultFlag,ResponseContant.success);
                result.put(ResponseContant.resultMsg,JSON.parseObject(JSON.toJSONString(devInfo, SerializerFeature.WriteMapNullValue)));
            }
        }
        return result;
    }
    /**
     * 根据设备sn及居民code获取居民有效的设备绑定数据
     * @param deviceSn 设备sn码
     * @return
     */
    public List<DevicePatientDevice> findByDeviceSn(String deviceSn){
       return  patientDeviceDao.findByDeviceSn(deviceSn);
    public JSONObject getPatientDeviceData(String patient,String deviceSn,Integer page,Integer pageSize)throws Exception{
        page = page>0?page-1:0;
        JSONObject result = new JSONObject();
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
        if (devices.size()>0){
            DevicePatientDevice device = devices.get(0);
            if (!patient.equals(device.getUser())){
                throw new Exception("居民未绑定该设备");
            }else{
                switch (device.getCategoryCode()){
                    case "1"://血压设备
                        result = getHealthIndex(result,deviceSn,patient,page,pageSize);
                        break;
                    case "2"://血糖设备
                        result = getHealthIndex(result,deviceSn,patient,page,pageSize);
                        break;
                    case "4"://手表 紧急工单与安防工单
                        result = getEmeWarn(result,deviceSn,patient,page,pageSize);
                        break;
                    case "7"://报警器 紧急工单
                        result = getEmeWarn(result,deviceSn,patient,page,pageSize);
                        break;
                    case "12"://监控
                        com.alibaba.fastjson.JSONObject tmp =ysDeviceService.getDeviceLiveAddress(patient,deviceSn,1,null);
                        result.put("monitorInfoStatus",tmp.getIntValue(ResponseContant.resultFlag));
                        if (tmp.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                            result.put("monitorInfo",tmp.getString(ResponseContant.resultMsg));
                        }
                        else {
                            result.put("monitorInfo",tmp.getJSONObject(ResponseContant.resultMsg));
                        }
                        break;
                    default://安防设备
                        result = null;
                        break;
                }
            }
        }else {
            throw new Exception("设备未被绑定");
        }
        return result;
    }
    public JSONObject getHealthIndex(JSONObject result,String deviceSn,String patient,Integer page,Integer pageSize){
        String sqlCount = "select count(id) from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
                " and del=1 ";
        String sql = "select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) sign_status from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
                " and del=1 order by record_date desc limit "+page*pageSize+","+pageSize;
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:list){
            Integer type =Integer.parseInt(tmp.get("type").toString());
            String value1 = tmp.get("value1")==null?null:tmp.get("value1").toString();
            String value2 = tmp.get("value2")==null?null:tmp.get("value2").toString();
            String value3 = tmp.get("value3")==null?null:tmp.get("value3").toString();
            String value4 = tmp.get("value4")==null?null:tmp.get("value4").toString();
            String value5 = tmp.get("value5")==null?null:tmp.get("value5").toString();
            String value6 = tmp.get("value6")==null?null:tmp.get("value6").toString();
            String value7 = tmp.get("value7")==null?null:tmp.get("value7").toString();
            com.alibaba.fastjson.JSONArray errorInfo = healthIndexUtil.verifyHealthIndex(type,value1,value2,value3,value4,value5,value6,value7);
            tmp.put("errorInfo",errorInfo);
        }
        result.put("total",count);
        result.put("page",page+1);
        result.put("pageSize",pageSize);
        result.put("dataList",list);
        return result;
    }
    public JSONObject getEmeWarn(JSONObject result,String deviceSn,String patient,Integer page,Integer pageSize){
        String sqlCount = "select SUM(total) from( \n" +
                "select count(ord.id) as total from base_emergency_assistance_order ord  where ord.device_sn='"+deviceSn+"' " +
                " and ord.patient='"+patient+"' " +
                "UNION All " +
                "select count(ord.id)  as total from base_security_monitoring_order ord  where ord.device_sn='"+deviceSn+"' " +
                " and ord.patient='"+patient+"' )A ";
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
        String sql = "select '20' as OrderType,ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
                "'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_emergency_assistance_order ord  where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"' " +
                "UNION " +
                "select  '22' as 'OrderType',ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
                "ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order ord " +
                " where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"'  order by create_time desc limit "+page*pageSize+","+pageSize;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        result.put("total",count);
        result.put("page",page+1);
        result.put("pageSize",pageSize);
        result.put("dataList",list);
        return result;
    }
     /******************************************* 爱牵挂设备start *****************************************************/
@ -804,6 +955,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    |
     */
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear){
        //先对移动接口限制做判断。
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
        String url ="";
        if ("4".equals(devices.get(0).getCategoryCode())){//手表

+ 92 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -2,18 +2,21 @@ package com.yihu.jw.care.service.doctor;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.care.service.birthday.BirthdayWishesService;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.DoctorSpecialDiseaseDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
@ -24,10 +27,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by yeshijie on 2021/3/3.
@ -60,6 +60,40 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    private ImService imService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private BirthdayWishesService birthdayWishesService;
    /**
     * 获取医生简单详情
     * @return
     */
    public Map<String,Object> doctorSimpleInfo(String doctorId){
        String sql = "SELECT d.id,d.name,d.photo,d.sex ";
        sql += " ,h.org_code orgCode,h.org_name orgName from base_doctor d left join base_doctor_hospital h on d.id = h.doctor_code  and h.del = 1" +
                "  WHERE d.id = '"+doctorId+"' limit 1 ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Map<String,Object> map = list.get(0);
        //签约老人数、紧急救助完成数、生活照料完成数、安防监护完成数
        String sql1 = "SELECT COUNT(DISTINCT sr.patient) FROM " +
                " base_service_package_sign_record sr, base_service_package_record r, base_service_package_item i, base_team_member m " +
                " WHERE  sr.id = r.sign_id and sr.status=1  AND r.service_package_id = i.service_package_id " +
                " AND i.del = 1 and m.team_code = r.team_code " +
                "  and m.del = '1' and m.doctor_code = '"+doctorId+"'";
        Integer signNum = jdbcTemplate.queryForObject(sql1,Integer.class);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 7 ";
        String filter = " and doctor = '"+doctorId+"'";
        Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
        Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
        Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);
        map.put("signNum",signNum);
        map.put("lifeCare",lifeCare);
        map.put("emergency",emergency);
        map.put("security",security);
        return map;
    }
    /**
     * 获取医生详情
@ -514,4 +548,58 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return result;
    }
    public JSONObject baseInfoCount(String doctor){
        JSONObject result = new JSONObject();
        result.put("lifeCare",0);
        result.put("emergencyAssistance",0);
        result.put("patientCare",0);//人文关怀
        result.put("security",0);
        List<BaseDoctorHospitalDO> doctorHospitalDOs = doctorHospitalDao.findByDoctorCode(doctor);
        String hospital = doctorHospitalDOs.get(0).getOrgCode();
        //生活照料
        String countSql = "SELECT  " +
                "   count(o.id)  " +
                " FROM  " +
                "   base_life_care_order o  " +
                " LEFT JOIN base_patient p ON o.patient = p.id " +
                " WHERE  " +
                "  o.hospital = 'hospital' "+
                " AND o.status = 1 and o.pay_status>0  ";
        Long count = jdbcTemplate.queryForObject(countSql,Long.class);
        if (count>0){
            result.put("lifeCare",count);
        }
        //紧急救助
        countSql = " select count(ord.id) count from base_emergency_assistance_order ord where ord.status=1 " +
                "AND EXISTS (SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                " base_service_package_item i ,base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and " +
                " sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                "  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        count = jdbcTemplate.queryForObject(countSql,Long.class);
        if (count>0){
            result.put("emergencyAssistance",count);
        }
        //安防工单
        countSql = " select count(ord.id) count from base_security_monitoring_order ord where ord.status=1 " +
                "AND EXISTS (SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                " base_service_package_item i ,base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and " +
                " sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                "  and i.del = 1 and sr.`status`=1  and i.topic_item='security' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        count = jdbcTemplate.queryForObject(countSql,Long.class);
        if (count>0){
            result.put("security",count);
        }
        //人文关怀
        try {
            Integer counts = birthdayWishesService.getPatientByDoctorCount(doctor);
            if (count>0){
                result.put("patientCare",count);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
}

+ 6 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java

@ -326,8 +326,8 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientMembers(String patient, String doctorCode, String isContain, Integer isAgree) {
        JSONArray resultArray = getPatientFamilyMembers(patient, doctorCode, isAgree);
    public JSONArray getPatientMembers(String patient, String doctorCode, String isContain, Integer isAgree,String archive_type) {
        JSONArray resultArray = getPatientFamilyMembers(patient, doctorCode, isAgree,archive_type);
        if (resultArray == null) {
            resultArray = new JSONArray();
@ -374,7 +374,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientFamilyMembers(String patient, String doctorCode, Integer isContacts) {
    public JSONArray getPatientFamilyMembers(String patient, String doctorCode, Integer isContacts,String archive_type) {
        JSONArray resultArray = new JSONArray();
        String sql = "select * " +
                " from " +
@ -384,6 +384,9 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                "    t2.id in (select family_member from base_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
        if (StringUtils.isNotBlank(archive_type)){
            sql += " and t2.archive_type='"+archive_type+"' ";
        }
/*        if(isContacts != null){
            sql += " and t1.is_contacts = "+ isContacts;
        }*/

+ 0 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java


Some files were not shown because too many files changed in this diff