ソースを参照

Merge branch 'dev' of liubing/wlyy2.0 into dev

liubing 3 年 前
コミット
bb14d5344a
33 ファイル変更1483 行追加629 行削除
  1. 2 0
      business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SystemMessageDao.java
  2. 2 0
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  3. 46 1
      common/common-entity/sql记录
  4. 54 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java
  5. 3 3
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderCancelLog.java
  6. 119 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/EmergencyWarnConclusionDO.java
  7. 45 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/EmergencyWarnDoctorResponseDO.java
  8. 0 79
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringConclusionDO.java
  9. 23 14
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  10. 0 81
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderPatientConfirmLog.java
  11. 10 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java
  12. 225 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/emergency/EmergencyOrderVO.java
  13. 15 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/EmergencyWarnCancelLogDao.java
  14. 18 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/EmergencyWarnConclusionDao.java
  15. 15 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/EmergencyWarnDoctorResponseDao.java
  16. 0 19
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/SecurityMonitoringConclusionDao.java
  17. 0 14
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/SecurityMonitoringOrderCancelLogDao.java
  18. 3 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/SecurityMonitoringOrderDao.java
  19. 0 12
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/SecurityMonitoringOrderPatientConfirmLogDao.java
  20. 51 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java
  21. 4 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java
  22. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/DoctorDoorCoachOrderController.java
  23. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/PatientDoorCoachOrderController.java
  24. 30 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java
  25. 108 18
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  26. 237 65
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  27. 56 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java
  28. 10 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java
  29. 14 13
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java
  30. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java
  31. 31 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java
  32. 350 267
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  33. 6 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/ConstantUtil.java

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SystemMessageDao.java

@ -34,4 +34,6 @@ public interface SystemMessageDao extends PagingAndSortingRepository<SystemMessa
    @Modifying
    @Query("delete from SystemMessageDO a  where a.receiver = ?1 and a.relationCode = ?2 and a.type =?3")
    int orderMessageDelByType(String doctor, String orderId,String type);
    SystemMessageDO findByRelationCodeAndReceiver(String relationCode,String receiver);
}

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

