Просмотр исходного кода

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

wangzhinan 1 год назад
Родитель
Сommit
112ee0a8be
27 измененных файлов с 1750 добавлено и 1025 удалено
  1. 12 20
      business/base-service/src/main/java/com/yihu/jw/device/dao/PatientDeviceDao.java
  2. 626 589
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  3. 2 0
      business/base-service/src/main/java/com/yihu/jw/knowledge/service/BaseKnowledgeDictService.java
  4. 13 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDischargeRecordDao.java
  5. 33 0
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientDischargeRecordService.java
  6. 218 0
      business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java
  7. 1 1
      business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java
  8. 3 4
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  9. 62 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceDetail.java
  10. 21 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientDevice.java
  11. 18 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientHealthIndex.java
  12. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java
  13. 51 0
      common/common-entity/src/main/java/com/yihu/jw/entity/patient/BasePatientDischargeRecord.java
  14. 1 1
      starter/elasticsearch-starter/src/main/java/com/yihu/jw/elasticsearch/ElasticSearch7Pool.java
  15. 12 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java
  16. 2 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  17. 29 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/DsyyPrescriptionCotroller.java
  18. 17 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java
  19. 114 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/StatisticsController.java
  20. 244 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/StatisticsService.java
  21. 36 357
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/DoorOrderController.java
  22. 41 5
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DeviceController.java
  23. 2 5
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java
  24. 94 3
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceService.java
  25. 8 27
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceUploadService.java
  26. 18 11
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientDeviceService.java
  27. 71 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/utils/ExportUtl.java

+ 12 - 20
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientDeviceDao.java

@ -12,37 +12,39 @@ import java.util.List;
public interface PatientDeviceDao extends JpaRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
public interface PatientDeviceDao extends JpaRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 ")
    Iterable<DevicePatientDevice> findByUser(String user);
    Iterable<DevicePatientDevice> findByUser(String user);
    @Query("select a from DevicePatientDevice a where a.del = 0 ")
    @Query("select a from DevicePatientDevice a where a.del = 0 ")
    List<DevicePatientDevice> findByAll();
    List<DevicePatientDevice> findByAll();
    @Query("select a from PatientHealthStandard a where a.patient = ?1 and a.type = ?2")
    @Query("select a from PatientHealthStandard a where a.patient = ?1 and a.type = ?2 ")
    PatientHealthStandard findByPatientType(String patient, int type);
    PatientHealthStandard findByPatientType(String patient, int type);
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 ")
    List<DevicePatientDevice> findByPatient(String user);
    List<DevicePatientDevice> findByPatient(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    List<DevicePatientDevice> findByPatientAndDel(String user);
    List<DevicePatientDevice> findByPatientAndDel(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 and a.del=?3 ")
    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn,Integer del);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
    List<DevicePatientDevice> findByUser(String user, Pageable pageRequest);
    List<DevicePatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);
    List<DevicePatientDevice> findByUserAndDel(String user,Integer del, Pageable pageRequest);
    @Query("select a from DevicePatientDevice a where a.deviceSn = ?1 and a.categoryCode=?2 and a.del=0 ")
    List<DevicePatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
    List<DevicePatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
    @Query("select a from DevicePatientDevice a where a.deviceSn = ?1 and a.categoryCode=?2 and a.userType=?3 and a.del=0 ")
    DevicePatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
    DevicePatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
    DevicePatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn, String userType);
    @Query("select a from DevicePatientDevice a where a.deviceSn = ?1 and a.userType=?2 and a.del=0 ")
    DevicePatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
    DevicePatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
    @Query("select a from DevicePatientDevice a where a.deviceSn=?1 and a.userType =?2 ")
    @Query("select a from DevicePatientDevice a where a.deviceSn=?1 and a.userType =?2  and a.del=0")
    List<DevicePatientDevice> findByDeviceSnAndUserType2(String deviceSn, String userType);
    List<DevicePatientDevice> findByDeviceSnAndUserType2(String deviceSn, String userType);
    @Query("select pd from DevicePatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
    @Query("select pd from DevicePatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
@ -55,22 +57,12 @@ public interface PatientDeviceDao extends JpaRepository<DevicePatientDevice, Lon
    //管理员解绑居民设备
    //管理员解绑居民设备
    @Modifying
    @Modifying
    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 and t.del =0  ")
    @Query("update DevicePatientDevice t set t.del = 1,t.delUser='admin'  where t.deviceSn = ?1 and t.del =0  ")
    int updatePatientDevice(String deviceSN);
    int updatePatientDevice(String deviceSN);
    @Query("select a from DevicePatientDevice a")
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    List<DevicePatientDevice> findAll();
    @Query("select a from DevicePatientDevice a group by a.user")
    List<DevicePatientDevice> findAllGroupUser();
    @Query("select a from DevicePatientDevice a where a.categoryCode = ?1 and a.del=0 group by a.user")
    List<DevicePatientDevice> findAllByCategoryCode(String categoryCode);
    @Modifying
    @Query("delete DevicePatientDevice a where a.deviceSn = ?1")
    int deleteByDeviceSn(String deviceSN);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
    List<DevicePatientDevice> findAllByUser(String user);

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

@ -5338,7 +5338,25 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return rs;
        return rs;
    }
    }
    //发送短信
    public void sendSms(String phone,String content,String type){
        try {
            if("2".equals(type)){
                //新增判断是否给医生发送消息
                WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("isSendDoctorSms").orElse(null);
                if(dictDO==null||"0".equals(dictDO.getDictValue())){
                    //不发送
                    return;
                }
            }
            if(StringUtils.isNotBlank(phone)&&StringUtils.isNotBlank(content)){
               int i= dsyyPrescriptionService.SendSms(phone,content);
               logger.info("phone="+phone+";content="+content+","+i);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
    /**
     * 发送微信模板消息  本地无法测试消息是否发送成功
     * 发送微信模板消息  本地无法测试消息是否发送成功
@ -5349,135 +5367,152 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param remindMsg
     * @param remindMsg
     */
     */
    public void sendWxTemplateMsg(String wxId, String outpatientId,ConsultTeamDo consultTeam,  String type, String titelType, String remindMsg) {
    public void sendWxTemplateMsg(String wxId, String outpatientId,ConsultTeamDo consultTeam,  String type, String titelType, String remindMsg) {
        if("xm_dsyy_wx".equals(wxId)){
            //三院的先不发模板消息
            return;
        }
        BaseDoctorDO consDoctorDO = new BaseDoctorDO();
        BasePatientDO consPatientDO = new BasePatientDO();
        BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
        //获取咨询的信息
        String msgUrl="";
        if (consultTeam!=null){
            consDoctorDO = baseDoctorDao.findByIdAndDel(consultTeam.getDoctor());
            consPatientDO = basePatientDao.findById(consultTeam.getPatient()).orElse(null);
            List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(consultTeam.getDoctor());
            if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()>=0){
                hospitalDO=doctorHospitalDOS.get(0);
        try {
            BaseDoctorDO consDoctorDO = new BaseDoctorDO();
            BasePatientDO consPatientDO = new BasePatientDO();
            BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
            //获取咨询的信息
            String msgUrl="";
            if (consultTeam!=null){
                consDoctorDO = baseDoctorDao.findByIdAndDel(consultTeam.getDoctor());
                consPatientDO = basePatientDao.findById(consultTeam.getPatient()).orElse(null);
                List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(consultTeam.getDoctor());
                if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()>=0){
                    hospitalDO=doctorHospitalDOS.get(0);
                }
            }
            }
        }
        WlyyOutpatientDO outpatientDO = new WlyyOutpatientDO();
        BaseDoctorDO doctorDO = new BaseDoctorDO();
        BasePatientDO patientDO = new BasePatientDO();
        if (StringUtils.isNotEmpty(outpatientId)){
            outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
            doctorDO = baseDoctorDao.findByIdAndDel(outpatientDO.getDoctor());
            patientDO = basePatientDao.findById(outpatientDO.getConsumer()).orElse(null);
        }
        logger.info("titelType:"+titelType+"&&remindMsg:"+remindMsg+"&&type"+type);
        String contentMsg = "";
        String first = "";
        String remark = "";
        if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
            //医生拒绝接诊
            if ("9".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已取消";
            }
            if ("16".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已取消";
            }
            if ("1".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已取消";
            }
            if ("17".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已取消";
            }
            logger.info("doctorRefuseRemind医生拒诊入参:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
            //医生未接诊时患者等待时间过长的模板提示
            contentMsg = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
            first = outpatientDO.getConsumerName() + ",您好!";
            logger.info("outPatientTimeOutRemind:outpatientId="+outpatientId+"contentMsg"+contentMsg);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        }else if("doctorPick".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "您发起的图文复诊已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的图文复诊,医生已接诊";
            }
            if ("16".equals(type)) {
                contentMsg =  "您发起的视频复诊已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的视频复诊,医生已接诊";
            }
            if ("1".equals(type)) {
                contentMsg =  "您发起的图文咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的图文咨询,医生已接诊";
            }
            if ("17".equals(type)) {
                contentMsg = "您发起的视频咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的视频咨询,医生已接诊";
            }
            if ("12".equals(type)) {
                contentMsg = "您发起的专科协同已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的专科协同,医生已接诊";
                return;
            }
            if ("15".equals(type)) {
                contentMsg = "您发起的家医咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的家医咨询,医生已接诊";
            }
            logger.info("doctorPick诊查费支付成功推送模板消息:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if("doctorRefund".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的图文复诊已退号";
            }
            if ("16".equals(type)) {
                contentMsg =  "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的视频复诊已退号";
            WlyyOutpatientDO outpatientDO = new WlyyOutpatientDO();
            BaseDoctorDO doctorDO = new BaseDoctorDO();
            BasePatientDO patientDO = new BasePatientDO();
            if (StringUtils.isNotEmpty(outpatientId)){
                outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
                doctorDO = baseDoctorDao.findByIdAndDel(outpatientDO.getDoctor());
                patientDO = basePatientDao.findById(outpatientDO.getConsumer()).orElse(null);
            }
            }
            if ("1".equals(type)) {
                contentMsg =  "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的图文咨询已退号";
            }
            if ("17".equals(type)) {
                contentMsg = "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的视频咨询已退号";
            }
            logger.info("doctorRefund:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if("patientCancel".equalsIgnoreCase(titelType)) {
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isCloseRefund").orElse(null);
            if (outpatientDO.getPayStatus()==1){
                if (hospitalSysDictDO!=null){
                    if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                        if ("9".equals(type)) {
                            contentMsg = "您发起的图文复诊已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                        }
                        if ("16".equals(type)) {
                            contentMsg =  "您发起的视频复诊已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                        }
                        if ("1".equals(type)) {
                            contentMsg =  "您发起的图文咨询已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                        }
                        if ("17".equals(type)) {
                            contentMsg = "您发起的视频咨询已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                        }
                        if ("12".equals(type)) {
                            return;
            logger.info("titelType:"+titelType+"&&remindMsg:"+remindMsg+"&&type"+type);
            String patientPhone = patientDO.getMobile();
            String contentMsg = "";
            String first = "";
            String remark = "";
            if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
                //医生拒绝接诊
                if ("9".equals(type)) {
                    contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                    first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已取消";
                }
                if ("16".equals(type)) {
                    contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                    first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已取消";
                }
                if ("1".equals(type)) {
                    contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                    first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已取消";
                }
                if ("17".equals(type)) {
                    contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                    first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已取消";
                }
                logger.info("doctorRefuseRemind医生拒诊入参:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
                //医生未接诊时患者等待时间过长的模板提示
                contentMsg = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
                first = outpatientDO.getConsumerName() + ",您好!";
                logger.info("outPatientTimeOutRemind:outpatientId="+outpatientId+"contentMsg"+contentMsg);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            }else if("doctorPick".equalsIgnoreCase(titelType)) {
                if ("9".equals(type)) {
                    contentMsg = "您发起的图文复诊已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的图文复诊,医生已接诊";
                }
                if ("16".equals(type)) {
                    contentMsg =  "您发起的视频复诊已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的视频复诊,医生已接诊";
                }
                if ("1".equals(type)) {
                    contentMsg =  "您发起的图文咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的图文咨询,医生已接诊";
                }
                if ("17".equals(type)) {
                    contentMsg = "您发起的视频咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的视频咨询,医生已接诊";
                }
                if ("12".equals(type)) {
                    contentMsg = "您发起的专科协同已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的专科协同,医生已接诊";
                    return;
                }
                if ("15".equals(type)) {
                    contentMsg = "您发起的家医咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的家医咨询,医生已接诊";
                }
                logger.info("doctorPick诊查费支付成功推送模板消息:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            } else if("doctorRefund".equalsIgnoreCase(titelType)) {
                if ("9".equals(type)) {
                    contentMsg = "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的图文复诊已退号";
                }
                if ("16".equals(type)) {
                    contentMsg =  "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的视频复诊已退号";
                }
                if ("1".equals(type)) {
                    contentMsg =  "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的图文咨询已退号";
                }
                if ("17".equals(type)) {
                    contentMsg = "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的视频咨询已退号";
                }
                logger.info("doctorRefund:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            } else if("patientCancel".equalsIgnoreCase(titelType)) {
                WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isCloseRefund").orElse(null);
                if (outpatientDO.getPayStatus()==1){
                    if (hospitalSysDictDO!=null){
                        if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                            if ("9".equals(type)) {
                                contentMsg = "您发起的图文复诊已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                            }
                            if ("16".equals(type)) {
                                contentMsg =  "您发起的视频复诊已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                            }
                            if ("1".equals(type)) {
                                contentMsg =  "您发起的图文咨询已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                            }
                            if ("17".equals(type)) {
                                contentMsg = "您发起的视频咨询已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                            }
                            if ("12".equals(type)) {
                                return;
                            }
                        }else {
                            if ("9".equals(type)) {
                                contentMsg = "您发起的图文复诊已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                            }
                            if ("16".equals(type)) {
                                contentMsg =  "您发起的视频复诊已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                            }
                            if ("1".equals(type)) {
                                contentMsg =  "您发起的图文咨询已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                            }
                            if ("17".equals(type)) {
                                contentMsg = "您发起的视频咨询已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                            }
                            if ("12".equals(type)) {
                                return;
                            }
                        }
                        }
                    }else {
                    }else {
                        if ("9".equals(type)) {
                        if ("9".equals(type)) {
@ -5502,62 +5537,51 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                    }
                }else {
                }else {
                    if ("9".equals(type)) {
                    if ("9".equals(type)) {
                        contentMsg = "您发起的图文复诊已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg = "您发起的图文复诊已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                    }
                    }
                    if ("16".equals(type)) {
                    if ("16".equals(type)) {
                        contentMsg =  "您发起的视频复诊已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg =  "您发起的视频复诊已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                    }
                    }
                    if ("1".equals(type)) {
                    if ("1".equals(type)) {
                        contentMsg =  "您发起的图文咨询已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg =  "您发起的图文咨询已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                    }
                    }
                    if ("17".equals(type)) {
                    if ("17".equals(type)) {
                        contentMsg = "您发起的视频咨询已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg = "您发起的视频咨询已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                    }
                    }
                    if ("12".equals(type)) {
                    if ("12".equals(type)) {
                        return;
                        return;
                    }
                    }
                }
                }
            }else {
                if ("9".equals(type)) {
                    contentMsg = "您发起的图文复诊已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                }
                if ("16".equals(type)) {
                    contentMsg =  "您发起的视频复诊已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                }
                if ("1".equals(type)) {
                    contentMsg =  "您发起的图文咨询已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                }
                if ("17".equals(type)) {
                    contentMsg = "您发起的视频咨询已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                }
                if ("12".equals(type)) {
                    return;
                }
            }
            logger.info("patientCancel诊查费支付成功推送模板消息:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        }else if("systemCancelRemind".equalsIgnoreCase(titelType)){
            //超过24小时未接诊,系统取消
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isCloseRefund").orElse(null);
            if (outpatientDO.getPayStatus()==1){
                if (hospitalSysDictDO!=null){
                    if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                        if ("9".equals(type)) {
                            contentMsg = "您发起的图文复诊已取消,已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                        }
                        if ("16".equals(type)) {
                            contentMsg = "您发起的视频复诊已取消,已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                logger.info("patientCancel诊查费支付成功推送模板消息:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            }else if("systemCancelRemind".equalsIgnoreCase(titelType)){
                //超过24小时未接诊,系统取消
                WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isCloseRefund").orElse(null);
                if (outpatientDO.getPayStatus()==1){
                    if (hospitalSysDictDO!=null){
                        if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                            if ("9".equals(type)) {
                                contentMsg = "您发起的图文复诊已取消,已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                            }
                            if ("16".equals(type)) {
                                contentMsg = "您发起的视频复诊已取消,已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                            }
                        }else {
                            if ("9".equals(type)) {
                                contentMsg = "您发起的图文复诊已取消,请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                            }
                            if ("16".equals(type)) {
                                contentMsg = "您发起的视频复诊已取消,请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                            }
                        }
                        }
                    }else {
                    }else {
                        if ("9".equals(type)) {
                        if ("9".equals(type)) {
@ -5571,450 +5595,455 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                    }
                }else {
                }else {
                    if ("9".equals(type)) {
                    if ("9".equals(type)) {
                        contentMsg = "您发起的图文复诊已取消,请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg = "您发起的图文复诊已取消,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                    }
                    }
                    if ("16".equals(type)) {
                    if ("16".equals(type)) {
                        contentMsg = "您发起的视频复诊已取消,请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg = "您发起的视频复诊已取消,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                    }
                    }
                }
                }
            }else {
                if ("9".equals(type)) {
                    contentMsg = "您发起的图文复诊已取消,如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                }
                if ("16".equals(type)) {
                    contentMsg = "您发起的视频复诊已取消,如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                }
            }
            logger.info("系统取消接诊入参:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if ("payRemind".equalsIgnoreCase(titelType)) {
            //患者发起时提醒患者支付诊费消息
            if ("9".equals(type)) {
                contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                first = outpatientDO.getConsumerName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个图文复诊订单待支付,请及时支付。
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                logger.info("图文复诊订单待支付微信消息模板推送开始");
            } else if ("16".equals(type)) {
                contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                first = outpatientDO.getConsumerName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个视频复诊订单待支付,请及时支付。
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                logger.info("视频复诊订单待支付微信消息模板推送开始");
            }else if ("1".equals(type)) {
                contentMsg = "您有一个图文咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                logger.info("系统取消接诊入参:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                first = outpatientDO.getConsumerName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
                logger.info("图文咨询订单待支付微信消息模板推送开始");
            } else if ("17".equals(type)) {
                contentMsg = "您有一个视频咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                first =  outpatientDO.getConsumerName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
                logger.info("视频咨询订单待支付微信消息模板推送开始");
            }else {
                return;
            }
        } else if ("paySuccess".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "您已成功发起图文复诊,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                first = outpatientDO.getConsumerName() + ",您好!您已成功发起图文复诊";
            }else if ("16".equals(type)) {
                contentMsg =  "您已成功发起视频复诊,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                first = outpatientDO.getConsumerName() + ",您好!您已成功发起视频复诊";
            }else if ("1".equals(type)) {
                contentMsg =  "您已成功发起图文咨询,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                first = outpatientDO.getConsumerName() + ",您好!您已成功发起图文咨询";
            }else if ("17".equals(type)) {
                contentMsg = "您已成功发起视频咨询,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                first = outpatientDO.getConsumerName() + ",您好!您已成功发起视频咨询";
            }else {
                return;
            }
            logger.info("paySuccess诊查费支付成功推送模板消息:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        }else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
            //开具处方后向患者发送支付提醒
            first = outpatientDO.getConsumerName() + ",您好! 医生已为您开具处方,请及时支付。";
            contentMsg = "医生已为您开具处方,请及时支付。";
            remark = "点击完成支付,如您已支付请忽略本条信息";
            msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId+"&id="+remindMsg;
            logger.info("处方支付微信消息模板推送开始");
        }else if ("diagnoPayRemind".equalsIgnoreCase(titelType)) {
            //开具处方后向患者发送支付提醒
            first = outpatientDO.getConsumerName() + ",您好! 您的问诊已结束,请及时结算费用。";
            contentMsg = "您好! 您的问诊已结束,请及时结算费用。";
            remark = "点击完成支付,如您已支付请忽略本条信息";
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            logger.info("诊查费微信消息模板推送开始");
        } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
            //视频复诊预约提醒
            if ("16".equals(type)) {
                msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=16&outpatientId="+outpatientId;
                if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                    first = "您的视频复诊已预约成功。";
                    contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频复诊。请留意微信公众号消息。";
                }else {
                    first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频复诊。";
                    contentMsg = "您已预约" + DateUtil.dateToStrLong(consultTeam.getCzrq()) +  "的视频复诊 与您进行视频复诊。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频复诊";
                }
                logger.info("视频复诊已预约成功微信消息模板推送开始");
            } else if ("17".equals(type)) {
                if (StringUtils.isNotEmpty(outpatientId)){
                    msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=17&outpatientId="+outpatientId;
                    if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                        first = "您的视频咨询已预约成功。";
                        contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频咨询。请留意微信公众号消息。";
                    }else{
                        first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频咨询。";
                        contentMsg = "您已预约" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) +  "的视频咨询 与您进行视频咨询。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频咨询";
                    }
                }else{
                    msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
                    contentMsg = "预计" + consDoctorDO.getName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频咨询。请留意微信公众号消息。";
                }
                logger.info("视频咨询已预约成功微信消息模板推送开始");
            }
            remark = "咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
        } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
            //服务评价提醒
            if (consultTeam.getType()!=null&&1==consultTeam.getType()){
                first = consultTeam.getName() + ",您好!您有1条图文咨询已结束,请及时对咨询医生进行评价。";
                logger.info("图文咨询服务评价微信消息模板推送开始");
            }else if (consultTeam.getType()!=null&&9==consultTeam.getType()){
                first = consultTeam.getName() + ",您好!您有1条图文复诊已结束,请及时对咨询医生进行评价。";
                logger.info("图文复诊服务评价微信消息模板推送开始");
            }else if (consultTeam.getType()!=null&&16==consultTeam.getType()){
                first = consultTeam.getName() + ",您好!您有1条视频复诊已结束,请及时对咨询医生进行评价。";
                logger.info("视频复诊服务评价微信消息模板推送开始");
            }else if (consultTeam.getType()!=null&&17==consultTeam.getType()){
                first = consultTeam.getName() + ",您好!您有1条视频咨询已结束,请及时对咨询医生进行评价。";
                logger.info("视频咨询服务评价微信消息模板推送开始");
            }else {
                return;
            }
            contentMsg = "请对" + consDoctorDO.getName() + "医生的服务进行评价";
            msgUrl="/ims-wx/index.html#/fuwupingjia?consultCode="+consultTeam.getConsult();
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)||"sd_tnzyy_wx".equalsIgnoreCase(wxId)) {
            List<BasePatientWechatDo> ps = new ArrayList<BasePatientWechatDo>();
            if (StringUtils.isNotEmpty(outpatientId)){
                ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getConsumer());
            }
            if (consultTeam!=null){
                ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, consultTeam.getPatient());
            }
            if (ps.isEmpty()) {
                logger.info("该用户" + outpatientDO.getConsumerName() + "没有openid,无法推送模版消息,用户ID:" + outpatientDO.getPatient() + "wechatId:" + wxId);
                return;
            }
            String scene = "";
            WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
            if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
                //医生拒绝接诊
                scene = "ysqxjz";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                }
                newConfig.setKeyword1( outpatientDO.getHospitalName());
                newConfig.setKeyword2(outpatientDO.getDoctorName());
                newConfig.setKeyword3( doctorDO.getFee());
                newConfig.setPagepath(newConfig.getPagepath() + "" + outpatientDO.getId());
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 医生拒诊开始");
                logger.info("极光消息推送 医生拒诊开始");
                wxTempalteJPush("cancel_remind",outpatientDO,null,"","","","");
                /*String res = wxTempalteJPush(outpatientDO.getConsumer(),newConfig.getFirst(),"医生拒绝了你的问诊",type,outpatientDO.getId());
                logger.info("JPUSH res==="+res);*/
            }else if("outPatientTimeOutRemind".equals(titelType)){
                //就诊等待过长提示
                scene="jzddgcts";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_timeout_remind", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setPagepath(newConfig.getPagepath() + "" + outpatientDO.getId());
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("就诊等待过长提示");
            } else if ("payRemind".equalsIgnoreCase(titelType)) {
            } else if ("payRemind".equalsIgnoreCase(titelType)) {
                //诊费支付提示
                scene = "zxzfts";
                //就诊支付
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_notice_jz", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                //患者发起时提醒患者支付诊费消息
                if ("9".equals(type)) {
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    newConfig.setKeyword1( "图文复诊支付");
                    contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                    first = outpatientDO.getConsumerName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个图文复诊订单待支付,请及时支付。
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    logger.info("图文复诊订单待支付微信消息模板推送开始");
                } else if ("16".equals(type)) {
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    newConfig.setKeyword1( "视频复诊支付");
                }
                if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    newConfig.setKeyword1("图文咨询支付");
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    newConfig.setKeyword1("视频咨询支付");
                }
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 就诊支付提醒开始");
                logger.info("极光消息推送 就诊支付提醒开始");
                wxTempalteJPush("outpatient_pay",outpatientDO,null,"","","","");
            } else if ("paySuccess".equalsIgnoreCase(titelType)) {
                //诊费支付成功提示
                scene = "zfcgtx";
                //就诊支付
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_success", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    newConfig.setKeyword1( "图文复诊支付");
                    newConfig.setRemark(config.getRemark().replace("key2","图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    newConfig.setRemark(config.getRemark().replace("key2","视频复诊"));
                    newConfig.setKeyword1( "视频复诊支付");
                }
                if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    newConfig.setRemark(config.getRemark().replace("key2","图文咨询"));
                    newConfig.setKeyword1("图文咨询支付");
                    contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                    first = outpatientDO.getConsumerName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个视频复诊订单待支付,请及时支付。
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    logger.info("视频复诊订单待支付微信消息模板推送开始");
                }else if ("1".equals(type)) {
                    contentMsg = "您有一个图文咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    first = outpatientDO.getConsumerName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
                    logger.info("图文咨询订单待支付微信消息模板推送开始");
                } else if ("17".equals(type)) {
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    newConfig.setRemark(config.getRemark().replace("key2","视频咨询"));
                    newConfig.setKeyword1("视频咨询支付");
                }
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
            } else if ("doctorPick".equalsIgnoreCase(titelType)) {
                //诊费支付成功提示
                scene = "ysjzts";
                //就诊支付
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_pick", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    newConfig.setKeyword1( "图文复诊接诊");
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    newConfig.setKeyword1( "视频复诊接诊");
                    contentMsg = "您有一个视频咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    first =  outpatientDO.getConsumerName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
                    logger.info("视频咨询订单待支付微信消息模板推送开始");
                }else {
                    return;
                }
                }
                if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    newConfig.setKeyword1("图文咨询接诊");
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    newConfig.setKeyword1("视频咨询接诊");
                }
                newConfig.setRemark(config.getRemark().replace("key1",outpatientDO.getDoctorName()));
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
            }else if ("patientCancel".equalsIgnoreCase(titelType)) {
                scene = "hzqxfz";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_patient_cancel", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
            } else if ("paySuccess".equalsIgnoreCase(titelType)) {
                if ("9".equals(type)) {
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    contentMsg = "您已成功发起图文复诊,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                    first = outpatientDO.getConsumerName() + ",您好!您已成功发起图文复诊";
                }else if ("16".equals(type)) {
                    contentMsg =  "您已成功发起视频复诊,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                    first = outpatientDO.getConsumerName() + ",您好!您已成功发起视频复诊";
                }else if ("1".equals(type)) {
                }else if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                }
                newConfig.setKeyword1( outpatientDO.getHospitalName());
                newConfig.setKeyword2(outpatientDO.getDoctorName());
                newConfig.setKeyword3(outpatientDO.getFee()==null?"0":outpatientDO.getFee().toString());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() + URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送");
                    contentMsg =  "您已成功发起图文咨询,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                    first = outpatientDO.getConsumerName() + ",您好!您已成功发起图文咨询";
                }else if ("17".equals(type)) {
                    contentMsg = "您已成功发起视频咨询,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                    first = outpatientDO.getConsumerName() + ",您好!您已成功发起视频咨询";
                }else {
                    return;
                }
                logger.info("paySuccess诊查费支付成功推送模板消息:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            }else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
            }else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
                //处方开具支付提醒
                scene = "cfzfts";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_prescription_pay_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                newConfig.setKeyword1( "处方支付");
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                String path = "returnVisit/preChat?type=16&outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path) );
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 处方支付提醒开始");
                logger.info("极光消息推送 医生拒诊开始");
                wxTempalteJPush("prescription_pay",outpatientDO,null,"","","",remindMsg);
            }else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
                //视频问诊预约提醒
                scene = "spwzyytx";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                //开具处方后向患者发送支付提醒
                first = outpatientDO.getConsumerName() + ",您好! 医生已为您开具处方,请及时支付。";
                contentMsg = "医生已为您开具处方,请及时支付。";
                remark = "点击完成支付,如您已支付请忽略本条信息";
                msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId+"&id="+remindMsg;
                logger.info("处方支付微信消息模板推送开始");
            }else if ("diagnoPayRemind".equalsIgnoreCase(titelType)) {
                //开具处方后向患者发送支付提醒
                first = outpatientDO.getConsumerName() + ",您好! 您的问诊已结束,请及时结算费用。";
                contentMsg = "您好! 您的问诊已结束,请及时结算费用。";
                remark = "点击完成支付,如您已支付请忽略本条信息";
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                logger.info("诊查费微信消息模板推送开始");
            } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
                //视频复诊预约提醒
                if ("16".equals(type)) {
                if ("16".equals(type)) {
                    newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频复诊"));
                    msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=16&outpatientId="+outpatientId;
                    if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                        first = "您的视频复诊已预约成功。";
                        contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频复诊。请留意微信公众号消息。";
                    }else {
                        first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频复诊。";
                        contentMsg = "您已预约" + DateUtil.dateToStrLong(consultTeam.getCzrq()) +  "的视频复诊 与您进行视频复诊。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频复诊";
                    }
                    logger.info("视频复诊已预约成功微信消息模板推送开始");
                } else if ("17".equals(type)) {
                    if (StringUtils.isNotEmpty(outpatientId)){
                        msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=17&outpatientId="+outpatientId;
                        if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                            first = "您的视频咨询已预约成功。";
                            contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频咨询。请留意微信公众号消息。";
                        }else{
                            first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频咨询。";
                            contentMsg = "您已预约" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) +  "的视频咨询 与您进行视频咨询。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频咨询";
                        }
                    }else{
                        msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
                        contentMsg = "预计" + consDoctorDO.getName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频咨询。请留意微信公众号消息。";
                    }
                    logger.info("视频咨询已预约成功微信消息模板推送开始");
                }
                }
                if ("17".equals(type)) {
                    newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
                }
                newConfig.setKeyword1( outpatientDO.getConsumerName());
                newConfig.setKeyword2( outpatientDO.getDeptName());
                newConfig.setKeyword3( outpatientDO.getDoctorName());
                newConfig.setKeyword4(DateUtil.dateToStrLong(outpatientDO.getRegisterDate()));
                newConfig.setKeyword5(generalDoctorWaitingNumber(doctorDO.getId(), wxId, outpatientId));
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 视频问诊预约提醒开始");
                remark = "咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
            } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
            } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
                //服务评价提醒
                //服务评价提醒
                scene = "fwqjtx";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_evaluate_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replaceFirst("key1", consPatientDO.getName()));
                newConfig.setKeyword2(hospitalDO.getOrgName());
                newConfig.setKeyword3(consDoctorDO.getName());
                String path = "fuwupingjia?consultCode="+consultTeam.getConsult();
                newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                logger.info("极光消息推送 医生拒诊开始");
                wxTempalteJPush("give_score",null,consultTeam,"","","","");
                logger.info("眼科微信消息模板推送 服务评价提醒开始");
            } else if ("systemCancelRemind".equalsIgnoreCase(titelType)) {
                //系统24小时取消复诊提醒
                scene = "xtqxfz";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_system_cancel", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                }else if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                if (consultTeam.getType()!=null&&1==consultTeam.getType()){
                    first = consultTeam.getName() + ",您好!您有1条图文咨询已结束,请及时对咨询医生进行评价。";
                    logger.info("图文咨询服务评价微信消息模板推送开始");
                }else if (consultTeam.getType()!=null&&9==consultTeam.getType()){
                    first = consultTeam.getName() + ",您好!您有1条图文复诊已结束,请及时对咨询医生进行评价。";
                    logger.info("图文复诊服务评价微信消息模板推送开始");
                }else if (consultTeam.getType()!=null&&16==consultTeam.getType()){
                    first = consultTeam.getName() + ",您好!您有1条视频复诊已结束,请及时对咨询医生进行评价。";
                    logger.info("视频复诊服务评价微信消息模板推送开始");
                }else if (consultTeam.getType()!=null&&17==consultTeam.getType()){
                    first = consultTeam.getName() + ",您好!您有1条视频咨询已结束,请及时对咨询医生进行评价。";
                    logger.info("视频咨询服务评价微信消息模板推送开始");
                }else {
                    return;
                }
                }
                newConfig.setKeyword1( outpatientDO.getHospitalName());
                newConfig.setKeyword2(outpatientDO.getDoctorName());
                newConfig.setKeyword3(outpatientDO.getFee()==null?"0":outpatientDO.getFee().toString());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 系统拒诊开始");
            }
            logger.info("=======setUrl========" + newConfig.getUrl());
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            for (BasePatientWechatDo one : ps) {
                logger.info("发送的消息="+ com.alibaba.fastjson.JSONObject.toJSONString(newConfig));
                try {
                    logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+one.getOpenid());
                    weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), one.getOpenid(), newConfig);
                    logger.info("发送成功");
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.info("发送失败,error="+e.getMessage());
                contentMsg = "请对" + consDoctorDO.getName() + "医生的服务进行评价";
                msgUrl="/ims-wx/index.html#/fuwupingjia?consultCode="+consultTeam.getConsult();
            }
            if("xm_dsyy_wx".equalsIgnoreCase(wxId)){
                //暂时只发生这些
                Map<String,Integer> patientMap = new HashMap<>();
                patientMap.put("doctorRefuseRemind",1);
                patientMap.put("evaluateRemind",1);
                patientMap.put("doctorPick",1);
                patientMap.put("patientCancel",1);
                patientMap.put("systemCancelRemind",1);
                patientMap.put("prescriptionPayRemind",1);
                patientMap.put("evaluateRemind",1);
                if(patientMap.containsKey(titelType)){
                    sendSms(patientPhone,contentMsg,"1");
                }
            }else if ("xm_ykyy_wx".equalsIgnoreCase(wxId)||"sd_tnzyy_wx".equalsIgnoreCase(wxId)) {
                List<BasePatientWechatDo> ps = new ArrayList<BasePatientWechatDo>();
                if (StringUtils.isNotEmpty(outpatientId)){
                    ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getConsumer());
                }
                if (consultTeam!=null){
                    ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, consultTeam.getPatient());
                }
                }
                //保存发送模板记录,
                WxPushLogDO wxPushLogDO = new WxPushLogDO();
                wxPushLogDO.setCreateTime(new Date());
                wxPushLogDO.setOpenid(one.getOpenid());
                wxPushLogDO.setReceiver(outpatientDO.getPatient());
                wxPushLogDO.setWechatId(wechatId);
                wxPushLogDO.setReceiverName(outpatientDO.getConsumerName());
                wxPushLogDO.setScene(scene);
                wxPushLogDao.save(wxPushLogDO);
            }
                if (ps.isEmpty()) {
                    logger.info("该用户" + outpatientDO.getConsumerName() + "没有openid,无法推送模版消息,用户ID:" + outpatientDO.getPatient() + "wechatId:" + wxId);
                    return;
                }
                String scene = "";
                WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
                    //医生拒绝接诊
                    scene = "ysqxjz";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    }
                    newConfig.setKeyword1( outpatientDO.getHospitalName());
                    newConfig.setKeyword2(outpatientDO.getDoctorName());
                    newConfig.setKeyword3( doctorDO.getFee());
                    newConfig.setPagepath(newConfig.getPagepath() + "" + outpatientDO.getId());
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 医生拒诊开始");
                    logger.info("极光消息推送 医生拒诊开始");
                    wxTempalteJPush("cancel_remind",outpatientDO,null,"","","","");
                /*String res = wxTempalteJPush(outpatientDO.getConsumer(),newConfig.getFirst(),"医生拒绝了你的问诊",type,outpatientDO.getId());
                logger.info("JPUSH res==="+res);*/
                }else if("outPatientTimeOutRemind".equals(titelType)){
                    //就诊等待过长提示
                    scene="jzddgcts";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_timeout_remind", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setPagepath(newConfig.getPagepath() + "" + outpatientDO.getId());
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("就诊等待过长提示");
                } else if ("payRemind".equalsIgnoreCase(titelType)) {
                    //诊费支付提示
                    scene = "zxzfts";
                    //就诊支付
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_notice_jz", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                        newConfig.setKeyword1( "图文复诊支付");
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                        newConfig.setKeyword1( "视频复诊支付");
                    }
                    if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                        newConfig.setKeyword1("图文咨询支付");
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                        newConfig.setKeyword1("视频咨询支付");
                    }
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 就诊支付提醒开始");
                    logger.info("极光消息推送 就诊支付提醒开始");
                    wxTempalteJPush("outpatient_pay",outpatientDO,null,"","","","");
                } else if ("paySuccess".equalsIgnoreCase(titelType)) {
                    //诊费支付成功提示
                    scene = "zfcgtx";
                    //就诊支付
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_success", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                        newConfig.setKeyword1( "图文复诊支付");
                        newConfig.setRemark(config.getRemark().replace("key2","图文复诊"));
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                        newConfig.setRemark(config.getRemark().replace("key2","视频复诊"));
                        newConfig.setKeyword1( "视频复诊支付");
                    }
                    if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                        newConfig.setRemark(config.getRemark().replace("key2","图文咨询"));
                        newConfig.setKeyword1("图文咨询支付");
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                        newConfig.setRemark(config.getRemark().replace("key2","视频咨询"));
                        newConfig.setKeyword1("视频咨询支付");
                    }
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                } else if ("doctorPick".equalsIgnoreCase(titelType)) {
                    //诊费支付成功提示
                    scene = "ysjzts";
                    //就诊支付
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_pick", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                        newConfig.setKeyword1( "图文复诊接诊");
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                        newConfig.setKeyword1( "视频复诊接诊");
                    }
                    if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                        newConfig.setKeyword1("图文咨询接诊");
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                        newConfig.setKeyword1("视频咨询接诊");
                    }
                    newConfig.setRemark(config.getRemark().replace("key1",outpatientDO.getDoctorName()));
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                }else if ("patientCancel".equalsIgnoreCase(titelType)) {
                    scene = "hzqxfz";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_patient_cancel", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    }else if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    }
                    newConfig.setKeyword1( outpatientDO.getHospitalName());
                    newConfig.setKeyword2(outpatientDO.getDoctorName());
                    newConfig.setKeyword3(outpatientDO.getFee()==null?"0":outpatientDO.getFee().toString());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() + URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送");
                }else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
                    //处方开具支付提醒
                    scene = "cfzfts";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_prescription_pay_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    newConfig.setKeyword1( "处方支付");
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    String path = "returnVisit/preChat?type=16&outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path) );
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 处方支付提醒开始");
                    logger.info("极光消息推送 医生拒诊开始");
                    wxTempalteJPush("prescription_pay",outpatientDO,null,"","","",remindMsg);
                }else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
                    //视频问诊预约提醒
                    scene = "spwzyytx";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    if ("16".equals(type)) {
                        newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频复诊"));
                    }
                    if ("17".equals(type)) {
                        newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
                    }
                    newConfig.setKeyword1( outpatientDO.getConsumerName());
                    newConfig.setKeyword2( outpatientDO.getDeptName());
                    newConfig.setKeyword3( outpatientDO.getDoctorName());
                    newConfig.setKeyword4(DateUtil.dateToStrLong(outpatientDO.getRegisterDate()));
                    newConfig.setKeyword5(generalDoctorWaitingNumber(doctorDO.getId(), wxId, outpatientId));
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 视频问诊预约提醒开始");
                } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
                    //服务评价提醒
                    scene = "fwqjtx";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_evaluate_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replaceFirst("key1", consPatientDO.getName()));
                    newConfig.setKeyword2(hospitalDO.getOrgName());
                    newConfig.setKeyword3(consDoctorDO.getName());
                    String path = "fuwupingjia?consultCode="+consultTeam.getConsult();
                    newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                    logger.info("极光消息推送 医生拒诊开始");
                    wxTempalteJPush("give_score",null,consultTeam,"","","","");
                    logger.info("眼科微信消息模板推送 服务评价提醒开始");
                } else if ("systemCancelRemind".equalsIgnoreCase(titelType)) {
                    //系统24小时取消复诊提醒
                    scene = "xtqxfz";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_system_cancel", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    }else if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    }
                    newConfig.setKeyword1( outpatientDO.getHospitalName());
                    newConfig.setKeyword2(outpatientDO.getDoctorName());
                    newConfig.setKeyword3(outpatientDO.getFee()==null?"0":outpatientDO.getFee().toString());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 系统拒诊开始");
                }
                logger.info("=======setUrl========" + newConfig.getUrl());
                WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
                for (BasePatientWechatDo one : ps) {
                    logger.info("发送的消息="+ com.alibaba.fastjson.JSONObject.toJSONString(newConfig));
                    try {
                        logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+one.getOpenid());
                        weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), one.getOpenid(), newConfig);
                        logger.info("发送成功");
                    } catch (Exception e) {
                        e.printStackTrace();
                        logger.info("发送失败,error="+e.getMessage());
                    }
        } else if ("xm_xzzx_wx".equalsIgnoreCase(wxId)) {
            String responseMsg="";
            //String prefix="https://www.xmheart.com";
            String prefix = "https://ih.xmheart.com/hlwyy";
            if(StringUtils.isNotEmpty(outpatientId)){
                responseMsg = xzzxEntranceService.sendMes(wxId,
                        patientDO.getId(),
                        patientDO.getIdcard(),
                        first,
                        contentMsg,
                        remark,
                        prefix+msgUrl);
            }
            if (consultTeam!=null&&consPatientDO!=null){
                responseMsg = xzzxEntranceService.sendMes(wxId,
                        consPatientDO.getId(),
                        consPatientDO.getIdcard(),
                        first,
                        contentMsg,
                        remark,
                        prefix+msgUrl);
            }
            logger.info("url="+prefix+msgUrl);
            String msg="first:"+first+"contentMsg:"+contentMsg+"remark:"+remark;
            logger.info("发送的信息="+msg);
            logger.info("XZZX_Msg_" + titelType + "=" + responseMsg);
        } else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            String responseMsg="";
            String prefix="https://hlwyy.xmzsh.com";
            if(StringUtils.isNotEmpty(outpatientId)){
                responseMsg = entranceService.ehospitalNotice(
                        patientDO.getName(),
                        patientDO.getIdcard(),
                        patientDO.getMobile(),
                        first,
                        prefix+msgUrl,
                        contentMsg,
                        remark
                );
                System.out.println("结束发送模板消息");
            }
            if (consultTeam!=null&&consPatientDO!=null){
                responseMsg = entranceService.ehospitalNotice(
                        consPatientDO.getName(),
                        consPatientDO.getIdcard(),
                        consPatientDO.getMobile(),
                        first,
                        prefix+msgUrl,
                        contentMsg,
                        remark
                );
                    //保存发送模板记录,
                    WxPushLogDO wxPushLogDO = new WxPushLogDO();
                    wxPushLogDO.setCreateTime(new Date());
                    wxPushLogDO.setOpenid(one.getOpenid());
                    wxPushLogDO.setReceiver(outpatientDO.getPatient());
                    wxPushLogDO.setWechatId(wechatId);
                    wxPushLogDO.setReceiverName(outpatientDO.getConsumerName());
                    wxPushLogDO.setScene(scene);
                    wxPushLogDao.save(wxPushLogDO);
                }
            } else if ("xm_xzzx_wx".equalsIgnoreCase(wxId)) {
                String responseMsg="";
                //String prefix="https://www.xmheart.com";
                String prefix = "https://ih.xmheart.com/hlwyy";
                if(StringUtils.isNotEmpty(outpatientId)){
                    responseMsg = xzzxEntranceService.sendMes(wxId,
                            patientDO.getId(),
                            patientDO.getIdcard(),
                            first,
                            contentMsg,
                            remark,
                            prefix+msgUrl);
                }
                if (consultTeam!=null&&consPatientDO!=null){
                    responseMsg = xzzxEntranceService.sendMes(wxId,
                            consPatientDO.getId(),
                            consPatientDO.getIdcard(),
                            first,
                            contentMsg,
                            remark,
                            prefix+msgUrl);
                }
                logger.info("url="+prefix+msgUrl);
                String msg="first:"+first+"contentMsg:"+contentMsg+"remark:"+remark;
                logger.info("发送的信息="+msg);
                logger.info("XZZX_Msg_" + titelType + "=" + responseMsg);
            } else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
                String responseMsg="";
                String prefix="https://hlwyy.xmzsh.com";
                if(StringUtils.isNotEmpty(outpatientId)){
                    responseMsg = entranceService.ehospitalNotice(
                            patientDO.getName(),
                            patientDO.getIdcard(),
                            patientDO.getMobile(),
                            first,
                            prefix+msgUrl,
                            contentMsg,
                            remark
                    );
                    System.out.println("结束发送模板消息");
                }
                if (consultTeam!=null&&consPatientDO!=null){
                    responseMsg = entranceService.ehospitalNotice(
                            consPatientDO.getName(),
                            consPatientDO.getIdcard(),
                            consPatientDO.getMobile(),
                            first,
                            prefix+msgUrl,
                            contentMsg,
                            remark
                    );
                }
                logger.info("url="+prefix+msgUrl);
                String msg="first:"+first+"-----contentMsg:"+contentMsg+"-----remark:"+remark;
                logger.info("发送的信息="+msg);
                logger.info("ZSYY_Msg" + titelType + "=" + responseMsg);
            }
            }
            logger.info("url="+prefix+msgUrl);
            String msg="first:"+first+"-----contentMsg:"+contentMsg+"-----remark:"+remark;
            logger.info("发送的信息="+msg);
            logger.info("ZSYY_Msg" + titelType + "=" + responseMsg);
        }catch (Exception e){
            e.printStackTrace();
        }
        }
    }
    }