@ -756,6 +756,8 @@ public class ImUtil {
	public static final String SESSION_STATUS_PROCEEDINGS = "0";
	public static final String SESSION_STATUS_END = "1";
	public static final String SESSION_TYPE_EMERGENCY_ASSISTANCE = "20";//紧急救助
	public static final String SESSION_TYPE_DOOR_COACH = "21";//上门辅导(上门预约)
	public static final String SESSION_TYPE_SECURITY_WARN = "22";//安防咨询
	
	public static final String CONTENT_TYPE_TEXT = "1";
	

+ 46 - 1
common/common-entity/sql记录

@ -930,7 +930,6 @@ ALTER table base_org_notice add column create_user varchar(50) DEFAULT NULL
-- 2021-05-20 lb
ALTER table base.base_security_monitoring_order add column `order_source` tinyint(4) DEFAULT '1' COMMENT '工单发起来源状态 1APP 2手环3居家报警'
-- 2021-05-19
CREATE TABLE `base_course_catalogue_read_time` (
  `id` varchar(50) NOT NULL,
@ -940,3 +939,49 @@ CREATE TABLE `base_course_catalogue_read_time` (
  `read_time` varchar(20) DEFAULT NULL COMMENT '阅读时间,保留时间戳格式,单位s',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='记录用户阅读课程时长';
-- 2021 05-21 lb
CREATE TABLE `base_emergency_warn_conclusion` (
  `id` varchar(50) NOT NULL,
  `order_id` varchar(50) NOT NULL COMMENT '工单id',
  `patient` varchar(50) DEFAULT NULL COMMENT '工单服务的居民',
  `patient_name` varchar(50) DEFAULT NULL COMMENT '居民姓名',
  `doctor` varchar(50) DEFAULT NULL COMMENT '医生',
  `doctor_name` varchar(50) DEFAULT NULL COMMENT '医生姓名',
  `conclusion` varchar(2000) DEFAULT NULL COMMENT '处置小结',
   `conclusion_img` varchar(1000) DEFAULT NULL COMMENT '服务相关附件',
  `emergency_reason` tinyint(4) DEFAULT '4' COMMENT '紧急预警工单发起原因 字典emergency_reason',
  `emergency_treatment_status` tinyint(4) DEFAULT '4' COMMENT '紧急预警工单处理结果 字典emergency_treatment_status',
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `create_user` varchar(50) DEFAULT NULL COMMENT '创建者id',
  `create_user_name` varchar(50) DEFAULT NULL COMMENT '创建者称名',
  `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `update_user` varchar(50) DEFAULT NULL,
  `update_user_name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `orderId` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='紧急预警工单服务小结';
CREATE TABLE `base_emergency_warn_cancel_log` (
  `id` varchar(50) NOT NULL,
  `order_id` varchar(50) NOT NULL COMMENT '工单id',
  `patient` varchar(50) DEFAULT NULL COMMENT '居民code',
  `cancel_type` int(1) DEFAULT NULL COMMENT '取消类型:1-调度员取消,2-居民取消 3 医生取消',
   `cancel_reason` varchar(50) DEFAULT NULL COMMENT '取消理由',
  `time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '取消时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='紧急预警工单取消记录';
alter table base_security_monitoring_order add column emergency_cancel tinyint(4) DEFAULT '4' COMMENT '紧急预警工单误报警原因 emergency_cancel';
alter table base_emergency_assistance_order add column emergency_cancel tinyint(4) DEFAULT '4' COMMENT '紧急预警工单误报警原因 emergency_cancel';
CREATE TABLE `base_emergency_warn_doctor_response` (
  `id` varchar(50) NOT NULL,
  `order_id` varchar(50) NOT NULL COMMENT '工单id',
  `doctor` varchar(50) NOT NULL COMMENT '医生code',
  `response_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP 	COMMENT '医生响应时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='紧急预警医生响应状态';
DROP TABLE IF EXISTS `base_security_monitoring_conclusion`;
DROP TABLE IF EXISTS `base_security_monitoring_order_cancel_log`;
DROP TABLE IF EXISTS `base_semoni_patient_confirm_log`;

+ 54 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.care.assistance;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import netscape.javascript.JSObject;
import javax.persistence.Entity;
@ -14,6 +15,34 @@ import java.util.Date;
@Entity
@Table(name="base_emergency_assistance_order")
public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    /**
     * 工单状态:
     */
    public enum Status {
        ErrorWarning(-2, "误报警"),
        cancel(-1, "已取消"),
        complete(0, "已完成"),
        apply(1, "申请中");
        private Integer type;
        private String desc;
        Status(Integer type, String desc) {
            this.type = type;
            this.desc = desc;
        }
        public Integer getType() {
            return type;
        }
        public void setType(Integer type) {
            this.type = type;
        }
    }
    private String patient; //发起救助的居民id
    private String patientName; //发起救助的居民姓名
    private String patientPhone; //救助居民电话
@ -34,11 +63,13 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private String doctorLon; //医生当前定位地址经度
    private String conclusion; //服务完成笔记
    private String conclusionImg; //服务相关附件
    private Integer status; //工单状态 -1已取消 0已完成 1申请中
    private Integer status;
    private Date completeTime;//完成时间
    private String teamCode;
    private Integer type; //发起类型(1本人发起 2家人待预约 3医生代预约)
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String sendMessage;//
    private Integer patientAge;
@ -47,6 +78,11 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private double distance;//医生与患者距离 单位km
    private String otherDoctorDistance;
    /**
     * 服务小结
     */
    private EmergencyWarnConclusionDO emergencyWarnConclusionDO;
    public String getPatient() {
        return patient;
    }
@ -299,4 +335,21 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    public void setOrderSource(Integer orderSource) {
        this.orderSource = orderSource;
    }
    @Transient
    public EmergencyWarnConclusionDO getEmergencyWarnConclusionDO() {
        return emergencyWarnConclusionDO;
    }
    public void setEmergencyWarnConclusionDO(EmergencyWarnConclusionDO emergencyWarnConclusionDO) {
        this.emergencyWarnConclusionDO = emergencyWarnConclusionDO;
    }
    public Integer getEmergencyCancel() {
        return emergencyCancel;
    }
    public void setEmergencyCancel(Integer emergencyCancel) {
        this.emergencyCancel = emergencyCancel;
    }
}

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderCancelLog.java

@ -13,8 +13,8 @@ import java.util.Date;
 * Created by Bing on 2021/4/7.
 */
@Entity
@Table(name="base_security_monitoring_order_cancel_log")
public class SecurityMonitoringOrderCancelLog extends UuidIdentityEntity {
@Table(name="base_emergency_warn_cancel_log")
public class EmergencyWarnCancelLogDO extends UuidIdentityEntity {
    /**
     * 工单id
@ -67,10 +67,10 @@ public class SecurityMonitoringOrderCancelLog extends UuidIdentityEntity {
        this.cancelType = cancelType;
    }
    @Column(name = "cancel_reason")
    public String getCancelReason() {
        return cancelReason;
    }
    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }

+ 119 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/EmergencyWarnConclusionDO.java

@ -0,0 +1,119 @@
package com.yihu.jw.entity.care.securitymonitoring;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 紧急预警工单服务小结
 * Created by yeshijie on 2021/4/1.
 */
@Entity
@Table(name = "base_emergency_warn_conclusion")
public class EmergencyWarnConclusionDO extends UuidIdentityEntityWithOperator {
    private String orderId;//工单id
    private String patient;//工单服务的居民
    private String patientName;//居民姓名
    private String doctor;//医生
    private String doctorName;//医生姓名
    private String conclusion;//处置小结
    private String conclusionImg;//服务相关附件
    private Integer emergencyReason;//紧急预警工单发起原因 字典emergency_reason
    private Integer emergencyTreatmentStatus;//紧急预警工单处理结果 字典emergency_treatment_status
    private String ReasonName;
    private String TreatmentStatusName;
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getConclusion() {
        return conclusion;
    }
    public void setConclusion(String conclusion) {
        this.conclusion = conclusion;
    }
    public String getConclusionImg() {
        return conclusionImg;
    }
    public void setConclusionImg(String conclusionImg) {
        this.conclusionImg = conclusionImg;
    }
    public Integer getEmergencyReason() {
        return emergencyReason;
    }
    public void setEmergencyReason(Integer emergencyReason) {
        this.emergencyReason = emergencyReason;
    }
    public Integer getEmergencyTreatmentStatus() {
        return emergencyTreatmentStatus;
    }
    public void setEmergencyTreatmentStatus(Integer emergencyTreatmentStatus) {
        this.emergencyTreatmentStatus = emergencyTreatmentStatus;
    }
    @Transient
    public String getReasonName() {
        return ReasonName;
    }
    public void setReasonName(String reasonName) {
        ReasonName = reasonName;
    }
    @Transient
    public String getTreatmentStatusName() {
        return TreatmentStatusName;
    }
    public void setTreatmentStatusName(String treatmentStatusName) {
        TreatmentStatusName = treatmentStatusName;
    }
}

+ 45 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/EmergencyWarnDoctorResponseDO.java

@ -0,0 +1,45 @@
package com.yihu.jw.entity.care.securitymonitoring;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 紧急预警医生响应表
 * Created by Bing on 2021/5/21.
 */
@Entity
@Table(name="base_emergency_warn_doctor_response")
public class EmergencyWarnDoctorResponseDO extends UuidIdentityEntity {
    private String orderId;
    private String doctor;
    private Date responseTime;
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getResponseTime() {
        return responseTime;
    }
    public void setResponseTime(Date responseTime) {
        this.responseTime = responseTime;
    }
}

+ 0 - 79
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringConclusionDO.java

@ -1,79 +0,0 @@
package com.yihu.jw.entity.care.securitymonitoring;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 工单服务小结
 * Created by yeshijie on 2021/4/1.
 */
@Entity
@Table(name = "base_security_monitoring_conclusion")
public class SecurityMonitoringConclusionDO extends UuidIdentityEntityWithOperator {
    private String orderId;//工单id
    private String patient;//工单服务的居民
    private String patientName;//居民姓名
    private String doctor;//医生
    private String doctorName;//医生姓名
    private Integer status;//处置状态 1已确认安全 2已转送医疗机构 3已处置完成
    private String conclusion;//处置小结
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getConclusion() {
        return conclusion;
    }
    public void setConclusion(String conclusion) {
        this.conclusion = conclusion;
    }
}

+ 23 - 14
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -17,18 +17,17 @@ import java.util.Date;
@Table(name = "base_security_monitoring_order")
public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    /**
     * 工单状态:-1-已取消,1-待处置,2-前往居民定位,3-已签到,4-已登记小结,5-待补录,6-待评价,7-已完成
     * 工单状态:
     */
    /**
     * 工单状态:
     */
    public enum Status {
        ErrorWarning(-2, "误报警"),
        cancel(-1, "已取消"),
        waitForSend(1, "待处置"),
        waitForArrive(2, "前往居民定位"),
        signed(3, "已签到"),
        registerSummary(4, "已登记小结,"),
        waitForAdded(5, "待补录"),
        waitForCommnet(6, "待评价"),
        complete(7,"已完成");
        complete(0, "已完成"),
        apply(1, "申请中");
        private Integer type;
        private String desc;
@ -245,7 +244,7 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private Integer examPaperUploadWay;
    /**
     * 工单状态:-1-已取消,1-待处置,2-前往居民定位,3-已签到,4-已登记小结,5-待补录,6-待评价,7-已完成
     * 工单状态:
     */
    private Integer status;
@ -274,7 +273,7 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    /**
     * 服务小结
     */
    private SecurityMonitoringConclusionDO monitoringConclusion;
    private EmergencyWarnConclusionDO emergencyWarnConclusionDO;
    /**
     * 服务医生响应时间(第一条咨询或者接单时间)
@ -320,6 +319,8 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private String orderInfo;//工单详情 0-未推送 1-未确认 2-已确认
    private String doctorConfirmFinishImg;
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    /**
     * 医生确认医生结束服务时间
     */
@ -564,12 +565,12 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    }
    @Transient
    public SecurityMonitoringConclusionDO getMonitoringConclusion() {
        return monitoringConclusion;
    public EmergencyWarnConclusionDO getEmergencyWarnConclusionDO() {
        return emergencyWarnConclusionDO;
    }
    public void setMonitoringConclusion(SecurityMonitoringConclusionDO monitoringConclusion) {
        this.monitoringConclusion = monitoringConclusion;
    public void setEmergencyWarnConclusionDO(EmergencyWarnConclusionDO emergencyWarnConclusionDO) {
        this.emergencyWarnConclusionDO = emergencyWarnConclusionDO;
    }
    @Column(name = "service_response_time")
@ -700,4 +701,12 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    public void setOrderSource(Integer orderSource) {
        this.orderSource = orderSource;
    }
    public Integer getEmergencyCancel() {
        return emergencyCancel;
    }
    public void setEmergencyCancel(Integer emergencyCancel) {
        this.emergencyCancel = emergencyCancel;
    }
}

+ 0 - 81
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderPatientConfirmLog.java

@ -1,81 +0,0 @@
package com.yihu.jw.entity.care.securitymonitoring;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/7.
 */
@Entity
@Table(name="base_semoni_patient_confirm_log")
public class SecurityMonitoringOrderPatientConfirmLog extends UuidIdentityEntityWithOperator {
    /**
     * 工单id
     */
    private String orderId;
    /**
     * 居民
     */
    private String patient;
    /**
     * 居民姓名
     */
    private String patientName;
    /**
     * 确认操作类型:1-确认基础信息无误或变更,2-确认上门医生变更上门信息,3-同意工单转接,4-同意取消工单
     */
    private Integer type;
    /**
     * 操作描述
     */
    private String description;
    @Column(name = "order_id")
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 10 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java

@ -18,7 +18,7 @@ import java.util.Date;
public class SystemMessageDO extends UuidIdentityEntity {
    /**
     *消息类型 上门服务400开头,生活照料500开头 ,安防监控600开头, 上门辅导700开头
     *消息类型 上门服务400开头,生活照料500开头 ,安防监控600开头, 上门辅导700开头,紧急救助800开头
     */
    private String type;
    /**
@ -58,6 +58,7 @@ public class SystemMessageDO extends UuidIdentityEntity {
     */
    private String del;
    private String over;//是否操作结束 是否操作结束 1否,0是
    private String code;
    /**
     *已读时间
     */
@ -173,4 +174,12 @@ public class SystemMessageDO extends UuidIdentityEntity {
    public void setOver(String over) {
        this.over = over;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}

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

@ -0,0 +1,225 @@
package com.yihu.jw.restmodel.emergency;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/5/21.
 */
public class EmergencyOrderVO {
    //预警信息
    private String orderId;
    private Integer status;//工单状态
    private String statusName;//工单状态
    private Date createTime;//工单发起时间
    private String serveLat;
    private String serveLon;
    private String serveAddress;
    private String patient;
    private String patientName;
    private Integer sex;
    private String age;
    private String liveAddress;
    private Integer orderSource; //工单发起来源状态 1APP 2手环 3居家报警
    //误报警字段
    private String updateUserName;//操作时间
    private String updateUser;//操作时间
    private Integer emergencyCancel;//紧急预警工单误报警原因 字典emergency_cancel
    private String emergencyCancelName;
    private Date updateTime;
    //附加信息
    private Map<String,Object> information;//附加信息
    //围栏状态 fences
    //小结
    private EmergencyWarnConclusionDO emergencyWarnConclusionDO;//工单小结
    //通知对象
    private List<Map<String,Object>> noticePersons;//通知对象
    private String otherDoctorDistance;//其他医生定位信息
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getServeLat() {
        return serveLat;
    }
    public void setServeLat(String serveLat) {
        this.serveLat = serveLat;
    }
    public String getServeLon() {
        return serveLon;
    }
    public void setServeLon(String serveLon) {
        this.serveLon = serveLon;
    }
    public String getServeAddress() {
        return serveAddress;
    }
    public void setServeAddress(String serveAddress) {
        this.serveAddress = serveAddress;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
    public String getLiveAddress() {
        return liveAddress;
    }
    public void setLiveAddress(String liveAddress) {
        this.liveAddress = liveAddress;
    }
    public Integer getOrderSource() {
        return orderSource;
    }
    public void setOrderSource(Integer orderSource) {
        this.orderSource = orderSource;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public Integer getEmergencyCancel() {
        return emergencyCancel;
    }
    public void setEmergencyCancel(Integer emergencyCancel) {
        this.emergencyCancel = emergencyCancel;
    }
    public String getEmergencyCancelName() {
        return emergencyCancelName;
    }
    public void setEmergencyCancelName(String emergencyCancelName) {
        this.emergencyCancelName = emergencyCancelName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Map<String, Object> getInformation() {
        return information;
    }
    public void setInformation(Map<String, Object> information) {
        this.information = information;
    }
    public EmergencyWarnConclusionDO getEmergencyWarnConclusionDO() {
        return emergencyWarnConclusionDO;
    }
    public void setEmergencyWarnConclusionDO(EmergencyWarnConclusionDO emergencyWarnConclusionDO) {
        this.emergencyWarnConclusionDO = emergencyWarnConclusionDO;
    }
    public List<Map<String, Object>> getNoticePersons() {
        return noticePersons;
    }
    public void setNoticePersons(List<Map<String, Object>> noticePersons) {
        this.noticePersons = noticePersons;
    }
    public String getOtherDoctorDistance() {
        return otherDoctorDistance;
    }
    public void setOtherDoctorDistance(String otherDoctorDistance) {
        this.otherDoctorDistance = otherDoctorDistance;
    }
}

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

@ -0,0 +1,15 @@
package com.yihu.jw.care.dao.security;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnCancelLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/7.
 */
public interface EmergencyWarnCancelLogDao extends PagingAndSortingRepository<EmergencyWarnCancelLogDO,String>,
        JpaSpecificationExecutor<EmergencyWarnCancelLogDO> {
}

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

@ -0,0 +1,18 @@
package com.yihu.jw.care.dao.security;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/7.
 */
public interface EmergencyWarnConclusionDao extends PagingAndSortingRepository<EmergencyWarnConclusionDO,String>,
        JpaSpecificationExecutor<EmergencyWarnConclusionDO> {
    @Query("select c from EmergencyWarnConclusionDO c where c.orderId = ?1")
    EmergencyWarnConclusionDO findByOrderId(String orderId);
}

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

@ -0,0 +1,15 @@
package com.yihu.jw.care.dao.security;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnDoctorResponseDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/5/21.
 */
public interface EmergencyWarnDoctorResponseDao extends PagingAndSortingRepository<EmergencyWarnDoctorResponseDO,String>,
        JpaSpecificationExecutor<EmergencyWarnDoctorResponseDO> {
    EmergencyWarnDoctorResponseDO findByDoctorAndOrderId(String doctor,String orderId);
}

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

@ -1,19 +0,0 @@
package com.yihu.jw.care.dao.security;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringConclusionDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/4/7.
 */
public interface SecurityMonitoringConclusionDao extends PagingAndSortingRepository<SecurityMonitoringConclusionDO,String>,
        JpaSpecificationExecutor<SecurityMonitoringConclusionDO> {
    @Query("select c from SecurityMonitoringConclusionDO c where c.orderId = ?1")
    SecurityMonitoringConclusionDO findByOrderId(String orderId);
}

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

@ -1,14 +0,0 @@
package com.yihu.jw.care.dao.security;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderCancelLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/7.
 */
public interface SecurityMonitoringOrderCancelLogDao extends PagingAndSortingRepository<SecurityMonitoringOrderCancelLog,String>,
        JpaSpecificationExecutor<SecurityMonitoringOrderCancelLog> {
}

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

@ -19,11 +19,13 @@ public interface SecurityMonitoringOrderDao extends PagingAndSortingRepository<S
    @Modifying
    @Transactional
    @Query("update SecurityMonitoringOrderDO o set o.conclusionStatus = 1,o.status='4' where o.id=?1")
    @Query("update SecurityMonitoringOrderDO o set o.conclusionStatus = 1,o.status='0' where o.id=?1")
    void updateConclusionStatus(String orderId);
    @Modifying
    @Transactional
    @Query("update SecurityMonitoringOrderDO o set o.conclusionStatus = 1 where o.id=?1")
    void updateConclusionStatus2(String orderId);
    List<SecurityMonitoringOrderDO> findByPatientAndStatus(String patient,Integer status);
}

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

@ -1,12 +0,0 @@
package com.yihu.jw.care.dao.security;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderPatientConfirmLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/7.
 */
public interface SecurityMonitoringOrderPatientConfirmLogDao extends PagingAndSortingRepository<SecurityMonitoringOrderPatientConfirmLog,String>,
        JpaSpecificationExecutor<SecurityMonitoringOrderPatientConfirmLog> {
}

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

@ -154,7 +154,7 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "getUnCompleteOrderList")
    @ApiOperation(value = "医生查看居民救助列表(不包括已取消与已完成)")
    @ApiOperation(value = "医生查看居民救助列表(申请中)")
    public ListEnvelop getUnCompleteOrderList(@ApiParam(name="patientId",value = "居民id")
                                    @RequestParam(value = "patientId",required = false) String patientId,
                                    @ApiParam(name="doctor",value = "查看医生")
@ -197,16 +197,18 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = "updateConclusion")
    @ApiOperation(value = "医生编辑救助服务小结")
    @ObserverRequired
    public ObjEnvelop updateConclusion(@ApiParam(name="doctor",value = "doctor")
                                  @RequestParam(value = "doctor") String doctor,
                                  @ApiParam(name="orderId",value = "工单id")
                                  @RequestParam(value = "orderId") String orderId,
                                  @ApiParam(name="conclusion",value = "服务小结")
                                  @RequestParam(value = "conclusion") String conclusion,
                                  @ApiParam(name="conclusionImg",value = "附件多张图片用逗号隔开,非必传")
                                  @RequestParam(value = "conclusionImg",required = false) String conclusionImg){
    public ObjEnvelop updateConclusion(@ApiParam(value = "字典emergency_reason值",name = "treatment_status",required = true)
                                       @RequestParam Integer emergency_reason,
                                       @ApiParam(value = "字典emergency_treatment_status值",name = "treatment_status",required = true)
                                       @RequestParam Integer treatment_status,
                                       @ApiParam(value = "工单id", name = "orderId")
                                       @RequestParam(value = "orderId") String orderId,
                                       @ApiParam(value = "服务小结", name = "conclusion")
                                       @RequestParam(value = "conclusion", required = false) String conclusion,
                                       @ApiParam(value = "服务小结", name = "conclusion_img")
                                       @RequestParam(value = "conclusion_img", required = false) String conclusion_img){
        try {
            JSONObject result = assistanceService.updateConclusion(doctor,orderId,conclusion,conclusionImg);
            JSONObject result = assistanceService.updateConclusion(emergency_reason,treatment_status, orderId,conclusion,conclusion_img,getUID());
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
@ -302,4 +304,43 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError("发送失败"+e.getMessage());
        }
    }
    @PostMapping("responseOrder")
    @ApiOperation(value = "医生响应紧急预警(点击立即前往)")
    @ObserverRequired
    public ObjEnvelop responseOrder(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(value = "doctor", name = "doctor")
            @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            JSONObject result = assistanceService.responseOrder(orderId, doctor);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("操作成功",result.getString("resultMsg"));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "操作失败!" + e.getMessage());
        }
    }
    @PostMapping("errorWarning")
    @ApiOperation(value = "误报警")
    public ObjEnvelop errorWarning(@ApiParam(value = "工单id", name = "orderId", required = true)
                                   @RequestParam(value = "orderId") String orderId,
                                   @ApiParam(value = "误报警类型 字典emergency_cancel的code", name = "emergencyCancel", required = true)
                                   @RequestParam(value = "doctor", defaultValue = "4") Integer emergencyCancel){
        try {
            JSONObject result = assistanceService.errorWarning(orderId,emergencyCancel,getUID());
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("修改成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("修改失败");
        }
    }
}

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

@ -207,6 +207,10 @@ public class DoctorHealthController extends BaseController {
			if (xl != null) {
				map.put("xl", xl);
			}
			DevicePatientHealthIndex tw = healthIndexService.findLastByPatienIot(patient, 6);
			if (xl != null) {
				map.put("tw", tw);
			}
			return write(200, "查询成功", "data", map);
		} catch (Exception ex) {
			error(ex);

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/DoctorDoorCoachOrderController.java

@ -42,7 +42,7 @@ public class DoctorDoorCoachOrderController extends BaseController {
    private DoctorDoorCoachOrderService doctorDoorCoachOrderService;
    @PostMapping(value = "proxyCreate")
    @ApiOperation(value = "创建上门服务咨询--医生代预约")
    @ApiOperation(value = "创建上门预约咨询--医生代预约")
    public String create(@ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData) {
        try{
            JSONObject result = patientDoorCoachOrderService.proxyCreate(jsonData,getUID());
@ -191,7 +191,7 @@ public class DoctorDoorCoachOrderController extends BaseController {
    }
    @PostMapping("signIn")
    @ApiOperation(value = "上门服务签到")
    @ApiOperation(value = "上门预约签到")
    public String signIn(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/PatientDoorCoachOrderController.java

@ -51,7 +51,7 @@ public class PatientDoorCoachOrderController extends EnvelopRestEndpoint {
    }
    @PostMapping(value = "create")
    @ApiOperation(value = "创建上门服务工单")
    @ApiOperation(value = "创建上门预约工单")
    public Envelop create(@ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData) {
        JSONObject result = new JSONObject();
        try{

+ 30 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java

@ -1,6 +1,8 @@
package com.yihu.jw.care.endpoint.message;
import com.yihu.jw.care.service.message.PatientMessageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -8,10 +10,9 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by Bing on 2021/5/19.
@ -57,4 +58,29 @@ public class PatientMessageEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @GetMapping(value = "getSystemMessage")
    @ApiOperation("居民获取系统消息父级列表")
    public ListEnvelop getSystemMessage(@ApiParam(name = "patient",required = true)
                                        @RequestParam(value = "patient")String patient){
        return ListEnvelop.getSuccess("查询成功",patientMessageService.getSystemMessage(patient));
    }
    @GetMapping(value = "getSystemMessageList")
    @ApiOperation("居民获取系统消息子级列表")
    public ListEnvelop getSystemMessageList(@ApiParam(name = "patient",required = true)
                                            @RequestParam(value = "patient")String patient,
                                            @ApiParam(name = "type",required = true)
                                            @RequestParam(value = "type")String type
                                            ){
        return ListEnvelop.getSuccess("查询成功",patientMessageService.getSystemMessageList(patient,type));
    }
    @PostMapping(value = "/updateMessageRead")
    @ApiOperation("已读消息")
    public Envelop updateMessageRead(@ApiParam(name = "messageId",required = true)
                                         @RequestParam(value = "patient")String messageId){
        patientMessageService.updateMessageRead(messageId);
        return Envelop.getSuccess("查询成功");
    }
}

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

@ -3,8 +3,8 @@ package com.yihu.jw.care.endpoint.security;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringConclusionDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -87,7 +87,6 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "getSecurityOrderDetail")
    @ApiOperation(value = "获取安防工单详情")//
    public ObjEnvelop getSecurityOrderDetail(@ApiParam(name="orderId",value = "orderId",required = true)
@ -105,7 +104,25 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping("acceptOrder")
    @PostMapping("errorWarning")
    @ApiOperation(value = "误报警")
    public ObjEnvelop errorWarning(@ApiParam(value = "工单id", name = "orderId", required = true)
                                   @RequestParam(value = "orderId") String orderId,
                                   @ApiParam(value = "误报警类型 字典emergency_cancel的code", name = "emergencyCancel", required = true)
                                   @RequestParam(value = "doctor", defaultValue = "4") Integer emergencyCancel){
        try {
            JSONObject result = securityMonitoringOrderService.errorWarning(orderId,emergencyCancel,getUID());
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("修改成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("修改失败");
        }
    }
    @PostMapping("acceptOrder-- 未使用")
    @ApiOperation(value = "接单")
    @ObserverRequired
    public ObjEnvelop acceptOrder(
@ -128,11 +145,13 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @ObserverRequired
    public Envelop cancelOrder(
            @ApiParam(name = "orderId", value = "工单id") @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(name = "reason", value = "取消理由") @RequestParam(value = "reason", required = true) String reason,
            @ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true) String doctor) {
            @ApiParam(name = "reason", value = "取消理由") @RequestParam(value = "reason", required = false) String reason,
            @ApiParam(name = "doctor", value = "doctor") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "cancel_type", value = "取消类型 1-调度员取消,2-居民取消 3 医生取消")
            @RequestParam(value = "cancel_type",required = false) Integer cancel_type) {
        JSONObject result = new JSONObject();
        try{
            result = securityMonitoringOrderService.cancelOrder(orderId, 2, reason,doctor);
            result = securityMonitoringOrderService.cancelOrder(orderId, cancel_type, reason,doctor);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
@ -145,7 +164,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    }
    @PostMapping("signIn")
    @ApiOperation(value = "上门服务签到")
    @ApiOperation(value = "服务签到-未使用")
    @ObserverRequired
    public ObjEnvelop signIn(
            @ApiParam(value = "工单id", name = "orderId")
@ -176,16 +195,19 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @ObserverRequired
    @ApiOperation("编辑保存服务工单小结")
    public ObjEnvelop updateDoorConclusion(
            @ApiParam(value = "处置状态",name = "manageStatus 1已确认安全 2已转送医疗机构 3已处置完成",required = true)
            @RequestParam Integer manageStatus,
            @ApiParam(value = "字典emergency_reason值",name = "treatment_status",required = true)
            @RequestParam Integer emergency_reason,
            @ApiParam(value = "字典emergency_treatment_status值",name = "treatment_status",required = true)
            @RequestParam Integer treatment_status,
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,
            @RequestParam(value = "orderId") String orderId,
            @ApiParam(value = "服务小结", name = "conclusion")
            @RequestParam(value = "conclusion", required = true) String conclusion,
            @ApiParam(value = "补录状态", name = "examPapeStatus")
            @RequestParam(value = "examPapeStatus", required = false) Integer examPapeStatus) {
            @RequestParam(value = "conclusion", required = false) String conclusion,
            @ApiParam(value = "服务小结", name = "conclusion_img")
            @RequestParam(value = "conclusion_img", required = false) String conclusion_img
            ) {
        try {
            JSONObject result = securityMonitoringOrderService.updateDoorConclusion(manageStatus, orderId,conclusion,examPapeStatus);
            JSONObject result = securityMonitoringOrderService.updateDoorConclusion(emergency_reason,treatment_status, orderId,conclusion,conclusion_img);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
@ -231,7 +253,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
                }
            }
            // 根据orderId查询工单小结表
            SecurityMonitoringConclusionDO doorConclusion = securityMonitoringOrderService.getDoorConclusion(orderId);
            EmergencyWarnConclusionDO doorConclusion = securityMonitoringOrderService.getDoorConclusion(orderId);
            return ObjEnvelop.getSuccess("获取成功", doorConclusion);
        } catch (Exception e) {
            e.printStackTrace();
@ -239,7 +261,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping("saveOrderFinishBydoctor")
    @PostMapping("saveOrderFinishBydoctor--未使用")
    @ApiOperation(value = "医生确认完成工单")
    @ObserverRequired
    public ObjEnvelop saveOrderFinishBydoctor(
@ -273,7 +295,6 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("获取居民监护信息")
    @RequestMapping(value = "patientMonitoringInfo", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
@ -286,4 +307,73 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError("查询失败");
        }
    }
    @PostMapping("responseOrder")
    @ApiOperation(value = "医生响应紧急预警(点击立即前往)")
    @ObserverRequired
    public ObjEnvelop responseOrder(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(value = "doctor", name = "doctor")
            @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            JSONObject result = securityMonitoringOrderService.responseOrder(orderId, doctor);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("操作成功",result.getString("resultMsg"));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "操作失败!" + e.getMessage());
        }
    }
    @PostMapping(value = "updateDoctorLocation")
    @ApiOperation(value = "更新医生定位信息")
    @ObserverRequired
    public ObjEnvelop updateDoctorLocation(@ApiParam(name="doctor",value = "doctor")
                                           @RequestParam(value = "doctor") String doctor,
                                           @ApiParam(name="orderId",value = "工单id",required =false )
                                           @RequestParam(value = "orderId",required = false) String orderId,
                                           @ApiParam(name="doctorAddress",value = "医生地址描述")
                                           @RequestParam(value = "doctorAddress") String doctorAddress,
                                           @ApiParam(name="doctorLat",value = "医生当前定位纬度")
                                           @RequestParam(value = "doctorLat") String doctorLat,
                                           @ApiParam(name="doctorLon",value = "医生当前定位经度")
                                           @RequestParam(value = "doctorLon") String doctorLon){
        try {
            JSONObject result = securityMonitoringOrderService.updateDoctorLocation(doctor,orderId,doctorAddress,doctorLat,doctorLon);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("定位更新成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("定位更新失败"+e.getMessage());
        }
    }
    @PostMapping(value = "updatePatientLocation")
    @ApiOperation(value = "更新患者定位信息")
    @ObserverRequired
    public ObjEnvelop updatePatientLocation(@ApiParam(name="patient",value = "patient")
                                            @RequestParam(value = "patient") String patient,
                                            @ApiParam(name="patientAddress",value = "患者地址描述")
                                            @RequestParam(value = "patientAddress") String patientAddress,
                                            @ApiParam(name="patientLat",value = "患者当前定位纬度")
                                            @RequestParam(value = "patientLat") String patientLat,
                                            @ApiParam(name="patientLon",value = "患者当前定位经度")
                                            @RequestParam(value = "patientLon") String patientLon){
        try {
            JSONObject result = securityMonitoringOrderService.updatePatientLocation(patient,patientAddress,patientLat,patientLon);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("定位更新成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("定位更新失败"+e.getMessage());
        }
    }
}

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

@ -6,22 +6,33 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.assistance.EmergencyAssistanceDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.EmergencyWarnConclusionDao;
import com.yihu.jw.care.dao.security.EmergencyWarnDoctorResponseDao;
import com.yihu.jw.care.dao.sign.ServicePackageItemDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnDoctorResponseDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.emergency.EmergencyOrderVO;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
@ -68,10 +79,20 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    private PatientDeviceService patientDeviceService;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private EmergencyWarnConclusionDao emergencyWarnConclusionDao;
    @Value("${baiduApi.AK}")
    private String baiduAk;
    @Value("${baiduApi.url}")
    private String baiduUrl;
    @Autowired
    private EmergencyWarnDoctorResponseDao emergencyWarnDoctorResponseDao;
    @Autowired
    private PatientFamilyMemberService familyMemberService;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private ConsultDao consultDao;
    /**
     * 新建居民紧急救助
@ -116,12 +137,12 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            }
        }
        if (emergencyAssistanceDao.findByPatientAndStatus(patient,1)!=null){
            String failMsg = "当前居民存在申请中的救助,请完成后再申请";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
//        if (emergencyAssistanceDao.findByPatientAndStatus(patient,1)!=null){
//            String failMsg = "当前居民存在申请中的救助,请完成后再申请";
//            result.put(ResponseContant.resultFlag, ResponseContant.fail);
//            result.put(ResponseContant.resultMsg,failMsg);
//            return result;
//        }
        //签约防走失服务包
        String sql ="SELECT i.code,i.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
@ -198,6 +219,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    public JSONObject getOrderDetail(String orderID){
        JSONObject result = new JSONObject();
        EmergencyOrderVO emergencyOrderVO = new EmergencyOrderVO();
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderID);
        if (assistanceDO==null){
            String failMsg = "当前救助工单不存在";
@ -205,7 +227,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        if (assistanceDO.getOrderSource()==2){//手环发起的获取手环坐标
        if (assistanceDO.getOrderSource()==2){//手环发起的紧急救助获取手环坐标
            try {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(assistanceDO.getPatient(),"4");
                if (devicePatientDeviceDos.size()>0){
@ -221,7 +243,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
                                    Double lon = pointJsonObject.getDouble("lon");
                                    assistanceDO.setServeLat(lat+"");
                                    assistanceDO.setServeLon(lon+"");
                                    emergencyAssistanceDao.save(assistanceDO);
                                    assistanceDO = emergencyAssistanceDao.save(assistanceDO);
                                }
                            }
                        }
@ -231,61 +253,156 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            }catch (Exception e){
            }
        }
        BasePatientDO patientDO = patientDao.findById(assistanceDO.getPatient());
        Integer statustemp = Integer.valueOf(assistanceDO.getStatus()+"");
        String statusName = "";
        switch (statustemp){
            case -2:statusName="误警报";break;
            case -1:statusName="已取消";break;
            case 0:statusName="已完成";break;
            case 1:statusName="申请中";break;
        }
        emergencyOrderVO.setStatusName(statusName);
        emergencyOrderVO.setOrderId(orderID);
        emergencyOrderVO.setStatus(assistanceDO.getStatus());
        emergencyOrderVO.setCreateTime(assistanceDO.getCreateTime());
        emergencyOrderVO.setServeLat(assistanceDO.getServeLat());
        emergencyOrderVO.setServeLon(assistanceDO.getServeLon());
        emergencyOrderVO.setServeAddress(assistanceDO.getServeAddress());
        emergencyOrderVO.setPatient(assistanceDO.getPatient());
        emergencyOrderVO.setPatientName(assistanceDO.getPatientName());
        emergencyOrderVO.setSex(patientDO.getSex());
        if(StringUtils.isNotBlank(patientDO.getIdcard())){
            emergencyOrderVO.setAge((IdCardUtil.getAgeForIdcard(patientDO.getIdcard()))+"");
        }
        emergencyOrderVO.setLiveAddress(patientDO.getAddress());
        emergencyOrderVO.setOrderSource(assistanceDO.getOrderSource());
        if(assistanceDO.getStatus()==-2){//误报警
            emergencyOrderVO.setUpdateUserName(assistanceDO.getUpdateUserName());
            emergencyOrderVO.setUpdateUser(assistanceDO.getUpdateUser());
            emergencyOrderVO.setUpdateTime(assistanceDO.getUpdateTime());
            emergencyOrderVO.setEmergencyCancel(assistanceDO.getEmergencyCancel());
        }
        emergencyOrderVO.setUpdateTime(assistanceDO.getUpdateTime());
        if (assistanceDO.getStatus()==-1){//已取消
            emergencyOrderVO.setUpdateTime(assistanceDO.getUpdateTime());
        }
        //小结
        if (assistanceDO.getStatus()==0){
            EmergencyWarnConclusionDO conclusionDO = emergencyWarnConclusionDao.findByOrderId(assistanceDO.getId());
            if (conclusionDO!=null){
                emergencyOrderVO.setEmergencyWarnConclusionDO(conclusionDO);
            }
        }
        //附加信息 紧急救助无
        //通知对象
        List<Map<String,Object>> noticePersons = new ArrayList<>();
        JSONArray familyArr =  familyMemberService.getPatientMembers(assistanceDO.getPatient(),null,null,null);
        for (int i=0;i<familyArr.size();i++){
            String patientId = familyArr.getJSONObject(i).getString("id");
            BasePatientDO patientDO1 = patientDao.findById(patientId);
            Map<String,Object> noticeObj = new HashMap<>();
            noticeObj.put("type","0");
            noticeObj.put("typeName","家属");
            noticeObj.put("id",patientDO1.getId());
            noticeObj.put("name",patientDO1.getName());
            noticeObj.put("photo",patientDO1.getPhoto());
            noticeObj.put("mobile",patientDO1.getMobile());
            List<Map<String,Object>> arr = new ArrayList<>();
            Map<String,Object> tmp = new HashMap<>();
            tmp.put("name","系统预警");
            tmp.put("status",0);
            SystemMessageDO messageDO = systemMessageDao.findByRelationCodeAndReceiver(assistanceDO.getId(),patientId);
            if (messageDO != null){
                if (StringUtils.isNotBlank(messageDO.getIsRead())){
                    tmp.put("status",Integer.parseInt(messageDO.getIsRead()));
                }
            }
            arr.add(tmp);
            noticeObj.put("response",arr);
            noticePersons.add(noticeObj);
        }
        List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(assistanceDO.getTeamCode());
        double distance = 0.0;
        JSONArray otherDoctorDistance = new JSONArray();
        JSONObject otherDoctorDistanceObj = new JSONObject();
        if (assistanceDO.getStatus()==1){
            StringBuilder origins = new StringBuilder("");
            for (BaseDoctorDO doctorDO:doctorDOS) {
                if (StringUtils.isBlank(doctorDO.getDoctorLat()) || StringUtils.isBlank(doctorDO.getDoctorLon())) {
                    continue;
                }
                double distanceTmp = countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(doctorDO.getDoctorLat()),Double.parseDouble(doctorDO.getDoctorLon()));
                otherDoctorDistanceObj = new JSONObject();
                otherDoctorDistanceObj.put("doctor",doctorDO.getId());
                otherDoctorDistanceObj.put("doctorName",doctorDO.getName());
                otherDoctorDistanceObj.put("doctorAddress",doctorDO.getDoctorLocateAddress());
                otherDoctorDistanceObj.put("doctorLon",doctorDO.getDoctorLon());
                otherDoctorDistanceObj.put("doctorLat",doctorDO.getDoctorLat());
                otherDoctorDistanceObj.put("distance",distanceTmp);//两点距离
                otherDoctorDistance.add(otherDoctorDistanceObj);
                origins.append(doctorDO.getDoctorLat()+","+doctorDO.getDoctorLon()+"|");
        StringBuilder origins = new StringBuilder("");
        for (BaseDoctorDO doctorDO:doctorDOS) {
            Map<String,Object> noticeObj = new HashMap<>();
            noticeObj.put("type","1");
            noticeObj.put("typeName","助老员");
            noticeObj.put("id",doctorDO.getId());
            noticeObj.put("name",doctorDO.getName());
            noticeObj.put("photo",doctorDO.getPhoto());
            noticeObj.put("mobile",doctorDO.getMobile());
            List<Map<String,Object>> arr = new ArrayList<>();
            Map<String,Object> tmp = new HashMap<>();
            tmp.put("name","系统预警");
            tmp.put("status",0);
            if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doctorDO.getId(),assistanceDO.getId())!=null){
                tmp.put("status",1);
            }
            if (StringUtils.isNotBlank(origins.toString())){
                origins.deleteCharAt(origins.length()-1);
            arr.add(tmp);
            noticeObj.put("response",arr);
            noticePersons.add(noticeObj);
            if (StringUtils.isBlank(doctorDO.getDoctorLat()) || StringUtils.isBlank(doctorDO.getDoctorLon())) {
                continue;
            }
            String destinations = assistanceDO.getServeLat()+","+assistanceDO.getServeLon();
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("origins", origins.toString()));
            params.add(new BasicNameValuePair("destinations", destinations));
            params.add(new BasicNameValuePair("output", "json"));
            params.add(new BasicNameValuePair("ak", baiduAk));
            //前端做距离计算
//            String url = baiduUrl+"routematrix/v2/driving";
//            String response = httpClientUtil.get(url,params,"UTF-8");
//            JSONObject responseObj = JSONObject.parseObject(response);
//            if (responseObj.getInteger("status")==0){
//                JSONArray resultArr = responseObj.getJSONArray("result");
//                int length = resultArr.size()>otherDoctorDistance.size()?resultArr.size():otherDoctorDistance.size();
//                for (int i=0;i<length;i++){
//                    JSONObject disTmp = resultArr.getJSONObject(i);
//                    JSONObject docTmp = otherDoctorDistance.getJSONObject(i);
//                    docTmp.put("time",disTmp.getJSONObject("duration").getString("text"));
//                    docTmp.put("distance",disTmp.getJSONObject("distance").getInteger("value")/1000.0);//实际路线距离
//                    docTmp.put("distanceMeter",disTmp.getJSONObject("distance").getInteger("value"));
//                }
//                otherDoctorDistance.sort(Comparator.comparing(obj -> ((JSONObject) obj).getInteger("distance")));
            double distanceTmp = countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(doctorDO.getDoctorLat()),Double.parseDouble(doctorDO.getDoctorLon()));
            otherDoctorDistanceObj = new JSONObject();
            otherDoctorDistanceObj.put("doctor",doctorDO.getId());
            otherDoctorDistanceObj.put("doctorName",doctorDO.getName());
            otherDoctorDistanceObj.put("doctorAddress",doctorDO.getDoctorLocateAddress());
            otherDoctorDistanceObj.put("doctorLon",doctorDO.getDoctorLon());
            otherDoctorDistanceObj.put("doctorLat",doctorDO.getDoctorLat());
            otherDoctorDistanceObj.put("distance",distanceTmp);//两点距离
            otherDoctorDistance.add(otherDoctorDistanceObj);
            origins.append(doctorDO.getDoctorLat()+","+doctorDO.getDoctorLon()+"|");
        }
        if (StringUtils.isNotBlank(origins.toString())){
            origins.deleteCharAt(origins.length()-1);
        }
        String destinations = assistanceDO.getServeLat()+","+assistanceDO.getServeLon();
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("origins", origins.toString()));
        params.add(new BasicNameValuePair("destinations", destinations));
        params.add(new BasicNameValuePair("output", "json"));
        params.add(new BasicNameValuePair("ak", baiduAk));
        //前端做距离计算
//        String url = baiduUrl+"routematrix/v2/driving";
//        String response = httpClientUtil.get(url,params,"UTF-8");
//        JSONObject responseObj = JSONObject.parseObject(response);
//        if (responseObj.getInteger("status")==0){
//            JSONArray resultArr = responseObj.getJSONArray("result");
//            int length = resultArr.size()>otherDoctorDistance.size()?resultArr.size():otherDoctorDistance.size();
//            for (int i=0;i<length;i++){
//                JSONObject disTmp = resultArr.getJSONObject(i);
//                JSONObject docTmp = otherDoctorDistance.getJSONObject(i);
//                docTmp.put("time",disTmp.getJSONObject("duration").getString("text"));
//                docTmp.put("distance",disTmp.getJSONObject("distance").getInteger("value")/1000.0);//实际路线距离
//                docTmp.put("distanceMeter",disTmp.getJSONObject("distance").getInteger("value"));
//            }
//            otherDoctorDistance.sort(Comparator.comparing(obj -> ((JSONObject) obj).getInteger("distance")));
//        }
        emergencyOrderVO.setOtherDoctorDistance(otherDoctorDistanceObj.toJSONString());
        emergencyOrderVO.setNoticePersons(noticePersons);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONStringWithDateFormat(emergencyOrderVO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
        //获取咨询
        ConsultDo consult = consultDao.queryByRelationCode(orderID);
        if (null != consult) {
            String sessionId = assistanceDO.getPatient() + "_" + consult.getId() + "_" + consult.getType();
            jsonObject.put("sessionId",sessionId);
        }
        else {
            jsonObject.put("sessionId",null);
        }
        assistanceDO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
        BasePatientDO patientDO = patientDao.findById(assistanceDO.getPatient());
        assistanceDO.setPatientPhoto(patientDO.getPhoto());
        assistanceDO.setPatientSex(patientDO.getSex());
        assistanceDO.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,JSONObject.parseObject(JSON.toJSONStringWithDateFormat(assistanceDO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue)));
        result.put(ResponseContant.resultMsg,jsonObject);
        return result;
    }
@ -510,13 +627,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    /**
     *
     * @param doctor
     * @param orderId
     * @param conclusion 必传
     * @param conclusionImg 非必传
     * @return
     */
    public JSONObject updateConclusion(String doctor,String orderId,String conclusion,String conclusionImg){
    public JSONObject updateConclusion(Integer emergency_reason,Integer treatment_status,String orderId,String conclusion,String conclusion_img,String doctor){
        JSONObject result = new JSONObject();
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderId);
        if (assistanceDO==null){
@ -525,12 +637,29 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        assistanceDO.setConclusion(conclusion);
        if (StringUtils.isNotBlank(conclusionImg)){
            assistanceDO.setConclusionImg(conclusionImg);
        }
        //完成医生
        EmergencyWarnConclusionDO doorConclusion =  emergencyWarnConclusionDao.findByOrderId(orderId);
        BaseDoctorDO doctorDO = doctorDao.findById(doctor);
        if (doctorDO==null){
            doctorDO = doctorDao.findById(assistanceDO.getDoctor());
        }
        if (doorConclusion==null){
            doorConclusion = new EmergencyWarnConclusionDO();
            doorConclusion.setOrderId(orderId);
            doorConclusion.setPatient(assistanceDO.getPatient());
            doorConclusion.setPatientName(assistanceDO.getPatientName());
            doorConclusion.setDoctor(doctorDO.getId());
            doorConclusion.setDoctorName(doctorDO.getName());
        }
        doorConclusion.setEmergencyReason(emergency_reason);
        doorConclusion.setEmergencyTreatmentStatus(treatment_status);
        doorConclusion.setConclusion(conclusion);
        doorConclusion.setConclusionImg(conclusion_img);
        emergencyWarnConclusionDao.save(doorConclusion);
//        assistanceDO.setConclusion(conclusion);
//        if (StringUtils.isNotBlank(conclusion_img)){
//            assistanceDO.setConclusionImg(conclusion_img);
//        }
        //完成医生
        assistanceDO.setDoctor(doctor);
        assistanceDO.setDoctorName(doctorDO.getName());
        assistanceDO.setCompleteTime(new Date());
@ -606,6 +735,49 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        return result;
    }
    public JSONObject responseOrder(String orderId,String doctor){
        JSONObject result = new JSONObject();
        EmergencyAssistanceDO one = emergencyAssistanceDao.findOne(orderId);
        if (one==null){
            String failMsg = "工单不存在" ;
            result.put("resultFlag", 0);
            result.put("resultMsg", failMsg);
            return result;
        }
        if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doctor,orderId)==null){
            EmergencyWarnDoctorResponseDO responseDO = new EmergencyWarnDoctorResponseDO();
            responseDO.setOrderId(orderId);
            responseDO.setDoctor(doctor);
            responseDO.setResponseTime(new Date());
            emergencyWarnDoctorResponseDao.save(responseDO);
        }
        result.put("resultFlag", 1);
        result.put("resultMsg", "success");
        return result;
    }
    public JSONObject errorWarning(String orderId,Integer emergencyCancel,String doctor){
        JSONObject result = new JSONObject();
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderId);
        if (assistanceDO==null){
            String failMsg = "工单不存在!";
            result.put("resultFlag", 0);
            result.put("resultMsg", failMsg);
            return result;
        }
        BaseDoctorDO doctorDO = doctorDao.findById(doctor);
        assistanceDO.setUpdateTime(new Date());
        assistanceDO.setUpdateUserName(doctorDO.getName());
        assistanceDO.setUpdateUser(doctorDO.getId());
        assistanceDO.setEmergencyCancel(emergencyCancel);
        emergencyAssistanceDao.save(assistanceDO);
        result = getOrderDetail(orderId);
        return result;
    }
    public JSONObject sendQuickMessage(String orderId,String patient,String content){
        JSONObject result = new JSONObject();
        ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(orderId);

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

@ -6,6 +6,7 @@ import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
@ -15,6 +16,8 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
@ -57,6 +60,8 @@ public class ConsultTeamService {
    private BaseDoorCoachOrderDao baseDoorCoachOrderDao;
    @Autowired
    private PatientFamilyMemberService familyMemberService;
    @Autowired
    private SystemMessageDao systemMessageDao;
    public JSONObject updateIMMsg(String sessionId,String sessionType,String msgId,String content){
@ -187,9 +192,33 @@ public class ConsultTeamService {
        //4、 紧急救助咨询-参与者
        JSONObject participants = new JSONObject();
        participants.put(patient, 0);
        if (StringUtils.isNotBlank(proxyPatient)&&(!proxyPatient.equals(patient))){
            participants.put(proxyPatient, 0);
        JSONArray familyArr =  familyMemberService.getPatientMembers(patient,null,null,null);
        for (int i=0;i<familyArr.size();i++){
            JSONObject tmp = familyArr.getJSONObject(i);
            String patientId = tmp.getString("id");
            if (patient.equals(patientId)){
                continue;
            }
            String name = tmp.getString("name");
            //创建家属系统消息
            SystemMessageDO messageDO = new SystemMessageDO();
            messageDO.setTitle("紧急救助");
            messageDO.setType("50");//50 紧急预警通知
            messageDO.setCode("20");//  20 relationCode为紧急救助工单id 22安防工单id
            messageDO.setSender(patientDO.getId());
            messageDO.setSenderName(patientDO.getName());
            messageDO.setRelationCode(orderId);
            messageDO.setReceiver(patientId);
            messageDO.setReceiverName(name);
            messageDO.setOver("0");
            messageDO.setData(patientDO.getName()+"发起紧急救助工单!");
            messageDO.setDel("1");
            messageDO.setIsRead("0");
            messageDO.setCreateTime(new Date());
            systemMessageDao.save(messageDO);
            participants.put(patientId, 0);
        }
        //加入团队医生
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient,"emergencyAssistance");
        for(Map<String,Object> map:doctorList){
@ -274,7 +303,7 @@ public class ConsultTeamService {
        String content = patientDO.getName() + "-上门辅导服务咨询";
        JSONObject messages = imUtill.getCreateTopicMessage(patient, patientDO.getName(), consult.getTitle(), content, consult.getImages(), "");
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_ONDOOR_NURSING);
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_DOOR_COACH);
        if (imResponseJson == null || imResponseJson.getInteger("status") == -1) {
            String failMsg = "发起服务咨询时:IM" + imResponseJson.getString("message");
            result.put(ResponseContant.resultFlag, ResponseContant.success);
@ -353,15 +382,32 @@ public class ConsultTeamService {
        //4、安防警报咨询-参与者  提供服务的助老员 老人本人 家属
        JSONObject participants = new JSONObject();
        participants.put(patient, 0);
        if (StringUtils.isNotBlank(proxyPatient)&&(!proxyPatient.equals(patient))){
            participants.put(proxyPatient, 0);
        }
        //家属
        JSONArray familyArr =  familyMemberService.getPatientMembers(patient,null,null,null);
        for (int i=0;i<familyArr.size();i++){
            JSONObject tmp = familyArr.getJSONObject(0);
            String familyId = tmp.getString("id");
            participants.put(familyId, 0);
            JSONObject tmp = familyArr.getJSONObject(i);
            String patientId = tmp.getString("id");
            if (patient.equals(patientId)){
                continue;
            }
            String name = tmp.getString("name");
            //创建家属系统消息
            SystemMessageDO messageDO = new SystemMessageDO();
            messageDO.setTitle("安防监护");
            messageDO.setType("50");
            messageDO.setCode("22");
            messageDO.setSender(patientDO.getId());
            messageDO.setSenderName(patientDO.getName());
            messageDO.setRelationCode(orderId);
            messageDO.setReceiver(patientId);
            messageDO.setReceiverName(name);
            messageDO.setOver("0");
            messageDO.setData(patientDO.getName()+"发起安防警报工单!");
            messageDO.setDel("1");
            messageDO.setIsRead("0");
            messageDO.setCreateTime(new Date());
            systemMessageDao.save(messageDO);
            participants.put(patientId, 0);
        }
@ -374,7 +420,7 @@ public class ConsultTeamService {
        String content = patientDO.getName() + "发起安防警报申请";
        JSONObject messages = imUtill.getCreateTopicMessage(patient, patientDO.getName(), consult.getTitle(), content, consult.getImages(), "");
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_EMERGENCY_ASSISTANCE);
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_SECURITY_WARN);
        if (imResponseJson == null || imResponseJson.getInteger("status") == -1) {
            String failMsg = "发起服务咨询时:IM" + imResponseJson.getString("message");
            result.put(ResponseContant.resultFlag, ResponseContant.success);

+ 10 - 10
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java

@ -447,7 +447,7 @@ public class DoctorDoorCoachOrderService {
            first = first.replace("key2", null != doorServiceOrder.getDoctorName() ? doorServiceOrder.getDoctorName() : "");
            List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
            String openId = basePatientWechatDos.get(0).getOpenid();
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyjjd",openId,first,null,null,30,json, DateUtil.dateToChineseDate(new Date()),"上门服务已接单");
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyjjd",openId,first,null,null,30,json, DateUtil.dateToChineseDate(new Date()),"上门预约已接单");
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
@ -612,7 +612,7 @@ public class DoctorDoorCoachOrderService {
            json.put("finish",finish);
            List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
            String openId = basePatientWechatDos.get(0).getOpenid();
            String first="key1预约上门服务医生已完成服务。".replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            String first="key1预约上门预约医生已完成服务。".replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","fwyspf",openId,first,null,null,31,json,DateUtil.dateToChineseDate(new Date()),"服务医生评分");
        }catch (Exception e){
@ -637,7 +637,7 @@ public class DoctorDoorCoachOrderService {
    }
    /**
     * 系统更新医生上门服务工单状态
     * 系统更新医生上门预约工单状态
     * @param doctor
     * @param dispatchOrderStatus
     */
@ -706,7 +706,7 @@ public class DoctorDoorCoachOrderService {
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Map<String, Integer> map = new HashMap<>();
        Integer all = list.size();
        Integer all = 0;
        Integer waitForAccept = 0;//待接单
        Integer waitForServe = 0;//待服务
        Integer served = 0;//已完成
@ -740,6 +740,7 @@ public class DoctorDoorCoachOrderService {
               }
           }
       }
       all = waitForAccept+waitForServe+served+cancel;
       map.put("all",all);
       map.put("waitForAccept",waitForAccept);
       map.put("waitForServe",waitForServe);
@ -808,7 +809,7 @@ public class DoctorDoorCoachOrderService {
                "  o.serve_lat as lat, " +
                "  o.`status` as status, " +
                "  o.`dispatcher_name` as dispatcherName, " +
                "  concat( o.patient,'_' ,c.id, '_',o.`number`,'_11' ) as sessionId " +
                "  concat( o.patient,'_' ,c.id, '_',o.`number`,'_21' ) as sessionId " +
                patientTypeTemp +
                " FROM " +
                " ( base_door_coach_order o " +
@ -832,7 +833,7 @@ public class DoctorDoorCoachOrderService {
                " LEFT JOIN base_patient p ON o.patient = p.id " +
                applicationSql +
                " WHERE  " +
                "  o.hospital = '{hospital}' " +buffer+
                "  o.hospital = '{hospital}' and o.type != 3 " +buffer+
                " AND (o.`status` = {status} or -100 = {status})";
        String finqlCountSql = countSql.replace("{hospital}", hospital)
@ -841,10 +842,9 @@ public class DoctorDoorCoachOrderService {
        List<Map<String,Object>> sqlResultlist = new ArrayList<>();
        try {
            sqlResultlist = jdbcTemplate.queryForList(finalSql);
            logger.info(finalSql);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库查询【调度员】上门服务工单列表信息失败:" + e.getMessage());
            result.put(ResponseContant.resultMsg, "从数据库查询【调度员】上门预约工单列表信息失败:" + e.getMessage());
            return result;
        }
@ -853,7 +853,7 @@ public class DoctorDoorCoachOrderService {
            count = jdbcTemplate.queryForObject(finqlCountSql, Integer.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库统计【调度员】上门服务工单数量失败:" + e.getMessage());
            result.put(ResponseContant.resultMsg, "从数据库统计【调度员】上门预约工单数量失败:" + e.getMessage());
            return result;
        }
@ -991,7 +991,7 @@ public class DoctorDoorCoachOrderService {
                String notFinishSql ="select o.id,o.number,o.patient,o.patient_name,o.patient_phone,o.patient_expected_serve_time,o.`status`, CASE p.sex when 1 then '男' when 2 THEN '女' END as sex,p.idcard, " +
                        "year(now()) - ((CASE LENGTH(p.idcard) WHEN 18 THEN substring(p.idcard, 7, 4) WHEN 15 THEN CONCAT('19',substring(p.idcard, 7, 2)) END )) as age , p.photo,o.serve_lat AS lat,o.serve_lon AS lon,o.id AS orderId " +
                        "from base_door_coach_order o LEFT JOIN base_patient p on o.patient = p.id and p.patient_status=1  " +
                        "where o.doctor ='"+doctor + "' and o.status in (2,3,4)";
                        "where o.doctor ='"+doctor + "' and o.status in (2,3,4,5)";
                List<Map<String, Object>> notFinishList = jdbcTemplate.queryForList(notFinishSql);
                map.put("notFinishList", notFinishList);
            }

+ 14 - 13
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java

@ -104,7 +104,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
     */
    public JSONObject create(String jsonData) {
        logger.info("创建上门服务jsonData参数:" + jsonData);
        logger.info("创建上门预约jsonData参数:" + jsonData);
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam;
@ -122,7 +122,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), BaseDoorCoachOrderDO.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "上门服务工单服务基本信息:" + e.getMessage();
            String failMsg = "上门预约工单服务基本信息:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
@ -160,7 +160,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                });
        if(bool){
            String failMsg = "当前服务对象存在未完成的上门服务,请先完成该服务!";
            String failMsg = "当前服务对象存在未完成的上门预约,请先完成该服务!";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
@ -169,7 +169,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
        orderDO.setCreateTime(new Date());
        //判断创建上门服务类型,发起类型(1本人发起 2家人待预约 3医生代预约)
        //判断创建上门预约类型,发起类型(1本人发起 2家人待预约 3医生代预约)
        if(orderDO.getProxyPatient().equals(orderDO.getPatient())){
            orderDO.setType(1);
        }else if(!orderDO.getProxyPatient().equals(orderDO.getPatient())){
@ -249,7 +249,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), BaseDoorCoachOrderDO.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "上门服务工单服务基本信息:" + e.getMessage();
            String failMsg = "上门预约工单服务基本信息:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
@ -281,7 +281,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                    });
            if(bool){
                String failMsg = "当前服务对象存在未完成的上门服务,请先完成该服务!";
                String failMsg = "当前服务对象存在未完成的上门预约,请先完成该服务!";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                logger.error(failMsg);
@ -415,7 +415,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    }
    /**
     * 修改上门服务工单(包括医生,费用,居民确认信息等)
     * 修改上门预约工单(包括医生,费用,居民确认信息等)
     *
     * @param jsonData
     * @return
@ -492,7 +492,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    }
    /**
     * 上门服务工单服务基本信息
     * 上门预约工单服务基本信息
     *
     * @param result
     * @param jsonObjectParam
@ -505,7 +505,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            wlyyDoorServiceOrder = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), BaseDoorCoachOrderDO.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "上门服务工单服务基本信息:" + e.getMessage();
            String failMsg = "上门预约工单服务基本信息:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return new BaseDoorCoachOrderDO();
@ -595,7 +595,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        }
        JSONObject resObj = JSONObject.parseObject(response);
        if (resObj.getIntValue("status") == -1) {
            logger.error("上门服务工单消息发送失败:" + resObj.getString("message"));
            logger.error("上门预约工单消息发送失败:" + resObj.getString("message"));
            return result;
        }
        result = 1;
@ -922,7 +922,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                params.add(new BasicNameValuePair("openId", doctor.getOpenid()));
                params.add(new BasicNameValuePair("first", first));
                params.add(new BasicNameValuePair("remark", templateConfig.getRemark()));
                params.add(new BasicNameValuePair("keywords", "上门服务预约待派单"));
                params.add(new BasicNameValuePair("keywords", "上门预约待派单"));
                params.add(new BasicNameValuePair("keywords", signFamily.getHospitalName()));
                params.add(new BasicNameValuePair("keywords", doctorName));
                httpClientUtil.post(url, params, "UTF-8");
@ -946,7 +946,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                params.add(new BasicNameValuePair("openId", doctor.getOpenid()));
                params.add(new BasicNameValuePair("first", first));
                params.add(new BasicNameValuePair("remark", templateConfig.getRemark()));
                params.add(new BasicNameValuePair("keywords", "上门服务预约待接单"));
                params.add(new BasicNameValuePair("keywords", "上门预约待接单"));
                params.add(new BasicNameValuePair("keywords", signFamily.getHospitalName()));
                params.add(new BasicNameValuePair("keywords", doctorName));
                httpClientUtil.post(url, params, "UTF-8");
@ -1138,7 +1138,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Map<String, Integer> map = new HashMap<>();
        Integer all = list.size();
        Integer all = 0;
        Integer waitForAccept = 0;//待接单
        Integer waitForServe = 0;//待服务
        Integer served = 0;//已完成
@ -1172,6 +1172,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                }
            }
        }
        all = waitForAccept+waitForServe+served+cancel;
        map.put("all",all);
        map.put("waitForAccept",waitForAccept);
        map.put("waitForServe",waitForServe);

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java

@ -86,12 +86,12 @@ public class DoctorMessageService {
            result.put("bedApply",tmpJson);
        }
        if (typeNull||type.equals("11")){//安全监护
        if (typeNull||type.equals("11")){//安全监护 已取消已完成不可见
            JSONObject tmpJson = new JSONObject();
            count=0;
            List<Map<String,Object>> listTmp = new ArrayList<>();
            String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,serve_desc from base_security_monitoring_order ord where 1=1 " +
                    "and status <>-1 and status<> 7  ";
                    "and status <>-1 and status<> 0  ";
            sql+= "and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
@ -110,7 +110,7 @@ public class DoctorMessageService {
            }
            result.put("security",tmpJson);
        }
        if (typeNull||type.equals("12")){//紧急救助
        if (typeNull||type.equals("12")){//紧急救助 申请中
            JSONObject tmpJson = new JSONObject();
            count=0;
            List<Map<String,Object>> listTmp = new ArrayList<>();

+ 31 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -4,6 +4,8 @@ import com.yihu.jw.care.dao.message.OrgNoticeDao;
import com.yihu.jw.care.dao.message.UserNoticeDao;
import com.yihu.jw.entity.base.notice.UserNoticeDO;
import com.yihu.jw.entity.care.message.OrgNoticeDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
@ -25,6 +27,8 @@ public class PatientMessageService {
    private OrgNoticeDao orgNoticeDao;
    @Autowired
    private UserNoticeDao userNoticeDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
    public PageEnvelop getNoticeList(String patient,String beginTime, String endTime, int page, int size){
        page = page>0?page-1:0;
@ -64,4 +68,31 @@ public class PatientMessageService {
        }
        return orgNoticeDO;
    }
    /**
     *50 紧急预警系统消息
     *
     */
    public List<Map<String,Object>> getSystemMessage(String patient){
        String sql = " select A.*,B.notRead from " +
                "(select  count(1) as 'all',type,create_time  " +
                "from base_system_message where receiver = '"+patient+"' and del=1 and type='50' GROUP BY type ORDER BY create_time desc)A " +
                "LEFT JOIN (select count(1) notRead,type " +
                "from base_system_message where receiver = '"+patient+"' and is_read=0 and del=1 and type='50' GROUP BY type)B on A.type = B.type " +
                "ORDER BY A.create_time desc ";
        return jdbcTemplate.queryForList(sql);
    }
    public List<Map<String,Object>> getSystemMessageList(String patient,String type){
        String sql = " select id,title,type,relation_code,sender,sender_name,is_read,code,create_time " +
                "from base_system_message where receiver = '"+patient+"' and del=1 and type='"+type+"'  ORDER BY create_time desc";
        return jdbcTemplate.queryForList(sql);
    }
    public void updateMessageRead(String messageId){
        SystemMessageDO messageDO = systemMessageDao.findOne(messageId);
        messageDO.setIsRead("1");
        messageDO.setOver("1");
        systemMessageDao.save(messageDO);
    }
}

+ 350 - 267
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -8,13 +8,19 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.restmodel.emergency.EmergencyOrderVO;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -56,12 +62,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private SecurityMonitoringOrderCancelLogDao securityMonitoringOrderCancelLogDao;
    private EmergencyWarnCancelLogDao emergencyWarnCancelLogDao;
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private SecurityMonitoringOrderPatientConfirmLogDao securityMonitoringOrderPatientConfirmLogDao;
    @Autowired
    private SecurityMonitoringDoctorStatusDao doctorStatusDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
@ -70,7 +74,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private SecurityMonitoringConclusionDao securityMonitoringConclusionDao;
    private EmergencyWarnConclusionDao emergencyWarnConclusionDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
@ -87,6 +91,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private BaseTeamMemberDao baseTeamMemberDao;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private DictService dictService;
    @Autowired
    private EmergencyWarnDoctorResponseDao emergencyWarnDoctorResponseDao;
    @Autowired
    private PatientFamilyMemberService familyMemberService;
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
@ -154,21 +164,17 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
        //已取消的订单也可以申请
        boolean bool = securityMonitoringOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
                new Integer[]{SecurityMonitoringOrderDO.Status.waitForSend.getType(),
                        SecurityMonitoringOrderDO.Status.waitForArrive.getType(),
                        SecurityMonitoringOrderDO.Status.signed.getType(),
                        SecurityMonitoringOrderDO.Status.registerSummary.getType(),
                        SecurityMonitoringOrderDO.Status.waitForAdded.getType(),
                });
        if(bool){
            String failMsg = "当前服务对象存在未完成的服务,请先完成该服务!";
            result.put("resultFlag", 0);
            result.put("resultMsg", failMsg);
            logger.error(failMsg);
            return result;
        }
//        boolean bool = securityMonitoringOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
//                new Integer[]{SecurityMonitoringOrderDO.Status.apply.getType()
//                });
//        if(bool){
//            String failMsg = "当前服务对象存在未完成的服务,请先完成该服务!";
//            result.put("resultFlag", 0);
//            result.put("resultMsg", failMsg);
//            logger.error(failMsg);
//            return result;
//        }
        Map<String,Object> mapTmp = items.get(0);
        List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(mapTmp.get("team_code").toString());
        if (doctorDOS.size()==0){
@ -180,7 +186,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        orderDO.setCreateTime(new Date());
        //判断创建预警服务类型,发起类型(1本人发起 2家人待预约 3医生代预约)
        orderDO.setType(3);//发起类型
        orderDO.setType(1);//发起类型
        orderDO.setServiceStatus("2");
        this.save(orderDO);
        //创建im会话  安防警报咨询的sessionid  为居民code+(wlyy_consult_team表consult)+20
@ -211,6 +217,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    public JSONObject getSecurityOrderDetail(String orderID){
        JSONObject result = new JSONObject();
        EmergencyOrderVO emergencyOrderVO = new EmergencyOrderVO();
        SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderID);
        if (orderDO==null){
            String failMsg = "工单不存在!";
@ -219,41 +226,128 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            logger.error(failMsg);
            return result;
        }
        Integer conclusionStatus = Integer.valueOf(orderDO.getConclusionStatus()==null?"0":(orderDO.getConclusionStatus()+""));
        String conclusionStatusName = "";
        switch (conclusionStatus){
            case 1:conclusionStatusName="待补录";break;
            case 2:conclusionStatusName="已登记";break;
        BasePatientDO patientDO = basePatientDao.findById(orderDO.getPatient());
        Integer statustemp = Integer.valueOf(orderDO.getStatus()+"");
        String statusName = "";
        switch (statustemp){
            case -2:statusName="误警报";break;
            case -1:statusName="已取消";break;
            case 0:statusName="已完成";break;
            case 1:statusName="申请中";break;
        }
        emergencyOrderVO.setStatusName(statusName);
        emergencyOrderVO.setOrderId(orderID);
        emergencyOrderVO.setStatus(orderDO.getStatus());
        emergencyOrderVO.setCreateTime(orderDO.getCreateTime());
        emergencyOrderVO.setServeLat(orderDO.getServeLat());
        emergencyOrderVO.setServeLon(orderDO.getServeLon());
        emergencyOrderVO.setServeAddress(orderDO.getServeAddress());
        emergencyOrderVO.setPatient(orderDO.getPatient());
        emergencyOrderVO.setPatientName(orderDO.getPatientName());
        emergencyOrderVO.setSex(patientDO.getSex());
        if(StringUtils.isNotBlank(patientDO.getIdcard())){
            emergencyOrderVO.setAge((IdCardUtil.getAgeForIdcard(patientDO.getIdcard()))+"");
        }
        emergencyOrderVO.setLiveAddress(patientDO.getAddress());
        emergencyOrderVO.setOrderSource(orderDO.getOrderSource());
        if(orderDO.getStatus()==-2){//误报警
            emergencyOrderVO.setUpdateUserName(orderDO.getUpdateUserName());
            emergencyOrderVO.setUpdateUser(orderDO.getUpdateUser());
            emergencyOrderVO.setUpdateTime(orderDO.getUpdateTime());
            emergencyOrderVO.setEmergencyCancel(orderDO.getEmergencyCancel());
        }
        emergencyOrderVO.setUpdateTime(orderDO.getUpdateTime());
        if (orderDO.getStatus()==-1){//已取消
            emergencyOrderVO.setUpdateTime(orderDO.getCancelTime());
        }
        //小结
        Integer conclusionStatus = Integer.valueOf(orderDO.getConclusionStatus()==null?"0":(orderDO.getConclusionStatus()+""));
        if (conclusionStatus==2){
            SecurityMonitoringConclusionDO conclusionDO = securityMonitoringConclusionDao.findByOrderId(orderDO.getId());
            EmergencyWarnConclusionDO conclusionDO = emergencyWarnConclusionDao.findByOrderId(orderDO.getId());
            if (conclusionDO!=null){
                orderDO.setMonitoringConclusion(conclusionDO);
                emergencyOrderVO.setEmergencyWarnConclusionDO(conclusionDO);
            }
        }
        JSONObject jsonObject = JSON.parseObject(JSON.toJSONStringWithDateFormat(orderDO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
        jsonObject.put("conclusionStatusName",conclusionStatusName);
        Integer statustemp = Integer.valueOf(orderDO.getStatus()+"");
        String statusName = "";
        switch (statustemp){
            case -1:statusName="已取消";break;
            case 1:statusName="待处置";break;
            case 2:statusName="前往居民定位";break;
            case 3:statusName="已签到";break;
            case 4:statusName="已登记小结";break;
            case 5:statusName="待补录";break;
            case 6:statusName="待评价";break;
            case 7:statusName="已完成";break;
        //附加信息 电子围栏状态
        if (orderDO.getOrderSource()==2){
            Map<String,Object> map = new HashMap<>();
            map.put("inFenceStatus",false);
            map.put("inFenceName","疑似超出安全区域");
            emergencyOrderVO.setInformation(map);
        }
        BasePatientDO patientDO = basePatientDao.findById(orderDO.getPatient());
        if (patientDO!=null){
            jsonObject.put("patientAddress",patientDO.getAddress());
        //通知对象
        List<Map<String,Object>> noticePersons = new ArrayList<>();
        JSONArray familyArr =  familyMemberService.getPatientMembers(orderDO.getPatient(),null,null,null);
        for (int i=0;i<familyArr.size();i++){
            String patientId = familyArr.getJSONObject(i).getString("id");
            BasePatientDO patientDO1 = basePatientDao.findById(patientId);
            Map<String,Object> noticeObj = new HashMap<>();
            noticeObj.put("type","0");
            noticeObj.put("typeName","家属");
            noticeObj.put("id",patientDO1.getId());
            noticeObj.put("name",patientDO1.getName());
            noticeObj.put("photo",patientDO1.getPhoto());
            noticeObj.put("mobile",patientDO1.getMobile());
            List<Map<String,Object>> arr = new ArrayList<>();
            Map<String,Object> tmp = new HashMap<>();
            tmp.put("name","系统预警");
            tmp.put("status",0);
            SystemMessageDO messageDO = systemMessageDao.findByRelationCodeAndReceiver(orderDO.getId(),patientId);
            if (messageDO != null){
                if (StringUtils.isNotBlank(messageDO.getIsRead())){
                    tmp.put("status",Integer.parseInt(messageDO.getIsRead()));
                }
            }
            arr.add(tmp);
            noticeObj.put("response",arr);
            noticePersons.add(noticeObj);
        }
        else {
            jsonObject.put("patientAddress",null);
        //医生信息
        String sql ="SELECT i.code,i.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+orderDO.getPatient()+"' and i.code='preventLost' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
        if (items.size()>0){
            Map<String,Object> mapTmp = items.get(0);
            List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(mapTmp.get("team_code").toString());
            JSONArray otherDoctorDistance = new JSONArray();
            JSONObject otherDoctorDistanceObj = new JSONObject();
            for(BaseDoctorDO doc:doctorDOS){
                Map<String,Object> noticeObj = new HashMap<>();
                noticeObj.put("type","1");
                noticeObj.put("typeName","助老员");
                noticeObj.put("id",doc.getId());
                noticeObj.put("name",doc.getName());
                noticeObj.put("photo",doc.getPhoto());
                noticeObj.put("mobile",doc.getMobile());
                List<Map<String,Object>> arr = new ArrayList<>();
                Map<String,Object> tmp = new HashMap<>();
                tmp.put("name","系统预警");
                tmp.put("status",0);
                if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doc.getId(),orderDO.getId())!=null){
                    tmp.put("status",1);
                }
                arr.add(tmp);
                noticeObj.put("response",arr);
                noticePersons.add(noticeObj);
                if (StringUtils.isBlank(doc.getDoctorLat()) || StringUtils.isBlank(doc.getDoctorLon())) {
                    continue;
                }
                otherDoctorDistanceObj = new JSONObject();
                otherDoctorDistanceObj.put("doctor",doc.getId());
                otherDoctorDistanceObj.put("doctorName",doc.getName());
                otherDoctorDistanceObj.put("doctorAddress",doc.getDoctorLocateAddress());
                otherDoctorDistanceObj.put("doctorLon",doc.getDoctorLon());
                otherDoctorDistanceObj.put("doctorLat",doc.getDoctorLat());
                otherDoctorDistanceObj.put("distance",doc);//两点距离
                otherDoctorDistance.add(otherDoctorDistanceObj);
            }
            emergencyOrderVO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
        }
        jsonObject.put("statusName",statusName);
        JSONObject jsonObject = JSON.parseObject(JSON.toJSONStringWithDateFormat(emergencyOrderVO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
        //获取咨询
        ConsultDo consult = consultDao.queryByRelationCode(orderID);
        if (null != consult) {
@ -270,6 +364,28 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    }
    public JSONObject errorWarning(String orderId,Integer emergencyCancel,String doctor){
        JSONObject result = new JSONObject();
        SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderId);
        if (orderDO==null){
            String failMsg = "工单不存在!";
            result.put("resultFlag", 0);
            result.put("resultMsg", failMsg);
            logger.error(failMsg);
            return result;
        }
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
        orderDO.setCancelTime(new Date());
        orderDO.setUpdateTime(new Date());
        orderDO.setUpdateUserName(doctorDO.getName());
        orderDO.setUpdateUser(doctorDO.getId());
        orderDO.setEmergencyCancel(emergencyCancel);
        securityMonitoringOrderDao.save(orderDO);
        result = getSecurityOrderDetail(orderId);
        return result;
    }
    public JSONArray getSecurityOrderList(String doctor,String serverDoctor,String patientName, String patient, String status, Integer page, Integer pageSize){
        String sql = " select p.id patientCode,p.name,p.sex,p.photo,p.idcard,ord.id orderId,ord.number,ord.serve_desc,ord.create_time,ord.`status`,ord.doctor," +
                "ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
@ -323,14 +439,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            Integer statustemp = Integer.valueOf(one.get("status")+"");
            String statusName = "";
            switch (statustemp){
                case -2:statusName="误警报";break;
                case -1:statusName="已取消";break;
                case 1:statusName="待处置";break;
                case 2:statusName="前往居民定位";break;
                case 3:statusName="已签到";break;
                case 4:statusName="已登记小结";break;
                case 5:statusName="待补录";break;
                case 6:statusName="待评价";break;
                case 7:statusName="已完成";break;
                case 0:statusName="已完成";break;
                case 1:statusName="申请中";break;
            }
            tmp.put("statusName",statusName);
            result.add(tmp);
@ -351,7 +463,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        List<Map<String,Object>> result = new ArrayList<>();
        String sql = " select p.id patientCode,p.name,p.sex,p.idcard,p.photo,ord.id orderId,ord.number,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`,ord.doctor," +
                "ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
                "where ord.status <>-1 and ord.status<> 7  ";
                "where ord.status <>-1 and ord.status<>0  ";
        sql+= "and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                "base_team_member m " +
                "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
@ -371,8 +483,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    /**
     * 系统更新医生上门服务工单状态
     * 系统更新医生工单状态
     * @param doctor
     * @param dispatchOrderStatus
     */
@ -399,24 +513,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        if (null == doorServiceOrder) {
            throw new Exception("该工单不存在");
        }
        doorServiceOrder.setStatus(SecurityMonitoringOrderDO.Status.waitForArrive.getType()); //
        this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 3);//待服务
        doorServiceOrder.setServiceResponseTime(new Date());
        //新增工单医生关联关系
//        JSONObject jsonObjectParam = new JSONObject();
//        JSONObject doc = new JSONObject();
//        doc.put("doctor",doorServiceOrder.getDoctor());
//        doc.put("doctorName",doorServiceOrder.getDoctorName());
//        doc.put("hospitalLevel",hospitalLevel);
//        doc.put("doctorJobCode",jobCode);
//        doc.put("doctorJobName",jobCodeName);
//        JSONArray docArr = new JSONArray();
//        docArr.add(doc);
//        jsonObjectParam.put("doctorArr",docArr);
        // 无费用
//        if (wlyyDoorServiceOrderService.orderWithDoctorAdd(new JSONObject(), jsonObjectParam, doorServiceOrder)) return null;
//        doorServiceOrder.setStatus(SecurityMonitoringOrderDO.Status.waitForArrive.getType()); //
//        this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 3);//待服务
//        doorServiceOrder.setServiceResponseTime(new Date());
        securityMonitoringOrderDao.save(doorServiceOrder);
@ -452,84 +551,65 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject acceptOrder(String orderId,String doctor) throws Exception {
        JSONObject result = new JSONObject();
        SecurityMonitoringOrderDO doorServiceOrderDO = securityMonitoringOrderDao.findOne(orderId);
        if(null == doorServiceOrderDO){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前工单不存在,id:" + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        if (doorServiceOrderDO.getStatus()!=1){//待处置工单才可进行接单操作
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前工单已被取消或接收:" + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        SecurityMonitoringDoctorStatusDo doctorStatusDo = doctorStatusDao.findByDoctor(doctor);
        BaseDoctorDO doctorVO = baseDoctorDao.findById(doctor);
        if (null == doctorStatusDo) {
            doctorStatusDo =new SecurityMonitoringDoctorStatusDo();
            doctorStatusDo.setDoctor(doctor);
            doctorStatusDo.setStatus(2);
            doctorStatusDo.setCreateTime(new Date());
            doctorStatusDo.setCreateUser(doctor);
            doctorStatusDo.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
            doctorStatusDao.save(doctorStatusDo);
        }
        SecurityMonitoringDoctorStatusDo doorDoctorStatusDO = doctorStatusDao.queryByDoctorAndStatusIn(doctor,new Integer[]{SecurityMonitoringDoctorStatusDo.Status.waitForSend.getType(),
                SecurityMonitoringDoctorStatusDo.Status.waitForAccept.getType(),
                SecurityMonitoringDoctorStatusDo.Status.waitForServe.getType(),
                SecurityMonitoringDoctorStatusDo.Status.serving.getType(),
        });
        if(null == doorDoctorStatusDO){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前接单的医生不存在或禁止接单,doctor:" + doctor;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        BaseDoctorDO doctorDO= baseDoctorDao.findById(doctor);
        doorServiceOrderDO.setDoctor(doctor);
        doorServiceOrderDO.setDoctorName(doctorDO.getName());
        doorServiceOrderDO.setDoctorType("医生");
        doorServiceOrderDO.setStatus(SecurityMonitoringOrderDO.Status.waitForArrive.getType());//前往居民定位
        doorServiceOrderDO.setUpdateUser(doctor);
        doorServiceOrderDO.setUpdateUserName(doctorDO.getName());
        securityMonitoringOrderDao.save(doorServiceOrderDO);
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        //TODO 接单时创建两个人聊天
//        ConsultDo consult = consultDao.queryByRelationCode(orderId);
//        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
//        imUtill.updateParticipantNew(sessionId,doctor,null);
        // 工单状态变更记录
//        WlyyDoorProcessLogDO processLogDO = new WlyyDoorProcessLogDO();
//        processLogDO.setOrderId(orderId);
//        processLogDO.setStatus(WlyyDoorServiceOrderDO.Status.waitForAccept.getType());
//        processLogDO.setDispatcher(dispatcher);
//        processLogDO.setDispatcherName(dispathcherName);
//        processLogDO.setCreateTime(new Date());
//        wlyyDoorProcessLogDao.save(processLogDO);
        // 发送IM消息通知患者医生已派单
//        String noticeContent = "已转派"+doorServiceOrderDO.getDoctorName()+"医生为您服务,请耐心等待医生接单";
//        this.qucikSendIM(doorServiceOrderDO.getId(), dispatcher, "智能助手","1", noticeContent);
        SecurityMonitoringOrderDO doorServiceOrder = acceptOrder1(orderId, doctor);
        if(doorServiceOrder==null){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前接单的医生不存在或禁止接单,doctor:" + doctor;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
//        JSONObject result = new JSONObject();
//        SecurityMonitoringOrderDO doorServiceOrderDO = securityMonitoringOrderDao.findOne(orderId);
//        if(null == doorServiceOrderDO){
//            result.put(ResponseContant.resultFlag, ResponseContant.fail);
//            String failMsg = "当前工单不存在,id:" + orderId;
//            result.put(ResponseContant.resultMsg, failMsg);
//            logger.error(failMsg);
//            return result;
//        }
//        if (doorServiceOrderDO.getStatus()!=1){//待处置工单才可进行接单操作
//            result.put(ResponseContant.resultFlag, ResponseContant.fail);
//            String failMsg = "当前工单已被取消或接收:" + orderId;
//            result.put(ResponseContant.resultMsg, failMsg);
//            logger.error(failMsg);
//            return result;
//        }
//        SecurityMonitoringDoctorStatusDo doctorStatusDo = doctorStatusDao.findByDoctor(doctor);
//        BaseDoctorDO doctorVO = baseDoctorDao.findById(doctor);
//        if (null == doctorStatusDo) {
//            doctorStatusDo =new SecurityMonitoringDoctorStatusDo();
//            doctorStatusDo.setDoctor(doctor);
//            doctorStatusDo.setStatus(2);
//            doctorStatusDo.setCreateTime(new Date());
//            doctorStatusDo.setCreateUser(doctor);
//            doctorStatusDo.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
//            doctorStatusDao.save(doctorStatusDo);
//        }
//
//        SecurityMonitoringDoctorStatusDo doorDoctorStatusDO = doctorStatusDao.queryByDoctorAndStatusIn(doctor,new Integer[]{SecurityMonitoringDoctorStatusDo.Status.waitForSend.getType(),
//                SecurityMonitoringDoctorStatusDo.Status.waitForAccept.getType(),
//                SecurityMonitoringDoctorStatusDo.Status.waitForServe.getType(),
//                SecurityMonitoringDoctorStatusDo.Status.serving.getType(),
//        });
//        if(null == doorDoctorStatusDO){
//            result.put(ResponseContant.resultFlag, ResponseContant.fail);
//            String failMsg = "当前接单的医生不存在或禁止接单,doctor:" + doctor;
//            result.put(ResponseContant.resultMsg, failMsg);
//            logger.error(failMsg);
//            return result;
//        }
//        BaseDoctorDO doctorDO= baseDoctorDao.findById(doctor);
//        doorServiceOrderDO.setDoctor(doctor);
//        doorServiceOrderDO.setDoctorName(doctorDO.getName());
//        doorServiceOrderDO.setDoctorType("医生");
//        doorServiceOrderDO.setStatus(SecurityMonitoringOrderDO.Status.waitForArrive.getType());//前往居民定位
//        doorServiceOrderDO.setUpdateUser(doctor);
//        doorServiceOrderDO.setUpdateUserName(doctorDO.getName());
//        securityMonitoringOrderDao.save(doorServiceOrderDO);
//
//
//        SecurityMonitoringOrderDO doorServiceOrder = acceptOrder1(orderId, doctor);
//        if(doorServiceOrder==null){
//            result.put(ResponseContant.resultFlag, ResponseContant.fail);
//            String failMsg = "当前接单的医生不存在或禁止接单,doctor:" + doctor;
//            result.put(ResponseContant.resultMsg, failMsg);
//            logger.error(failMsg);
//            return result;
//        }
        result = getSecurityOrderDetail(orderId);
        // 发送微信模板消息通知患者医生已接单
//        BasePatientDO patient = basePatientDao.findById(doorServiceOrder.getPatient());//
@ -551,9 +631,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
//            logger.error(e.getMessage());
//        }
        //  待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678
        messageUtil.createMessage("医生接单","634",doorServiceOrder.getPatient(),doorServiceOrder.getPatientName(),
                doorServiceOrder.getId(), doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName() ,null, doorServiceOrder.getDoctorName() + "接受了服务工单"+ doorServiceOrder.getNumber());
        return result;
//        messageUtil.createMessage("医生接单","634",doorServiceOrder.getPatient(),doorServiceOrder.getPatientName(),
//                doorServiceOrder.getId(), doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName() ,null, doorServiceOrder.getDoctorName() + "接受了服务工单"+ doorServiceOrder.getNumber());
        return getSecurityOrderDetail(orderId);
    }
@ -582,8 +662,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            logger.error(failMsg);
            return result;
        }
        if(orderDO.getStatus() > SecurityMonitoringOrderDO.Status.waitForSend.getType()){
            String failMsg = "只有医生接单前的工单才可取消";
        if(orderDO.getStatus() != SecurityMonitoringOrderDO.Status.complete.getType()){
            String failMsg = "当前工单已结束";
            result.put("resultFlag", 0);
            result.put("resultMsg", failMsg);
            logger.error(failMsg);
@ -609,25 +689,13 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
        //保存取消记录
        SecurityMonitoringOrderCancelLog cancelLogDO = new SecurityMonitoringOrderCancelLog();
        EmergencyWarnCancelLogDO cancelLogDO = new EmergencyWarnCancelLogDO();
        cancelLogDO.setOrderId(orderId);
        cancelLogDO.setPatient(orderDO.getPatient());
        cancelLogDO.setCancelType(type);
        cancelLogDO.setCancelReason(reason);
        cancelLogDO.setTime(orderDO.getCancelTime());
        securityMonitoringOrderCancelLogDao.save(cancelLogDO);
        //保存居民确认取消记录
        JSONObject confirmInfo = new JSONObject();
        confirmInfo.put("orderId",orderId);
        confirmInfo.put("patient",orderDO.getPatient());
        confirmInfo.put("patientName",orderDO.getPatientName());
        confirmInfo.put("type",4);
        confirmInfo.put("description",reason);
        JSONObject confirmInfoJson = new JSONObject();
        confirmInfoJson.put("confirmInfo",confirmInfo);
        this.orderWithConfirmLogAdd(result,confirmInfo,orderId);
        emergencyWarnCancelLogDao.save(cancelLogDO);
//        Consult consult = consultDao.queryByRelationCode(orderId);
//        // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
@ -652,36 +720,6 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    @Transactional(rollbackFor = Exception.class)
    public boolean orderWithConfirmLogAdd(JSONObject result, JSONObject jsonObjectParam, String orderId) {
        // 确认信息
        JSONObject confirmInfo = jsonObjectParam.getJSONObject("confirmInfo");
        if (null != confirmInfo) {
            SecurityMonitoringOrderPatientConfirmLog confirmLogDO = null;
            try {
                confirmLogDO = EntityUtils.jsonToEntity(confirmInfo.toString(), SecurityMonitoringOrderPatientConfirmLog.class);
            } catch (Exception e) {
                String failMsg = "工单关联【居民确认操作日志记录】时出错";
                result.put("resultFlag", 0);
                result.put("resultMsg", failMsg);
                logger.error(failMsg);
                return true;
            }
            confirmLogDO.setOrderId(orderId);
            confirmLogDO.setCreateTime(new Date());
            try {
                securityMonitoringOrderPatientConfirmLogDao.save(confirmLogDO);
            } catch (Exception e) {
                String failMsg = "保存工单关联的【居民确认操作日志记录】时出错";
                result.put("resultFlag", 0);
                result.put("resultMsg", failMsg);
                logger.error(failMsg);
                return true;
            }
        }
        return false;
    }
    /**
     * 签到保存
     * @param orderId
@ -693,7 +731,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
     */
    public JSONObject signIn(String orderId, String signTime, Integer signWay, String signLocation,
                                         String signImg, String twoDimensionalCode,String doctorId) throws Exception {
        SecurityMonitoringOrderDO doorServiceOrder = securityMonitoringOrderDao.findOne(orderId);
       /* SecurityMonitoringOrderDO doorServiceOrder = securityMonitoringOrderDao.findOne(orderId);
        doorServiceOrder.setDoctorSignTime(DateUtil.strToDate(signTime));
        doorServiceOrder.setDoctorSignWay(signWay);
        // 签到方式-2扫码时,需要去解析地址
@ -717,8 +755,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            doorServiceOrder = securityMonitoringOrderDao.save(doorServiceOrder);
            // 修改医生上门服务工单状态 4服务中
            this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 4);
            return getSecurityOrderDetail(orderId);
        }
        }*/
        return getSecurityOrderDetail(orderId);
    }
    /**
@ -737,7 +777,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
     * @return
     * @throws Exception
     */
    public JSONObject updateDoorConclusion(Integer manageStatus,String orderId,String conclusion,Integer examPapeStatus) throws Exception {
    public JSONObject updateDoorConclusion(Integer emergency_reason,Integer treatment_status,String orderId,String conclusion,String conclusion_img) throws Exception {
        JSONObject result = new JSONObject();
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
@ -748,17 +788,19 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            result.put("resultMsg", failMsg);
            return result;
        }
        SecurityMonitoringConclusionDO doorConclusion =  securityMonitoringConclusionDao.findByOrderId(orderId);
        EmergencyWarnConclusionDO doorConclusion =  emergencyWarnConclusionDao.findByOrderId(orderId);
        if (doorConclusion==null){
            doorConclusion = new SecurityMonitoringConclusionDO();
            doorConclusion = new EmergencyWarnConclusionDO();
            doorConclusion.setOrderId(orderId);
            doorConclusion.setPatient(one.getPatient());
            doorConclusion.setPatientName(one.getPatientName());
            doorConclusion.setDoctor(one.getDoctor());
            doorConclusion.setDoctorName(one.getDoctorName());
        }
        doorConclusion.setStatus(manageStatus);
        doorConclusion.setEmergencyReason(emergency_reason);
        doorConclusion.setEmergencyTreatmentStatus(treatment_status);
        doorConclusion.setConclusion(conclusion);
        doorConclusion.setConclusionImg(conclusion_img);
        BaseDoctorDO doctorVO = baseDoctorDao.findById(one.getDoctor());
        if (doorConclusion != null && org.apache.commons.lang.StringUtils.isNotEmpty(doorConclusion.getId())) {
            doorConclusion.setUpdateTime(new Date());
@ -770,12 +812,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            doorConclusion.setCreateUser(one.getDoctor());
            doorConclusion.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
        }
        securityMonitoringConclusionDao.save(doorConclusion);
        // 设置是否需要上传补录报告
        if (!(one.getStatus()==SecurityMonitoringOrderDO.Status.complete.getType())){
            one.setStatus(SecurityMonitoringOrderDO.Status.registerSummary.getType());//已登记服务小结
        if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
            String failMsg = "咨询结束失败 无法结束工单";
            throw new Exception(failMsg);
        }
        one.setExamPaperStatus(examPapeStatus);
        emergencyWarnConclusionDao.save(doorConclusion);
        one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());//已完成
        one.setConclusionStatus(2);
        securityMonitoringOrderDao.save(one);
        return getSecurityOrderDetail(orderId);
@ -785,7 +827,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
     * 跳过登记服务小结
     * @param orderId
     */
    public JSONObject cancelConclusion(String orderId) {
    public JSONObject cancelConclusion(String orderId) throws Exception {
        JSONObject result = new JSONObject();
        SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
        if (one==null){
@ -794,12 +836,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            result.put("resultMsg", failMsg);
            return result;
        }
        if (one.getStatus()==SecurityMonitoringOrderDO.Status.complete.getType()){//修改工单记录
            securityMonitoringOrderDao.updateConclusionStatus2(orderId);
        }
        else {
            securityMonitoringOrderDao.updateConclusionStatus(orderId);
        if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
            String failMsg = "咨询结束失败 无法结束工单";
            throw new Exception(failMsg);
        }
        securityMonitoringOrderDao.updateConclusionStatus(orderId);
        return getSecurityOrderDetail(orderId);
    }
@ -820,67 +861,41 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
     * @param orderId
     * @return
     */
    public SecurityMonitoringConclusionDO getDoorConclusion(String orderId){
        SecurityMonitoringConclusionDO doorConclusion = securityMonitoringConclusionDao.findByOrderId(orderId);
    public EmergencyWarnConclusionDO getDoorConclusion(String orderId){
        EmergencyWarnConclusionDO doorConclusion = emergencyWarnConclusionDao.findByOrderId(orderId);
        SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
        if (doorConclusion==null&&one!=null) {
            doorConclusion = new SecurityMonitoringConclusionDO();
            doorConclusion = new EmergencyWarnConclusionDO();
            doorConclusion.setOrderId(one.getId());
            doorConclusion.setPatient(one.getPatient());
            doorConclusion.setPatientName(one.getPatientName());
            doorConclusion.setDoctor(one.getDoctor());
            doorConclusion.setDoctorName(one.getDoctorName());
        }else {
            doorConclusion.setReasonName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_REASON,String.valueOf(doorConclusion.getEmergencyReason())));
            doorConclusion.setTreatmentStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_TREATMENT_STATUS,String.valueOf(doorConclusion.getEmergencyTreatmentStatus())));
        }
        return doorConclusion;
    }
    public JSONObject saveOrderFinishBydoctor(String orderId ,String finishImg) throws Exception {
        SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
        one.setDoctorConfirmFinishImg(finishImg);
        one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());
        one.setDoctorConfirmFinishTime(new Date());
        one.setCompleteTime(one.getDoctorConfirmFinishTime());
        // 更新记录
        this.setUpdateColumnInfo(one);
        if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
            String failMsg = "咨询结束失败 无法结束工单";
            throw new Exception(failMsg);
        }
        securityMonitoringOrderDao.save(one);
        SecurityMonitoringOrderDO doorServiceOrderDO = this.getDoorServiceOrderById(orderId);
        // 发送微信通知  待付款
        BasePatientDO patient = basePatientDao.findById(one.getPatient());
//        SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
//        one.setDoctorConfirmFinishImg(finishImg);
//        one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());
//        one.setDoctorConfirmFinishTime(new Date());
//        one.setCompleteTime(one.getDoctorConfirmFinishTime());
//        // 更新记录
//        this.setUpdateColumnInfo(one);
//        if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
//            String failMsg = "咨询结束失败 无法结束工单";
//            throw new Exception(failMsg);
//        }
//        securityMonitoringOrderDao.save(one);
//        SecurityMonitoringOrderDO doorServiceOrderDO = this.getDoorServiceOrderById(orderId);
//
//        // 发送微信通知  待付款
//        BasePatientDO patient = basePatientDao.findById(one.getPatient());
        // 获取微信模板 smfwdwk-上门服务待付款
//        Consult consult = consultDao.queryByRelationCode(orderId);
        try {
//            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","fwyspf");
//            String first = templateConfig.getFirst();
//            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
//            first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
//            org.json.JSONObject json = new org.json.JSONObject();
//            json.put("first", first);
//            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
//            json.put("keyword2", "服务医生评分");
//            json.put("url", templateConfig.getUrl());
//            json.put("remark", templateConfig.getRemark());
//            json.put("id",orderId);
//            //json.put("consult",consult.getCode());
//            WlyyDoorCommentDO wlyyDoorCommentDO = this.DoorCommentDao.selectCommentDoctor(patient.getCode(),orderId);
//            String finish="";
//            if(wlyyDoorCommentDO!=null){
//                finish = "0";
//                json.put("finish",finish);
//            }else {
//                finish = "1";
//                json.put("finish",finish);
//            }
//            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return getSecurityOrderDetail(orderId);
    }
@ -910,8 +925,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        // 设置服务小结
        SecurityMonitoringConclusionDO doorConclusion = this.getDoorConclusion(id);
        doorServiceOrder.setMonitoringConclusion(doorConclusion);
        EmergencyWarnConclusionDO doorConclusion = this.getDoorConclusion(id);
        doorServiceOrder.setEmergencyWarnConclusionDO(doorConclusion);
        return doorServiceOrder;
@ -1002,6 +1017,74 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    public JSONObject updateDoctorLocation(String doctor,String orderId,String doctorAddress,String doctorLat,String doctorLon){
        JSONObject result = new JSONObject();
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
        if (doctorDO==null){
            String failMsg = "当前医生不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        else {
            doctorDO.setDoctorLocateAddress(doctorAddress);
            doctorDO.setDoctorLat(doctorLat);
            doctorDO.setDoctorLon(doctorLon);
            baseDoctorDao.save(doctorDO);
            result.put(ResponseContant.resultFlag, ResponseContant.success);
        }
        return result;
    }
    public JSONObject updatePatientLocation(String patient,String patientAddress,String patientLat,String patientLon){
        JSONObject result = new JSONObject();
        BasePatientDO patientDO = basePatientDao.findById(patient);
        if (patientDO==null){
            String failMsg = "患者不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        List<SecurityMonitoringOrderDO> monitoringOrderDO = securityMonitoringOrderDao.findByPatientAndStatus(patient,1);
        if (monitoringOrderDO.size()>0){
            for (SecurityMonitoringOrderDO tmp:monitoringOrderDO){
                tmp.setServeAddress(patientAddress);
                tmp.setServeLat(patientLat);
                tmp.setServeLon(patientLon);
                securityMonitoringOrderDao.save(monitoringOrderDO);
            }
            result.put(ResponseContant.resultFlag, ResponseContant.success);
        }
        else {
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg,null);
        }
        return result;
    }
    public JSONObject responseOrder(String orderId,String doctor){
        JSONObject result = new JSONObject();
        SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
        if (one==null){
            String failMsg = "工单不存在" ;
            result.put("resultFlag", 0);
            result.put("resultMsg", failMsg);
            return result;
        }
        if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doctor,orderId)==null){
            EmergencyWarnDoctorResponseDO responseDO = new EmergencyWarnDoctorResponseDO();
            responseDO.setOrderId(orderId);
            responseDO.setDoctor(doctor);
            responseDO.setResponseTime(new Date());
            emergencyWarnDoctorResponseDao.save(responseDO);
        }
        result.put("resultFlag", 1);
        result.put("resultMsg", "success");
        return result;
    }
    private String getRandomIntStr(){
        Random rand = new Random();
        int i = rand.nextInt(); //int范围类的随机数

+ 6 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/ConstantUtil.java

@ -40,6 +40,9 @@ public class ConstantUtil {
     emergency_assistance_message //紧急救助快速消息
     emergency_assistance_call //紧急救助快速呼叫
     foodClassification 食物分类
     emergency_reason //紧急预警工单发起原因
     emergency_treatment_status //紧急预警工单处理结果
     emergency_cancel //紧急预警工单取消状态
     */
    public static final String DICT_ARCHIVETYPE = "archiveType";
    public static final String DICT_ARCHIVESTATUS = "archiveStatus";
@ -58,6 +61,9 @@ public class ConstantUtil {
    public static final String DICT_EMERGENCY_ASSISTANCE_MESSAGE= "emergency_assistance_message";
    public static final String DICT_EMERGENCY_ASSISTANCE_CALL= "emergency_assistance_call";
    public static final String DICT_FOODCLASSIFICATION= "foodClassification";
    public static final String DICT_EMERGENCY_REASON = "emergency_reason";
    public static final String DICT_EMERGENCY_TREATMENT_STATUS= "emergency_treatment_status";
    public static final String DICT_EMERGENCY_CANCEL= "emergency_cancel";
}