@ -8956,6 +8985,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        String msg = "";
        String msg = "";
        try {
        try {
            JSONObject data = new JSONObject();
            JSONObject data = new JSONObject();
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient()).orElse(null);
            String title = "";
            //1.在线复诊2.协同门诊
            //1.在线复诊2.协同门诊
            if ("2".equals(outpatient.getOutpatientType())) {
            if ("2".equals(outpatient.getOutpatientType())) {
                systemMessageDO.setTitle("协同门诊");
                systemMessageDO.setTitle("协同门诊");
@ -8975,7 +9006,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setData(data.toString());
                systemMessageDO.setData(data.toString());
                logger.info("添加模板消息4");
                logger.info("添加模板消息4");
                systemMessageService.saveMessage(systemMessageDO);
                systemMessageService.saveMessage(systemMessageDO);
                BasePatientDO patient = basePatientDao.findById(outpatient.getPatient()).orElse(null);
                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                }
                }
@ -8988,11 +9019,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        saveInquirySystemMessage(outpatient,null);
                        saveInquirySystemMessage(outpatient,null);
                    }
                    }
                    msg="图文咨询";
                    msg="图文咨询";
                    title="图文咨询";
                } else if("3".equals(outpatient.getType())){
                } else if("3".equals(outpatient.getType())){
                    systemMessageDO.setTitle("家医咨询");
                    systemMessageDO.setTitle("家医咨询");
                    systemMessageDO.setType("15");
                    systemMessageDO.setType("15");
                    msg="家医咨询";
                    msg="家医咨询";
                    title="家医咨询";
                    if (payFlag){
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                        saveInquirySystemMessage(outpatient,null);
                    }
                    }
@ -9002,6 +9035,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    if (payFlag){
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                        saveInquirySystemMessage(outpatient,null);
                    }
                    }
                    title = "视频咨询";
                    msg = "您的视频咨询已预约成功。\n" +
                    msg = "您的视频咨询已预约成功。\n" +
                            "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                            "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                    sendWxTemplateMsg(wechatId, outpatient.getId(),null, "17", "videoOrderRemind", "");
                    sendWxTemplateMsg(wechatId, outpatient.getId(),null, "17", "videoOrderRemind", "");
@ -9022,10 +9056,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setData(data.toString());
                systemMessageDO.setData(data.toString());
                logger.info("添加模板消息4");
                logger.info("添加模板消息4");
                systemMessageService.saveMessage(systemMessageDO);
                systemMessageService.saveMessage(systemMessageDO);
                BasePatientDO patient = basePatientDao.findById(outpatient.getPatient()).orElse(null);
                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                }
                }
                if("xm_dsyy_wx".equalsIgnoreCase(wechatId)){
                    sendSms(patient.getMobile(),"医生您好,患者"+outpatient.getPatientName()+"向您发起了"+title+",请及时查看","2");
                }
            } else if ("1".equals(outpatient.getOutpatientType()))  {        //在线复诊
            } else if ("1".equals(outpatient.getOutpatientType()))  {        //在线复诊
                //1.图文 2.视频
                //1.图文 2.视频
                if ("1".equals(outpatient.getType())) {
                if ("1".equals(outpatient.getType())) {
@ -9051,6 +9087,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                                wlyyHttpLogDao.save(wlyyHttpLogDO);
                                wlyyHttpLogDao.save(wlyyHttpLogDO);
                            }
                            }
                        }
                        }
                    }else  if("xm_dsyy_wx".equalsIgnoreCase(wechatId)){
                        sendSms(patient.getMobile(),"医生您好,患者"+outpatient.getPatientName()+"向您发起了图文问诊,请及时查看","2");
                    }
                    }
                } else {
                } else {
                    systemMessageDO.setTitle("视频复诊预约成功");
                    systemMessageDO.setTitle("视频复诊预约成功");
@ -9081,7 +9119,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setData(data.toString());
                systemMessageDO.setData(data.toString());
                systemMessageService.saveMessage(systemMessageDO);
                systemMessageService.saveMessage(systemMessageDO);
            }
            }
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient()).orElse(null);
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
            }
            }

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/knowledge/service/BaseKnowledgeDictService.java

@ -263,6 +263,8 @@ public class BaseKnowledgeDictService extends BaseJpaService<BaseKnowledgeDict,
        if (status==0){
        if (status==0){
            dictRelationDao.deleteByDictId(baseKnowledgeDictRelation.getDictId());
            dictRelationDao.deleteByDictId(baseKnowledgeDictRelation.getDictId());
        }else {
        }else {
            dictRelationDao.deleteByDictId(baseKnowledgeDictRelation.getDictId());
            baseKnowledgeDictRelation.setId(null);
            baseKnowledgeDictRelation.setUpdateTime(new Date());
            baseKnowledgeDictRelation.setUpdateTime(new Date());
            baseKnowledgeDictRelation.setCreateTime(new Date());
            baseKnowledgeDictRelation.setCreateTime(new Date());
            dictRelationDao.save(baseKnowledgeDictRelation);
            dictRelationDao.save(baseKnowledgeDictRelation);

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

@ -0,0 +1,13 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.patient.BasePatientDischargeRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/8/31.
 */
public interface BasePatientDischargeRecordDao extends PagingAndSortingRepository<BasePatientDischargeRecord, String>, JpaSpecificationExecutor<BasePatientDischargeRecord> {
}

+ 33 - 0
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientDischargeRecordService.java

@ -0,0 +1,33 @@
package com.yihu.jw.patient.service;
import com.yihu.jw.entity.patient.BasePatientDischargeRecord;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.patient.dao.BasePatientDischargeRecordDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
 * 
 * 患者出院记录service
 *
 */
@Service
public class BasePatientDischargeRecordService<T, R extends CrudRepository> extends BaseJpaService<BasePatientDischargeRecord, BasePatientDischargeRecordDao> {
    private static final Logger logger = LoggerFactory.getLogger(BasePatientDischargeRecordService.class);
    @Autowired
    private BasePatientDischargeRecordDao patientDischargeRecordDao;
    public BasePatientDischargeRecord pushPatientInfos(String idcard,String content){
        BasePatientDischargeRecord patientDischargeRecord = new BasePatientDischargeRecord();
        patientDischargeRecord.setIdcard(idcard);
        patientDischargeRecord.setContent(content);
        patientDischargeRecord.setCreateTime(new Date());
        return patientDischargeRecordDao.save(patientDischargeRecord);
    }
}

+ 218 - 0
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -6079,6 +6079,7 @@ public class StatisticsEsService {
     * 【总收入】= 诊查费(21) + 处方费(3)
     * 【总收入】= 诊查费(21) + 处方费(3)
     * 【问诊量】= 用户成功发起问诊量,包含取消的订单(同一人发起多次累计多次)   【接诊率】= 接诊量 ÷ 问诊量 ×100%
     * 【问诊量】= 用户成功发起问诊量,包含取消的订单(同一人发起多次累计多次)   【接诊率】= 接诊量 ÷ 问诊量 ×100%
     * 【处方量】= 成功接诊后开方数量 【处方率】= 处方量 ÷ 接诊量 ×100%
     * 【处方量】= 成功接诊后开方数量 【处方率】= 处方量 ÷ 接诊量 ×100%
     * 门诊转住院:医生登记住院申请的次数
     */
     */
    public JSONObject getTotal3Data(ScreenQvo qvo) throws Exception {
    public JSONObject getTotal3Data(ScreenQvo qvo) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
@ -6135,6 +6136,7 @@ public class StatisticsEsService {
        //去年同期时间
        //去年同期时间
        List<SaveModel> jz_model03 = elasticsearchUtil.findListDateQuotaLevel2(periodYear[0], periodYear[1], qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
        List<SaveModel> jz_model03 = elasticsearchUtil.findListDateQuotaLevel2(periodYear[0], periodYear[1], qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
        /**
        /**
         *  计算同比和环比
         *  计算同比和环比
         *  环比增长= (本期统计周期数据-上期统计周期数据)上期统计周期数据×100%
         *  环比增长= (本期统计周期数据-上期统计周期数据)上期统计周期数据×100%
@ -6182,6 +6184,44 @@ public class StatisticsEsService {
        result.put("kf_kfl", getRange(kf_total, patientVolume, 0));//【处方率】= 处方量 ÷ 接诊量 ×100%
        result.put("kf_kfl", getRange(kf_total, patientVolume, 0));//【处方率】= 处方量 ÷ 接诊量 ×100%
        result.put("kf_hb", getRange((kf_total - kf_period), kf_period, 0));//环比
        result.put("kf_hb", getRange((kf_total - kf_period), kf_period, 0));//环比
        result.put("kf_tb", getRange((kf_total - kf_periodYear), kf_periodYear, 0));//同比
        result.put("kf_tb", getRange((kf_total - kf_periodYear), kf_periodYear, 0));//同比
        if("1".equals(qvo.getType())){
            //门诊转住院
            String sql = "select COUNT(DISTINCT r.id) from wlyy_outpatient_hospitalization r,base_doctor_hospital bdh,base_doctor bd,dict_hospital_dept hd " +
                    "WHERE r.doctor=bdh.doctor_code and bdh.doctor_code = bd.id AND hd.code= bdh.dept_code " +
                    "AND bdh.del=1 AND hd.CONSULT_DEPT_FLAG='1' AND bd.job_title_code IN('1201','1301','1401','1101','066','067','061','1310','061','065','1','2','3','4') ";
            //本周期
            String sql01 = sql + " and r.create_time>='"+qvo.getStartDate()+"' and r.create_time<='"+qvo.getEndDate()+" 23:59:59'";
            //上个周期
            String sql02 = sql + " and r.create_time>='"+period[0]+"' and r.create_time<='"+period[1]+" 23:59:59'";
            //去年同期
            String sql03 = sql + " and r.create_time>='"+periodYear[0]+"' and r.create_time<='"+periodYear[1]+" 23:59:59'";
            if("5".equals(qvo.getLevel())){
                //科室
                sql01 += " and hd.code='"+qvo.getArea()+"' ";
                sql02 += " and hd.code='"+qvo.getArea()+"' ";
                sql03 += " and hd.code='"+qvo.getArea()+"' ";
            }
            if("6".equals(qvo.getLevel())){
                //医生
                sql01 += " and r.doctor='"+qvo.getArea()+"' ";
                sql02 += " and r.doctor='"+qvo.getArea()+"' ";
                sql03 += " and r.doctor='"+qvo.getArea()+"' ";
            }
            //已接诊的复诊数
            String sql04 = sql01.replace("wlyy_outpatient_hospitalization","wlyy_outpatient");
            sql04 += " and r.status IN(1,2,3) and r.outpatient_type !='3' ";
            Integer hospitalization01 = jdbcTemplate.queryForObject(sql01,Integer.class);
            Integer hospitalization02 = jdbcTemplate.queryForObject(sql02,Integer.class);
            Integer hospitalization03 = jdbcTemplate.queryForObject(sql03,Integer.class);
            Integer hospitalization04 = jdbcTemplate.queryForObject(sql04,Integer.class);
            result.put("ar_total", hospitalization01);//门诊转住院量
            result.put("ar_kfl", getRange(hospitalization01, hospitalization04, 0));//【转化率】= 门诊转住院量 ÷ 已接诊的复诊数 ×100%
            result.put("ar_hb", getRange((hospitalization01 - hospitalization02), hospitalization02, 0));//环比
            result.put("ar_tb", getRange((hospitalization01 - hospitalization03), hospitalization03, 0));//同比
        }
        return result;
        return result;
    }
    }
@ -6608,6 +6648,184 @@ public class StatisticsEsService {
        return result;
        return result;
    }
    }
    /**
     * 业务情况说明
     * 1、【问诊量】= 用户成功发起问诊量,包含取消的订单(同一人发起多次累计多次);
     * 2、问诊类型:支持管理员点击问诊类型的颜色,展示该问诊类型占问诊量的百分比。
     * 3、【处方量】 = 成功接诊开放的数量;
     * 4、【接诊率】 = 接诊量 ÷ 问诊量 × 100%;
     * 5、【问诊转住院】 = 医生登记住院申请的次数;
     * 6、同比增长:(本期统计周期数据-去年同期统计周期数据)去年同期统计周期数据× 100%;
     * 7、环比增长:(本期统计周期数据 - 上期统计周期数据)上期统计周期数据× 100%;
     */
    public JSONObject businessSituation(ScreenQvo qvo){
        JSONObject json = new JSONObject();
        // 计算上一个周期  开始时间period[0] 、结束时间period[1]
        String[] period = calculatePreviousPeriod(qvo.getStartDate(), qvo.getEndDate());
        //计算去年同期时间段 开始时间periodYear[0] 、结束时间periodYear[1]
        String[] periodYear = calculatePreviousYearPeriod(qvo.getStartDate(), qvo.getEndDate());
        return json;
    }
    /**
     * 收入情况
     1、【总收入】=药品费+诊查费;
     2、【药品费】=患者支付的处方费用;
     3、【诊查费】=图文门诊+图文咨询+视频问诊+视频咨询+社区协诊;
     4、同比增长:(本期统计周期数据-去年同期统计周期数据)去年同期统计周期数据× 100%;
     5、环比增长:(本期统计周期数据 - 上期统计周期数据)上期统计周期数据× 100%;
     6、图文问诊、图文咨询、视频问诊、视频咨询、社区协诊=患者支付的属于该类型的诊查费;
     7、环形图,支持管理员点击颜色,显示所属类别占总收入的百分比;
     8、点击【查看更多】按钮,页面跳转至「收入分析」页。
     */
    public JSONObject incomeSituation(ScreenQvo qvo) throws Exception{
        JSONObject json = new JSONObject();
        // 计算上一个周期  开始时间period[0] 、结束时间period[1]
        String[] period = calculatePreviousPeriod(qvo.getStartDate(), qvo.getEndDate());
        //计算去年同期时间段 开始时间periodYear[0] 、结束时间periodYear[1]
        String[] periodYear = calculatePreviousYearPeriod(qvo.getStartDate(), qvo.getEndDate());
        String lowLevel = "2";
        String index3 = "3";//处方费/药品费
        String index21 = "21";//诊查费
        //图文问诊、图文咨询、视频问诊、视频咨询、社区协诊=患者支付的属于该类型的诊查费
        //药品费
        double ypFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index3, SaveModel.timeLevel_ZL, null, null, null,lowLevel);
        //上一个周期
        double ypFee_l1 = findResult1BySaveModelList(period[0], period[1], qvo.getArea(),
                qvo.getLevel(), index3, SaveModel.timeLevel_ZL, null, null, null,lowLevel);
        //去年同期
        double ypFee_l2 = findResult1BySaveModelList(periodYear[0], periodYear[1], qvo.getArea(),
                qvo.getLevel(), index3, SaveModel.timeLevel_ZL, null, null, null,lowLevel);
        //诊查费
        double zcFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, null, null, null,lowLevel);
        //上一个周期
        double zcFee_l1 = findResult1BySaveModelList(period[0], period[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, null, null, null,lowLevel);
        //去年同期
        double zcFee_l2 = findResult1BySaveModelList(periodYear[0], periodYear[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, null, null, null,lowLevel);
        //总收入
        double totalFee = ypFee+zcFee;
        double totalFee_l1 = ypFee_l1+zcFee_l1;
        double totalFee_l2 = ypFee_l2+zcFee_l2;
        //图文问诊
        double ppFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "1", "1", null,lowLevel);
        //上一个周期
        double ppFee_l1 = findResult1BySaveModelList(period[0], period[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "1", "1", null,lowLevel);
        //去年同期
        double ppFee_l2 = findResult1BySaveModelList(periodYear[0], periodYear[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "1", "1", null,lowLevel);
        //图文咨询
        double pcFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "3", "1", null,lowLevel);
        //上一个周期
        double pcFee_l1 = findResult1BySaveModelList(period[0], period[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "3", "1", null,lowLevel);
        //去年同期
        double pcFee_l2 = findResult1BySaveModelList(periodYear[0], periodYear[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "3", "1", null,lowLevel);
        //视频问诊
        double vpFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "1", "2", null,lowLevel);
        //上一个周期
        double vpFee_l1 = findResult1BySaveModelList(period[0], period[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "1", "2", null,lowLevel);
        //去年同期
        double vpFee_l2 = findResult1BySaveModelList(periodYear[0], periodYear[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "1", "2", null,lowLevel);
        //视频咨询
        double vcFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "3", "2", null,lowLevel);
        //上一个周期
        double vcFee_l1 = findResult1BySaveModelList(period[0], period[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "3", "2", null,lowLevel);
        //去年同期
        double vcFee_l2 = findResult1BySaveModelList(periodYear[0], periodYear[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "3", "2", null,lowLevel);
        //社区协诊
        double sxFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "2", null, null,lowLevel);
        //上一个周期
        double sxFee_l1 = findResult1BySaveModelList(period[0], period[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "2", null, null,lowLevel);
        //去年同期
        double sxFee_l2 = findResult1BySaveModelList(periodYear[0], periodYear[1], qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "2", null, null,lowLevel);
        json.put("ypFee",ypFee);
        json.put("ypFee_hb", getDoubleRange((ypFee - ypFee_l1), ypFee_l1, 0));//环比
        json.put("ypFee_tb", getDoubleRange((ypFee - ypFee_l2), ypFee_l2, 0));//同比
        json.put("zcFee",zcFee);
        json.put("zcFee_hb", getDoubleRange((zcFee - zcFee_l1), zcFee_l1, 0));//环比
        json.put("zcFee_tb", getDoubleRange((zcFee - zcFee_l2), zcFee_l2, 0));//同比
        json.put("totalFee",totalFee);
        json.put("totalFee_hb", getDoubleRange((totalFee - totalFee_l1), totalFee_l1, 0));//环比
        json.put("totalFee_tb", getDoubleRange((totalFee - totalFee_l2), totalFee_l2, 0));//同比
        json.put("ppFee",ppFee);
        json.put("ppFee_hb", getDoubleRange((ppFee - ppFee_l1), ppFee_l1, 0));//环比
        json.put("ppFee_tb", getDoubleRange((ppFee - ppFee_l2), ppFee_l2, 0));//同比
        json.put("pcFee",pcFee);
        json.put("pcFee_hb", getDoubleRange((pcFee - pcFee_l1), pcFee_l1, 0));//环比
        json.put("pcFee_tb", getDoubleRange((pcFee - pcFee_l2), pcFee_l2, 0));//同比
        json.put("vpFee",vpFee);
        json.put("vpFee_hb", getDoubleRange((vpFee - vpFee_l1), vpFee_l1, 0));//环比
        json.put("vpFee_tb", getDoubleRange((vpFee - vpFee_l2), vpFee_l2, 0));//同比
        json.put("vcFee",vcFee);
        json.put("vcFee_hb", getDoubleRange((vcFee - vcFee_l1), vcFee_l1, 0));//环比
        json.put("vcFee_tb", getDoubleRange((vcFee - vcFee_l2), vcFee_l2, 0));//同比
        json.put("sxFee",sxFee);
        json.put("sxFee_hb", getDoubleRange((sxFee - sxFee_l1), sxFee_l1, 0));//环比
        json.put("sxFee_tb", getDoubleRange((sxFee - sxFee_l2), sxFee_l2, 0));//同比
        return json;
    }
    public SaveModel findOneBySaveModelList(String startDate, String endDate, String area, int level, String index, String timeLevel,
                                            String slaveKey1, String slaveKey2, String interval, String lowLevel){
        List<SaveModel> list = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area,
                level, index, timeLevel, slaveKey1, slaveKey2,interval,lowLevel);
        if(list.size()>0){
            return list.get(0);
        }
        SaveModel saveModel = new SaveModel();
        saveModel.setResult1(0d);
        saveModel.setResult2(0d);
        return saveModel;
    }
    public Double findResult1BySaveModelList(String startDate, String endDate, String area, int level, String index, String timeLevel,
                                            String slaveKey1, String slaveKey2, String interval, String lowLevel){
        List<SaveModel> list = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area,
                level, index, timeLevel, slaveKey1, slaveKey2,interval,lowLevel);
        if(list.size()>0){
            return list.get(0).getResult1();
        }
        return 0d;
    }
    public Double findResult2BySaveModelList(String startDate, String endDate, String area, int level, String index, String timeLevel,
                                             String slaveKey1, String slaveKey2, String interval, String lowLevel){
        List<SaveModel> list = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area,
                level, index, timeLevel, slaveKey1, slaveKey2,interval,lowLevel);
        if(list.size()>0){
            return list.get(0).getResult2();
        }
        return 0d;
    }
    /**
    /**
     * 导出
     * 导出
     * 获取全部的科室和医生数据
     * 获取全部的科室和医生数据

+ 1 - 1
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -1609,7 +1609,7 @@ public class ElasticsearchUtil {
            }
            }
        }
        }
        sql.append(groupBy);
        sql.append(groupBy);
        //logger.info("sql :" + sql.toString());
        logger.info("sql :" + sql.toString());
        return excuteEs7(sql.toString(), SaveModel.class, "", "");
        return excuteEs7(sql.toString(), SaveModel.class, "", "");
    }
    }

Разница между файлами не показана из-за своего большого размера
+ 3 - 4
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java


+ 62 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceDetail.java

@ -27,6 +27,8 @@ public class DeviceDetail extends IdEntity {
    private String serverIp;//服务IP地址
    private String serverIp;//服务IP地址
    private String manufacturerCode;//厂商代码threeNod:三诺 urion:优瑞恩 bioland:爱奥乐 comvee:康为
    private String manufacturerCode;//厂商代码threeNod:三诺 urion:优瑞恩 bioland:爱奥乐 comvee:康为
    private String address;//厂家地址
    private String address;//厂家地址
    private String dept;//投放科室编码
    private String deptName;//投放科室名称
    private String representative;//法人代表
    private String representative;//法人代表
    private String applicantName;//申请注册人(发放人/医生)
    private String applicantName;//申请注册人(发放人/医生)
    private String applicantIdentity;//申请人(发放人/医生)身份证号
    private String applicantIdentity;//申请人(发放人/医生)身份证号
@ -59,6 +61,12 @@ public class DeviceDetail extends IdEntity {
    private String qrcode;//二维码地址
    private String qrcode;//二维码地址
    //非数据库字段
    private String applyStatus;//1申请解绑
    private String type;//类型 1血糖 2血压
    private String patientName;//居民姓名
    private String photo;//设备照片
    //导入设备错误信息
    //导入设备错误信息
    private String errorMsg;
    private String errorMsg;
    private Map<String,String> errorMsgMap = new HashMap<>();
    private Map<String,String> errorMsgMap = new HashMap<>();
@ -427,4 +435,58 @@ public class DeviceDetail extends IdEntity {
    public void setQrcode(String qrcode) {
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
        this.qrcode = qrcode;
    }
    }
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Transient
    public String getApplyStatus() {
        return applyStatus;
    }
    public void setApplyStatus(String applyStatus) {
        this.applyStatus = applyStatus;
    }
    @Transient
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Transient
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Transient
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
}
}

+ 21 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientDevice.java

@ -89,6 +89,9 @@ public class DevicePatientDevice extends IdEntity {
     */
     */
    private String safeAreaGz;
    private String safeAreaGz;
    private String dept;//绑定时的投放科室
    private String deptName;//
    @Column(name = "device_id")
    @Column(name = "device_id")
    public Long getDeviceId() {
    public Long getDeviceId() {
        return deviceId;
        return deviceId;
@ -361,4 +364,22 @@ public class DevicePatientDevice extends IdEntity {
    public void setSafeAreaGz(String safeAreaGz) {
    public void setSafeAreaGz(String safeAreaGz) {
        this.safeAreaGz = safeAreaGz;
        this.safeAreaGz = safeAreaGz;
    }
    }
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
}
}

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

@ -56,6 +56,8 @@ public class DevicePatientHealthIndex extends IdEntity {
	private String name;//居民姓名
	private String name;//居民姓名
	private String hospital;//医院
	private String hospital;//医院
	private String hospitalName;//医院名称
	private String hospitalName;//医院名称
	private String dept;//科室code
	private String deptName;//科室名称
	private Integer isUpload;//是否上传物联网 0和null否 1是,2失败
	private Integer isUpload;//是否上传物联网 0和null否 1是,2失败
@ -258,4 +260,20 @@ public class DevicePatientHealthIndex extends IdEntity {
	public void setIsUpload(Integer isUpload) {
	public void setIsUpload(Integer isUpload) {
		this.isUpload = isUpload;
		this.isUpload = isUpload;
	}
	}
	public String getDept() {
		return dept;
	}
	public void setDept(String dept) {
		this.dept = dept;
	}
	public String getDeptName() {
		return deptName;
	}
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
}
}

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

@ -50,7 +50,7 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
    private String conNo;
    private String conNo;
    /**
    /**
     * 1.在线复诊2.协同门诊
     * 1.在线复诊2.协同门诊 3.专家咨询 4为上门复诊
     */
     */
    private String outpatientType;
    private String outpatientType;
    /**
    /**

+ 51 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/patient/BasePatientDischargeRecord.java

@ -0,0 +1,51 @@
package com.yihu.jw.entity.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 患者出院记录信息
 *
 * @author George
 */
@Entity
@Table(name = "base_patient_discharge_record")
public class BasePatientDischargeRecord extends UuidIdentityEntity {
    private String idcard;
    private String content;
    // 创建时间
    private Date createTime;
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    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")
    @Column(name = "create_time", nullable = false, length = 0,updatable = false)
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 1 - 1
starter/elasticsearch-starter/src/main/java/com/yihu/jw/elasticsearch/ElasticSearch7Pool.java

@ -95,7 +95,7 @@ public class ElasticSearch7Pool {
    public ResultSet restHighLevelClientStream(String sql) throws Exception {
    public ResultSet restHighLevelClientStream(String sql) throws Exception {
//        Connection connection = DriverManager.getConnection("jdbc:es://http://172.26.0.55:9200","elastic","elastic");
//        Connection connection = DriverManager.getConnection("jdbc:es://http://172.26.0.55:9200","elastic","elastic");
//        Connection connection = DriverManager.getConnection("jdbc:es://http://172.26.0.168:9200/","elastic","elastic");
//        Connection connection = DriverManager.getConnection("jdbc:es://http://172.26.0.168:9200/","elastic","elastic");
        System.out.println("连接地址==>hosts:" + hosts + " es账号密码==>userName:" + userName + "   -------------  password:" + password);
//        System.out.println("连接地址==>hosts:" + hosts + " es账号密码==>userName:" + userName + "   -------------  password:" + password);
        Connection connection = DriverManager.getConnection("jdbc:es://" + hosts, userName, password);
        Connection connection = DriverManager.getConnection("jdbc:es://" + hosts, userName, password);
        Statement statement = connection.createStatement();
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);
        ResultSet resultSet = statement.executeQuery(sql);

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

@ -6,6 +6,7 @@ import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
import com.yihu.jw.order.pay.ylz.YlzPayService;
import com.yihu.jw.order.pay.ylz.YlzPayService;
import com.yihu.jw.patient.service.BasePatientDischargeRecordService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -33,6 +34,17 @@ public class DsyyController extends EnvelopRestEndpoint {
    private DsyyEntranceService dsyyEntranceService;
    private DsyyEntranceService dsyyEntranceService;
    @Autowired
    @Autowired
    private YlzPayService ylzPayService;
    private YlzPayService ylzPayService;
    @Autowired
    private BasePatientDischargeRecordService patientDischargeRecordService;
    @PostMapping(value = "open/noLogin/pushPatientInfos")
    @ApiOperation(value = "确认居民下推接口(调互联网医院接口)", notes = "确认居民下推接口(调互联网医院接口)")
    public Envelop pushPatientInfos(@ApiParam(name = "idcard", value = "患者身份证")
                                    @RequestParam(value = "idcard", required = true)String idcard,
                                    @ApiParam(name = "content", value = "患者出院记录")
                                    @RequestParam(value = "content", required = true)String content) throws Exception {
        return success(patientDischargeRecordService.pushPatientInfos(idcard,content));
    }
    @GetMapping(value = "/createSQLQuery")
    @GetMapping(value = "/createSQLQuery")
    @ApiOperation(value = "视图统一查询")
    @ApiOperation(value = "视图统一查询")

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

@ -347,6 +347,8 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			return success("操作成功",result);
			return success("操作成功",result);
	}
	}
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.refundRegisterNo)
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.refundRegisterNo)
	@ApiOperation(value = "退号", notes = "退号")
	@ApiOperation(value = "退号", notes = "退号")
	public Envelop refundRegisterNo(@ApiParam(name = "outpatientCode", value = "就诊记录code", defaultValue = "1")
	public Envelop refundRegisterNo(@ApiParam(name = "outpatientCode", value = "就诊记录code", defaultValue = "1")

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

@ -13,6 +13,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import java.net.URLDecoder;
import java.net.URLDecoder;
@ -35,6 +36,34 @@ public class DsyyPrescriptionCotroller extends EnvelopRestEndpoint {
    private ElasticsearchUtil elasticsearchUtil;
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    @Autowired
    private ElasticSearch7Util elasticSearch7Util;
    private ElasticSearch7Util elasticSearch7Util;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @PostMapping(value = "open/exportExcel/dmSql")
    @ApiOperation(value = "执行sql语句")
    public ObjEnvelop dmSql(@ApiParam(name = "content", value = "sql", required = true)
                            @RequestParam(value = "content", required = true) String content,
                            @ApiParam(name = "type", value = "类型1 查询 2修改删除新增", required = true)
                            @RequestParam(value = "type", required = true) String type) {
        try {
            content = URLDecoder.decode(content, "UTF-8");
            if ("2".equals(type)) {
                int result = 0;
                try {
                    result = jdbcTemplate.update(content);
                } catch (Exception e) {
                    e.printStackTrace();
                    result = -1;
                }
                return ObjEnvelop.getSuccess("ok", result);
            } else {
                return ObjEnvelop.getSuccess("ok", jdbcTemplate.queryForList(content));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("请求失败");
        }
    }
    @PostMapping(value = "open/exportExcel/executeSQLStream")
    @PostMapping(value = "open/exportExcel/executeSQLStream")
    @ApiOperation(value = "sql查询es", notes = "sql查询es")
    @ApiOperation(value = "sql查询es", notes = "sql查询es")

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

@ -1214,7 +1214,7 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    /**
    /**
     * 查询收入,开方,问诊量
     * 查询收入,开方,问诊量
     * 参数:
     * 参数:
     * strJson={"startDate":"2023-07-18","endDate":"2023-07-19","area":"350200","level":2,"flag":1}
     * strJson={"startDate":"2023-07-18","endDate":"2023-07-19","area":"350200","level":2,"flag":1,"type":"1"}
     */
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.getTotal3Data)
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.getTotal3Data)
    @ApiOperation(value = "查询收入,开方,问诊量")
    @ApiOperation(value = "查询收入,开方,问诊量")
@ -1900,6 +1900,22 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
        }
        }
    }
    }
    /**
     * 收入情况
     * strJson={"startDate":"2024-01-01","endDate":"2024-05-27","area":"350200","level":2}
     */
    @GetMapping(value = "/incomeSituation")
    @ApiOperation(value = "收入情况")
    public ObjEnvelop incomeSituation(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            JSONObject json = statisticsEsService.incomeSituation(qvo);
            return ObjEnvelop.getSuccess("查询成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }

+ 114 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/StatisticsController.java

@ -0,0 +1,114 @@
package com.yihu.jw.hospital.module.common;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.hospital.module.common.service.StatisticsService;
import com.yihu.jw.hospital.utils.ExportUtl;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2024/6/3.
 */
@RestController
@RequestMapping("statistics")
@Api(tags = "统计分析")
public class StatisticsController extends EnvelopRestEndpoint {
    @Autowired
    private StatisticsService statisticsService;
    @Autowired
    private ExportUtl exportUtl;
    /**
     * 智能设备分析
     * strJson={"startDate":"2024-01-01","endDate":"2024-05-27","area":"350200","level":2}
     */
    @GetMapping(value = "deviceAnalysis")
    @ApiOperation(value = "智能设备分析")
    public ObjEnvelop deviceAnalysis(@RequestParam(required = false) String startDate,
                                     @RequestParam(required = false) String endDate) {
        try {
            JSONObject json = statisticsService.deviceAnalysis(startDate,endDate);
            return ObjEnvelop.getSuccess("查询成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "deviceUseInfo")
    @ApiOperation(value = "设备使用情况")
    public ObjEnvelop deviceUseInfo(@RequestParam(required = true) String type,
                                    @RequestParam(required = false) String startDate,
                                     @RequestParam(required = false) String endDate) {
        try {
            JSONObject json = statisticsService.deviceUseInfo(type,startDate,endDate);
            return ObjEnvelop.getSuccess("查询成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "deviceUseDetail")
    @ApiOperation(value = "设备使用情况明细")
    public ListEnvelop deviceUseDetail(@RequestParam(required = false) String sort,
                                       @RequestParam(required = false) String startDate,
                                       @RequestParam(required = false) String endDate) {
        try {
            List<Map<String,Object>> list = statisticsService.deviceUseDetail(sort,startDate,endDate);
            return ListEnvelop.getSuccess("查询成功",list);
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    //导出设备使用情况明细
    @GetMapping(value="exportExcel/deviceUseDetail")
    public void exportList(
            @RequestParam(required = false) String sort,
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            HttpServletResponse response){
        try {
            List<Map<String,Object>> list = statisticsService.deviceUseDetail(sort,startDate,endDate);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=deviceUseDetail.xls");
            OutputStream os = response.getOutputStream();
            String header[] = {"科室","血压计数量","血压计绑定次数","血压计上传次数","血糖仪数量","血糖仪绑定次数","血糖仪上传次数"};
            String col[] = {"deptName","xyNum","xyBindNum","xyUseNum","xtNum","xtBindNum","xtUseNum"};
            exportUtl.write(os,list,header,col);
        }catch (Exception ex){
            error(ex);
        }
    }
    @GetMapping(value = "deptRanking")
    @ApiOperation(value = "科室使用情况排名")
    public ListEnvelop deptRanking(@RequestParam(required = true) String type,
                                    @RequestParam(required = false) String startDate,
                                    @RequestParam(required = false) String endDate) {
        try {
            List<Map<String,Object>> list = statisticsService.deptRanking(type,startDate,endDate);
            return ListEnvelop.getSuccess("查询成功",list);
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
}

+ 244 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/StatisticsService.java

@ -0,0 +1,244 @@
package com.yihu.jw.hospital.module.common.service;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2024/6/3.
 */
@Service
public class StatisticsService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 智能设备分析
     * 1、统计智能设备总数、设备上传次数、投放科室数量;
     * 2、智能设备总数:展示添加时间为查询时间内的设备总数,展示各类型的设备数量及占比比例;
     * 3、设备上传次数:展示查询时间段内所有设备的上传次数,展示各类型设备的上传次数及占总数的比例;
     * 4、投放科室数量:展示添加时间为查询时间内的设备分配给科室的科室数量,需去重;
     * 5、设备总数取值:医生PC端—设备信息管理中添加时间为查询时间段内设备数量(已删除的不算在内);
     * 6、上传总数取值:医生PC端—体征数据查询中,上传时间为查询时间段内的记录数量;
     * 7、投放科室数量取值:医生PC端—设备信息管理中已维护的设备中选择的科室的数量,按添加时间进行查询注:(一个科室只计算一次)
     */
    public JSONObject deviceAnalysis(String startDate,String endDate) throws Exception{
        JSONObject json = new JSONObject();
        String filterDevice = "";
        String filterUpload = "";
        String filterDept = "";
        String filterDeptUse = "";
        if(StringUtils.isNotBlank(startDate)){
            filterDevice += " and d.apply_date>='"+startDate+"' ";
            filterDept += " and apply_date>='"+startDate+"' ";
            filterDeptUse += " and d.apply_date>='"+startDate+"' and i.czrq>='"+startDate+"' ";
            filterUpload += " and czrq>='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            filterDevice += " and d.apply_date<='"+endDate+" 23:59:59' ";
            filterDept += " and apply_date<='"+endDate+" 23:59:59' ";
            filterDeptUse += " and d.apply_date<='"+endDate+" 23:59:59' and i.czrq<='"+endDate+" 23:59:59' ";
            filterUpload += " and czrq<='"+endDate+" 23:59:59' ";
        }
        //智能设备总数
        int devcieTotal = 0;
        int devcieXt = 0;//血糖仪数
        int devcieXy = 0;//血压计数
        String deviceSql = "SELECT dm.category_code type,COUNT(d.id) num FROM " +
                "wlyy_devices d INNER JOIN dm_device dm ON d.category_code = dm.id " +
                "where 1=1  " + filterDevice +
                "GROUP BY dm.category_code";
        List<Map<String,Object>> deviceList = jdbcTemplate.queryForList(deviceSql);
        for (Map<String,Object> map:deviceList){
            String type = map.get("type")+"";
            if("1".equals(type)){
                devcieXt = Integer.parseInt(map.get("num")+"");
            }
            if("3".equals(type)){
                devcieXy = Integer.parseInt(map.get("num")+"");
            }
        }
        devcieTotal = devcieXt+devcieXy;
        json.put("devcieTotal",devcieTotal);
        json.put("devcieXt",devcieXt);
        json.put("devcieXy",devcieXy);
        //设备上传次数
        int uploadTotal = 0;
        int uploadXt = 0;//
        int uploadXy = 0;//
        String uploadSql = "select type,count(id) num from wlyy_patient_health_index where 1=1 "+filterUpload+" group by type";
        List<Map<String,Object>> uploadList = jdbcTemplate.queryForList(uploadSql);
        for (Map<String,Object> map:uploadList){
            String type = map.get("type")+"";
            if("1".equals(type)){
                uploadXt = Integer.parseInt(map.get("num")+"");
            }
            if("3".equals(type)){
                uploadXy = Integer.parseInt(map.get("num")+"");
            }
        }
        uploadTotal = uploadXt+uploadXy;
        json.put("uploadTotal",uploadTotal);
        json.put("uploadXt",uploadXt);
        json.put("uploadXy",uploadXy);
        //投放科室数量
        String deptSql = "select count(DISTINCT dept) from wlyy_devices where dept is not null "+filterDept;
        String deptUseSql = "SELECT count(DISTINCT d.dept) from wlyy_devices d,wlyy_patient_health_index i " +
                "WHERE d.dept is not null and d.device_code=i.device_sn and i.del=1 "+filterDeptUse;
        int deptTotal = jdbcTemplate.queryForObject(deptSql,Integer.class);
        int deptUse = jdbcTemplate.queryForObject(deptUseSql,Integer.class);
        if(deptUse>deptTotal){
            deptUse = deptTotal;
        }
        int deptUnUse = deptTotal-deptUse;
        json.put("deptTotal",deptTotal);
        json.put("deptUse",deptUse);
        json.put("deptUnUse",deptUnUse);
        return json;
    }
    /**
     * 设备使用情况
     * type 1血糖 2血压
     * 1、图表说明
     * X轴:时间-默认按日期汇总,切换为近半年、今年时,改为按月份汇总支
     * Y轴:次数
     * 2、用不同颜色代表绑定次数及上传次数,鼠标停留在柱形图后,显示该条的具体数据;
     * 3、支持进行血压计、血糖仪的使用情况切换。
     */
    public JSONObject deviceUseInfo(String type,String startDate,String endDate){
        JSONObject json = new JSONObject();
        String bindSql = "SELECT COUNT(*) num,DATE_FORMAT(czrq,'%Y-%m-%d') date from wlyy_patient_device " +
                " where category_code = '"+type+"' ";
        String useSql = "SELECT COUNT(*) num,DATE_FORMAT(czrq,'%Y-%m-%d') date from wlyy_patient_health_index " +
                " where type = '"+type+"' and del=1 ";
        if(StringUtils.isNotBlank(startDate)){
            bindSql += " and czrq>='"+startDate+"' ";
            useSql += " and czrq>='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            bindSql += " and czrq<='"+endDate+" 23:59:59' ";
            useSql += " and czrq<='"+endDate+" 23:59:59' ";
        }
        bindSql += " GROUP BY date ORDER BY date ";
        useSql += " GROUP BY date ORDER BY date ";
        List<Map<String,Object>> bindList = jdbcTemplate.queryForList(bindSql);
        List<Map<String,Object>> useList = jdbcTemplate.queryForList(useSql);
        json.put("bindList",bindList);
        json.put("useList",useList);
        return json;
    }
    /**
     * 设备使用情况明细
     * 1、展示查询时间段内各科室的使用情况列表;
     * 2、支持导出该表格;
     * 3、默认按照科室名称的拼音字母进行排序;
     * 4、支持通过点击字段名称旁边的排序符号切换排序规则。
     * 设备数量按最新的投放科室进行统计;绑定次数按绑定时的投放科室进行统计;上传次数按照上传时的投放科室进行统计
     */
    public List<Map<String,Object>> deviceUseDetail(String sort,String startDate,String endDate){
        if(StringUtils.isNotBlank(sort)){
            sort = "deptName";
        }
        String filter = "";
        String filterUse = "";
        String filterBind = "";
        if(StringUtils.isNotBlank(startDate)){
            filter += " and d.apply_date>='"+startDate+"' ";
            filterUse += " and czrq>='"+startDate+"' ";
            filterBind += " and czrq>='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            filter += " and d.apply_date<='"+endDate+" 23:59:59' ";
            filterUse += " and czrq<='"+endDate+" 23:59:59' ";
            filterBind += " and czrq<='"+endDate+" 23:59:59' ";
        }
        String sql = "SELECT d.code dept,d.`name` deptName,IFNULL(t1.xtNum,0) xtNum,IFNULL(t1.xyNum,0) xyNum " +
                ",IFNULL(t2.xtUseNum,0) xtUseNum,IFNULL(t2.xyUseNum,0) xyUseNum " +
                ",IFNULL(t3.xtBindNum,0) xtBindNum,IFNULL(t3.xyBindNum,0) xyBindNum from dict_hospital_dept d " +
                "LEFT JOIN (SELECT d.dept,d.dept_name,COUNT(if(dm.category_code=1,1,null)) xtNum,COUNT(if(dm.category_code=2,1,null)) xyNum " +
                " from wlyy_devices d,dm_device dm " +
                "WHERE d.category_code=dm.id " + filter +
                "GROUP BY d.dept) t1 on d.code=t1.dept " +
                "LEFT JOIN (SELECT dept,dept_name,COUNT(if(type=1,1,null)) xtUseNum,COUNT(if(type=2,1,null)) xyUseNum from  " +
                "wlyy_patient_health_index where del=1 " + filterUse +
                "GROUP BY dept) t2 on d.code=t2.dept " +
                "LEFT JOIN (SELECT dept,dept_name,COUNT(if(category_code=1,1,null)) xtBindNum,COUNT(if(category_code=2,1,null)) xyBindNum  " +
                "from wlyy_patient_device where 1=1 " + filterBind+
                "GROUP BY dept) t3 on d.code=t3.dept " +
                "WHERE (xtNum+xyNum+xtUseNum+xyUseNum+xtBindNum+xyBindNum)>0 ORDER BY '"+sort+"' desc";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    /**
     * 科室使用情况排名
     * 1、默认展示投放科室排名,展示设备添加时间为查询时间段内,各科室的的血糖仪、血压计数量;
     * 2、使用科室排名,展示所有在查询时间段内,有使用设备的科室排名(有用户绑定、数据上传的科室),展示“绑定次数”、“上传次数”,默认按照上传次数进行倒序排序
     * type 1投放科室 2使用科室
     */
    public List<Map<String,Object>> deptRanking(String type,String startDate,String endDate){
        String filter = "";
        String filterUse = "";
        String filterBind = "";
        if(StringUtils.isNotBlank(startDate)){
            filter += " and d.apply_date>='"+startDate+"' ";
            filterUse += " and czrq>='"+startDate+"' ";
            filterBind += " and czrq>='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            filter += " and d.apply_date<='"+endDate+" 23:59:59' ";
            filterUse += " and czrq<='"+endDate+" 23:59:59' ";
            filterBind += " and czrq<='"+endDate+" 23:59:59' ";
        }
        //使用科室排名
        String sql = "SELECT d.dept,d.dept_name,COUNT(if(dm.category_code=1,1,null)) xtNum,COUNT(if(dm.category_code=2,1,null)) xyNum " +
                " from wlyy_devices d,dm_device dm " +
                "WHERE d.category_code=dm.id " + filter +
                "GROUP BY d.dept order by xtNum desc ";
        //投放科室排名
        String sql2 = "SELECT d.code dept,d.`name` deptName,IFNULL(t2.useNum,0) useNum " +
                ",IFNULL(t3.bindNum,0) bindNum from dict_hospital_dept d " +
                "LEFT JOIN (SELECT dept,dept_name,COUNT(id) useNum from  " +
                "wlyy_patient_health_index where del=1 " + filterUse +
                "GROUP BY dept) t2 on d.code=t2.dept " +
                "LEFT JOIN (SELECT dept,dept_name,COUNT(id) bindNum " +
                "from wlyy_patient_device where 1=1 " + filterBind +
                "GROUP BY dept) t3 on d.code=t3.dept " +
                "WHERE (useNum+bindNum)>0 " +
                "ORDER BY useNum desc ";
        List<Map<String,Object>> list = null;
        if("1".equals(type)){
            list = jdbcTemplate.queryForList(sql);
        }else {
            list = jdbcTemplate.queryForList(sql2);
        }
        return list;
    }
    public String getRange(int first, int second) {
        if (second == 0 && first > 0) {
            return "100%";
        } else if (second == 0 && first == 0) {
            return "0%";
        }
        float size = (float) (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0");//格式化小数,不足的补0
        String filesize = df.format(size);
        return filesize + "%";
    }
}

+ 36 - 357
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/DoorOrderController.java

@ -4,8 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.door.WlyyDoorConclusionDO;
import com.yihu.jw.entity.door.WlyyDoorConclusionDO;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import com.yihu.jw.hospital.module.door.dao.WlyyDoorDoctorDao;
import com.yihu.jw.hospital.module.door.dao.WlyyDoorServiceOrderDao;
import com.yihu.jw.hospital.module.door.service.DoorOrderService;
import com.yihu.jw.hospital.module.door.service.DoorOrderService;
import com.yihu.jw.hospital.module.door.service.WlyyDoorPrescriptionService;
import com.yihu.jw.hospital.module.door.service.WlyyDoorPrescriptionService;
import com.yihu.jw.hospital.module.door.service.WlyyDoorServiceOrderService;
import com.yihu.jw.hospital.module.door.service.WlyyDoorServiceOrderService;
@ -50,11 +48,6 @@ public class DoorOrderController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private DoorOrderService doorOrderService;
    private DoorOrderService doorOrderService;
    @Autowired
    private WlyyDoorDoctorDao doorDoctorDao;
    @Autowired
    private WlyyDoorServiceOrderDao doorServiceOrderDao;
    @Autowired
    @Autowired
    private WlyyDoorServiceOrderService wlyyDoorServiceOrderService;
    private WlyyDoorServiceOrderService wlyyDoorServiceOrderService;
    @Autowired
    @Autowired
@ -113,6 +106,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            Map<String, Object> result = wlyyDoorServiceOrderService.getDoctorInfo(qvo);
            Map<String, Object> result = wlyyDoorServiceOrderService.getDoctorInfo(qvo);
            return success("查询成功!", result);
            return success("查询成功!", result);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -145,6 +139,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            object.put("pageSize", size);
            object.put("pageSize", size);
            return success("查询成功", object);
            return success("查询成功", object);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -173,6 +168,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            object.put("pageSize", size);
            object.put("pageSize", size);
            return success("查询成功", object);
            return success("查询成功", object);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -191,6 +187,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("提交成功!", result);
            return success("提交成功!", result);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -211,6 +208,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("保存成功", result.get(ResponseContant.resultMsg));
            return success("保存成功", result.get(ResponseContant.resultMsg));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
@ -226,6 +224,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            String status = doorOrderService.findDispatchStatusByDoctor(doctor);
            String status = doorOrderService.findDispatchStatusByDoctor(doctor);
            return success("成功", status);
            return success("成功", status);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -240,6 +239,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            doorOrderService.updateDispatchStatusByDoctor(doctor, value);
            doorOrderService.updateDispatchStatusByDoctor(doctor, value);
            return success("成功");
            return success("成功");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
@ -255,6 +255,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            Map<String, String> map = doorOrderService.getNumGroupByStatusTeam(doctor, type);
            Map<String, String> map = doorOrderService.getNumGroupByStatusTeam(doctor, type);
            return success("获取成功", map);
            return success("获取成功", map);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -385,6 +386,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("派单成功", result.get(ResponseContant.resultMsg));
            return success("派单成功", result.get(ResponseContant.resultMsg));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
@ -402,6 +404,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            Map<String, String> map = doorOrderService.getNumGroupByStatus(doctor, type, name);
            Map<String, String> map = doorOrderService.getNumGroupByStatus(doctor, type, name);
            return success("获取成功", map);
            return success("获取成功", map);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -433,6 +436,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            WlyyDoorServiceOrderDO doorServiceOrderDO = doorOrderService.getDoorServiceOrderById(orderId, level);
            WlyyDoorServiceOrderDO doorServiceOrderDO = doorOrderService.getDoorServiceOrderById(orderId, level);
            return success("获取成功", doorServiceOrderDO);
            return success("获取成功", doorServiceOrderDO);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -458,6 +462,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
        } catch (RuntimeException se) {
        } catch (RuntimeException se) {
            return failed(se.getMessage());
            return failed(se.getMessage());
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -481,6 +486,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("派单成功", result.get(ResponseContant.resultMsg));
            return success("派单成功", result.get(ResponseContant.resultMsg));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -511,18 +517,19 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            WlyyDoorServiceOrderDO wlyyDoorServiceOrderDO = doorOrderService.updateArrivingTime(orderId, arrivingTime);
            WlyyDoorServiceOrderDO wlyyDoorServiceOrderDO = doorOrderService.updateArrivingTime(orderId, arrivingTime);
            return success("修改成功", wlyyDoorServiceOrderDO);
            return success("修改成功", wlyyDoorServiceOrderDO);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
    @RequestMapping(value = "/urlAnalysis", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @RequestMapping(value = "/urlAnalysis", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("门牌解析上门地址")
    @ApiOperation("门牌解析上门地址")
    @ResponseBody
    public Envelop urlAnalysis(@ApiParam(name = "url", value = "地址解析", defaultValue = "")
    public Envelop urlAnalysis(@ApiParam(name = "url", value = "地址解析", defaultValue = "")
                               @RequestParam(value = "url", required = true) String url) throws Exception {
                               @RequestParam(value = "url", required = true) String url) throws Exception {
        try {
        try {
            return success("操作成功!", doorOrderService.urlAnalysis(url));
            return success("操作成功!", doorOrderService.urlAnalysis(url));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -545,6 +552,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
                return failed("扫码签到失败");
                return failed("扫码签到失败");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -572,6 +580,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            WlyyDoorConclusionDO doorConclusion = doorOrderService.getDoorConclusion(orderId, true);
            WlyyDoorConclusionDO doorConclusion = doorOrderService.getDoorConclusion(orderId, true);
            return success("获取成功", doorConclusion);
            return success("获取成功", doorConclusion);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -591,6 +600,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            WlyyDoorConclusionDO doorConclusion = doorOrderService.updateDoorConclusion(model, examPapeStatus);
            WlyyDoorConclusionDO doorConclusion = doorOrderService.updateDoorConclusion(model, examPapeStatus);
            return success("保存成功", doorConclusion);
            return success("保存成功", doorConclusion);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -649,19 +659,6 @@ public class DoorOrderController extends EnvelopRestEndpoint {
        }
        }
    }
    }
//    @PostMapping("confirmReceipt")
//    @ApiOperation(value = "医生确认线下收款")
//    public Envelop confirmReceipt(
//            @ApiParam(value = "工单id", name = "orderId") @RequestParam(value = "orderId", required = true) String orderId,
//            @ApiParam(name = "level", value = "医院等级,1.三级医院,2.二级医院,3.一级及以下") @RequestParam(value = "level", required = true) Integer level
//    ) {
//        try {
//            return success("获取成功", doorOrderService.confirmReceipt(orderId, level));
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
    @GetMapping("/adminTeamLeader")
    @GetMapping("/adminTeamLeader")
    @ApiOperation(value = "判断医生是不是团队长")
    @ApiOperation(value = "判断医生是不是团队长")
    public Envelop adminTeamLeader(@ApiParam(value = "医生id", name = "doctorId") @RequestParam(value = "doctorId", required = true) String doctorId) {
    public Envelop adminTeamLeader(@ApiParam(value = "医生id", name = "doctorId") @RequestParam(value = "doctorId", required = true) String doctorId) {
@ -690,6 +687,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("查询成功", doorOrderService.getTeamLeaderAllOrder(doctorId, ss, page, pageSize));
            return success("查询成功", doorOrderService.getTeamLeaderAllOrder(doctorId, ss, page, pageSize));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -745,52 +743,6 @@ public class DoorOrderController extends EnvelopRestEndpoint {
    }
    }
//    /**
//     * 获取服务项目
//     */
//    @GetMapping("selectByHospital")
//    @ApiOperation(value = "获取服务项目")
//    public Envelop selectByHospital(
//            @ApiParam(value = "机构code", name = "hospital") @RequestParam(value = "hospital", required = false) String hospital,
//            @ApiParam(value = "服务项目名称", name = "serverItemName") @RequestParam(value = "serverItemName", required = false) String serverItemName) {
//        try {
//            return success("获取成功", "dara", serviceItemService.selectByHospital(hospital, serverItemName));
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//
//    /**
//     * 获取服务项目-上门服务
//     */
//    @GetMapping("selectServiceByHospital")
//    @ApiOperation(value = "获取服务项目-上门服务")
//    public Envelop selectServiceByHospital(
//            @ApiParam(value = "机构code", name = "hospital") @RequestParam(value = "hospital", required = false) String hospital,
//            @ApiParam(value = "服务项目名称", name = "serverItemName") @RequestParam(value = "serverItemName", required = false) String serverItemName,
//            @ApiParam(value = "类型", name = "type") @RequestParam(value = "type", required = false) String type,
//            @ApiParam(value = "居民", name = "patient") @RequestParam(value = "patient", required = false) String patient,
//            @ApiParam(value = "loginUserId", name = "loginUserId") @RequestParam(value = "loginUserId", required = false) String loginUserId
//    ) {
//        try {
//            return success("获取成功", serverPackageService.selectServiceByHospital(hospital, serverItemName, type, patient, loginUserId));
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//
//
//    @RequestMapping(value = "selectServiceTypes", method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation(value = "获取服务项目类型-上门服务")
//    public Envelop selectServiceTypes() {
//        try {
//            return success("查询成功", serverPackageService.selectTypes());
//        } catch (Exception ex) {
//            return failed(ex.getMessage());
//        }
//    }
    @PostMapping("updateDoctorInfo")
    @PostMapping("updateDoctorInfo")
    @ApiOperation(value = "修改保存服务医生")
    @ApiOperation(value = "修改保存服务医生")
    public Envelop updateDoctorInfo(
    public Envelop updateDoctorInfo(
@ -801,6 +753,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            wlyyDoorServiceOrderService.updateDoctorInfo(jsonData);
            wlyyDoorServiceOrderService.updateDoctorInfo(jsonData);
            return success("修改成功");
            return success("修改成功");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -815,116 +768,11 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            wlyyDoorServiceOrderService.updateDoctorInfoNoPatient(jsonData);
            wlyyDoorServiceOrderService.updateDoctorInfoNoPatient(jsonData);
            return success("修改成功");
            return success("修改成功");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
//    @PostMapping("updatePackageItemInfo")
//    @ApiOperation(value = "修改保存服务项")
//
//    public Envelop updatePackageItemInfo(
//            @ApiParam(value = "jsonData", name = "jsonData")
//            @RequestParam(value = "jsonData", required = false) String jsonData) {
//        try {
//            doorOrderService.updatePackageItemInfo(jsonData);
//            return success("修改成功");
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//    @ApiOperation("社区医院下医生列表查询接口 没分页")
//    @RequestMapping(value = "getDoctorListByHospitalNoPage", method = RequestMethod.POST)
//    @ResponseBody
//    public Envelop getDoctorListByHospitalNoPage(
//            @RequestParam(required = true) String orderId,
//            @RequestParam(required = false) String hospital,
//            @RequestParam(required = false) String name,
//            @RequestParam(required = false) Integer type
//    ) {
//        try {
//            List<JSONObject> array = new ArrayList<>();
//            WlyyDoorServiceOrderDO one = doorServiceOrderDao.findById(orderId).orElse(null);
//            // 被服务的居民的次数(非代理居民)
//            Integer times = wlyyDoorServiceOrderService.countPatientDoorTimes(one.getPatient());
//            List<String> doctors = doorDoctorDao.findDoctors(orderId);
//            List<Map<String, Object>> list = familyContractService.getDoctorsByhospitalNoPage(hospital, name, type, times);
//            if (list != null) {
//                for (Map<String, Object> doctor : list) {
//                    if (doctor == null) {
//                        continue;
//                    }
//                    JSONObject json = new JSONObject();
//                    json.put("id", doctor.get("id"));
//                    // 医生标识
//                    json.put("code", doctor.get("code"));
//                    // 医生姓名
//                    json.put("name", doctor.get("name"));
//                    // 所在医院名称
//                    json.put("hospital", doctor.get("hospital"));
//                    // 所在医院名称
//                    json.put("hospital_name", doctor.get("hospital_name"));
//                    // 科室名称
//                    json.put("dept_name", (doctor.get("dept_name") == null ||
//                            org.apache.commons.lang3.StringUtils.isEmpty(doctor.get("dept_name").toString())) ? " " : doctor.get("dept_name"));
//
//                    json.put("level", doctor.get("level"));
//                    json.put("job", doctor.get("job"));
//                    // 职称名称
//                    json.put("job_name", (doctor.get("job_name") == null ||
//                            org.apache.commons.lang3.StringUtils.isEmpty(doctor.get("job_name").toString())) ? " " : doctor.get("job_name"));
//                    // 头像
//                    json.put("photo", doctor.get("photo"));
//                    // 简介
//                    json.put("introduce", doctor.get("introduce"));
//                    // 专长
//                    json.put("expertise", doctor.get("expertise"));
//                    json.put("flag", doctors.contains(String.valueOf(doctor.get("code"))) ? true : false);
//                    json.put("fixed", one != null && String.valueOf(doctor.get("code")).equals(one.getDoctor()) ? true : false);
//                    //出诊费用
//                    json.put("fee", doctor.get("fee"));
//                    array.add(json);
//                }
//            }
//            // 排序
//            Collections.sort(array, new Comparator<JSONObject>() {
//                @Override
//                public int compare(JSONObject o1, JSONObject o2) {
//                    Integer flag1 = (Boolean) o1.get("flag") ? 2 : 1;
//                    Integer flag2 = (Boolean) o2.get("flag") ? 2 : 1;
//                    if (flag1 - flag2 > 0) {
//                        return -1;
//                    } else if (flag1 - flag2 < 0) {
//                        return 1;
//                    } else {
//                        return 0;
//                    }
//                }
//            });
//            Collections.sort(array, new Comparator<JSONObject>() {
//                @Override
//                public int compare(JSONObject o1, JSONObject o2) {
//                    Integer fixed = (Boolean) o1.get("fixed") ? 2 : 1;
//                    Integer fixed2 = (Boolean) o2.get("fixed") ? 2 : 1;
//                    int sort = fixed - fixed2;
//                    if (sort > 0) {
//                        return -1;
//                    } else if (sort < 0) {
//                        return 1;
//                    } else {
//                        return 0;
//                    }
//                }
//            });
//            return success("获取医院医生列表成功!", array);
//        } catch (RuntimeException se) {
//            return failed(se.getMessage());
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
    @GetMapping(value = "queryDoctorListNotStopped")
    @GetMapping(value = "queryDoctorListNotStopped")
    @ApiOperation(value = "服务人员列表(可接单状态的医生列表)")
    @ApiOperation(value = "服务人员列表(可接单状态的医生列表)")
@ -946,6 +794,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            object.put("pageSize", size);
            object.put("pageSize", size);
            return success("查询成功", object);
            return success("查询成功", object);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
@ -967,15 +816,14 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("取消成功", result.get(ResponseContant.resultMsg));
            return success("取消成功", result.get(ResponseContant.resultMsg));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
    @PostMapping(value = "transOrderToOtherOrg")
    @PostMapping(value = "transOrderToOtherOrg")
    @ApiOperation(value = "调度员将工单转接给其他机构")
    @ApiOperation(value = "调度员将工单转接给其他机构")
    public Envelop transOrderToOtherOrg(
    public Envelop transOrderToOtherOrg(
            @ApiParam(name = "orderId", value = "工单id") @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(name = "orderId", value = "工单id") @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(name = "hospital", value = "机构code") @RequestParam(value = "hospital", required = true) String hospital) {
            @ApiParam(name = "hospital", value = "机构code") @RequestParam(value = "hospital", required = true) String hospital) {
@ -986,9 +834,9 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("转接成功", result.get(ResponseContant.resultMsg));
            return success("转接成功", result.get(ResponseContant.resultMsg));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -1007,15 +855,14 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("转接成功", result.get(ResponseContant.resultMsg));
            return success("转接成功", result.get(ResponseContant.resultMsg));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
    @PostMapping(value = "updateServiceStatus")
    @PostMapping(value = "updateServiceStatus")
    @ApiOperation(value = "更新预约服务项目类型")
    @ApiOperation(value = "更新预约服务项目类型")
    public Envelop updateServiceStatus(
    public Envelop updateServiceStatus(
            @ApiParam(name = "id", value = "工单id") @RequestParam(value = "id", required = true) String id) {
            @ApiParam(name = "id", value = "工单id") @RequestParam(value = "id", required = true) String id) {
        try {
        try {
@ -1025,14 +872,13 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("修改成功", result);
            return success("修改成功", result);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
    @GetMapping(value = "orderIsCancel")
    @GetMapping(value = "orderIsCancel")
    @ApiOperation(value = "查看消息时判断工单是否取消")
    @ApiOperation(value = "查看消息时判断工单是否取消")
    public Envelop orderIsCancel(
    public Envelop orderIsCancel(
            @ApiParam(name = "messageId", value = "消息id", required = true) @RequestParam String messageId) {
            @ApiParam(name = "messageId", value = "消息id", required = true) @RequestParam String messageId) {
        try {
        try {
@ -1042,39 +888,25 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("查询成功", result.get(ResponseContant.resultMsg));
            return success("查询成功", result.get(ResponseContant.resultMsg));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
//    @GetMapping(value = "getWorkingTimeByDoctor")
//    @ResponseBody
//    @ApiOperation("获取居民家签机构的上班时间")
//    public Envelop getWorkingTimeByPatient(@RequestParam String patient) {
//        try {
//            return success("查询成功", hospitalService.getWorkingTimeByPatient(patient));
//        } catch (RuntimeException se) {
//            return failed(se.getMessage());
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
    @PostMapping(value = "cancelConclusion")
    @PostMapping(value = "cancelConclusion")
    @ResponseBody
    @ApiOperation("取消登记服务小结")
    @ApiOperation("取消登记服务小结")
    public Envelop cancelConclusion(@ApiParam(name = "orderId", value = "工单id", required = true) @RequestParam String orderId) {
    public Envelop cancelConclusion(@ApiParam(name = "orderId", value = "工单id", required = true) @RequestParam String orderId) {
        try {
        try {
            wlyyDoorServiceOrderService.cancelConclusion(orderId);
            wlyyDoorServiceOrderService.cancelConclusion(orderId);
            return success("取消成功");
            return success("取消成功");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
    @PostMapping(value = "createPrescription")
    @PostMapping(value = "createPrescription")
    @ResponseBody
    @ApiOperation("上门服务前手工开方接口")
    @ApiOperation("上门服务前手工开方接口")
    public Envelop createPrescription(@ApiParam(name = "orderId", value = "工单id", required = true) @RequestParam String orderId,
    public Envelop createPrescription(@ApiParam(name = "orderId", value = "工单id", required = true) @RequestParam String orderId,
                                      @ApiParam(name = "prescriptionCode", value = "处方单号,多个用逗号隔开", required = true) @RequestParam String prescriptionCode,
                                      @ApiParam(name = "prescriptionCode", value = "处方单号,多个用逗号隔开", required = true) @RequestParam String prescriptionCode,
@ -1086,13 +918,13 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("开方完成");
            return success("开方完成");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
    @PostMapping(value = "updateDoctorStatus")
    @PostMapping(value = "updateDoctorStatus")
    @ResponseBody
    @ApiOperation("更新医生地理位置状态")
    @ApiOperation("更新医生地理位置状态")
    public Envelop updateDoctorStatus(@ApiParam(name = "positionStatus", value = "医生地理位置状态", required = true) @RequestParam Integer positionStatus,
    public Envelop updateDoctorStatus(@ApiParam(name = "positionStatus", value = "医生地理位置状态", required = true) @RequestParam Integer positionStatus,
                                      @ApiParam(name = "position", value = "地理位置,用逗号隔开", required = false) @RequestParam String position) {
                                      @ApiParam(name = "position", value = "地理位置,用逗号隔开", required = false) @RequestParam String position) {
@ -1100,108 +932,13 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            wlyyDoorServiceOrderService.updateDoctorStatus(getUID(), positionStatus, position);
            wlyyDoorServiceOrderService.updateDoctorStatus(getUID(), positionStatus, position);
            return success("更新完成");
            return success("更新完成");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
//    @GetMapping(value = "getPrescription")
//    @ResponseBody
//    @ApiOperation("获取长处方信息")
//    public Envelop getPrescription(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true) String patient,
//                                   @ApiParam(name = "visitDept", value = "挂号科室编码") @RequestParam(required = false) String visitDept,
//                                   @ApiParam(name = "visitTimeFrom", value = "开始时间") @RequestParam(required = false) String visitTimeFrom,
//                                   @ApiParam(name = "visitTimeEnd", value = "结束时间") @RequestParam(required = false) String visitTimeEnd) {
//        try {
//            JSONArray json = doorPrescriptionService.getPrescription(getUID(), patient, visitDept, visitTimeFrom, visitTimeEnd);
//            return success("获取成功", json);
//        } catch (RuntimeException se) {
//            return failed(se.getMessage());
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//    @PostMapping(value = "createDoorPrescription")
//    @ResponseBody
//    @ApiOperation("开方接口")
//    public Envelop createDoorPrescription(@ApiParam(name = "orderId", value = "订单id", required = true) @RequestParam String orderId,
//                                          @ApiParam(name = "jsonData", value = "有关处方相关数据", required = true) @RequestParam String jsonData) {
//        try {
//            JSONObject jsonObject = doorPrescriptionService.createDoorPrescription(orderId, jsonData, getUID());
//            if (jsonObject.getInteger("status") == 200) {
//                return success("开方成功", jsonObject.get("data"));
//            } else {
//                return failed(jsonObject.getString("msg"));
//            }
//        } catch (RuntimeException se) {
//            return failed(se.getMessage());
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//    @GetMapping(value = "getPrescriptionByCode")
//    @ResponseBody
//    @ApiOperation("获取长处方详情")
//    public Envelop getPrescriptionByCode(@ApiParam(name = "recipeNo", value = "医嘱号", required = true)
//                                         @RequestParam String recipeNo,
//                                         @ApiParam(name = "patientCode", value = "居民code", required = true)
//                                         @RequestParam String patientCode) {
//        try {
//            JSONObject json = doorPrescriptionService.getPrescriptionByCode(recipeNo, patientCode);
//            return success("获取成功", json);
//        } catch (RuntimeException se) {
//            return success(se.getMessage());
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//    @PostMapping(value = "cancelPrescriptionByCode")
//    @ResponseBody
//    @ApiOperation("取消开方")
//    public Envelop cancelPrescriptionByCode(@ApiParam(name = "prescriptionCode", value = "处方表code", required = true)
//                                            @RequestParam String prescriptionCode) {
//        try {
//            JSONObject result = jwDoorPrescriptionService.fadeRecipeUnion(prescriptionCode, getUID());
//            if (result.getInteger("status") == 200) {
//                return success("取消成功", result.getString("msg"));
//            } else {
//                return failed(result.getString("msg"));
//            }
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//    @PostMapping(value = "skipPrescription")
//    @ResponseBody
//    @ApiOperation("跳过开方")
//    public Envelop skipPrescription(@ApiParam(name = "orderId", value = "订单id", required = true) @RequestParam String orderId) {
//        try {
//            doorPrescriptionService.skipPrescriptionByOrderId(orderId);
//            return success("成功跳过");
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//    @RequestMapping(value = "/findDictByName", method = RequestMethod.GET)
//    @ApiOperation(value = "药品列表")
//    public Envelop findDictByName(@ApiParam(name = "name", value = "药品名称(中文或拼音首字母查询)", defaultValue = "胰岛素")
//                                  @RequestParam(value = "name", required = false) String name,
//                                  @ApiParam(name = "subjectClass", value = "药品科目, 0101西成药,0103中草药", required = true)
//                                  @RequestParam(value = "subjectClass") String subjectClass) {
//        try {
//            return success("操作成功!", zyDictService.findDictByDoctorAndName(getUID(), name, null, subjectClass));
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
    @PostMapping(value = "proxyUpdate")
    @PostMapping(value = "proxyUpdate")
    @ApiOperation(value = "上门服务-工单编辑")
    @ApiOperation(value = "上门服务-工单编辑")
    public Envelop proxyUpdate(@ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData) {
    public Envelop proxyUpdate(@ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData) {
        try {
        try {
@ -1211,6 +948,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            }
            }
            return success("修改成功!");
            return success("修改成功!");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -1228,60 +966,11 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            List<Map<String, Object>> list = wlyyDoorServiceOrderService.getDoorPatientList(teamCode, getUID(), patientName, page, pageSize);
            List<Map<String, Object>> list = wlyyDoorServiceOrderService.getDoorPatientList(teamCode, getUID(), patientName, page, pageSize);
            return success("获取成功", list);
            return success("获取成功", list);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
//    @PostMapping(value = "saveAuthorizeImage")
//    @ResponseBody
//    @ApiOperation("保存电子健康卡图片")
//    public Envelop saveAuthorizeImage(@ApiParam(name = "orderId", value = "订单id", required = true) @RequestParam String orderId,
//                                      @ApiParam(name = "authorizeImage", value = "电子健康卡授权图片", required = true) @RequestParam String authorizeImage) {
//        try {
//            doorPrescriptionService.saveAuthorizeImage(orderId, authorizeImage);
//            return success("保存成功");
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//    //ca认证
//    @ApiOperation("请求实名软证书并进行数字签名")
//    @ResponseBody
//    @RequestMapping(value = "/requestRealNameSoftCertAndSign", method = RequestMethod.POST)
//    public Envelop requestRealNameSoftCertAndSign(
//            @ApiParam(required = true, name = "strRealNameSoftCertCalledPasswd", value = "证书被调用保护口令")
//            @RequestParam(value = "strRealNameSoftCertCalledPasswd", required = true) String strRealNameSoftCertCalledPasswd,
//            @ApiParam(name = "strOriginalData", value = "原文")
//            @RequestParam(value = "strOriginalData", required = false) String strOriginalData,
//            @ApiParam(required = true, name = "prescriptionCode", value = "处方code")
//            @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode) {
//
//        try {
//            org.json.JSONObject jsonObject = jwDoorPrescriptionService.requestRealNameSoftCertAndSign(getUID(), strRealNameSoftCertCalledPasswd, strOriginalData, prescriptionCode);
//            return success("获取信息成功!", jsonObject);
//        } catch (RuntimeException se) {
//            return failed(se.getMessage());
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//    @RequestMapping(value = "uploadCaDigital", method = RequestMethod.POST)
//    @ApiOperation("上传基位ca认证信息")
//    public Envelop uploadCaDigital(
//            @ApiParam(name = "prescriptionCode", value = "处方code") @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode
//    ) {
//        try {
//            JSONObject json = jwDoorPrescriptionService.uploadCaDigital(prescriptionCode);
//            if (json.getInteger("status") == -1) {
//                return failed(json.getString("msg"));
//            }
//            return success("上传ca认证信息成功");
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
    @RequestMapping(value = "/getIcd10Info", method = RequestMethod.GET)
    @RequestMapping(value = "/getIcd10Info", method = RequestMethod.GET)
    @ApiOperation(value = "获取诊断结果")
    @ApiOperation(value = "获取诊断结果")
@ -1293,6 +982,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
        try {
        try {
            return success("操作成功!", doorPrescriptionService.getIcd10Info(nameKey, page, pageSize));
            return success("操作成功!", doorPrescriptionService.getIcd10Info(nameKey, page, pageSize));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -1309,26 +999,14 @@ public class DoorOrderController extends EnvelopRestEndpoint {
                isManage = getCurrentRoleIsManange(doctorId);
                isManage = getCurrentRoleIsManange(doctorId);
            }
            }
            if ("1".equals(isManage) && StringUtils.isBlank(hospital)) {
            if ("1".equals(isManage) && StringUtils.isBlank(hospital)) {
                //如果是管理员并且未筛选机构,就默认展示其管理下所有机构
                //这边先注释-用到的时候在改20231011
//                String level = getCurrentRoleLevel();
//                String currentRoleCode = getCurrentRoleCode();
//                if (level.equals("2")) {
//                    //市管理员
//                    hospital = currentRoleCode.substring(0, currentRoleCode.length() - 2) + "%";
//                } else if (level.equals("3")) {
//                    //区管理员
//                    hospital = currentRoleCode + "%";
//                } else if (level.equals("4")) {
//                    //机构管理员
//                    hospital = currentRoleCode;
//                }
            } else if (StringUtils.isNotBlank(hospital) && hospital.length() < 10) {
            } else if (StringUtils.isNotBlank(hospital) && hospital.length() < 10) {
                hospital += "%";
                hospital += "%";
            }
            }
            Map<String, String> map = doorOrderService.getAdministratorStatusBarNum(hospital);
            Map<String, String> map = doorOrderService.getAdministratorStatusBarNum(hospital);
            return success("获取成功", map);
            return success("获取成功", map);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }
@ -1411,6 +1089,7 @@ public class DoorOrderController extends EnvelopRestEndpoint {
                return failed("请检查工单");
                return failed("请检查工单");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
            return failed(e.getMessage());
        }
        }
    }
    }

+ 41 - 5
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DeviceController.java

@ -46,6 +46,39 @@ public class DeviceController extends BaseController {
    private DeviceDetailService deviceDetailService;
    private DeviceDetailService deviceDetailService;
    @Autowired
    @Autowired
    private PatientDeviceLogService patientDeviceLogService;
    private PatientDeviceLogService patientDeviceLogService;
    @Autowired
    private QrcodeUtil qrcodeUtil;
    //设备使用情况列表
    @GetMapping(value="devicePage")
    public PageEnvelop devicePage(
            @RequestParam(value = "name",required = false)String name,
            @RequestParam(value = "type",required = false) String type,
            @RequestParam(value = "dept",required = false) String dept,
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "pageSize",required = false)Integer pageSize){
        try {
            return deviceService.devicePage(page, pageSize,name,type,dept);
        }catch (Exception ex){
            ex.printStackTrace();
            return PageEnvelop.getError("查询失败!");
        }
    }
    //绑定记录页
    @GetMapping(value="patientDevicePage")
    public PageEnvelop patientDevicePage(
            @RequestParam(value = "name",required = false)String name,
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "pageSize",required = false)Integer pageSize){
        try {
            return deviceService.patientDevicePage(page, pageSize,name,deviceSn);
        }catch (Exception ex){
            ex.printStackTrace();
            return PageEnvelop.getError("查询失败!");
        }
    }
    @ApiOperation("获取设备分类")
    @ApiOperation("获取设备分类")
    @RequestMapping(value = "DeviceCategory", method = {RequestMethod.POST, RequestMethod.GET})
    @RequestMapping(value = "DeviceCategory", method = {RequestMethod.POST, RequestMethod.GET})
@ -86,9 +119,6 @@ public class DeviceController extends BaseController {
        }
        }
    }
    }
    @Autowired
    private QrcodeUtil qrcodeUtil;
    @ApiOperation("生成设备的小程序二维码")
    @ApiOperation("生成设备的小程序二维码")
    @PostMapping(value = "setQrcode")
    @PostMapping(value = "setQrcode")
    public Envelop setQrcode(@ApiParam(name = "id", value = "设备ID", defaultValue = "19")
    public Envelop setQrcode(@ApiParam(name = "id", value = "设备ID", defaultValue = "19")
@ -298,6 +328,11 @@ public class DeviceController extends BaseController {
    public Envelop healthIndexlist(
    public Envelop healthIndexlist(
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "date",required = false) String date,
            @RequestParam(value = "date",required = false) String date,
            @RequestParam(value = "dept",required = false) String dept,
            @RequestParam(value = "startDate",required = false) String startDate,
            @RequestParam(value = "endDate",required = false) String endDate,
            @RequestParam(value = "startRecordDate",required = false) String startRecordDate,
            @RequestParam(value = "endRecordDate",required = false) String endRecordDate,
            @RequestParam(value = "idcard",required = false) String idcard,
            @RequestParam(value = "idcard",required = false) String idcard,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "indexType",required = false) String indexType,
            @RequestParam(value = "indexType",required = false) String indexType,
@ -308,7 +343,8 @@ public class DeviceController extends BaseController {
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "pageSize",required = false) Integer pageSize){
            @RequestParam(value = "pageSize",required = false) Integer pageSize){
        try{
        try{
            return deviceService.healthIndexlist(deviceSn,date, idcard, userName, indexType,page, pageSize,indexTypeMin1, indexTypeMax1, indexTypeMin2,indexTypeMax2);
            return deviceService.healthIndexlist(deviceSn,date, idcard, userName, indexType,page, pageSize,indexTypeMin1,
                    indexTypeMax1, indexTypeMin2,indexTypeMax2,dept,startDate,endDate,startRecordDate,endRecordDate);
        }catch (Exception ex){
        }catch (Exception ex){
            ex.printStackTrace();
            ex.printStackTrace();
            return Envelop.getError("操作失败!");
            return Envelop.getError("操作失败!");
@ -333,7 +369,7 @@ public class DeviceController extends BaseController {
        }
        }
    }
    }
    //设备解绑(记录删除)
    //设备解绑
    @PostMapping(value = "deletePatientDevice")
    @PostMapping(value = "deletePatientDevice")
    public Envelop deletePatientDevice(@RequestParam(value = "id") String id){
    public Envelop deletePatientDevice(@RequestParam(value = "id") String id){
        try {
        try {

+ 2 - 5
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java

@ -173,7 +173,7 @@ public class PatientDeviceController extends BaseController {
    }
    }
    /**
    /**
     * 设备保存接口  ---增加血糖时间段保存 Reece v1.3.3 06
     * 设备保存接口
     */
     */
    @ApiOperation("设备保存接口")
    @ApiOperation("设备保存接口")
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
@ -204,10 +204,7 @@ public class PatientDeviceController extends BaseController {
            }
            }
            BasePatientDO patient = patientService.findById(patientId).orElse(null);
            BasePatientDO patient = patientService.findById(patientId).orElse(null);
//            if(!getUID().equals(patientId)&&device.getId()==null){
//                device.setAgent(patientId);
//                device.setAgentName(patient.getName());
//            }
            String sn = device.getDeviceSn();
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
            synchronized (sn.intern()){
                patientDeviceService.saveDevice(device,isScan);
                patientDeviceService.saveDevice(device,isScan);

+ 94 - 3
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceService.java

@ -13,6 +13,7 @@ import com.yihu.jw.hospital.utils.QrcodeUtil;
import com.yihu.jw.restmodel.iot.device.DeviceHealthIndexVO;
import com.yihu.jw.restmodel.iot.device.DeviceHealthIndexVO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateTimeUtil;
import com.yihu.jw.util.date.DateTimeUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
@ -213,6 +214,65 @@ public class DeviceService {
		return deviceDetailDao.findAll(spec);
		return deviceDetailDao.findAll(spec);
	}
	}
	/**
	 * 设备使用情况列表
	 * @param page
	 * @param pageSize
	 * @param name
	 * @param type 类型 1血糖 2血压
	 * @param dept
	 * @return
	 */
	public PageEnvelop devicePage(Integer page,Integer pageSize,String name,String type,String dept){
		if(page == null){
			page = 1;
		}
		if(pageSize == null){
			pageSize = 15;
		}
		String sql = "SELECT p.name patientName,pd.del,pd.applyStatus,dm.category_code type,dm.photo,d.* ";
		String countSql = "select count(*) ";
		String filter = " from wlyy_devices d  " +
				"INNER JOIN dm_device dm on d.category_code=dm.id " +
				"LEFT JOIN (SELECT MAX(pd.id) id,pd.del,pd.user,pd.apply_status applyStatus,d.device_code from wlyy_devices d,wlyy_patient_device pd " +
				"where pd.device_sn=d.device_code and pd.del=0 GROUP BY d.device_code) pd on d.device_code=pd.device_code " +
				"LEFT JOIN base_patient p on p.id=pd.user where 1=1 ";
		if(StringUtils.isNotBlank(name)){
			filter += " and (p.name like '%"+name+"%' or d.device_code like '%"+name+"%') ";
		}
		if(StringUtils.isNotBlank(type)){
			filter += " and dm.category_code = '"+type+"'";
		}
		if(StringUtils.isNotBlank(dept)){
			filter += " and dept = '"+dept+"'";
		}
		String orderBy = " limit "+(page-1)*pageSize+","+pageSize;
		List<DeviceDetail> list = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(DeviceDetail.class));
		Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
		return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
	}
	//绑定记录页
	public PageEnvelop patientDevicePage(Integer page,Integer pageSize,String name,String deviceSn){
		String sql = "SELECT d.device_sn deviceSn,DATE_FORMAT(d.czrq,'%Y-%m-%d %H:%i:%s') bindDate,DATEDIFF(NOW(), d.czrq) AS bindDays,d.del,d.apply_status applyStatus " +
				",p.id patient,p.`name`,p.sex,p.photo,p.idcard,p.birthday,d.id " ;
		String countSql = "select count(*) ";
		String filter = " from wlyy_patient_device d,base_patient p  WHERE d.device_sn='"+deviceSn+"' and d.`user` =p.id ";
		if(StringUtils.isNotBlank(name)){
			filter += " and p.name like '%"+name+"%' ";
		}
		String orderBy = " ORDER BY d.czrq desc limit "+(page-1)*pageSize+","+pageSize;
		List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
		for (Map<String,Object> map:list){
			String sex = map.get("sex")+"";
			String idcard = map.get("idcard")+"";
			String birthday = map.get("birthday")+"";
			map.put("age", IdCardUtil.getAgeByIdcardOrBirthday(idcard,DateUtil.strToDate(birthday)));
		}
		Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
		return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
	}
	public PageEnvelop searchDeviceList(String deviceName,String deviceCode,String linkman,Integer page,Integer pageSize){
	public PageEnvelop searchDeviceList(String deviceName,String deviceCode,String linkman,Integer page,Integer pageSize){
		if(page == null){
		if(page == null){
			page = 1;
			page = 1;
@ -290,6 +350,8 @@ public class DeviceService {
		deviceNew.setApplicantTel(device.getApplicantTel());
		deviceNew.setApplicantTel(device.getApplicantTel());
		deviceNew.setApplicantMail(device.getApplicantMail());
		deviceNew.setApplicantMail(device.getApplicantMail());
		deviceNew.setSim(device.getSim());
		deviceNew.setSim(device.getSim());
		deviceNew.setDept(device.getDept());
		deviceNew.setDeptName(device.getDeptName());
		return deviceDetailDao.save(deviceNew);
		return deviceDetailDao.save(deviceNew);
	}
	}
@ -366,8 +428,19 @@ public class DeviceService {
		return total ;
		return total ;
	}
	}
	/**
	 *
	 * dept 投放科室
	 * startDate 开始上传时间
	 * endDate 结束上传时间
	 * startRecordDate 开始测量时间
	 * endRecordDate	结束测量时间
	 * @return
	 * @throws Exception
	 */
	public PageEnvelop healthIndexlist(String deviceSn, String date, String idcard, String userName, String indexType, Integer page, Integer pageSize,
	public PageEnvelop healthIndexlist(String deviceSn, String date, String idcard, String userName, String indexType, Integer page, Integer pageSize,
									   Double indexTypeMin1, Double indexTypeMax1, Double indexTypeMin2, Double indexTypeMax2)throws Exception{
									   Double indexTypeMin1, Double indexTypeMax1, Double indexTypeMin2, Double indexTypeMax2,String dept,String startDate,
									   String endDate,String startRecordDate,String endRecordDate)throws Exception{
		if (page == null){
		if (page == null){
			page = 1;
			page = 1;
		}
		}
@ -376,8 +449,10 @@ public class DeviceService {
		}
		}
		StringBuilder filter = new StringBuilder();
		StringBuilder filter = new StringBuilder();
		String sql =" SELECT i.* ,s.name userName FROM wlyy_patient_health_index i JOIN base_patient s ON i.user=s.id ";
		String countSql =" SELECT count(1) as num FROM wlyy_patient_health_index i JOIN base_patient s ON i.user=s.id ";
		String sql =" SELECT i.* ,s.name userName,d.dept,d.dept_name FROM wlyy_patient_health_index i JOIN base_patient s ON i.user=s.id " +
				" left join wlyy_devices d on d.device_code=i.device_sn ";
		String countSql =" SELECT count(1) as num FROM wlyy_patient_health_index i JOIN base_patient s ON i.user=s.id " +
				" left join wlyy_devices d on d.device_code=i.device_sn ";
		sql += " WHERE 1=1 ";
		sql += " WHERE 1=1 ";
		countSql += " WHERE 1=1 ";
		countSql += " WHERE 1=1 ";
@ -393,6 +468,9 @@ public class DeviceService {
		if(!StringUtils.isEmpty(idcard)){
		if(!StringUtils.isEmpty(idcard)){
			filter.append(" and i.idcard like '%"+idcard+"%' ");
			filter.append(" and i.idcard like '%"+idcard+"%' ");
		}
		}
		if(!StringUtils.isEmpty(dept)){
			filter.append(" and d.dept = '"+dept+"' ");
		}
		//体征数据创建时间
		//体征数据创建时间
		if(!StringUtils.isEmpty(date)){
		if(!StringUtils.isEmpty(date)){
			Date startTimeTemp  =  DateTimeUtil.simpleDateParse(date);
			Date startTimeTemp  =  DateTimeUtil.simpleDateParse(date);
@ -423,6 +501,18 @@ public class DeviceService {
		if(indexTypeMax2!=null){
		if(indexTypeMax2!=null){
			filter.append(" and value2<="+indexTypeMax2);
			filter.append(" and value2<="+indexTypeMax2);
		}
		}
		if(StringUtils.isNotBlank(startDate)){
			filter.append(" and i.czrq>='"+startDate+"'");
		}
		if(StringUtils.isNotBlank(endDate)){
			filter.append(" and i.czrq<='"+endDate+" 23:59:59'");
		}
		if(StringUtils.isNotBlank(startRecordDate)){
			filter.append(" and i.record_date>='"+startRecordDate+"'");
		}
		if(StringUtils.isNotBlank(endRecordDate)){
			filter.append(" and i.record_date<='"+endRecordDate+" 23:59:59'");
		}
		String f = filter.toString();
		String f = filter.toString();
		List<DeviceHealthIndexVO> resultList = jdbcTemplate.query(sql+f+" order by i.czrq desc "+" limit "+(page-1)*pageSize+","+pageSize,new BeanPropertyRowMapper<>(DeviceHealthIndexVO.class));
		List<DeviceHealthIndexVO> resultList = jdbcTemplate.query(sql+f+" order by i.czrq desc "+" limit "+(page-1)*pageSize+","+pageSize,new BeanPropertyRowMapper<>(DeviceHealthIndexVO.class));
		if(resultList.size()<=0){
		if(resultList.size()<=0){
@ -435,6 +525,7 @@ public class DeviceService {
		long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
		long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
		return PageEnvelop.getSuccessListWithPage("查询成功",resultList,page,pageSize,count);
		return PageEnvelop.getSuccessListWithPage("查询成功",resultList,page,pageSize,count);
	}
	}
	public JSONObject gethealthStandard(Integer type, String patientCode) {
	public JSONObject gethealthStandard(Integer type, String patientCode) {
		//血糖校验
		//血糖校验
		JSONObject json = new JSONObject();
		JSONObject json = new JSONObject();

+ 8 - 27
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceUploadService.java

@ -173,33 +173,14 @@ public class DeviceUploadService {
        List<DeviceDetail> deviceDetails = deviceDetailDao.findByDeviceCode(deviceSn);
        List<DeviceDetail> deviceDetails = deviceDetailDao.findByDeviceCode(deviceSn);
        if (deviceDetails != null && deviceDetails.size()>0){
        if (deviceDetails != null && deviceDetails.size()>0){
            deviceDetail = deviceDetails.get(0);
            deviceDetail = deviceDetails.get(0);
            if (deviceDetail.getGrantOrgCode() != null&& deviceDetail.getGrantOrgCode().equals("3502050300")){//
                List<DevicePatientDevice> patientDeviceList =  patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                if (patientDeviceList != null&&patientDeviceList.size()==1) {
                    device = patientDeviceList.get(0);
                }else if(patientDeviceList != null&&patientDeviceList.size()==2){
                    for (int i=0;i<patientDeviceList.size();i++){
                        if(userType.equals(patientDeviceList.get(i).getUserType())){
                            device = patientDeviceList.get(i);
                            break;
                        }
                    }
                }
            }else {
//                device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn, type, userType);
                List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                if (devices.size()>0){
                    device = devices.get(0);
                }else {
                    device=null;
                }
            List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
            if (devices.size()>0){
                device = devices.get(0);
            }
            }
        }
        }
        if (device != null) {
        /*//根据设备获取患者(设备只绑定一个人的时候,不判断按键)
        if (device!=null) {*/
        if (device != null) {
            //设备改成都不判断按键
            /************设备数据重复推送处理 start**********************/
            /************设备数据重复推送处理 start**********************/
            String value1 = data;
            String value1 = data;
            String value2="";
            String value2="";
@ -229,9 +210,6 @@ public class DeviceUploadService {
            if (value1.equals(value2) && value2.equals(value3)){
            if (value1.equals(value2) && value2.equals(value3)){
                return null;
                return null;
            }
            }
//            List<PatientHealthIndex> list = patientHealthIndexDao.findByType(device.getUser(),deviceSn,value1,Integer.parseInt(type),time);
            /*long maxtime = time.getTime()+30*1000;
            long mintime = time.getTime()-30*1000;*/
            Date minDate = DateUtil.getPreDays(time,-3);
            Date minDate = DateUtil.getPreDays(time,-3);
            Date maxDate = DateUtil.getPreDays(time,3);
            Date maxDate = DateUtil.getPreDays(time,3);
            List<DevicePatientHealthIndex> list = ioTfindByType(device.getUser(),deviceSn,value1,value2,value3,Integer.parseInt(type),time,minDate,maxDate);
            List<DevicePatientHealthIndex> list = ioTfindByType(device.getUser(),deviceSn,value1,value2,value3,Integer.parseInt(type),time,minDate,maxDate);
@ -300,6 +278,9 @@ public class DeviceUploadService {
            if(deviceDetail!=null){
            if(deviceDetail!=null){
                obj.setHospital(deviceDetail.getGrantOrgCode());
                obj.setHospital(deviceDetail.getGrantOrgCode());
                obj.setHospitalName(deviceDetail.getOrgName());
                obj.setHospitalName(deviceDetail.getOrgName());
                //设置使用科室
                obj.setDeptName(deviceDetail.getDeptName());
                obj.setDept(deviceDetail.getDept());
            }
            }
            obj = patientHealthIndexDao.save(obj);
            obj = patientHealthIndexDao.save(obj);

+ 18 - 11
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientDeviceService.java

@ -110,7 +110,9 @@ public class PatientDeviceService  {
            if("1".equals(isScan)){
            if("1".equals(isScan)){
                //解绑
                //解绑
                List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndUserType2(sn, userType);
                List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndUserType2(sn, userType);
                patientDeviceDao.deleteAll(devices);
                if(devices.size()>0){
                    patientDeviceDao.updatePatientDevice(sn);
                }
            }
            }
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            if (device != null && !device.getId().equals(patientDevice.getId())) {
            if (device != null && !device.getId().equals(patientDevice.getId())) {
@ -124,17 +126,20 @@ public class PatientDeviceService  {
        BasePatientDO patient = patientDao.findById(patientDevice.getUser()).orElse(null);
        BasePatientDO patient = patientDao.findById(patientDevice.getUser()).orElse(null);
        patientDevice.setUserIdcard(patient.getIdcard());
        patientDevice.setUserIdcard(patient.getIdcard());
        savePatientDevice(patientDevice);
        List<DevicePatientDevice> ownList = patientDeviceDao.findByPatientAndDeviceSn(patientDevice.getUser(),patientDevice.getDeviceSn());
        if(ownList.size()>0){
            patientDeviceDao.deleteAll(ownList);
        }
        return true;
    }
        List<DeviceDetail> deviceDetails = deviceDetailDao.findByDeviceCode(patientDevice.getDeviceSn());
        if(deviceDetails.size()>0){
            patientDevice.setDept(deviceDetails.get(0).getDept());
            patientDevice.setDeptName(deviceDetails.get(0).getDeptName());
        }
    /**
     * 设备绑定
     * @param patientDevice
     */
    public void savePatientDevice(DevicePatientDevice patientDevice){
        patientDeviceDao.save(patientDevice);
        patientDeviceDao.save(patientDevice);
        return true;
    }
    }
@ -154,7 +159,9 @@ public class PatientDeviceService  {
     */
     */
    public List<com.alibaba.fastjson.JSONObject> deleteDevice(String id, String uuid) {
    public List<com.alibaba.fastjson.JSONObject> deleteDevice(String id, String uuid) {
        DevicePatientDevice device = patientDeviceDao.findById(Long.valueOf(id)).orElse(null);
        DevicePatientDevice device = patientDeviceDao.findById(Long.valueOf(id)).orElse(null);
        patientDeviceDao.delete(device);
        device.setDel(1);
        device.setDelUser(uuid);
        patientDeviceDao.save(device);
        List<DevicePatientDevice> patientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(device.getDeviceSn(), device.getCategoryCode());
        List<DevicePatientDevice> patientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(device.getDeviceSn(), device.getCategoryCode());
        List<com.alibaba.fastjson.JSONObject> objects = new ArrayList<>();
        List<com.alibaba.fastjson.JSONObject> objects = new ArrayList<>();
        for (DevicePatientDevice patientDevice : patientDevices) {
        for (DevicePatientDevice patientDevice : patientDevices) {
@ -207,7 +214,7 @@ public class PatientDeviceService  {
        PageRequest pageRequest = PageRequest.of(page - 1, pagesize);
        PageRequest pageRequest = PageRequest.of(page - 1, pagesize);
        List<DevicePatientDevice> list = new ArrayList<>();
        List<DevicePatientDevice> list = new ArrayList<>();
        list = patientDeviceDao.findByUser(patientCode, pageRequest);
        list = patientDeviceDao.findByUserAndDel(patientCode,0, pageRequest);
        if (list != null) {
        if (list != null) {
            //获取设备路径,医生姓名
            //获取设备路径,医生姓名
            List<Device> deviceList = deviceDao.findAll();
            List<Device> deviceList = deviceDao.findAll();

+ 71 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/utils/ExportUtl.java

@ -0,0 +1,71 @@
package com.yihu.jw.hospital.utils;
import jxl.write.*;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
 * 导出工具类
 * Created by yeshijie on 2024/6/4.
 */
@Component
public class ExportUtl {
    public void addHeader(WritableSheet ws,String[] header) throws WriteException {
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    public void write(WritableWorkbook wwb, List<Map<String,Object>> ls,String[] header,String[] col) throws Exception {
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            addHeader(ws,header);
            int i = 1;
            for (Map<String,Object> m : ls) {
                for (int j=0;j<col.length;j++){
                    addCell(ws, i, j, m.get(col[j]),"");
                }
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void write(OutputStream os, List ls,String[] header,String[] col) throws Exception{
        write(jxl.Workbook.createWorkbook(os), ls,header,col);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column ,row, data);
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, Object obj, String memo) throws WriteException {
        String data = "";
        if(obj!=null){
            data = obj +"";
        }
        if("null".equals(data)){
            data = "";
        }
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
}